Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert library code to TypeScript #762

Merged
merged 307 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
307 commits
Select commit Hold shift + click to select a range
3bdec40
Add common HTTP types
owenpearson Sep 30, 2021
b5438ce
Improve node HTTP typings
owenpearson Sep 30, 2021
8a30a22
Improve browser HTTP typings
owenpearson Sep 30, 2021
b903da7
Merge pull request #794 from ably/feature/types-typescript
owenpearson Oct 4, 2021
ea6c528
Merge pull request #795 from ably/feature/multicaster-typescript
owenpearson Oct 4, 2021
2060cb3
Merge pull request #798 from ably/feature/defaults-typescript
owenpearson Oct 4, 2021
f9a82df
Rename idx to index
owenpearson Oct 6, 2021
516ee19
Rename ev to eventName
owenpearson Oct 6, 2021
6f0aea0
Remove unnecessary comment
owenpearson Oct 6, 2021
32f8d04
Refactor EventEmitter overloaded methods
owenpearson Oct 6, 2021
7e9cf2f
Fix error in EventEmitter.off
owenpearson Oct 6, 2021
a2ff3c8
Add comments explaining placeholder types
owenpearson Oct 6, 2021
9af7d81
Rename ops to operations
owenpearson Oct 6, 2021
bd3e89e
Replace noop assignment with optional chaining
owenpearson Oct 6, 2021
a9cc689
Use strict equals in node Http
owenpearson Oct 6, 2021
6a496a8
Use strict equals in browser Http
owenpearson Oct 6, 2021
a3f429b
Use strict equals in node Http
owenpearson Oct 6, 2021
16c996d
Rename err to errorInfo
owenpearson Oct 6, 2021
5ccf130
Improve errorinfo and http error typings
owenpearson Oct 6, 2021
640a7f0
Add HttpStatusCodes enum
owenpearson Oct 6, 2021
e064528
Fix another bug in EventEmitter.off
owenpearson Oct 7, 2021
7f36f9c
Merge branch 'feature/event-emitter-typescript' into feature/http-typ…
owenpearson Oct 7, 2021
a9db3e7
Remove `extends Error` from ErrorInfo
owenpearson Oct 7, 2021
92629ae
Fix a bug with callback args in browser Http
owenpearson Oct 7, 2021
d7a2b55
Fix bug with callback args in node Http
owenpearson Oct 7, 2021
a30d2e3
Merge branch 'main' into integration/typescript
owenpearson Oct 7, 2021
339c387
Merge branch 'integration/typescript' into feature/event-emitter-type…
owenpearson Oct 7, 2021
da57b17
Merge branch 'feature/event-emitter-typescript' into feature/http-typ…
owenpearson Oct 7, 2021
2c373f7
Merge pull request #799 from ably/feature/event-emitter-typescript
owenpearson Oct 7, 2021
9e1844c
Fix errant typecheck in node http checkConnectivity
owenpearson Oct 7, 2021
f29ceda
Merge pull request #800 from ably/feature/http-typescript
owenpearson Oct 7, 2021
be27d06
Rename connectionerror.js to connectionerror.ts
owenpearson Oct 7, 2021
6f38162
Convert connectionerror to TypeScript
owenpearson Oct 7, 2021
bd7718b
Rename transport.js to transport.ts
owenpearson Oct 7, 2021
b4100bc
Fix typing in EventEmitter
owenpearson Oct 7, 2021
244207f
Add globals.d.ts for clearTimeout typing
owenpearson Oct 7, 2021
e5335ec
Convert transport.ts to TypeScript
owenpearson Oct 7, 2021
ea44064
Remove Transport.onAuthUpdated
owenpearson Oct 7, 2021
c58b8ad
npm i @types/ws
owenpearson Oct 7, 2021
a872e53
Fix platform typings
owenpearson Oct 7, 2021
ec05a96
Rename websockettransport.js to websockettransport.ts
owenpearson Oct 7, 2021
2bd92c1
Convert websockettransport to TypeScript
owenpearson Oct 7, 2021
bfabac8
Make calls to Transport.onAuthUpdated optional
owenpearson Oct 7, 2021
ece6743
Merge branch 'feature/transport-typescript' into feature/fix-platform…
owenpearson Oct 7, 2021
3f7511b
Merge branch 'feature/fix-platform-typings' into feature/websockettra…
owenpearson Oct 7, 2021
125eeb7
Rename webstorage.js to webstorage.ts
owenpearson Oct 8, 2021
d6f06f4
Convert webstorage to TypeScript
owenpearson Oct 8, 2021
1b1f482
Add platform-webstorage module declaration
owenpearson Oct 8, 2021
9ce4ad3
Add ambient module declaration for platform-http
owenpearson Oct 8, 2021
2fad413
Add ambient module declaration for platform-base64
owenpearson Oct 8, 2021
a36d565
Add module declaration for crypto-js hmac-sha256
owenpearson Oct 8, 2021
2e9304a
Rename auth.js to auth.ts
owenpearson Oct 8, 2021
b16e5b0
Add TokenDetails type
owenpearson Oct 8, 2021
19a0522
Add TokenParams type
owenpearson Oct 8, 2021
f8ebc3c
Add StandardCallback type
owenpearson Oct 8, 2021
d6522f2
Convert Auth to TypeScript
owenpearson Oct 8, 2021
adc66b8
Replace Auth placeholder type
owenpearson Oct 8, 2021
342e56a
Rename ConnectionError to ConnectionErrors
owenpearson Oct 11, 2021
e9833d9
Improve clarity of Transport event types comment
owenpearson Oct 11, 2021
5ad2c1d
Remove unnecessary conditional around calling of connectionManager.on…
owenpearson Oct 11, 2021
4cebdcb
Remove unnecessary Logger.shouldLog
owenpearson Oct 11, 2021
290df5d
Improve clarity of Transport.disconnect comment
owenpearson Oct 11, 2021
1b5b56d
Update TokenParams type to match IDL spec
owenpearson Oct 11, 2021
f187e84
Update TokenDetails type to match IDL spec
owenpearson Oct 11, 2021
b1ad152
Add check for wsConnection undefined in WebSocketTransport.dispose
owenpearson Oct 12, 2021
b5e5ac4
Convert webstorage from static class to regular ES6 module
owenpearson Oct 12, 2021
75a7644
Merge pull request #807 from ably/feature/connectionerror-typescript
owenpearson Oct 12, 2021
86c8571
Re-add necessary Logger.shouldLog call
owenpearson Oct 12, 2021
51a4d78
Merge branch 'integration/typescript' into feature/transport-typescript
owenpearson Oct 12, 2021
5fc188e
Merge pull request #808 from ably/feature/transport-typescript
owenpearson Oct 12, 2021
38318c0
Merge pull request #809 from ably/feature/fix-platform-typings
owenpearson Oct 12, 2021
a564b18
Merge pull request #811 from ably/feature/webstorage-typescript
owenpearson Oct 12, 2021
c90cf53
Merge pull request #812 from ably/feature/http-module-declaration
owenpearson Oct 12, 2021
e95e7c8
Merge pull request #813 from ably/feature/base64-module-declaration
owenpearson Oct 12, 2021
e1ffea0
Merge pull request #814 from ably/feature/hmac-sha256-typing
owenpearson Oct 12, 2021
d5726d9
Fix error in realtime Auth.requestToken
owenpearson Oct 12, 2021
9125309
Merge branch 'integration/typescript' into feature/auth-typescript
owenpearson Oct 12, 2021
1b59857
Merge pull request #810 from ably/feature/websockettransport-typescript
owenpearson Oct 13, 2021
c955da6
Fix failing promise auth test
owenpearson Oct 14, 2021
d37ade5
Merge pull request #815 from ably/feature/auth-typescript
owenpearson Oct 14, 2021
9b3386a
Merge branch 'main' into integration/typescript
owenpearson Oct 14, 2021
56dd0b7
Rename xhrrequest.js to xhrrequest.ts
owenpearson Oct 14, 2021
cdf7a54
Add common XHRRequest interface
owenpearson Oct 14, 2021
5bd09ce
Convert xhrrequest to TypeScript
owenpearson Oct 14, 2021
c1b9d0d
Rename comettransport.js to comettransport.ts
owenpearson Oct 14, 2021
d402ab4
Convert CometTransport to TypeScript
owenpearson Oct 14, 2021
9c4168b
Rename messagequeue.js to messagequeue.ts
owenpearson Oct 14, 2021
a40958b
Convert MessageQueue to TypeScript
owenpearson Oct 14, 2021
2f427b7
Rename protocol.js to protocol.ts
owenpearson Oct 14, 2021
f57073b
Convert Protocol to TypeScript
owenpearson Oct 14, 2021
605dd90
Replace type alias for PendingMessage
owenpearson Oct 14, 2021
45afb95
Rename connectionstatechange.js to connectionstatechange.ts
owenpearson Oct 14, 2021
c296f25
Convert ConnectionStateChange to TypeScript
owenpearson Oct 14, 2021
34528f0
Rename errorreporter.js to errorreporter.ts
owenpearson Oct 14, 2021
2940eca
Convert ErrorReporter to TypeScript
owenpearson Oct 14, 2021
a57c8a7
Add ambient module declaration for platform-transports
owenpearson Oct 14, 2021
51e4f7f
Rename connectionmanager.js to connectionmanager.ts
owenpearson Oct 14, 2021
cfcc459
Convert ConnectionManager to TypeScript
owenpearson Oct 14, 2021
0a7efc9
Replace type aliases for converted modules
owenpearson Oct 14, 2021
b2df827
Fix error in CometTransport constructor
owenpearson Oct 18, 2021
e1be792
Remove module wrapper around bufferutils
owenpearson Oct 20, 2021
03fcb48
Fix param reassignment in XhrRequest.createRequest
owenpearson Oct 20, 2021
f3eb8af
Add comment to accept header logic in xhrrequest
owenpearson Oct 20, 2021
f9d1e3d
Improve readability of comettransport constructor
owenpearson Oct 20, 2021
55fb4b7
Merge branch 'feature/xhrrequest-typescript' into feature/comettransp…
owenpearson Oct 20, 2021
21a83d2
Fix imports for platform-bufferutils
owenpearson Oct 20, 2021
861a544
Merge branch 'feature/xhrrequest-typescript' into feature/comettransp…
owenpearson Oct 20, 2021
341eb4e
Merge branch 'feature/comettransport-typescript' into feature/message…
owenpearson Oct 20, 2021
63bd7d2
Merge branch 'feature/messagequeue-typescript' into feature/protocol-…
owenpearson Oct 20, 2021
a155889
Merge branch 'feature/protocol-typescript' into feature/connectionsta…
owenpearson Oct 20, 2021
32c8cd8
Merge branch 'feature/connectionstatechange-typescript' into feature/…
owenpearson Oct 20, 2021
e8920bc
Merge branch 'feature/errorreporter-typescript' into feature/platform…
owenpearson Oct 20, 2021
bc58798
Merge branch 'feature/platform-transports-declaration' into feature/c…
owenpearson Oct 20, 2021
25ebce9
Fix broken platform-webstorage import
owenpearson Oct 21, 2021
b938b6c
Merge pull request #830 from ably/feature/xhrrequest-typescript
owenpearson Nov 4, 2021
e9d0e80
Add XHRStates enum
owenpearson Nov 4, 2021
37d7520
Merge branch 'feature/comettransport-typescript' into feature/message…
owenpearson Nov 4, 2021
d0c48d5
Add error case for MessageQueue.last with MessageQueue is empty
owenpearson Nov 4, 2021
15e20a5
Add error case for MessageQueue.completeMessages when MessageQueue is…
owenpearson Nov 4, 2021
f0f58db
Merge branch 'feature/messagequeue-typescript' into feature/protocol-…
owenpearson Nov 4, 2021
43487e9
Use ES6 export for PendingMessage
owenpearson Nov 4, 2021
a300bcc
Merge pull request #832 from ably/feature/comettransport-typescript
owenpearson Nov 5, 2021
1c57a2b
Remove error for MessageQueue.last with empty queue
owenpearson Nov 5, 2021
5dab0ec
Merge pull request #833 from ably/feature/messagequeue-typescript
owenpearson Nov 5, 2021
ba842e1
Merge branch 'feature/messagequeue-typescript' into feature/protocol-…
owenpearson Nov 5, 2021
0f0a020
Merge branch 'feature/protocol-typescript' into feature/connectionsta…
owenpearson Nov 5, 2021
47417d3
Merge branch 'feature/connectionstatechange-typescript' into feature/…
owenpearson Nov 5, 2021
20d0bc7
Merge branch 'feature/errorreporter-typescript' into feature/platform…
owenpearson Nov 5, 2021
60b31d0
Merge branch 'feature/platform-transports-declaration' into feature/c…
owenpearson Nov 5, 2021
eaa4498
Merge pull request #834 from ably/feature/protocol-typescript
owenpearson Nov 5, 2021
23496c5
Merge pull request #835 from ably/feature/connectionstatechange-types…
owenpearson Nov 5, 2021
27b98e2
Merge pull request #836 from ably/feature/errorreporter-typescript
owenpearson Nov 5, 2021
a5db88d
Merge pull request #837 from ably/feature/platform-transports-declara…
owenpearson Nov 5, 2021
e31957b
Merge pull request #838 from ably/feature/connectionmanager-typescript
owenpearson Nov 5, 2021
7788b7a
Merge branch 'main' into integration/typescript
owenpearson Nov 5, 2021
0d7db64
Rename resource.js to resource.ts
owenpearson Nov 5, 2021
b65f956
Convert Resource to TypeScript
owenpearson Nov 5, 2021
0a47ae7
Rename paginatedresource.js to paginatedresource.ts
owenpearson Nov 5, 2021
dcf150e
Convert PaginatedResource to TypeScript
owenpearson Nov 5, 2021
8e3cdc3
Rename push.js to push.ts
owenpearson Nov 5, 2021
4fa4310
Convert Push to TypeScript
owenpearson Nov 5, 2021
b120539
Rename presence.js to presence.ts
owenpearson Nov 5, 2021
21ab03c
Convert Presence to TypeScript
owenpearson Nov 5, 2021
75e7d06
Rename channel.js to channel.ts
owenpearson Nov 5, 2021
e079a69
Convert Channel to TypeScript
owenpearson Nov 5, 2021
db02f5f
Replace type alias for Channel
owenpearson Nov 5, 2021
4f66064
Add typings for ClientOptions
owenpearson Nov 5, 2021
561bee4
Rename rest.js to rest.ts
owenpearson Nov 5, 2021
72fd3d3
Convert Rest to TypeScript
owenpearson Nov 5, 2021
ca944ef
Use arguments keyword for push promsification
owenpearson Nov 8, 2021
c476a8d
Merge branch 'feature/push-typescript' into feature/presence-typescript
owenpearson Nov 8, 2021
2c3c801
Merge branch 'feature/presence-typescript' into feature/channel-types…
owenpearson Nov 8, 2021
2afc7b1
Merge branch 'feature/channel-typescript' into feature/clientoptions-…
owenpearson Nov 8, 2021
a1970a0
Merge branch 'feature/clientoptions-typescript' into feature/rest-typ…
owenpearson Nov 8, 2021
43ecbb6
Fix double decoding in push listChannels
owenpearson Nov 8, 2021
5bb1e97
Merge branch 'feature/push-typescript' into feature/presence-typescript
owenpearson Nov 8, 2021
5334ca2
Merge branch 'feature/presence-typescript' into feature/channel-types…
owenpearson Nov 8, 2021
5c33795
Merge branch 'feature/channel-typescript' into feature/clientoptions-…
owenpearson Nov 8, 2021
9cc1363
Merge branch 'feature/clientoptions-typescript' into feature/rest-typ…
owenpearson Nov 8, 2021
4462063
Use arguments keyword for channel promsification
owenpearson Nov 8, 2021
77614ec
Merge branch 'feature/channel-typescript' into feature/clientoptions-…
owenpearson Nov 8, 2021
5af4182
Merge branch 'feature/clientoptions-typescript' into feature/rest-typ…
owenpearson Nov 8, 2021
bf9ad16
Add missing normalisation logic for custom agent client option
owenpearson Nov 8, 2021
06ce336
Merge branch 'feature/clientoptions-typescript' into feature/rest-typ…
owenpearson Nov 8, 2021
9795906
Fix error in Rest request HTTP method casing
owenpearson Nov 8, 2021
bdbd191
Use arguments keyword for rest promsification
owenpearson Nov 8, 2021
a2ea53c
Use new keyword for constructor in init promises tests
owenpearson Nov 8, 2021
7d8de2b
Add explanation comment for args.slice
owenpearson Nov 24, 2021
2e1fd3b
Add check for urlMatch regex result length
owenpearson Nov 24, 2021
cdfa6f7
Improve wording in PaginatedResource.handlePage comment
owenpearson Nov 24, 2021
500ea75
Rename cb to callback
owenpearson Nov 24, 2021
919a066
Remove useless assignement to channel.channelOptions
owenpearson Nov 24, 2021
d4c4505
Add comment explaining usage of the Modify generic type
owenpearson Nov 24, 2021
73294d4
Remove unnecessary comment from rest constructor
owenpearson Nov 24, 2021
66ca0c2
Merge pull request #849 from ably/feature/resource-typescript
owenpearson Nov 30, 2021
92da970
Merge pull request #850 from ably/feature/paginatedresource-typescript
owenpearson Dec 1, 2021
ba222bd
Merge pull request #851 from ably/feature/push-typescript
owenpearson Dec 1, 2021
c3070d0
Merge pull request #852 from ably/feature/presence-typescript
owenpearson Dec 1, 2021
f6d5d81
Merge pull request #853 from ably/feature/channel-typescript
owenpearson Dec 1, 2021
566efbd
Merge pull request #854 from ably/feature/clientoptions-typescript
owenpearson Dec 1, 2021
f6bb5ed
Merge pull request #855 from ably/feature/rest-typescript
owenpearson Dec 1, 2021
46b9936
Rename channelstatechange.js to channelstatechange.ts
owenpearson Dec 7, 2021
63f5af4
Convert ChannelStateChange to TypeScript
owenpearson Dec 7, 2021
64da595
Rename connection.js to connection.ts
owenpearson Dec 7, 2021
816b32b
Convert Connection to TypeScript
owenpearson Dec 7, 2021
e5ba91a
Rename realtimepresence.js to realtimepresence.ts
owenpearson Dec 7, 2021
dabb76e
Rename realtimechannel.js to realtimechannel.ts
owenpearson Dec 7, 2021
9d5470c
Convert RealtimeChannel and RealtimePresence to TypeScript
owenpearson Dec 7, 2021
7bc8889
Rename realtime.js to realtime.ts
owenpearson Dec 7, 2021
f029aa5
Convert Realtime to TypeScript
owenpearson Dec 7, 2021
596c572
Use arguments keywork for promisify
owenpearson Dec 14, 2021
47606de
fix spelling/grammar errors and JSDoc inaccuracies
Feb 8, 2022
4b1b58b
Change "auto remove" for "automatically remove"
Peter-Maguire Feb 9, 2022
2a7b69f
Merge pull request #884 from ably/update-documentation
owenpearson Feb 9, 2022
514f2c5
tie internal and external typings together
Feb 15, 2022
a899b95
add boolean to ClientOptions.recover to bring in line with the intern…
Feb 15, 2022
d8944dd
fix missing typings in protcolmessage
Feb 15, 2022
5699204
switch null for undefined
Feb 15, 2022
e1b0cb9
remove extraneous newlines
Feb 16, 2022
bfbb362
Fix bug in RealtimeChannel.detach
owenpearson Feb 22, 2022
b852440
Remove erroneous break from RealtimePresence._enteOrUpdateClient
owenpearson Feb 22, 2022
d0c6bdc
Improve typing of RealtimeChannel._publish
owenpearson Feb 22, 2022
d1a33ea
use API prefix for public type imports
Feb 22, 2022
110cca7
force options.recover to work as a boolean to detect deprecated usage
Feb 22, 2022
839fe14
Improve typing for RealtimePresence.get
owenpearson Feb 22, 2022
2134656
Remove erroneous breaks from RealtimeChannel.onMessage
owenpearson Feb 22, 2022
55e9975
Fix bug in RealtimePresence.get
owenpearson Feb 22, 2022
637eba7
Merge branch 'feature/realtimepresencechannel-typescript' into featur…
owenpearson Feb 22, 2022
7eb08e3
Merge pull request #865 from ably/feature/channelstatechange-typescript
owenpearson Feb 23, 2022
95c408f
Merge pull request #866 from ably/feature/connection-typescript
owenpearson Feb 23, 2022
afe7b52
Fix typing of RealtimeChannel.attach flags param
owenpearson Feb 23, 2022
01febf1
Add union type for RealtimeChannel.state
owenpearson Feb 23, 2022
eeb649f
Allow null err in Message.encodeArray callback invcation
owenpearson Feb 23, 2022
49bf700
Remove redundant _requestedFlags cast
owenpearson Feb 23, 2022
f6bf24e
Combine nested if statements
owenpearson Feb 23, 2022
00218b6
Use object destructuring in RealtimeChannel.onMessage
owenpearson Feb 23, 2022
c4eefbf
Remove redundant NodeJS.Timeout cast
owenpearson Feb 23, 2022
ad1c2b9
Replace `any` with actual typing for event
owenpearson Feb 23, 2022
8e3ae21
Merge pull request #890 from ably/use-public-typescript-typings
Feb 23, 2022
9ecccef
Merge branch 'integration/typescript' into feature/realtimepresencech…
owenpearson Feb 23, 2022
115bcde
Merge branch 'feature/realtimepresencechannel-typescript' into featur…
owenpearson Feb 23, 2022
34d4e89
Fix type error
owenpearson Feb 23, 2022
e30ad65
Merge pull request #867 from ably/feature/realtimepresencechannel-typ…
owenpearson Feb 23, 2022
c6eaa4a
Merge pull request #868 from ably/feature/realtime-typescript
owenpearson Feb 23, 2022
b023634
Merge branch 'main' into integration/typescript
owenpearson Feb 23, 2022
3b7404c
Use TypeScript import-helpers compiler option
owenpearson Feb 23, 2022
fc8d6c9
Re-sync lockfile
owenpearson Feb 23, 2022
ec37a31
fix retry timer setting wrong variable to null (Fixes #898)
Feb 24, 2022
e80d29f
Merge pull request #896 from ably/ts-import-helpers
owenpearson Feb 24, 2022
e4b847b
Merge branch 'main' into integration/typescript
owenpearson Feb 24, 2022
24ef7de
Merge pull request #899 from ably/fix-retry-timer-bug
Feb 24, 2022
5f18cab
Replace Rest/Realtime type aliases in auth.ts
owenpearson Feb 24, 2022
d422eca
Replace ClientOptions type alias in auth.ts
owenpearson Feb 24, 2022
5dd144e
Replace AuthOptions type alias in auth.ts
owenpearson Feb 24, 2022
27b2745
Replace `var` declarations in auth.ts
owenpearson Feb 24, 2022
25259db
Replace Realtime type alias in channel.ts
owenpearson Feb 24, 2022
b7ebeba
Replace Realtime type alias in realtimechannel.ts
owenpearson Feb 24, 2022
36eec65
Replace Realtime type alias in realtimechannel.ts
owenpearson Feb 24, 2022
2966904
Replace Rest/Realtime type aliases in node http.js
owenpearson Feb 24, 2022
3de0da7
Remove useless type assertion in platform-browser
owenpearson Feb 24, 2022
90fe711
Use API typing for RealtimeChannel state
owenpearson Feb 24, 2022
6d62b51
Add proper plugins option typing to public ClientOptions
owenpearson Feb 24, 2022
5daa570
Use API typing for channel state in realtime.ts
owenpearson Feb 24, 2022
f27b929
Fix nullable authOptions arg for Auth.authorize
owenpearson Feb 24, 2022
33f44c3
Add scripts to build for specific platforms
owenpearson Feb 24, 2022
b0995e5
Only build necessary bundles for test scripts
owenpearson Feb 24, 2022
78ff8c2
Merge pull request #902 from ably/separate-webpack-builds
owenpearson Feb 25, 2022
4cc0ef6
Fix platform msgpack typing
owenpearson Feb 25, 2022
ce064d0
Replace outstanding type aliases
owenpearson Feb 25, 2022
43161cf
Make first argument to Rest.time optional
owenpearson Feb 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"PresenceMessage": true,
"ProtocolMessage": true,
"Stats": true,
"ConnectionError": true,
"ConnectionErrors": true,
"MessageQueue": true,
"Protocol": true,
"ConnectionManager": true,
Expand Down
20 changes: 16 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ module.exports = function (grunt) {
dirs: dirs,
pkgVersion: grunt.file.readJSON('package.json').version,
webpack: {
config: webpackConfig
all: Object.values(webpackConfig),
node: webpackConfig.node,
browser: [webpackConfig.browser, webpackConfig.browserMin]
}
};

Expand Down Expand Up @@ -110,7 +112,17 @@ module.exports = function (grunt) {

grunt.registerTask('build', [
'checkGitSubmodules',
'webpack'
'webpack:all'
]);

grunt.registerTask('build:node', [
'checkGitSubmodules',
'webpack:node'
]);

grunt.registerTask('build:browser', [
'checkGitSubmodules',
'webpack:browser'
]);

grunt.registerTask('check-closure-compiler', [
Expand All @@ -126,12 +138,12 @@ module.exports = function (grunt) {
grunt.registerTask('test', ['test:node']);
grunt.registerTask('test:node',
'Build the library and run the node test suite\nOptions\n --test [tests] e.g. --test test/rest/auth.js',
['build', 'mocha']
['build:node', 'mocha']
);

grunt.registerTask('test:webserver',
'Launch the Mocha test web server on http://localhost:3000/',
['build', 'checkGitSubmodules', 'mocha:webserver']
['build:browser', 'checkGitSubmodules', 'mocha:webserver']
);

grunt.registerTask('release:refresh-pkgVersion',
Expand Down
7 changes: 4 additions & 3 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ declare namespace Types {
}, callback: (shouldRecover: boolean) => void) => void);

/**
* Use a non-secure connection connection. By default, a TLS connection is used to connect to Ably
* Use a non-secure connection. By default, a TLS connection is used to connect to Ably
*/
tls?: boolean;
tlsPort?: number;
Expand All @@ -153,6 +153,7 @@ declare namespace Types {
httpOpenTimeout?: number;
httpRequestTimeout?: number;

plugins?: { vcdiff?: any };
}

interface AuthOptions {
Expand All @@ -178,7 +179,7 @@ declare namespace Types {

/**
* Optional clientId that can be used to specify the identity for this client. In most cases
* it is preferable to instead specift a clientId in the token issued to this client.
* it is preferable to instead specify a clientId in the token issued to this client.
*/
clientId?: string;
}
Expand Down Expand Up @@ -265,7 +266,7 @@ declare namespace Types {

type ChannelParams = { [key: string]: string };

type ChannelMode = 'PUBLISH' | 'SUBSCRIBE' | 'PRESENCE' | 'PRESENCE_SUBSCRIBE';
type ChannelMode = 'PUBLISH' | 'SUBSCRIBE' | 'PRESENCE' | 'PRESENCE_SUBSCRIBE' | 'ATTACH_RESUME';
QuintinWillison marked this conversation as resolved.
Show resolved Hide resolved
type ChannelModes = Array<ChannelMode>;

interface ChannelOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import msgpack from '../lib/util/msgpack';
import { TypedArray, IPlatform } from '../../common/types/IPlatform';

declare var MozWebSocket: typeof WebSocket; // For Chrome 14 and Firefox 7
declare var msCrypto: typeof crypto; // for IE11

if(typeof Window === 'undefined' && typeof WorkerGlobalScope === 'undefined') {
console.log("Warning: this distribution of Ably is intended for browsers. On nodejs, please use the 'ably' package on npm");
Expand All @@ -8,36 +12,37 @@ function allowComet() {
/* xhr requests from local files are unreliable in some browsers, such as Chrome 65 and higher -- see eg
* https://stackoverflow.com/questions/49256429/chrome-65-unable-to-make-post-requests-from-local-files-to-flask
* So if websockets are supported, then just forget about comet transports and use that */
var loc = global.location;
const loc = global.location;
return (!global.WebSocket || !loc || !loc.origin || loc.origin.indexOf("http") > -1);
}

var userAgent = global.navigator && global.navigator.userAgent.toString();
var currentUrl = global.location && global.location.href;
const userAgent = global.navigator && global.navigator.userAgent.toString();
const currentUrl = global.location && global.location.href;

var Platform = {
agent: 'browser',
const Platform: IPlatform = {
agent: 'browser',
logTimestamps: true,
userAgent: userAgent,
currentUrl: currentUrl,
noUpgrade: userAgent && userAgent.match(/MSIE\s8\.0/),
noUpgrade: userAgent && !!userAgent.match(/MSIE\s8\.0/),
binaryType: 'arraybuffer',
WebSocket: global.WebSocket || global.MozWebSocket,
WebSocket: global.WebSocket || MozWebSocket,
xhrSupported: global.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest(),
jsonpSupported: typeof(document) !== 'undefined',
allowComet: allowComet(),
streamingSupported: true,
useProtocolHeartbeats: true,
createHmac: null,
msgpack: msgpack,
// TODO: type this properly
msgpack: msgpack as unknown as typeof import('@ably/msgpack-js'),
supportsBinary: !!global.TextDecoder,
preferBinary: false,
ArrayBuffer: global.ArrayBuffer,
atob: global.atob,
nextTick: typeof global.setImmediate !== 'undefined' ? global.setImmediate.bind(global) : function(f) { setTimeout(f, 0); },
nextTick: typeof global.setImmediate !== 'undefined' ? global.setImmediate.bind(global) : function(f: () => void) { setTimeout(f, 0); },
addEventListener: global.addEventListener,
inspect: JSON.stringify,
stringByteSize: function(str) {
stringByteSize: function(str: string) {
/* str.length will be an underestimate for non-ascii strings. But if we're
* in a browser too old to support TextDecoder, not much we can do. Better
* to underestimate, so if we do go over-size, the server will reject the
Expand All @@ -53,13 +58,13 @@ var Platform = {
if (crypto === undefined) {
return undefined;
}
return function(arr, callback) {
return function(arr: TypedArray, callback?: (error: Error | null) => void) {
crypto.getRandomValues(arr);
if(callback) {
callback(null);
}
};
})(global.crypto || global.msCrypto) // mscrypto for IE11
})(global.crypto || msCrypto)
};

export default Platform;
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import msgpack from '../lib/util/msgpack';
import { parse as parseBase64 } from 'crypto-js/build/enc-base64';
import { IPlatform } from '../../common/types/IPlatform';

var Platform = {
agent: 'reactnative',
const Platform: IPlatform = {
agent: 'reactnative',
logTimestamps: true,
noUpgrade: false,
binaryType: 'arraybuffer',
WebSocket: WebSocket,
xhrSupported: XMLHttpRequest,
xhrSupported: true,
allowComet: true,
jsonpSupported: false,
streamingSupported: true,
useProtocolHeartbeats: true,
createHmac: null,
msgpack: msgpack,
supportsBinary: (typeof TextDecoder !== 'undefined') && TextDecoder,
// TODO: type this properly
QuintinWillison marked this conversation as resolved.
Show resolved Hide resolved
msgpack: msgpack as unknown as typeof import('@ably/msgpack-js'),
supportsBinary: ((typeof TextDecoder !== 'undefined') && TextDecoder) ? true : false,
preferBinary: false,
ArrayBuffer: (typeof ArrayBuffer !== 'undefined') && ArrayBuffer,
atob: global.atob,
nextTick: function(f) { setTimeout(f, 0); },
nextTick: function(f: Function) { setTimeout(f, 0); },
addEventListener: null,
inspect: JSON.stringify,
stringByteSize: function(str) {
stringByteSize: function(str: string) {
/* str.length will be an underestimate for non-ascii strings. But if we're
* in a browser too old to support TextDecoder, not much we can do. Better
* to underestimate, so if we do go over-size, the server will reject the
Expand All @@ -34,8 +36,8 @@ var Platform = {
TextDecoder: global.TextDecoder,
Promise: global.Promise,
getRandomWordArray: (function(RNRandomBytes) {
return function(byteLength, callback) {
RNRandomBytes.randomBytes(byteLength, function(err, base64String) {
return function(byteLength: number, callback: Function) {
RNRandomBytes.randomBytes(byteLength, function(err: Error, base64String: string) {
callback(err, !err && parseBase64(base64String));
});
};
Expand Down
12 changes: 7 additions & 5 deletions browser/lib/transport/jsonptransport.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Utils from '../../../common/lib/util/utils';
import * as Utils from '../../../common/lib/util/utils';
import CometTransport from '../../../common/lib/transport/comettransport';
import Platform from 'platform';
import EventEmitter from '../../../common/lib/util/eventemitter';
import Http from 'platform-http';
import ErrorInfo from '../../../common/lib/types/errorinfo';
import Defaults from '../../../common/lib/util/defaults';
import Logger from '../../../common/lib/util/logger';
import HttpStatusCodes from '../../../common/constants/HttpStatusCodes';
import XHRStates from '../../../common/constants/XHRStates';

var JSONPTransport = function(connectionManager) {
var noop = function() {};
Expand Down Expand Up @@ -128,7 +130,7 @@ var JSONPTransport = function(connectionManager) {
if(message.statusCode) {
/* Handle as enveloped jsonp, as all jsonp transport uses should be */
var response = message.response;
if(message.statusCode == 204) {
if(message.statusCode == HttpStatusCodes.NoContent) {
self.complete(null, null, null, message.statusCode);
} else if(!response) {
self.complete(new ErrorInfo('Invalid server response: no envelope detected', null, 500));
Expand All @@ -148,7 +150,7 @@ var JSONPTransport = function(connectionManager) {
}
};

var timeout = (this.requestMode == CometTransport.REQ_SEND) ? this.timeouts.httpRequestTimeout : this.timeouts.recvTimeout;
var timeout = (this.requestMode == XHRStates.REQ_SEND) ? this.timeouts.httpRequestTimeout : this.timeouts.recvTimeout;
this.timer = setTimeout(function() { self.abort(); }, timeout);
head.insertBefore(script, head.firstChild);
};
Expand Down Expand Up @@ -187,7 +189,7 @@ var JSONPTransport = function(connectionManager) {

if(Platform.jsonpSupported && !Http.Request) {
Http.Request = function(method, rest, uri, headers, params, body, callback) {
var req = createRequest(uri, headers, params, body, CometTransport.REQ_SEND, rest && rest.options.timeouts, method);
var req = createRequest(uri, headers, params, body, XHRStates.REQ_SEND, rest && rest.options.timeouts, method);
req.once('complete', callback);
Utils.nextTick(function() {
req.exec();
Expand All @@ -205,7 +207,7 @@ var JSONPTransport = function(connectionManager) {
checksInProgress = [callback];
Logger.logAction(Logger.LOG_MICRO, '(JSONP)Http.checkConnectivity()', 'Sending; ' + upUrl);

var req = new Request('isTheInternetUp', upUrl, null, null, null, CometTransport.REQ_SEND, Defaults.TIMEOUTS);
var req = new Request('isTheInternetUp', upUrl, null, null, null, XHRStates.REQ_SEND, Defaults.TIMEOUTS);
req.once('complete', function(err, response) {
var result = !err && response;
Logger.logAction(Logger.LOG_MICRO, '(JSONP)Http.checkConnectivity()', 'Result: ' + result);
Expand Down
2 changes: 1 addition & 1 deletion browser/lib/transport/xhrpollingtransport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Utils from '../../../common/lib/util/utils';
import * as Utils from '../../../common/lib/util/utils';
import Logger from '../../../common/lib/util/logger';
import Platform from 'platform';
import CometTransport from '../../../common/lib/transport/comettransport';
Expand Down
Loading