@graphrefly/graphrefly 0.16.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 (47) hide show
  1. package/dist/{chunk-RLVFZDCE.js → chunk-2PORF4RP.js} +3 -3
  2. package/dist/{chunk-YX263TXI.js → chunk-646OG3PO.js} +2 -2
  3. package/dist/{chunk-VZY2B2LU.js → chunk-BV3TPSBK.js} +1 -2
  4. package/dist/chunk-BV3TPSBK.js.map +1 -0
  5. package/dist/chunk-EBNKJULL.js +231 -0
  6. package/dist/chunk-EBNKJULL.js.map +1 -0
  7. package/dist/{chunk-ITDVOCFO.js → chunk-F2ULI3Q3.js} +2 -2
  8. package/dist/{chunk-3BLRREFM.js → chunk-IHJHBADD.js} +3 -3
  9. package/dist/{chunk-LKP7IWRV.js → chunk-R6OHUUYB.js} +3 -3
  10. package/dist/{chunk-26A4E7J7.js → chunk-XJ6EMQ22.js} +4 -4
  11. package/dist/{chunk-RZSQ7P2C.js → chunk-YXROQFXZ.js} +3 -3
  12. package/dist/compat/nestjs/index.cjs +0 -1
  13. package/dist/compat/nestjs/index.cjs.map +1 -1
  14. package/dist/compat/nestjs/index.js +7 -7
  15. package/dist/core/index.cjs +0 -1
  16. package/dist/core/index.cjs.map +1 -1
  17. package/dist/core/index.js +3 -3
  18. package/dist/extra/index.cjs +0 -1
  19. package/dist/extra/index.cjs.map +1 -1
  20. package/dist/extra/index.js +3 -3
  21. package/dist/graph/index.cjs +125 -3
  22. package/dist/graph/index.cjs.map +1 -1
  23. package/dist/graph/index.d.cts +1 -1
  24. package/dist/graph/index.d.ts +1 -1
  25. package/dist/graph/index.js +10 -6
  26. package/dist/{index-Db27z6Ki.d.cts → index-4OIX-q0C.d.cts} +88 -3
  27. package/dist/{index-BR19vQME.d.ts → index-D7y9Q8W4.d.ts} +88 -3
  28. package/dist/index.cjs +193 -45
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +51 -8
  31. package/dist/index.d.ts +51 -8
  32. package/dist/index.js +85 -57
  33. package/dist/index.js.map +1 -1
  34. package/dist/patterns/reactive-layout/index.cjs +0 -1
  35. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  36. package/dist/patterns/reactive-layout/index.js +4 -4
  37. package/package.json +1 -1
  38. package/dist/chunk-SHRJH2DN.js +0 -107
  39. package/dist/chunk-SHRJH2DN.js.map +0 -1
  40. package/dist/chunk-VZY2B2LU.js.map +0 -1
  41. /package/dist/{chunk-RLVFZDCE.js.map → chunk-2PORF4RP.js.map} +0 -0
  42. /package/dist/{chunk-YX263TXI.js.map → chunk-646OG3PO.js.map} +0 -0
  43. /package/dist/{chunk-ITDVOCFO.js.map → chunk-F2ULI3Q3.js.map} +0 -0
  44. /package/dist/{chunk-3BLRREFM.js.map → chunk-IHJHBADD.js.map} +0 -0
  45. /package/dist/{chunk-LKP7IWRV.js.map → chunk-R6OHUUYB.js.map} +0 -0
  46. /package/dist/{chunk-26A4E7J7.js.map → chunk-XJ6EMQ22.js.map} +0 -0
  47. /package/dist/{chunk-RZSQ7P2C.js.map → chunk-YXROQFXZ.js.map} +0 -0
@@ -136,7 +136,7 @@ import {
136
136
  workerBridge,
137
137
  workerSelf,
138
138
  zip
139
- } from "../chunk-RLVFZDCE.js";
139
+ } from "../chunk-2PORF4RP.js";
140
140
  import {
141
141
  cached,
142
142
  createWatermarkController,
@@ -169,9 +169,9 @@ import {
169
169
  toArray,
170
170
  toMessages$,
171
171
  toObservable
172
- } from "../chunk-YX263TXI.js";
172
+ } from "../chunk-646OG3PO.js";
173
173
  import "../chunk-WZ2Z2CRV.js";
174
- import "../chunk-VZY2B2LU.js";
174
+ import "../chunk-BV3TPSBK.js";
175
175
  export {
176
176
  CircuitOpenError,
177
177
  DictCheckpointAdapter,
@@ -25,9 +25,11 @@ __export(graph_exports, {
25
25
  JsonCodec: () => JsonCodec,
26
26
  createDagCborCodec: () => createDagCborCodec,
27
27
  createDagCborZstdCodec: () => createDagCborZstdCodec,
28
+ graphProfile: () => graphProfile,
28
29
  negotiateCodec: () => negotiateCodec,
29
30
  reachable: () => reachable,
30
- replayWAL: () => replayWAL
31
+ replayWAL: () => replayWAL,
32
+ sizeof: () => sizeof
31
33
  });
32
34
  module.exports = __toCommonJS(graph_exports);
33
35
 
@@ -787,7 +789,6 @@ var NodeImpl = class {
787
789
  this._downInternal(wasDirty ? [[RESOLVED]] : [[DIRTY], [RESOLVED]]);
788
790
  return;
789
791
  }
790
- this._cached = value;
791
792
  this._downInternal(wasDirty ? [[DATA, value]] : [[DIRTY], [DATA, value]]);
792
793
  }
793
794
  _runFn() {
@@ -3454,6 +3455,125 @@ function reachable(described, from, direction, options = {}) {
3454
3455
  }
3455
3456
  return [...out].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
3456
3457
  }
