prostgles-client 4.0.317 → 4.0.319
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/auth/useAuthState.js +1 -1
- package/dist/getSubscriptionHandler.d.ts +1 -4
- package/dist/getSubscriptionHandler.d.ts.map +1 -1
- package/dist/getSubscriptionHandler.js +17 -17
- package/dist/hooks/reactImports.d.ts +1 -1
- package/dist/hooks/reactImports.d.ts.map +1 -1
- package/dist/hooks/useEffectDeep.d.ts +5 -3
- package/dist/hooks/useEffectDeep.d.ts.map +1 -1
- package/dist/hooks/useEffectDeep.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.no-sync.js +1 -1
- package/dist/prostgles.d.ts +2 -2
- package/dist/prostgles.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -221,7 +221,7 @@ exports.ERR_CODE_MESSAGES = {
|
|
|
221
221
|
"expired-magic-link": "Magic link expired",
|
|
222
222
|
"inactive-account": "Account is inactive",
|
|
223
223
|
"invalid-password": "Invalid or missing password",
|
|
224
|
-
"invalid-totp-code": "Invalid
|
|
224
|
+
"invalid-totp-code": "Invalid totp code",
|
|
225
225
|
"invalid-username": "Invalid or missing username",
|
|
226
226
|
"is-from-magic-link": "Cannot login with password",
|
|
227
227
|
"is-from-OAuth": "Cannot login with password",
|
|
@@ -11,12 +11,9 @@ export type Subscription = CoreParams & {
|
|
|
11
11
|
unsubChannel: string;
|
|
12
12
|
reAttach: () => Promise<void>;
|
|
13
13
|
};
|
|
14
|
-
type Subscriptions = {
|
|
15
|
-
[key: string]: Subscription;
|
|
16
|
-
};
|
|
17
14
|
export declare const getSubscriptionHandler: (initOpts: Pick<InitOptions, "socket" | "onDebug">) => {
|
|
18
15
|
addSub: (dbo: any, params: CoreParams, onChange: AnyFunction, _onError?: AnyFunction) => Promise<SubscriptionHandler>;
|
|
19
|
-
subscriptions:
|
|
16
|
+
subscriptions: Map<string, Subscription>;
|
|
20
17
|
addServerSub: ({ tableName, command, param1, param2, }: CoreParams) => Promise<SubscriptionChannels>;
|
|
21
18
|
_unsubscribe: (channelName: string, unsubChannel: string, handler: AnyFunction) => Promise<true>;
|
|
22
19
|
reAttachAll: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSubscriptionHandler.d.ts","sourceRoot":"","sources":["../lib/getSubscriptionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAS,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzF,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG;IACtC,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;
|
|
1
|
+
{"version":3,"file":"getSubscriptionHandler.d.ts","sourceRoot":"","sources":["../lib/getSubscriptionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAS,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzF,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG;IACtC,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;AAIF,eAAO,MAAM,sBAAsB,GAAI,UAAU,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,CAAC;kBAkF/E,GAAG,UACA,UAAU,YACR,WAAW,aACV,WAAW,KACrB,OAAO,CAAC,mBAAmB,CAAC;;4DA1B5B,UAAU,KAAG,OAAO,CAAC,oBAAoB,CAAC;gCAzC9B,MAAM,gBACL,MAAM,WACX,WAAW,KACnB,OAAO,CAAC,IAAI,CAAC;;CAqMjB,CAAC"}
|
|
@@ -7,7 +7,7 @@ const FunctionQueuer_1 = require("./FunctionQueuer");
|
|
|
7
7
|
const preffix = prostgles_types_1.CHANNELS._preffix;
|
|
8
8
|
const getSubscriptionHandler = (initOpts) => {
|
|
9
9
|
const { socket, onDebug } = initOpts;
|
|
10
|
-
const subscriptions =
|
|
10
|
+
const subscriptions = new Map();
|
|
11
11
|
const removeServerSub = (unsubChannel) => {
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
13
|
socket.emit(unsubChannel, {}, (err, _res) => {
|
|
@@ -24,7 +24,7 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
24
24
|
function _unsubscribe(channelName, unsubChannel, handler) {
|
|
25
25
|
(0, prostgles_1.debug)("_unsubscribe", { channelName, handler });
|
|
26
26
|
return new Promise((resolve) => {
|
|
27
|
-
const sub = subscriptions
|
|
27
|
+
const sub = subscriptions.get(channelName);
|
|
28
28
|
if (sub) {
|
|
29
29
|
sub.handlers = sub.handlers.filter((h) => h !== handler);
|
|
30
30
|
onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
@@ -37,7 +37,7 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
37
37
|
if (!sub.handlers.length) {
|
|
38
38
|
removeServerSub(unsubChannel);
|
|
39
39
|
socket.removeListener(channelName, sub.onCall);
|
|
40
|
-
delete
|
|
40
|
+
subscriptions.delete(channelName);
|
|
41
41
|
/* Not waiting for server confirmation to speed things up */
|
|
42
42
|
resolve(true);
|
|
43
43
|
}
|
|
@@ -101,22 +101,22 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
101
101
|
}
|
|
102
102
|
return Object.freeze(subHandlers);
|
|
103
103
|
};
|
|
104
|
-
const existing =
|
|
104
|
+
const existing = Array.from(subscriptions.entries()).find(([ch, s]) => {
|
|
105
105
|
return (s.tableName === tableName &&
|
|
106
106
|
s.command === command &&
|
|
107
107
|
(0, prostgles_types_1.isEqual)(s.param1 || {}, param1 || {}) &&
|
|
108
108
|
(0, prostgles_types_1.isEqual)(s.param2 || {}, param2 || {}));
|
|
109
109
|
});
|
|
110
110
|
if (existing) {
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const [existingChannel, existingSub] = existing;
|
|
112
|
+
existingSub.handlers.push(onChange);
|
|
113
113
|
setTimeout(() => {
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
onChange(
|
|
114
|
+
const sub = subscriptions.get(existingChannel);
|
|
115
|
+
if (sub === null || sub === void 0 ? void 0 : sub.lastData) {
|
|
116
|
+
onChange(sub.lastData);
|
|
117
117
|
}
|
|
118
118
|
}, 10);
|
|
119
|
-
return makeHandler(
|
|
119
|
+
return makeHandler(existingChannel, existingSub.unsubChannel);
|
|
120
120
|
}
|
|
121
121
|
const { channelName, channelNameReady, channelNameUnsubscribe } = await addServerSub({
|
|
122
122
|
tableName,
|
|
@@ -127,16 +127,16 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
127
127
|
const onCall = function (subData) {
|
|
128
128
|
/* TO DO: confirm receiving data or server will unsubscribe */
|
|
129
129
|
// if(cb) cb(true);
|
|
130
|
-
const sub = subscriptions
|
|
130
|
+
const sub = subscriptions.get(channelName);
|
|
131
131
|
const { data, err } = subData;
|
|
132
132
|
if (sub) {
|
|
133
133
|
if (data !== undefined || err !== undefined) {
|
|
134
|
-
sub.lastData = data
|
|
135
|
-
sub.handlers.forEach((
|
|
134
|
+
sub.lastData = data;
|
|
135
|
+
sub.handlers.forEach((handler) => {
|
|
136
136
|
if (err !== undefined) {
|
|
137
137
|
console.error(`Error within running subscription \n ${channelName}`, err);
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
handler(data !== null && data !== void 0 ? data : [], err);
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
@@ -148,7 +148,7 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
socket.on(channelName, onCall);
|
|
151
|
-
subscriptions
|
|
151
|
+
subscriptions.set(channelName, {
|
|
152
152
|
lastData: undefined,
|
|
153
153
|
tableName,
|
|
154
154
|
command,
|
|
@@ -162,7 +162,7 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
162
162
|
await addServerSub({ tableName, command, param1, param2 });
|
|
163
163
|
socket.emit(channelNameReady, { now: Date.now() });
|
|
164
164
|
},
|
|
165
|
-
};
|
|
165
|
+
});
|
|
166
166
|
socket.emit(channelNameReady, { now: Date.now() });
|
|
167
167
|
return makeHandler(channelName, channelNameUnsubscribe);
|
|
168
168
|
}
|
|
@@ -172,7 +172,7 @@ const getSubscriptionHandler = (initOpts) => {
|
|
|
172
172
|
*/
|
|
173
173
|
const reAttachAll = async () => {
|
|
174
174
|
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({ type: "subscriptions", command: "reAttachAll.start", subscriptions }));
|
|
175
|
-
for await (const s of
|
|
175
|
+
for await (const s of Array.from(subscriptions.values())) {
|
|
176
176
|
try {
|
|
177
177
|
await s.reAttach();
|
|
178
178
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type ReactT = typeof import("react");
|
|
2
2
|
declare let React: ReactT;
|
|
3
3
|
export declare const getReact: (throwError?: boolean) => ReactT;
|
|
4
4
|
declare const useEffect: typeof import("react").useEffect, useCallback: typeof import("react").useCallback, useRef: typeof import("react").useRef, useState: typeof import("react").useState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactImports.d.ts","sourceRoot":"","sources":["../../lib/hooks/reactImports.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"reactImports.d.ts","sourceRoot":"","sources":["../../lib/hooks/reactImports.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,cAAc,OAAO,CAAC,CAAC;AACrC,QAAA,IAAI,KAAK,EAAE,MAAM,CAAC;AAQlB,eAAO,MAAM,QAAQ,GAAI,aAAa,OAAO,KAAG,MAQ/C,CAAC;AAEF,QAAA,MACE,SAAS,oCACT,WAAW,sCACX,MAAM,iCACN,QAAQ,iCAEM,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAE3D,eAAO,MAAM,oBAAoB,eAA0C,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { React } from "./reactImports";
|
|
2
|
+
type React = typeof import("react");
|
|
2
3
|
export declare const useDeepCompareMemoize: (value: unknown) => unknown;
|
|
3
|
-
export declare const useMemoDeep:
|
|
4
|
-
export declare const useEffectDeep:
|
|
4
|
+
export declare const useMemoDeep: React["useMemo"];
|
|
5
|
+
export declare const useEffectDeep: React["useEffect"];
|
|
6
|
+
export {};
|
|
5
7
|
//# sourceMappingURL=useEffectDeep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEffectDeep.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectDeep.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"useEffectDeep.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectDeep.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAqB,MAAM,gBAAgB,CAAC;AAE1D,KAAK,KAAK,GAAG,cAAc,OAAO,CAAC,CAAC;AACpC,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,YAQnD,CAAC;AAEF,eAAO,MAAM,WAAW,EAGlB,KAAK,CAAC,SAAS,CAAC,CAAC;AAEvB,eAAO,MAAM,aAAa,EAGpB,KAAK,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -13,7 +13,7 @@ const useDeepCompareMemoize = (value) => {
|
|
|
13
13
|
exports.useDeepCompareMemoize = useDeepCompareMemoize;
|
|
14
14
|
exports.useMemoDeep = ((callback, deps) => {
|
|
15
15
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
-
return reactImports_1.React.useMemo(callback, deps
|
|
16
|
+
return reactImports_1.React.useMemo(callback, deps.map(exports.useDeepCompareMemoize));
|
|
17
17
|
});
|
|
18
18
|
exports.useEffectDeep = ((callback, deps) => {
|
|
19
19
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|