orez-lite 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/cf-do/application-sql.d.ts +10 -3
  2. package/dist/cf-do/application-sql.d.ts.map +1 -1
  3. package/dist/cf-do/application-sql.js.map +1 -1
  4. package/dist/cf-do/lite-data-worker.d.ts.map +1 -1
  5. package/dist/cf-do/lite-data-worker.js +10 -1
  6. package/dist/cf-do/lite-data-worker.js.map +1 -1
  7. package/dist/cf-do/worker.d.ts +1 -1
  8. package/dist/cf-do/worker.d.ts.map +1 -1
  9. package/dist/cf-do/worker.js +3 -0
  10. package/dist/cf-do/worker.js.map +1 -1
  11. package/dist/realtime.d.ts +18 -0
  12. package/dist/realtime.d.ts.map +1 -0
  13. package/dist/realtime.js +18 -0
  14. package/dist/realtime.js.map +1 -0
  15. package/package.json +6 -6
  16. package/dist/realtime/host.d.ts +0 -7
  17. package/dist/realtime/host.d.ts.map +0 -1
  18. package/dist/realtime/host.js +0 -77
  19. package/dist/realtime/host.js.map +0 -1
  20. package/dist/realtime/hub.d.ts +0 -67
  21. package/dist/realtime/hub.d.ts.map +0 -1
  22. package/dist/realtime/hub.js +0 -456
  23. package/dist/realtime/hub.js.map +0 -1
  24. package/dist/realtime/index.d.ts +0 -24
  25. package/dist/realtime/index.d.ts.map +0 -1
  26. package/dist/realtime/index.js +0 -27
  27. package/dist/realtime/index.js.map +0 -1
  28. package/dist/realtime/local.d.ts +0 -15
  29. package/dist/realtime/local.d.ts.map +0 -1
  30. package/dist/realtime/local.js +0 -63
  31. package/dist/realtime/local.js.map +0 -1
  32. package/dist/realtime/manifest.d.ts +0 -51
  33. package/dist/realtime/manifest.d.ts.map +0 -1
  34. package/dist/realtime/manifest.js +0 -110
  35. package/dist/realtime/manifest.js.map +0 -1
  36. package/dist/realtime/message-port.d.ts +0 -34
  37. package/dist/realtime/message-port.d.ts.map +0 -1
  38. package/dist/realtime/message-port.js +0 -141
  39. package/dist/realtime/message-port.js.map +0 -1
  40. package/dist/realtime/producer-socket.d.ts +0 -10
  41. package/dist/realtime/producer-socket.d.ts.map +0 -1
  42. package/dist/realtime/producer-socket.js +0 -90
  43. package/dist/realtime/producer-socket.js.map +0 -1
  44. package/dist/realtime/producer.d.ts +0 -16
  45. package/dist/realtime/producer.d.ts.map +0 -1
  46. package/dist/realtime/producer.js +0 -51
  47. package/dist/realtime/producer.js.map +0 -1
  48. package/dist/realtime/protocol.d.ts +0 -99
  49. package/dist/realtime/protocol.d.ts.map +0 -1
  50. package/dist/realtime/protocol.js +0 -191
  51. package/dist/realtime/protocol.js.map +0 -1
  52. package/dist/realtime/publisher.d.ts +0 -28
  53. package/dist/realtime/publisher.d.ts.map +0 -1
  54. package/dist/realtime/publisher.js +0 -309
  55. package/dist/realtime/publisher.js.map +0 -1
  56. package/dist/realtime/socket-host.d.ts +0 -25
  57. package/dist/realtime/socket-host.d.ts.map +0 -1
  58. package/dist/realtime/socket-host.js +0 -105
  59. package/dist/realtime/socket-host.js.map +0 -1
  60. package/dist/realtime/store.d.ts +0 -28
  61. package/dist/realtime/store.d.ts.map +0 -1
  62. package/dist/realtime/store.js +0 -0
  63. package/dist/realtime/store.js.map +0 -1
  64. package/dist/realtime/writer.d.ts +0 -17
  65. package/dist/realtime/writer.d.ts.map +0 -1
  66. package/dist/realtime/writer.js +0 -138
  67. package/dist/realtime/writer.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/realtime/hub.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ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,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;CAInE"}
