@m4l/gclick-realtime 1.1.0 → 1.2.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.
Files changed (62) hide show
  1. package/contracts/deviceData.d.ts +1 -1
  2. package/contracts/deviceData.d.ts.map +1 -1
  3. package/contracts/deviceDetail.d.ts +0 -1
  4. package/contracts/deviceDetail.d.ts.map +1 -1
  5. package/dummy/catalogs/baseDeviceTemplate.d.ts +1 -1
  6. package/dummy/catalogs/baseDeviceTemplate.d.ts.map +1 -1
  7. package/dummy/catalogs/scenarios.d.ts +46 -46
  8. package/dummy/catalogs/scenarios.js +46 -46
  9. package/dummy/runtime/dummy.d.ts.map +1 -1
  10. package/dummy/runtime/dummy.js +11 -10
  11. package/dummy/runtime/simulation.d.ts +2 -1
  12. package/dummy/runtime/simulation.d.ts.map +1 -1
  13. package/dummy/runtime/simulation.js +384 -361
  14. package/dummy/shared/types.d.ts +1 -1
  15. package/dummy/shared/types.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/payload/index.d.ts +1 -0
  18. package/payload/index.d.ts.map +1 -1
  19. package/payload/index.js +7 -4
  20. package/payload/mergeDevicePayloadWithUpdatedAtGuard.d.ts +10 -0
  21. package/payload/mergeDevicePayloadWithUpdatedAtGuard.d.ts.map +1 -0
  22. package/payload/mergeDevicePayloadWithUpdatedAtGuard.js +50 -0
  23. package/web/consumer/RealTimeConsumerContext.d.ts.map +1 -1
  24. package/web/consumer/RealTimeConsumerContext.js +59 -30
  25. package/web/consumer/store.d.ts +1 -0
  26. package/web/consumer/store.d.ts.map +1 -1
  27. package/web/consumer/store.helpers.d.ts +24 -2
  28. package/web/consumer/store.helpers.d.ts.map +1 -1
  29. package/web/consumer/store.helpers.js +61 -33
  30. package/web/consumer/store.js +176 -60
  31. package/web/consumer/types.d.ts +3 -2
  32. package/web/consumer/types.d.ts.map +1 -1
  33. package/web/host/devicesResourceType.d.ts +70 -0
  34. package/web/host/devicesResourceType.d.ts.map +1 -0
  35. package/web/host/devicesResourceType.js +196 -0
  36. package/web/host/hostRuntime.d.ts +7 -0
  37. package/web/host/hostRuntime.d.ts.map +1 -1
  38. package/web/host/hostRuntime.js +44 -28
  39. package/web/host/index.d.ts +5 -2
  40. package/web/host/index.d.ts.map +1 -1
  41. package/web/host/launchContract.d.ts +25 -5
  42. package/web/host/launchContract.d.ts.map +1 -1
  43. package/web/host/launchContract.js +78 -41
  44. package/web/host/startupSnapshots.d.ts +32 -0
  45. package/web/host/startupSnapshots.d.ts.map +1 -0
  46. package/web/host/startupSnapshots.js +50 -0
  47. package/web/index.js +53 -47
  48. package/web/producer/sourceDataFactory.d.ts +3 -3
  49. package/web/producer/sourceDataFactory.d.ts.map +1 -1
  50. package/web/producer/sourceDataFactory.js +25 -21
  51. package/web/runtime/resourceTypeMergeStrategies.d.ts +10 -0
  52. package/web/runtime/resourceTypeMergeStrategies.d.ts.map +1 -0
  53. package/web/runtime/resourceTypeMergeStrategies.js +19 -0
  54. package/web/runtime/runtime.d.ts.map +1 -1
  55. package/web/runtime/runtime.js +15 -9
  56. package/web/runtime/runtimeAtmosphereOnly.d.ts.map +1 -1
  57. package/web/runtime/runtimeAtmosphereOnly.js +18 -12
  58. package/web/shared/performanceMetrics.d.ts +18 -2
  59. package/web/shared/performanceMetrics.d.ts.map +1 -1
  60. package/web/shared/performanceMetrics.js +35 -20
  61. package/web/shared/runtimeTypes.d.ts +2 -2
  62. package/web/shared/runtimeTypes.d.ts.map +1 -1
