@based/server 3.4.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +173 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/dummyAuth.d.ts +1 -1
- package/dist/auth/dummyAuth.js +3 -2
- package/dist/auth/dummyAuth.js.map +1 -1
- package/dist/auth/index.d.ts +8 -4
- package/dist/auth/index.js +28 -23
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/parseAuthState.d.ts +2 -0
- package/dist/auth/parseAuthState.js +16 -0
- package/dist/auth/parseAuthState.js.map +1 -0
- package/dist/auth/types.d.ts +10 -0
- package/dist/{handlers/rest/file → auth}/types.js +0 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/compress.d.ts +5 -0
- package/dist/{network/http/compress.js → compress.js} +2 -6
- package/dist/compress.js.map +1 -0
- package/dist/context.d.ts +54 -0
- package/dist/context.js +18 -0
- package/dist/context.js.map +1 -0
- package/dist/error/errorTypeHandlers.d.ts +6 -0
- package/dist/error/errorTypeHandlers.js +130 -0
- package/dist/error/errorTypeHandlers.js.map +1 -0
- package/dist/error/index.d.ts +5 -0
- package/dist/error/index.js +61 -0
- package/dist/error/index.js.map +1 -0
- package/dist/error/types.d.ts +105 -0
- package/dist/error/types.js +30 -0
- package/dist/error/types.js.map +1 -0
- package/dist/functions/index.d.ts +10 -24
- package/dist/functions/index.js +98 -287
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/timeout.d.ts +1 -1
- package/dist/functions/types.d.ts +69 -0
- package/dist/functions/types.js +15 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/incoming/http/authorize.d.ts +4 -0
- package/dist/incoming/http/authorize.js +37 -0
- package/dist/incoming/http/authorize.js.map +1 -0
- package/dist/incoming/http/function.d.ts +4 -0
- package/dist/{network → incoming}/http/function.js +13 -13
- package/dist/incoming/http/function.js.map +1 -0
- package/dist/incoming/http/get.d.ts +4 -0
- package/dist/incoming/http/get.js +155 -0
- package/dist/incoming/http/get.js.map +1 -0
- package/dist/{network → incoming}/http/index.d.ts +0 -0
- package/dist/incoming/http/index.js +134 -0
- package/dist/incoming/http/index.js.map +1 -0
- package/dist/incoming/http/parseQuery.d.ts +4 -0
- package/dist/incoming/http/parseQuery.js +25 -0
- package/dist/incoming/http/parseQuery.js.map +1 -0
- package/dist/incoming/http/readBody.d.ts +4 -0
- package/dist/{network → incoming}/http/readBody.js +27 -32
- package/dist/incoming/http/readBody.js.map +1 -0
- package/dist/{handlers/rest/file → incoming/http/streamFunction}/DataStream.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/DataStream.js +0 -0
- package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.js +0 -0
- package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
- package/dist/incoming/http/streamFunction/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/index.js +106 -0
- package/dist/incoming/http/streamFunction/index.js.map +1 -0
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
- package/dist/{network → incoming}/http/streamFunction/multipartStream.js +12 -12
- package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/stream.d.ts +3 -2
- package/dist/{network → incoming}/http/streamFunction/stream.js +16 -11
- package/dist/incoming/http/streamFunction/stream.js.map +1 -0
- package/dist/incoming/index.d.ts +3 -0
- package/dist/{network → incoming}/index.js +28 -28
- package/dist/incoming/index.js.map +1 -0
- package/dist/incoming/upgrade.d.ts +4 -0
- package/dist/{network → incoming}/upgrade.js +24 -9
- package/dist/incoming/upgrade.js.map +1 -0
- package/dist/incoming/ws/auth.d.ts +5 -0
- package/dist/incoming/ws/auth.js +40 -0
- package/dist/incoming/ws/auth.js.map +1 -0
- package/dist/incoming/ws/function.d.ts +3 -0
- package/dist/incoming/ws/function.js +107 -0
- package/dist/incoming/ws/function.js.map +1 -0
- package/dist/incoming/ws/get.d.ts +3 -0
- package/dist/incoming/ws/get.js +136 -0
- package/dist/incoming/ws/get.js.map +1 -0
- package/dist/incoming/ws/index.d.ts +3 -0
- package/dist/{network/message → incoming/ws}/index.js +17 -18
- package/dist/incoming/ws/index.js.map +1 -0
- package/dist/incoming/ws/observable.d.ts +6 -0
- package/dist/incoming/ws/observable.js +112 -0
- package/dist/incoming/ws/observable.js.map +1 -0
- package/dist/index.d.ts +10 -35
- package/dist/index.js +17 -196
- package/dist/index.js.map +1 -1
- package/dist/ip.d.ts +2 -0
- package/dist/ip.js +8 -0
- package/dist/ip.js.map +1 -0
- package/dist/observable/create.d.ts +3 -0
- package/dist/observable/create.js +30 -0
- package/dist/observable/create.js.map +1 -0
- package/dist/observable/destroy.d.ts +2 -0
- package/dist/observable/destroy.js +51 -0
- package/dist/observable/destroy.js.map +1 -0
- package/dist/observable/error.d.ts +4 -0
- package/dist/observable/error.js +17 -0
- package/dist/observable/error.js.map +1 -0
- package/dist/observable/extendCache.d.ts +2 -0
- package/dist/observable/extendCache.js +11 -0
- package/dist/observable/extendCache.js.map +1 -0
- package/dist/observable/genObservableId.d.ts +1 -0
- package/dist/observable/genObservableId.js +9 -0
- package/dist/observable/genObservableId.js.map +1 -0
- package/dist/observable/get.d.ts +4 -0
- package/dist/observable/get.js +15 -0
- package/dist/observable/get.js.map +1 -0
- package/dist/observable/index.d.ts +11 -8
- package/dist/observable/index.js +25 -151
- package/dist/observable/index.js.map +1 -1
- package/dist/observable/send.d.ts +6 -0
- package/dist/observable/send.js +32 -0
- package/dist/observable/send.js.map +1 -0
- package/dist/observable/start/error.d.ts +3 -0
- package/dist/observable/start/error.js +36 -0
- package/dist/observable/start/error.js.map +1 -0
- package/dist/observable/start/index.d.ts +2 -0
- package/dist/observable/start/index.js +46 -0
- package/dist/observable/start/index.js.map +1 -0
- package/dist/observable/start/update.d.ts +6 -0
- package/dist/observable/start/update.js +104 -0
- package/dist/observable/start/update.js.map +1 -0
- package/dist/observable/subscribe.d.ts +7 -0
- package/dist/observable/subscribe.js +54 -0
- package/dist/observable/subscribe.js.map +1 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.js +3 -0
- package/dist/observable/types.js.map +1 -0
- package/dist/observable/unsub.d.ts +6 -0
- package/dist/observable/unsub.js +43 -0
- package/dist/observable/unsub.js.map +1 -0
- package/dist/observable/verify.d.ts +4 -0
- package/dist/observable/verify.js +18 -0
- package/dist/observable/verify.js.map +1 -0
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.js +32 -11
- package/dist/protocol.js.map +1 -1
- package/dist/security.d.ts +6 -0
- package/dist/security.js +95 -0
- package/dist/security.js.map +1 -0
- package/dist/sendError.d.ts +5 -0
- package/dist/sendError.js +42 -0
- package/dist/sendError.js.map +1 -0
- package/dist/sendHttpResponse.d.ts +4 -0
- package/dist/sendHttpResponse.js +53 -0
- package/dist/sendHttpResponse.js.map +1 -0
- package/dist/server.d.ts +42 -8
- package/dist/server.js +26 -12
- package/dist/server.js.map +1 -1
- package/package.json +16 -14
- package/.turbo/turbo-build.log +0 -4
- package/dist/BasedServerClient.d.ts +0 -71
- package/dist/BasedServerClient.js +0 -390
- package/dist/BasedServerClient.js.map +0 -1
- package/dist/Client.d.ts +0 -75
- package/dist/Client.js +0 -277
- package/dist/Client.js.map +0 -1
- package/dist/Params.d.ts +0 -20
- package/dist/Params.js +0 -48
- package/dist/Params.js.map +0 -1
- package/dist/auth/authorize.d.ts +0 -2
- package/dist/auth/authorize.js +0 -8
- package/dist/auth/authorize.js.map +0 -1
- package/dist/clientContext.d.ts +0 -0
- package/dist/clientContext.js +0 -83
- package/dist/clientContext.js.map +0 -1
- package/dist/closeListener.d.ts +0 -4
- package/dist/closeListener.js +0 -13
- package/dist/closeListener.js.map +0 -1
- package/dist/error.d.ts +0 -66
- package/dist/error.js +0 -149
- package/dist/error.js.map +0 -1
- package/dist/findPrefix.d.ts +0 -3
- package/dist/findPrefix.js +0 -20
- package/dist/findPrefix.js.map +0 -1
- package/dist/functions/workerPool.d.ts +0 -0
- package/dist/functions/workerPool.js +0 -5
- package/dist/functions/workerPool.js.map +0 -1
- package/dist/getFromConfig.d.ts +0 -3
- package/dist/getFromConfig.js +0 -50
- package/dist/getFromConfig.js.map +0 -1
- package/dist/handlers/authorize.d.ts +0 -5
- package/dist/handlers/authorize.js +0 -196
- package/dist/handlers/authorize.js.map +0 -1
- package/dist/handlers/bulkUpdate/index.d.ts +0 -5
- package/dist/handlers/bulkUpdate/index.js +0 -26
- package/dist/handlers/bulkUpdate/index.js.map +0 -1
- package/dist/handlers/configuration/index.d.ts +0 -10
- package/dist/handlers/configuration/index.js +0 -74
- package/dist/handlers/configuration/index.js.map +0 -1
- package/dist/handlers/configuration/observable/index.d.ts +0 -46
- package/dist/handlers/configuration/observable/index.js +0 -277
- package/dist/handlers/configuration/observable/index.js.map +0 -1
- package/dist/handlers/configure/index.d.ts +0 -5
- package/dist/handlers/configure/index.js +0 -44
- package/dist/handlers/configure/index.js.map +0 -1
- package/dist/handlers/copy/index.d.ts +0 -8
- package/dist/handlers/copy/index.js +0 -135
- package/dist/handlers/copy/index.js.map +0 -1
- package/dist/handlers/delete/index.d.ts +0 -5
- package/dist/handlers/delete/index.js +0 -34
- package/dist/handlers/delete/index.js.map +0 -1
- package/dist/handlers/digest/index.d.ts +0 -5
- package/dist/handlers/digest/index.js +0 -23
- package/dist/handlers/digest/index.js.map +0 -1
- package/dist/handlers/functions/call.d.ts +0 -6
- package/dist/handlers/functions/call.js +0 -54
- package/dist/handlers/functions/call.js.map +0 -1
- package/dist/handlers/functions/observable/Observable.d.ts +0 -49
- package/dist/handlers/functions/observable/Observable.js +0 -290
- package/dist/handlers/functions/observable/Observable.js.map +0 -1
- package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
- package/dist/handlers/functions/observable/SharedObservable.js +0 -291
- package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
- package/dist/handlers/functions/observable/index.d.ts +0 -14
- package/dist/handlers/functions/observable/index.js +0 -130
- package/dist/handlers/functions/observable/index.js.map +0 -1
- package/dist/handlers/get/index.d.ts +0 -5
- package/dist/handlers/get/index.js +0 -23
- package/dist/handlers/get/index.js.map +0 -1
- package/dist/handlers/getConfig/index.d.ts +0 -5
- package/dist/handlers/getConfig/index.js +0 -38
- package/dist/handlers/getConfig/index.js.map +0 -1
- package/dist/handlers/handleRequests.d.ts +0 -5
- package/dist/handlers/handleRequests.js +0 -78
- package/dist/handlers/handleRequests.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -4
- package/dist/handlers/index.js +0 -49
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/messageParser.d.ts +0 -5
- package/dist/handlers/messageParser.js +0 -122
- package/dist/handlers/messageParser.js.map +0 -1
- package/dist/handlers/removeField/index.d.ts +0 -5
- package/dist/handlers/removeField/index.js +0 -42
- package/dist/handlers/removeField/index.js.map +0 -1
- package/dist/handlers/removeType/index.d.ts +0 -5
- package/dist/handlers/removeType/index.js +0 -30
- package/dist/handlers/removeType/index.js.map +0 -1
- package/dist/handlers/rest/file/DataStream.js +0 -17
- package/dist/handlers/rest/file/DataStream.js.map +0 -1
- package/dist/handlers/rest/file/formStream.d.ts +0 -4
- package/dist/handlers/rest/file/formStream.js +0 -188
- package/dist/handlers/rest/file/formStream.js.map +0 -1
- package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
- package/dist/handlers/rest/file/getExtenstion.js +0 -22
- package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
- package/dist/handlers/rest/file/index.d.ts +0 -4
- package/dist/handlers/rest/file/index.js +0 -53
- package/dist/handlers/rest/file/index.js.map +0 -1
- package/dist/handlers/rest/file/storeFile.d.ts +0 -6
- package/dist/handlers/rest/file/storeFile.js +0 -44
- package/dist/handlers/rest/file/storeFile.js.map +0 -1
- package/dist/handlers/rest/file/stream.d.ts +0 -5
- package/dist/handlers/rest/file/stream.js +0 -105
- package/dist/handlers/rest/file/stream.js.map +0 -1
- package/dist/handlers/rest/file/types.d.ts +0 -9
- package/dist/handlers/rest/file/types.js.map +0 -1
- package/dist/handlers/rest/getReqMessage.d.ts +0 -3
- package/dist/handlers/rest/getReqMessage.js +0 -92
- package/dist/handlers/rest/getReqMessage.js.map +0 -1
- package/dist/handlers/rest/index.d.ts +0 -4
- package/dist/handlers/rest/index.js +0 -121
- package/dist/handlers/rest/index.js.map +0 -1
- package/dist/handlers/rest/invalidReq.d.ts +0 -4
- package/dist/handlers/rest/invalidReq.js +0 -20
- package/dist/handlers/rest/invalidReq.js.map +0 -1
- package/dist/handlers/rest/parseResponse.d.ts +0 -6
- package/dist/handlers/rest/parseResponse.js +0 -230
- package/dist/handlers/rest/parseResponse.js.map +0 -1
- package/dist/handlers/rest/playground/index.d.ts +0 -5
- package/dist/handlers/rest/playground/index.js +0 -308
- package/dist/handlers/rest/playground/index.js.map +0 -1
- package/dist/handlers/rest/readBody.d.ts +0 -3
- package/dist/handlers/rest/readBody.js +0 -45
- package/dist/handlers/rest/readBody.js.map +0 -1
- package/dist/handlers/set/index.d.ts +0 -5
- package/dist/handlers/set/index.js +0 -20
- package/dist/handlers/set/index.js.map +0 -1
- package/dist/handlers/subscription/index.d.ts +0 -32
- package/dist/handlers/subscription/index.js +0 -223
- package/dist/handlers/subscription/index.js.map +0 -1
- package/dist/handlers/token.d.ts +0 -5
- package/dist/handlers/token.js +0 -122
- package/dist/handlers/token.js.map +0 -1
- package/dist/handlers/track/index.d.ts +0 -7
- package/dist/handlers/track/index.js +0 -102
- package/dist/handlers/track/index.js.map +0 -1
- package/dist/handlers/userAuth/index.d.ts +0 -5
- package/dist/handlers/userAuth/index.js +0 -78
- package/dist/handlers/userAuth/index.js.map +0 -1
- package/dist/network/http/authorize.d.ts +0 -3
- package/dist/network/http/authorize.js +0 -28
- package/dist/network/http/authorize.js.map +0 -1
- package/dist/network/http/compress.d.ts +0 -6
- package/dist/network/http/compress.js.map +0 -1
- package/dist/network/http/end.d.ts +0 -4
- package/dist/network/http/end.js +0 -19
- package/dist/network/http/end.js.map +0 -1
- package/dist/network/http/function.d.ts +0 -3
- package/dist/network/http/function.js.map +0 -1
- package/dist/network/http/get.d.ts +0 -3
- package/dist/network/http/get.js +0 -129
- package/dist/network/http/get.js.map +0 -1
- package/dist/network/http/index.js +0 -122
- package/dist/network/http/index.js.map +0 -1
- package/dist/network/http/readBody.d.ts +0 -3
- package/dist/network/http/readBody.js.map +0 -1
- package/dist/network/http/send.d.ts +0 -5
- package/dist/network/http/send.js +0 -60
- package/dist/network/http/send.js.map +0 -1
- package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.js.map +0 -1
- package/dist/network/http/streamFunction/index.d.ts +0 -3
- package/dist/network/http/streamFunction/index.js +0 -81
- package/dist/network/http/streamFunction/index.js.map +0 -1
- package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js.map +0 -1
- package/dist/network/message/auth.d.ts +0 -4
- package/dist/network/message/auth.js +0 -32
- package/dist/network/message/auth.js.map +0 -1
- package/dist/network/message/function.d.ts +0 -3
- package/dist/network/message/function.js +0 -67
- package/dist/network/message/function.js.map +0 -1
- package/dist/network/message/get.d.ts +0 -3
- package/dist/network/message/get.js +0 -109
- package/dist/network/message/get.js.map +0 -1
- package/dist/network/message/index.d.ts +0 -3
- package/dist/network/message/index.js.map +0 -1
- package/dist/network/message/observable.d.ts +0 -5
- package/dist/network/message/observable.js +0 -103
- package/dist/network/message/observable.js.map +0 -1
- package/dist/network/message/send.d.ts +0 -4
- package/dist/network/message/send.js +0 -11
- package/dist/network/message/send.js.map +0 -1
- package/dist/network/upgrade.d.ts +0 -4
- package/dist/network/upgrade.js.map +0 -1
- package/dist/network/worker/get.d.ts +0 -0
- package/dist/network/worker/get.js +0 -122
- package/dist/network/worker/get.js.map +0 -1
- package/dist/network/worker/observable.d.ts +0 -0
- package/dist/network/worker/observable.js +0 -120
- package/dist/network/worker/observable.js.map +0 -1
- package/dist/openListener.d.ts +0 -4
- package/dist/openListener.js +0 -13
- package/dist/openListener.js.map +0 -1
- package/dist/secrets.d.ts +0 -9
- package/dist/secrets.js +0 -150
- package/dist/secrets.js.map +0 -1
- package/dist/security/index.d.ts +0 -2
- package/dist/security/index.js +0 -57
- package/dist/security/index.js.map +0 -1
- package/dist/types.d.ts +0 -129
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/upgradeListener.d.ts +0 -4
- package/dist/upgradeListener.js +0 -47
- package/dist/upgradeListener.js.map +0 -1
- package/dist/worker/authorize.d.ts +0 -5
- package/dist/worker/authorize.js +0 -15
- package/dist/worker/authorize.js.map +0 -1
- package/dist/worker/fnMap.d.ts +0 -2
- package/dist/worker/fnMap.js +0 -5
- package/dist/worker/fnMap.js.map +0 -1
- package/dist/worker/functions.d.ts +0 -3
- package/dist/worker/functions.js +0 -8
- package/dist/worker/functions.js.map +0 -1
- package/dist/worker/http/function.d.ts +0 -4
- package/dist/worker/http/function.js +0 -75
- package/dist/worker/http/function.js.map +0 -1
- package/dist/worker/index.d.ts +0 -1
- package/dist/worker/index.js +0 -101
- package/dist/worker/index.js.map +0 -1
- package/dist/worker/observable.d.ts +0 -15
- package/dist/worker/observable.js +0 -110
- package/dist/worker/observable.js.map +0 -1
- package/dist/worker/ws/function.d.ts +0 -3
- package/dist/worker/ws/function.js +0 -42
- package/dist/worker/ws/function.js.map +0 -1
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +0 -20
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/workerCode.d.ts +0 -12
- package/dist/workers/workerCode.js +0 -46
- package/dist/workers/workerCode.js.map +0 -1
package/dist/observable/index.js
CHANGED
|
@@ -1,154 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!
|
|
15
|
-
console.warn('Cannot find observable function spec!', obs.name);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const memCacheTimeout = spec.memCacheTimeout ?? server.functions.config.memCacheTimeout;
|
|
19
|
-
if (!obs.beingDestroyed) {
|
|
20
|
-
obs.beingDestroyed = setTimeout(() => {
|
|
21
|
-
if (!server.activeObservables[obs.name]) {
|
|
22
|
-
console.info('Trying to destroy a removed observable function');
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
obs.beingDestroyed = null;
|
|
26
|
-
server.activeObservables[obs.name].delete(id);
|
|
27
|
-
if (server.activeObservables[obs.name].size === 0) {
|
|
28
|
-
delete server.activeObservables[obs.name];
|
|
29
|
-
}
|
|
30
|
-
server.activeObservablesById.delete(id);
|
|
31
|
-
obs.isDestroyed = true;
|
|
32
|
-
obs.closeFunction();
|
|
33
|
-
}, memCacheTimeout);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.destroy = destroy;
|
|
37
|
-
const subscribe = (server, id, checksum, client) => {
|
|
38
|
-
if (!client.ws) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const obs = server.activeObservablesById.get(id);
|
|
42
|
-
client.ws.obs.add(id);
|
|
43
|
-
if (obs.beingDestroyed) {
|
|
44
|
-
clearTimeout(obs.beingDestroyed);
|
|
45
|
-
obs.beingDestroyed = null;
|
|
46
|
-
}
|
|
47
|
-
obs.clients.add(client.ws.id);
|
|
48
|
-
if (obs.cache && obs.checksum !== checksum) {
|
|
49
|
-
if (obs.diffCache && obs.previousChecksum === checksum) {
|
|
50
|
-
client.ws.send(obs.diffCache, true, false);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
client.ws.send(obs.cache, true, false);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.subscribe = subscribe;
|
|
58
|
-
const unsubscribe = (server, id, client) => {
|
|
59
|
-
if (!client.ws) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (!client.ws.obs.has(id)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const obs = server.activeObservablesById.get(id);
|
|
66
|
-
client.ws.obs.delete(id);
|
|
67
|
-
if (!obs) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
obs.clients.delete(client.ws.id);
|
|
71
|
-
if (obs.clients.size === 0) {
|
|
72
|
-
(0, exports.destroy)(server, id);
|
|
73
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
74
15
|
};
|
|
75
|
-
exports
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
exports.unsubscribeIgnoreClient = unsubscribeIgnoreClient;
|
|
90
|
-
const initFunction = async (server, id) => {
|
|
91
|
-
const obs = server.activeObservablesById.get(id);
|
|
92
|
-
if (obs.closeFunction) {
|
|
93
|
-
obs.closeFunction();
|
|
94
|
-
delete obs.closeFunction;
|
|
95
|
-
}
|
|
96
|
-
const spec = server.functions.observables[obs.name];
|
|
97
|
-
if (!spec) {
|
|
98
|
-
console.warn('Cannot find observable function spec!', obs.name);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const payload = obs.payload;
|
|
102
|
-
const close = server.functions.runObservableFunction(spec, id,
|
|
103
|
-
// add isDeflate for http
|
|
104
|
-
(err) => {
|
|
105
|
-
if (err) {
|
|
106
|
-
console.error('ERROR TIMES /w obserbable', err);
|
|
107
|
-
}
|
|
108
|
-
}, (encodedDiffData, encodedData, checksum, isDeflate) => {
|
|
109
|
-
obs.previousChecksum = obs.checksum;
|
|
110
|
-
obs.checksum = checksum;
|
|
111
|
-
obs.cache = encodedData;
|
|
112
|
-
obs.isDeflate = isDeflate;
|
|
113
|
-
if (encodedDiffData) {
|
|
114
|
-
obs.diffCache = encodedDiffData;
|
|
115
|
-
server.uwsApp.publish(String(id), encodedDiffData, true, false);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
server.uwsApp.publish(String(id), encodedData, true, false);
|
|
119
|
-
}
|
|
120
|
-
if (obs.onNextData) {
|
|
121
|
-
const setObs = obs.onNextData;
|
|
122
|
-
delete obs.onNextData;
|
|
123
|
-
setObs.forEach((fn) => fn());
|
|
124
|
-
}
|
|
125
|
-
}, payload);
|
|
126
|
-
if (obs.isDestroyed) {
|
|
127
|
-
close();
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
obs.closeFunction = close;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
exports.initFunction = initFunction;
|
|
134
|
-
const create = (server, name, id, payload) => {
|
|
135
|
-
if (server.activeObservablesById.has(id)) {
|
|
136
|
-
return server.activeObservablesById.get(id);
|
|
137
|
-
}
|
|
138
|
-
const obs = {
|
|
139
|
-
payload,
|
|
140
|
-
clients: new Set(),
|
|
141
|
-
id,
|
|
142
|
-
name,
|
|
143
|
-
isDestroyed: false,
|
|
144
|
-
};
|
|
145
|
-
if (!server.activeObservables[name]) {
|
|
146
|
-
server.activeObservables[name] = new Map();
|
|
147
|
-
}
|
|
148
|
-
server.activeObservables[name].set(id, obs);
|
|
149
|
-
server.activeObservablesById.set(id, obs);
|
|
150
|
-
(0, exports.initFunction)(server, id);
|
|
151
|
-
return obs;
|
|
152
|
-
};
|
|
153
|
-
exports.create = create;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./subscribe"), exports);
|
|
18
|
+
__exportStar(require("./unsub"), exports);
|
|
19
|
+
__exportStar(require("./destroy"), exports);
|
|
20
|
+
__exportStar(require("./create"), exports);
|
|
21
|
+
__exportStar(require("./extendCache"), exports);
|
|
22
|
+
__exportStar(require("./start"), exports);
|
|
23
|
+
__exportStar(require("./verify"), exports);
|
|
24
|
+
__exportStar(require("./send"), exports);
|
|
25
|
+
__exportStar(require("./get"), exports);
|
|
26
|
+
__exportStar(require("./types"), exports);
|
|
27
|
+
__exportStar(require("./genObservableId"), exports);
|
|
154
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observable/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observable/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,0CAAuB;AACvB,4CAAyB;AACzB,2CAAwB;AACxB,gDAA6B;AAC7B,0CAAuB;AACvB,2CAAwB;AACxB,yCAAsB;AACtB,wCAAqB;AACrB,0CAAuB;AACvB,oDAAiC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Context, WebSocketSession, HttpSession } from '../context';
|
|
2
|
+
import { BasedServer } from '../server';
|
|
3
|
+
import { BasedErrorCode, BasedError } from '../error';
|
|
4
|
+
import { ActiveObservable } from './types';
|
|
5
|
+
export declare const sendObsWs: (ctx: Context<WebSocketSession>, buffer: Uint8Array, obs: ActiveObservable) => void;
|
|
6
|
+
export declare const sendObsGetError: (server: BasedServer, ctx: Context<WebSocketSession | HttpSession>, id: number, name: string, err: BasedError<BasedErrorCode.ObservableFunctionError>) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendObsGetError = exports.sendObsWs = void 0;
|
|
4
|
+
const protocol_1 = require("../protocol");
|
|
5
|
+
const destroy_1 = require("./destroy");
|
|
6
|
+
const sendError_1 = require("../sendError");
|
|
7
|
+
const sendObsWs = (ctx, buffer, obs) => {
|
|
8
|
+
if (!ctx.session) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (obs.reusedCache) {
|
|
12
|
+
const prevId = (0, protocol_1.updateId)(buffer, obs.id);
|
|
13
|
+
ctx.session.send(buffer, true, false);
|
|
14
|
+
buffer.set(prevId, 4);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
ctx.session.send(buffer, true, false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.sendObsWs = sendObsWs;
|
|
21
|
+
const sendObsGetError = (server, ctx, id, name, err) => {
|
|
22
|
+
(0, sendError_1.sendError)(server, ctx, err.code, {
|
|
23
|
+
observableId: id,
|
|
24
|
+
route: {
|
|
25
|
+
name,
|
|
26
|
+
},
|
|
27
|
+
err: err,
|
|
28
|
+
});
|
|
29
|
+
(0, destroy_1.destroyObs)(server, id);
|
|
30
|
+
};
|
|
31
|
+
exports.sendObsGetError = sendObsGetError;
|
|
32
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/observable/send.ts"],"names":[],"mappings":";;;AACA,0CAAsC;AAEtC,uCAAsC;AAEtC,4CAAwC;AAGjC,MAAM,SAAS,GAAG,CACvB,GAA8B,EAC9B,MAAkB,EAClB,GAAqB,EACrB,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,MAAM,MAAM,GAAG,IAAA,mBAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;QACvC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QACrC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;KACtB;SAAM;QACL,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACtC;AACH,CAAC,CAAA;AAfY,QAAA,SAAS,aAerB;AAEM,MAAM,eAAe,GAAG,CAC7B,MAAmB,EACnB,GAA4C,EAC5C,EAAU,EACV,IAAY,EACZ,GAAuD,EACvD,EAAE;IACF,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;QAC/B,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE;YACL,IAAI;SACL;QACD,GAAG,EAAE,GAAG;KACT,CAAC,CAAA;IACF,IAAA,oBAAU,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACxB,CAAC,CAAA;AAfY,QAAA,eAAe,mBAe3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorListener = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const protocol_1 = require("../../protocol");
|
|
6
|
+
const errorListener = (server, obs, err) => {
|
|
7
|
+
obs.error = err;
|
|
8
|
+
delete obs.cache;
|
|
9
|
+
delete obs.diffCache;
|
|
10
|
+
delete obs.checksum;
|
|
11
|
+
delete obs.previousChecksum;
|
|
12
|
+
obs.isDeflate = false;
|
|
13
|
+
obs.reusedCache = false;
|
|
14
|
+
const errorData = (0, error_1.createError)(server, { session: { id: obs.id, name: obs.name } }, err.code || error_1.BasedErrorCode.ObservableFunctionError, {
|
|
15
|
+
err,
|
|
16
|
+
observableId: obs.id,
|
|
17
|
+
route: {
|
|
18
|
+
name: obs.name,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (obs.clients.size) {
|
|
22
|
+
server.uwsApp.publish(String(obs.id), (0, protocol_1.encodeErrorResponse)((0, protocol_1.valueToBuffer)(errorData)), true, false);
|
|
23
|
+
}
|
|
24
|
+
if (obs.functionObserveClients.size) {
|
|
25
|
+
obs.functionObserveClients.forEach((fnUpdate) => {
|
|
26
|
+
fnUpdate(obs.cache, obs.checksum, obs.diffCache, obs.previousChecksum, obs.isDeflate, obs.rawData, errorData);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (obs.onNextData) {
|
|
30
|
+
const onNextData = obs.onNextData;
|
|
31
|
+
delete obs.onNextData;
|
|
32
|
+
onNextData.forEach((fn) => fn(err));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.errorListener = errorListener;
|
|
36
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/observable/start/error.ts"],"names":[],"mappings":";;;AAEA,uCAAyD;AACzD,6CAAmE;AAE5D,MAAM,aAAa,GAAG,CAC3B,MAAmB,EACnB,GAAqB,EACrB,GAAG,EACH,EAAE;IACF,GAAG,CAAC,KAAK,GAAG,GAAG,CAAA;IACf,OAAO,GAAG,CAAC,KAAK,CAAA;IAChB,OAAO,GAAG,CAAC,SAAS,CAAA;IACpB,OAAO,GAA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G,CAAC,CAAC,CAAA;KACpC;AACH,CAAC,CAAA;AAvDY,QAAA,aAAa,iBAuDzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.start = void 0;
|
|
4
|
+
const functions_1 = require("../../functions");
|
|
5
|
+
const update_1 = require("./update");
|
|
6
|
+
const error_1 = require("./error");
|
|
7
|
+
const start = (server, id) => {
|
|
8
|
+
// TODO: install here - if fn is not available is ok - just wait until start gets called again
|
|
9
|
+
const obs = server.activeObservablesById.get(id);
|
|
10
|
+
if (obs.closeFunction) {
|
|
11
|
+
obs.closeFunction();
|
|
12
|
+
delete obs.closeFunction;
|
|
13
|
+
}
|
|
14
|
+
const spec = server.functions.specs[obs.name];
|
|
15
|
+
if (!spec || !(0, functions_1.isObservableFunctionSpec)(spec)) {
|
|
16
|
+
console.warn('Cannot find observable function spec!', obs.name);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const payload = obs.payload;
|
|
20
|
+
const update = (data, checksum, diff, fromChecksum, isDeflate, rawData) => (0, update_1.updateListener)(server, obs, data, checksum, diff, fromChecksum, isDeflate, rawData);
|
|
21
|
+
update.__internalObs__ = true;
|
|
22
|
+
try {
|
|
23
|
+
// TODO: make these functions receive server and obs (as last args) - every fn that you dont need is WIN
|
|
24
|
+
const r = spec.function(payload, update);
|
|
25
|
+
if (r instanceof Promise) {
|
|
26
|
+
r.then((close) => {
|
|
27
|
+
if (obs.isDestroyed) {
|
|
28
|
+
close();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
obs.closeFunction = close;
|
|
32
|
+
}
|
|
33
|
+
}).catch((err) => {
|
|
34
|
+
(0, error_1.errorListener)(server, obs, err);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
obs.closeFunction = r;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
(0, error_1.errorListener)(server, obs, err);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.start = start;
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/observable/start/index.ts"],"names":[],"mappings":";;;AACA,+CAA0D;AAC1D,qCAAyC;AACzC,mCAAuC;AAGhC,MAAM,KAAK,GAAG,CAAC,MAAmB,EAAE,EAAU,EAAE,EAAE;IACvD,8FAA8F;IAE9F,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEhD,IAAI,GAAG,CAAC,aAAa,EAAE;QACrB,GAAG,CAAC,aAAa,EAAE,CAAA;QACnB,OAAO,GAAG,CAAC,aAAa,CAAA;KACzB;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAE7C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAA,oCAAwB,EAAC,IAAI,CAAC,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,uCAAuC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QAC/D,OAAM;KACP;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;IAE3B,MAAM,MAAM,GAA6B,CACvC,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,OAAO,EACP,EAAE,CACF,IAAA,uBAAc,EACZ,MAAM,EACN,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,OAAO,CACR,CAAA;IAEH,MAAM,CAAC,eAAe,GAAG,IAAI,CAAA;IAE7B,IAAI;QACF,wGAAwG;QACxG,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAExC,IAAI,CAAC,YAAY,OAAO,EAAE;YACxB,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,GAAG,CAAC,WAAW,EAAE;oBACnB,KAAK,EAAE,CAAA;iBACR;qBAAM;oBACL,GAAG,CAAC,aAAa,GAAG,KAAK,CAAA;iBAC1B;YACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACf,IAAA,qBAAa,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACjC,CAAC,CAAC,CAAA;SACH;aAAM;YACL,GAAG,CAAC,aAAa,GAAG,CAAC,CAAA;SACtB;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,qBAAa,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;KAChC;AACH,CAAC,CAAA;AA5DY,QAAA,KAAK,SA4DjB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActiveObservable } from '../types';
|
|
2
|
+
import { BasedServer } from '../../server';
|
|
3
|
+
export declare const updateListener: {
|
|
4
|
+
(server: BasedServer, obs: ActiveObservable, data: any, checksum?: number, diff?: any, previousChecksum?: number, isDeflate?: boolean, rawData?: any): void;
|
|
5
|
+
__isEdge__: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateListener = void 0;
|
|
4
|
+
const protocol_1 = require("../../protocol");
|
|
5
|
+
const utils_1 = require("@saulx/utils");
|
|
6
|
+
const hash_1 = require("@saulx/hash");
|
|
7
|
+
const diff_1 = require("@saulx/diff");
|
|
8
|
+
const updateListener = (server, obs, data, checksum, diff, previousChecksum, isDeflate, rawData) => {
|
|
9
|
+
if (checksum === undefined) {
|
|
10
|
+
if (data === undefined) {
|
|
11
|
+
checksum = 0;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
if (typeof data === 'object' && data !== null) {
|
|
15
|
+
checksum = (0, hash_1.hashObjectIgnoreKeyOrder)(data);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
checksum = (0, hash_1.hash)(data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (checksum !== obs.checksum) {
|
|
23
|
+
let encodedData;
|
|
24
|
+
if (data instanceof Uint8Array) {
|
|
25
|
+
obs.reusedCache = true;
|
|
26
|
+
encodedData = data;
|
|
27
|
+
if (diff) {
|
|
28
|
+
obs.diffCache = diff;
|
|
29
|
+
obs.previousChecksum = previousChecksum;
|
|
30
|
+
}
|
|
31
|
+
if (rawData) {
|
|
32
|
+
obs.rawData = rawData;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// go go go just read id and put it
|
|
36
|
+
}
|
|
37
|
+
if (!isDeflate) {
|
|
38
|
+
isDeflate = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
obs.reusedCache = false;
|
|
43
|
+
const buff = (0, protocol_1.valueToBuffer)(data);
|
|
44
|
+
if (previousChecksum === undefined) {
|
|
45
|
+
if (typeof data === 'object' && data !== null) {
|
|
46
|
+
if (obs.rawData) {
|
|
47
|
+
diff = (0, diff_1.createPatch)(obs.rawData, data);
|
|
48
|
+
obs.previousChecksum = obs.checksum;
|
|
49
|
+
}
|
|
50
|
+
obs.rawData = (0, utils_1.deepCopy)(data);
|
|
51
|
+
}
|
|
52
|
+
else if (obs.rawData) {
|
|
53
|
+
delete obs.rawData;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// keep track globally of total mem usage
|
|
57
|
+
;
|
|
58
|
+
[encodedData, isDeflate] = (0, protocol_1.encodeObservableResponse)(obs.id, checksum, buff);
|
|
59
|
+
if (diff) {
|
|
60
|
+
const diffBuff = (0, protocol_1.valueToBuffer)(diff);
|
|
61
|
+
const encodedDiffData = (0, protocol_1.encodeObservableDiffResponse)(obs.id, checksum, obs.previousChecksum, diffBuff);
|
|
62
|
+
obs.diffCache = encodedDiffData;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
obs.isDeflate = isDeflate;
|
|
66
|
+
obs.cache = encodedData;
|
|
67
|
+
obs.checksum = checksum;
|
|
68
|
+
let prevId;
|
|
69
|
+
let prevDiffId;
|
|
70
|
+
if (obs.clients.size) {
|
|
71
|
+
if (obs.diffCache) {
|
|
72
|
+
if (obs.reusedCache) {
|
|
73
|
+
prevDiffId = (0, protocol_1.updateId)(obs.diffCache, obs.id);
|
|
74
|
+
}
|
|
75
|
+
server.uwsApp.publish(String(obs.id), obs.diffCache, true, false);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (obs.reusedCache) {
|
|
79
|
+
prevId = (0, protocol_1.updateId)(encodedData, obs.id);
|
|
80
|
+
}
|
|
81
|
+
server.uwsApp.publish(String(obs.id), encodedData, true, false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (obs.functionObserveClients.size) {
|
|
85
|
+
obs.functionObserveClients.forEach((fnUpdate) => {
|
|
86
|
+
fnUpdate(obs.cache, obs.checksum, obs.diffCache, obs.previousChecksum, obs.isDeflate, obs.rawData);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (obs.onNextData) {
|
|
90
|
+
const onNextData = obs.onNextData;
|
|
91
|
+
delete obs.onNextData;
|
|
92
|
+
onNextData.forEach((fn) => fn());
|
|
93
|
+
}
|
|
94
|
+
if (prevDiffId) {
|
|
95
|
+
obs.diffCache.set(prevDiffId, 4);
|
|
96
|
+
}
|
|
97
|
+
if (prevId) {
|
|
98
|
+
encodedData.set(prevId, 4);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.updateListener = updateListener;
|
|
103
|
+
exports.updateListener.__isEdge__ = true;
|
|
104
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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{ BasedServer } from '../server';
|
|
2
|
+
import { ActiveObservable, ObservableUpdateFunction } from './types';
|
|
3
|
+
import { BasedError, BasedErrorCode } from '../error';
|
|
4
|
+
import { WebSocketSession, Context } from '../context';
|
|
5
|
+
export declare const subscribeWs: (server: BasedServer, id: number, checksum: number, ctx: Context<WebSocketSession>) => void;
|
|
6
|
+
export declare const subscribeFunction: (server: BasedServer, id: number, update: ObservableUpdateFunction) => void;
|
|
7
|
+
export declare const subscribeNext: (obs: ActiveObservable, onNext: (err?: BasedError<BasedErrorCode.ObservableFunctionError>) => void) => void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribeNext = exports.subscribeFunction = exports.subscribeWs = void 0;
|
|
4
|
+
const extendCache_1 = require("./extendCache");
|
|
5
|
+
const send_1 = require("./send");
|
|
6
|
+
const get_1 = require("./get");
|
|
7
|
+
const sendError_1 = require("../sendError");
|
|
8
|
+
const subscribeWs = (server, id, checksum, ctx) => {
|
|
9
|
+
if (!ctx.session) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
ctx.session.subscribe(String(id));
|
|
13
|
+
const obs = (0, get_1.getObs)(server, id);
|
|
14
|
+
ctx.session.obs.add(id);
|
|
15
|
+
obs.clients.add(ctx.session.id);
|
|
16
|
+
if (obs.error) {
|
|
17
|
+
(0, sendError_1.sendError)(server, ctx, obs.error.code, {
|
|
18
|
+
err: obs.error,
|
|
19
|
+
observableId: id,
|
|
20
|
+
route: {
|
|
21
|
+
name: obs.name,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (obs.cache && obs.checksum !== checksum) {
|
|
27
|
+
if (obs.diffCache && obs.previousChecksum === checksum) {
|
|
28
|
+
(0, send_1.sendObsWs)(ctx, obs.diffCache, obs);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
(0, send_1.sendObsWs)(ctx, obs.cache, obs);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.subscribeWs = subscribeWs;
|
|
36
|
+
const subscribeFunction = (server, id, update) => {
|
|
37
|
+
// TODO: FIX THIS
|
|
38
|
+
const obs = (0, get_1.getObs)(server, id);
|
|
39
|
+
obs.functionObserveClients.add(update);
|
|
40
|
+
if (obs.cache) {
|
|
41
|
+
// will make this better!
|
|
42
|
+
update(obs.cache, obs.checksum, obs.diffCache, obs.previousChecksum, obs.isDeflate);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.subscribeFunction = subscribeFunction;
|
|
46
|
+
const subscribeNext = (obs, onNext) => {
|
|
47
|
+
(0, extendCache_1.extendCache)(obs);
|
|
48
|
+
if (!obs.onNextData) {
|
|
49
|
+
obs.onNextData = new Set();
|
|
50
|
+
}
|
|
51
|
+
obs.onNextData.add(onNext);
|
|
52
|
+
};
|
|
53
|
+
exports.subscribeNext = subscribeNext;
|
|
54
|
+
//# sourceMappingURL=subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/observable/subscribe.ts"],"names":[],"mappings":";;;AAEA,+CAA2C;AAE3C,iCAAkC;AAClC,+BAA8B;AAC9B,4CAAwC;AAGjC,MAAM,WAAW,GAAG,CACzB,MAAmB,EACnB,EAAU,EACV,QAAgB,EAChB,GAA8B,EAC9B,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IAED,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IACjC,MAAM,GAAG,GAAG,IAAA,YAAM,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAE9B,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACvB,GAAG,CAAC,OAAO,CAAC,G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,EAAE;IACF,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAA;IAChB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;QACnB,GAAG,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;KAC3B;IACD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AATY,QAAA,aAAa,iBASzB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BasedError, BasedErrorCode, BasedErrorData } from '../error';
|
|
3
|
+
export declare type ObservableUpdateFunction = {
|
|
4
|
+
(data: any, checksum?: number, diff?: any, fromChecksum?: number, isDeflate?: boolean, rawData?: any, err?: BasedErrorData<BasedErrorCode.ObservableFunctionError>): void;
|
|
5
|
+
__internalObs__?: true;
|
|
6
|
+
};
|
|
7
|
+
export declare type ObserveErrorListener = (err: BasedError<BasedErrorCode.ObservableFunctionError> | BasedErrorData<BasedErrorCode.ObservableFunctionError> | BasedError<BasedErrorCode.FunctionIsNotObservable> | BasedErrorData<BasedErrorCode.FunctionIsNotObservable> | BasedError<BasedErrorCode.FunctionNotFound> | BasedErrorData<BasedErrorCode.FunctionNotFound>) => void;
|
|
8
|
+
export declare type ActiveObservable = {
|
|
9
|
+
name: string;
|
|
10
|
+
id: number;
|
|
11
|
+
reusedCache: boolean;
|
|
12
|
+
functionObserveClients: Set<ObservableUpdateFunction>;
|
|
13
|
+
clients: Set<number>;
|
|
14
|
+
onNextData?: Set<(err?: BasedError<BasedErrorCode.ObservableFunctionError>) => void>;
|
|
15
|
+
isDestroyed: boolean;
|
|
16
|
+
payload: any;
|
|
17
|
+
diffCache?: Uint8Array;
|
|
18
|
+
cache?: Uint8Array;
|
|
19
|
+
rawData?: any;
|
|
20
|
+
previousChecksum?: number;
|
|
21
|
+
isDeflate?: boolean;
|
|
22
|
+
checksum?: number;
|
|
23
|
+
closeFunction?: () => void;
|
|
24
|
+
beingDestroyed?: NodeJS.Timeout;
|
|
25
|
+
error?: BasedError<BasedErrorCode.ObservableFunctionError> | null;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/observable/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BasedServer } from '../server';
|
|
2
|
+
import { WebSocketSession, Context } from '../context';
|
|
3
|
+
import { ObservableUpdateFunction } from './types';
|
|
4
|
+
export declare const unsubscribeFunction: (server: BasedServer, id: number, update: ObservableUpdateFunction) => true | void;
|
|
5
|
+
export declare const unsubscribeWs: (server: BasedServer, id: number, ctx: Context<WebSocketSession>) => true | void;
|
|
6
|
+
export declare const unsubscribeWsIgnoreClient: (server: BasedServer, id: number, ctx: Context<WebSocketSession>) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unsubscribeWsIgnoreClient = exports.unsubscribeWs = exports.unsubscribeFunction = void 0;
|
|
4
|
+
const destroy_1 = require("./destroy");
|
|
5
|
+
const unsubscribeFunction = (server, id, update) => {
|
|
6
|
+
const obs = server.activeObservablesById.get(id);
|
|
7
|
+
if (!obs) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (obs.functionObserveClients.delete(update)) {
|
|
11
|
+
(0, destroy_1.destroyObs)(server, id);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.unsubscribeFunction = unsubscribeFunction;
|
|
16
|
+
const unsubscribeWs = (server, id, ctx) => {
|
|
17
|
+
if (!ctx.session?.obs.has(id)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const obs = server.activeObservablesById.get(id);
|
|
21
|
+
ctx.session.obs.delete(id);
|
|
22
|
+
if (!obs) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (obs.clients.delete(ctx.session.id)) {
|
|
26
|
+
(0, destroy_1.destroyObs)(server, id);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.unsubscribeWs = unsubscribeWs;
|
|
31
|
+
const unsubscribeWsIgnoreClient = (server, id, ctx) => {
|
|
32
|
+
if (!ctx.session) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const obs = server.activeObservablesById.get(id);
|
|
36
|
+
if (!obs) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
obs.clients.delete(ctx.session.id);
|
|
40
|
+
(0, destroy_1.destroyObs)(server, id);
|
|
41
|
+
};
|
|
42
|
+
exports.unsubscribeWsIgnoreClient = unsubscribeWsIgnoreClient;
|
|
43
|
+
//# sourceMappingURL=unsub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsub.js","sourceRoot":"","sources":["../../src/observable/unsub.ts"],"names":[],"mappings":";;;AAEA,uCAAsC;AAG/B,MAAM,mBAAmB,GAAG,CACjC,MAAmB,EACnB,EAAU,EACV,MAAgC,EACnB,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAChD,IAAI,CAAC,GAAG,EAAE;QACR,OAAM;KACP;IACD,IAAI,GAAG,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC7C,IAAA,oBAAU,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACtB,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAbY,QAAA,mBAAmB,uBAa/B;AAEM,MAAM,aAAa,GAAG,CAC3B,MAAmB,EACnB,EAAU,EACV,GAA8B,EACjB,EAAE;IACf,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAC7B,OAAM;KACP;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAChD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC1B,IAAI,CAAC,GAAG,EAAE;QACR,OAAM;KACP;IACD,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QACtC,IAAA,oBAAU,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACtB,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAjBY,QAAA,aAAa,iBAiBzB;AAEM,MAAM,yBAAyB,GAAG,CACvC,MAAmB,EACnB,EAAU,EACV,GAA8B,EAC9B,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEhD,IAAI,CAAC,GAAG,EAAE;QACR,OAAM;KACP;IAED,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAElC,IAAA,oBAAU,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACxB,CAAC,CAAA;AAlBY,QAAA,yBAAyB,6BAkBrC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HttpSession, WebSocketSession, Context } from '../context';
|
|
2
|
+
import { BasedServer } from '../server';
|
|
3
|
+
import { BasedFunctionRoute } from '../functions';
|
|
4
|
+
export declare const verifyRoute: (server: BasedServer, name: string, route: BasedFunctionRoute | false, ctx: Context<HttpSession | WebSocketSession>) => BasedFunctionRoute | false;
|