@graphrefly/graphrefly 0.9.0 → 0.11.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/dist/{chunk-WYI7YW54.js → chunk-2OTXEZQO.js} +3 -3
  2. package/dist/{chunk-TZLX4KIT.js → chunk-2VHNCFGG.js} +3 -3
  3. package/dist/{chunk-XCZPGOVP.js → chunk-3WACHRHV.js} +3 -3
  4. package/dist/{chunk-YWTP2XRJ.js → chunk-5WXTWOD7.js} +2 -2
  5. package/dist/{chunk-E7OH6ZAZ.js → chunk-FMVFRP7L.js} +62 -3
  6. package/dist/chunk-FMVFRP7L.js.map +1 -0
  7. package/dist/{chunk-LR2CLSEF.js → chunk-OHUECHWY.js} +2 -3
  8. package/dist/chunk-OHUECHWY.js.map +1 -0
  9. package/dist/{chunk-UCW3VWMN.js → chunk-PZCDQD2U.js} +4 -4
  10. package/dist/{chunk-A2AJJOSJ.js → chunk-U5HFZGAQ.js} +3 -3
  11. package/dist/{chunk-QTZSBQGJ.js → chunk-UG2QZMRN.js} +18 -1
  12. package/dist/chunk-UG2QZMRN.js.map +1 -0
  13. package/dist/compat/nestjs/index.cjs +10 -1
  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 +74 -1
  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 +12 -3
  23. package/dist/extra/index.cjs +10 -0
  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 +10 -1
  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-DqTICAY2.d.cts → graph-BE10ujU9.d.cts} +1 -1
  34. package/dist/{graph-X9uwnD_z.d.ts → graph-DXT95WZ3.d.ts} +1 -1
  35. package/dist/{index-DLO8wnYU.d.ts → index-53cDGX7F.d.ts} +3 -3
  36. package/dist/{index-DMv1Etbi.d.ts → index-B10Q0sQB.d.ts} +2 -2
  37. package/dist/{index-a5gHmH5b.d.ts → index-Bbgvinsi.d.ts} +3 -3
  38. package/dist/{index-BPCeYDS4.d.ts → index-C0_7g9sj.d.ts} +1 -1
  39. package/dist/{index-3U0WxdD-.d.cts → index-CCvzN5GB.d.cts} +2 -2
  40. package/dist/{index-BP1t_38S.d.cts → index-DpZozxaJ.d.cts} +3 -3
  41. package/dist/{index-BVG5pjin.d.ts → index-Dzdm20sx.d.ts} +88 -3
  42. package/dist/{index-BYEgosAX.d.cts → index-QfbXNW1N.d.cts} +88 -3
  43. package/dist/{index-BYa2YMat.d.cts → index-aBZ2RoP0.d.cts} +3 -3
  44. package/dist/{index-DbwgQ4Cw.d.cts → index-nRulwTr-.d.cts} +1 -1
  45. package/dist/index.cjs +2009 -406
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +559 -14
  48. package/dist/index.d.ts +559 -14
  49. package/dist/index.js +1938 -406
  50. package/dist/index.js.map +1 -1
  51. package/dist/{meta-BJEU8fYz.d.cts → meta-BcuDhtwu.d.cts} +33 -1
  52. package/dist/{meta-BJEU8fYz.d.ts → meta-BcuDhtwu.d.ts} +33 -1
  53. package/dist/patterns/reactive-layout/index.cjs +10 -1
  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-RhgIog2Z.d.ts → reactive-log-Cu0VdqkT.d.ts} +2 -2
  59. package/dist/{reactive-log-BfX6bOSZ.d.cts → reactive-log-OULQssZg.d.cts} +2 -2
  60. package/package.json +7 -2
  61. package/dist/chunk-E7OH6ZAZ.js.map +0 -1
  62. package/dist/chunk-LR2CLSEF.js.map +0 -1
  63. package/dist/chunk-QTZSBQGJ.js.map +0 -1
  64. /package/dist/{chunk-WYI7YW54.js.map → chunk-2OTXEZQO.js.map} +0 -0
  65. /package/dist/{chunk-TZLX4KIT.js.map → chunk-2VHNCFGG.js.map} +0 -0
  66. /package/dist/{chunk-XCZPGOVP.js.map → chunk-3WACHRHV.js.map} +0 -0
  67. /package/dist/{chunk-YWTP2XRJ.js.map → chunk-5WXTWOD7.js.map} +0 -0
  68. /package/dist/{chunk-UCW3VWMN.js.map → chunk-PZCDQD2U.js.map} +0 -0
  69. /package/dist/{chunk-A2AJJOSJ.js.map → chunk-U5HFZGAQ.js.map} +0 -0