@@ -1,105 +1,221 @@
1
- import { immer as l } from "../../node_modules/zustand/esm/middleware/immer.js";
2
- import R from "../../node_modules/lodash-es/merge.js";
3
- import { REALTIME_CONSUMER_SOTORE_ID as p } from "../shared/constants.js";
4
- import { ObjectQueue as h } from "@m4l/realtime-runtime";
5
- import { recordRealtimePerformanceMetric as m } from "../shared/performanceMetrics.js";
6
- import { createConsumerDevtools as M, drainQueuedMessages as T, applyConsumerMessage as C, decorateAllResourcesOfType as D } from "./store.helpers.js";
7
- import { createStore as E } from "../../node_modules/zustand/esm/vanilla.js";
8
- function _(n, u = !1) {
9
- const i = {
10
- ...n,
1
+ import { immer as T } from "../../node_modules/zustand/esm/middleware/immer.js";
2
+ import y from "../../node_modules/lodash-es/merge.js";
3
+ import { REALTIME_CONSUMER_SOTORE_ID as Q } from "../shared/constants.js";
4
+ import { recordRealtimePerformanceMetric as u, getRealtimePerformanceNowMs as _, isRealtimePerformanceMetricsEnabled as E } from "../shared/performanceMetrics.js";
5
+ import { createConsumerDevtools as d, drainQueuedMessages as v, applyConsumerMessage as H, createConsumerResourceKey as b, createConsumerSnapshotEntries as x, createConsumerMessageManager as K, decorateAllResourcesOfType as U, applyConsumerSnapshotEntriesChunk as w } from "./store.helpers.js";
6
+ import { createStore as z } from "../../node_modules/zustand/esm/vanilla.js";
7
+ const N = 200, B = 250;
8
+ function C() {
9
+ return E() ? _() : 0;
10
+ }
11
+ function p(c, m) {
12
+ E() && u(
13
+ c,
14
+ Math.max(0, _() - m)
15
+ );
16
+ }
17
+ function Y(c) {
18
+ globalThis.setTimeout(c, 0);
19
+ }
20
+ function g(c, m) {
21
+ E() && u(
22
+ "consumerResourceCount",
23
+ Object.keys(m().hasResourcesTypes[c]?.hasResources ?? {}).length
24
+ );
25
+ }
26
+ function G(c, m = !1) {
27
+ const O = {
28
+ ...c,
11
29
  hasResourcesTypes: {},
12
30
  customData: {}
13
- }, a = {};
14
- return E(
15
- M(
16
- l((t, c) => ({
17
- ...i,
31
+ }, h = {}, M = {}, l = {};
32
+ function P(e) {
33
+ const n = (M[e] ?? 0) + 1;
34
+ return M[e] = n, l[e] = /* @__PURE__ */ new Set(), n;
35
+ }
36
+ function S(e, n) {
37
+ return M[e] === n;
38
+ }
39
+ function A(e, n) {
40
+ S(e, n) && (l[e] = void 0);
41
+ }
42
+ function L(e, n) {
43
+ const s = l[e];
44
+ s && n.forEach((o) => {
45
+ s.add(b(o));
46
+ });
47
+ }
48
+ function D(e, n, s, o, t, a) {
49
+ if (!S(s, a))
50
+ return;
51
+ const r = Math.min(
52
+ t + N,
53
+ o.length
54
+ ), i = C();
55
+ if (e((f) => {
56
+ if (!S(s, a))
57
+ return;
58
+ const R = f.hasResourcesTypes[s];
59
+ R && w(
60
+ R.hasResources,
61
+ o,
62
+ t,
63
+ r,
64
+ f.hasResourcesTypesDecorators?.[s],
65
+ l[s]
66
+ );
67
+ }), p(
68
+ "consumerSnapshotApplyDurationMs",
69
+ i
70
+ ), u(
71
+ "consumerSnapshotChunkSize",
72
+ r - t
73
+ ), g(s, n), r >= o.length) {
74
+ A(s, a);
75
+ return;
76
+ }
77
+ u("consumerSnapshotYieldCount"), Y(() => {
78
+ D(
79
+ e,
80
+ n,
81
+ s,
82
+ o,
83
+ r,
84
+ a
85
+ );
86
+ });
87
+ }
88
+ function k(e, n, s, o) {
89
+ const t = P(s), a = x(o);
90
+ if (h[s] = K(), u(
91
+ "consumerSnapshotChunkCount",
92
+ Math.max(
93
+ 1,
94
+ Math.ceil(
95
+ a.length / N
96
+ )
97
+ )
98
+ ), a.length <= B) {
99
+ const r = U(
100
+ o,
101
+ n().hasResourcesTypesDecorators?.[s]
102
+ );
103
+ e((i) => {
104
+ i.hasResourcesTypes[s] = {
105
+ hasResources: r || {}
106
+ };
107
+ }), g(s, n), A(s, t);
108
+ return;
109
+ }
110
+ e((r) => {
111
+ r.hasResourcesTypes[s] = {
112
+ hasResources: {}
113
+ };
114
+ }), D(
115
+ e,
116
+ n,
117
+ s,
118
+ a,
119
+ 0,
120
+ t
121
+ );
122
+ }
123
+ return z(
124
+ d(
125
+ T((e, n) => ({
126
+ ...O,
18
127
  realTimeConsumerActions: {
19
128
  /**
20
129
  * Seed one resource type with the current producer-side hash.
21
130
  */
22
- loadResourceType: (e, s) => {
23
- const o = D(
131
+ loadResourceType: (s, o) => {
132
+ k(
133
+ e,
134
+ n,
24
135
  s,
25
- c().hasResourcesTypesDecorators?.[e]
136
+ o
26
137
  );
27
- t((r) => {
28
- r.hasResourcesTypes[e] = {
29
- hasResources: o || {}
30
- }, a[e] = {
31
- messagesToProcces: [],
32
- messagesQueue: new h(),
33
- statusProccesing: !1
34
- };
35
- });
36
138
  },
37
139
  /**
38
140
  * Enqueue one incoming realtime batch and start draining the queue.
39
141
  */
40
- onMessages: (e, s) => {
41
- m(
142
+ onMessages: (s, o) => {
143
+ u(
42
144
  "consumerIncomingBatch",
43
- s.length
44
- ), s.forEach((o) => {
45
- a[e].messagesQueue.enqueue(
46
- o
145
+ o.length
146
+ ), o.forEach((t) => {
147
+ h[s].messagesQueue.enqueue(
148
+ t
47
149
  );
48
- }), c().realTimeConsumerActions.processMessages(e);
150
+ }), u(
151
+ "consumerQueueLength",
152
+ h[s].messagesQueue.size()
153
+ ), n().realTimeConsumerActions.processMessages(s);
49
154
  },
50
155
  /**
51
156
  * Drain the queued messages in one store transaction while preserving order.
52
157
  */
53
- processMessages: (e) => {
54
- const s = a[e];
55
- if (s.statusProccesing)
158
+ processMessages: (s) => {
159
+ const o = C(), t = h[s];
160
+ if (t.statusProccesing)
56
161
  return;
57
- s.statusProccesing = !0;
58
- const o = T(
59
- s.messagesQueue
162
+ t.statusProccesing = !0;
163
+ const a = v(
164
+ t.messagesQueue
60
165
  );
61
- if (!o.length) {
62
- s.statusProccesing = !1;
166
+ if (!a.length) {
167
+ t.statusProccesing = !1;
63
168
  return;
64
169
  }
65
- m(
170
+ u(
66
171
  "consumerDrainSet",
67
- o.length
172
+ a.length
173
+ ), L(
174
+ s,
175
+ a.map((r) => r.resourceSerialId)
68
176
  );
69
177
  try {
70
- t((r) => {
71
- const g = r.hasResourcesTypes[e].hasResources;
72
- o.forEach((f) => {
73
- C(
74
- g,
75
- e,
178
+ const r = C();
179
+ e((i) => {
180
+ const f = i.hasResourcesTypes[s].hasResources;
181
+ a.forEach((R) => {
182
+ H(
76
183
  f,
77
- r.hasResourcesTypesDecorators
184
+ s,
185
+ R,
186
+ i.hasResourcesTypesDecorators
78
187
  );
79
188
  });
80
- });
189
+ }), p(
190
+ "consumerApplyNotifyDurationMs",
191
+ r
192
+ ), g(s, n);
81
193
  } finally {
82
- s.statusProccesing = !1;
194
+ p(
195
+ "consumerProcessDurationMs",
196
+ o
197
+ ), t.statusProccesing = !1;
83
198
  }
84
- s.messagesQueue.isEmpty() || c().realTimeConsumerActions.processMessages(e);
199
+ t.messagesQueue.isEmpty() || n().realTimeConsumerActions.processMessages(s);
85
200
  },
86
201
  /**
87
202
  * Merge partial custom data into the consumer store.
88
203
  */
89
- setCustomData: (e) => {
90
- t((s) => {
91
- R(s.customData, e);
204
+ setCustomData: (s) => {
205
+ e((o) => {
206
+ y(o.customData, s);
92
207
  });
93
208
  }
94
209
  }
95
210
  })),
96
211
  {
97
- name: `${p}: ${n.storeId}`,
98
- enabled: u
212
+ name: `${Q}: ${c.storeId}`,
213
+ enabled: m
99
214
  }
100
215
  )
101
216
  );
102
217
  }
103
218
  export {
104
- _ as createRealTimeConsumerStore
219
+ N as REALTIME_CONSUMER_SNAPSHOT_CHUNK_SIZE,
220
+ G as createRealTimeConsumerStore
105
221
  };
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { RealTimeProducerTools } from '@m4l/realtime-runtime';
3
- import { OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessagePayload, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../shared/runtimeTypes';
3
+ import { OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessagePayload, RealTimeReadonlyResourceHash, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../shared/runtimeTypes';
4
4
  /**
5
5
  * Realtime message decorator. Only the payload is decorated.
6
6
  */
@@ -39,8 +39,9 @@ export interface RealTimeConsumerStoreStateWithActions extends RealTimeConsumerS
39
39
  realTimeConsumerActions: {
40
40
  /**
41
41
  * Seed one resource type with the current producer-side hash.
42
+ * Large snapshots may load incrementally so the UI can keep responding.
42
43
  */
43
- loadResourceType(resourceTypeId: RealTimeResourceTypeId, hasResources: Record<RealTimeResourceSerialId, RealTimeMessagePayload>): void;
44
+ loadResourceType(resourceTypeId: RealTimeResourceTypeId, hasResources: RealTimeReadonlyResourceHash): void;
44
45
  /**
45
46
  * Accept a raw incoming batch and enqueue it for consumer-side processing.
46
47
  */
@@ -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,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;;WAEG;QACH,gBAAgB,CACd,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,MAAM,CAAC,wBAAwB,EAAE,sBAAsB,CAAC,GACrE,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":"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;IAC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70 @@
1
+ import { RealTimeMessage, RealTimeResourceMessageNormalizeStrategy, RealTimeResourceTypeId } from '../shared/runtimeTypes';
2
+ import { GClickRealtimeResourceStartupSnapshotConfig } from './startupSnapshots';
3
+ import { GClickRealtimeAtmosphereResourceTypeLaunchConfig } from './launchContract';
4
+ /**
5
+ * Snapshot loader used by host shells to fetch a full devices startup payload.
6
+ */
7
+ export type GClickDevicesStartupSnapshotLoader = () => Promise<unknown> | unknown;
8
+ export interface CreateGClickDevicesStartupSnapshotProps {
9
+ loadSnapshot: GClickDevicesStartupSnapshotLoader;
10
+ resourceTypeId?: RealTimeResourceTypeId;
11
+ }
12
+ /**
13
+ * Network request shape used by the standard hot devices startup snapshot helper.
14
+ */
15
+ export interface GClickDevicesHotStartupSnapshotRequest {
16
+ database?: string;
17
+ endPoint: string;
18
+ isExternalUrl?: true;
19
+ method: 'GET';
20
+ parms: {
21
+ hot: true;
22
+ };
23
+ responseToCamelCase: true;
24
+ }
25
+ /**
26
+ * Structural network operation contract supplied by shells without coupling this package to @m4l/core.
27
+ */
28
+ export type GClickDevicesHotStartupSnapshotNetworkOperation = <T = unknown>(request: GClickDevicesHotStartupSnapshotRequest) => Promise<T>;
29
+ export interface CreateGClickDevicesHotStartupSnapshotProps {
30
+ database?: string;
31
+ endPoint?: string;
32
+ networkOperation: GClickDevicesHotStartupSnapshotNetworkOperation;
33
+ resourceTypeId?: RealTimeResourceTypeId;
34
+ startupSnapshotHostApiRemote?: string;
35
+ }
36
+ type CreateGClickDevicesAtmosphereResourceTypeBaseProps = Omit<Partial<GClickRealtimeAtmosphereResourceTypeLaunchConfig>, 'mergePayloadStrategy' | 'resourceTypeId' | 'startupSnapshot'> & {
37
+ database?: string;
38
+ endPoint?: string;
39
+ resourceTypeId: RealTimeResourceTypeId;
40
+ startupSnapshotHostApiRemote?: string;
41
+ };
42
+ export type CreateGClickDevicesAtmosphereResourceTypeProps = CreateGClickDevicesAtmosphereResourceTypeBaseProps & {
43
+ networkOperation: GClickDevicesHotStartupSnapshotNetworkOperation;
44
+ startupSnapshot?: never;
45
+ } | CreateGClickDevicesAtmosphereResourceTypeBaseProps & {
46
+ networkOperation?: never;
47
+ startupSnapshot: GClickRealtimeResourceStartupSnapshotConfig;
48
+ };
49
+ /**
50
+ * Normalize one live `rt_devices` realtime message to the shared hash-key and payload identity contract.
51
+ */
52
+ export declare const normalizeGClickDevicesRealtimeMessage: RealTimeResourceMessageNormalizeStrategy;
53
+ /**
54
+ * Convert a backend devices snapshot response into replayable `rt_devices` realtime messages.
55
+ */
56
+ export declare function createGClickDevicesStartupSnapshotMessages(response: unknown, resourceTypeId?: RealTimeResourceTypeId): RealTimeMessage[];
57
+ /**
58
+ * Create one `rt_devices` startup snapshot from a shell-owned snapshot loader.
59
+ */
60
+ export declare function createGClickDevicesStartupSnapshot(props: CreateGClickDevicesStartupSnapshotProps): GClickRealtimeResourceStartupSnapshotConfig;
61
+ /**
62
+ * Create one standard `rt_devices` hot startup snapshot from a shell network operation.
63
+ */
64
+ export declare function createGClickDevicesHotStartupSnapshot(props: CreateGClickDevicesHotStartupSnapshotProps): GClickRealtimeResourceStartupSnapshotConfig;
65
+ /**
66
+ * Create the Atmosphere launch config for the devices resource type with its own merge and snapshot policy.
67
+ */
68
+ export declare function createGClickDevicesAtmosphereResourceType(props: CreateGClickDevicesAtmosphereResourceTypeProps): GClickRealtimeAtmosphereResourceTypeLaunchConfig;
69
+ export {};
70
+ //# sourceMappingURL=devicesResourceType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devicesResourceType.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/host/devicesResourceType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,wCAAwC,EAGxC,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAE,2CAA2C,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EACV,gDAAgD,EACjD,MAAM,kBAA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,kDAAkD,GAAG;IACrD,gBAAgB,CAAC,EAAE,KAAK,CAAC;IACzB,eAAe,EAAE,2CAA2C,CAAC;CAC9D,CAAC;AAwKJ;;GAEG;AACH,eAAO,MAAM,qCAAqC,EAAE,wCAwCnD,CAAC;AAwCF;;GAEG;AACH,wBAAgB,0CAA0C,CACxD,QAAQ,EAAE,OAAO,EACjB,cAAc,GAAE,sBAAqD,GACpE,eAAe,EAAE,CAiCnB;AAED;;GAEG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uCAAuC,GAC7C,2CAA2C,CAY7C;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,0CAA0C,GAChD,2CAA2C,CA2B7C;AAED;;GAEG;AACH,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,8CAA8C,GACpD,gDAAgD,CAyBlD"}
@@ -0,0 +1,196 @@
1
+ import { EnumResourceTypesIds as c } from "../shared/constants.js";
2
+ import { mergeDevicePayloadWithUpdatedAtGuard as f } from "../../payload/mergeDevicePayloadWithUpdatedAtGuard.js";
3
+ const I = [
4
+ "devices",
5
+ "resources",
6
+ "items",
7
+ "results"
8
+ ], y = "operative", m = "devices/";
9
+ function D(...e) {
10
+ const [r = "", ...t] = e, n = r.replace(/\/+$/u, ""), o = t.map((i) => i.replace(/^\/+|\/+$/gu, "")).filter(Boolean);
11
+ return [n, ...o].join("/");
12
+ }
13
+ function h(e) {
14
+ return e.startupSnapshotHostApiRemote?.trim() ? D(
15
+ e.startupSnapshotHostApiRemote,
16
+ e.database,
17
+ e.endPoint
18
+ ) : e.endPoint;
19
+ }
20
+ function a(e) {
21
+ return typeof e == "object" && e !== null && !Array.isArray(e);
22
+ }
23
+ function A(e) {
24
+ return a(e) && "data" in e ? e.data : e;
25
+ }
26
+ function l(e) {
27
+ return typeof e == "string" && e.trim() ? e : null;
28
+ }
29
+ function d(e) {
30
+ return typeof e == "number" && Number.isSafeInteger(e);
31
+ }
32
+ function P(e) {
33
+ return typeof e == "string" && !!e.trim();
34
+ }
35
+ function E(e) {
36
+ const r = Number(e);
37
+ return Number.isSafeInteger(r) ? r : null;
38
+ }
39
+ function p(e, r) {
40
+ return l(
41
+ e.resourceSerialId ?? e.serialId ?? r
42
+ );
43
+ }
44
+ function T(e, r) {
45
+ if ("id" in e && !d(e.id))
46
+ return null;
47
+ const t = { ...e };
48
+ if (delete t.resourceId, delete t.resourceSerialId, delete t.serialId, !("id" in t)) {
49
+ const n = E(r);
50
+ if (n === null)
51
+ return null;
52
+ t.id = n;
53
+ }
54
+ return t;
55
+ }
56
+ function v(e) {
57
+ if (!d(e.id) || !P(e.serialId))
58
+ return null;
59
+ const r = { ...e };
60
+ return delete r.resourceId, delete r.resourceSerialId, delete r.serialId, r.alias === null && delete r.alias, r;
61
+ }
62
+ const R = (e) => {
63
+ const r = l(e.resourceSerialId);
64
+ if (!r)
65
+ return null;
66
+ if (e.type === "delete")
67
+ return e.resourceSerialId === r ? e : {
68
+ ...e,
69
+ resourceSerialId: r
70
+ };
71
+ if (!a(e.payload))
72
+ return null;
73
+ const t = T(
74
+ e.payload,
75
+ r
76
+ );
77
+ return t ? r === e.resourceSerialId && t === e.payload ? e : {
78
+ ...e,
79
+ payload: t,
80
+ resourceSerialId: r
81
+ } : null;
82
+ };
83
+ function C(e) {
84
+ const r = A(e);
85
+ if (Array.isArray(r))
86
+ return r.map((t) => ({
87
+ deviceCandidate: t
88
+ }));
89
+ if (!a(r))
90
+ return [];
91
+ if (p(r))
92
+ return [{ deviceCandidate: r }];
93
+ for (const t of I) {
94
+ const n = r[t];
95
+ if (Array.isArray(n))
96
+ return n.map((o) => ({
97
+ deviceCandidate: o
98
+ }));
99
+ }
100
+ return Object.entries(r).map(([t, n]) => ({
101
+ deviceCandidate: n,
102
+ resourceSerialId: t
103
+ }));
104
+ }
105
+ function _(e, r = c.devices) {
106
+ return C(e).flatMap(({
107
+ deviceCandidate: t,
108
+ resourceSerialId: n
109
+ }) => {
110
+ if (!a(t))
111
+ return [];
112
+ const o = p(
113
+ t,
114
+ n
115
+ );
116
+ if (o === null)
117
+ return [];
118
+ const i = v(t);
119
+ return i === null ? [] : [
120
+ {
121
+ payload: i,
122
+ resourceSerialId: o,
123
+ resourceTypeId: r,
124
+ type: "update"
125
+ }
126
+ ];
127
+ });
128
+ }
129
+ function N(e) {
130
+ const {
131
+ loadSnapshot: r,
132
+ resourceTypeId: t = c.devices
133
+ } = e;
134
+ return {
135
+ loadMessages: async () => _(
136
+ await r(),
137
+ t
138
+ )
139
+ };
140
+ }
141
+ function b(e) {
142
+ const {
143
+ database: r = y,
144
+ endPoint: t = m,
145
+ networkOperation: n,
146
+ resourceTypeId: o = c.devices,
147
+ startupSnapshotHostApiRemote: i
148
+ } = e, s = h({
149
+ database: r,
150
+ endPoint: t,
151
+ startupSnapshotHostApiRemote: i
152
+ }), u = !!i?.trim();
153
+ return N({
154
+ loadSnapshot: () => n({
155
+ ...u ? { isExternalUrl: !0 } : { database: r },
156
+ endPoint: s,
157
+ method: "GET",
158
+ parms: {
159
+ hot: !0
160
+ },
161
+ responseToCamelCase: !0
162
+ }),
163
+ resourceTypeId: o
164
+ });
165
+ }
166
+ function H(e) {
167
+ const {
168
+ database: r,
169
+ endPoint: t,
170
+ networkOperation: n,
171
+ resourceTypeId: o,
172
+ startupSnapshot: i,
173
+ startupSnapshotHostApiRemote: s,
174
+ ...u
175
+ } = e, S = i ?? b({
176
+ database: r,
177
+ endPoint: t,
178
+ networkOperation: n,
179
+ resourceTypeId: o,
180
+ startupSnapshotHostApiRemote: s
181
+ });
182
+ return {
183
+ ...u,
184
+ normalizeMessageStrategy: R,
185
+ startupSnapshot: S,
186
+ resourceTypeId: o,
187
+ mergePayloadStrategy: f
188
+ };
189
+ }
190
+ export {
191
+ H as createGClickDevicesAtmosphereResourceType,
192
+ b as createGClickDevicesHotStartupSnapshot,
193
+ N as createGClickDevicesStartupSnapshot,
194
+ _ as createGClickDevicesStartupSnapshotMessages,
195
+ R as normalizeGClickDevicesRealtimeMessage
196
+ };
@@ -1,6 +1,7 @@
1
1
  import { RealTimeProducerTools } from '@m4l/realtime-runtime';
2
2
  import { RealTimeDummySimulationPresetId } from '../../dummy/index';
3
3
  import { RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceTypeId } from '../shared/runtimeTypes';
4
+ import { GClickRealtimeStartupSnapshotConfig } from './startupSnapshots';
4
5
  /**
5
6
  * Host-runtime realtime payload forwarded from the host into one gclick MF instance.
6
7
  *
@@ -8,6 +9,10 @@ import { RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceTypeId
8
9
  * package does not depend on MF shell runtime types from another workspace package.
9
10
  */
10
11
  export interface GClickRealtimeHostRuntime {
12
+ /**
13
+ * Release the shell-owned realtime runtime and stop its active sources.
14
+ */
15
+ dispose?: () => void;
11
16
  realtime?: {
12
17
  producerTools?: RealTimeProducerTools;
13
18
  };
@@ -31,6 +36,8 @@ export interface LaunchGClickAtmosphereHostRuntimeProps {
31
36
  runtimeKey: string;
32
37
  storeId?: string;
33
38
  storeDevtoolsEnabled?: boolean;
39
+ startSourceData?: boolean;
40
+ startupSnapshots?: GClickRealtimeStartupSnapshotConfig[];
34
41
  }
35
42
  /**
36
43
  * Create one host-runtime bag from a deterministic dummy preset without rebuilding MF-local runtime wiring.
@@ -1 +1 @@
1
- {"version":3,"file":"hostRuntime.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/host/hostRuntime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,+CAA+C,EAC/C,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,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,mBAAmB,EAAE,+CAA+C,EAAE,CAAC;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,yBAAyB,CAyB3B;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,sCAAsC,GAC5C,yBAAyB,CAQ3B;AACD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,CAAC,EAAE,yBAAyB,GACtC,qBAAqB,CAevB"}
1
+ {"version":3,"file":"hostRuntime.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/web/host/hostRuntime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,+CAA+C,EAC/C,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,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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