@@ -1,456 +0,0 @@
1
- // The host-side realtime hub: one pure state machine shared by every
2
- // TypeScript host (the Cloudflare Durable Object and the browser worker).
3
- //
4
- // It owns no I/O. Connections are opaque handles with a `send`, so the same
5
- // logic drives a hibernatable WebSocket, a MessagePort, and a test harness. A
6
- // host adapter is then only socket lifecycle plus authentication.
7
- //
8
- // The hub ACCUMULATES each generation's value. That is what makes append-mode
9
- // frames safe: a subscriber arriving at token 900 gets one snapshot of what the
10
- // hub has, then appends, and no client ever needs a replay buffer. It is also
11
- // why a lost frame cannot produce a wrong value, since the next snapshot after
12
- // any reconnect is authoritative.
13
- import { resolveTopic } from './manifest.js';
14
- import { canonicalEncode } from './store.js';
15
- export const DEFAULT_HUB_LIMITS = {
16
- maxTopicsPerConnection: 256,
17
- maxSubscribersPerTopic: 512,
18
- maxTopicsPerNamespace: 4096,
19
- maxBatchBytes: 512 * 1024,
20
- batchWindowMs: 25,
21
- };
22
- export class RealtimeHub {
23
- #manifest;
24
- #authorize;
25
- #limits;
26
- #schedule;
27
- #generations = new Map();
28
- #subscribers = new Map();
29
- #connectionTopics = new Map();
30
- #connections = new Map();
31
- // producer id -> every generation it currently leases. An application server
32
- // streaming twenty agent sessions holds one connection, not twenty, so the
33
- // lease is a set: the socket closing releases all of them at once.
34
- #producerGenerations = new Map();
35
- // per-connection outbound batch, flushed on the batching window
36
- #outbox = new Map();
37
- #flushScheduled = false;
38
- // One chain per connection so its subscribe and unsubscribe frames apply in
39
- // arrival order even though authorization may await. Without it, a
40
- // subscribe/unsubscribe pair sent back to back could resolve out of order and
41
- // leave a connection subscribed to a topic it had already dropped.
42
- #connectionQueue = new Map();
43
- // Bumped by dropConnection. A subscribe captures the epoch when the frame
44
- // ARRIVES, not when its queued task runs, so a socket that closes while its
45
- // authorization is still in flight abandons the subscription instead of
46
- // completing it against a connection nobody is reading from.
47
- #connectionEpoch = new Map();
48
- constructor(options) {
49
- this.#manifest = options.manifest;
50
- this.#authorize = options.authorizeSubscribe;
51
- this.#limits = { ...DEFAULT_HUB_LIMITS, ...options.limits };
52
- this.#schedule =
53
- options.scheduleFlush ??
54
- ((flush, ms) => {
55
- setTimeout(flush, ms);
56
- });
57
- }
58
- // ---- subscribers --------------------------------------------------------
59
- // Queued per connection: the returned promise resolves once this frame has
60
- // been applied, which is what a host adapter awaits before processing the
61
- // next frame from the same socket.
62
- subscribe(connection, topic) {
63
- const epoch = this.#connectionEpoch.get(connection.id) ?? 0;
64
- return this.#enqueue(connection.id, () => this.#subscribe(connection, topic, epoch));
65
- }
66
- unsubscribe(connection, topic) {
67
- return this.#enqueue(connection.id, () => {
68
- const resolved = resolveTopic(this.#manifest, topic);
69
- if ('reason' in resolved)
70
- return;
71
- this.#removeSubscription(connection.id, resolved.id);
72
- });
73
- }
74
- #enqueue(connectionID, task) {
75
- const previous = this.#connectionQueue.get(connectionID) ?? Promise.resolve();
76
- // a rejected task must not poison the chain for later frames
77
- const next = previous.then(task).catch(() => { });
78
- this.#connectionQueue.set(connectionID, next);
79
- return next;
80
- }
81
- #isCurrent(connectionID, epoch) {
82
- return (this.#connectionEpoch.get(connectionID) ?? 0) === epoch;
83
- }
84
- async #subscribe(connection, topic, epoch) {
85
- if (!this.#isCurrent(connection.id, epoch))
86
- return;
87
- this.#connections.set(connection.id, connection);
88
- const resolved = resolveTopic(this.#manifest, topic);
89
- if ('reason' in resolved) {
90
- connection.send([
91
- 'subscribe-error',
92
- { topic: describe(topic), reason: resolved.reason },
93
- ]);
94
- return;
95
- }
96
- const { spec, id } = resolved;
97
- const owned = this.#connectionTopics.get(connection.id) ?? new Set();
98
- // a resubscribe after reconnect is not a new subscription
99
- if (!owned.has(id)) {
100
- if (owned.size >= this.#limits.maxTopicsPerConnection) {
101
- connection.send([
102
- 'subscribe-error',
103
- { topic: id, reason: 'connection is at its subscription limit' },
104
- ]);
105
- return;
106
- }
107
- if (!this.#subscribers.has(id) &&
108
- this.#subscribers.size >= this.#limits.maxTopicsPerNamespace) {
109
- connection.send([
110
- 'subscribe-error',
111
- { topic: id, reason: 'namespace is at its active topic limit' },
112
- ]);
113
- return;
114
- }
115
- const existing = this.#subscribers.get(id);
116
- if (existing && existing.size >= this.#limits.maxSubscribersPerTopic) {
117
- connection.send([
118
- 'subscribe-error',
119
- { topic: id, reason: 'topic is at its subscriber limit' },
120
- ]);
121
- return;
122
- }
123
- }
124
- const authorization = await this.#authorize(connection.identity, topic, spec);
125
- // the socket can close while authorization is in flight
126
- if (!this.#isCurrent(connection.id, epoch))
127
- return;
128
- if (authorization.status === 'denied') {
129
- connection.send(['subscribe-error', { topic: id, reason: authorization.reason }]);
130
- return;
131
- }
132
- owned.add(id);
133
- this.#connectionTopics.set(connection.id, owned);
134
- if (authorization.status === 'active') {
135
- let subscribers = this.#subscribers.get(id);
136
- if (!subscribers) {
137
- subscribers = new Set();
138
- this.#subscribers.set(id, subscribers);
139
- }
140
- subscribers.add(connection);
141
- }
142
- connection.send(['subscribed', { topic: id, status: authorization.status }]);
143
- // catch a new subscriber up on a generation already in flight. This is what
144
- // lets append-mode frames be safe for late joiners, and it is sent
145
- // immediately rather than batched so a mid-stream mount paints at once.
146
- const generation = this.#generations.get(id);
147
- if (authorization.status === 'active' && generation) {
148
- connection.send([
149
- 'field',
150
- {
151
- updates: [
152
- {
153
- topic: id,
154
- streamID: generation.streamID,
155
- seq: generation.seq,
156
- op: 'snapshot',
157
- value: generation.value,
158
- },
159
- ],
160
- },
161
- ]);
162
- }
163
- }
164
- dropConnection(connectionID) {
165
- this.#connectionEpoch.set(connectionID, (this.#connectionEpoch.get(connectionID) ?? 0) + 1);
166
- this.#connectionQueue.delete(connectionID);
167
- for (const topicID of this.#connectionTopics.get(connectionID) ?? []) {
168
- this.#subscribers.get(topicID)?.forEach((connection) => {
169
- if (connection.id === connectionID)
170
- this.#subscribers.get(topicID).delete(connection);
171
- });
172
- if (this.#subscribers.get(topicID)?.size === 0)
173
- this.#subscribers.delete(topicID);
174
- }
175
- this.#connectionTopics.delete(connectionID);
176
- this.#connections.delete(connectionID);
177
- this.#outbox.delete(connectionID);
178
- }
179
- #removeSubscription(connectionID, topicID) {
180
- this.#connectionTopics.get(connectionID)?.delete(topicID);
181
- const subscribers = this.#subscribers.get(topicID);
182
- if (!subscribers)
183
- return;
184
- for (const connection of subscribers) {
185
- if (connection.id === connectionID)
186
- subscribers.delete(connection);
187
- }
188
- if (subscribers.size === 0)
189
- this.#subscribers.delete(topicID);
190
- }
191
- // A pull removed rows from a client group's query membership. The client is
192
- // about to learn the row left its query, so its field subscriptions for those
193
- // rows go with it, in the same update rather than on a later sweep.
194
- revokeMembership(clientGroupID, removed) {
195
- for (const topic of removed) {
196
- const resolved = resolveTopic(this.#manifest, topic);
197
- if ('reason' in resolved)
198
- continue;
199
- const subscribers = this.#subscribers.get(resolved.id);
200
- if (!subscribers)
201
- continue;
202
- for (const connection of [...subscribers]) {
203
- if (connection.identity.clientGroupID !== clientGroupID)
204
- continue;
205
- this.#removeSubscription(connection.id, resolved.id);
206
- connection.send([
207
- 'subscribe-error',
208
- { topic: resolved.id, reason: 'row left your authorized query membership' },
209
- ]);
210
- }
211
- }
212
- }
213
- // Every row a client group can currently subscribe to left its membership.
214
- // Cheaper than enumerating rows when a whole query is dropped.
215
- revokeAllForGroup(clientGroupID) {
216
- for (const [topicID, subscribers] of [...this.#subscribers]) {
217
- for (const connection of [...subscribers]) {
218
- if (connection.identity.clientGroupID !== clientGroupID)
219
- continue;
220
- this.#removeSubscription(connection.id, topicID);
221
- connection.send([
222
- 'subscribe-error',
223
- { topic: topicID, reason: 'row left your authorized query membership' },
224
- ]);
225
- }
226
- }
227
- }
228
- // ---- producers ----------------------------------------------------------
229
- // Open a generation. A newer generation always supersedes an older one for
230
- // the same topic, matching how an LLM retry replaces its predecessor. The
231
- // application still owns final-write fencing in the database; this only
232
- // decides who may deliver display values.
233
- beginGeneration(producer, topic, streamID) {
234
- const resolved = resolveTopic(this.#manifest, topic);
235
- if ('reason' in resolved)
236
- return { ok: false, reason: resolved.reason };
237
- const { spec, id } = resolved;
238
- const previous = this.#generations.get(id);
239
- if (previous && previous.streamID !== streamID) {
240
- if (previous.producer) {
241
- this.#releaseLease(previous.producer.id, id);
242
- previous.producer.send(['superseded', { topic: id, streamID: previous.streamID }]);
243
- }
244
- }
245
- this.#generations.set(id, {
246
- topicID: id,
247
- spec,
248
- streamID,
249
- seq: -1,
250
- value: spec.mode === 'append' ? '' : null,
251
- producer,
252
- });
253
- const leases = this.#producerGenerations.get(producer.id);
254
- if (leases)
255
- leases.add(id);
256
- else
257
- this.#producerGenerations.set(producer.id, new Set([id]));
258
- return { ok: true, topicID: id };
259
- }
260
- // Accept one update from a producer, accumulate it, and fan it out. The
261
- // rejection REASON is returned rather than a bare false: a producer that is
262
- // told only "refused" has to guess between supersession, a stale sequence, and
263
- // a manifest bound, and every adapter was inventing the same vague guess.
264
- publish(producer, update) {
265
- const generation = this.#generations.get(update.topic);
266
- if (!generation) {
267
- return { ok: false, reason: `no open generation for '${update.topic}'` };
268
- }
269
- // Only the producer holding this generation may publish. A subscriber
270
- // socket is never a producer, so a leaked streamID grants nothing: the check
271
- // is on the producer handle, not the frame contents. A superseded generation
272
- // needs no flag of its own, because beginGeneration REPLACED it in this map;
273
- // its old producer falls out here, and its old stream id falls out below.
274
- if (generation.producer?.id !== producer.id) {
275
- return { ok: false, reason: `another producer holds '${update.topic}'` };
276
- }
277
- if (generation.streamID !== update.streamID) {
278
- return {
279
- ok: false,
280
- reason: `stream ${update.streamID} is not the current generation for '${update.topic}'`,
281
- };
282
- }
283
- if (update.seq <= generation.seq) {
284
- return {
285
- ok: false,
286
- reason: `seq ${update.seq} is not newer than the delivered ${generation.seq}`,
287
- };
288
- }
289
- switch (update.op) {
290
- case 'snapshot': {
291
- if (!this.#validate(generation.spec, update.value)) {
292
- return {
293
- ok: false,
294
- reason: `value failed the manifest bounds for '${update.topic}'`,
295
- };
296
- }
297
- generation.value = update.value;
298
- break;
299
- }
300
- case 'append': {
301
- if (generation.spec.mode !== 'append') {
302
- return {
303
- ok: false,
304
- reason: `'${update.topic}' is replace mode and takes no appends`,
305
- };
306
- }
307
- const next = generation.value + update.text;
308
- if (byteLength(next) > generation.spec.maxBytes) {
309
- return {
310
- ok: false,
311
- reason: `append would exceed maxBytes for '${update.topic}'`,
312
- };
313
- }
314
- generation.value = next;
315
- break;
316
- }
317
- case 'end':
318
- case 'abort':
319
- break;
320
- }
321
- generation.seq = update.seq;
322
- this.#fanOut(update);
323
- if (update.op === 'end' || update.op === 'abort') {
324
- this.#generations.delete(update.topic);
325
- this.#releaseLease(producer.id, update.topic);
326
- }
327
- return { ok: true };
328
- }
329
- #releaseLease(producerID, topicID) {
330
- const leases = this.#producerGenerations.get(producerID);
331
- if (!leases)
332
- return;
333
- leases.delete(topicID);
334
- if (leases.size === 0)
335
- this.#producerGenerations.delete(producerID);
336
- }
337
- // A producer socket closed without a terminal frame (a crash, or a lost
338
- // connection). The generation's lease is released so the next `begin` is
339
- // clean; subscribers fall back to their inactivity deadline, which reveals
340
- // the durable value rather than inventing a recovery value here.
341
- dropProducer(producerID) {
342
- const leases = this.#producerGenerations.get(producerID);
343
- this.#producerGenerations.delete(producerID);
344
- if (!leases)
345
- return;
346
- for (const topicID of leases) {
347
- const generation = this.#generations.get(topicID);
348
- if (generation?.producer?.id === producerID)
349
- this.#generations.delete(topicID);
350
- }
351
- }
352
- #validate(spec, value) {
353
- if (spec.mode === 'append' && typeof value !== 'string')
354
- return false;
355
- if (spec.validate && !spec.validate(value))
356
- return false;
357
- return byteLength(canonicalEncode(value)) <= spec.maxBytes;
358
- }
359
- #fanOut(update) {
360
- const subscribers = this.#subscribers.get(update.topic);
361
- if (!subscribers || subscribers.size === 0)
362
- return;
363
- for (const connection of subscribers) {
364
- const batch = this.#outbox.get(connection.id);
365
- if (batch)
366
- batch.push(update);
367
- else
368
- this.#outbox.set(connection.id, [update]);
369
- }
370
- this.#scheduleFlush();
371
- }
372
- // The "is a flush already pending" flag is separate from the cancel handle
373
- // because a scheduler is allowed to run its callback SYNCHRONOUSLY, which the
374
- // local in-process host does (there is no socket, so there is nothing to
375
- // batch for). In that case flush() completes during the schedule call and
376
- // clears its state before the handle could be assigned, so guarding on the
377
- // handle alone left it permanently set and no later batch was ever scheduled.
378
- #scheduleFlush() {
379
- if (this.#flushScheduled)
380
- return;
381
- this.#flushScheduled = true;
382
- this.#schedule(() => this.flush(), this.#limits.batchWindowMs);
383
- }
384
- // Deliver every pending batch. Public so an adapter can force a flush before
385
- // it lets its runtime go idle.
386
- flush() {
387
- this.#flushScheduled = false;
388
- if (this.#outbox.size === 0)
389
- return;
390
- const outbox = [...this.#outbox];
391
- this.#outbox.clear();
392
- let requeued = false;
393
- for (const [connectionID, updates] of outbox) {
394
- const connection = this.#connections.get(connectionID);
395
- if (!connection)
396
- continue;
397
- // Stop a batch before it exceeds the frame ceiling; the rest goes in the
398
- // next frame rather than being dropped or sent as one oversized frame.
399
- let bytes = 0;
400
- let cut = updates.length;
401
- for (let index = 0; index < updates.length; index++) {
402
- bytes += updateBytes(updates[index]);
403
- if (bytes > this.#limits.maxBatchBytes && index > 0) {
404
- cut = index;
405
- break;
406
- }
407
- }
408
- connection.send(['field', { updates: updates.slice(0, cut) }]);
409
- if (cut < updates.length) {
410
- this.#outbox.set(connectionID, updates.slice(cut));
411
- requeued = true;
412
- }
413
- }
414
- if (requeued)
415
- this.#scheduleFlush();
416
- }
417
- // ---- introspection for adapters and tests -------------------------------
418
- get activeTopics() {
419
- return this.#generations.size;
420
- }
421
- get subscribedTopics() {
422
- return this.#subscribers.size;
423
- }
424
- generationFor(topicID) {
425
- const generation = this.#generations.get(topicID);
426
- return generation ? { streamID: generation.streamID, seq: generation.seq } : undefined;
427
- }
428
- }
429
- function describe(topic) {
430
- return `${topic.table}.${topic.field}`;
431
- }
432
- function updateBytes(update) {
433
- if (update.op === 'append')
434
- return byteLength(update.text) + 96;
435
- if (update.op === 'snapshot')
436
- return byteLength(canonicalEncode(update.value)) + 96;
437
- return 96;
438
- }
439
- function byteLength(value) {
440
- let bytes = 0;
441
- for (let index = 0; index < value.length; index++) {
442
- const code = value.charCodeAt(index);
443
- if (code < 0x80)
444
- bytes += 1;
445
- else if (code < 0x800)
446
- bytes += 2;
447
- else if (code >= 0xd800 && code < 0xdc00) {
448
- bytes += 4;
449
- index++;
450
- }
451
- else
452
- bytes += 3;
453
- }
454
- return bytes;
455
- }
456
- //# sourceMappingURL=hub.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hub.js","sourceRoot":"","sources":["../../src/realtime/hub.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,+EAA+E;AAC/E,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAuC5C,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,sBAAsB,EAAE,GAAG;IAC3B,sBAAsB,EAAE,GAAG;IAC3B,qBAAqB,EAAE,IAAI;IAC3B,aAAa,EAAE,GAAG,GAAG,IAAI;IACzB,aAAa,EAAE,EAAE;CAClB,CAAA;AA6BD,MAAM,OAAO,WAAW;IACb,SAAS,CAAmB;IAC5B,UAAU,CAAkC;IAC5C,OAAO,CAAW;IAClB,SAAS,CAAyC;IAElD,YAAY,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC5C,YAAY,GAAG,IAAI,GAAG,EAA8B,CAAA;IACpD,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAClD,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAA;IACxD,6EAA6E;IAC7E,2EAA2E;IAC3E,mE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CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;IAC/D,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;IACnF,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,IAAI,GAAG,IAAI;YAAE,KAAK,IAAI,CAAC,CAAA;aACtB,IAAI,IAAI,GAAG,KAAK;YAAE,KAAK,IAAI,CAAC,CAAA;aAC5B,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,GAAG,MAAM,EAAE,CAAC;YACzC,KAAK,IAAI,CAAC,CAAA;YACV,KAAK,EAAE,CAAA;QACT,CAAC;;YAAM,KAAK,IAAI,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,24 +0,0 @@
1
- export { defineStreamingFields, resolveTopic } from './manifest.js';
2
- export type { FieldMode, StreamingFieldDeclaration, StreamingFieldOptions, StreamingFieldHandle, StreamingFieldRef, StreamingFieldSpec, StreamingManifest, ZeroSchemaShape, } from './manifest.js';
3
- export { canonicalPrimaryKey, canonicalTopic, decodeFrame, encodeFrame, isLegacyWake, LEGACY_WAKE_FRAME, TOPIC_SEPARATOR, } from './protocol.js';
4
- export type { AnyFrame, ClientFrame, FieldUpdate, HostFrame, ProducerFrame, ProducerHostFrame, RealtimeKeyValue, RealtimeTopic, } from './protocol.js';
5
- export { canonicalEncode, RealtimeStore } from './store.js';
6
- export type { RealtimeStoreOptions, StreamingFieldState, StreamingPhase, } from './store.js';
7
- export { RealtimePublisher } from './publisher.js';
8
- export type { BeginOptions, PublisherTransport, StreamSession } from './publisher.js';
9
- export { DEFAULT_HUB_LIMITS, RealtimeHub } from './hub.js';
10
- export type { HubConnection, HubLimits, HubOptions, HubProducer, RealtimeIdentity, SubscribeAuthorization, } from './hub.js';
11
- export { FieldWriter } from './writer.js';
12
- export type { FieldWriterOptions } from './writer.js';
13
- export { createLocalRealtime } from './local.js';
14
- export type { LocalRealtime, LocalRealtimeOptions } from './local.js';
15
- export { BrowserRealtime, connectRealtimePort } from './message-port.js';
16
- export type { BrowserRealtimeOptions, MembershipReader } from './message-port.js';
17
- export { applyClientFrame, applyHostFrame, applyProducerFrame } from './host.js';
18
- export { createProducer, inProcessTransport } from './producer.js';
19
- export type { ProducerOptions, RealtimeProducer } from './producer.js';
20
- export { createSocketHost } from './socket-host.js';
21
- export type { HostConnection, HostSocket, RealtimeSocketHost } from './socket-host.js';
22
- export { createSocketProducer } from './producer-socket.js';
23
- export type { ProducerSocket, SocketProducer } from './producer-socket.js';
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACnE,YAAY,EACV,SAAS,EACT,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,eAAe,E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1
- // Streaming fields: an ephemeral, typed field overlay beside Zero.
2
- //
3
- // The ordinary Zero row stays the durable truth. During a stream orez
4
- // broadcasts field values without writing the application row or advancing the
5
- // Zero cookie, and the application commits the final value through its existing
6
- // write path. See plans/streaming-fields.md for the design and its rejected
7
- // alternatives.
8
- export { defineStreamingFields, resolveTopic } from './manifest.js';
9
- export { canonicalPrimaryKey, canonicalTopic, decodeFrame, encodeFrame, isLegacyWake, LEGACY_WAKE_FRAME, TOPIC_SEPARATOR, } from './protocol.js';
10
- export { canonicalEncode, RealtimeStore } from './store.js';
11
- export { RealtimePublisher } from './publisher.js';
12
- export { DEFAULT_HUB_LIMITS, RealtimeHub } from './hub.js';
13
- export { FieldWriter } from './writer.js';
14
- export { createLocalRealtime } from './local.js';
15
- export { BrowserRealtime, connectRealtimePort } from './message-port.js';
16
- // Frame routing. One applier per direction; every surface is built from these.
17
- export { applyClientFrame, applyHostFrame, applyProducerFrame } from './host.js';
18
- // The producer role, identical on every surface
19
- export { createProducer, inProcessTransport } from './producer.js';
20
- // The host role over sockets, for any runtime that has them
21
- export { createSocketHost } from './socket-host.js';
22
- // A producer that reaches the hub over a socket: an application server
23
- // generating values while the subscribers are browsers elsewhere
24
- export { createSocketProducer } from './producer-socket.js';
25
- // The React binding lives in on-zero, which already owns the React peer
26
- // dependency. orez-lite stays framework-free: see on-zero's useStreamingField.
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,sEAAsE;AACtE,+EAA+E;AAC/E,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAEhB,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAYnE,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAA;AAYtB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAO3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAU1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAGxE,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAEhF,gDAAgD;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAGlE,4DAA4D;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGnD,uEAAuE;AACvE,iEAAiE;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG3D,wEAAwE;AACxE,+EAA+E"}
@@ -1,15 +0,0 @@
1
- import { RealtimeStore } from './store.js';
2
- import type { StreamingManifest } from './manifest.js';
3
- import type { RealtimeProducer } from './producer.js';
4
- export type LocalRealtimeOptions = {
5
- readonly manifest: StreamingManifest;
6
- readonly staleAfterMs?: number;
7
- readonly onError?: (message: string) => void;
8
- };
9
- export type LocalRealtime = RealtimeProducer & {
10
- readonly store: RealtimeStore;
11
- readonly flush: () => void;
12
- readonly close: () => void;
13
- };
14
- export declare function createLocalRealtime(options: LocalRealtimeOptions): LocalRealtime;
15
- //# sourceMappingURL=local.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/realtime/local.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGrD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IAEpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C,CAAA;AAID,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAE7C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAG7B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAC3B,CAAA;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA0ChF"}
@@ -1,63 +0,0 @@
1
- // Single-client realtime: a hub, a publisher, and a store wired together in
2
- // one JavaScript context, with no socket, no host, and no authorization.
3
- //
4
- // This is the shape an application needs when the thing producing the values
5
- // and the thing displaying them are the same client. Soot's agent loop runs in
6
- // the browser: the tab running the agent is the tab rendering its output, so
7
- // routing those values through a server and back would add latency and an auth
8
- // surface to reach the component sitting next to the producer.
9
- //
10
- // It is the same RealtimeHub every other host runs, so a stream behaves
11
- // identically here and over a socket: same generations, same append
12
- // accumulation, same durable handoff, same manifest bounds. Moving an
13
- // application from local to a shared host changes which realtime it constructs
14
- // and nothing about its components or its producer code.
15
- //
16
- // What it deliberately does NOT do is reach other clients. Values live in this
17
- // context only. The durable Zero row remains the cross-client story, which is
18
- // exactly the guarantee the overlay already makes: a reload, another tab, or
19
- // another user sees the committed value, never the in-flight one.
20
- import { applyClientFrame, applyHostFrame } from './host.js';
21
- import { RealtimeHub } from './hub.js';
22
- import { createProducer, inProcessTransport } from './producer.js';
23
- import { RealtimeStore } from './store.js';
24
- export function createLocalRealtime(options) {
25
- // Every row is authorized: there is one client, it is the producer, and it
26
- // already holds the data it is about to display. There is nothing to
27
- // authorize against and nobody to withhold it from.
28
- const hub = new RealtimeHub({
29
- manifest: options.manifest,
30
- authorizeSubscribe: () => ({ status: 'active' }),
31
- // No batching: the window exists to collapse several updates into one
32
- // WebSocket frame, and there is no socket here. Deferring an in-process
33
- // call would only add a tick of latency between the producer and the
34
- // component next to it.
35
- scheduleFlush: (flush) => flush(),
36
- });
37
- const store = new RealtimeStore({
38
- send: (frame) => void applyClientFrame(hub, connection, frame),
39
- staleAfterMs: options.staleAfterMs,
40
- onError: options.onError,
41
- });
42
- const connection = {
43
- id: 'local',
44
- identity: { userID: 'local', clientID: 'local', clientGroupID: 'local' },
45
- // Frames are handed straight to the store, not serialized: this is one
46
- // context, and a JSON round trip per token would be pure cost. The routing
47
- // is still the shared one, so a frame means the same thing here as it does
48
- // over a socket.
49
- send: (frame) => applyHostFrame(store, frame),
50
- };
51
- const producerHandle = { id: 'local-producer', send: () => { } };
52
- const producer = createProducer(inProcessTransport(hub, producerHandle), options);
53
- return {
54
- store,
55
- ...producer,
56
- flush: () => hub.flush(),
57
- close: () => {
58
- hub.dropProducer(producerHandle.id);
59
- hub.dropConnection(connection.id);
60
- },
61
- };
62
- }
63
- //# sourceMappingURL=local.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/realtime/local.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yEAAyE;AACzE,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,sEAAsE;AACtE,+EAA+E;AAC/E,yDAAyD;AACzD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,kEAAkE;AAElE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CA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