@feltdb/core 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -23,7 +23,7 @@ import * as path from 'path';
23
23
  import * as readline from 'readline';
24
24
  import { getClient } from './api-client.js';
25
25
  import { loadFeltDBConfig, createDefaultConfig, validateModel, } from './config.js';
26
- const VERSION = '0.6.5';
26
+ const VERSION = '0.6.6';
27
27
  function prompt(question) {
28
28
  const rl = readline.createInterface({
29
29
  input: process.stdin,
@@ -1,4 +1,4 @@
1
1
  // One release train keeps generated applications installable. The repository
2
2
  // validation script checks these values against every workspace manifest.
3
- export const FELTDB_PACKAGE_VERSION = '0.6.5';
3
+ export const FELTDB_PACKAGE_VERSION = '0.6.6';
4
4
  export const feltdbPackageRange = `^${FELTDB_PACKAGE_VERSION}`;
@@ -407,13 +407,38 @@ class HttpWorkspaceTransport {
407
407
  }
408
408
  subscribe(workspaceId, handler) {
409
409
  let stopped = false;
410
+ let delivering = false;
411
+ let deliveryPending = false;
410
412
  const subscribedAt = Date.now();
413
+ const deliver = async () => {
414
+ if (stopped)
415
+ return;
416
+ if (delivering) {
417
+ deliveryPending = true;
418
+ return;
419
+ }
420
+ delivering = true;
421
+ try {
422
+ await this.deliverEvents(workspaceId, subscribedAt, handler);
423
+ }
424
+ finally {
425
+ delivering = false;
426
+ if (deliveryPending) {
427
+ deliveryPending = false;
428
+ void deliver();
429
+ }
430
+ }
431
+ };
411
432
  const unsubscribe = this.db.subscribe_changes(collection => {
412
433
  if (collection !== EVENT_COLLECTION || stopped)
413
434
  return;
414
- void this.deliverEvents(workspaceId, subscribedAt, handler);
435
+ void deliver();
415
436
  });
416
- return () => { stopped = true; unsubscribe(); };
437
+ // The event log is authoritative. Reconcile immediately and periodically so
438
+ // an event cannot be stranded in the small window before SSE is established.
439
+ void deliver();
440
+ const reconciliation = setInterval(() => void deliver(), 250);
441
+ return () => { stopped = true; clearInterval(reconciliation); unsubscribe(); };
417
442
  }
418
443
  async appendEvent(input, type, value) {
419
444
  const event = { id: generateEventId(), ...input, type, value, timestamp: Date.now() };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feltdb/core",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "FeltDB Core - Application-facing database with Browser, Local, and Server runtimes. Durable state, reactive APIs.",
5
5
  "license": "MIT",
6
6
  "type": "module",