@graphrefly/graphrefly 0.12.0 → 0.14.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 (69) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-NULSP7U4.js → chunk-2ZICUAUJ.js} +4 -4
  3. package/dist/{chunk-BRPCN2HJ.js → chunk-4APC3AFN.js} +3 -3
  4. package/dist/{chunk-VQWLA6XQ.js → chunk-CRACCCJY.js} +3 -3
  5. package/dist/{chunk-JYRHO63K.js → chunk-GKRKDYNT.js} +17 -17
  6. package/dist/chunk-GKRKDYNT.js.map +1 -0
  7. package/dist/{chunk-4F2ZFD5L.js → chunk-H243FWYP.js} +50 -51
  8. package/dist/chunk-H243FWYP.js.map +1 -0
  9. package/dist/{chunk-X732W3QA.js → chunk-QVYZD65U.js} +2 -2
  10. package/dist/{chunk-6OLNYOGU.js → chunk-XQ4UMAU7.js} +2 -2
  11. package/dist/{chunk-XWMTVV2D.js → chunk-YW6LFCFS.js} +5 -5
  12. package/dist/{chunk-IXTW3BIO.js → chunk-ZHTHUX5D.js} +3 -3
  13. package/dist/compat/nestjs/index.cjs +48 -49
  14. package/dist/compat/nestjs/index.cjs.map +1 -1
  15. package/dist/compat/nestjs/index.d.cts +4 -4
  16. package/dist/compat/nestjs/index.d.ts +4 -4
  17. package/dist/compat/nestjs/index.js +7 -7
  18. package/dist/core/index.cjs +50 -51
  19. package/dist/core/index.cjs.map +1 -1
  20. package/dist/core/index.d.cts +2 -2
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/index.js +5 -5
  23. package/dist/extra/index.cjs +48 -49
  24. package/dist/extra/index.cjs.map +1 -1
  25. package/dist/extra/index.d.cts +4 -4
  26. package/dist/extra/index.d.ts +4 -4
  27. package/dist/extra/index.js +3 -3
  28. package/dist/graph/index.cjs +40 -37
  29. package/dist/graph/index.cjs.map +1 -1
  30. package/dist/graph/index.d.cts +3 -3
  31. package/dist/graph/index.d.ts +3 -3
  32. package/dist/graph/index.js +4 -4
  33. package/dist/{graph-DXT95WZ3.d.ts → graph-BXIK5Dq5.d.ts} +1 -1
  34. package/dist/{graph-BE10ujU9.d.cts → graph-BhADtuFU.d.cts} +1 -1
  35. package/dist/{index-QfbXNW1N.d.cts → index-BNB0KjKe.d.ts} +24 -21
  36. package/dist/{index-C0_7g9sj.d.ts → index-BkToATim.d.ts} +1 -1
  37. package/dist/{index-CiAqgfFg.d.ts → index-CKyYg4IP.d.ts} +3 -3
  38. package/dist/{index-CCvzN5GB.d.cts → index-DANO9Gg7.d.cts} +2 -2
  39. package/dist/{index-CthwPnHQ.d.cts → index-DBhLjWSV.d.cts} +3 -3
  40. package/dist/{index-Dzdm20sx.d.ts → index-DKIyo4Bq.d.cts} +24 -21
  41. package/dist/{index-53cDGX7F.d.ts → index-DSp5R3Xq.d.ts} +3 -3
  42. package/dist/{index-aBZ2RoP0.d.cts → index-Dqemj9q0.d.cts} +3 -3
  43. package/dist/{index-nRulwTr-.d.cts → index-Wa8jXne6.d.cts} +1 -1
  44. package/dist/{index-B10Q0sQB.d.ts → index-fYObbpUw.d.ts} +2 -2
  45. package/dist/index.cjs +443 -68
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +369 -66
  48. package/dist/index.d.ts +369 -66
  49. package/dist/index.js +397 -22
  50. package/dist/index.js.map +1 -1
  51. package/dist/{meta-BcuDhtwu.d.cts → meta-CrZUQAJ6.d.cts} +1 -1
  52. package/dist/{meta-BcuDhtwu.d.ts → meta-CrZUQAJ6.d.ts} +1 -1
  53. package/dist/patterns/reactive-layout/index.cjs +53 -50
  54. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  55. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  56. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  57. package/dist/patterns/reactive-layout/index.js +4 -4
  58. package/dist/{reactive-log-OULQssZg.d.cts → reactive-log-ChbpUrY2.d.cts} +2 -2
  59. package/dist/{reactive-log-Cu0VdqkT.d.ts → reactive-log-DV--7BWd.d.ts} +2 -2
  60. package/package.json +3 -1
  61. package/dist/chunk-4F2ZFD5L.js.map +0 -1
  62. package/dist/chunk-JYRHO63K.js.map +0 -1
  63. /package/dist/{chunk-NULSP7U4.js.map → chunk-2ZICUAUJ.js.map} +0 -0
  64. /package/dist/{chunk-BRPCN2HJ.js.map → chunk-4APC3AFN.js.map} +0 -0
  65. /package/dist/{chunk-VQWLA6XQ.js.map → chunk-CRACCCJY.js.map} +0 -0
  66. /package/dist/{chunk-X732W3QA.js.map → chunk-QVYZD65U.js.map} +0 -0
  67. /package/dist/{chunk-6OLNYOGU.js.map → chunk-XQ4UMAU7.js.map} +0 -0
  68. /package/dist/{chunk-XWMTVV2D.js.map → chunk-YW6LFCFS.js.map} +0 -0
  69. /package/dist/{chunk-IXTW3BIO.js.map → chunk-ZHTHUX5D.js.map} +0 -0