3458
+
3459
+ // src/graph/sizeof.ts
3460
+ var OVERHEAD = {
3461
+ object: 56,
3462
+ array: 64,
3463
+ string: 40,
3464
+ // header; content added separately
3465
+ number: 8,
3466
+ boolean: 4,
3467
+ null: 0,
3468
+ undefined: 0,
3469
+ symbol: 40,
3470
+ bigint: 16,
3471
+ function: 120,
3472
+ map: 72,
3473
+ set: 72,
3474
+ mapEntry: 40,
3475
+ setEntry: 24
3476
+ };
3477
+ function sizeof(value) {
3478
+ const seen = /* @__PURE__ */ new WeakSet();
3479
+ return _sizeof(value, seen);
3480
+ }
3481
+ function _sizeof(value, seen) {
3482
+ if (value == null) return 0;
3483
+ const t = typeof value;
3484
+ switch (t) {
3485
+ case "number":
3486
+ return OVERHEAD.number;
3487
+ case "boolean":
3488
+ return OVERHEAD.boolean;
3489
+ case "string":
3490
+ return OVERHEAD.string + value.length * 2;
3491
+ // UTF-16
3492
+ case "bigint":
3493
+ return OVERHEAD.bigint;
3494
+ case "symbol":
3495
+ return OVERHEAD.symbol;
3496
+ case "function":
3497
+ if (seen.has(value)) return 0;
3498
+ seen.add(value);
3499
+ return OVERHEAD.function;
3500
+ case "undefined":
3501
+ return 0;
3502
+ }
3503
+ const obj = value;
3504
+ if (seen.has(obj)) return 0;
3505
+ seen.add(obj);
3506
+ if (obj instanceof Map) {
3507
+ let size2 = OVERHEAD.map;
3508
+ for (const [k, v] of obj) {
3509
+ size2 += OVERHEAD.mapEntry + _sizeof(k, seen) + _sizeof(v, seen);
3510
+ }
3511
+ return size2;
3512
+ }
3513
+ if (obj instanceof Set) {
3514
+ let size2 = OVERHEAD.set;
3515
+ for (const v of obj) {
3516
+ size2 += OVERHEAD.setEntry + _sizeof(v, seen);
3517
+ }
3518
+ return size2;
3519
+ }
3520
+ if (Array.isArray(obj)) {
3521
+ let size2 = OVERHEAD.array + obj.length * 8;
3522
+ for (const item of obj) {
3523
+ size2 += _sizeof(item, seen);
3524
+ }
3525
+ return size2;
3526
+ }
3527
+ if (obj instanceof ArrayBuffer) return obj.byteLength;
3528
+ if (ArrayBuffer.isView(obj)) return obj.byteLength;
3529
+ let size = OVERHEAD.object;
3530
+ const keys = Object.keys(obj);
3531
+ for (const key of keys) {
3532
+ size += OVERHEAD.string + key.length * 2;
3533
+ size += _sizeof(obj[key], seen);
3534
+ }
3535
+ return size;
3536
+ }
3537
+
3538
+ // src/graph/profile.ts
3539
+ function graphProfile(graph, opts) {
3540
+ const topN = opts?.topN ?? 10;
3541
+ const desc = graph.describe({ detail: "standard" });
3542
+ const targets = [];
3543
+ if (typeof graph._collectObserveTargets === "function") {
3544
+ graph._collectObserveTargets("", targets);
3545
+ }
3546
+ const pathToNode = /* @__PURE__ */ new Map();
3547
+ for (const [p, n] of targets) {
3548
+ pathToNode.set(p, n);
3549
+ }
3550
+ const profiles = [];
3551
+ for (const [path, nodeDesc] of Object.entries(desc.nodes)) {
3552
+ const nd = pathToNode.get(path);
3553
+ const impl = nd instanceof NodeImpl ? nd : null;
3554
+ const valueSizeBytes = impl ? sizeof(impl.get()) : 0;
3555
+ const subscriberCount = impl ? impl._sinkCount : 0;
3556
+ const depCount = nodeDesc.deps?.length ?? 0;
3557
+ profiles.push({
3558
+ path,
3559
+ type: nodeDesc.type,
3560
+ status: nodeDesc.status ?? "unknown",
3561
+ valueSizeBytes,
3562
+ subscriberCount,
3563
+ depCount
3564
+ });
3565
+ }
3566
+ const totalValueSizeBytes = profiles.reduce((sum, p) => sum + p.valueSizeBytes, 0);
3567
+ const hotspots = [...profiles].sort((a, b) => b.valueSizeBytes - a.valueSizeBytes).slice(0, topN);
3568
+ return {
3569
+ nodeCount: profiles.length,
3570
+ edgeCount: desc.edges.length,
3571
+ subgraphCount: desc.subgraphs.length,
3572
+ nodes: profiles,
3573
+ totalValueSizeBytes,
3574
+ hotspots
3575
+ };
3576
+ }
3457
3577
  // Annotate the CommonJS export names for ESM import in node:
3458
3578
  0 && (module.exports = {
3459
3579
  GRAPH_META_SEGMENT,
@@ -3461,8 +3581,10 @@ function reachable(described, from, direction, options = {}) {
3461
3581
  JsonCodec,
3462
3582
  createDagCborCodec,
3463
3583
  createDagCborZstdCodec,
3584
+ graphProfile,
3464
3585
  negotiateCodec,
3465
3586
  reachable,
3466
- replayWAL
3587
+ replayWAL,
3588
+ sizeof
3467
3589
  });
3468
3590
  //# sourceMappingURL=index.cjs.map