@@ -345,6 +345,12 @@ declare function advanceVersion(info: NodeVersionInfo, newValue: unknown, hashFn
345
345
  /** Type guard: is this V1 versioning info? */
346
346
  declare function isV1(info: NodeVersionInfo): info is V1;
347
347
 
348
+ /**
349
+ * Branded symbol that marks a {@link CleanupResult} wrapper.
350
+ * Used internally by {@link cleanupResult} — prevents duck-type collisions
351
+ * with domain objects that happen to have a `cleanup` property.
352
+ */
353
+ declare const CLEANUP_RESULT: unique symbol;
348
354
  /** Lifecycle status of a node. */
349
355
  type NodeStatus = "disconnected" | "dirty" | "settled" | "resolved" | "completed" | "errored";
350
356
  /** Callback that receives downstream message batches. */
@@ -513,6 +519,32 @@ interface Node<T = unknown> {
513
519
  /** Versioning info (GRAPHREFLY-SPEC §7). `undefined` when versioning is not enabled. */
514
520
  readonly v: Readonly<NodeVersionInfo> | undefined;
515
521
  }
522
+ /**
523
+ * Explicit cleanup wrapper. When a node fn returns `{ cleanup, value? }`,
524
+ * `cleanup` is registered as the teardown/recompute cleanup and `value`
525
+ * (if present) is emitted as data. This avoids the ambiguity where returning
526
+ * a plain function is silently consumed as cleanup instead of emitted as data.
527
+ *
528
+ * Use the {@link cleanupResult} factory to create instances — it stamps the
529
+ * branded {@link CLEANUP_RESULT} symbol so that domain objects with a `cleanup`
530
+ * property are never misinterpreted.
531
+ *
532
+ * Plain function returns are still treated as cleanup for backward compatibility.
533
+ */
534
+ type CleanupResult<T = unknown> = {
535
+ readonly [CLEANUP_RESULT]: true;
536
+ cleanup: () => void;
537
+ value?: T;
538
+ };
539
+ /**
540
+ * Create a branded {@link CleanupResult}.
541
+ *
542
+ * ```ts
543
+ * node([dep], () => cleanupResult(() => release(), computedValue))
544
+ * ```
545
+ */
546
+ declare function cleanupResult<T>(cleanup: () => void): CleanupResult<T>;
547
+ declare function cleanupResult<T>(cleanup: () => void, value: T): CleanupResult<T>;
516
548
  /**
517
549
  * Creates a reactive {@link Node} — the single GraphReFly primitive (GRAPHREFLY-SPEC §2).
518
550
  *
@@ -631,4 +663,4 @@ declare function metaSnapshot(node: Node): Record<string, unknown>;
631
663
  */
632
664
  declare function describeNode(node: Node, includeFields?: Set<string> | null): DescribeNodeOutput;
633
665
 
634
- export { policy as $, type Actor as A, createVersioning as B, COMPLETE as C, DATA as D, ERROR as E, defaultHash as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, describeNode as J, isKnownMessageType as K, isPhase2Message as L, type Message as M, type Node as N, type OnMessageHandler as O, PAUSE as P, isTerminalMessage as Q, RESOLVED as R, type SubscribeHints as S, TEARDOWN as T, isV1 as U, type V0 as V, knownMessageTypes as W, messageTier as X, metaSnapshot as Y, node as Z, normalizeActor as _, type NodeOptions as a, policyFromRules as a0, propagatesToMeta as a1, resolveDescribeFields as a2, type NodeInspectorHook as a3, type NodeActions as b, type NodeFn as c, DEFAULT_ACTOR as d, DIRTY as e, type DescribeDetail as f, type DescribeField as g, type DescribeNodeOutput as h, GuardDenied as i, type GuardDeniedDetails as j, type Messages as k, type NodeDescribeKind as l, type NodeGuard as m, type NodeSink as n, type NodeStatus as o, type NodeTransportOptions as p, type NodeVersionInfo as q, type PolicyAllow as r, type PolicyDeny as s, type PolicyRuleData as t, RESUME as u, type V1 as v, type VersioningLevel as w, type VersioningOptions as x, accessHintForGuard as y, advanceVersion as z };
666
+ export { metaSnapshot as $, type Actor as A, accessHintForGuard as B, CLEANUP_RESULT as C, DATA as D, ERROR as E, advanceVersion as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, cleanupResult as J, createVersioning as K, defaultHash as L, type Message as M, type Node as N, type OnMessageHandler as O, PAUSE as P, describeNode as Q, RESOLVED as R, type SubscribeHints as S, TEARDOWN as T, isKnownMessageType as U, type V0 as V, isPhase2Message as W, isTerminalMessage as X, isV1 as Y, knownMessageTypes as Z, messageTier as _, type NodeOptions as a, node as a0, normalizeActor as a1, policy as a2, policyFromRules as a3, propagatesToMeta as a4, resolveDescribeFields as a5, type NodeInspectorHook as a6, type NodeActions as b, type NodeFn as c, COMPLETE as d, type CleanupResult as e, DEFAULT_ACTOR as f, DIRTY as g, type DescribeDetail as h, type DescribeField as i, type DescribeNodeOutput as j, GuardDenied as k, type GuardDeniedDetails as l, type Messages as m, type NodeDescribeKind as n, type NodeGuard as o, type NodeSink as p, type NodeStatus as q, type NodeTransportOptions as r, type NodeVersionInfo as s, type PolicyAllow as t, type PolicyDeny as u, type PolicyRuleData as v, RESUME as w, type V1 as x, type VersioningLevel as y, type VersioningOptions as z };
@@ -345,6 +345,12 @@ declare function advanceVersion(info: NodeVersionInfo, newValue: unknown, hashFn
345
345
  /** Type guard: is this V1 versioning info? */
346
346
  declare function isV1(info: NodeVersionInfo): info is V1;
347
347
 
348
+ /**
349
+ * Branded symbol that marks a {@link CleanupResult} wrapper.
350
+ * Used internally by {@link cleanupResult} — prevents duck-type collisions
351
+ * with domain objects that happen to have a `cleanup` property.
352
+ */
353
+ declare const CLEANUP_RESULT: unique symbol;
348
354
  /** Lifecycle status of a node. */
349
355
  type NodeStatus = "disconnected" | "dirty" | "settled" | "resolved" | "completed" | "errored";
350
356
  /** Callback that receives downstream message batches. */
@@ -513,6 +519,32 @@ interface Node<T = unknown> {
513
519
  /** Versioning info (GRAPHREFLY-SPEC §7). `undefined` when versioning is not enabled. */
514
520
  readonly v: Readonly<NodeVersionInfo> | undefined;
515
521
  }
522
+ /**
523
+ * Explicit cleanup wrapper. When a node fn returns `{ cleanup, value? }`,
524
+ * `cleanup` is registered as the teardown/recompute cleanup and `value`
525
+ * (if present) is emitted as data. This avoids the ambiguity where returning
526
+ * a plain function is silently consumed as cleanup instead of emitted as data.
527
+ *
528
+ * Use the {@link cleanupResult} factory to create instances — it stamps the
529
+ * branded {@link CLEANUP_RESULT} symbol so that domain objects with a `cleanup`
530
+ * property are never misinterpreted.
531
+ *
532
+ * Plain function returns are still treated as cleanup for backward compatibility.
533
+ */
534
+ type CleanupResult<T = unknown> = {
535
+ readonly [CLEANUP_RESULT]: true;
536
+ cleanup: () => void;
537
+ value?: T;
538
+ };
539
+ /**
540
+ * Create a branded {@link CleanupResult}.
541
+ *
542
+ * ```ts
543
+ * node([dep], () => cleanupResult(() => release(), computedValue))
544
+ * ```
545
+ */
546
+ declare function cleanupResult<T>(cleanup: () => void): CleanupResult<T>;
547
+ declare function cleanupResult<T>(cleanup: () => void, value: T): CleanupResult<T>;
516
548
  /**
517
549
  * Creates a reactive {@link Node} — the single GraphReFly primitive (GRAPHREFLY-SPEC §2).
518
550
  *
@@ -631,4 +663,4 @@ declare function metaSnapshot(node: Node): Record<string, unknown>;
631
663
  */
632
664
  declare function describeNode(node: Node, includeFields?: Set<string> | null): DescribeNodeOutput;
633
665
 
634
- export { policy as $, type Actor as A, createVersioning as B, COMPLETE as C, DATA as D, ERROR as E, defaultHash as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, describeNode as J, isKnownMessageType as K, isPhase2Message as L, type Message as M, type Node as N, type OnMessageHandler as O, PAUSE as P, isTerminalMessage as Q, RESOLVED as R, type SubscribeHints as S, TEARDOWN as T, isV1 as U, type V0 as V, knownMessageTypes as W, messageTier as X, metaSnapshot as Y, node as Z, normalizeActor as _, type NodeOptions as a, policyFromRules as a0, propagatesToMeta as a1, resolveDescribeFields as a2, type NodeInspectorHook as a3, type NodeActions as b, type NodeFn as c, DEFAULT_ACTOR as d, DIRTY as e, type DescribeDetail as f, type DescribeField as g, type DescribeNodeOutput as h, GuardDenied as i, type GuardDeniedDetails as j, type Messages as k, type NodeDescribeKind as l, type NodeGuard as m, type NodeSink as n, type NodeStatus as o, type NodeTransportOptions as p, type NodeVersionInfo as q, type PolicyAllow as r, type PolicyDeny as s, type PolicyRuleData as t, RESUME as u, type V1 as v, type VersioningLevel as w, type VersioningOptions as x, accessHintForGuard as y, advanceVersion as z };
666
+ export { metaSnapshot as $, type Actor as A, accessHintForGuard as B, CLEANUP_RESULT as C, DATA as D, ERROR as E, advanceVersion as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, cleanupResult as J, createVersioning as K, defaultHash as L, type Message as M, type Node as N, type OnMessageHandler as O, PAUSE as P, describeNode as Q, RESOLVED as R, type SubscribeHints as S, TEARDOWN as T, isKnownMessageType as U, type V0 as V, isPhase2Message as W, isTerminalMessage as X, isV1 as Y, knownMessageTypes as Z, messageTier as _, type NodeOptions as a, node as a0, normalizeActor as a1, policy as a2, policyFromRules as a3, propagatesToMeta as a4, resolveDescribeFields as a5, type NodeInspectorHook as a6, type NodeActions as b, type NodeFn as c, COMPLETE as d, type CleanupResult as e, DEFAULT_ACTOR as f, DIRTY as g, type DescribeDetail as h, type DescribeField as i, type DescribeNodeOutput as j, GuardDenied as k, type GuardDeniedDetails as l, type Messages as m, type NodeDescribeKind as n, type NodeGuard as o, type NodeSink as p, type NodeStatus as q, type NodeTransportOptions as r, type NodeVersionInfo as s, type PolicyAllow as t, type PolicyDeny as u, type PolicyRuleData as v, RESUME as w, type V1 as x, type VersioningLevel as y, type VersioningOptions as z };
@@ -548,6 +548,7 @@ function advanceVersion(info, newValue, hashFn) {
548
548
 
549
549
  // src/core/node.ts
550
550
  var NO_VALUE = /* @__PURE__ */ Symbol.for("graphrefly/NO_VALUE");
551
+ var CLEANUP_RESULT = /* @__PURE__ */ Symbol.for("graphrefly/CLEANUP_RESULT");
551
552
  function createIntBitSet() {
552
553
  let bits = 0;
553
554
  return {
@@ -610,6 +611,7 @@ function createBitSet(size) {
610
611
  }
611
612
  var isNodeArray = (value) => Array.isArray(value);
612
613
  var isNodeOptions = (value) => typeof value === "object" && value != null && !Array.isArray(value);
614
+ var isCleanupResult = (value) => typeof value === "object" && value !== null && CLEANUP_RESULT in value;
613
615
  var isCleanupFn = (value) => typeof value === "function";
614
616
  var statusAfterMessage = (status, msg) => {
615
617
  const t = msg[0];
@@ -1025,6 +1027,14 @@ var NodeImpl = class {
1025
1027
  this._lastDepValues = depValues;
1026
1028
  this._inspectorHook?.({ kind: "run", depValues });
1027
1029
  const out = this._fn(depValues, this._actions);
1030
+ if (isCleanupResult(out)) {
1031
+ this._cleanup = out.cleanup;
1032
+ if (this._manualEmitUsed) return;
1033
+ if ("value" in out) {
1034
+ this._emitAutoValue(out.value);
1035
+ }
1036
+ return;
1037
+ }
1028
1038
  if (isCleanupFn(out)) {
1029
1039
  this._cleanup = out;
1030
1040
  return;
@@ -1667,7 +1677,6 @@ function resolveDescribeFields(detail, fields) {
1667
1677
  case "full":
1668
1678
  return null;
1669
1679
  // null = include everything
1670
- case "minimal":
1671
1680
  default:
1672
1681
  return /* @__PURE__ */ new Set(["type", "deps"]);
1673
1682
  }