@@ -148,7 +148,7 @@ declare function accessHintForGuard(guard: NodeGuard): string;
148
148
  * | 3 | COMPLETE, ERROR | Terminal lifecycle | Deferred to after phase-2 |
149
149
  * | 4 | TEARDOWN | Destruction | Immediate (usually sent alone) |
150
150
  *
151
- * **Rule:** Within `emitWithBatch`, messages are partitioned by tier and delivered
151
+ * **Rule:** Within `downWithBatch`, messages are partitioned by tier and delivered
152
152
  * in tier order. This ensures phase-2 values (DATA/RESOLVED) reach sinks before
153
153
  * terminal signals (COMPLETE/ERROR) mark the node as done, preventing the
154
154
  * "COMPLETE-before-DATA" class of bugs. Sources that emit in canonical order
@@ -148,7 +148,7 @@ declare function accessHintForGuard(guard: NodeGuard): string;
148
148
  * | 3 | COMPLETE, ERROR | Terminal lifecycle | Deferred to after phase-2 |
149
149
  * | 4 | TEARDOWN | Destruction | Immediate (usually sent alone) |
150
150
  *
151
- * **Rule:** Within `emitWithBatch`, messages are partitioned by tier and delivered
151
+ * **Rule:** Within `downWithBatch`, messages are partitioned by tier and delivered
152
152
  * in tier order. This ensures phase-2 values (DATA/RESOLVED) reach sinks before
153
153
  * terminal signals (COMPLETE/ERROR) mark the node as done, preventing the
154
154
  * "COMPLETE-before-DATA" class of bugs. Sources that emit in canonical order
@@ -368,12 +368,12 @@ function partitionForBatch(messages) {
368
368
  }
369
369
  return { immediate, deferred, terminal };
370
370
  }
