@m4l/realtime-runtime 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 (39) hide show
  1. package/contracts/index.d.ts +1 -1
  2. package/contracts/index.d.ts.map +1 -1
  3. package/contracts/types.d.ts +88 -4
  4. package/contracts/types.d.ts.map +1 -1
  5. package/engine/runtimeCore.d.ts +3 -1
  6. package/engine/runtimeCore.d.ts.map +1 -1
  7. package/engine/runtimeCore.js +9 -7
  8. package/index.d.ts +2 -1
  9. package/index.d.ts.map +1 -1
  10. package/index.js +7 -6
  11. package/package.json +1 -1
  12. package/transport/atmosphere/SourceDataAtmosphere.d.ts +41 -9
  13. package/transport/atmosphere/SourceDataAtmosphere.d.ts.map +1 -1
  14. package/transport/atmosphere/SourceDataAtmosphere.js +240 -96
  15. package/transport/atmosphere/createAtmosphereSourceData.d.ts +7 -3
  16. package/transport/atmosphere/createAtmosphereSourceData.d.ts.map +1 -1
  17. package/transport/atmosphere/createAtmosphereSourceData.js +33 -4
  18. package/transport/atmosphere/index.d.ts +1 -1
  19. package/transport/atmosphere/index.d.ts.map +1 -1
  20. package/transport/atmosphere/types.d.ts +24 -3
  21. package/transport/atmosphere/types.d.ts.map +1 -1
  22. package/transport/index.d.ts +1 -1
  23. package/transport/index.d.ts.map +1 -1
  24. package/web/index.d.ts +1 -1
  25. package/web/index.d.ts.map +1 -1
  26. package/web/runtime.d.ts.map +1 -1
  27. package/web/runtime.js +55 -53
  28. package/web/store.d.ts +2 -2
  29. package/web/store.d.ts.map +1 -1
  30. package/web/store.helpers.d.ts +24 -4
  31. package/web/store.helpers.d.ts.map +1 -1
  32. package/web/store.helpers.js +126 -23
  33. package/web/store.js +261 -80
  34. package/web/tools.d.ts.map +1 -1
  35. package/web/tools.js +15 -4
  36. package/web/types.d.ts +32 -3
  37. package/web/types.d.ts.map +1 -1
  38. package/web.d.ts +1 -1
  39. package/web.d.ts.map +1 -1
