@graphrefly/graphrefly 0.15.0 → 0.17.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 (75) hide show
  1. package/dist/{chunk-4APC3AFN.js → chunk-2PORF4RP.js} +22 -49
  2. package/dist/chunk-2PORF4RP.js.map +1 -0
  3. package/dist/{chunk-QVYZD65U.js → chunk-646OG3PO.js} +10 -38
  4. package/dist/chunk-646OG3PO.js.map +1 -0
  5. package/dist/{chunk-H243FWYP.js → chunk-BV3TPSBK.js} +1 -2
  6. package/dist/chunk-BV3TPSBK.js.map +1 -0
  7. package/dist/chunk-EBNKJULL.js +231 -0
  8. package/dist/chunk-EBNKJULL.js.map +1 -0
  9. package/dist/{chunk-XQ4UMAU7.js → chunk-F2ULI3Q3.js} +2 -2
  10. package/dist/{chunk-CRACCCJY.js → chunk-IHJHBADD.js} +29 -5
  11. package/dist/chunk-IHJHBADD.js.map +1 -0
  12. package/dist/{chunk-YW6LFCFS.js → chunk-R6OHUUYB.js} +3 -3
  13. package/dist/{chunk-2ZICUAUJ.js → chunk-XJ6EMQ22.js} +10 -12
  14. package/dist/chunk-XJ6EMQ22.js.map +1 -0
  15. package/dist/{chunk-GKRKDYNT.js → chunk-YXROQFXZ.js} +3 -3
  16. package/dist/compat/nestjs/index.cjs +38 -42
  17. package/dist/compat/nestjs/index.cjs.map +1 -1
  18. package/dist/compat/nestjs/index.d.cts +4 -4
  19. package/dist/compat/nestjs/index.d.ts +4 -4
  20. package/dist/compat/nestjs/index.js +7 -7
  21. package/dist/core/index.cjs +0 -1
  22. package/dist/core/index.cjs.map +1 -1
  23. package/dist/core/index.d.cts +2 -2
  24. package/dist/core/index.d.ts +2 -2
  25. package/dist/core/index.js +3 -3
  26. package/dist/extra/index.cjs +27 -79
  27. package/dist/extra/index.cjs.map +1 -1
  28. package/dist/extra/index.d.cts +4 -4
  29. package/dist/extra/index.d.ts +4 -4
  30. package/dist/extra/index.js +3 -3
  31. package/dist/graph/index.cjs +151 -5
  32. package/dist/graph/index.cjs.map +1 -1
  33. package/dist/graph/index.d.cts +3 -3
  34. package/dist/graph/index.d.ts +3 -3
  35. package/dist/graph/index.js +10 -6
  36. package/dist/{graph-BXIK5Dq5.d.ts → graph-Dc-P9BVm.d.ts} +15 -3
  37. package/dist/{graph-BhADtuFU.d.cts → graph-fCsaaVIa.d.cts} +15 -3
  38. package/dist/{index-BkToATim.d.ts → index-4OIX-q0C.d.cts} +88 -3
  39. package/dist/{index-DSp5R3Xq.d.ts → index-BBVBYPxr.d.cts} +4 -4
  40. package/dist/{index-BNB0KjKe.d.ts → index-BmoUvOGN.d.ts} +1 -1
  41. package/dist/{index-DBhLjWSV.d.cts → index-ClaKZFPl.d.cts} +100 -31
  42. package/dist/{index-Wa8jXne6.d.cts → index-D7y9Q8W4.d.ts} +88 -3
  43. package/dist/{index-Dqemj9q0.d.cts → index-DWq0P9T6.d.ts} +4 -4
  44. package/dist/{index-fYObbpUw.d.ts → index-DhXznWyH.d.ts} +2 -2
  45. package/dist/{index-DANO9Gg7.d.cts → index-DlGMf_Qe.d.cts} +2 -2
  46. package/dist/{index-CKyYg4IP.d.ts → index-N704txAA.d.ts} +100 -31
  47. package/dist/{index-DKIyo4Bq.d.cts → index-YlOH1Gw6.d.cts} +1 -1
  48. package/dist/index.cjs +302 -231
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +71 -41
  51. package/dist/index.d.ts +71 -41
  52. package/dist/index.js +131 -151
  53. package/dist/index.js.map +1 -1
  54. package/dist/{meta-CrZUQAJ6.d.cts → meta-BV4pj9ML.d.cts} +6 -0
  55. package/dist/{meta-CrZUQAJ6.d.ts → meta-BV4pj9ML.d.ts} +6 -0
  56. package/dist/observable-Cz-AWhwR.d.cts +42 -0
  57. package/dist/observable-DCqlwGyl.d.ts +42 -0
  58. package/dist/patterns/reactive-layout/index.cjs +26 -3
  59. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  60. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  61. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  62. package/dist/patterns/reactive-layout/index.js +4 -4
  63. package/package.json +1 -1
  64. package/dist/chunk-2ZICUAUJ.js.map +0 -1
  65. package/dist/chunk-4APC3AFN.js.map +0 -1
  66. package/dist/chunk-CRACCCJY.js.map +0 -1
  67. package/dist/chunk-H243FWYP.js.map +0 -1
  68. package/dist/chunk-QVYZD65U.js.map +0 -1
  69. package/dist/chunk-ZHTHUX5D.js +0 -107
  70. package/dist/chunk-ZHTHUX5D.js.map +0 -1
  71. package/dist/reactive-log-ChbpUrY2.d.cts +0 -137
  72. package/dist/reactive-log-DV--7BWd.d.ts +0 -137
  73. /package/dist/{chunk-XQ4UMAU7.js.map → chunk-F2ULI3Q3.js.map} +0 -0
  74. /package/dist/{chunk-YW6LFCFS.js.map → chunk-R6OHUUYB.js.map} +0 -0
  75. /package/dist/{chunk-GKRKDYNT.js.map → chunk-YXROQFXZ.js.map} +0 -0
