@m4l/gclick-realtime 1.6.1 → 1.7.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/package.json +1 -1
- package/web/consumer/RealTimeConsumerContext.d.ts.map +1 -1
- package/web/consumer/RealTimeConsumerContext.js +135 -51
- package/web/consumer/index.d.ts +1 -1
- package/web/consumer/index.d.ts.map +1 -1
- package/web/consumer/store.d.ts.map +1 -1
- package/web/consumer/store.helpers.d.ts +13 -5
- package/web/consumer/store.helpers.d.ts.map +1 -1
- package/web/consumer/store.helpers.js +117 -59
- package/web/consumer/store.js +81 -75
- package/web/consumer/types.d.ts +87 -1
- package/web/consumer/types.d.ts.map +1 -1
- package/web/host/hostRuntime.d.ts.map +1 -1
- package/web/host/hostRuntime.js +11 -11
- package/web/index.js +32 -31
- package/web/shared/constants.d.ts +2 -0
- package/web/shared/constants.d.ts.map +1 -1
- package/web/shared/constants.js +8 -7
- package/web/shared/index.d.ts +2 -2
- package/web/shared/index.d.ts.map +1 -1
- package/web/shared/runtimeTypes.d.ts +2 -2
- package/web/shared/runtimeTypes.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealTimeConsumerContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/RealTimeConsumerContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RealTimeConsumerContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/RealTimeConsumerContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAYjB,QAAA,MAAM,uBAAuB;;UAE5B,CAAC;AAyGF;;GAEG;AACH,iBAAS,wBAAwB,CAAC,KAAK,EAAE,qBAAqB,2CA2J7D;AAED,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,72 +1,156 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as V } from "../../_virtual/jsx-runtime.js";
|
|
2
2
|
import { r as o } from "../../_virtual/index.js";
|
|
3
|
-
import { createRealTimeConsumerStore as
|
|
4
|
-
import { RESOURCE_TYPE_DEVICES as
|
|
5
|
-
import { recordRealtimePerformanceMetric as
|
|
6
|
-
const
|
|
3
|
+
import { createRealTimeConsumerStore as W } from "./store.js";
|
|
4
|
+
import { RESOURCE_TYPE_DEVICES as g } from "../shared/constants.js";
|
|
5
|
+
import { recordRealtimePerformanceMetric as h } from "../shared/performanceMetrics.js";
|
|
6
|
+
const Y = o.createContext(
|
|
7
7
|
null
|
|
8
8
|
);
|
|
9
|
-
let
|
|
10
|
-
function
|
|
11
|
-
|
|
9
|
+
let C = 0, T = 0;
|
|
10
|
+
function I(e) {
|
|
11
|
+
C = Math.max(
|
|
12
12
|
0,
|
|
13
|
-
|
|
14
|
-
),
|
|
13
|
+
C + e
|
|
14
|
+
), h(
|
|
15
15
|
"consumerActiveStoreCount",
|
|
16
|
-
|
|
16
|
+
C
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
19
|
+
function k(e) {
|
|
20
|
+
T = Math.max(
|
|
21
21
|
0,
|
|
22
|
-
|
|
23
|
-
),
|
|
22
|
+
T + e
|
|
23
|
+
), h(
|
|
24
24
|
"consumerActiveSubscriptionCount",
|
|
25
|
-
|
|
25
|
+
T
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function $(e, r, s, n) {
|
|
29
|
+
return e || [
|
|
30
|
+
{
|
|
31
|
+
resourceTypeId: g,
|
|
32
|
+
hasResourcesDecorators: n[g],
|
|
33
|
+
onMessagesCallbacks: r,
|
|
34
|
+
onSubscribeCallbacks: s,
|
|
35
|
+
storeMode: "full"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function q(e) {
|
|
40
|
+
return e.reduce(
|
|
41
|
+
(r, s) => (s.hasResourcesDecorators?.length && (r[s.resourceTypeId] = s.hasResourcesDecorators), r),
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function z(e) {
|
|
46
|
+
return e.reduce(
|
|
47
|
+
(r, s) => {
|
|
48
|
+
const { messageProjector: n, resourceTypeId: u, snapshotProjector: a, storeMode: t } = s;
|
|
49
|
+
return !t && !n && !a || (r[u] = {
|
|
50
|
+
mode: t,
|
|
51
|
+
messageProjector: n,
|
|
52
|
+
snapshotProjector: a
|
|
53
|
+
}), r;
|
|
54
|
+
},
|
|
55
|
+
{}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function L(e) {
|
|
29
59
|
const {
|
|
30
|
-
children:
|
|
31
|
-
onMessagesCallbacks:
|
|
32
|
-
onSubscribeCallbacks:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
children: r,
|
|
61
|
+
onMessagesCallbacks: s = [],
|
|
62
|
+
onSubscribeCallbacks: n = [],
|
|
63
|
+
onTransportReconnectCallbacks: u = [],
|
|
64
|
+
hasResourcesTypesDecorators: a = {},
|
|
65
|
+
producerTools: t,
|
|
66
|
+
resourceSubscriptions: S,
|
|
67
|
+
windowId: y,
|
|
68
|
+
storeDevtoolsEnabled: x = !1,
|
|
69
|
+
...D
|
|
70
|
+
} = e, i = o.useRef(null), j = o.useRef(y), H = o.useRef(
|
|
71
|
+
`${y}:transport-reconnect`
|
|
72
|
+
), l = j.current, R = H.current, c = o.useMemo(
|
|
73
|
+
() => $(
|
|
74
|
+
S,
|
|
75
|
+
s,
|
|
76
|
+
n,
|
|
77
|
+
a
|
|
78
|
+
),
|
|
79
|
+
[
|
|
80
|
+
a,
|
|
81
|
+
s,
|
|
82
|
+
n,
|
|
83
|
+
S
|
|
84
|
+
]
|
|
85
|
+
), P = o.useMemo(
|
|
86
|
+
() => q(c),
|
|
87
|
+
[c]
|
|
88
|
+
), w = o.useMemo(
|
|
89
|
+
() => z(c),
|
|
90
|
+
[c]
|
|
91
|
+
);
|
|
92
|
+
return i.current || (i.current = W(
|
|
40
93
|
{
|
|
41
|
-
...
|
|
42
|
-
storeId:
|
|
43
|
-
hasResourcesTypesDecorators:
|
|
94
|
+
...D,
|
|
95
|
+
storeId: l,
|
|
96
|
+
hasResourcesTypesDecorators: P,
|
|
97
|
+
hasResourcesTypesStoreConfig: w
|
|
44
98
|
},
|
|
45
|
-
|
|
46
|
-
)), o.useEffect(() => (
|
|
47
|
-
|
|
99
|
+
x
|
|
100
|
+
)), o.useEffect(() => (I(1), () => {
|
|
101
|
+
I(-1);
|
|
48
102
|
}), []), o.useEffect(() => {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
103
|
+
if (!i.current)
|
|
104
|
+
return;
|
|
105
|
+
const { onMessages: d, loadResourceType: p } = i.current.getState().realTimeConsumerActions, v = [];
|
|
106
|
+
return c.forEach((m) => {
|
|
107
|
+
const {
|
|
108
|
+
onMessagesCallbacks: E = [],
|
|
109
|
+
onSubscribeCallbacks: A = [],
|
|
110
|
+
resourceTypeId: f,
|
|
111
|
+
storeMode: O = "full"
|
|
112
|
+
} = m, M = O !== "callbacks-only", _ = M ? [d, ...E] : E, b = t.subscribeResourceType(
|
|
113
|
+
f,
|
|
114
|
+
{
|
|
115
|
+
clientId: l,
|
|
116
|
+
onMessageCallbacks: _
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
M && p(f, b), A.forEach((U) => {
|
|
120
|
+
U(
|
|
121
|
+
f,
|
|
122
|
+
b
|
|
58
123
|
);
|
|
59
|
-
}),
|
|
124
|
+
}), h(
|
|
60
125
|
"consumerSnapshotResourceCount",
|
|
61
|
-
Object.keys(
|
|
62
|
-
),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
126
|
+
Object.keys(b).length
|
|
127
|
+
), k(1), v.push(f);
|
|
128
|
+
}), () => {
|
|
129
|
+
v.forEach((m) => {
|
|
130
|
+
t.unsubscribe(m, l), k(-1);
|
|
131
|
+
});
|
|
66
132
|
};
|
|
67
|
-
}, [
|
|
133
|
+
}, [t, c, l]), o.useEffect(() => {
|
|
134
|
+
if (u.length !== 0)
|
|
135
|
+
return t.subscribeTransportReconnect({
|
|
136
|
+
clientId: R,
|
|
137
|
+
onReconnectCallback: (d) => {
|
|
138
|
+
u.forEach((p) => {
|
|
139
|
+
p(d);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}), () => {
|
|
143
|
+
t.unsubscribeTransportReconnect(
|
|
144
|
+
R
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
}, [
|
|
148
|
+
u,
|
|
149
|
+
t,
|
|
150
|
+
R
|
|
151
|
+
]), /* @__PURE__ */ V.jsx(Y.Provider, { value: i.current, children: r });
|
|
68
152
|
}
|
|
69
153
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
154
|
+
Y as RealTimeConsumerContext,
|
|
155
|
+
L as RealTimeConsumerProvider
|
|
72
156
|
};
|
package/web/consumer/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { RealTimeConsumerContext, RealTimeConsumerProvider, } from './RealTimeCo
|
|
|
2
2
|
export { useRealTimeConsumer } from './useRealTimeConsumer';
|
|
3
3
|
export { createRealTimeConsumerStore } from './store';
|
|
4
4
|
export type { RealTimeConsumerStoreType } from './store';
|
|
5
|
-
export type { InitialRealTimeStoreProps, RealTimeConsumer, RealTimeConsumerStoreState, RealTimeConsumerStoreStateWithActions, RealTimeMessageDecorator, RealTimeProviderProps, } from './types';
|
|
5
|
+
export type { InitialRealTimeStoreProps, RealTimeConsumer, RealTimeConsumerMessageProjector, RealTimeConsumerMessageProjectorContext, RealTimeConsumerResourceStoreConfig, RealTimeConsumerResourceSubscription, RealTimeConsumerSnapshotProjector, RealTimeConsumerStoreMode, RealTimeConsumerStoreState, RealTimeConsumerStoreStateWithActions, RealTimeMessageDecorator, RealTimeProviderProps, } from './types';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC1B,qCAAqC,EACrC,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,yBAAyB,EACzB,gBAAgB,EAChB,gCAAgC,EAChC,uCAAuC,EACvC,mCAAmC,EACnC,oCAAoC,EACpC,iCAAiC,EACjC,yBAAyB,EACzB,0BAA0B,EAC1B,qCAAqC,EACrC,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EAEzB,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAwBjB,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAkEzD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,yBAAyB,EACpC,oBAAoB,UAAQ;;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EAEzB,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAwBjB,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAkEzD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,yBAAyB,EACpC,oBAAoB,UAAQ;;EAwU7B;AAED,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAChD,OAAO,2BAA2B,CACnC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { DevtoolsOptions } from 'zustand/middleware';
|
|
|
2
2
|
import { StateCreator } from 'zustand';
|
|
3
3
|
import { ObjectQueue } from '@m4l/realtime-runtime';
|
|
4
4
|
import { MessageQueueManager, RealTimeMessage, RealTimeMessagePayload, RealTimeReadonlyResourceHash, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../shared/runtimeTypes';
|
|
5
|
-
import { RealTimeConsumerStoreStateWithActions, RealTimeMessageDecorator } from './types';
|
|
5
|
+
import { RealTimeConsumerResourceStoreConfig, RealTimeConsumerStoreStateWithActions, RealTimeMessageDecorator } from './types';
|
|
6
6
|
type ConsumerSnapshotResourceKey = string;
|
|
7
7
|
type RealTimeConsumerSnapshotEntry = [
|
|
8
8
|
resourceSerialId: RealTimeResourceSerialId,
|
|
@@ -13,9 +13,17 @@ type RealTimeConsumerSnapshotEntry = [
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function decorateResourceOrMessage(resourceSerialId: RealTimeResourceSerialId, resourceOrMessage: RealTimeMessagePayload, decorators?: RealTimeMessageDecorator[]): RealTimeMessagePayload;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Clone one consumer resource and guarantee the hash key also exists inside the stored payload.
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function createStoredConsumerResource(resourceSerialId: RealTimeResourceSerialId, resource: RealTimeMessagePayload): RealTimeMessagePayload;
|
|
19
|
+
/**
|
|
20
|
+
* Decorate and optionally project one startup snapshot resource into the local consumer shape.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildConsumerSnapshotResource(resourceSerialId: RealTimeResourceSerialId, resource: RealTimeMessagePayload, decorators?: RealTimeMessageDecorator[], storeConfig?: RealTimeConsumerResourceStoreConfig): RealTimeMessagePayload | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Decorate the full resource hash for one resource type and optionally project it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildConsumerSnapshotResources(resources: RealTimeReadonlyResourceHash, decorators?: RealTimeMessageDecorator[], storeConfig?: RealTimeConsumerResourceStoreConfig): Record<string, RealTimeMessagePayload>;
|
|
19
27
|
/**
|
|
20
28
|
* Create the queue manager used by one consumer resource type.
|
|
21
29
|
*/
|
|
@@ -31,7 +39,7 @@ export declare function createConsumerSnapshotEntries(resources: RealTimeReadonl
|
|
|
31
39
|
/**
|
|
32
40
|
* Apply one startup snapshot slice to the consumer hash without overwriting live-touched resources.
|
|
33
41
|
*/
|
|
34
|
-
export declare function applyConsumerSnapshotEntriesChunk(hasResources: Record<RealTimeResourceSerialId, RealTimeMessagePayload>, entries: RealTimeConsumerSnapshotEntry[], startIndex: number, endIndex: number, decorators?: RealTimeMessageDecorator[], liveTouchedResourceKeys?: Set<ConsumerSnapshotResourceKey>): void;
|
|
42
|
+
export declare function applyConsumerSnapshotEntriesChunk(hasResources: Record<RealTimeResourceSerialId, RealTimeMessagePayload>, entries: RealTimeConsumerSnapshotEntry[], startIndex: number, endIndex: number, decorators?: RealTimeMessageDecorator[], storeConfig?: RealTimeConsumerResourceStoreConfig, liveTouchedResourceKeys?: Set<ConsumerSnapshotResourceKey>): void;
|
|
35
43
|
/**
|
|
36
44
|
* Drain all queued realtime messages while preserving arrival order.
|
|
37
45
|
*/
|
|
@@ -39,7 +47,7 @@ export declare function drainQueuedMessages(messagesQueue: ObjectQueue<RealTimeM
|
|
|
39
47
|
/**
|
|
40
48
|
* Apply one decorated realtime payload to the consumer-side resource hash.
|
|
41
49
|
*/
|
|
42
|
-
export declare function applyConsumerMessage(hasResources: Record<RealTimeResourceSerialId, RealTimeMessagePayload>, resourceTypeId: RealTimeResourceTypeId, message: RealTimeMessage, decorators?: Record<RealTimeResourceTypeId, RealTimeMessageDecorator[]>): void;
|
|
50
|
+
export declare function applyConsumerMessage(hasResources: Record<RealTimeResourceSerialId, RealTimeMessagePayload>, resourceTypeId: RealTimeResourceTypeId, message: RealTimeMessage, decorators?: Record<RealTimeResourceTypeId, RealTimeMessageDecorator[]>, storeConfig?: Record<RealTimeResourceTypeId, RealTimeConsumerResourceStoreConfig>): void;
|
|
43
51
|
/**
|
|
44
52
|
* Create the devtools wrapper only when the store runs in development mode.
|
|
45
53
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.helpers.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/store.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,qCAAqC,EACrC,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,KAAK,2BAA2B,GAAG,MAAM,CAAC;AAE1C,KAAK,6BAA6B,GAAG;IACnC,gBAAgB,EAAE,wBAAwB;IAC1C,QAAQ,EAAE,sBAAsB;CACjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,wBAAwB,EAC1C,iBAAiB,EAAE,sBAAsB,EACzC,UAAU,CAAC,EAAE,wBAAwB,EAAE,0BAWxC;AAED;;GAEG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"store.helpers.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/store.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,KAAK,2BAA2B,GAAG,MAAM,CAAC;AAE1C,KAAK,6BAA6B,GAAG;IACnC,gBAAgB,EAAE,wBAAwB;IAC1C,QAAQ,EAAE,sBAAsB;CACjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,wBAAwB,EAC1C,iBAAiB,EAAE,sBAAsB,EACzC,UAAU,CAAC,EAAE,wBAAwB,EAAE,0BAWxC;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,wBAAwB,EAC1C,QAAQ,EAAE,sBAAsB,0BAYjC;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,wBAAwB,EAC1C,QAAQ,EAAE,sBAAsB,EAChC,UAAU,CAAC,EAAE,wBAAwB,EAAE,EACvC,WAAW,CAAC,EAAE,mCAAmC,sCAqBlD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,4BAA4B,EACvC,UAAU,CAAC,EAAE,wBAAwB,EAAE,EACvC,WAAW,CAAC,EAAE,mCAAmC,0CAmBlD;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,mBAAmB,CAMlE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,wBAAwB,GACzC,2BAA2B,CAE7B;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,4BAA4B,GACtC,6BAA6B,EAAE,CAEjC;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,MAAM,CAAC,wBAAwB,EAAE,sBAAsB,CAAC,EACtE,OAAO,EAAE,6BAA6B,EAAE,EACxC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,wBAAwB,EAAE,EACvC,WAAW,CAAC,EAAE,mCAAmC,EACjD,uBAAuB,CAAC,EAAE,GAAG,CAAC,2BAA2B,CAAC,QAoB3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,qBAY9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,CAAC,wBAAwB,EAAE,sBAAsB,CAAC,EACtE,cAAc,EAAE,sBAAsB,EACtC,OAAO,EAAE,eAAe,EACxB,UAAU,CAAC,EAAE,MAAM,CAAC,sBAAsB,EAAE,wBAAwB,EAAE,CAAC,EACvE,WAAW,CAAC,EAAE,MAAM,CAClB,sBAAsB,EACtB,mCAAmC,CACpC,QA+DF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,YAAY,CAC3B,qCAAqC,EACrC;CAAE,EACF;IAAC,CAAC,eAAe,EAAE,KAAK,CAAC;CAAC,CAC3B,EACD,MAAM,EAAE,eAAe,GACtB,YAAY,CACb,qCAAqC,EACrC;CAAE,EACF;IAAC,CAAC,eAAe,EAAE,KAAK,CAAC;CAAC,CAC3B,CAYA"}
|
|
@@ -1,83 +1,141 @@
|
|
|
1
|
-
import { devtools as
|
|
2
|
-
import { ObjectQueue as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function
|
|
6
|
-
return
|
|
7
|
-
(
|
|
8
|
-
|
|
9
|
-
) :
|
|
1
|
+
import { devtools as g } from "../../node_modules/zustand/esm/middleware.js";
|
|
2
|
+
import { ObjectQueue as C } from "@m4l/realtime-runtime";
|
|
3
|
+
import a from "../../node_modules/lodash-es/merge.js";
|
|
4
|
+
import v from "../../node_modules/lodash-es/cloneDeep.js";
|
|
5
|
+
function l(e, t, r) {
|
|
6
|
+
return r && t ? r.reduce(
|
|
7
|
+
(u, o) => o(e, u),
|
|
8
|
+
t
|
|
9
|
+
) : t;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
function p(e, t) {
|
|
12
|
+
const r = v(t);
|
|
13
|
+
return r.resourceSerialId === void 0 ? {
|
|
14
|
+
...r,
|
|
15
|
+
resourceSerialId: e
|
|
16
|
+
} : r;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function m(e, t, r, u) {
|
|
19
|
+
const o = l(
|
|
20
|
+
e,
|
|
21
|
+
t,
|
|
22
|
+
r
|
|
23
|
+
);
|
|
24
|
+
if (u?.mode !== "projected" || !o)
|
|
25
|
+
return p(e, o);
|
|
26
|
+
const i = u.snapshotProjector ? u.snapshotProjector(e, o) : o;
|
|
27
|
+
if (i != null)
|
|
28
|
+
return p(e, i);
|
|
29
|
+
}
|
|
30
|
+
function x(e, t, r) {
|
|
31
|
+
return Object.entries(e).reduce(
|
|
32
|
+
(u, [o, i]) => {
|
|
33
|
+
const n = m(
|
|
34
|
+
o,
|
|
35
|
+
i,
|
|
36
|
+
t,
|
|
37
|
+
r
|
|
38
|
+
);
|
|
39
|
+
return n && (u[o] = n), u;
|
|
40
|
+
},
|
|
41
|
+
{}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function D() {
|
|
19
45
|
return {
|
|
20
46
|
messagesToProcces: [],
|
|
21
|
-
messagesQueue: new
|
|
47
|
+
messagesQueue: new C(),
|
|
22
48
|
statusProccesing: !1
|
|
23
49
|
};
|
|
24
50
|
}
|
|
25
|
-
function
|
|
51
|
+
function b(e) {
|
|
26
52
|
return String(e);
|
|
27
53
|
}
|
|
28
|
-
function
|
|
54
|
+
function M(e) {
|
|
29
55
|
return Object.entries(e);
|
|
30
56
|
}
|
|
31
|
-
function
|
|
32
|
-
for (let
|
|
33
|
-
const [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
57
|
+
function O(e, t, r, u, o, i, n) {
|
|
58
|
+
for (let d = r; d < u; d += 1) {
|
|
59
|
+
const [c, f] = t[d];
|
|
60
|
+
if (n?.has(b(c)))
|
|
61
|
+
continue;
|
|
62
|
+
const s = m(
|
|
63
|
+
c,
|
|
64
|
+
f,
|
|
65
|
+
o,
|
|
66
|
+
i
|
|
67
|
+
);
|
|
68
|
+
s && (e[c] = s);
|
|
39
69
|
}
|
|
40
70
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
71
|
+
function k(e) {
|
|
72
|
+
const t = [];
|
|
43
73
|
for (; !e.isEmpty(); ) {
|
|
44
|
-
const
|
|
45
|
-
|
|
74
|
+
const r = e.dequeue();
|
|
75
|
+
r && t.push(r);
|
|
46
76
|
}
|
|
47
|
-
return
|
|
77
|
+
return t;
|
|
48
78
|
}
|
|
49
|
-
function
|
|
50
|
-
const { payload:
|
|
51
|
-
if (
|
|
52
|
-
delete e[
|
|
79
|
+
function N(e, t, r, u, o) {
|
|
80
|
+
const { payload: i, resourceSerialId: n, type: d } = r;
|
|
81
|
+
if (d === "delete") {
|
|
82
|
+
delete e[n];
|
|
53
83
|
return;
|
|
54
84
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
const c = l(
|
|
86
|
+
n,
|
|
87
|
+
i,
|
|
88
|
+
u?.[t]
|
|
89
|
+
), f = o?.[t];
|
|
90
|
+
if (f?.mode === "projected") {
|
|
91
|
+
const s = f.messageProjector ? f.messageProjector(n, {
|
|
92
|
+
currentResource: e[n],
|
|
93
|
+
message: {
|
|
94
|
+
...r,
|
|
95
|
+
payload: c
|
|
96
|
+
}
|
|
97
|
+
}) ?? void 0 : e[n] ? a({}, e[n], c) : c;
|
|
98
|
+
if (s === void 0) {
|
|
99
|
+
const j = e[n] ? a({}, e[n], c) : c;
|
|
100
|
+
e[n] = p(
|
|
101
|
+
n,
|
|
102
|
+
j
|
|
103
|
+
);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (s === null) {
|
|
107
|
+
delete e[n];
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
e[n] = p(
|
|
111
|
+
n,
|
|
112
|
+
s
|
|
113
|
+
);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!e[n]) {
|
|
117
|
+
e[n] = p(
|
|
118
|
+
n,
|
|
119
|
+
c
|
|
120
|
+
);
|
|
65
121
|
return;
|
|
66
122
|
}
|
|
67
|
-
|
|
123
|
+
a(e[n], c);
|
|
68
124
|
}
|
|
69
|
-
function
|
|
70
|
-
const { enabled:
|
|
71
|
-
return
|
|
125
|
+
function Q(e, t) {
|
|
126
|
+
const { enabled: r = !1 } = t;
|
|
127
|
+
return r && process.env.NODE_ENV === "development" ? g(e, t) : e;
|
|
72
128
|
}
|
|
73
129
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
b as
|
|
81
|
-
|
|
82
|
-
|
|
130
|
+
N as applyConsumerMessage,
|
|
131
|
+
O as applyConsumerSnapshotEntriesChunk,
|
|
132
|
+
m as buildConsumerSnapshotResource,
|
|
133
|
+
x as buildConsumerSnapshotResources,
|
|
134
|
+
Q as createConsumerDevtools,
|
|
135
|
+
D as createConsumerMessageManager,
|
|
136
|
+
b as createConsumerResourceKey,
|
|
137
|
+
M as createConsumerSnapshotEntries,
|
|
138
|
+
p as createStoredConsumerResource,
|
|
139
|
+
l as decorateResourceOrMessage,
|
|
140
|
+
k as drainQueuedMessages
|
|
83
141
|
};
|
package/web/consumer/store.js
CHANGED
|
@@ -1,81 +1,82 @@
|
|
|
1
1
|
import { immer as T } from "../../node_modules/zustand/esm/middleware/immer.js";
|
|
2
|
-
import
|
|
3
|
-
import { REALTIME_CONSUMER_SOTORE_ID as
|
|
4
|
-
import { recordRealtimePerformanceMetric as
|
|
5
|
-
import { createConsumerDevtools as
|
|
6
|
-
import { createStore as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
return E() ?
|
|
2
|
+
import b from "../../node_modules/lodash-es/merge.js";
|
|
3
|
+
import { REALTIME_CONSUMER_SOTORE_ID as v } from "../shared/constants.js";
|
|
4
|
+
import { recordRealtimePerformanceMetric as i, getRealtimePerformanceNowMs as P, isRealtimePerformanceMetricsEnabled as E } from "../shared/performanceMetrics.js";
|
|
5
|
+
import { createConsumerDevtools as x, drainQueuedMessages as y, applyConsumerMessage as H, createConsumerMessageManager as N, createConsumerResourceKey as K, createConsumerSnapshotEntries as U, buildConsumerSnapshotResources as w, applyConsumerSnapshotEntriesChunk as z } from "./store.helpers.js";
|
|
6
|
+
import { createStore as B } from "../../node_modules/zustand/esm/vanilla.js";
|
|
7
|
+
const _ = 200, Y = 250;
|
|
8
|
+
function M() {
|
|
9
|
+
return E() ? P() : 0;
|
|
10
10
|
}
|
|
11
11
|
function p(c, m) {
|
|
12
|
-
E() &&
|
|
12
|
+
E() && i(
|
|
13
13
|
c,
|
|
14
|
-
Math.max(0,
|
|
14
|
+
Math.max(0, P() - m)
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function $(c) {
|
|
18
18
|
globalThis.setTimeout(c, 0);
|
|
19
19
|
}
|
|
20
20
|
function g(c, m) {
|
|
21
|
-
E() &&
|
|
21
|
+
E() && i(
|
|
22
22
|
"consumerResourceCount",
|
|
23
23
|
Object.keys(m().hasResourcesTypes[c]?.hasResources ?? {}).length
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
26
|
+
function J(c, m = !1) {
|
|
27
|
+
const L = {
|
|
28
28
|
...c,
|
|
29
29
|
hasResourcesTypes: {},
|
|
30
30
|
customData: {}
|
|
31
|
-
}, h = {},
|
|
32
|
-
function
|
|
33
|
-
const n = (
|
|
34
|
-
return
|
|
31
|
+
}, h = {}, S = {}, f = {};
|
|
32
|
+
function O(e) {
|
|
33
|
+
const n = (S[e] ?? 0) + 1;
|
|
34
|
+
return S[e] = n, f[e] = /* @__PURE__ */ new Set(), n;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function C(e, n) {
|
|
37
|
+
return S[e] === n;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function D(e, n) {
|
|
40
|
+
C(e, n) && (f[e] = void 0);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const s =
|
|
42
|
+
function k(e, n) {
|
|
43
|
+
const s = f[e];
|
|
44
44
|
s && n.forEach((o) => {
|
|
45
|
-
s.add(
|
|
45
|
+
s.add(K(o));
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (!
|
|
48
|
+
function A(e, n, s, o, t, a) {
|
|
49
|
+
if (!C(s, a))
|
|
50
50
|
return;
|
|
51
51
|
const r = Math.min(
|
|
52
|
-
t +
|
|
52
|
+
t + _,
|
|
53
53
|
o.length
|
|
54
|
-
),
|
|
55
|
-
if (e((
|
|
56
|
-
if (!
|
|
54
|
+
), u = M();
|
|
55
|
+
if (e((R) => {
|
|
56
|
+
if (!C(s, a))
|
|
57
57
|
return;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const l = R.hasResourcesTypes[s];
|
|
59
|
+
l && z(
|
|
60
|
+
l.hasResources,
|
|
61
61
|
o,
|
|
62
62
|
t,
|
|
63
63
|
r,
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
R.hasResourcesTypesDecorators?.[s],
|
|
65
|
+
R.hasResourcesTypesStoreConfig?.[s],
|
|
66
|
+
f[s]
|
|
66
67
|
);
|
|
67
68
|
}), p(
|
|
68
69
|
"consumerSnapshotApplyDurationMs",
|
|
69
|
-
|
|
70
|
-
),
|
|
70
|
+
u
|
|
71
|
+
), i(
|
|
71
72
|
"consumerSnapshotChunkSize",
|
|
72
73
|
r - t
|
|
73
74
|
), g(s, n), r >= o.length) {
|
|
74
|
-
|
|
75
|
+
D(s, a);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
i("consumerSnapshotYieldCount"), $(() => {
|
|
79
|
+
A(
|
|
79
80
|
e,
|
|
80
81
|
n,
|
|
81
82
|
s,
|
|
@@ -85,33 +86,34 @@ function G(c, m = !1) {
|
|
|
85
86
|
);
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
-
const t =
|
|
90
|
-
if (h[s]
|
|
89
|
+
function Q(e, n, s, o) {
|
|
90
|
+
const t = O(s), a = U(o);
|
|
91
|
+
if (h[s] ??= N(), i(
|
|
91
92
|
"consumerSnapshotChunkCount",
|
|
92
93
|
Math.max(
|
|
93
94
|
1,
|
|
94
95
|
Math.ceil(
|
|
95
|
-
a.length /
|
|
96
|
+
a.length / _
|
|
96
97
|
)
|
|
97
98
|
)
|
|
98
|
-
), a.length <=
|
|
99
|
-
const r =
|
|
99
|
+
), a.length <= Y) {
|
|
100
|
+
const r = w(
|
|
100
101
|
o,
|
|
101
|
-
n().hasResourcesTypesDecorators?.[s]
|
|
102
|
+
n().hasResourcesTypesDecorators?.[s],
|
|
103
|
+
n().hasResourcesTypesStoreConfig?.[s]
|
|
102
104
|
);
|
|
103
|
-
e((
|
|
104
|
-
|
|
105
|
-
hasResources: r
|
|
105
|
+
e((u) => {
|
|
106
|
+
u.hasResourcesTypes[s] = {
|
|
107
|
+
hasResources: r
|
|
106
108
|
};
|
|
107
|
-
}), g(s, n),
|
|
109
|
+
}), g(s, n), D(s, t);
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
112
|
e((r) => {
|
|
111
113
|
r.hasResourcesTypes[s] = {
|
|
112
114
|
hasResources: {}
|
|
113
115
|
};
|
|
114
|
-
}),
|
|
116
|
+
}), A(
|
|
115
117
|
e,
|
|
116
118
|
n,
|
|
117
119
|
s,
|
|
@@ -120,16 +122,16 @@ function G(c, m = !1) {
|
|
|
120
122
|
t
|
|
121
123
|
);
|
|
122
124
|
}
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
+
return B(
|
|
126
|
+
x(
|
|
125
127
|
T((e, n) => ({
|
|
126
|
-
...
|
|
128
|
+
...L,
|
|
127
129
|
realTimeConsumerActions: {
|
|
128
130
|
/**
|
|
129
131
|
* Seed one resource type with the current producer-side hash.
|
|
130
132
|
*/
|
|
131
133
|
loadResourceType: (s, o) => {
|
|
132
|
-
|
|
134
|
+
Q(
|
|
133
135
|
e,
|
|
134
136
|
n,
|
|
135
137
|
s,
|
|
@@ -140,14 +142,14 @@ function G(c, m = !1) {
|
|
|
140
142
|
* Enqueue one incoming realtime batch and start draining the queue.
|
|
141
143
|
*/
|
|
142
144
|
onMessages: (s, o) => {
|
|
143
|
-
|
|
145
|
+
i(
|
|
144
146
|
"consumerIncomingBatch",
|
|
145
147
|
o.length
|
|
146
|
-
), o.forEach((t) => {
|
|
148
|
+
), h[s] ??= N(), o.forEach((t) => {
|
|
147
149
|
h[s].messagesQueue.enqueue(
|
|
148
150
|
t
|
|
149
151
|
);
|
|
150
|
-
}),
|
|
152
|
+
}), i(
|
|
151
153
|
"consumerQueueLength",
|
|
152
154
|
h[s].messagesQueue.size()
|
|
153
155
|
), n().realTimeConsumerActions.processMessages(s);
|
|
@@ -156,34 +158,38 @@ function G(c, m = !1) {
|
|
|
156
158
|
* Drain the queued messages in one store transaction while preserving order.
|
|
157
159
|
*/
|
|
158
160
|
processMessages: (s) => {
|
|
159
|
-
const o =
|
|
161
|
+
const o = M(), t = h[s];
|
|
160
162
|
if (t.statusProccesing)
|
|
161
163
|
return;
|
|
162
164
|
t.statusProccesing = !0;
|
|
163
|
-
const a =
|
|
165
|
+
const a = y(
|
|
164
166
|
t.messagesQueue
|
|
165
167
|
);
|
|
166
168
|
if (!a.length) {
|
|
167
169
|
t.statusProccesing = !1;
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
|
-
|
|
172
|
+
i(
|
|
171
173
|
"consumerDrainSet",
|
|
172
174
|
a.length
|
|
173
|
-
),
|
|
175
|
+
), k(
|
|
174
176
|
s,
|
|
175
177
|
a.map((r) => r.resourceSerialId)
|
|
176
178
|
);
|
|
177
179
|
try {
|
|
178
|
-
const r =
|
|
179
|
-
e((
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
const r = M();
|
|
181
|
+
e((u) => {
|
|
182
|
+
u.hasResourcesTypes[s] || (u.hasResourcesTypes[s] = {
|
|
183
|
+
hasResources: {}
|
|
184
|
+
});
|
|
185
|
+
const R = u.hasResourcesTypes[s].hasResources;
|
|
186
|
+
a.forEach((l) => {
|
|
182
187
|
H(
|
|
183
|
-
f,
|
|
184
|
-
s,
|
|
185
188
|
R,
|
|
186
|
-
|
|
189
|
+
s,
|
|
190
|
+
l,
|
|
191
|
+
u.hasResourcesTypesDecorators,
|
|
192
|
+
u.hasResourcesTypesStoreConfig
|
|
187
193
|
);
|
|
188
194
|
});
|
|
189
195
|
}), p(
|
|
@@ -203,19 +209,19 @@ function G(c, m = !1) {
|
|
|
203
209
|
*/
|
|
204
210
|
setCustomData: (s) => {
|
|
205
211
|
e((o) => {
|
|
206
|
-
|
|
212
|
+
b(o.customData, s);
|
|
207
213
|
});
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
216
|
})),
|
|
211
217
|
{
|
|
212
|
-
name: `${
|
|
218
|
+
name: `${v}: ${c.storeId}`,
|
|
213
219
|
enabled: m
|
|
214
220
|
}
|
|
215
221
|
)
|
|
216
222
|
);
|
|
217
223
|
}
|
|
218
224
|
export {
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
_ as REALTIME_CONSUMER_SNAPSHOT_CHUNK_SIZE,
|
|
226
|
+
J as createRealTimeConsumerStore
|
|
221
227
|
};
|
package/web/consumer/types.d.ts
CHANGED
|
@@ -1,10 +1,83 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { RealTimeProducerTools } from '@m4l/realtime-runtime';
|
|
3
|
-
import { OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessagePayload, RealTimeReadonlyResourceHash, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../shared/runtimeTypes';
|
|
3
|
+
import { OnRealTimeTransportReconnectCallback, RealTimeMessage, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessagePayload, RealTimeReadonlyResourceHash, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../shared/runtimeTypes';
|
|
4
4
|
/**
|
|
5
5
|
* Realtime message decorator. Only the payload is decorated.
|
|
6
6
|
*/
|
|
7
7
|
export type RealTimeMessageDecorator = (resourceSerialId: RealTimeResourceSerialId, message: RealTimeMessagePayload) => RealTimeMessagePayload;
|
|
8
|
+
/**
|
|
9
|
+
* Consumer-side store ownership mode for one realtime resource type.
|
|
10
|
+
*/
|
|
11
|
+
export type RealTimeConsumerStoreMode = 'callbacks-only' | 'full' | 'projected';
|
|
12
|
+
/**
|
|
13
|
+
* Project one startup snapshot resource into the MF-local consumer store shape.
|
|
14
|
+
* Returning `null` or `undefined` skips that resource from the local store.
|
|
15
|
+
*/
|
|
16
|
+
export type RealTimeConsumerSnapshotProjector = (resourceSerialId: RealTimeResourceSerialId, resource: RealTimeMessagePayload) => RealTimeMessagePayload | null | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Context passed to projected message reducers so they can keep only the fields they need.
|
|
19
|
+
*/
|
|
20
|
+
export interface RealTimeConsumerMessageProjectorContext {
|
|
21
|
+
/**
|
|
22
|
+
* Current projected resource already stored in the consumer hash, if any.
|
|
23
|
+
*/
|
|
24
|
+
currentResource?: RealTimeMessagePayload;
|
|
25
|
+
/**
|
|
26
|
+
* Incoming realtime message with its payload already decorated for this resource type.
|
|
27
|
+
*/
|
|
28
|
+
message: RealTimeMessage;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Project one live realtime message into the MF-local consumer store shape.
|
|
32
|
+
* Returning `undefined` keeps the previous local resource unchanged, while
|
|
33
|
+
* returning `null` removes it from the consumer hash.
|
|
34
|
+
*/
|
|
35
|
+
export type RealTimeConsumerMessageProjector = (resourceSerialId: RealTimeResourceSerialId, context: RealTimeConsumerMessageProjectorContext) => RealTimeMessagePayload | null | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Configure how one realtime resource type should be represented in the MF-local store.
|
|
38
|
+
*/
|
|
39
|
+
export interface RealTimeConsumerResourceStoreConfig {
|
|
40
|
+
/**
|
|
41
|
+
* `full` keeps the decorated payload merge semantics, `projected` lets the
|
|
42
|
+
* consumer keep only a reduced shape, and `callbacks-only` skips the local
|
|
43
|
+
* consumer store entirely.
|
|
44
|
+
*/
|
|
45
|
+
mode?: RealTimeConsumerStoreMode;
|
|
46
|
+
/**
|
|
47
|
+
* Optional reducer used when the local store runs in `projected` mode.
|
|
48
|
+
*/
|
|
49
|
+
messageProjector?: RealTimeConsumerMessageProjector;
|
|
50
|
+
/**
|
|
51
|
+
* Optional snapshot projector used when the local store runs in `projected` mode.
|
|
52
|
+
*/
|
|
53
|
+
snapshotProjector?: RealTimeConsumerSnapshotProjector;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Declarative subscription contract for one realtime resource type.
|
|
57
|
+
*/
|
|
58
|
+
export interface RealTimeConsumerResourceSubscription extends Omit<RealTimeConsumerResourceStoreConfig, 'mode'> {
|
|
59
|
+
/**
|
|
60
|
+
* Realtime resource type handled by this MF-local subscription.
|
|
61
|
+
*/
|
|
62
|
+
resourceTypeId: RealTimeResourceTypeId;
|
|
63
|
+
/**
|
|
64
|
+
* Controls whether this subscription hydrates the MF-local consumer store.
|
|
65
|
+
*/
|
|
66
|
+
storeMode?: RealTimeConsumerStoreMode;
|
|
67
|
+
/**
|
|
68
|
+
* Decorators applied before the local store keeps snapshot resources or
|
|
69
|
+
* incoming message payloads for this resource type.
|
|
70
|
+
*/
|
|
71
|
+
hasResourcesDecorators?: RealTimeMessageDecorator[];
|
|
72
|
+
/**
|
|
73
|
+
* Optional MF-local side effects for live batches of this resource type.
|
|
74
|
+
*/
|
|
75
|
+
onMessagesCallbacks?: OnRealTimeConsumerMessageCallback[];
|
|
76
|
+
/**
|
|
77
|
+
* Optional MF-local side effects for the initial snapshot of this resource type.
|
|
78
|
+
*/
|
|
79
|
+
onSubscribeCallbacks?: OnRealtimeConsumerSubscribeCallback[];
|
|
80
|
+
}
|
|
8
81
|
/**
|
|
9
82
|
* Consumer-side realtime resource bucket.
|
|
10
83
|
*/
|
|
@@ -30,6 +103,10 @@ export interface RealTimeConsumerStoreState {
|
|
|
30
103
|
* Decorators applied to initial resources and incoming payloads.
|
|
31
104
|
*/
|
|
32
105
|
hasResourcesTypesDecorators?: Record<RealTimeResourceTypeId, RealTimeMessageDecorator[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Per-resource store behavior for explicit consumer subscriptions.
|
|
108
|
+
*/
|
|
109
|
+
hasResourcesTypesStoreConfig?: Record<RealTimeResourceTypeId, RealTimeConsumerResourceStoreConfig>;
|
|
33
110
|
/**
|
|
34
111
|
* Additional arbitrary data associated with the realtime consumer.
|
|
35
112
|
*/
|
|
@@ -67,9 +144,18 @@ export interface RealTimeProviderProps extends Omit<InitialRealTimeStoreProps, '
|
|
|
67
144
|
* Host-owned producer tools used to subscribe and unsubscribe without producer React context.
|
|
68
145
|
*/
|
|
69
146
|
producerTools: RealTimeProducerTools;
|
|
147
|
+
/**
|
|
148
|
+
* Declarative resource subscriptions for this MF-local consumer.
|
|
149
|
+
* When omitted, the provider keeps the legacy `rt_devices` subscription path.
|
|
150
|
+
*/
|
|
151
|
+
resourceSubscriptions?: RealTimeConsumerResourceSubscription[];
|
|
70
152
|
storeDevtoolsEnabled?: boolean;
|
|
71
153
|
onMessagesCallbacks?: OnRealTimeConsumerMessageCallback[];
|
|
72
154
|
onSubscribeCallbacks?: OnRealtimeConsumerSubscribeCallback[];
|
|
155
|
+
/**
|
|
156
|
+
* Optional MF-local side effects fired when the shared transport recovers after a reconnect.
|
|
157
|
+
*/
|
|
158
|
+
onTransportReconnectCallbacks?: OnRealTimeTransportReconnectCallback[];
|
|
73
159
|
children: ReactNode;
|
|
74
160
|
}
|
|
75
161
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EACV,iCAAiC,EACjC,mCAAmC,EACnC,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,gBAAgB,EAAE,wBAAwB,EAC1C,OAAO,EAAE,sBAAsB,KAC5B,sBAAsB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,wBAAwB,EAAE,sBAAsB,CAAC,CAAC;CACxE;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;IACpE;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAClC,sBAAsB,EACtB,wBAAwB,EAAE,CAC3B,CAAC;IACF;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,qCACf,SAAQ,0BAA0B;IAClC,uBAAuB,EAAE;QACvB;;;WAGG;QACH,gBAAgB,CACd,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,4BAA4B,GACzC,IAAI,CAAC;QACR;;WAEG;QACH,UAAU,EAAE,iCAAiC,CAAC;QAC9C;;WAEG;QACH,eAAe,EAAE,CAAC,cAAc,EAAE,sBAAsB,KAAK,IAAI,CAAC;QAClE;;WAEG;QACH,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAC9D,CAAC;CACH;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,0BAA0B,EAC1B,YAAY,GAAG,mBAAmB,CACnC,CAAC;AAEF,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC;IAClD;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,aAAa,EAAE,qBAAqB,CAAC;IACrC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,iCAAiC,EAAE,CAAC;IAC1D,oBAAoB,CAAC,EAAE,mCAAmC,EAAE,CAAC;IAC7D,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/consumer/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostRuntime.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/host/hostRuntime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oCAAoC,EACpC,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,+CAA+C,EAC/C,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,mCAAmC,EACzC,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,qBAAqB,CAAC;KACvC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,cAAc,EAAE,sBAAsB,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;OAEG;IACH,oBAAoB,CAAC,EAAE,oCAAoC,CAAC;IAC5D,mBAAmB,EAAE,+CAA+C,EAAE,CAAC;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,mCAAmC,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,yBAAyB,CA4B3B;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,sCAAsC,GAC5C,yBAAyB,CAyC3B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,CAAC,EAAE,yBAAyB,GACtC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"hostRuntime.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/host/hostRuntime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oCAAoC,EACpC,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,+CAA+C,EAC/C,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,mCAAmC,EACzC,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,qBAAqB,CAAC;KACvC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,cAAc,EAAE,sBAAsB,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;OAEG;IACH,oBAAoB,CAAC,EAAE,oCAAoC,CAAC;IAC5D,mBAAmB,EAAE,+CAA+C,EAAE,CAAC;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,mCAAmC,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,yBAAyB,CA4B3B;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,sCAAsC,GAC5C,yBAAyB,CAyC3B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,CAAC,EAAE,yBAAyB,GACtC,qBAAqB,CAmBvB"}
|
package/web/host/hostRuntime.js
CHANGED
|
@@ -7,13 +7,13 @@ function h(t) {
|
|
|
7
7
|
const {
|
|
8
8
|
presetId: e,
|
|
9
9
|
resourceTypeId: r,
|
|
10
|
-
storeDevtoolsEnabled:
|
|
10
|
+
storeDevtoolsEnabled: s = !1,
|
|
11
11
|
storeId: o,
|
|
12
12
|
runtimeKey: n
|
|
13
|
-
} = t,
|
|
13
|
+
} = t, i = c({
|
|
14
14
|
runtimeKey: n,
|
|
15
15
|
storeId: o,
|
|
16
|
-
storeDevtoolsEnabled:
|
|
16
|
+
storeDevtoolsEnabled: s,
|
|
17
17
|
resourceTypesConfig: [
|
|
18
18
|
m({
|
|
19
19
|
presetId: e,
|
|
@@ -26,22 +26,22 @@ function h(t) {
|
|
|
26
26
|
u(n);
|
|
27
27
|
},
|
|
28
28
|
realtime: {
|
|
29
|
-
producerTools:
|
|
29
|
+
producerTools: i.tools
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
function C(t) {
|
|
34
|
-
const { onTransportReconnect: e, startupSnapshots: r, ...
|
|
34
|
+
const { onTransportReconnect: e, startupSnapshots: r, ...s } = t;
|
|
35
35
|
let o = null;
|
|
36
|
-
const n = r?.length || e ? (
|
|
37
|
-
e?.(
|
|
36
|
+
const n = r?.length || e ? (i) => {
|
|
37
|
+
e?.(i), !(!o || !r?.length) && a({
|
|
38
38
|
producerTools: o.tools,
|
|
39
39
|
runtimeKey: t.runtimeKey,
|
|
40
40
|
startupSnapshots: r
|
|
41
41
|
});
|
|
42
42
|
} : void 0;
|
|
43
43
|
return o = l({
|
|
44
|
-
...
|
|
44
|
+
...s,
|
|
45
45
|
onTransportReconnect: n
|
|
46
46
|
}), p({
|
|
47
47
|
producerTools: o.tools,
|
|
@@ -56,9 +56,9 @@ function C(t) {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function b(t) {
|
|
60
60
|
const e = t?.realtime?.producerTools;
|
|
61
|
-
if (typeof e?.getResourceRuntimeMeta != "function" || typeof e?.getResourceTypeSnapshot != "function" || typeof e?.publishMessages != "function" || typeof e?.subscribe != "function" || typeof e?.subscribeResourceType != "function" || typeof e?.unsubscribe != "function")
|
|
61
|
+
if (typeof e?.getResourceRuntimeMeta != "function" || typeof e?.getResourceTypeSnapshot != "function" || typeof e?.publishMessages != "function" || typeof e?.subscribe != "function" || typeof e?.subscribeTransportReconnect != "function" || typeof e?.subscribeResourceType != "function" || typeof e?.unsubscribe != "function" || typeof e?.unsubscribeTransportReconnect != "function")
|
|
62
62
|
throw new Error(
|
|
63
63
|
"GClick realtime host runtime requires host-owned realtime producerTools."
|
|
64
64
|
);
|
|
@@ -67,5 +67,5 @@ function g(t) {
|
|
|
67
67
|
export {
|
|
68
68
|
C as launchGClickAtmosphereHostRuntime,
|
|
69
69
|
h as launchGClickDummyHostRuntime,
|
|
70
|
-
|
|
70
|
+
b as resolveGClickRealtimeTools
|
|
71
71
|
};
|
package/web/index.js
CHANGED
|
@@ -1,63 +1,64 @@
|
|
|
1
1
|
import { createRealTimeProducerTools as t } from "@m4l/realtime-runtime/web";
|
|
2
2
|
import { REAL_TIME_DUMMY_DEFAULT_PRESET_ID as m, REAL_TIME_DUMMY_SIMULATION_PRESETS as i, createRealTimeDummySimulationConfigFromPreset as a } from "../dummy/catalogs/presets.js";
|
|
3
|
-
import { createRealTimeDummyResourceTypeConfigFromPreset as
|
|
3
|
+
import { createRealTimeDummyResourceTypeConfigFromPreset as l } from "../dummy/runtime/simulation.js";
|
|
4
4
|
import { RealTimeDummySimulationPresetId as s } from "../fixtures/types.js";
|
|
5
5
|
import { RealTimeProducerContext as p, RealTimeProducerProvider as C } from "./producer/RealTimeProducerContext.js";
|
|
6
6
|
import { useRealTimeProducer as T } from "./producer/useRealTimeProducer.js";
|
|
7
|
-
import { createRealTimeProducerStore as
|
|
7
|
+
import { createRealTimeProducerStore as S } from "./producer/store.js";
|
|
8
8
|
import { SourceDataFactory as x } from "./producer/sourceDataFactory.js";
|
|
9
|
-
import { RealTimeConsumerContext as
|
|
10
|
-
import { useRealTimeConsumer as
|
|
11
|
-
import { createRealTimeConsumerStore as
|
|
9
|
+
import { RealTimeConsumerContext as _, RealTimeConsumerProvider as k } from "./consumer/RealTimeConsumerContext.js";
|
|
10
|
+
import { useRealTimeConsumer as D } from "./consumer/useRealTimeConsumer.js";
|
|
11
|
+
import { createRealTimeConsumerStore as h } from "./consumer/store.js";
|
|
12
12
|
import { createRealtimeRuntime as M } from "./runtime/runtime.js";
|
|
13
13
|
import { createAtmosphereRealtimeRuntime as d } from "./runtime/runtimeAtmosphereOnly.js";
|
|
14
14
|
import { getOrCreateGClickRealtimeRuntime as v } from "./runtime/runtimeRegistry.js";
|
|
15
15
|
import { createGetOrCreateGClickRealtimeRuntime as U, disposeGClickRealtimeRuntime as g } from "./runtime/runtimeRegistry.shared.js";
|
|
16
16
|
import { getOrCreateGClickAtmosphereRealtimeRuntime as H } from "./runtime/runtimeRegistryAtmosphereOnly.js";
|
|
17
|
-
import { EnumResourceTypesIds as
|
|
18
|
-
import { createGClickDevicesAtmosphereResourceType as
|
|
19
|
-
import { launchGClickAtmosphereHostRuntime as
|
|
20
|
-
import { createGClickAtmosphereRuntimeConfigs as
|
|
17
|
+
import { EnumResourceTypesIds as N, PROCCESS_MESSAGES_INTERVAL as z, REALTIME_CONSUMER_SOTORE_ID as K, REALTIME_PRODUCER_SOTORE_ID as V, RESOURCE_TYPE_ALARMS as b, RESOURCE_TYPE_DEVICES as j } from "./shared/constants.js";
|
|
18
|
+
import { createGClickDevicesAtmosphereResourceType as w, createGClickDevicesHotStartupSnapshot as B, createGClickDevicesStartupSnapshot as J, createGClickDevicesStartupSnapshotMessages as Q } from "./host/devicesResourceType.js";
|
|
19
|
+
import { launchGClickAtmosphereHostRuntime as X, launchGClickDummyHostRuntime as Z, resolveGClickRealtimeTools as $ } from "./host/hostRuntime.js";
|
|
20
|
+
import { createGClickAtmosphereRuntimeConfigs as re, createGClickAtmosphereRuntimeKey as te, createGClickAtmosphereStartupSnapshots as oe, createGClickDummyRuntimeKey as me, launchGClickRealtimeHostRuntime as ie, normalizeGClickRealtimeFallbackTransport as ae, normalizeGClickRealtimeSessionId as Re, resolveGClickRealtimeAtmosphereHost as le } from "./host/launchContract.js";
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
N as EnumResourceTypesIds,
|
|
23
23
|
z as PROCCESS_MESSAGES_INTERVAL,
|
|
24
24
|
K as REALTIME_CONSUMER_SOTORE_ID,
|
|
25
25
|
V as REALTIME_PRODUCER_SOTORE_ID,
|
|
26
26
|
m as REAL_TIME_DUMMY_DEFAULT_PRESET_ID,
|
|
27
27
|
i as REAL_TIME_DUMMY_SIMULATION_PRESETS,
|
|
28
|
-
b as
|
|
29
|
-
|
|
30
|
-
_ as
|
|
28
|
+
b as RESOURCE_TYPE_ALARMS,
|
|
29
|
+
j as RESOURCE_TYPE_DEVICES,
|
|
30
|
+
_ as RealTimeConsumerContext,
|
|
31
|
+
k as RealTimeConsumerProvider,
|
|
31
32
|
s as RealTimeDummySimulationPresetId,
|
|
32
33
|
p as RealTimeProducerContext,
|
|
33
34
|
C as RealTimeProducerProvider,
|
|
34
35
|
x as SourceDataFactory,
|
|
35
36
|
d as createAtmosphereRealtimeRuntime,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
re as createGClickAtmosphereRuntimeConfigs,
|
|
38
|
+
te as createGClickAtmosphereRuntimeKey,
|
|
39
|
+
oe as createGClickAtmosphereStartupSnapshots,
|
|
40
|
+
w as createGClickDevicesAtmosphereResourceType,
|
|
41
|
+
B as createGClickDevicesHotStartupSnapshot,
|
|
42
|
+
J as createGClickDevicesStartupSnapshot,
|
|
43
|
+
Q as createGClickDevicesStartupSnapshotMessages,
|
|
44
|
+
me as createGClickDummyRuntimeKey,
|
|
44
45
|
U as createGetOrCreateGClickRealtimeRuntime,
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
h as createRealTimeConsumerStore,
|
|
47
|
+
l as createRealTimeDummyResourceTypeConfigFromPreset,
|
|
47
48
|
a as createRealTimeDummySimulationConfigFromPreset,
|
|
48
|
-
|
|
49
|
+
S as createRealTimeProducerStore,
|
|
49
50
|
t as createRealTimeProducerTools,
|
|
50
51
|
M as createRealtimeRuntime,
|
|
51
52
|
g as disposeGClickRealtimeRuntime,
|
|
52
53
|
H as getOrCreateGClickAtmosphereRealtimeRuntime,
|
|
53
54
|
v as getOrCreateGClickRealtimeRuntime,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
X as launchGClickAtmosphereHostRuntime,
|
|
56
|
+
Z as launchGClickDummyHostRuntime,
|
|
57
|
+
ie as launchGClickRealtimeHostRuntime,
|
|
58
|
+
ae as normalizeGClickRealtimeFallbackTransport,
|
|
59
|
+
Re as normalizeGClickRealtimeSessionId,
|
|
59
60
|
le as resolveGClickRealtimeAtmosphereHost,
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
$ as resolveGClickRealtimeTools,
|
|
62
|
+
D as useRealTimeConsumer,
|
|
62
63
|
T as useRealTimeProducer
|
|
63
64
|
};
|
|
@@ -2,8 +2,10 @@ export declare const PROCCESS_MESSAGES_INTERVAL = 1;
|
|
|
2
2
|
export declare const REALTIME_PRODUCER_SOTORE_ID = "M4LRealTimeProducerStore";
|
|
3
3
|
export declare const REALTIME_CONSUMER_SOTORE_ID = "M4LRealTimeConsumerStore";
|
|
4
4
|
export declare enum EnumResourceTypesIds {
|
|
5
|
+
alarms = "rt_alarms",
|
|
5
6
|
devices = "rt_devices",
|
|
6
7
|
user = "rt_user"
|
|
7
8
|
}
|
|
9
|
+
export declare const RESOURCE_TYPE_ALARMS = EnumResourceTypesIds.alarms;
|
|
8
10
|
export declare const RESOURCE_TYPE_DEVICES = EnumResourceTypesIds.devices;
|
|
9
11
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AACtE,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AAEtE,oBAAY,oBAAoB;IAC9B,OAAO,eAAe;IACtB,IAAI,YAAY;CACjB;AAED,eAAO,MAAM,qBAAqB,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AACtE,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AAEtE,oBAAY,oBAAoB;IAC9B,MAAM,cAAc;IACpB,OAAO,eAAe;IACtB,IAAI,YAAY;CACjB;AAED,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,qBAAqB,+BAA+B,CAAC"}
|
package/web/shared/constants.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
var
|
|
3
|
-
const S = "rt_devices";
|
|
1
|
+
const _ = 1, t = "M4LRealTimeProducerStore", R = "M4LRealTimeConsumerStore";
|
|
2
|
+
var r = /* @__PURE__ */ ((E) => (E.alarms = "rt_alarms", E.devices = "rt_devices", E.user = "rt_user", E))(r || {});
|
|
3
|
+
const S = "rt_alarms", e = "rt_devices";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
r as EnumResourceTypesIds,
|
|
6
|
+
_ as PROCCESS_MESSAGES_INTERVAL,
|
|
7
7
|
R as REALTIME_CONSUMER_SOTORE_ID,
|
|
8
|
-
|
|
9
|
-
S as
|
|
8
|
+
t as REALTIME_PRODUCER_SOTORE_ID,
|
|
9
|
+
S as RESOURCE_TYPE_ALARMS,
|
|
10
|
+
e as RESOURCE_TYPE_DEVICES
|
|
10
11
|
};
|
package/web/shared/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { EnumResourceTypesIds, PROCCESS_MESSAGES_INTERVAL, REALTIME_CONSUMER_SOTORE_ID, REALTIME_PRODUCER_SOTORE_ID, RESOURCE_TYPE_DEVICES, } from './constants';
|
|
2
|
-
export type { MessageQueueManager, OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessagePayload, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeResourceTypeId, RealTimeStatus, SubscribeOptions, Subscriber, } from './runtimeTypes';
|
|
1
|
+
export { EnumResourceTypesIds, PROCCESS_MESSAGES_INTERVAL, REALTIME_CONSUMER_SOTORE_ID, REALTIME_PRODUCER_SOTORE_ID, RESOURCE_TYPE_ALARMS, RESOURCE_TYPE_DEVICES, } from './constants';
|
|
2
|
+
export type { MessageQueueManager, OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealTimeTransportReconnectCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessagePayload, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeTransportReconnectEvent, RealTimeResourceTypeId, RealTimeStatus, SubscribeTransportReconnectOptions, SubscribeOptions, Subscriber, } from './runtimeTypes';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,mCAAmC,EACnC,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,+CAA+C,EAC/C,yCAAyC,EACzC,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,GACX,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,oCAAoC,EACpC,mCAAmC,EACnC,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,+CAA+C,EAC/C,yCAAyC,EACzC,+BAA+B,EAC/B,sBAAsB,EACtB,cAAc,EACd,kCAAkC,EAClC,gBAAgB,EAChB,UAAU,GACX,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessageIngressReason, RealTimeMessagePayload, RealTimeResourceMessageNormalizeContext, RealTimeResourceMessageNormalizeStrategy, RealTimeReadonlyResourceHash, RealTimeResourceMergeContext, RealTimeResourceSerialId, RealTimeResourcePayloadMergeStrategy, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeResourceTypeId, RealTimeStatus, SubscribeOptions, Subscriber } from '@m4l/realtime-runtime';
|
|
1
|
+
import { OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealTimeTransportReconnectCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessageIngressReason, RealTimeMessagePayload, RealTimeResourceMessageNormalizeContext, RealTimeResourceMessageNormalizeStrategy, RealTimeReadonlyResourceHash, RealTimeResourceMergeContext, RealTimeResourceSerialId, RealTimeResourcePayloadMergeStrategy, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeTransportReconnectEvent, RealTimeResourceTypeId, RealTimeStatus, SubscribeTransportReconnectOptions, SubscribeOptions, Subscriber } from '@m4l/realtime-runtime';
|
|
2
2
|
import { MessageQueueManager } from '../../../../../dist/packages/@m4l/realtime-runtime/web';
|
|
3
|
-
export type { MessageQueueManager, OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessageIngressReason, RealTimeMessagePayload, RealTimeResourceMessageNormalizeContext, RealTimeResourceMessageNormalizeStrategy, RealTimeReadonlyResourceHash, RealTimeResourceMergeContext, RealTimeResourcePayloadMergeStrategy, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeResourceTypeId, RealTimeStatus, SubscribeOptions, Subscriber, };
|
|
3
|
+
export type { MessageQueueManager, OnMessagesStoreCallback, OnRealTimeConsumerMessageCallback, OnRealTimeTransportReconnectCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessageIngressReason, RealTimeMessagePayload, RealTimeResourceMessageNormalizeContext, RealTimeResourceMessageNormalizeStrategy, RealTimeReadonlyResourceHash, RealTimeResourceMergeContext, RealTimeResourcePayloadMergeStrategy, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeTransportReconnectEvent, RealTimeResourceTypeId, RealTimeStatus, SubscribeTransportReconnectOptions, SubscribeOptions, Subscriber, };
|
|
4
4
|
//# sourceMappingURL=runtimeTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeTypes.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/runtimeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,iCAAiC,EACjC,mCAAmC,EACnC,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,uCAAuC,EACvC,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,oCAAoC,EACpC,+CAA+C,EAC/C,yCAAyC,EACzC,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,mCAAmC,EACnC,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,uCAAuC,EACvC,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,EACxB,+CAA+C,EAC/C,yCAAyC,EACzC,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,GACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"runtimeTypes.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/shared/runtimeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,iCAAiC,EACjC,oCAAoC,EACpC,mCAAmC,EACnC,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,uCAAuC,EACvC,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,oCAAoC,EACpC,+CAA+C,EAC/C,yCAAyC,EACzC,+BAA+B,EAC/B,sBAAsB,EACtB,cAAc,EACd,kCAAkC,EAClC,gBAAgB,EAChB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,oCAAoC,EACpC,mCAAmC,EACnC,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,uCAAuC,EACvC,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,EACxB,+CAA+C,EAC/C,yCAAyC,EACzC,+BAA+B,EAC/B,sBAAsB,EACtB,cAAc,EACd,kCAAkC,EAClC,gBAAgB,EAChB,UAAU,GACX,CAAC"}
|