@@ -1,19 +1,67 @@
1
- import { SourceDataBase as p } from "../SourceDataBase.js";
2
- import * as a from "atmosphere.js";
3
- import u from "camelcase-keys";
4
- const l = "warn", m = 2e3, d = 1e4, f = 6e4;
5
- function T(o) {
6
- const e = o.host.trim(), t = `${e.endsWith(o.path) ? "" : o.path}${o.topic}`;
7
- return e ? e.startsWith("wss://") ? `https://${e.slice(6)}${t}` : e.startsWith("ws://") ? `http://${e.slice(5)}${t}` : e.startsWith("https://") || e.startsWith("http://") ? `${e}${t}` : `https://${e}${t}` : `${o.path}${o.topic}`;
1
+ import { SourceDataBase as y } from "../SourceDataBase.js";
2
+ import * as A from "atmosphere.js";
3
+ import S from "camelcase-keys";
4
+ const g = "warn", R = 2e3, O = 1e4, M = 6e4, d = "2.0.0";
5
+ function E() {
6
+ const t = A;
7
+ return t.subscribe ?? t.default?.subscribe;
8
8
  }
9
- class y extends p {
9
+ function f() {
10
+ return typeof globalThis.performance?.now == "function" ? globalThis.performance.now() : Date.now();
11
+ }
12
+ function c(t) {
13
+ return t ? f() : 0;
14
+ }
15
+ function u(t, e, s) {
16
+ t && t(
17
+ e,
18
+ Math.max(0, f() - s)
19
+ );
20
+ }
21
+ function L(t) {
22
+ return {
23
+ action: t.action,
24
+ session_id: t.sessionId,
25
+ version: t.version,
26
+ database: t.database,
27
+ account_id: "310000",
28
+ resource_types: t.resourceTypes.map((e) => ({
29
+ id: e.id,
30
+ consumer_type: e.consumerType,
31
+ publish_parms: e.publishParams,
32
+ rate_limit: e.rateLimit,
33
+ size_limit: e.sizeLimit,
34
+ resources_id: e.resourcesId,
35
+ projections: []
36
+ }))
37
+ };
38
+ }
39
+ function m(t) {
40
+ return JSON.stringify({
41
+ database: t.database,
42
+ fallbackTransport: t.fallbackTransport ?? "long-polling",
43
+ requestUrl: T(t),
44
+ sessionId: t.sessionId,
45
+ version: t.version ?? d
46
+ });
47
+ }
48
+ function T(t) {
49
+ const e = t.host.trim(), r = `${e.endsWith(t.path) ? "" : t.path}${t.topic}`;
50
+ return e ? e.startsWith("wss://") ? `https://${e.slice(6)}${r}` : e.startsWith("ws://") ? `http://${e.slice(5)}${r}` : e.startsWith("https://") || e.startsWith("http://") ? `${e}${r}` : `https://${e}${r}` : `${t.path}${t.topic}`;
51
+ }
52
+ class B {
53
+ constructor(e, s) {
54
+ this.onMessages = e, this.onPerformanceMetric = s;
55
+ }
10
56
  subSocket = null;
11
- stopped = !1;
12
57
  reconnectTimeout = null;
13
58
  transportOpenTimeout = null;
14
59
  transportAttempt = 0;
15
60
  browserRecoveryListenersBound = !1;
61
+ isTransportOpen = !1;
16
62
  lastMessageTime = performance.now();
63
+ connectionSignature = null;
64
+ activeConfigs = /* @__PURE__ */ new Map();
17
65
  /**
18
66
  * Recheck the current transport when the browser regains focus.
19
67
  */
@@ -33,43 +81,68 @@ class y extends p {
33
81
  this.isBrowserDocumentHidden() || this.recoverTransportFromBrowserEvent("visibilitychange");
34
82
  };
35
83
  /**
36
- * Start the realtime transport connection.
84
+ * Register one resource type in the active shared transport group.
37
85
  */
38
- start() {
39
- this.stopped = !1, this.bindBrowserRecoveryListeners(), this.connect();
86
+ start(e) {
87
+ const s = this.activeConfigs.size === 0;
88
+ if (this.assertCompatibleConfig(e), this.activeConfigs.set(e.resourceTypeId, e), this.connectionSignature = this.connectionSignature ?? m(e), s) {
89
+ this.bindBrowserRecoveryListeners(), this.connect();
90
+ return;
91
+ }
92
+ this.isTransportOpen && this.sendSubscribe();
93
+ }
94
+ /**
95
+ * Remove one resource type from the shared transport group and stop the socket when the last one leaves.
96
+ */
97
+ stop(e) {
98
+ this.activeConfigs.delete(e), !this.activeConfigs.size && (this.shutdownTransport(), this.connectionSignature = null);
40
99
  }
41
100
  /**
42
- * Send the subscribe payload expected by the Atmosphere backend.
101
+ * Keep one shared transport restricted to a single Atmosphere connection contract per runtime.
102
+ */
103
+ assertCompatibleConfig(e) {
104
+ if (!(!this.connectionSignature || m(e) === this.connectionSignature))
105
+ throw new Error(
106
+ "Atmosphere runtime factory only supports one shared Atmosphere connection per runtime. Received one incompatible resource config that would require a second socket."
107
+ );
108
+ }
109
+ /**
110
+ * Send the grouped subscribe payload expected by the Atmosphere backend.
43
111
  */
44
112
  sendSubscribe() {
113
+ const e = this.getRepresentativeConfig();
114
+ if (!e || !this.subSocket)
115
+ return;
45
116
  this.lastMessageTime = performance.now();
46
- const {
47
- consumerType: e = "batch",
48
- database: n,
49
- projections: t = [],
50
- rateLimit: i = 3,
51
- resourceTypeId: r,
52
- resourcesId: s = ["all"],
53
- sessionId: c,
54
- version: h = "1.0.0"
55
- } = this.config;
56
- this.subSocket?.push?.(JSON.stringify({
117
+ const s = {
57
118
  action: "subscribe",
58
- session_id: c,
59
- version: h,
60
- resource_type_id: r,
61
- database: n,
62
- consumer_type: e,
63
- rate_limit: i,
64
- resources_id: s,
65
- projections: t
66
- }));
119
+ database: e.database,
120
+ resourceTypes: Array.from(this.activeConfigs.values()).map((r) => ({
121
+ consumerType: r.consumerType ?? "batch",
122
+ id: r.resourceTypeId,
123
+ publishParams: r.publishParams ?? {},
124
+ rateLimit: r.rateLimit ?? 3,
125
+ resourcesId: r.resourcesId ?? ["all"],
126
+ sizeLimit: r.sizeLimit
127
+ })),
128
+ sessionId: e.sessionId,
129
+ version: e.version ?? d
130
+ };
131
+ this.subSocket.push?.(JSON.stringify(
132
+ L(s)
133
+ ));
134
+ }
135
+ /**
136
+ * Return the current compatibility config that defines the shared connection details.
137
+ */
138
+ getRepresentativeConfig() {
139
+ return this.activeConfigs.values().next().value;
67
140
  }
68
141
  /**
69
142
  * Return whether one callback still belongs to the latest transport attempt.
70
143
  */
71
144
  isActiveAttempt(e) {
72
- return !this.stopped && e === this.transportAttempt;
145
+ return this.activeConfigs.size > 0 && e === this.transportAttempt;
73
146
  }
74
147
  /**
75
148
  * Clear the pending manual reconnect timer.
@@ -110,8 +183,8 @@ class y extends p {
110
183
  /**
111
184
  * Mark the transport as healthy again after one successful open or message.
112
185
  */
113
- markTransportHealthy(e) {
114
- this.lastMessageTime = performance.now(), this.clearTransportOpenTimeout(), this.clearReconnectTimeout();
186
+ markTransportHealthy() {
187
+ this.isTransportOpen = !0, this.lastMessageTime = performance.now(), this.clearTransportOpenTimeout(), this.clearReconnectTimeout();
115
188
  }
116
189
  /**
117
190
  * Force one fresh reconnect when the current transport never reaches onOpen.
@@ -119,13 +192,13 @@ class y extends p {
119
192
  armTransportOpenTimeout(e) {
120
193
  this.clearTransportOpenTimeout(), this.transportOpenTimeout = setTimeout(() => {
121
194
  this.transportOpenTimeout = null, this.isActiveAttempt(e) && (console.warn("Atmosphere: transport open timed out; scheduling reconnect"), this.tryReconnect());
122
- }, d);
195
+ }, O);
123
196
  }
124
197
  /**
125
198
  * Reconnect one stale transport when the browser regains a healthy execution state.
126
199
  */
127
200
  recoverTransportFromBrowserEvent(e) {
128
- if (this.stopped)
201
+ if (!this.activeConfigs.size)
129
202
  return;
130
203
  if (!this.subSocket) {
131
204
  console.warn("Atmosphere: browser recovery found no active socket; scheduling reconnect", {
@@ -133,24 +206,25 @@ class y extends p {
133
206
  }), this.tryReconnect();
134
207
  return;
135
208
  }
136
- const n = performance.now() - this.lastMessageTime;
137
- n < f || (console.warn("Atmosphere: browser recovery found one stale transport; scheduling reconnect", {
209
+ const s = performance.now() - this.lastMessageTime;
210
+ s < M || (console.warn("Atmosphere: browser recovery found one stale transport; scheduling reconnect", {
138
211
  reason: e,
139
- silenceDurationMs: n
212
+ silenceDurationMs: s
140
213
  }), this.tryReconnect());
141
214
  }
142
215
  /**
143
- * Connect to the realtime backend transport.
216
+ * Connect to the shared realtime backend transport.
144
217
  */
145
218
  connect() {
146
- if (this.stopped)
219
+ const e = this.getRepresentativeConfig();
220
+ if (!e)
147
221
  return;
148
- const e = this.config, n = T(e), t = this.transportAttempt + 1;
149
- this.transportAttempt = t;
150
- const i = {
151
- url: n,
222
+ const s = T(e), r = this.transportAttempt + 1;
223
+ this.transportAttempt = r, this.isTransportOpen = !1;
224
+ const h = {
225
+ url: s,
152
226
  contentType: "application/json",
153
- logLevel: l,
227
+ logLevel: g,
154
228
  transport: "websocket",
155
229
  fallbackTransport: e.fallbackTransport ?? "long-polling",
156
230
  reconnectInterval: 2e3,
@@ -158,74 +232,119 @@ class y extends p {
158
232
  * Resubscribe as soon as the connection opens.
159
233
  */
160
234
  onOpen: () => {
161
- this.isActiveAttempt(t) && (this.markTransportHealthy(t), this.sendSubscribe());
235
+ this.isActiveAttempt(r) && (this.markTransportHealthy(), this.sendSubscribe());
162
236
  },
163
237
  /**
164
238
  * Resubscribe after an Atmosphere reconnect event.
165
239
  */
166
240
  onReopen: () => {
167
- this.isActiveAttempt(t) && (this.markTransportHealthy(t), this.sendSubscribe());
241
+ this.isActiveAttempt(r) && (this.markTransportHealthy(), this.sendSubscribe());
168
242
  },
169
243
  /**
170
244
  * Decode one transport message and forward event batches into the producer store.
171
245
  */
172
- onMessage: (r) => {
173
- if (this.isActiveAttempt(t)) {
174
- this.markTransportHealthy(t);
246
+ onMessage: (n) => {
247
+ if (!this.isActiveAttempt(r))
248
+ return;
249
+ this.markTransportHealthy();
250
+ const o = c(
251
+ this.onPerformanceMetric
252
+ );
253
+ try {
254
+ let a;
255
+ const v = c(
256
+ this.onPerformanceMetric
257
+ );
175
258
  try {
176
- const s = u(
177
- JSON.parse(r.responseBody ?? ""),
178
- { deep: !0 }
259
+ a = JSON.parse(n.responseBody ?? "");
260
+ } finally {
261
+ u(
262
+ this.onPerformanceMetric,
263
+ "producerTransportParseDurationMs",
264
+ v
179
265
  );
180
- if (s.type === "event") {
181
- const { messages: c } = s.data;
182
- this.onMessages(this.config.resourceTypeId, c);
183
- } else s.type !== "success" && console.error(
184
- `Atmosphere: subscription error after ${performance.now() - this.lastMessageTime}ms`,
185
- s
186
- );
187
- } catch (s) {
188
- console.error("Atmosphere: invalid JSON message", s);
189
266
  }
267
+ const b = c(
268
+ this.onPerformanceMetric
269
+ ), i = S(
270
+ a,
271
+ { deep: !0 }
272
+ );
273
+ if (u(
274
+ this.onPerformanceMetric,
275
+ "producerTransportNormalizeDurationMs",
276
+ b
277
+ ), i.type === "event") {
278
+ const l = this.getRepresentativeConfig()?.resourceTypeId;
279
+ if (!l) {
280
+ console.error(
281
+ "Atmosphere: received one event batch without any active runtime resourceTypeId context.",
282
+ i
283
+ );
284
+ return;
285
+ }
286
+ const w = c(
287
+ this.onPerformanceMetric
288
+ );
289
+ this.onMessages(
290
+ l,
291
+ i.data.messages
292
+ ), u(
293
+ this.onPerformanceMetric,
294
+ "producerTransportEmitDurationMs",
295
+ w
296
+ );
297
+ } else i.type !== "success" && console.error(
298
+ `Atmosphere: subscription error after ${performance.now() - this.lastMessageTime}ms`,
299
+ i
300
+ );
301
+ } catch (a) {
302
+ console.error("Atmosphere: invalid JSON message", a);
303
+ } finally {
304
+ u(
305
+ this.onPerformanceMetric,
306
+ "producerTransportMessageDurationMs",
307
+ o
308
+ );
190
309
  }
191
310
  },
192
311
  /**
193
312
  * Schedule one fresh reconnect when the active transport closes.
194
313
  */
195
- onClose: (r) => {
196
- this.isActiveAttempt(t) && (console.warn("Atmosphere: transport closed", {
197
- reason: r?.reasonPhrase,
198
- state: r?.state,
199
- transport: r?.transport
314
+ onClose: (n) => {
315
+ this.isActiveAttempt(r) && (this.isTransportOpen = !1, console.warn("Atmosphere: transport closed", {
316
+ reason: n?.reasonPhrase,
317
+ state: n?.state,
318
+ transport: n?.transport
200
319
  }), this.tryReconnect());
201
320
  },
202
321
  /**
203
322
  * Schedule one fresh reconnect after one transport error.
204
323
  */
205
- onError: (r) => {
206
- this.isActiveAttempt(t) && (console.warn("Atmosphere: transport error", {
207
- error: r?.error,
208
- reason: r?.reasonPhrase,
209
- state: r?.state,
210
- transport: r?.transport
324
+ onError: (n) => {
325
+ this.isActiveAttempt(r) && (this.isTransportOpen = !1, console.warn("Atmosphere: transport error", {
326
+ error: n?.error,
327
+ reason: n?.reasonPhrase,
328
+ state: n?.state,
329
+ transport: n?.transport
211
330
  }), this.tryReconnect());
212
331
  },
213
332
  /**
214
333
  * Schedule one fresh reconnect when Atmosphere cannot preserve the transport.
215
334
  */
216
- onTransportFailure: (r, s) => {
217
- this.isActiveAttempt(t) && (console.warn("Atmosphere: transport failure", {
218
- reason: r,
219
- responseError: s?.error,
220
- responseState: s?.state,
221
- transport: s?.transport
335
+ onTransportFailure: (n, o) => {
336
+ this.isActiveAttempt(r) && (this.isTransportOpen = !1, console.warn("Atmosphere: transport failure", {
337
+ reason: n,
338
+ responseError: o?.error,
339
+ responseState: o?.state,
340
+ transport: o?.transport
222
341
  }), this.tryReconnect());
223
342
  },
224
343
  /**
225
344
  * Trigger one fresh reconnect after Atmosphere gives up on its own retry loop.
226
345
  */
227
346
  onFailureToReconnect: () => {
228
- this.isActiveAttempt(t) && this.tryReconnect();
347
+ this.isActiveAttempt(r) && (this.isTransportOpen = !1, this.tryReconnect());
229
348
  }
230
349
  };
231
350
  if (this.subSocket) {
@@ -235,28 +354,29 @@ class y extends p {
235
354
  }
236
355
  this.subSocket = null;
237
356
  }
238
- if (a.subscribe) {
239
- this.lastMessageTime = performance.now(), this.armTransportOpenTimeout(t);
357
+ const p = E();
358
+ if (p) {
359
+ this.lastMessageTime = performance.now(), this.armTransportOpenTimeout(r);
240
360
  try {
241
- this.subSocket = a.subscribe(i);
242
- } catch (r) {
243
- console.error("Atmosphere: failed to subscribe", r), this.tryReconnect();
361
+ this.subSocket = p(h);
362
+ } catch (n) {
363
+ console.error("Atmosphere: failed to subscribe", n), this.tryReconnect();
244
364
  }
245
365
  }
246
366
  }
247
367
  /**
248
- * Schedule the next reconnect attempt unless the source has already stopped.
368
+ * Schedule the next reconnect attempt unless the shared source group is already empty.
249
369
  */
250
370
  tryReconnect() {
251
- this.stopped || (this.clearTransportOpenTimeout(), !this.reconnectTimeout && (this.reconnectTimeout = setTimeout(() => {
371
+ this.activeConfigs.size && (this.clearTransportOpenTimeout(), !this.reconnectTimeout && (this.reconnectTimeout = setTimeout(() => {
252
372
  this.reconnectTimeout = null, this.connect();
253
- }, m)));
373
+ }, R)));
254
374
  }
255
375
  /**
256
- * Stop the transport and cancel any pending reconnect attempt.
376
+ * Stop the shared transport and cancel any pending reconnect attempt.
257
377
  */
258
- stop() {
259
- if (this.stopped = !0, this.transportAttempt += 1, this.unbindBrowserRecoveryListeners(), this.clearReconnectTimeout(), this.clearTransportOpenTimeout(), this.subSocket) {
378
+ shutdownTransport() {
379
+ if (this.transportAttempt += 1, this.isTransportOpen = !1, this.unbindBrowserRecoveryListeners(), this.clearReconnectTimeout(), this.clearTransportOpenTimeout(), this.subSocket) {
260
380
  try {
261
381
  this.subSocket.close?.();
262
382
  } catch {
@@ -265,8 +385,32 @@ class y extends p {
265
385
  }
266
386
  }
267
387
  }
388
+ class k extends y {
389
+ sharedTransport;
390
+ constructor(e, s, r, h) {
391
+ super(e, s), this.sharedTransport = r ?? new B(
392
+ s,
393
+ h
394
+ );
395
+ }
396
+ /**
397
+ * Start the realtime transport connection.
398
+ */
399
+ start() {
400
+ this.sharedTransport.start(
401
+ this.config
402
+ );
403
+ }
404
+ /**
405
+ * Stop the transport and cancel any pending reconnect attempt.
406
+ */
407
+ stop() {
408
+ this.sharedTransport.stop(this.config.resourceTypeId);
409
+ }
410
+ }
268
411
  export {
269
- y as SourceDataAtmosphere,
270
- y as default,
412
+ B as SharedAtmosphereTransport,
413
+ k as SourceDataAtmosphere,
414
+ k as default,
271
415
  T as resolveAtmosphereRequestUrl
272
416
  };
@@ -1,7 +1,11 @@
1
- import { OnMessagesStoreCallback, RealTimeResourceSourceMechanismConfig } from '../../contracts';
1
+ import { OnMessagesStoreCallback, OnRealTimeProducerMetricCallback, RealTimeResourceSourceMechanismConfig } from '../../contracts';
2
2
  import { SourceDataBase } from '../SourceDataBase';
3
3
  /**
4
- * Create one source mechanism restricted to the real Atmosphere transport.
4
+ * Create one dedicated source mechanism restricted to the real Atmosphere transport.
5
5
  */
6
- export declare function createAtmosphereSourceData(config: RealTimeResourceSourceMechanismConfig, onMessages: OnMessagesStoreCallback): SourceDataBase;
6
+ export declare function createAtmosphereSourceData(config: RealTimeResourceSourceMechanismConfig, onMessages: OnMessagesStoreCallback, onPerformanceMetric?: OnRealTimeProducerMetricCallback): SourceDataBase;
7
+ /**
8
+ * Create one runtime-scoped Atmosphere source factory that reuses a single shared socket for the whole app/runtime.
9
+ */
10
+ export declare function createAtmosphereSourceDataFactory(): (config: RealTimeResourceSourceMechanismConfig, onMessages: OnMessagesStoreCallback, onPerformanceMetric?: OnRealTimeProducerMetricCallback) => SourceDataBase;
7
11
  //# sourceMappingURL=createAtmosphereSourceData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAtmosphereSourceData.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/createAtmosphereSourceData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,qCAAqC,EACtC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,qCAAqC,EAC7C,UAAU,EAAE,uBAAuB,GAClC,cAAc,CAQhB"}
1
+ {"version":3,"file":"createAtmosphereSourceData.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/createAtmosphereSourceData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,gCAAgC,EAEhC,qCAAqC,EACtC,MAAM,iBAAiB,CAAC;AAKzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,qCAAqC,EAC7C,UAAU,EAAE,uBAAuB,EACnC,mBAAmB,CAAC,EAAE,gCAAgC,GACrD,cAAc,CAahB;AAED;;GAEG;AACH,wBAAgB,iCAAiC,KAK7C,QAAQ,qCAAqC,EAC7C,YAAY,uBAAuB,EACnC,sBAAsB,gCAAgC,KACrD,cAAc,CAyBlB"}
@@ -1,11 +1,40 @@
1
- import { SourceDataAtmosphere as o } from "./SourceDataAtmosphere.js";
2
- function a(e, r) {
1
+ import { SourceDataAtmosphere as n, SharedAtmosphereTransport as u } from "./SourceDataAtmosphere.js";
2
+ function c(e, r, o) {
3
3
  if (e.sourceDataMechanism !== "atmosphere")
4
4
  throw new Error(
5
5
  "Atmosphere-only realtime runtime does not support non-atmosphere resource types."
6
6
  );
7
- return new o(e, r);
7
+ return new n(
8
+ e,
9
+ r,
10
+ void 0,
11
+ o
12
+ );
13
+ }
14
+ function m() {
15
+ let e = null, r = null;
16
+ return function(a, t, s) {
17
+ if (a.sourceDataMechanism !== "atmosphere")
18
+ throw new Error(
19
+ "Atmosphere-only realtime runtime does not support non-atmosphere resource types."
20
+ );
21
+ if (!e)
22
+ r = t, e = new u(
23
+ t,
24
+ s
25
+ );
26
+ else if (r !== t)
27
+ throw new Error(
28
+ "Atmosphere source-data factory is scoped to one runtime callback and cannot be reused across runtimes."
29
+ );
30
+ return new n(
31
+ a,
32
+ t,
33
+ e
34
+ );
35
+ };
8
36
  }
9
37
  export {
10
- a as createAtmosphereSourceData
38
+ c as createAtmosphereSourceData,
39
+ m as createAtmosphereSourceDataFactory
11
40
  };
@@ -1,4 +1,4 @@
1
- export { createAtmosphereSourceData } from './createAtmosphereSourceData';
1
+ export { createAtmosphereSourceData, createAtmosphereSourceDataFactory, } from './createAtmosphereSourceData';
2
2
  export { resolveAtmosphereRequestUrl, SourceDataAtmosphere, } from './SourceDataAtmosphere';
3
3
  export type { AtmosphereMessage } from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,6 +1,27 @@
1
- import { RealTimeMessage, RealTimeResourceTypeId } from '../../contracts';
1
+ import { RealTimeMessage, RealTimeResourceSerialId, RealTimeResourceTypeId } from '../../contracts';
2
2
  export type AtmosphereMessageType = 'success' | 'event' | 'error';
3
3
  export type AtmosphereMessageAction = 'subscribe' | 'event';
4
+ /**
5
+ * One resource-type entry sent through the new Atmosphere subscribe payload.
6
+ */
7
+ export interface AtmosphereSubscribeResourceTypePayload {
8
+ id: RealTimeResourceTypeId;
9
+ consumerType?: string;
10
+ publishParams?: Record<string, unknown>;
11
+ rateLimit?: number;
12
+ sizeLimit?: number;
13
+ resourcesId?: Array<RealTimeResourceSerialId | 'all'>;
14
+ }
15
+ /**
16
+ * Subscribe payload expected by the updated Atmosphere backend contract.
17
+ */
18
+ export interface AtmosphereSubscribePayload {
19
+ action: 'subscribe';
20
+ sessionId: string;
21
+ version: string | number;
22
+ database: string;
23
+ resourceTypes: AtmosphereSubscribeResourceTypePayload[];
24
+ }
4
25
  /**
5
26
  * Messages received from the Atmosphere transport.
6
27
  */
@@ -20,8 +41,8 @@ export interface AtmosphereMessageEvent {
20
41
  type: 'event';
21
42
  action: 'event';
22
43
  data: {
23
- version: string;
24
- resource_type_id: RealTimeResourceTypeId;
44
+ version: string | number;
45
+ resourceTypeId?: RealTimeResourceTypeId;
25
46
  messages: RealTimeMessage[];
26
47
  };
27
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,OAAO,CAAC;AAC5D;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CAMrB;AACD,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IAEpB,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,sBAAsB,CAAC;QACzC,QAAQ,EAAE,eAAe,EAAE,CAAC;KAK7B,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GACzB,+BAA+B,GAC/B,sBAAsB,GACtB,8BAA8B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,OAAO,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,sCAAsC;IACrD,EAAE,EAAE,sBAAsB,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,sCAAsC,EAAE,CAAC;CACzD;AACD;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CAMrB;AACD,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IAEpB,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,sBAAsB,CAAC;QACxC,QAAQ,EAAE,eAAe,EAAE,CAAC;KAK7B,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GACzB,+BAA+B,GAC/B,sBAAsB,GACtB,8BAA8B,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export { SourceDataBase } from './SourceDataBase';
2
- export { createAtmosphereSourceData, resolveAtmosphereRequestUrl, SourceDataAtmosphere, } from './atmosphere';
2
+ export { createAtmosphereSourceData, createAtmosphereSourceDataFactory, resolveAtmosphereRequestUrl, SourceDataAtmosphere, } from './atmosphere';
3
3
  export type { AtmosphereMessage } from './atmosphere';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,EACjC,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
package/web/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { REALTIME_PRODUCER_STORE_ID } from './constants';
2
2
  export { createRealTimeStore } from './store';
3
3
  export type { CreateRealTimeSourceData, RealTimeStoreType, } from './store';
4
4
  export { createRealTimeProducerTools } from './tools';
5
- export type { RealTimeProducerTools } from '../contracts';
5
+ export type { RealTimeProducerTools, RealTimeReadonlyResourceHash, SubscribeResourceTypeOptions, } from '../contracts';
6
6
  export { createGetOrCreateRealtimeRuntime, createRealtimeRuntime, createRealtimeRuntimeBundle, disposeRealtimeRuntime, } from './runtime';
7
7
  export type { CreateRealTimeStoreProps, CreateRealtimeRuntimeProps, GetOrCreateRealtimeRuntimeProps, InitialRealTimeProducerStoreProps, MessageQueueManager, RealtimeRuntimeBundle, RealTimeProducerStoreResourceType, RealTimeProducerStoreState, RealTimeProducerStoreStateWithActions, } from './runtime';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,gCAAgC,EAChC,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,+BAA+B,EAC/B,iCAAiC,EACjC,mBAAmB,EACnB,qBAAqB,EACrB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,GACtC,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,gCAAgC,EAChC,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,+BAA+B,EAC/B,iCAAiC,EACjC,mBAAmB,EACnB,qBAAqB,EACrB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,GACtC,MAAM,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,mBAAmB,EACnB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAQjB;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED,MAAM,WAAW,+BACf,SAAQ,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA2HD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,EACjC,gBAAgB,EAAE,wBAAwB,GACzC,eAAe,CAKjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,0BAA0B,EACjC,gBAAgB,EAAE,wBAAwB,GACzC,qBAAqB,CASvB;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,SAAS,qBAAqB,EAEtC,aAAa,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,QAAQ,IAQ5D,OAAO,+BAA+B,KACrC,QAAQ,CAWZ;AACD,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,mBAAmB,EACnB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,GACtC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,mBAAmB,EACnB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAQjB;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED,MAAM,WAAW,+BACf,SAAQ,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiID;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,EACjC,gBAAgB,EAAE,wBAAwB,GACzC,eAAe,CAKjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,0BAA0B,EACjC,gBAAgB,EAAE,wBAAwB,GACzC,qBAAqB,CASvB;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,SAAS,qBAAqB,EAEtC,aAAa,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,QAAQ,IAQ5D,OAAO,+BAA+B,KACrC,QAAQ,CAWZ;AACD,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,mBAAmB,EACnB,iCAAiC,EACjC,0BAA0B,EAC1B,qCAAqC,GACtC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}