@@ -559,6 +559,12 @@ declare function cleanupResult<T>(cleanup: () => void, value: T): CleanupResult<
559
559
  * @remarks
560
560
  * **Protocol:** DIRTY / DATA / RESOLVED ordering, completion, and batch deferral follow `~/src/graphrefly/GRAPHREFLY-SPEC.md`.
561
561
  *
562
+ * **`equals` and mutable values:** The default `Object.is` identity check is
563
+ * correct for the common immutable-value case. If your node produces mutable
564
+ * objects (e.g. arrays or maps mutated in place), provide a custom `equals`
565
+ * function — otherwise `Object.is` will always return `true` for the same
566
+ * reference and the node will emit `RESOLVED` instead of `DATA`.
567
+ *
562
568
  * @example
563
569
  * ```ts
564
570
  * import { node, state } from "@graphrefly/graphrefly-ts";
@@ -559,6 +559,12 @@ declare function cleanupResult<T>(cleanup: () => void, value: T): CleanupResult<
559
559
  * @remarks
560
560
  * **Protocol:** DIRTY / DATA / RESOLVED ordering, completion, and batch deferral follow `~/src/graphrefly/GRAPHREFLY-SPEC.md`.
561
561
  *
562
+ * **`equals` and mutable values:** The default `Object.is` identity check is
563
+ * correct for the common immutable-value case. If your node produces mutable
564
+ * objects (e.g. arrays or maps mutated in place), provide a custom `equals`
565
+ * function — otherwise `Object.is` will always return `true` for the same
566
+ * reference and the node will emit `RESOLVED` instead of `DATA`.
567
+ *
562
568
  * @example
563
569
  * ```ts
564
570
  * import { node, state } from "@graphrefly/graphrefly-ts";