371
- function emitWithBatch(emit, messages, phase = 2, options) {
371
+ function downWithBatch(sink, messages, phase = 2, options) {
372
372
  if (messages.length === 0) {
373
373
  return;
374
374
  }
375
375
  if (options?.strategy === "sequential") {
376
- _emitSequential(emit, messages, phase);
376
+ _downSequential(sink, messages, phase);
377
377
  return;
378
378
  }
379
379
  const queue = phase === 3 ? pendingPhase3 : pendingPhase2;
@@ -381,61 +381,61 @@ function emitWithBatch(emit, messages, phase = 2, options) {
381
381
  const t = messages[0][0];
382
382
  if (t === DATA || t === RESOLVED) {
383
383
  if (isBatching()) {
384
- queue.push(() => emit(messages));
384
+ queue.push(() => sink(messages));
385
385
  } else {
386
- emit(messages);
386
+ sink(messages);
387
387
  }
388
388
  } else if (isTerminalMessage(t)) {
389
389
  if (isBatching()) {
390
- queue.push(() => emit(messages));
390
+ queue.push(() => sink(messages));
391
391
  } else {
392
- emit(messages);
392
+ sink(messages);
393
393
  }
394
394
  } else {
395
- emit(messages);
395
+ sink(messages);
396
396
  }
397
397
  return;
398
398
  }
399
399
  const { immediate, deferred, terminal } = partitionForBatch(messages);
400
400
  if (immediate.length > 0) {
401
- emit(immediate);
401
+ sink(immediate);
402
402
  }
403
403
  if (isBatching()) {
404
404
  if (deferred.length > 0) {
405
- queue.push(() => emit(deferred));
405
+ queue.push(() => sink(deferred));
406
406
  }
407
407
  if (terminal.length > 0) {
408
- queue.push(() => emit(terminal));
408
+ queue.push(() => sink(terminal));
409
409
  }
410
410
  } else {
411
411
  if (deferred.length > 0) {
412
- emit(deferred);
412
+ sink(deferred);
413
413
  }
414
414
  if (terminal.length > 0) {
415
- emit(terminal);
415
+ sink(terminal);
416
416
  }
417
417
  }
418
418
  }
419
- function _emitSequential(emit, messages, phase = 2) {
419
+ function _downSequential(sink, messages, phase = 2) {
420
420
  const dataQueue = phase === 3 ? pendingPhase3 : pendingPhase2;
421
421
  for (const msg of messages) {
422
422
  const tier = messageTier(msg[0]);
423
423
  if (tier === 2) {
424
424
  if (isBatching()) {
425
425
  const m = msg;
426
- dataQueue.push(() => emit([m]));
426
+ dataQueue.push(() => sink([m]));
427
427
  } else {
428
- emit([msg]);
428
+ sink([msg]);
429
429
  }
430
430
  } else if (tier >= 3) {
431
431
  if (isBatching()) {
432
432
  const m = msg;
433
- pendingPhase3.push(() => emit([m]));
433
+ pendingPhase3.push(() => sink([m]));
434
434
  } else {
435
- emit([msg]);
435
+ sink([msg]);
436
436
  }
437
437
  } else {
438
- emit([msg]);
438
+ sink([msg]);
439
439
  }
440
440
  }
441
441
  }
@@ -663,7 +663,7 @@ var NodeImpl = class {
663
663
  _singleDepSinks = /* @__PURE__ */ new WeakSet();
664
664
  _upstreamUnsubs = [];
665
665
  _actions;
666
- _boundEmitToSinks;
666
+ _boundDownToSinks;
667
667
  _inspectorHook;
668
668
  _versioning;
669
669
  _hashFn;
@@ -710,7 +710,7 @@ var NodeImpl = class {
710
710
  },
711
711
  emit(value) {
712
712
  self._manualEmitUsed = true;
713
- self._emitAutoValue(value);
713
+ self._downAutoValue(value);
714
714
  },
715
715
  up(messages) {
716
716
  self._upInternal(messages);
@@ -718,7 +718,7 @@ var NodeImpl = class {
718
718
  };
719
719
  this.down = this.down.bind(this);
720
720
  this.up = this.up.bind(this);
721
- this._boundEmitToSinks = this._emitToSinks.bind(this);
721
+ this._boundDownToSinks = this._downToSinks.bind(this);
722
722
  }
723
723
  get name() {
724
724
  return this._registryName ?? this._optsName;
@@ -824,12 +824,12 @@ var NodeImpl = class {
824
824
  if (sinkMessages[i][0] !== DIRTY) filtered.push(sinkMessages[i]);
825
825
  }
826
826
  if (filtered.length > 0) {
827
- emitWithBatch(this._boundEmitToSinks, filtered);
827
+ downWithBatch(this._boundDownToSinks, filtered);
828
828
  }
829
829
  return;
830
830
  }
831
831
  }
832
- emitWithBatch(this._boundEmitToSinks, sinkMessages);
832
+ downWithBatch(this._boundDownToSinks, sinkMessages);
833
833
  }
834
834
  subscribe(sink, hints) {
835
835
  if (hints?.actor != null && this._guard != null) {
@@ -916,7 +916,7 @@ var NodeImpl = class {
916
916
  this._disconnectUpstream();
917
917
  }
918
918
  // --- Private methods (prototype, _ prefix) ---
919
- _emitToSinks(messages) {
919
+ _downToSinks(messages) {
920
920
  if (this._sinks == null) return;
921
921
  if (typeof this._sinks === "function") {
922
922
  this._sinks(messages);
@@ -931,6 +931,9 @@ var NodeImpl = class {
931
931
  for (const m of messages) {
932
932
  const t = m[0];
933
933
  if (t === DATA) {
934
+ if (m.length < 2) {
935
+ continue;
936
+ }
934
937
  this._cached = m[1];
935
938
  if (this._versioning != null) {
936
939
  advanceVersion(this._versioning, m[1], this._hashFn);
@@ -978,7 +981,7 @@ var NodeImpl = class {
978
981
  _canSkipDirty() {
979
982
  return this._sinkCount === 1 && this._singleDepSinkCount === 1;
980
983
  }
981
- _emitAutoValue(value) {
984
+ _downAutoValue(value) {
982
985
  const wasDirty = this._status === "dirty";
983
986
  let unchanged;
984
987
  try {
@@ -1031,7 +1034,7 @@ var NodeImpl = class {
1031
1034
  this._cleanup = out.cleanup;
1032
1035
  if (this._manualEmitUsed) return;
1033
1036
  if ("value" in out) {
1034
- this._emitAutoValue(out.value);
1037
+ this._downAutoValue(out.value);
1035
1038
  }
1036
1039
  return;
1037
1040
  }
@@ -1041,7 +1044,7 @@ var NodeImpl = class {
1041
1044
  }
1042
1045
  if (this._manualEmitUsed) return;
1043
1046
  if (out === void 0) return;
1044
- this._emitAutoValue(out);
1047
+ this._downAutoValue(out);
1045
1048
  } catch (err) {
1046
1049
  const errMsg = err instanceof Error ? err.message : String(err);
1047
1050
  const wrapped = new Error(`Node "${this.name}": fn threw: ${errMsg}`, { cause: err });
@@ -1223,7 +1226,7 @@ var DynamicNodeImpl = class {
1223
1226
  _singleDepSinks = /* @__PURE__ */ new WeakSet();
1224
1227
  // Actions object (for onMessage handler)
1225
1228
  _actions;
1226
- _boundEmitToSinks;
1229
+ _boundDownToSinks;
1227
1230
  // Mutable state
1228
1231
  _cached = NO_VALUE;
1229
1232
  _status = "disconnected";
@@ -1270,7 +1273,7 @@ var DynamicNodeImpl = class {
1270
1273
  self._downInternal(messages);
1271
1274
  },
1272
1275
  emit(value) {
1273
- self._emitAutoValue(value);
1276
+ self._downAutoValue(value);
1274
1277
  },
1275
1278
  up(messages) {
1276
1279
  for (const dep of self._deps) {
@@ -1278,7 +1281,7 @@ var DynamicNodeImpl = class {
1278
1281
  }
1279
1282
  }
1280
1283
  };
1281
- this._boundEmitToSinks = this._emitToSinks.bind(this);
1284
+ this._boundDownToSinks = this._downToSinks.bind(this);
1282
1285
  }
1283
1286
  get name() {
1284
1287
  return this._registryName ?? this._optsName;
@@ -1358,12 +1361,12 @@ var DynamicNodeImpl = class {
1358
1361
  if (sinkMessages[i][0] !== DIRTY) filtered.push(sinkMessages[i]);
1359
1362
  }
1360
1363
  if (filtered.length > 0) {
1361
- emitWithBatch(this._boundEmitToSinks, filtered);
1364
+ downWithBatch(this._boundDownToSinks, filtered);
1362
1365
  }
1363
1366
  return;
1364
1367
  }
1365
1368
  }
1366
- emitWithBatch(this._boundEmitToSinks, sinkMessages);
1369
+ downWithBatch(this._boundDownToSinks, sinkMessages);
1367
1370
  }
1368
1371
  _canSkipDirty() {
1369
1372
  return this._sinkCount === 1 && this._singleDepSinkCount === 1;
@@ -1439,7 +1442,7 @@ var DynamicNodeImpl = class {
1439
1442
  this._disconnect();
1440
1443
  }
1441
1444
  // --- Private methods ---
1442
- _emitToSinks(messages) {
1445
+ _downToSinks(messages) {
1443
1446
  if (this._sinks == null) return;
1444
1447
  if (typeof this._sinks === "function") {
1445
1448
  this._sinks(messages);
@@ -1493,7 +1496,7 @@ var DynamicNodeImpl = class {
1493
1496
  }
1494
1497
  }
1495
1498
  }
1496
- _emitAutoValue(value) {
1499
+ _downAutoValue(value) {
1497
1500
  const wasDirty = this._status === "dirty";
1498
1501
  let unchanged;
1499
1502
  try {
@@ -1553,7 +1556,7 @@ var DynamicNodeImpl = class {
1553
1556
  const result = this._fn(get);
1554
1557
  this._rewire(trackedDeps);
1555
1558
  if (result === void 0) return;
1556
- this._emitAutoValue(result);
1559
+ this._downAutoValue(result);
1557
1560
  } catch (err) {
1558
1561
  this._downInternal([[ERROR, err]]);
1559
1562
  }
@@ -1617,14 +1620,14 @@ var DynamicNodeImpl = class {
1617
1620
  this._dirtyBits.add(index);
1618
1621
  this._settledBits.delete(index);
1619
1622
  if (this._dirtyBits.size === 1) {
1620
- emitWithBatch(this._boundEmitToSinks, [[DIRTY]]);
1623
+ downWithBatch(this._boundDownToSinks, [[DIRTY]]);
1621
1624
  }
1622
1625
  continue;
1623
1626
  }
1624
1627
  if (t === DATA || t === RESOLVED) {
1625
1628
  if (!this._dirtyBits.has(index)) {
1626
1629
  this._dirtyBits.add(index);
1627
- emitWithBatch(this._boundEmitToSinks, [[DIRTY]]);
1630
+ downWithBatch(this._boundDownToSinks, [[DIRTY]]);
1628
1631
  }
1629
1632
  this._settledBits.add(index);
1630
1633
  if (this._allDirtySettled()) {
@@ -3803,7 +3806,7 @@ function computeLineBreaks(segments, maxWidth, adapter, font, cache) {
3803
3806
  hyphenWidth = adapter.measureSegment("-", font).width;
3804
3807
  fontCache.set("-", hyphenWidth);
3805
3808
  }
3806
- function emitLine(endSeg = lineEndSeg, endGrapheme = lineEndGrapheme, width = lineW) {
3809
+ function flushLine(endSeg = lineEndSeg, endGrapheme = lineEndGrapheme, width = lineW) {
3807
3810
  let text = "";
3808
3811
  for (let i = lineStartSeg; i < endSeg; i++) {
3809
3812
  const seg = segments[i];
@@ -3866,7 +3869,7 @@ function computeLineBreaks(segments, maxWidth, adapter, font, cache) {
3866
3869
  const seg = segments[i];
3867
3870
  if (seg.kind === "hard-break") {
3868
3871
  if (hasContent) {
3869
- emitLine();
3872
+ flushLine();
3870
3873
  } else {
3871
3874
  lines.push({
3872
3875
  text: "",
@@ -3900,20 +3903,20 @@ function computeLineBreaks(segments, maxWidth, adapter, font, cache) {
3900
3903
  lineW += w;
3901
3904
  lineEndSeg = i + 1;
3902
3905
  lineEndGrapheme = 0;
3903
- emitLine(i + 1, 0, seg.kind === "space" ? lineW - w : lineW);
3906
+ flushLine(i + 1, 0, seg.kind === "space" ? lineW - w : lineW);
3904
3907
  continue;
3905
3908
  }
3906
3909
  if (pendingBreakSeg >= 0) {
3907
- emitLine(pendingBreakSeg, 0, pendingBreakWidth);
3910
+ flushLine(pendingBreakSeg, 0, pendingBreakWidth);
3908
3911
  i--;
3909
3912
  continue;
3910
3913
  }
3911
3914
  if (w > maxWidth && seg.graphemeWidths) {
3912
- emitLine();
3915
+ flushLine();
3913
3916
  appendBreakableSegment(i, 0, seg.graphemeWidths);
3914
3917
  continue;
3915
3918
  }
3916
- emitLine();
3919
+ flushLine();
3917
3920
  i--;
3918
3921
  continue;
3919
3922
  }
@@ -3926,7 +3929,7 @@ function computeLineBreaks(segments, maxWidth, adapter, font, cache) {
3926
3929
  }
3927
3930
  }
3928
3931
  if (hasContent) {
3929
- emitLine();
3932
+ flushLine();
3930
3933
  }
3931
3934
  return { lines, lineCount: lines.length };
3932
3935
  function appendBreakableSegment(segIdx, startG, gWidths) {
@@ -3937,7 +3940,7 @@ function computeLineBreaks(segments, maxWidth, adapter, font, cache) {
3937
3940
  continue;
3938
3941
  }
3939
3942
  if (lineW + gw > maxWidth + 5e-3) {
3940
- emitLine();
3943
+ flushLine();
3941
3944
  startLineAtGrapheme(segIdx, g, gw);
3942
3945
  } else {
3943
3946
  lineW += gw;
@@ -4028,9 +4031,9 @@ function reactiveLayout(opts) {
4028
4031
  const hr = hitRate;
4029
4032
  const len = result.length;
4030
4033
  const el = elapsed;
4031
- emitWithBatch((msgs) => meta["cache-hit-rate"]?.down(msgs), [[DATA, hr]], 3);
4032
- emitWithBatch((msgs) => meta["segment-count"]?.down(msgs), [[DATA, len]], 3);
4033
- emitWithBatch((msgs) => meta["layout-time-ns"]?.down(msgs), [[DATA, el]], 3);
4034
+ downWithBatch((msgs) => meta["cache-hit-rate"]?.down(msgs), [[DATA, hr]], 3);
4035
+ downWithBatch((msgs) => meta["segment-count"]?.down(msgs), [[DATA, len]], 3);
4036
+ downWithBatch((msgs) => meta["layout-time-ns"]?.down(msgs), [[DATA, el]], 3);
4034
4037
  }
4035
4038
  return result;
4036
4039
  },
@@ -4260,8 +4263,8 @@ function reactiveBlockLayout(opts) {
4260
4263
  const elapsed = monotonicNs() - t0;
4261
4264
  const meta = measuredBlocksNode.meta;
4262
4265
  if (meta) {
4263
- emitWithBatch((msgs) => meta["block-count"]?.down(msgs), [[DATA, result.length]], 3);
4264
- emitWithBatch((msgs) => meta["layout-time-ns"]?.down(msgs), [[DATA, elapsed]], 3);
4266
+ downWithBatch((msgs) => meta["block-count"]?.down(msgs), [[DATA, result.length]], 3);
4267
+ downWithBatch((msgs) => meta["layout-time-ns"]?.down(msgs), [[DATA, elapsed]], 3);
4265
4268
  }
4266
4269
  return result;
4267
4270
  },