tinybase 5.4.0-beta.1 → 5.4.0-beta.2
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/@types/synchronizers/synchronizer-ws-server/index.d.cts +1 -0
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +1 -0
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +62 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +62 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +62 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +62 -0
- package/cjs/es6/index.cjs +5 -5
- package/cjs/es6/mergeable-store/index.cjs +5 -5
- package/cjs/es6/mergeable-store/with-schemas/index.cjs +5 -5
- package/cjs/es6/min/index.cjs +1 -1
- package/cjs/es6/min/index.cjs.gz +0 -0
- package/cjs/es6/min/mergeable-store/index.cjs +1 -1
- package/cjs/es6/min/mergeable-store/index.cjs.gz +0 -0
- package/cjs/es6/min/mergeable-store/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/store/index.cjs +1 -1
- package/cjs/es6/min/store/index.cjs.gz +0 -0
- package/cjs/es6/min/store/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/store/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs +1 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +1 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-simple/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-simple/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react-inspector/index.cjs +1 -1
- package/cjs/es6/min/ui-react-inspector/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/store/index.cjs +5 -5
- package/cjs/es6/store/with-schemas/index.cjs +5 -5
- package/cjs/es6/synchronizers/synchronizer-ws-client/index.cjs +2 -2
- package/cjs/es6/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +2 -2
- package/cjs/es6/synchronizers/synchronizer-ws-server/index.cjs +9 -11
- package/cjs/es6/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +9 -11
- package/cjs/es6/synchronizers/synchronizer-ws-server-durable-object/index.cjs +116 -0
- package/cjs/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +116 -0
- package/cjs/es6/synchronizers/synchronizer-ws-server-simple/index.cjs +11 -12
- package/cjs/es6/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs +11 -12
- package/cjs/es6/ui-react-inspector/index.cjs +5 -5
- package/cjs/es6/ui-react-inspector/with-schemas/index.cjs +5 -5
- package/cjs/es6/with-schemas/index.cjs +5 -5
- package/cjs/index.cjs +5 -5
- package/cjs/mergeable-store/index.cjs +5 -5
- package/cjs/mergeable-store/with-schemas/index.cjs +5 -5
- package/cjs/min/index.cjs +1 -1
- package/cjs/min/index.cjs.gz +0 -0
- package/cjs/min/mergeable-store/index.cjs +1 -1
- package/cjs/min/mergeable-store/index.cjs.gz +0 -0
- package/cjs/min/mergeable-store/with-schemas/index.cjs +1 -1
- package/cjs/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/store/index.cjs +1 -1
- package/cjs/min/store/index.cjs.gz +0 -0
- package/cjs/min/store/with-schemas/index.cjs +1 -1
- package/cjs/min/store/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs +1 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +1 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-simple/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server-simple/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/ui-react-inspector/index.cjs +1 -1
- package/cjs/min/ui-react-inspector/index.cjs.gz +0 -0
- package/cjs/min/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/cjs/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/with-schemas/index.cjs +1 -1
- package/cjs/min/with-schemas/index.cjs.gz +0 -0
- package/cjs/store/index.cjs +5 -5
- package/cjs/store/with-schemas/index.cjs +5 -5
- package/cjs/synchronizers/synchronizer-ws-client/index.cjs +2 -2
- package/cjs/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +2 -2
- package/cjs/synchronizers/synchronizer-ws-server/index.cjs +9 -11
- package/cjs/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +9 -11
- package/cjs/synchronizers/synchronizer-ws-server-durable-object/index.cjs +102 -0
- package/cjs/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +102 -0
- package/cjs/synchronizers/synchronizer-ws-server-simple/index.cjs +11 -12
- package/cjs/synchronizers/synchronizer-ws-server-simple/with-schemas/index.cjs +11 -12
- package/cjs/ui-react-inspector/index.cjs +5 -5
- package/cjs/ui-react-inspector/with-schemas/index.cjs +5 -5
- package/cjs/with-schemas/index.cjs +5 -5
- package/es6/index.js +5 -5
- package/es6/mergeable-store/index.js +5 -5
- package/es6/mergeable-store/with-schemas/index.js +5 -5
- package/es6/min/index.js +1 -1
- package/es6/min/index.js.gz +0 -0
- package/es6/min/mergeable-store/index.js +1 -1
- package/es6/min/mergeable-store/index.js.gz +0 -0
- package/es6/min/mergeable-store/with-schemas/index.js +1 -1
- package/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/es6/min/store/index.js +1 -1
- package/es6/min/store/index.js.gz +0 -0
- package/es6/min/store/with-schemas/index.js +1 -1
- package/es6/min/store/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/index.js +1 -1
- package/es6/min/ui-react-inspector/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/es6/min/with-schemas/index.js +1 -1
- package/es6/min/with-schemas/index.js.gz +0 -0
- package/es6/store/index.js +5 -5
- package/es6/store/with-schemas/index.js +5 -5
- package/es6/synchronizers/synchronizer-ws-client/index.js +2 -2
- package/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -2
- package/es6/synchronizers/synchronizer-ws-server/index.js +9 -11
- package/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +9 -11
- package/es6/synchronizers/synchronizer-ws-server-durable-object/index.js +113 -0
- package/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +113 -0
- package/es6/synchronizers/synchronizer-ws-server-simple/index.js +11 -12
- package/es6/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +11 -12
- package/es6/ui-react-inspector/index.js +5 -5
- package/es6/ui-react-inspector/with-schemas/index.js +5 -5
- package/es6/with-schemas/index.js +5 -5
- package/index.js +5 -5
- package/mergeable-store/index.js +5 -5
- package/mergeable-store/with-schemas/index.js +5 -5
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/package.json +110 -2
- package/readme.md +1 -1
- package/store/index.js +5 -5
- package/store/with-schemas/index.js +5 -5
- package/synchronizers/synchronizer-ws-client/index.js +2 -2
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -2
- package/synchronizers/synchronizer-ws-server/index.js +9 -11
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +9 -11
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +99 -0
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +99 -0
- package/synchronizers/synchronizer-ws-server-simple/index.js +11 -12
- package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +11 -12
- package/ui-react-inspector/index.js +5 -5
- package/ui-react-inspector/with-schemas/index.js +5 -5
- package/umd/es6/index.js +5 -5
- package/umd/es6/mergeable-store/index.js +5 -5
- package/umd/es6/mergeable-store/with-schemas/index.js +5 -5
- package/umd/es6/min/index.js +1 -1
- package/umd/es6/min/index.js.gz +0 -0
- package/umd/es6/min/mergeable-store/index.js +1 -1
- package/umd/es6/min/mergeable-store/index.js.gz +0 -0
- package/umd/es6/min/mergeable-store/with-schemas/index.js +1 -1
- package/umd/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/store/index.js +1 -1
- package/umd/es6/min/store/index.js.gz +0 -0
- package/umd/es6/min/store/with-schemas/index.js +1 -1
- package/umd/es6/min/store/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/ui-react-inspector/index.js +1 -1
- package/umd/es6/min/ui-react-inspector/index.js.gz +0 -0
- package/umd/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/umd/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/with-schemas/index.js +1 -1
- package/umd/es6/min/with-schemas/index.js.gz +0 -0
- package/umd/es6/store/index.js +5 -5
- package/umd/es6/store/with-schemas/index.js +5 -5
- package/umd/es6/synchronizers/synchronizer-ws-client/index.js +2 -2
- package/umd/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -2
- package/umd/es6/synchronizers/synchronizer-ws-server/index.js +9 -11
- package/umd/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +9 -11
- package/umd/es6/synchronizers/synchronizer-ws-server-durable-object/index.js +131 -0
- package/umd/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +131 -0
- package/umd/es6/synchronizers/synchronizer-ws-server-simple/index.js +11 -12
- package/umd/es6/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +11 -12
- package/umd/es6/ui-react-inspector/index.js +5 -5
- package/umd/es6/ui-react-inspector/with-schemas/index.js +5 -5
- package/umd/es6/with-schemas/index.js +5 -5
- package/umd/index.js +5 -5
- package/umd/mergeable-store/index.js +5 -5
- package/umd/mergeable-store/with-schemas/index.js +5 -5
- package/umd/min/index.js +1 -1
- package/umd/min/index.js.gz +0 -0
- package/umd/min/mergeable-store/index.js +1 -1
- package/umd/min/mergeable-store/index.js.gz +0 -0
- package/umd/min/mergeable-store/with-schemas/index.js +1 -1
- package/umd/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/umd/min/store/index.js +1 -1
- package/umd/min/store/index.js.gz +0 -0
- package/umd/min/store/with-schemas/index.js +1 -1
- package/umd/min/store/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/umd/min/ui-react-inspector/index.js +1 -1
- package/umd/min/ui-react-inspector/index.js.gz +0 -0
- package/umd/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/umd/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/umd/min/with-schemas/index.js +1 -1
- package/umd/min/with-schemas/index.js.gz +0 -0
- package/umd/store/index.js +5 -5
- package/umd/store/with-schemas/index.js +5 -5
- package/umd/synchronizers/synchronizer-ws-client/index.js +2 -2
- package/umd/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -2
- package/umd/synchronizers/synchronizer-ws-server/index.js +9 -11
- package/umd/synchronizers/synchronizer-ws-server/with-schemas/index.js +9 -11
- package/umd/synchronizers/synchronizer-ws-server-durable-object/index.js +113 -0
- package/umd/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +113 -0
- package/umd/synchronizers/synchronizer-ws-server-simple/index.js +11 -12
- package/umd/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +11 -12
- package/umd/ui-react-inspector/index.js +5 -5
- package/umd/ui-react-inspector/with-schemas/index.js +5 -5
- package/umd/with-schemas/index.js +5 -5
- package/with-schemas/index.js +5 -5
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
);
|
|
141
141
|
const createPayload = (toClientId, ...args) =>
|
|
142
142
|
createRawPayload(toClientId ?? EMPTY_STRING, jsonStringWithUndefined(args));
|
|
143
|
-
const createRawPayload = (
|
|
144
|
-
|
|
143
|
+
const createRawPayload = (clientId, remainder) =>
|
|
144
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
145
145
|
|
|
146
146
|
const newStamp = (value, time) => (time ? [value, time] : [value]);
|
|
147
147
|
const getLatestTime = (time1, time2) =>
|
|
@@ -719,10 +719,8 @@
|
|
|
719
719
|
if (clientId !== SERVER_CLIENT_ID) {
|
|
720
720
|
serverClient[3 /* Send */]?.(forwardedPayload);
|
|
721
721
|
}
|
|
722
|
-
mapForEach(clients, (otherClientId,
|
|
723
|
-
otherClientId !== clientId
|
|
724
|
-
? otherWebSocket.send(forwardedPayload)
|
|
725
|
-
: 0,
|
|
722
|
+
mapForEach(clients, (otherClientId, otherClient) =>
|
|
723
|
+
otherClientId !== clientId ? otherClient.send(forwardedPayload) : 0,
|
|
726
724
|
);
|
|
727
725
|
} else if (toClientId === SERVER_CLIENT_ID) {
|
|
728
726
|
serverClient[3 /* Send */]?.(forwardedPayload);
|
|
@@ -730,7 +728,7 @@
|
|
|
730
728
|
mapGet(clients, toClientId)?.send(forwardedPayload);
|
|
731
729
|
}
|
|
732
730
|
});
|
|
733
|
-
webSocketServer.on('connection', (
|
|
731
|
+
webSocketServer.on('connection', (client, request) =>
|
|
734
732
|
ifNotUndefined(strMatch(request.url, PATH_REGEX), ([, pathId]) =>
|
|
735
733
|
ifNotUndefined(
|
|
736
734
|
request.headers['sec-websocket-key'],
|
|
@@ -748,9 +746,9 @@
|
|
|
748
746
|
callListeners(pathIdListeners, void 0, pathId, 1);
|
|
749
747
|
await configureServerClient(serverClient, pathId, clients);
|
|
750
748
|
}
|
|
751
|
-
mapSet(clients, clientId,
|
|
749
|
+
mapSet(clients, clientId, client);
|
|
752
750
|
callListeners(clientIdListeners, [pathId], clientId, 1);
|
|
753
|
-
|
|
751
|
+
client.on('message', (data) => {
|
|
754
752
|
const payload = data.toString(UTF8);
|
|
755
753
|
if (serverClient[0 /* State */] == 0 /* Ready */) {
|
|
756
754
|
messageHandler(payload);
|
|
@@ -763,7 +761,7 @@
|
|
|
763
761
|
arrayForEach(serverClient[4 /* Buffer */], messageHandler);
|
|
764
762
|
serverClient[4 /* Buffer */] = [];
|
|
765
763
|
}
|
|
766
|
-
|
|
764
|
+
client.on('close', () => {
|
|
767
765
|
collDel(clients, clientId);
|
|
768
766
|
callListeners(clientIdListeners, [pathId], clientId, -1);
|
|
769
767
|
if (collIsEmpty(clients)) {
|
|
@@ -779,7 +777,7 @@
|
|
|
779
777
|
);
|
|
780
778
|
const getWebSocketServer = () => webSocketServer;
|
|
781
779
|
const getPathIds = () => mapKeys(clientsByPath);
|
|
782
|
-
const getClientIds = (
|
|
780
|
+
const getClientIds = (pathId) => mapKeys(mapGet(clientsByPath, pathId));
|
|
783
781
|
const addPathIdsListener = (listener) =>
|
|
784
782
|
addListener(listener, pathIdListeners);
|
|
785
783
|
const addClientIdsListener = (pathId, listener) =>
|
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
);
|
|
141
141
|
const createPayload = (toClientId, ...args) =>
|
|
142
142
|
createRawPayload(toClientId ?? EMPTY_STRING, jsonStringWithUndefined(args));
|
|
143
|
-
const createRawPayload = (
|
|
144
|
-
|
|
143
|
+
const createRawPayload = (clientId, remainder) =>
|
|
144
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
145
145
|
|
|
146
146
|
const newStamp = (value, time) => (time ? [value, time] : [value]);
|
|
147
147
|
const getLatestTime = (time1, time2) =>
|
|
@@ -719,10 +719,8 @@
|
|
|
719
719
|
if (clientId !== SERVER_CLIENT_ID) {
|
|
720
720
|
serverClient[3 /* Send */]?.(forwardedPayload);
|
|
721
721
|
}
|
|
722
|
-
mapForEach(clients, (otherClientId,
|
|
723
|
-
otherClientId !== clientId
|
|
724
|
-
? otherWebSocket.send(forwardedPayload)
|
|
725
|
-
: 0,
|
|
722
|
+
mapForEach(clients, (otherClientId, otherClient) =>
|
|
723
|
+
otherClientId !== clientId ? otherClient.send(forwardedPayload) : 0,
|
|
726
724
|
);
|
|
727
725
|
} else if (toClientId === SERVER_CLIENT_ID) {
|
|
728
726
|
serverClient[3 /* Send */]?.(forwardedPayload);
|
|
@@ -730,7 +728,7 @@
|
|
|
730
728
|
mapGet(clients, toClientId)?.send(forwardedPayload);
|
|
731
729
|
}
|
|
732
730
|
});
|
|
733
|
-
webSocketServer.on('connection', (
|
|
731
|
+
webSocketServer.on('connection', (client, request) =>
|
|
734
732
|
ifNotUndefined(strMatch(request.url, PATH_REGEX), ([, pathId]) =>
|
|
735
733
|
ifNotUndefined(
|
|
736
734
|
request.headers['sec-websocket-key'],
|
|
@@ -748,9 +746,9 @@
|
|
|
748
746
|
callListeners(pathIdListeners, void 0, pathId, 1);
|
|
749
747
|
await configureServerClient(serverClient, pathId, clients);
|
|
750
748
|
}
|
|
751
|
-
mapSet(clients, clientId,
|
|
749
|
+
mapSet(clients, clientId, client);
|
|
752
750
|
callListeners(clientIdListeners, [pathId], clientId, 1);
|
|
753
|
-
|
|
751
|
+
client.on('message', (data) => {
|
|
754
752
|
const payload = data.toString(UTF8);
|
|
755
753
|
if (serverClient[0 /* State */] == 0 /* Ready */) {
|
|
756
754
|
messageHandler(payload);
|
|
@@ -763,7 +761,7 @@
|
|
|
763
761
|
arrayForEach(serverClient[4 /* Buffer */], messageHandler);
|
|
764
762
|
serverClient[4 /* Buffer */] = [];
|
|
765
763
|
}
|
|
766
|
-
|
|
764
|
+
client.on('close', () => {
|
|
767
765
|
collDel(clients, clientId);
|
|
768
766
|
callListeners(clientIdListeners, [pathId], clientId, -1);
|
|
769
767
|
if (collIsEmpty(clients)) {
|
|
@@ -779,7 +777,7 @@
|
|
|
779
777
|
);
|
|
780
778
|
const getWebSocketServer = () => webSocketServer;
|
|
781
779
|
const getPathIds = () => mapKeys(clientsByPath);
|
|
782
|
-
const getClientIds = (
|
|
780
|
+
const getClientIds = (pathId) => mapKeys(mapGet(clientsByPath, pathId));
|
|
783
781
|
const addPathIdsListener = (listener) =>
|
|
784
782
|
addListener(listener, pathIdListeners);
|
|
785
783
|
const addClientIdsListener = (pathId, listener) =>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined'
|
|
3
|
+
? factory(exports, require('cloudflare:workers'))
|
|
4
|
+
: typeof define === 'function' && define.amd
|
|
5
|
+
? define(['exports', 'cloudflare:workers'], factory)
|
|
6
|
+
: ((global =
|
|
7
|
+
typeof globalThis !== 'undefined' ? globalThis : global || self),
|
|
8
|
+
factory(
|
|
9
|
+
(global.TinyBaseSynchronizerWsServerDurableObject = {}),
|
|
10
|
+
global.cloudflare_workers,
|
|
11
|
+
));
|
|
12
|
+
})(this, function (exports, cloudflare_workers) {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const EMPTY_STRING = '';
|
|
16
|
+
const strMatch = (str, regex) => str?.match(regex);
|
|
17
|
+
|
|
18
|
+
const isUndefined = (thing) => thing == void 0;
|
|
19
|
+
const ifNotUndefined = (value, then, otherwise) =>
|
|
20
|
+
isUndefined(value) ? otherwise?.() : then(value);
|
|
21
|
+
const slice = (arrayOrString, start, end) => arrayOrString.slice(start, end);
|
|
22
|
+
const size = (arrayOrString) => arrayOrString.length;
|
|
23
|
+
|
|
24
|
+
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
25
|
+
const arrayMap = (array, cb) => array.map(cb);
|
|
26
|
+
const arrayIsEmpty = (array) => size(array) == 0;
|
|
27
|
+
|
|
28
|
+
const object = Object;
|
|
29
|
+
const objValues = (obj) => object.values(obj);
|
|
30
|
+
|
|
31
|
+
const MESSAGE_SEPARATOR = '\n';
|
|
32
|
+
const ifPayloadValid = (payload, then) => {
|
|
33
|
+
const splitAt = payload.indexOf(MESSAGE_SEPARATOR);
|
|
34
|
+
if (splitAt !== -1) {
|
|
35
|
+
then(slice(payload, 0, splitAt), slice(payload, splitAt + 1));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const createRawPayload = (clientId, remainder) =>
|
|
39
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
40
|
+
|
|
41
|
+
const PATH_REGEX = /\/([^?]*)/;
|
|
42
|
+
const getPathId = (request) =>
|
|
43
|
+
strMatch(new URL(request.url).pathname, PATH_REGEX)?.[1] ?? EMPTY_STRING;
|
|
44
|
+
const getClientId = (request) =>
|
|
45
|
+
request.headers.get('upgrade')?.toLowerCase() == 'websocket'
|
|
46
|
+
? request.headers.get('sec-websocket-key')
|
|
47
|
+
: null;
|
|
48
|
+
const createResponse = (status, webSocket = null, body = null) =>
|
|
49
|
+
new Response(body, {status, webSocket});
|
|
50
|
+
const createUpgradeRequiredResponse = () =>
|
|
51
|
+
createResponse(426, null, 'Upgrade required');
|
|
52
|
+
class WsServerDurableObject extends cloudflare_workers.DurableObject {
|
|
53
|
+
constructor(ctx, env) {
|
|
54
|
+
super(ctx, env);
|
|
55
|
+
}
|
|
56
|
+
fetch(request) {
|
|
57
|
+
const pathId = getPathId(request);
|
|
58
|
+
return ifNotUndefined(
|
|
59
|
+
getClientId(request),
|
|
60
|
+
(clientId) => {
|
|
61
|
+
const [webSocket, client] = objValues(new WebSocketPair());
|
|
62
|
+
client.serializeAttachment({pathId});
|
|
63
|
+
if (arrayIsEmpty(this.ctx.getWebSockets())) {
|
|
64
|
+
this.onPathId(pathId, 1);
|
|
65
|
+
}
|
|
66
|
+
this.ctx.acceptWebSocket(client, [clientId]);
|
|
67
|
+
this.onClientId(pathId, clientId, 1);
|
|
68
|
+
return createResponse(101, webSocket);
|
|
69
|
+
},
|
|
70
|
+
createUpgradeRequiredResponse,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
webSocketMessage(client, message) {
|
|
74
|
+
ifNotUndefined(this.ctx.getTags(client)[0], (clientId) =>
|
|
75
|
+
ifPayloadValid(message.toString(), (toClientId, remainder) => {
|
|
76
|
+
const forwardedPayload = createRawPayload(clientId, remainder);
|
|
77
|
+
if (toClientId === EMPTY_STRING) {
|
|
78
|
+
arrayForEach(this.ctx.getWebSockets(), (otherClient) =>
|
|
79
|
+
otherClient !== client ? otherClient.send(forwardedPayload) : 0,
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
this.ctx.getWebSockets(toClientId)[0]?.send(forwardedPayload);
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
webSocketClose(client) {
|
|
88
|
+
const {pathId} = client.deserializeAttachment();
|
|
89
|
+
this.onClientId(pathId, this.ctx.getTags(client)[0], -1);
|
|
90
|
+
if (size(this.ctx.getWebSockets()) == 1) {
|
|
91
|
+
this.onPathId(pathId, -1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// --
|
|
95
|
+
getClientIds(_pathId) {
|
|
96
|
+
return arrayMap(
|
|
97
|
+
this.ctx.getWebSockets(),
|
|
98
|
+
(client) => this.ctx.getTags(client)[0],
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
onPathId(_pathId, _addedOrRemoved) {}
|
|
102
|
+
onClientId(_pathId, _clientId, _addedOrRemoved) {}
|
|
103
|
+
}
|
|
104
|
+
const getWsServerDurableObjectFetch = (namespace) => (request, env) =>
|
|
105
|
+
getClientId(request)
|
|
106
|
+
? env[namespace]
|
|
107
|
+
.get(env[namespace].idFromName(getPathId(request)))
|
|
108
|
+
.fetch(request)
|
|
109
|
+
: createUpgradeRequiredResponse();
|
|
110
|
+
|
|
111
|
+
exports.WsServerDurableObject = WsServerDurableObject;
|
|
112
|
+
exports.getWsServerDurableObjectFetch = getWsServerDurableObjectFetch;
|
|
113
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined'
|
|
3
|
+
? factory(exports, require('cloudflare:workers'))
|
|
4
|
+
: typeof define === 'function' && define.amd
|
|
5
|
+
? define(['exports', 'cloudflare:workers'], factory)
|
|
6
|
+
: ((global =
|
|
7
|
+
typeof globalThis !== 'undefined' ? globalThis : global || self),
|
|
8
|
+
factory(
|
|
9
|
+
(global.TinyBaseSynchronizerWsServerDurableObject = {}),
|
|
10
|
+
global.cloudflare_workers,
|
|
11
|
+
));
|
|
12
|
+
})(this, function (exports, cloudflare_workers) {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const EMPTY_STRING = '';
|
|
16
|
+
const strMatch = (str, regex) => str?.match(regex);
|
|
17
|
+
|
|
18
|
+
const isUndefined = (thing) => thing == void 0;
|
|
19
|
+
const ifNotUndefined = (value, then, otherwise) =>
|
|
20
|
+
isUndefined(value) ? otherwise?.() : then(value);
|
|
21
|
+
const slice = (arrayOrString, start, end) => arrayOrString.slice(start, end);
|
|
22
|
+
const size = (arrayOrString) => arrayOrString.length;
|
|
23
|
+
|
|
24
|
+
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
25
|
+
const arrayMap = (array, cb) => array.map(cb);
|
|
26
|
+
const arrayIsEmpty = (array) => size(array) == 0;
|
|
27
|
+
|
|
28
|
+
const object = Object;
|
|
29
|
+
const objValues = (obj) => object.values(obj);
|
|
30
|
+
|
|
31
|
+
const MESSAGE_SEPARATOR = '\n';
|
|
32
|
+
const ifPayloadValid = (payload, then) => {
|
|
33
|
+
const splitAt = payload.indexOf(MESSAGE_SEPARATOR);
|
|
34
|
+
if (splitAt !== -1) {
|
|
35
|
+
then(slice(payload, 0, splitAt), slice(payload, splitAt + 1));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const createRawPayload = (clientId, remainder) =>
|
|
39
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
40
|
+
|
|
41
|
+
const PATH_REGEX = /\/([^?]*)/;
|
|
42
|
+
const getPathId = (request) =>
|
|
43
|
+
strMatch(new URL(request.url).pathname, PATH_REGEX)?.[1] ?? EMPTY_STRING;
|
|
44
|
+
const getClientId = (request) =>
|
|
45
|
+
request.headers.get('upgrade')?.toLowerCase() == 'websocket'
|
|
46
|
+
? request.headers.get('sec-websocket-key')
|
|
47
|
+
: null;
|
|
48
|
+
const createResponse = (status, webSocket = null, body = null) =>
|
|
49
|
+
new Response(body, {status, webSocket});
|
|
50
|
+
const createUpgradeRequiredResponse = () =>
|
|
51
|
+
createResponse(426, null, 'Upgrade required');
|
|
52
|
+
class WsServerDurableObject extends cloudflare_workers.DurableObject {
|
|
53
|
+
constructor(ctx, env) {
|
|
54
|
+
super(ctx, env);
|
|
55
|
+
}
|
|
56
|
+
fetch(request) {
|
|
57
|
+
const pathId = getPathId(request);
|
|
58
|
+
return ifNotUndefined(
|
|
59
|
+
getClientId(request),
|
|
60
|
+
(clientId) => {
|
|
61
|
+
const [webSocket, client] = objValues(new WebSocketPair());
|
|
62
|
+
client.serializeAttachment({pathId});
|
|
63
|
+
if (arrayIsEmpty(this.ctx.getWebSockets())) {
|
|
64
|
+
this.onPathId(pathId, 1);
|
|
65
|
+
}
|
|
66
|
+
this.ctx.acceptWebSocket(client, [clientId]);
|
|
67
|
+
this.onClientId(pathId, clientId, 1);
|
|
68
|
+
return createResponse(101, webSocket);
|
|
69
|
+
},
|
|
70
|
+
createUpgradeRequiredResponse,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
webSocketMessage(client, message) {
|
|
74
|
+
ifNotUndefined(this.ctx.getTags(client)[0], (clientId) =>
|
|
75
|
+
ifPayloadValid(message.toString(), (toClientId, remainder) => {
|
|
76
|
+
const forwardedPayload = createRawPayload(clientId, remainder);
|
|
77
|
+
if (toClientId === EMPTY_STRING) {
|
|
78
|
+
arrayForEach(this.ctx.getWebSockets(), (otherClient) =>
|
|
79
|
+
otherClient !== client ? otherClient.send(forwardedPayload) : 0,
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
this.ctx.getWebSockets(toClientId)[0]?.send(forwardedPayload);
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
webSocketClose(client) {
|
|
88
|
+
const {pathId} = client.deserializeAttachment();
|
|
89
|
+
this.onClientId(pathId, this.ctx.getTags(client)[0], -1);
|
|
90
|
+
if (size(this.ctx.getWebSockets()) == 1) {
|
|
91
|
+
this.onPathId(pathId, -1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// --
|
|
95
|
+
getClientIds(_pathId) {
|
|
96
|
+
return arrayMap(
|
|
97
|
+
this.ctx.getWebSockets(),
|
|
98
|
+
(client) => this.ctx.getTags(client)[0],
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
onPathId(_pathId, _addedOrRemoved) {}
|
|
102
|
+
onClientId(_pathId, _clientId, _addedOrRemoved) {}
|
|
103
|
+
}
|
|
104
|
+
const getWsServerDurableObjectFetch = (namespace) => (request, env) =>
|
|
105
|
+
getClientId(request)
|
|
106
|
+
? env[namespace]
|
|
107
|
+
.get(env[namespace].idFromName(getPathId(request)))
|
|
108
|
+
.fetch(request)
|
|
109
|
+
: createUpgradeRequiredResponse();
|
|
110
|
+
|
|
111
|
+
exports.WsServerDurableObject = WsServerDurableObject;
|
|
112
|
+
exports.getWsServerDurableObjectFetch = getWsServerDurableObjectFetch;
|
|
113
|
+
});
|
|
@@ -48,35 +48,34 @@
|
|
|
48
48
|
then(slice(payload, 0, splitAt), slice(payload, splitAt + 1));
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const createRawPayload = (
|
|
52
|
-
|
|
51
|
+
const createRawPayload = (clientId, remainder) =>
|
|
52
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
53
53
|
|
|
54
54
|
const PATH_REGEX = /\/([^?]*)/;
|
|
55
55
|
const createWsServerSimple = (webSocketServer) => {
|
|
56
56
|
const clientsByPath = mapNew();
|
|
57
|
-
webSocketServer.on('connection', (
|
|
57
|
+
webSocketServer.on('connection', (client, request) =>
|
|
58
58
|
ifNotUndefined(strMatch(request.url, PATH_REGEX), ([, pathId]) =>
|
|
59
59
|
ifNotUndefined(
|
|
60
60
|
request.headers['sec-websocket-key'],
|
|
61
61
|
async (clientId) => {
|
|
62
62
|
const clients = mapEnsure(clientsByPath, pathId, mapNew);
|
|
63
|
-
mapSet(clients, clientId,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
ifPayloadValid(payload, (toClientId, remainder) => {
|
|
63
|
+
mapSet(clients, clientId, client);
|
|
64
|
+
client.on('message', (data) =>
|
|
65
|
+
ifPayloadValid(data.toString(UTF8), (toClientId, remainder) => {
|
|
67
66
|
const forwardedPayload = createRawPayload(clientId, remainder);
|
|
68
67
|
if (toClientId === EMPTY_STRING) {
|
|
69
|
-
mapForEach(clients, (otherClientId,
|
|
68
|
+
mapForEach(clients, (otherClientId, otherClient) =>
|
|
70
69
|
otherClientId !== clientId
|
|
71
|
-
?
|
|
70
|
+
? otherClient.send(forwardedPayload)
|
|
72
71
|
: 0,
|
|
73
72
|
);
|
|
74
73
|
} else {
|
|
75
74
|
mapGet(clients, toClientId)?.send(forwardedPayload);
|
|
76
75
|
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
client.on('close', () => {
|
|
80
79
|
collDel(clients, clientId);
|
|
81
80
|
if (collIsEmpty(clients)) {
|
|
82
81
|
collDel(clientsByPath, pathId);
|
|
@@ -48,35 +48,34 @@
|
|
|
48
48
|
then(slice(payload, 0, splitAt), slice(payload, splitAt + 1));
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const createRawPayload = (
|
|
52
|
-
|
|
51
|
+
const createRawPayload = (clientId, remainder) =>
|
|
52
|
+
clientId + MESSAGE_SEPARATOR + remainder;
|
|
53
53
|
|
|
54
54
|
const PATH_REGEX = /\/([^?]*)/;
|
|
55
55
|
const createWsServerSimple = (webSocketServer) => {
|
|
56
56
|
const clientsByPath = mapNew();
|
|
57
|
-
webSocketServer.on('connection', (
|
|
57
|
+
webSocketServer.on('connection', (client, request) =>
|
|
58
58
|
ifNotUndefined(strMatch(request.url, PATH_REGEX), ([, pathId]) =>
|
|
59
59
|
ifNotUndefined(
|
|
60
60
|
request.headers['sec-websocket-key'],
|
|
61
61
|
async (clientId) => {
|
|
62
62
|
const clients = mapEnsure(clientsByPath, pathId, mapNew);
|
|
63
|
-
mapSet(clients, clientId,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
ifPayloadValid(payload, (toClientId, remainder) => {
|
|
63
|
+
mapSet(clients, clientId, client);
|
|
64
|
+
client.on('message', (data) =>
|
|
65
|
+
ifPayloadValid(data.toString(UTF8), (toClientId, remainder) => {
|
|
67
66
|
const forwardedPayload = createRawPayload(clientId, remainder);
|
|
68
67
|
if (toClientId === EMPTY_STRING) {
|
|
69
|
-
mapForEach(clients, (otherClientId,
|
|
68
|
+
mapForEach(clients, (otherClientId, otherClient) =>
|
|
70
69
|
otherClientId !== clientId
|
|
71
|
-
?
|
|
70
|
+
? otherClient.send(forwardedPayload)
|
|
72
71
|
: 0,
|
|
73
72
|
);
|
|
74
73
|
} else {
|
|
75
74
|
mapGet(clients, toClientId)?.send(forwardedPayload);
|
|
76
75
|
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
client.on('close', () => {
|
|
80
79
|
collDel(clients, clientId);
|
|
81
80
|
if (collIsEmpty(clients)) {
|
|
82
81
|
collDel(clientsByPath, pathId);
|
|
@@ -2301,11 +2301,11 @@
|
|
|
2301
2301
|
};
|
|
2302
2302
|
const getNewRowId = (tableId, reuse) => {
|
|
2303
2303
|
const [getId] = mapGet(tablePoolFunctions, tableId);
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
}
|
|
2308
|
-
return
|
|
2304
|
+
let rowId;
|
|
2305
|
+
do {
|
|
2306
|
+
rowId = getId(reuse);
|
|
2307
|
+
} while (collHas(mapGet(tablesMap, tableId), rowId));
|
|
2308
|
+
return rowId;
|
|
2309
2309
|
};
|
|
2310
2310
|
const getOrCreateTable = (tableId) =>
|
|
2311
2311
|
mapGet(tablesMap, tableId) ?? setValidTable(tableId, {});
|
|
@@ -2301,11 +2301,11 @@
|
|
|
2301
2301
|
};
|
|
2302
2302
|
const getNewRowId = (tableId, reuse) => {
|
|
2303
2303
|
const [getId] = mapGet(tablePoolFunctions, tableId);
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
}
|
|
2308
|
-
return
|
|
2304
|
+
let rowId;
|
|
2305
|
+
do {
|
|
2306
|
+
rowId = getId(reuse);
|
|
2307
|
+
} while (collHas(mapGet(tablesMap, tableId), rowId));
|
|
2308
|
+
return rowId;
|
|
2309
2309
|
};
|
|
2310
2310
|
const getOrCreateTable = (tableId) =>
|
|
2311
2311
|
mapGet(tablesMap, tableId) ?? setValidTable(tableId, {});
|
|
@@ -2207,11 +2207,11 @@
|
|
|
2207
2207
|
};
|
|
2208
2208
|
const getNewRowId = (tableId, reuse) => {
|
|
2209
2209
|
const [getId] = mapGet(tablePoolFunctions, tableId);
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
}
|
|
2214
|
-
return
|
|
2210
|
+
let rowId;
|
|
2211
|
+
do {
|
|
2212
|
+
rowId = getId(reuse);
|
|
2213
|
+
} while (collHas(mapGet(tablesMap, tableId), rowId));
|
|
2214
|
+
return rowId;
|
|
2215
2215
|
};
|
|
2216
2216
|
const getOrCreateTable = (tableId) =>
|
|
2217
2217
|
mapGet(tablesMap, tableId) ?? setValidTable(tableId, {});
|
package/with-schemas/index.js
CHANGED
|
@@ -2155,11 +2155,11 @@ const createStore = () => {
|
|
|
2155
2155
|
};
|
|
2156
2156
|
const getNewRowId = (tableId, reuse) => {
|
|
2157
2157
|
const [getId] = mapGet(tablePoolFunctions, tableId);
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
}
|
|
2162
|
-
return
|
|
2158
|
+
let rowId;
|
|
2159
|
+
do {
|
|
2160
|
+
rowId = getId(reuse);
|
|
2161
|
+
} while (collHas(mapGet(tablesMap, tableId), rowId));
|
|
2162
|
+
return rowId;
|
|
2163
2163
|
};
|
|
2164
2164
|
const getOrCreateTable = (tableId) =>
|
|
2165
2165
|
mapGet(tablesMap, tableId) ?? setValidTable(tableId, {});
|