@@ -0,0 +1,42 @@
1
+ import { Observable } from 'rxjs';
2
+ import { m as Messages, N as Node } from './meta-BV4pj9ML.cjs';
3
+ import { G as Graph, x as ObserveOptions } from './graph-fCsaaVIa.cjs';
4
+
5
+ /**
6
+ * Bridge a `Node<T>` to an RxJS `Observable<T>`.
7
+ *
8
+ * Emits the node's value on each `DATA` message. Maps `ERROR` to
9
+ * `subscriber.error()` and `COMPLETE` to `subscriber.complete()`.
10
+ * Protocol-internal signals (DIRTY, RESOLVED, PAUSE, etc.) are skipped.
11
+ *
12
+ * Unsubscribing the Observable unsubscribes the node.
13
+ */
14
+ declare function toObservable<T>(node: Node<T>): Observable<T>;
15
+ /**
16
+ * Bridge a `Node<T>` to an `Observable<Messages>` — raw message batches.
17
+ *
18
+ * Each emission is a full `[[Type, Data?], ...]` batch. The Observable
19
+ * terminates on ERROR or COMPLETE (the terminal batch is still emitted
20
+ * as the final `next()` before the Observable signal).
21
+ */
22
+ declare function toMessages$<T>(node: Node<T>): Observable<Messages>;
23
+ /**
24
+ * Observe a single node in a `Graph` as an `Observable<T>`.
25
+ *
26
+ * Equivalent to `toObservable(graph.resolve(path))` but routes through
27
+ * `graph.observe()` so actor guards are respected when provided.
28
+ */
29
+ declare function observeNode$<T>(graph: Graph, path: string, options?: ObserveOptions): Observable<T>;
30
+ /**
31
+ * Observe all nodes in a `Graph` as an `Observable<{ path, messages }>`.
32
+ *
33
+ * Each emission carries the qualified node path and the raw message batch.
34
+ * The Observable never self-completes (graphs are long-lived); dispose by
35
+ * unsubscribing.
36
+ */
37
+ declare function observeGraph$(graph: Graph, options?: ObserveOptions): Observable<{
38
+ path: string;
39
+ messages: Messages;
40
+ }>;
41
+
42
+ export { observeNode$ as a, toObservable as b, observeGraph$ as o, toMessages$ as t };
@@ -0,0 +1,42 @@
1
+ import { Observable } from 'rxjs';
2
+ import { m as Messages, N as Node } from './meta-BV4pj9ML.js';
3
+ import { G as Graph, x as ObserveOptions } from './graph-Dc-P9BVm.js';
4
+
5
+ /**
6
+ * Bridge a `Node<T>` to an RxJS `Observable<T>`.
7
+ *
8
+ * Emits the node's value on each `DATA` message. Maps `ERROR` to
9
+ * `subscriber.error()` and `COMPLETE` to `subscriber.complete()`.
10
+ * Protocol-internal signals (DIRTY, RESOLVED, PAUSE, etc.) are skipped.
11
+ *
12
+ * Unsubscribing the Observable unsubscribes the node.
13
+ */
14
+ declare function toObservable<T>(node: Node<T>): Observable<T>;
15
+ /**
16
+ * Bridge a `Node<T>` to an `Observable<Messages>` — raw message batches.
17
+ *
18
+ * Each emission is a full `[[Type, Data?], ...]` batch. The Observable
19
+ * terminates on ERROR or COMPLETE (the terminal batch is still emitted
20
+ * as the final `next()` before the Observable signal).
21
+ */
22
+ declare function toMessages$<T>(node: Node<T>): Observable<Messages>;
23
+ /**
24
+ * Observe a single node in a `Graph` as an `Observable<T>`.
25
+ *
26
+ * Equivalent to `toObservable(graph.resolve(path))` but routes through
27
+ * `graph.observe()` so actor guards are respected when provided.
28
+ */
29
+ declare function observeNode$<T>(graph: Graph, path: string, options?: ObserveOptions): Observable<T>;
30
+ /**
31
+ * Observe all nodes in a `Graph` as an `Observable<{ path, messages }>`.
32
+ *
33
+ * Each emission carries the qualified node path and the raw message batch.
34
+ * The Observable never self-completes (graphs are long-lived); dispose by
35
+ * unsubscribing.
36
+ */
37
+ declare function observeGraph$(graph: Graph, options?: ObserveOptions): Observable<{
38
+ path: string;
39
+ messages: Messages;
40
+ }>;
41
+
42
+ export { observeNode$ as a, toObservable as b, observeGraph$ as o, toMessages$ as t };
@@ -996,7 +996,6 @@ var NodeImpl = class {
996
996
  this._downInternal(wasDirty ? [[RESOLVED]] : [[DIRTY], [RESOLVED]]);
997
997
  return;
998
998
  }
999
- this._cached = value;
1000
999
  this._downInternal(wasDirty ? [[DATA, value]] : [[DIRTY], [DATA, value]]);
1001
1000
  }
1002
1001
  _runFn() {
@@ -2035,6 +2034,7 @@ var Graph = class _Graph {
2035
2034
  /** @internal — exposed for {@link teardownMountedGraph}. */
2036
2035
  _mounts = /* @__PURE__ */ new Map();
2037
2036
  _autoCheckpointDisposers = /* @__PURE__ */ new Set();
2037
+ _disposers = /* @__PURE__ */ new Set();
2038
2038
  _defaultVersioningLevel;
2039
2039
  static registerFactory(pattern, factory) {
2040
2040
  if (!pattern) {
@@ -3170,10 +3170,33 @@ var Graph = class _Graph {
3170
3170
  // Lifecycle & persistence (§3.7–§3.8)
3171
3171
  // ——————————————————————————————————————————————————————————————
3172
3172
  /**
3173
- * Sends `[[TEARDOWN]]` to all nodes, then clears registries on this graph and every
3174
- * mounted subgraph (§3.7). The instance is left empty and may be reused with {@link Graph.add}.
3173
+ * Register a cleanup function to be called on {@link Graph.destroy}.
3174
+ *
3175
+ * Factories use this to attach teardown logic for internal nodes, keepalive
3176
+ * subscriptions, or other resources that are not registered on the graph and
3177
+ * would otherwise leak on repeated create/destroy cycles.
3178
+ *
3179
+ * Returns a removal function — call it to unregister the disposer early.
3180
+ */
3181
+ addDisposer(fn) {
3182
+ this._disposers.add(fn);
3183
+ return () => {
3184
+ this._disposers.delete(fn);
3185
+ };
3186
+ }
3187
+ /**
3188
+ * Drains disposers (registered via {@link addDisposer}), then sends `[[TEARDOWN]]` to all
3189
+ * nodes and clears registries on this graph and every mounted subgraph (§3.7).
3190
+ * The instance is left empty and may be reused with {@link Graph.add}.
3175
3191
  */
3176
3192
  destroy() {
3193
+ for (const dispose of [...this._disposers]) {
3194
+ try {
3195
+ dispose();
3196
+ } catch {
3197
+ }
3198
+ }
3199
+ this._disposers.clear();
3177
3200
  this.signal([[TEARDOWN]], { internal: true });
3178
3201
  for (const dispose of [...this._autoCheckpointDisposers]) {
3179
3202
  try {