@graphrefly/graphrefly 0.27.0 → 0.28.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.
- package/dist/backoff-HPZMEZNF.js +1 -0
- package/dist/cascading-B-5zmAUv.d.cts +180 -0
- package/dist/cascading-D9WG1-9L.d.ts +180 -0
- package/dist/chunk-2FOAM3OR.js +1 -0
- package/dist/chunk-2PMCKKRK.js +1 -0
- package/dist/chunk-3JXNEPCD.js +2 -0
- package/dist/chunk-3R5HFPX7.js +78 -0
- package/dist/chunk-4GKB4OUJ.js +1 -0
- package/dist/chunk-4VVTGLXJ.js +1 -0
- package/dist/chunk-5QDBSZBV.js +1 -0
- package/dist/chunk-6QZNQS5B.js +1 -0
- package/dist/chunk-6V3SEX2I.js +1 -0
- package/dist/chunk-76A3HVQE.js +9 -0
- package/dist/chunk-7H6LGFUG.js +64 -0
- package/dist/chunk-CK2E7BTU.js +1 -0
- package/dist/chunk-CKCSDI7T.js +6 -0
- package/dist/chunk-CRXTH3SH.js +1 -0
- package/dist/chunk-CWLN3X3N.js +1 -0
- package/dist/chunk-D7A7DBE4.js +1 -0
- package/dist/chunk-DBGGMN3D.js +1 -0
- package/dist/chunk-DQA3UIQ2.js +1 -0
- package/dist/chunk-ERLIRFPA.js +1 -0
- package/dist/chunk-ESMPEKEV.js +1 -0
- package/dist/chunk-ETWTCCJI.js +1 -0
- package/dist/chunk-FNYWM6JC.js +1 -0
- package/dist/chunk-GHJJR5P4.js +1 -0
- package/dist/chunk-GPW2V3RE.js +1 -0
- package/dist/chunk-I6VIH3VA.js +1 -0
- package/dist/chunk-K2GNMCQT.js +1 -0
- package/dist/chunk-LBTDSCCO.js +3 -0
- package/dist/chunk-LQ3Y5NJS.js +1 -0
- package/dist/chunk-MIQTDPY4.js +5 -0
- package/dist/chunk-MTTAAPCK.js +1 -0
- package/dist/chunk-OAWLCNJJ.js +1 -0
- package/dist/chunk-OBKQQA5I.js +1 -0
- package/dist/chunk-OYHGKYQM.js +1 -0
- package/dist/chunk-PIOGHC63.js +1 -0
- package/dist/chunk-QWAPKG3O.js +2 -0
- package/dist/chunk-QYADASLV.js +1 -0
- package/dist/chunk-RHESUC3V.js +43 -0
- package/dist/chunk-S35VARIR.js +1 -0
- package/dist/chunk-SC3U7ETD.js +1 -0
- package/dist/chunk-U3AICJKU.js +1 -0
- package/dist/chunk-UMBIDLJ4.js +1 -0
- package/dist/chunk-UPHHLMHE.js +1 -0
- package/dist/chunk-UPXUCFMX.js +1 -0
- package/dist/chunk-UWJE5FQA.js +18 -0
- package/dist/chunk-V6YQICXZ.js +1 -0
- package/dist/chunk-VIMF6LGM.js +1 -0
- package/dist/chunk-VJLMUKOI.js +1 -0
- package/dist/chunk-VPYBOXVT.js +1 -0
- package/dist/chunk-VTPVOGHH.js +1 -0
- package/dist/chunk-WQ2BN6X6.js +1 -0
- package/dist/chunk-XAUNPIMX.js +1 -0
- package/dist/chunk-Y2EMPB3I.js +1 -0
- package/dist/chunk-Z4HDAS2Q.js +1 -0
- package/dist/chunk-ZB5EHBIO.js +1 -0
- package/dist/chunk-ZV2DXV5A.js +23 -0
- package/dist/compat/index.cjs +14 -7656
- package/dist/compat/index.d.cts +15 -14
- package/dist/compat/index.d.ts +15 -14
- package/dist/compat/index.js +1 -50
- package/dist/compat/jotai/index.cjs +1 -2048
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -9
- package/dist/compat/nanostores/index.cjs +1 -2175
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -23
- package/dist/compat/nestjs/index.cjs +14 -6782
- package/dist/compat/nestjs/index.d.cts +7 -6
- package/dist/compat/nestjs/index.d.ts +7 -6
- package/dist/compat/nestjs/index.js +1 -83
- package/dist/compat/react/index.cjs +1 -141
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/react/index.js +1 -12
- package/dist/compat/solid/index.cjs +1 -128
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/solid/index.js +1 -12
- package/dist/compat/svelte/index.cjs +1 -131
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/svelte/index.js +1 -12
- package/dist/compat/vue/index.cjs +1 -146
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/vue/index.js +1 -12
- package/dist/compat/zustand/index.cjs +6 -4931
- package/dist/compat/zustand/index.d.cts +5 -5
- package/dist/compat/zustand/index.d.ts +5 -5
- package/dist/compat/zustand/index.js +1 -12
- package/dist/composite-B-xqw4Kk.d.cts +69 -0
- package/dist/composite-BhbKHbOS.d.ts +69 -0
- package/dist/core/index.cjs +1 -2271
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -110
- package/dist/extra/browser.cjs +1 -0
- package/dist/extra/browser.d.cts +3 -0
- package/dist/extra/browser.d.ts +3 -0
- package/dist/extra/browser.js +1 -0
- package/dist/extra/index.cjs +23 -9971
- package/dist/extra/index.d.cts +13 -6
- package/dist/extra/index.d.ts +13 -6
- package/dist/extra/index.js +1 -381
- package/dist/extra/node.cjs +3 -0
- package/dist/extra/node.d.cts +81 -0
- package/dist/extra/node.d.ts +81 -0
- package/dist/extra/node.js +2 -0
- package/dist/extra/operators.cjs +1 -0
- package/dist/extra/operators.d.cts +910 -0
- package/dist/extra/operators.d.ts +910 -0
- package/dist/extra/operators.js +1 -0
- package/dist/extra/reactive.cjs +1 -0
- package/dist/extra/reactive.d.cts +352 -0
- package/dist/extra/reactive.d.ts +352 -0
- package/dist/extra/reactive.js +1 -0
- package/dist/extra/sources.cjs +1 -2486
- package/dist/extra/sources.d.cts +6 -2
- package/dist/extra/sources.d.ts +6 -2
- package/dist/extra/sources.js +1 -57
- package/dist/extra/storage-browser.cjs +1 -0
- package/dist/extra/storage-browser.d.cts +71 -0
- package/dist/extra/storage-browser.d.ts +71 -0
- package/dist/extra/storage-browser.js +1 -0
- package/dist/extra/storage-core.cjs +1 -0
- package/dist/extra/storage-core.d.cts +98 -0
- package/dist/extra/storage-core.d.ts +98 -0
- package/dist/extra/storage-core.js +1 -0
- package/dist/extra/storage-node.cjs +2 -0
- package/dist/extra/storage-node.d.cts +60 -0
- package/dist/extra/storage-node.d.ts +60 -0
- package/dist/extra/storage-node.js +1 -0
- package/dist/fallback-BaTS7vVY.d.cts +258 -0
- package/dist/fallback-eOm3LNxP.d.ts +258 -0
- package/dist/graph/index.cjs +6 -5030
- package/dist/graph/index.d.cts +6 -5
- package/dist/graph/index.d.ts +6 -5
- package/dist/graph/index.js +1 -50
- package/dist/{graph-CCwGKLCm.d.ts → graph-BZGRXwOm.d.ts} +134 -31
- package/dist/{graph-DNCrvZSn.d.cts → graph-D48Qw9Cg.d.cts} +134 -31
- package/dist/index-8FSVk4Uf.d.ts +135 -0
- package/dist/index-9oDeHH2u.d.cts +291 -0
- package/dist/{messaging-XDoYablx.d.ts → index-B0c4cmIO.d.ts} +31 -93
- package/dist/{index-VdHQMPy1.d.ts → index-B1AmmSlb.d.ts} +1 -1
- package/dist/{index-VHqptjhu.d.cts → index-B2pwesl9.d.cts} +1 -1
- package/dist/index-BHvIquRZ.d.ts +1957 -0
- package/dist/{index-Dzk2hrlR.d.ts → index-BVHOrDwO.d.ts} +1 -1
- package/dist/{index-CxFrXH4m.d.ts → index-BWJV63ti.d.ts} +1 -1
- package/dist/{index-Xi3u0HCQ.d.cts → index-B_agccPe.d.cts} +1 -1
- package/dist/index-BgyGlizc.d.ts +163 -0
- package/dist/index-BpA5c4G9.d.ts +357 -0
- package/dist/index-BpIFjILY.d.cts +357 -0
- package/dist/{index-3lsddbbS.d.ts → index-Bqachn9_.d.ts} +1 -1
- package/dist/index-Btib9rsU.d.ts +607 -0
- package/dist/{index-wEn0eFe8.d.ts → index-BwM9BEkt.d.ts} +1 -1
- package/dist/index-BxJ86YZZ.d.cts +105 -0
- package/dist/{audit-DRlSzBu9.d.ts → index-C73n7lo-.d.cts} +27 -21
- package/dist/index-CEXXwWVH.d.cts +192 -0
- package/dist/index-CHEswufn.d.cts +163 -0
- package/dist/{index-C0svESO4.d.ts → index-CMn8S8Hw.d.ts} +1 -1
- package/dist/{index-ByQxazQJ.d.cts → index-CRO83MmV.d.cts} +1 -1
- package/dist/{index-BuEoe-Qu.d.ts → index-CloUk1kY.d.ts} +9 -9
- package/dist/index-CpgYhnrG.d.ts +291 -0
- package/dist/{index-DO_6JN9Z.d.cts → index-Cyojz0AE.d.cts} +1 -1
- package/dist/{demo-shell-BDkOptd6.d.ts → index-CzobVSMr.d.ts} +14 -14
- package/dist/index-Czq6ynh8.d.ts +143 -0
- package/dist/{index-BaSM3aYt.d.ts → index-D-YB-Vl3.d.ts} +3 -3
- package/dist/index-DAlweici.d.ts +231 -0
- package/dist/index-DEwTb_fm.d.cts +1957 -0
- package/dist/{index-DYme44FM.d.cts → index-DL-rYJrx.d.cts} +1 -1
- package/dist/{memory-li6FL5RM.d.ts → index-DP4ZTkdw.d.ts} +26 -26
- package/dist/{index-BwfLUNw4.d.ts → index-DUqMOlKZ.d.cts} +173 -2040
- package/dist/{index-B1tloyhO.d.cts → index-D_NwnRYS.d.cts} +1 -1
- package/dist/index-DaLJvH8Z.d.ts +105 -0
- package/dist/index-DcXZBF5a.d.cts +135 -0
- package/dist/index-DfyOkTvs.d.ts +321 -0
- package/dist/{index-B9B7_HEY.d.ts → index-DiOXyAwt.d.ts} +1 -1
- package/dist/index-DpHe5e0Q.d.ts +186 -0
- package/dist/index-DraikLjn.d.ts +86 -0
- package/dist/{index-D8wS_PeY.d.cts → index-DxsnAMWD.d.cts} +9 -9
- package/dist/{messaging-Gt4LPbyA.d.cts → index-DyxjtScX.d.cts} +31 -93
- package/dist/{audit-ClmqGOCx.d.cts → index-HDpJe9hX.d.ts} +27 -21
- package/dist/{index-DVGiGFGT.d.cts → index-O6TgGUBV.d.cts} +3 -3
- package/dist/{index-B6EhDnjH.d.cts → index-Oi8d8w4R.d.cts} +1 -1
- package/dist/{index-C8oil6M6.d.ts → index-ROpQmGjE.d.ts} +30 -6
- package/dist/index-RukJ4DLS.d.cts +607 -0
- package/dist/{index-BHlKbUwO.d.cts → index-ZftwfxJM.d.ts} +173 -2040
- package/dist/{index-BPVt8kqc.d.ts → index-cByzxQIC.d.cts} +10 -195
- package/dist/index-dtN7YA2x.d.cts +143 -0
- package/dist/{index-CI3DprxP.d.cts → index-fM6y00vT.d.cts} +30 -6
- package/dist/{index-DlLp-2Xn.d.cts → index-m-yHof5p.d.ts} +10 -195
- package/dist/index-pXrDMpRO.d.cts +231 -0
- package/dist/index-rHJSKsU8.d.cts +186 -0
- package/dist/index-rX8HBM5h.d.cts +321 -0
- package/dist/{index-CO8uBlUh.d.cts → index-rnwQly8X.d.cts} +147 -20
- package/dist/index-sm373fsH.d.ts +192 -0
- package/dist/{memory-C6Z2tGpC.d.cts → index-tbf2gKHd.d.cts} +26 -26
- package/dist/{demo-shell-Crid1WdR.d.cts → index-u15meRxL.d.cts} +14 -14
- package/dist/{index-B6D3QNSA.d.ts → index-umtoWT8K.d.ts} +147 -20
- package/dist/index-vscRDkjW.d.cts +86 -0
- package/dist/index.cjs +150 -24142
- package/dist/index.d.cts +69 -2099
- package/dist/index.d.ts +69 -2099
- package/dist/index.js +1 -3868
- package/dist/{meta-CbznRPYJ.d.ts → meta-Cgj6zeji.d.cts} +5 -5
- package/dist/{meta-BxCA7rcr.d.cts → meta-CwesDrMD.d.ts} +5 -5
- package/dist/{node-BmerH3kS.d.cts → node-Cc1TniY8.d.cts} +36 -9
- package/dist/{node-BmerH3kS.d.ts → node-Cc1TniY8.d.ts} +36 -9
- package/dist/{observable-BgGUwcqp.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
- package/dist/{observable-DJt_AxzQ.d.cts → observable-glXQoGj2.d.cts} +1 -1
- package/dist/patterns/ai/browser.cjs +25 -0
- package/dist/patterns/ai/browser.d.cts +127 -0
- package/dist/patterns/ai/browser.d.ts +127 -0
- package/dist/patterns/ai/browser.js +3 -0
- package/dist/patterns/ai/index.cjs +91 -0
- package/dist/patterns/ai/index.d.cts +17 -0
- package/dist/patterns/ai/index.d.ts +17 -0
- package/dist/patterns/ai/index.js +1 -0
- package/dist/patterns/ai/node.cjs +2 -0
- package/dist/patterns/ai/node.d.cts +58 -0
- package/dist/patterns/ai/node.d.ts +58 -0
- package/dist/patterns/ai/node.js +1 -0
- package/dist/patterns/audit/index.cjs +6 -0
- package/dist/patterns/audit/index.d.cts +6 -0
- package/dist/patterns/audit/index.d.ts +6 -0
- package/dist/patterns/audit/index.js +1 -0
- package/dist/patterns/cqrs/index.cjs +6 -0
- package/dist/patterns/cqrs/index.d.cts +5 -0
- package/dist/patterns/cqrs/index.d.ts +5 -0
- package/dist/patterns/cqrs/index.js +1 -0
- package/dist/patterns/demo-shell/index.cjs +7 -0
- package/dist/patterns/demo-shell/index.d.cts +6 -0
- package/dist/patterns/demo-shell/index.d.ts +6 -0
- package/dist/patterns/demo-shell/index.js +1 -0
- package/dist/patterns/domain-templates/index.cjs +6 -0
- package/dist/patterns/domain-templates/index.d.cts +5 -0
- package/dist/patterns/domain-templates/index.d.ts +5 -0
- package/dist/patterns/domain-templates/index.js +1 -0
- package/dist/patterns/graphspec/index.cjs +83 -0
- package/dist/patterns/graphspec/index.d.cts +7 -0
- package/dist/patterns/graphspec/index.d.ts +7 -0
- package/dist/patterns/graphspec/index.js +1 -0
- package/dist/patterns/guarded-execution/index.cjs +6 -0
- package/dist/patterns/guarded-execution/index.d.cts +7 -0
- package/dist/patterns/guarded-execution/index.d.ts +7 -0
- package/dist/patterns/guarded-execution/index.js +1 -0
- package/dist/patterns/harness/index.cjs +48 -0
- package/dist/patterns/harness/index.d.cts +8 -0
- package/dist/patterns/harness/index.d.ts +8 -0
- package/dist/patterns/harness/index.js +1 -0
- package/dist/patterns/job-queue/index.cjs +6 -0
- package/dist/patterns/job-queue/index.d.cts +5 -0
- package/dist/patterns/job-queue/index.d.ts +5 -0
- package/dist/patterns/job-queue/index.js +1 -0
- package/dist/patterns/lens/index.cjs +6 -0
- package/dist/patterns/lens/index.d.cts +7 -0
- package/dist/patterns/lens/index.d.ts +7 -0
- package/dist/patterns/lens/index.js +1 -0
- package/dist/patterns/memory/index.cjs +6 -0
- package/dist/patterns/memory/index.d.cts +5 -0
- package/dist/patterns/memory/index.d.ts +5 -0
- package/dist/patterns/memory/index.js +1 -0
- package/dist/patterns/messaging/index.cjs +6 -0
- package/dist/patterns/messaging/index.d.cts +5 -0
- package/dist/patterns/messaging/index.d.ts +5 -0
- package/dist/patterns/messaging/index.js +1 -0
- package/dist/patterns/orchestration/index.cjs +6 -0
- package/dist/patterns/orchestration/index.d.cts +6 -0
- package/dist/patterns/orchestration/index.d.ts +6 -0
- package/dist/patterns/orchestration/index.js +1 -0
- package/dist/patterns/reactive-layout/index.cjs +7 -6444
- package/dist/patterns/reactive-layout/index.d.cts +6 -6
- package/dist/patterns/reactive-layout/index.d.ts +6 -6
- package/dist/patterns/reactive-layout/index.js +1 -56
- package/dist/patterns/reduction/index.cjs +6 -0
- package/dist/patterns/reduction/index.d.cts +5 -0
- package/dist/patterns/reduction/index.d.ts +5 -0
- package/dist/patterns/reduction/index.js +1 -0
- package/dist/patterns/refine-loop/index.cjs +8 -0
- package/dist/patterns/refine-loop/index.d.cts +7 -0
- package/dist/patterns/refine-loop/index.d.ts +7 -0
- package/dist/patterns/refine-loop/index.js +1 -0
- package/dist/patterns/resilient-pipeline/index.cjs +1 -0
- package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
- package/dist/patterns/resilient-pipeline/index.js +1 -0
- package/dist/patterns/surface/index.cjs +14 -0
- package/dist/patterns/surface/index.d.cts +8 -0
- package/dist/patterns/surface/index.d.ts +8 -0
- package/dist/patterns/surface/index.js +1 -0
- package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
- package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
- package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
- package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
- package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CdbNoSgP.d.ts} +2 -67
- package/dist/{composite-C7PcQvcs.d.cts → reactive-map-DUeRmb9d.d.cts} +2 -67
- package/dist/resilience-Ba5-b4WD.d.cts +493 -0
- package/dist/resilience-CGRzhnD3.d.ts +493 -0
- package/dist/resilience-QAHKANT5.js +1 -0
- package/dist/{sugar-D02n5JjF.d.cts → sugar-BV0htudb.d.cts} +8 -4
- package/dist/{sugar-CCOxXK1e.d.ts → sugar-Dtyrq2_q.d.ts} +8 -4
- package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
- package/dist/topology-tree-DROUdq5B.d.cts +25 -0
- package/dist/types-O3GzJY2U.d.cts +401 -0
- package/dist/types-u64Ose53.d.ts +401 -0
- package/package.json +252 -22
- package/dist/ai-CaR_912Q.d.cts +0 -1033
- package/dist/ai-WlRltJV7.d.ts +0 -1033
- package/dist/chunk-3ZWCKRHX.js +0 -117
- package/dist/chunk-3ZWCKRHX.js.map +0 -1
- package/dist/chunk-7TAQJHQV.js +0 -103
- package/dist/chunk-7TAQJHQV.js.map +0 -1
- package/dist/chunk-APFNLIRG.js +0 -62
- package/dist/chunk-APFNLIRG.js.map +0 -1
- package/dist/chunk-AT5LKYNL.js +0 -395
- package/dist/chunk-AT5LKYNL.js.map +0 -1
- package/dist/chunk-BQ6RQQFF.js +0 -5087
- package/dist/chunk-BQ6RQQFF.js.map +0 -1
- package/dist/chunk-BVZYTZ5H.js +0 -599
- package/dist/chunk-BVZYTZ5H.js.map +0 -1
- package/dist/chunk-DST5DKZS.js +0 -1371
- package/dist/chunk-DST5DKZS.js.map +0 -1
- package/dist/chunk-GTE6PWRZ.js +0 -866
- package/dist/chunk-GTE6PWRZ.js.map +0 -1
- package/dist/chunk-HXZEYDUR.js +0 -94
- package/dist/chunk-HXZEYDUR.js.map +0 -1
- package/dist/chunk-J22W6HV3.js +0 -107
- package/dist/chunk-J22W6HV3.js.map +0 -1
- package/dist/chunk-J2VBW3DZ.js +0 -302
- package/dist/chunk-J2VBW3DZ.js.map +0 -1
- package/dist/chunk-JSCT3CR4.js +0 -38
- package/dist/chunk-JSCT3CR4.js.map +0 -1
- package/dist/chunk-JWBCY4NC.js +0 -330
- package/dist/chunk-JWBCY4NC.js.map +0 -1
- package/dist/chunk-K2AUJHVP.js +0 -2251
- package/dist/chunk-K2AUJHVP.js.map +0 -1
- package/dist/chunk-MJ2NKQQL.js +0 -119
- package/dist/chunk-MJ2NKQQL.js.map +0 -1
- package/dist/chunk-N6UR7YVY.js +0 -198
- package/dist/chunk-N6UR7YVY.js.map +0 -1
- package/dist/chunk-NC6S43JJ.js +0 -456
- package/dist/chunk-NC6S43JJ.js.map +0 -1
- package/dist/chunk-OFVJBJXR.js +0 -98
- package/dist/chunk-OFVJBJXR.js.map +0 -1
- package/dist/chunk-OHISZPOJ.js +0 -97
- package/dist/chunk-OHISZPOJ.js.map +0 -1
- package/dist/chunk-OU5CQKNW.js +0 -102
- package/dist/chunk-OU5CQKNW.js.map +0 -1
- package/dist/chunk-PF7GRZMW.js +0 -2712
- package/dist/chunk-PF7GRZMW.js.map +0 -1
- package/dist/chunk-PHOUUNK7.js +0 -2291
- package/dist/chunk-PHOUUNK7.js.map +0 -1
- package/dist/chunk-RNHBMHKA.js +0 -1665
- package/dist/chunk-RNHBMHKA.js.map +0 -1
- package/dist/chunk-SX52TAR4.js +0 -110
- package/dist/chunk-SX52TAR4.js.map +0 -1
- package/dist/chunk-VYPWMZ6H.js +0 -98
- package/dist/chunk-VYPWMZ6H.js.map +0 -1
- package/dist/chunk-WBZOVTYK.js +0 -171
- package/dist/chunk-WBZOVTYK.js.map +0 -1
- package/dist/chunk-WKNUIZOY.js +0 -354
- package/dist/chunk-WKNUIZOY.js.map +0 -1
- package/dist/chunk-X3VMZYBT.js +0 -713
- package/dist/chunk-X3VMZYBT.js.map +0 -1
- package/dist/chunk-X5R3GL6H.js +0 -525
- package/dist/chunk-X5R3GL6H.js.map +0 -1
- package/dist/chunk-XGPU467M.js +0 -136
- package/dist/chunk-XGPU467M.js.map +0 -1
- package/dist/compat/index.cjs.map +0 -1
- package/dist/compat/index.js.map +0 -1
- package/dist/compat/jotai/index.cjs.map +0 -1
- package/dist/compat/jotai/index.js.map +0 -1
- package/dist/compat/nanostores/index.cjs.map +0 -1
- package/dist/compat/nanostores/index.js.map +0 -1
- package/dist/compat/nestjs/index.cjs.map +0 -1
- package/dist/compat/nestjs/index.js.map +0 -1
- package/dist/compat/react/index.cjs.map +0 -1
- package/dist/compat/react/index.js.map +0 -1
- package/dist/compat/solid/index.cjs.map +0 -1
- package/dist/compat/solid/index.js.map +0 -1
- package/dist/compat/svelte/index.cjs.map +0 -1
- package/dist/compat/svelte/index.js.map +0 -1
- package/dist/compat/vue/index.cjs.map +0 -1
- package/dist/compat/vue/index.js.map +0 -1
- package/dist/compat/zustand/index.cjs.map +0 -1
- package/dist/compat/zustand/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.js.map +0 -1
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/patterns/ai.cjs +0 -7930
- package/dist/patterns/ai.cjs.map +0 -1
- package/dist/patterns/ai.d.cts +0 -10
- package/dist/patterns/ai.d.ts +0 -10
- package/dist/patterns/ai.js +0 -71
- package/dist/patterns/ai.js.map +0 -1
- package/dist/patterns/audit.cjs +0 -5805
- package/dist/patterns/audit.cjs.map +0 -1
- package/dist/patterns/audit.d.cts +0 -6
- package/dist/patterns/audit.d.ts +0 -6
- package/dist/patterns/audit.js +0 -29
- package/dist/patterns/audit.js.map +0 -1
- package/dist/patterns/demo-shell.cjs +0 -5604
- package/dist/patterns/demo-shell.cjs.map +0 -1
- package/dist/patterns/demo-shell.d.cts +0 -6
- package/dist/patterns/demo-shell.d.ts +0 -6
- package/dist/patterns/demo-shell.js +0 -15
- package/dist/patterns/demo-shell.js.map +0 -1
- package/dist/patterns/memory.cjs +0 -5283
- package/dist/patterns/memory.cjs.map +0 -1
- package/dist/patterns/memory.d.cts +0 -5
- package/dist/patterns/memory.d.ts +0 -5
- package/dist/patterns/memory.js +0 -20
- package/dist/patterns/memory.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/storage-CMjUUuxn.d.ts +0 -190
- package/dist/storage-DdWlZo6U.d.cts +0 -190
package/dist/extra/sources.cjs
CHANGED
|
@@ -1,2486 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/extra/sources.ts
|
|
21
|
-
var sources_exports = {};
|
|
22
|
-
__export(sources_exports, {
|
|
23
|
-
cached: () => cached,
|
|
24
|
-
empty: () => empty,
|
|
25
|
-
escapeRegexChar: () => escapeRegexChar,
|
|
26
|
-
firstValueFrom: () => firstValueFrom,
|
|
27
|
-
firstWhere: () => firstWhere,
|
|
28
|
-
forEach: () => forEach,
|
|
29
|
-
fromAny: () => fromAny,
|
|
30
|
-
fromAsyncIter: () => fromAsyncIter,
|
|
31
|
-
fromCron: () => fromCron,
|
|
32
|
-
fromEvent: () => fromEvent,
|
|
33
|
-
fromIter: () => fromIter,
|
|
34
|
-
fromPromise: () => fromPromise,
|
|
35
|
-
fromRaf: () => fromRaf,
|
|
36
|
-
fromTimer: () => fromTimer,
|
|
37
|
-
globToRegExp: () => globToRegExp,
|
|
38
|
-
keepalive: () => keepalive,
|
|
39
|
-
matchesAnyPattern: () => matchesAnyPattern,
|
|
40
|
-
never: () => never,
|
|
41
|
-
of: () => of,
|
|
42
|
-
reactiveCounter: () => reactiveCounter,
|
|
43
|
-
replay: () => replay,
|
|
44
|
-
share: () => share,
|
|
45
|
-
shareReplay: () => shareReplay,
|
|
46
|
-
throwError: () => throwError,
|
|
47
|
-
toArray: () => toArray
|
|
48
|
-
});
|
|
49
|
-
module.exports = __toCommonJS(sources_exports);
|
|
50
|
-
|
|
51
|
-
// src/core/clock.ts
|
|
52
|
-
function wallClockNs() {
|
|
53
|
-
return Date.now() * 1e6;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/core/messages.ts
|
|
57
|
-
var START = /* @__PURE__ */ Symbol.for("graphrefly/START");
|
|
58
|
-
var DATA = /* @__PURE__ */ Symbol.for("graphrefly/DATA");
|
|
59
|
-
var DIRTY = /* @__PURE__ */ Symbol.for("graphrefly/DIRTY");
|
|
60
|
-
var RESOLVED = /* @__PURE__ */ Symbol.for("graphrefly/RESOLVED");
|
|
61
|
-
var INVALIDATE = /* @__PURE__ */ Symbol.for("graphrefly/INVALIDATE");
|
|
62
|
-
var PAUSE = /* @__PURE__ */ Symbol.for("graphrefly/PAUSE");
|
|
63
|
-
var RESUME = /* @__PURE__ */ Symbol.for("graphrefly/RESUME");
|
|
64
|
-
var TEARDOWN = /* @__PURE__ */ Symbol.for("graphrefly/TEARDOWN");
|
|
65
|
-
var COMPLETE = /* @__PURE__ */ Symbol.for("graphrefly/COMPLETE");
|
|
66
|
-
var ERROR = /* @__PURE__ */ Symbol.for("graphrefly/ERROR");
|
|
67
|
-
var DIRTY_MSG = Object.freeze([DIRTY]);
|
|
68
|
-
var RESOLVED_MSG = Object.freeze([RESOLVED]);
|
|
69
|
-
var INVALIDATE_MSG = Object.freeze([INVALIDATE]);
|
|
70
|
-
var START_MSG = Object.freeze([START]);
|
|
71
|
-
var COMPLETE_MSG = Object.freeze([COMPLETE]);
|
|
72
|
-
var TEARDOWN_MSG = Object.freeze([TEARDOWN]);
|
|
73
|
-
var DIRTY_ONLY_BATCH = Object.freeze([DIRTY_MSG]);
|
|
74
|
-
var RESOLVED_ONLY_BATCH = Object.freeze([RESOLVED_MSG]);
|
|
75
|
-
var INVALIDATE_ONLY_BATCH = Object.freeze([INVALIDATE_MSG]);
|
|
76
|
-
var COMPLETE_ONLY_BATCH = Object.freeze([COMPLETE_MSG]);
|
|
77
|
-
var TEARDOWN_ONLY_BATCH = Object.freeze([TEARDOWN_MSG]);
|
|
78
|
-
|
|
79
|
-
// src/graph/codec.ts
|
|
80
|
-
var JsonCodec = {
|
|
81
|
-
name: "json",
|
|
82
|
-
version: 1,
|
|
83
|
-
contentType: "application/json",
|
|
84
|
-
encode(snapshot) {
|
|
85
|
-
const json = JSON.stringify(snapshot);
|
|
86
|
-
return new TextEncoder().encode(json);
|
|
87
|
-
},
|
|
88
|
-
decode(buffer, _codecVersion) {
|
|
89
|
-
const json = new TextDecoder().decode(buffer);
|
|
90
|
-
return JSON.parse(json);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
function registerBuiltinCodecs(config) {
|
|
94
|
-
config.registerCodec(JsonCodec);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/core/actor.ts
|
|
98
|
-
var DEFAULT_ACTOR = { type: "system", id: "" };
|
|
99
|
-
function normalizeActor(actor) {
|
|
100
|
-
if (actor == null) return DEFAULT_ACTOR;
|
|
101
|
-
const { type, id, ...rest } = actor;
|
|
102
|
-
return {
|
|
103
|
-
type: type ?? "system",
|
|
104
|
-
id: id ?? "",
|
|
105
|
-
...rest
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/core/batch.ts
|
|
110
|
-
var batchDepth = 0;
|
|
111
|
-
var flushInProgress = false;
|
|
112
|
-
var drainPhase2 = [];
|
|
113
|
-
var drainPhase3 = [];
|
|
114
|
-
var drainPhase4 = [];
|
|
115
|
-
var flushHooks = [];
|
|
116
|
-
function isBatching() {
|
|
117
|
-
return batchDepth > 0 || flushInProgress;
|
|
118
|
-
}
|
|
119
|
-
function isExplicitlyBatching() {
|
|
120
|
-
return batchDepth > 0;
|
|
121
|
-
}
|
|
122
|
-
function registerBatchFlushHook(hook) {
|
|
123
|
-
if (batchDepth > 0) {
|
|
124
|
-
flushHooks.push(hook);
|
|
125
|
-
} else {
|
|
126
|
-
hook();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function downWithBatch(sink, messages, tierOf) {
|
|
130
|
-
if (messages.length === 0) return;
|
|
131
|
-
if (messages.length === 1) {
|
|
132
|
-
const tier = tierOf(messages[0][0]);
|
|
133
|
-
if (tier < 3 || !isBatching()) {
|
|
134
|
-
sink(messages);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const queue = tier >= 5 ? drainPhase4 : tier === 4 ? drainPhase3 : drainPhase2;
|
|
138
|
-
queue.push(() => sink(messages));
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const n = messages.length;
|
|
142
|
-
let phase2Start = n;
|
|
143
|
-
let phase3Start = n;
|
|
144
|
-
let phase4Start = n;
|
|
145
|
-
let i = 0;
|
|
146
|
-
while (i < n && tierOf(messages[i][0]) < 3) i++;
|
|
147
|
-
phase2Start = i;
|
|
148
|
-
while (i < n && tierOf(messages[i][0]) === 3) i++;
|
|
149
|
-
phase3Start = i;
|
|
150
|
-
while (i < n && tierOf(messages[i][0]) === 4) i++;
|
|
151
|
-
phase4Start = i;
|
|
152
|
-
const batching = isBatching();
|
|
153
|
-
if (phase2Start > 0) {
|
|
154
|
-
const immediate = messages.slice(0, phase2Start);
|
|
155
|
-
sink(immediate);
|
|
156
|
-
}
|
|
157
|
-
if (phase3Start > phase2Start) {
|
|
158
|
-
const phase2 = messages.slice(phase2Start, phase3Start);
|
|
159
|
-
if (batching) drainPhase2.push(() => sink(phase2));
|
|
160
|
-
else sink(phase2);
|
|
161
|
-
}
|
|
162
|
-
if (phase4Start > phase3Start) {
|
|
163
|
-
const phase3 = messages.slice(phase3Start, phase4Start);
|
|
164
|
-
if (batching) drainPhase3.push(() => sink(phase3));
|
|
165
|
-
else sink(phase3);
|
|
166
|
-
}
|
|
167
|
-
if (n > phase4Start) {
|
|
168
|
-
const phase4 = messages.slice(phase4Start, n);
|
|
169
|
-
if (batching) drainPhase4.push(() => sink(phase4));
|
|
170
|
-
else sink(phase4);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// src/core/config.ts
|
|
175
|
-
var GraphReFlyConfig = class {
|
|
176
|
-
_messageTypes = /* @__PURE__ */ new Map();
|
|
177
|
-
_codecs = /* @__PURE__ */ new Map();
|
|
178
|
-
_onMessage;
|
|
179
|
-
_onSubscribe;
|
|
180
|
-
_defaultVersioning;
|
|
181
|
-
_defaultHashFn;
|
|
182
|
-
_inspectorEnabled = !(typeof process !== "undefined" && process.env?.NODE_ENV === "production");
|
|
183
|
-
_globalInspector;
|
|
184
|
-
_frozen = false;
|
|
185
|
-
/**
|
|
186
|
-
* Pre-bound tier lookup — shared by every node bound to this config. Since
|
|
187
|
-
* the registry is frozen on first hook access, this closure can be built
|
|
188
|
-
* once in the constructor and handed directly to `downWithBatch` /
|
|
189
|
-
* `_frameBatch` paths without per-node or per-emission `.bind(config)`
|
|
190
|
-
* allocation.
|
|
191
|
-
*/
|
|
192
|
-
tierOf;
|
|
193
|
-
constructor(init) {
|
|
194
|
-
this._onMessage = init.onMessage;
|
|
195
|
-
this._onSubscribe = init.onSubscribe;
|
|
196
|
-
this._defaultVersioning = init.defaultVersioning;
|
|
197
|
-
this._defaultHashFn = init.defaultHashFn;
|
|
198
|
-
this.tierOf = (t) => {
|
|
199
|
-
const reg = this._messageTypes.get(t);
|
|
200
|
-
return reg != null ? reg.tier : 1;
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
// --- Hook getters (freeze on read) ---
|
|
204
|
-
get onMessage() {
|
|
205
|
-
this._frozen = true;
|
|
206
|
-
return this._onMessage;
|
|
207
|
-
}
|
|
208
|
-
get onSubscribe() {
|
|
209
|
-
this._frozen = true;
|
|
210
|
-
return this._onSubscribe;
|
|
211
|
-
}
|
|
212
|
-
// --- Hook setters (throw when frozen) ---
|
|
213
|
-
set onMessage(v) {
|
|
214
|
-
this._assertUnfrozen();
|
|
215
|
-
this._onMessage = v;
|
|
216
|
-
}
|
|
217
|
-
set onSubscribe(v) {
|
|
218
|
-
this._assertUnfrozen();
|
|
219
|
-
this._onSubscribe = v;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Default versioning level applied to every node bound to this config,
|
|
223
|
-
* unless the node's own `opts.versioning` provides an explicit override.
|
|
224
|
-
* Setting this is only allowed before the config freezes (i.e., before
|
|
225
|
-
* the first node is created) so every node in the graph sees a
|
|
226
|
-
* consistent starting level. Individual nodes can still opt into a
|
|
227
|
-
* higher level via `opts.versioning`, or post-hoc via
|
|
228
|
-
* `NodeImpl._applyVersioning(level)` when the node is quiescent.
|
|
229
|
-
*
|
|
230
|
-
* v0 is the minimum opt-in — unversioned nodes (`undefined`) skip
|
|
231
|
-
* the version counter entirely. v1 adds content-addressed cid.
|
|
232
|
-
* Future levels (v2, v3) are reserved for linked-history and
|
|
233
|
-
* cryptographic attestation extensions.
|
|
234
|
-
*/
|
|
235
|
-
get defaultVersioning() {
|
|
236
|
-
return this._defaultVersioning;
|
|
237
|
-
}
|
|
238
|
-
set defaultVersioning(v) {
|
|
239
|
-
this._assertUnfrozen();
|
|
240
|
-
this._defaultVersioning = v;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Default content-hash function applied to every versioned node bound
|
|
244
|
-
* to this config, unless the node's own `opts.versioningHash` provides
|
|
245
|
-
* an explicit override. Use this when a graph needs a non-default hash
|
|
246
|
-
* — e.g., swap the vendored sync SHA-256 for a faster non-crypto hash
|
|
247
|
-
* (xxHash, FNV-1a) in hot-path workloads, or a stronger hash when
|
|
248
|
-
* versioning v1 cids are used as audit anchors.
|
|
249
|
-
*
|
|
250
|
-
* Only settable before the config freezes. Individual nodes can still
|
|
251
|
-
* override via `opts.versioningHash`.
|
|
252
|
-
*/
|
|
253
|
-
get defaultHashFn() {
|
|
254
|
-
return this._defaultHashFn;
|
|
255
|
-
}
|
|
256
|
-
set defaultHashFn(v) {
|
|
257
|
-
this._assertUnfrozen();
|
|
258
|
-
this._defaultHashFn = v;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* When `false`, structured observation options (`causal`, `timeline`)
|
|
262
|
-
* and `Graph.trace()` writes are no-ops. Raw `Graph.observe()` always
|
|
263
|
-
* works. Default: `true` outside production (`NODE_ENV !== "production"`).
|
|
264
|
-
*
|
|
265
|
-
* Settable at any time — inspector gating is an operational concern, not
|
|
266
|
-
* a protocol invariant, so it does NOT require freeze before node creation.
|
|
267
|
-
*/
|
|
268
|
-
get inspectorEnabled() {
|
|
269
|
-
return this._inspectorEnabled;
|
|
270
|
-
}
|
|
271
|
-
set inspectorEnabled(v) {
|
|
272
|
-
this._inspectorEnabled = v;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Process-global observability hook (Redux-DevTools-style full-graph
|
|
276
|
-
* tracer). Fires once per outgoing batch from every node bound to this
|
|
277
|
-
* config, gated by {@link inspectorEnabled}. See {@link GlobalInspectorHook}.
|
|
278
|
-
*
|
|
279
|
-
* Settable at any time — like {@link inspectorEnabled} this is operational,
|
|
280
|
-
* not protocol-shaping, so it does NOT trigger config freeze.
|
|
281
|
-
*/
|
|
282
|
-
get globalInspector() {
|
|
283
|
-
return this._globalInspector;
|
|
284
|
-
}
|
|
285
|
-
set globalInspector(v) {
|
|
286
|
-
this._globalInspector = v;
|
|
287
|
-
}
|
|
288
|
-
// --- Registry (writes require unfrozen; reads are free lookups) ---
|
|
289
|
-
/**
|
|
290
|
-
* Register a custom message type. Must be called before any node that
|
|
291
|
-
* uses this config has been created — otherwise throws. Default
|
|
292
|
-
* `wireCrossing` is `tier >= 3`.
|
|
293
|
-
*/
|
|
294
|
-
registerMessageType(t, input) {
|
|
295
|
-
this._assertUnfrozen();
|
|
296
|
-
this._messageTypes.set(t, {
|
|
297
|
-
tier: input.tier,
|
|
298
|
-
wireCrossing: input.wireCrossing ?? input.tier >= 3,
|
|
299
|
-
metaPassthrough: input.metaPassthrough ?? true
|
|
300
|
-
});
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
/** Tier for `t`. Unknown types default to tier 1 (immediate, after START). */
|
|
304
|
-
messageTier(t) {
|
|
305
|
-
const reg = this._messageTypes.get(t);
|
|
306
|
-
return reg != null ? reg.tier : 1;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Whether `t` is registered as wire-crossing. Unknown types default to
|
|
310
|
-
* `true` (spec §1.3.6 forward-compat — unknowns cross the wire).
|
|
311
|
-
*/
|
|
312
|
-
isWireCrossing(t) {
|
|
313
|
-
const reg = this._messageTypes.get(t);
|
|
314
|
-
return reg != null ? reg.wireCrossing : true;
|
|
315
|
-
}
|
|
316
|
-
/** Convenience inverse of {@link isWireCrossing}. */
|
|
317
|
-
isLocalOnly(t) {
|
|
318
|
-
return !this.isWireCrossing(t);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Whether `t` is forwarded to meta companions by `Graph.signal`. Defaults
|
|
322
|
-
* to `true` for unknowns (forward-compat — new types pass through meta by
|
|
323
|
-
* default; opt-in filter via `registerMessageType({metaPassthrough: false})`).
|
|
324
|
-
*/
|
|
325
|
-
isMetaPassthrough(t) {
|
|
326
|
-
const reg = this._messageTypes.get(t);
|
|
327
|
-
return reg != null ? reg.metaPassthrough : true;
|
|
328
|
-
}
|
|
329
|
-
/** Whether `t` is a registered (built-in or custom) type. */
|
|
330
|
-
isKnownMessageType(t) {
|
|
331
|
-
return this._messageTypes.has(t);
|
|
332
|
-
}
|
|
333
|
-
// --- Codec registry (writes require unfrozen; reads are free lookups) ---
|
|
334
|
-
/**
|
|
335
|
-
* Register a graph codec by `codec.name`. Used by the envelope-based
|
|
336
|
-
* `graph.snapshot({format: "bytes", codec: name})` path and
|
|
337
|
-
* `Graph.decode(bytes)` auto-dispatch. Must be called before any node
|
|
338
|
-
* bound to this config is created — otherwise throws.
|
|
339
|
-
*
|
|
340
|
-
* Re-registering the same name overwrites, so user codecs can shadow
|
|
341
|
-
* built-in ones before freeze (e.g., to swap a zstd-wrapped dag-cbor in
|
|
342
|
-
* for `"dag-cbor"`).
|
|
343
|
-
*/
|
|
344
|
-
registerCodec(codec) {
|
|
345
|
-
this._assertUnfrozen();
|
|
346
|
-
this._codecs.set(codec.name, codec);
|
|
347
|
-
return this;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Resolve a registered codec by name. Returns `undefined` for unknown
|
|
351
|
-
* names. Typed callers cast to their concrete codec interface (e.g.,
|
|
352
|
-
* `config.lookupCodec<GraphCodec>("json")`) — this method stays
|
|
353
|
-
* layer-pure (no import of graph-layer types into `core/`).
|
|
354
|
-
*/
|
|
355
|
-
lookupCodec(name) {
|
|
356
|
-
return this._codecs.get(name);
|
|
357
|
-
}
|
|
358
|
-
/** @internal Used by tests and dev tooling — check freeze state without triggering it. */
|
|
359
|
-
_isFrozen() {
|
|
360
|
-
return this._frozen;
|
|
361
|
-
}
|
|
362
|
-
_assertUnfrozen() {
|
|
363
|
-
if (this._frozen) {
|
|
364
|
-
throw new Error(
|
|
365
|
-
"GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node."
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
function registerBuiltins(cfg) {
|
|
371
|
-
cfg.registerMessageType(START, { tier: 0, wireCrossing: false });
|
|
372
|
-
cfg.registerMessageType(DIRTY, { tier: 1, wireCrossing: false });
|
|
373
|
-
cfg.registerMessageType(INVALIDATE, {
|
|
374
|
-
tier: 1,
|
|
375
|
-
wireCrossing: false,
|
|
376
|
-
metaPassthrough: false
|
|
377
|
-
});
|
|
378
|
-
cfg.registerMessageType(PAUSE, { tier: 2, wireCrossing: false });
|
|
379
|
-
cfg.registerMessageType(RESUME, { tier: 2, wireCrossing: false });
|
|
380
|
-
cfg.registerMessageType(DATA, { tier: 3, wireCrossing: true });
|
|
381
|
-
cfg.registerMessageType(RESOLVED, { tier: 3, wireCrossing: true });
|
|
382
|
-
cfg.registerMessageType(COMPLETE, {
|
|
383
|
-
tier: 4,
|
|
384
|
-
wireCrossing: true,
|
|
385
|
-
metaPassthrough: false
|
|
386
|
-
});
|
|
387
|
-
cfg.registerMessageType(ERROR, {
|
|
388
|
-
tier: 4,
|
|
389
|
-
wireCrossing: true,
|
|
390
|
-
metaPassthrough: false
|
|
391
|
-
});
|
|
392
|
-
cfg.registerMessageType(TEARDOWN, {
|
|
393
|
-
tier: 5,
|
|
394
|
-
wireCrossing: true,
|
|
395
|
-
metaPassthrough: false
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// src/core/guard.ts
|
|
400
|
-
var GuardDenied = class extends Error {
|
|
401
|
-
actor;
|
|
402
|
-
action;
|
|
403
|
-
nodeName;
|
|
404
|
-
/**
|
|
405
|
-
* @param details - Actor, action, and optional node name for the denial.
|
|
406
|
-
* @param message - Optional override for the default error message.
|
|
407
|
-
*/
|
|
408
|
-
constructor(details, message) {
|
|
409
|
-
super(
|
|
410
|
-
message ?? `GuardDenied: action "${String(details.action)}" denied for actor type "${String(details.actor.type)}"`
|
|
411
|
-
);
|
|
412
|
-
this.name = "GuardDenied";
|
|
413
|
-
this.actor = details.actor;
|
|
414
|
-
this.action = details.action;
|
|
415
|
-
this.nodeName = details.nodeName;
|
|
416
|
-
}
|
|
417
|
-
/** Qualified registry path when known (roadmap diagnostics: same as {@link nodeName}). */
|
|
418
|
-
get node() {
|
|
419
|
-
return this.nodeName;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
// src/core/versioning.ts
|
|
424
|
-
function canonicalizeForHash(value) {
|
|
425
|
-
if (value === void 0) return null;
|
|
426
|
-
if (typeof value === "number") {
|
|
427
|
-
if (!Number.isFinite(value)) {
|
|
428
|
-
throw new TypeError(`Cannot hash non-finite number: ${value}`);
|
|
429
|
-
}
|
|
430
|
-
if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
|
|
431
|
-
throw new TypeError(
|
|
432
|
-
`Cannot hash integer outside safe range (|n| > 2^53-1): ${value}. Cross-language cid parity is not guaranteed for unsafe integers.`
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
return value;
|
|
436
|
-
}
|
|
437
|
-
if (typeof value === "string" || typeof value === "boolean" || value === null) {
|
|
438
|
-
return value;
|
|
439
|
-
}
|
|
440
|
-
if (Array.isArray(value)) {
|
|
441
|
-
return value.map(canonicalizeForHash);
|
|
442
|
-
}
|
|
443
|
-
if (typeof value === "object" && value !== null) {
|
|
444
|
-
const sorted = {};
|
|
445
|
-
for (const k of Object.keys(value).sort()) {
|
|
446
|
-
sorted[k] = canonicalizeForHash(value[k]);
|
|
447
|
-
}
|
|
448
|
-
return sorted;
|
|
449
|
-
}
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
453
|
-
1116352408,
|
|
454
|
-
1899447441,
|
|
455
|
-
3049323471,
|
|
456
|
-
3921009573,
|
|
457
|
-
961987163,
|
|
458
|
-
1508970993,
|
|
459
|
-
2453635748,
|
|
460
|
-
2870763221,
|
|
461
|
-
3624381080,
|
|
462
|
-
310598401,
|
|
463
|
-
607225278,
|
|
464
|
-
1426881987,
|
|
465
|
-
1925078388,
|
|
466
|
-
2162078206,
|
|
467
|
-
2614888103,
|
|
468
|
-
3248222580,
|
|
469
|
-
3835390401,
|
|
470
|
-
4022224774,
|
|
471
|
-
264347078,
|
|
472
|
-
604807628,
|
|
473
|
-
770255983,
|
|
474
|
-
1249150122,
|
|
475
|
-
1555081692,
|
|
476
|
-
1996064986,
|
|
477
|
-
2554220882,
|
|
478
|
-
2821834349,
|
|
479
|
-
2952996808,
|
|
480
|
-
3210313671,
|
|
481
|
-
3336571891,
|
|
482
|
-
3584528711,
|
|
483
|
-
113926993,
|
|
484
|
-
338241895,
|
|
485
|
-
666307205,
|
|
486
|
-
773529912,
|
|
487
|
-
1294757372,
|
|
488
|
-
1396182291,
|
|
489
|
-
1695183700,
|
|
490
|
-
1986661051,
|
|
491
|
-
2177026350,
|
|
492
|
-
2456956037,
|
|
493
|
-
2730485921,
|
|
494
|
-
2820302411,
|
|
495
|
-
3259730800,
|
|
496
|
-
3345764771,
|
|
497
|
-
3516065817,
|
|
498
|
-
3600352804,
|
|
499
|
-
4094571909,
|
|
500
|
-
275423344,
|
|
501
|
-
430227734,
|
|
502
|
-
506948616,
|
|
503
|
-
659060556,
|
|
504
|
-
883997877,
|
|
505
|
-
958139571,
|
|
506
|
-
1322822218,
|
|
507
|
-
1537002063,
|
|
508
|
-
1747873779,
|
|
509
|
-
1955562222,
|
|
510
|
-
2024104815,
|
|
511
|
-
2227730452,
|
|
512
|
-
2361852424,
|
|
513
|
-
2428436474,
|
|
514
|
-
2756734187,
|
|
515
|
-
3204031479,
|
|
516
|
-
3329325298
|
|
517
|
-
]);
|
|
518
|
-
var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
|
|
519
|
-
function sha256Hex(msg) {
|
|
520
|
-
const bytes = UTF8_ENCODER.encode(msg);
|
|
521
|
-
const msgLen = bytes.length;
|
|
522
|
-
const bitLen = msgLen * 8;
|
|
523
|
-
const totalLen = msgLen + 9 + 63 & ~63;
|
|
524
|
-
const padded = new Uint8Array(totalLen);
|
|
525
|
-
padded.set(bytes);
|
|
526
|
-
padded[msgLen] = 128;
|
|
527
|
-
const dv = new DataView(padded.buffer);
|
|
528
|
-
dv.setUint32(totalLen - 4, bitLen >>> 0, false);
|
|
529
|
-
dv.setUint32(totalLen - 8, Math.floor(bitLen / 4294967296) >>> 0, false);
|
|
530
|
-
let h0 = 1779033703;
|
|
531
|
-
let h1 = 3144134277;
|
|
532
|
-
let h2 = 1013904242;
|
|
533
|
-
let h3 = 2773480762;
|
|
534
|
-
let h4 = 1359893119;
|
|
535
|
-
let h5 = 2600822924;
|
|
536
|
-
let h6 = 528734635;
|
|
537
|
-
let h7 = 1541459225;
|
|
538
|
-
const W = new Uint32Array(64);
|
|
539
|
-
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
540
|
-
for (let off = 0; off < totalLen; off += 64) {
|
|
541
|
-
for (let i = 0; i < 16; i++) W[i] = dv.getUint32(off + i * 4, false);
|
|
542
|
-
for (let i = 16; i < 64; i++) {
|
|
543
|
-
const w15 = W[i - 15];
|
|
544
|
-
const w2 = W[i - 2];
|
|
545
|
-
const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ w15 >>> 3;
|
|
546
|
-
const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ w2 >>> 10;
|
|
547
|
-
W[i] = W[i - 16] + s0 + W[i - 7] + s1 >>> 0;
|
|
548
|
-
}
|
|
549
|
-
let a = h0;
|
|
550
|
-
let b = h1;
|
|
551
|
-
let c = h2;
|
|
552
|
-
let d = h3;
|
|
553
|
-
let e = h4;
|
|
554
|
-
let f = h5;
|
|
555
|
-
let g = h6;
|
|
556
|
-
let h = h7;
|
|
557
|
-
for (let i = 0; i < 64; i++) {
|
|
558
|
-
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
559
|
-
const ch = e & f ^ ~e & g;
|
|
560
|
-
const t1 = h + S1 + ch + SHA256_K[i] + W[i] >>> 0;
|
|
561
|
-
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
562
|
-
const mj = a & b ^ a & c ^ b & c;
|
|
563
|
-
const t2 = S0 + mj >>> 0;
|
|
564
|
-
h = g;
|
|
565
|
-
g = f;
|
|
566
|
-
f = e;
|
|
567
|
-
e = d + t1 >>> 0;
|
|
568
|
-
d = c;
|
|
569
|
-
c = b;
|
|
570
|
-
b = a;
|
|
571
|
-
a = t1 + t2 >>> 0;
|
|
572
|
-
}
|
|
573
|
-
h0 = h0 + a >>> 0;
|
|
574
|
-
h1 = h1 + b >>> 0;
|
|
575
|
-
h2 = h2 + c >>> 0;
|
|
576
|
-
h3 = h3 + d >>> 0;
|
|
577
|
-
h4 = h4 + e >>> 0;
|
|
578
|
-
h5 = h5 + f >>> 0;
|
|
579
|
-
h6 = h6 + g >>> 0;
|
|
580
|
-
h7 = h7 + h >>> 0;
|
|
581
|
-
}
|
|
582
|
-
const toHex = (x) => x.toString(16).padStart(8, "0");
|
|
583
|
-
return toHex(h0) + toHex(h1) + toHex(h2) + toHex(h3) + toHex(h4) + toHex(h5) + toHex(h6) + toHex(h7);
|
|
584
|
-
}
|
|
585
|
-
function defaultHash(value) {
|
|
586
|
-
const canonical = canonicalizeForHash(value ?? null);
|
|
587
|
-
const json = JSON.stringify(canonical);
|
|
588
|
-
return sha256Hex(json).slice(0, 16);
|
|
589
|
-
}
|
|
590
|
-
function randomUuid() {
|
|
591
|
-
const c = globalThis.crypto;
|
|
592
|
-
if (c?.randomUUID) return c.randomUUID();
|
|
593
|
-
const r = () => Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
|
594
|
-
const hex = r() + r() + r() + r();
|
|
595
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-${(parseInt(hex.slice(16, 17), 16) & 3 | 8).toString(16)}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
596
|
-
}
|
|
597
|
-
function createVersioning(level, initialValue, opts) {
|
|
598
|
-
const id = opts?.id ?? randomUuid();
|
|
599
|
-
if (level === 0) {
|
|
600
|
-
return { id, version: 0 };
|
|
601
|
-
}
|
|
602
|
-
const hash = opts?.hash ?? defaultHash;
|
|
603
|
-
const cid = hash(initialValue);
|
|
604
|
-
return { id, version: 0, cid, prev: null };
|
|
605
|
-
}
|
|
606
|
-
function advanceVersion(info, newValue, hashFn) {
|
|
607
|
-
info.version += 1;
|
|
608
|
-
if ("cid" in info) {
|
|
609
|
-
info.prev = info.cid;
|
|
610
|
-
info.cid = hashFn(newValue);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// src/core/node.ts
|
|
615
|
-
var noopUnsub = () => {
|
|
616
|
-
};
|
|
617
|
-
var MAX_RERUN_DEPTH = 100;
|
|
618
|
-
function createDepRecord(n) {
|
|
619
|
-
return {
|
|
620
|
-
node: n,
|
|
621
|
-
unsub: null,
|
|
622
|
-
prevData: void 0,
|
|
623
|
-
dirty: false,
|
|
624
|
-
involvedThisWave: false,
|
|
625
|
-
dataBatch: [],
|
|
626
|
-
terminal: void 0
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
function resetDepRecord(d) {
|
|
630
|
-
d.prevData = void 0;
|
|
631
|
-
d.dirty = false;
|
|
632
|
-
d.involvedThisWave = false;
|
|
633
|
-
d.dataBatch.length = 0;
|
|
634
|
-
d.terminal = void 0;
|
|
635
|
-
}
|
|
636
|
-
function normalizeMessages(input) {
|
|
637
|
-
if (input.length === 0) return input;
|
|
638
|
-
return typeof input[0] === "symbol" ? [input] : input;
|
|
639
|
-
}
|
|
640
|
-
var defaultOnMessage = (node2, msg, ctx, _actions) => {
|
|
641
|
-
if (ctx.direction === "down-in") {
|
|
642
|
-
node2._onDepMessage(ctx.depIndex, msg);
|
|
643
|
-
}
|
|
644
|
-
return void 0;
|
|
645
|
-
};
|
|
646
|
-
var defaultOnSubscribe = (node2, sink, _ctx, _actions) => {
|
|
647
|
-
const impl = node2;
|
|
648
|
-
if (impl._status === "completed" || impl._status === "errored") return;
|
|
649
|
-
const cached2 = impl._cached;
|
|
650
|
-
const initial = cached2 === void 0 ? [START_MSG] : [START_MSG, [DATA, cached2]];
|
|
651
|
-
if (impl._status === "dirty") initial.push(DIRTY_MSG);
|
|
652
|
-
downWithBatch(sink, initial, impl._config.tierOf);
|
|
653
|
-
};
|
|
654
|
-
var defaultConfig = new GraphReFlyConfig({
|
|
655
|
-
onMessage: defaultOnMessage,
|
|
656
|
-
onSubscribe: defaultOnSubscribe
|
|
657
|
-
});
|
|
658
|
-
registerBuiltins(defaultConfig);
|
|
659
|
-
registerBuiltinCodecs(defaultConfig);
|
|
660
|
-
var NodeImpl = class _NodeImpl {
|
|
661
|
-
// --- Identity ---
|
|
662
|
-
_optsName;
|
|
663
|
-
_describeKind;
|
|
664
|
-
meta;
|
|
665
|
-
/**
|
|
666
|
-
* Cached `Object.keys(meta).length > 0` check. `meta` is frozen at
|
|
667
|
-
* construction so this boolean never flips. Used by `_emit` to skip
|
|
668
|
-
* the meta TEARDOWN fan-out block allocation on the common "no meta"
|
|
669
|
-
* hot path.
|
|
670
|
-
*/
|
|
671
|
-
_hasMeta;
|
|
672
|
-
// --- Config ---
|
|
673
|
-
_config;
|
|
674
|
-
// --- Topology ---
|
|
675
|
-
/** Mutable for autoTrackNode / Graph.connect() post-construction dep addition. */
|
|
676
|
-
_deps;
|
|
677
|
-
_sinks = null;
|
|
678
|
-
_sinkCount = 0;
|
|
679
|
-
// --- State ---
|
|
680
|
-
_cached;
|
|
681
|
-
_status;
|
|
682
|
-
_cleanup;
|
|
683
|
-
_store = {};
|
|
684
|
-
_waveHasNewData = false;
|
|
685
|
-
_hasNewTerminal = false;
|
|
686
|
-
_hasCalledFnOnce = false;
|
|
687
|
-
_paused = false;
|
|
688
|
-
_pendingWave = false;
|
|
689
|
-
_isExecutingFn = false;
|
|
690
|
-
_pendingRerun = false;
|
|
691
|
-
_rerunDepth = 0;
|
|
692
|
-
// --- Settlement counter (A3) ---
|
|
693
|
-
/**
|
|
694
|
-
* Count of deps currently in `dirty === true`. `_maybeRunFnOnSettlement`
|
|
695
|
-
* treats `0` as "wave settled" — O(1) check for full dep settlement.
|
|
696
|
-
*/
|
|
697
|
-
_dirtyDepCount = 0;
|
|
698
|
-
// --- Per-batch emit accumulator (Bug 2: K+1 fan-in fix) ---
|
|
699
|
-
/**
|
|
700
|
-
* Inside an explicit `batch(() => ...)` scope, every `_emit` accumulates
|
|
701
|
-
* its already-framed messages here instead of dispatching synchronously.
|
|
702
|
-
* At batch end, `_flushBatchPending` runs (registered via
|
|
703
|
-
* `registerBatchFlushHook`) and delivers the whole accumulated batch as
|
|
704
|
-
* one `downWithBatch` call — collapsing what would otherwise be K
|
|
705
|
-
* separate sink invocations into one. This is the fix for the diamond
|
|
706
|
-
* fan-in K+1 over-fire.
|
|
707
|
-
*
|
|
708
|
-
* `null` outside batch (or after flush). Only ever appended to within
|
|
709
|
-
* a single explicit batch lifetime; reset to `null` on flush. State
|
|
710
|
-
* updates (cache, version, status) still happen per-emit via
|
|
711
|
-
* `_updateState` — only the downstream delivery is coalesced.
|
|
712
|
-
*/
|
|
713
|
-
_batchPendingMessages = null;
|
|
714
|
-
// --- PAUSE/RESUME lock tracking (C0) ---
|
|
715
|
-
/**
|
|
716
|
-
* Set of active pause locks held against this node. Every `[PAUSE, lockId]`
|
|
717
|
-
* adds its `lockId` to the set; every `[RESUME, lockId]` removes it.
|
|
718
|
-
* `_paused` is a derived quantity: `_pauseLocks.size > 0`. Multi-pauser
|
|
719
|
-
* correctness — one controller releasing its lock does NOT resume the
|
|
720
|
-
* node while another controller still holds its lock.
|
|
721
|
-
*/
|
|
722
|
-
_pauseLocks = null;
|
|
723
|
-
/**
|
|
724
|
-
* Buffered DATA messages held while paused. Only populated when
|
|
725
|
-
* `_pausable === "resumeAll"` (bufferAll mode). On final lock release
|
|
726
|
-
* the buffer is replayed through the node's outgoing pipeline in the
|
|
727
|
-
* order received. Non-bufferAll pause mode drops DATA on the floor
|
|
728
|
-
* (upstream is expected to honor PAUSE by suppressing production).
|
|
729
|
-
*/
|
|
730
|
-
_pauseBuffer = null;
|
|
731
|
-
// --- Options (frozen at construction) ---
|
|
732
|
-
_fn;
|
|
733
|
-
_equals;
|
|
734
|
-
_resubscribable;
|
|
735
|
-
_resetOnTeardown;
|
|
736
|
-
_autoComplete;
|
|
737
|
-
_autoError;
|
|
738
|
-
_pausable;
|
|
739
|
-
_guard;
|
|
740
|
-
/**
|
|
741
|
-
* @internal Additional guards stacked at runtime via {@link NodeImpl._pushGuard}
|
|
742
|
-
* (e.g. by `policyEnforcer({ mode: "enforce" })`, roadmap §9.2). Effective
|
|
743
|
-
* write/signal/observe checks AND the original `_guard` with every entry here.
|
|
744
|
-
*/
|
|
745
|
-
_extraGuards;
|
|
746
|
-
_hashFn;
|
|
747
|
-
_versioning;
|
|
748
|
-
/**
|
|
749
|
-
* Explicit versioning level, tracked separately from `_versioning` so
|
|
750
|
-
* monotonicity checks and future v2/v3 extensions don't rely on the
|
|
751
|
-
* fragile `"cid" in _versioning` shape discriminator. `undefined` means
|
|
752
|
-
* the node has no versioning attached; `0` / `1` / future levels name
|
|
753
|
-
* the tier. Mutated in lockstep with `_versioning` by the constructor
|
|
754
|
-
* and by `_applyVersioning`.
|
|
755
|
-
*/
|
|
756
|
-
_versioningLevel;
|
|
757
|
-
// --- ABAC ---
|
|
758
|
-
_lastMutation;
|
|
759
|
-
/**
|
|
760
|
-
* @internal Per-node inspector hooks for `Graph.observe(path,
|
|
761
|
-
* { causal, derived })`. Fires in `_onDepMessage` and `_execFn`.
|
|
762
|
-
* Attached via `_setInspectorHook` (returns a disposer). Multiple
|
|
763
|
-
* observers can attach simultaneously — all registered hooks fire for
|
|
764
|
-
* every event.
|
|
765
|
-
*/
|
|
766
|
-
_inspectorHooks;
|
|
767
|
-
// --- Actions (built once in the constructor) ---
|
|
768
|
-
_actions;
|
|
769
|
-
constructor(deps, fn, opts) {
|
|
770
|
-
this._config = opts.config ?? defaultConfig;
|
|
771
|
-
void this._config.onMessage;
|
|
772
|
-
this._optsName = opts.name;
|
|
773
|
-
this._describeKind = opts.describeKind;
|
|
774
|
-
this._equals = opts.equals ?? Object.is;
|
|
775
|
-
this._resubscribable = opts.resubscribable ?? false;
|
|
776
|
-
this._resetOnTeardown = opts.resetOnTeardown ?? false;
|
|
777
|
-
this._autoComplete = opts.completeWhenDepsComplete ?? true;
|
|
778
|
-
this._autoError = opts.errorWhenDepsError ?? true;
|
|
779
|
-
this._pausable = opts.pausable ?? true;
|
|
780
|
-
this._guard = opts.guard;
|
|
781
|
-
this._fn = fn;
|
|
782
|
-
this._cached = opts.initial !== void 0 ? opts.initial : void 0;
|
|
783
|
-
this._status = deps.length === 0 && fn == null && this._cached !== void 0 ? "settled" : "sentinel";
|
|
784
|
-
this._hashFn = opts.versioningHash ?? this._config.defaultHashFn ?? defaultHash;
|
|
785
|
-
const versioningLevel = opts.versioning ?? this._config.defaultVersioning;
|
|
786
|
-
this._versioningLevel = versioningLevel;
|
|
787
|
-
this._versioning = versioningLevel != null ? createVersioning(versioningLevel, this._cached === void 0 ? void 0 : this._cached, {
|
|
788
|
-
id: opts.versioningId,
|
|
789
|
-
hash: this._hashFn
|
|
790
|
-
}) : void 0;
|
|
791
|
-
this._deps = deps.map(createDepRecord);
|
|
792
|
-
const meta = {};
|
|
793
|
-
for (const [k, v] of Object.entries(opts.meta ?? {})) {
|
|
794
|
-
const metaOpts = {
|
|
795
|
-
initial: v,
|
|
796
|
-
name: `${opts.name ?? "node"}:meta:${k}`,
|
|
797
|
-
describeKind: "state",
|
|
798
|
-
config: this._config
|
|
799
|
-
};
|
|
800
|
-
if (opts.guard != null) metaOpts.guard = opts.guard;
|
|
801
|
-
meta[k] = new _NodeImpl([], void 0, metaOpts);
|
|
802
|
-
}
|
|
803
|
-
Object.freeze(meta);
|
|
804
|
-
this.meta = meta;
|
|
805
|
-
this._hasMeta = Object.keys(meta).length > 0;
|
|
806
|
-
const self = this;
|
|
807
|
-
this._actions = {
|
|
808
|
-
emit(value) {
|
|
809
|
-
self._emit([[DATA, value]]);
|
|
810
|
-
},
|
|
811
|
-
down(messageOrMessages) {
|
|
812
|
-
self._emit(normalizeMessages(messageOrMessages));
|
|
813
|
-
},
|
|
814
|
-
up(messageOrMessages) {
|
|
815
|
-
self._emitUp(normalizeMessages(messageOrMessages));
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
this.down = this.down.bind(this);
|
|
819
|
-
this.up = this.up.bind(this);
|
|
820
|
-
}
|
|
821
|
-
// --- Derived state ---
|
|
822
|
-
get _isTerminal() {
|
|
823
|
-
return this._status === "completed" || this._status === "errored";
|
|
824
|
-
}
|
|
825
|
-
// --- Public getters ---
|
|
826
|
-
get name() {
|
|
827
|
-
return this._optsName;
|
|
828
|
-
}
|
|
829
|
-
get status() {
|
|
830
|
-
return this._status;
|
|
831
|
-
}
|
|
832
|
-
get cache() {
|
|
833
|
-
return this._cached === void 0 ? void 0 : this._cached;
|
|
834
|
-
}
|
|
835
|
-
get lastMutation() {
|
|
836
|
-
return this._lastMutation;
|
|
837
|
-
}
|
|
838
|
-
get v() {
|
|
839
|
-
return this._versioning;
|
|
840
|
-
}
|
|
841
|
-
hasGuard() {
|
|
842
|
-
return this._guard != null;
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* @internal Retroactively attach (or upgrade) versioning state on this
|
|
846
|
-
* node. Intended for `Graph.setVersioning(level)` bulk application and
|
|
847
|
-
* for rare cases where a specific node needs to be bumped to a higher
|
|
848
|
-
* level (e.g., `v0 → v1`) after construction.
|
|
849
|
-
*
|
|
850
|
-
* **Safety:** the mutation is rejected mid-wave. Specifically,
|
|
851
|
-
* throws if the node is currently executing its fn (`_isExecutingFn`).
|
|
852
|
-
* Callers at quiescent points — before the first sink subscribes, or
|
|
853
|
-
* after all sinks unsubscribe, or between external `down()` / `emit()`
|
|
854
|
-
* invocations — are safe. The re-entrance window that motivated §10.6.4
|
|
855
|
-
* removal was the "transition `_versioning` from `undefined` to a fresh
|
|
856
|
-
* object mid-`_updateState`" case; that path is now guarded.
|
|
857
|
-
*
|
|
858
|
-
* **Monotonicity:** levels can only go up. Downgrade (e.g., `v1 → v0`)
|
|
859
|
-
* is a no-op — once a node carries higher-level metadata, dropping it
|
|
860
|
-
* mid-graph would tear the linked-history invariant for v1 and above.
|
|
861
|
-
*
|
|
862
|
-
* **Linked-history boundary (D1, 2026-04-13):** upgrading v0 → v1
|
|
863
|
-
* produces a **fresh history root**. The new v1 state has `cid =
|
|
864
|
-
* hash(currentCachedValue)` and `prev = null`, not a synthetic `prev`
|
|
865
|
-
* anchored to any previous v0 value. The v0 monotonic `version` counter
|
|
866
|
-
* is preserved across the upgrade, but the linked-cid chain (spec §7)
|
|
867
|
-
* starts fresh at the upgrade point. Downstream audit tools that walk
|
|
868
|
-
* `v.cid.prev` backwards through time will see a `null` boundary at
|
|
869
|
-
* the upgrade — **this is intentional**: v0 had no cid to link to, and
|
|
870
|
-
* fabricating one would lie about the hash. Callers that require an
|
|
871
|
-
* unbroken cid chain from birth must attach versioning at construction
|
|
872
|
-
* via `opts.versioning` or `config.defaultVersioning`, not retroactively.
|
|
873
|
-
*
|
|
874
|
-
* @param level - New minimum versioning level.
|
|
875
|
-
* @param opts - Optional id / hash overrides; applied only if the
|
|
876
|
-
* node currently has no versioning state.
|
|
877
|
-
*/
|
|
878
|
-
_applyVersioning(level, opts) {
|
|
879
|
-
if (this._isExecutingFn) {
|
|
880
|
-
throw new Error(
|
|
881
|
-
`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
const currentLevel = this._versioningLevel;
|
|
885
|
-
if (currentLevel != null && level <= currentLevel) {
|
|
886
|
-
return;
|
|
887
|
-
}
|
|
888
|
-
const hash = opts?.hash ?? this._hashFn;
|
|
889
|
-
if (hash !== this._hashFn) this._hashFn = hash;
|
|
890
|
-
const initialValue = this._cached === void 0 ? void 0 : this._cached;
|
|
891
|
-
const current = this._versioning;
|
|
892
|
-
const preservedId = current?.id ?? opts?.id;
|
|
893
|
-
const preservedVersion = current?.version ?? 0;
|
|
894
|
-
const fresh = createVersioning(level, initialValue, {
|
|
895
|
-
id: preservedId,
|
|
896
|
-
hash
|
|
897
|
-
});
|
|
898
|
-
fresh.version = preservedVersion;
|
|
899
|
-
this._versioning = fresh;
|
|
900
|
-
this._versioningLevel = level;
|
|
901
|
-
}
|
|
902
|
-
/**
|
|
903
|
-
* @internal Attach an inspector hook. Returns a disposer that removes
|
|
904
|
-
* the hook. Used by `Graph.observe(path, { causal, derived })` to build
|
|
905
|
-
* causal traces. Multiple hooks may be attached concurrently — all fire
|
|
906
|
-
* for every event in registration order. Passing `undefined` is a no-op
|
|
907
|
-
* and returns a no-op disposer.
|
|
908
|
-
*/
|
|
909
|
-
_setInspectorHook(hook) {
|
|
910
|
-
if (hook == null) return () => {
|
|
911
|
-
};
|
|
912
|
-
if (this._inspectorHooks == null) this._inspectorHooks = /* @__PURE__ */ new Set();
|
|
913
|
-
this._inspectorHooks.add(hook);
|
|
914
|
-
return () => {
|
|
915
|
-
this._inspectorHooks?.delete(hook);
|
|
916
|
-
if (this._inspectorHooks?.size === 0) this._inspectorHooks = void 0;
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
/**
|
|
920
|
-
* @internal Push an additional guard onto this node. Effective enforcement
|
|
921
|
-
* is the AND of `_guard` and every guard pushed via this hook — any one
|
|
922
|
-
* rejecting throws {@link GuardDenied}. Returns a disposer that removes
|
|
923
|
-
* the pushed guard. Multiple guards may be stacked simultaneously.
|
|
924
|
-
*
|
|
925
|
-
* Used by `policyEnforcer({ mode: "enforce" })` (roadmap §9.2) to overlay
|
|
926
|
-
* runtime constraint enforcement onto an existing graph without rebuilding
|
|
927
|
-
* its nodes. Pre-1.0 internal API; not part of the public surface.
|
|
928
|
-
*
|
|
929
|
-
* **Identity semantics:** guards are tracked in a `Set`, so pushing the
|
|
930
|
-
* same `NodeGuard` reference twice is a single registration. Wrap each
|
|
931
|
-
* push in a unique closure if independent stacking is needed.
|
|
932
|
-
*
|
|
933
|
-
* **Iteration order:** insertion-ordered (`Set` semantics). Determinism
|
|
934
|
-
* follows from single-threaded JS execution; nested re-entry from inside
|
|
935
|
-
* a guard body (push/pop while iterating) is undefined-but-survivable.
|
|
936
|
-
*/
|
|
937
|
-
_pushGuard(guard) {
|
|
938
|
-
if (this._extraGuards == null) this._extraGuards = /* @__PURE__ */ new Set();
|
|
939
|
-
this._extraGuards.add(guard);
|
|
940
|
-
return () => {
|
|
941
|
-
this._extraGuards?.delete(guard);
|
|
942
|
-
if (this._extraGuards?.size === 0) this._extraGuards = void 0;
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
allowsObserve(actor) {
|
|
946
|
-
if (this._guard == null && this._extraGuards == null) return true;
|
|
947
|
-
const a = normalizeActor(actor);
|
|
948
|
-
if (this._guard != null && !this._guard(a, "observe")) return false;
|
|
949
|
-
if (this._extraGuards != null) {
|
|
950
|
-
for (const eg of this._extraGuards) {
|
|
951
|
-
if (!eg(a, "observe")) return false;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
return true;
|
|
955
|
-
}
|
|
956
|
-
// --- Guard helper ---
|
|
957
|
-
_checkGuard(options) {
|
|
958
|
-
if (options?.internal) return;
|
|
959
|
-
const hasGuard = this._guard != null || this._extraGuards != null;
|
|
960
|
-
const hasActor = options?.actor != null;
|
|
961
|
-
if (!hasGuard && !hasActor) return;
|
|
962
|
-
const actor = normalizeActor(options?.actor);
|
|
963
|
-
const action = options?.delivery === "signal" ? "signal" : "write";
|
|
964
|
-
if (this._guard != null && !this._guard(actor, action)) {
|
|
965
|
-
throw new GuardDenied({ actor, action, nodeName: this.name });
|
|
966
|
-
}
|
|
967
|
-
if (this._extraGuards != null) {
|
|
968
|
-
for (const eg of this._extraGuards) {
|
|
969
|
-
if (!eg(actor, action)) {
|
|
970
|
-
throw new GuardDenied({ actor, action, nodeName: this.name });
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
this._lastMutation = { actor, timestamp_ns: wallClockNs() };
|
|
975
|
-
}
|
|
976
|
-
// --- Public transport ---
|
|
977
|
-
down(messageOrMessages, options) {
|
|
978
|
-
const messages = normalizeMessages(messageOrMessages);
|
|
979
|
-
if (messages.length === 0) return;
|
|
980
|
-
this._checkGuard(options);
|
|
981
|
-
this._emit(messages);
|
|
982
|
-
}
|
|
983
|
-
emit(value, options) {
|
|
984
|
-
this._checkGuard(options);
|
|
985
|
-
this._emit([[DATA, value]]);
|
|
986
|
-
}
|
|
987
|
-
up(messageOrMessages, options) {
|
|
988
|
-
if (this._deps.length === 0) return;
|
|
989
|
-
const messages = normalizeMessages(messageOrMessages);
|
|
990
|
-
if (messages.length === 0) return;
|
|
991
|
-
this._checkGuard(options);
|
|
992
|
-
const forwardOpts = options ?? { internal: true };
|
|
993
|
-
this._validateUpTiers(messages);
|
|
994
|
-
for (const d of this._deps) {
|
|
995
|
-
d.node.up?.(messages, forwardOpts);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* @internal Internal up-path used by `actions.up(...)` from inside fn.
|
|
1000
|
-
* Same tier validation as public `up`, but bypasses the guard check
|
|
1001
|
-
* since the fn context is already inside an authorized operation.
|
|
1002
|
-
*/
|
|
1003
|
-
_emitUp(messages) {
|
|
1004
|
-
if (this._deps.length === 0) return;
|
|
1005
|
-
if (messages.length === 0) return;
|
|
1006
|
-
this._validateUpTiers(messages);
|
|
1007
|
-
for (const d of this._deps) {
|
|
1008
|
-
d.node.up?.(messages, { internal: true });
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* @internal Enforce spec §1.2 — up-direction messages are restricted to
|
|
1013
|
-
* tier 0–2 and tier 5 (START, DIRTY, INVALIDATE, PAUSE, RESUME,
|
|
1014
|
-
* TEARDOWN). Tier 3 (DATA/RESOLVED) and tier 4 (COMPLETE/ERROR) are
|
|
1015
|
-
* downstream-only. Emitting tier-3/4 via `up` would bypass equals
|
|
1016
|
-
* substitution and cache advance entirely and is a protocol bug.
|
|
1017
|
-
*/
|
|
1018
|
-
_validateUpTiers(messages) {
|
|
1019
|
-
const tierOf = this._config.tierOf;
|
|
1020
|
-
for (const m of messages) {
|
|
1021
|
-
const tier = tierOf(m[0]);
|
|
1022
|
-
if (tier === 3 || tier === 4) {
|
|
1023
|
-
throw new Error(
|
|
1024
|
-
`Node "${this.name}": tier-${tier} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`
|
|
1025
|
-
);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
subscribe(sink, actor) {
|
|
1030
|
-
if (actor != null && this._guard != null) {
|
|
1031
|
-
const a = normalizeActor(actor);
|
|
1032
|
-
if (!this._guard(a, "observe")) {
|
|
1033
|
-
throw new GuardDenied({ actor: a, action: "observe", nodeName: this.name });
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
const wasTerminal = this._isTerminal;
|
|
1037
|
-
const afterTerminalReset = wasTerminal && this._resubscribable;
|
|
1038
|
-
if (afterTerminalReset) {
|
|
1039
|
-
this._cached = void 0;
|
|
1040
|
-
this._status = "sentinel";
|
|
1041
|
-
this._store = {};
|
|
1042
|
-
this._hasCalledFnOnce = false;
|
|
1043
|
-
this._waveHasNewData = false;
|
|
1044
|
-
this._hasNewTerminal = false;
|
|
1045
|
-
this._paused = false;
|
|
1046
|
-
this._pendingWave = false;
|
|
1047
|
-
this._pendingRerun = false;
|
|
1048
|
-
this._isExecutingFn = false;
|
|
1049
|
-
this._rerunDepth = 0;
|
|
1050
|
-
this._dirtyDepCount = 0;
|
|
1051
|
-
this._pauseLocks = null;
|
|
1052
|
-
this._pauseBuffer = null;
|
|
1053
|
-
for (const d of this._deps) resetDepRecord(d);
|
|
1054
|
-
}
|
|
1055
|
-
this._sinkCount += 1;
|
|
1056
|
-
let subCleanup;
|
|
1057
|
-
try {
|
|
1058
|
-
subCleanup = this._config.onSubscribe(
|
|
1059
|
-
this,
|
|
1060
|
-
sink,
|
|
1061
|
-
{ sinkCount: this._sinkCount, afterTerminalReset },
|
|
1062
|
-
this._actions
|
|
1063
|
-
);
|
|
1064
|
-
} catch (err) {
|
|
1065
|
-
this._sinkCount -= 1;
|
|
1066
|
-
throw err;
|
|
1067
|
-
}
|
|
1068
|
-
if (this._sinks == null) {
|
|
1069
|
-
this._sinks = sink;
|
|
1070
|
-
} else if (typeof this._sinks === "function") {
|
|
1071
|
-
this._sinks = /* @__PURE__ */ new Set([this._sinks, sink]);
|
|
1072
|
-
} else {
|
|
1073
|
-
this._sinks.add(sink);
|
|
1074
|
-
}
|
|
1075
|
-
const isTerminalNow = this._isTerminal;
|
|
1076
|
-
if (this._sinkCount === 1 && !isTerminalNow) {
|
|
1077
|
-
try {
|
|
1078
|
-
this._activate();
|
|
1079
|
-
} catch (err) {
|
|
1080
|
-
this._sinkCount -= 1;
|
|
1081
|
-
this._removeSink(sink);
|
|
1082
|
-
if (this._sinkCount === 0) this._status = "sentinel";
|
|
1083
|
-
if (typeof subCleanup === "function") {
|
|
1084
|
-
try {
|
|
1085
|
-
subCleanup();
|
|
1086
|
-
} catch {
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
throw err;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
if (this._status === "sentinel" && this._cached === void 0) {
|
|
1093
|
-
this._status = "pending";
|
|
1094
|
-
}
|
|
1095
|
-
let removed = false;
|
|
1096
|
-
return () => {
|
|
1097
|
-
if (removed) return;
|
|
1098
|
-
removed = true;
|
|
1099
|
-
this._sinkCount -= 1;
|
|
1100
|
-
this._removeSink(sink);
|
|
1101
|
-
if (typeof subCleanup === "function") subCleanup();
|
|
1102
|
-
if (this._sinks == null) this._deactivate();
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
_removeSink(sink) {
|
|
1106
|
-
if (this._sinks === sink) {
|
|
1107
|
-
this._sinks = null;
|
|
1108
|
-
} else if (this._sinks != null && typeof this._sinks !== "function") {
|
|
1109
|
-
this._sinks.delete(sink);
|
|
1110
|
-
if (this._sinks.size === 1) {
|
|
1111
|
-
const [only] = this._sinks;
|
|
1112
|
-
this._sinks = only;
|
|
1113
|
-
} else if (this._sinks.size === 0) {
|
|
1114
|
-
this._sinks = null;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
// --- Lifecycle ---
|
|
1119
|
-
/**
|
|
1120
|
-
* @internal First-sink activation. For a producer (no deps + fn),
|
|
1121
|
-
* invokes fn once. For a compute node (has deps), subscribes to every
|
|
1122
|
-
* dep with the pre-set-dirty trick so the first-run gate waits for
|
|
1123
|
-
* every dep to settle at least once.
|
|
1124
|
-
*/
|
|
1125
|
-
_activate() {
|
|
1126
|
-
if (this._deps.length === 0) {
|
|
1127
|
-
if (this._fn) this._execFn();
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
this._dirtyDepCount = 0;
|
|
1131
|
-
const initialLen = this._deps.length;
|
|
1132
|
-
let subscribedCount = 0;
|
|
1133
|
-
try {
|
|
1134
|
-
for (let i = 0; i < initialLen; i++) {
|
|
1135
|
-
const depIdx = i;
|
|
1136
|
-
const dep = this._deps[i];
|
|
1137
|
-
dep.unsub = noopUnsub;
|
|
1138
|
-
dep.unsub = dep.node.subscribe((msgs) => {
|
|
1139
|
-
if (dep.unsub === null) return;
|
|
1140
|
-
const tierOf = this._config.tierOf;
|
|
1141
|
-
let sawSettlement = false;
|
|
1142
|
-
for (const m of msgs) {
|
|
1143
|
-
if (tierOf(m[0]) >= 3) sawSettlement = true;
|
|
1144
|
-
this._config.onMessage(
|
|
1145
|
-
this,
|
|
1146
|
-
m,
|
|
1147
|
-
{ direction: "down-in", depIndex: depIdx },
|
|
1148
|
-
this._actions
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
if (sawSettlement) this._maybeRunFnOnSettlement();
|
|
1152
|
-
});
|
|
1153
|
-
subscribedCount++;
|
|
1154
|
-
}
|
|
1155
|
-
} catch (err) {
|
|
1156
|
-
this._deps[subscribedCount].unsub = null;
|
|
1157
|
-
for (let j = 0; j < subscribedCount; j++) {
|
|
1158
|
-
const d = this._deps[j];
|
|
1159
|
-
if (d.unsub != null) {
|
|
1160
|
-
const u = d.unsub;
|
|
1161
|
-
d.unsub = null;
|
|
1162
|
-
try {
|
|
1163
|
-
u();
|
|
1164
|
-
} catch {
|
|
1165
|
-
}
|
|
1166
|
-
resetDepRecord(d);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
this._dirtyDepCount = 0;
|
|
1170
|
-
throw err;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* @internal Append a dep post-construction. Used by `autoTrackNode`
|
|
1175
|
-
* (runtime dep discovery) and `Graph.connect()` (post-construction
|
|
1176
|
-
* wiring). Subscribes immediately — if DATA arrives synchronously
|
|
1177
|
-
* during subscribe and fn is currently executing, the re-run is
|
|
1178
|
-
* deferred via `_pendingRerun` flag (see `_execFn` guard).
|
|
1179
|
-
*
|
|
1180
|
-
* **Dedup:** idempotent on duplicate `depNode` — if `depNode` is
|
|
1181
|
-
* already in `_deps`, returns the existing index without mutating
|
|
1182
|
-
* state. Callers can safely invoke `_addDep` without their own
|
|
1183
|
-
* "already added" check. `autoTrackNode` still keeps a `depIndexMap`
|
|
1184
|
-
* as a fast-path lookup for known deps (returning cached `data[idx]`
|
|
1185
|
-
* without calling `_addDep` at all); this internal dedup is the
|
|
1186
|
-
* backstop for any caller that doesn't track its own dep set.
|
|
1187
|
-
*
|
|
1188
|
-
* @returns The index of the new dep in `_deps`, or the existing index
|
|
1189
|
-
* if the dep was already present.
|
|
1190
|
-
*/
|
|
1191
|
-
_addDep(depNode) {
|
|
1192
|
-
for (let i = 0; i < this._deps.length; i++) {
|
|
1193
|
-
if (this._deps[i].node === depNode) return i;
|
|
1194
|
-
}
|
|
1195
|
-
const depIdx = this._deps.length;
|
|
1196
|
-
const record = createDepRecord(depNode);
|
|
1197
|
-
this._deps.push(record);
|
|
1198
|
-
if (this._sinks == null) return depIdx;
|
|
1199
|
-
record.dirty = true;
|
|
1200
|
-
this._dirtyDepCount++;
|
|
1201
|
-
if (this._status !== "dirty") this._emit(DIRTY_ONLY_BATCH);
|
|
1202
|
-
record.unsub = noopUnsub;
|
|
1203
|
-
try {
|
|
1204
|
-
record.unsub = depNode.subscribe((msgs) => {
|
|
1205
|
-
if (record.unsub === null) return;
|
|
1206
|
-
const tierOf = this._config.tierOf;
|
|
1207
|
-
let sawSettlement = false;
|
|
1208
|
-
for (const m of msgs) {
|
|
1209
|
-
if (tierOf(m[0]) >= 3) sawSettlement = true;
|
|
1210
|
-
this._config.onMessage(
|
|
1211
|
-
this,
|
|
1212
|
-
m,
|
|
1213
|
-
{ direction: "down-in", depIndex: depIdx },
|
|
1214
|
-
this._actions
|
|
1215
|
-
);
|
|
1216
|
-
}
|
|
1217
|
-
if (sawSettlement) this._maybeRunFnOnSettlement();
|
|
1218
|
-
});
|
|
1219
|
-
} catch (err) {
|
|
1220
|
-
record.unsub = null;
|
|
1221
|
-
this._deps.pop();
|
|
1222
|
-
this._dirtyDepCount--;
|
|
1223
|
-
throw err;
|
|
1224
|
-
}
|
|
1225
|
-
return depIdx;
|
|
1226
|
-
}
|
|
1227
|
-
/**
|
|
1228
|
-
* @internal Unsubscribes from deps, fires fn cleanup (both shapes),
|
|
1229
|
-
* clears wave/store state, and (for compute nodes) drops `_cached` per
|
|
1230
|
-
* the ROM/RAM rule. Idempotent: second call is a no-op.
|
|
1231
|
-
*
|
|
1232
|
-
* @param skipStatusUpdate — When `true`, the caller takes responsibility
|
|
1233
|
-
* for setting `_status` after deactivation (e.g. TEARDOWN always sets
|
|
1234
|
-
* `"sentinel"` unconditionally). When `false` (default), deactivation
|
|
1235
|
-
* applies the ROM rule: compute nodes → `"sentinel"`, state nodes
|
|
1236
|
-
* preserve their current status.
|
|
1237
|
-
*/
|
|
1238
|
-
_deactivate(skipStatusUpdate = false) {
|
|
1239
|
-
const cleanup = this._cleanup;
|
|
1240
|
-
this._cleanup = void 0;
|
|
1241
|
-
if (typeof cleanup === "function") {
|
|
1242
|
-
try {
|
|
1243
|
-
cleanup();
|
|
1244
|
-
} catch (err) {
|
|
1245
|
-
this._emit([[ERROR, this._wrapFnError("cleanup threw", err)]]);
|
|
1246
|
-
}
|
|
1247
|
-
} else if (cleanup != null && typeof cleanup.deactivation === "function") {
|
|
1248
|
-
try {
|
|
1249
|
-
cleanup.deactivation();
|
|
1250
|
-
} catch (err) {
|
|
1251
|
-
this._emit([[ERROR, this._wrapFnError("cleanup.deactivation threw", err)]]);
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
for (const d of this._deps) {
|
|
1255
|
-
if (d.unsub != null) {
|
|
1256
|
-
const u = d.unsub;
|
|
1257
|
-
d.unsub = null;
|
|
1258
|
-
try {
|
|
1259
|
-
u();
|
|
1260
|
-
} catch {
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
resetDepRecord(d);
|
|
1264
|
-
}
|
|
1265
|
-
this._waveHasNewData = false;
|
|
1266
|
-
this._hasNewTerminal = false;
|
|
1267
|
-
this._hasCalledFnOnce = false;
|
|
1268
|
-
this._paused = false;
|
|
1269
|
-
this._pendingWave = false;
|
|
1270
|
-
this._pendingRerun = false;
|
|
1271
|
-
this._rerunDepth = 0;
|
|
1272
|
-
this._store = {};
|
|
1273
|
-
this._dirtyDepCount = 0;
|
|
1274
|
-
this._pauseLocks = null;
|
|
1275
|
-
this._pauseBuffer = null;
|
|
1276
|
-
if (this._fn != null) {
|
|
1277
|
-
this._cached = void 0;
|
|
1278
|
-
}
|
|
1279
|
-
if (!skipStatusUpdate) {
|
|
1280
|
-
if (this._fn != null || this._deps.length > 0) {
|
|
1281
|
-
if (!this._isTerminal || this._resubscribable) {
|
|
1282
|
-
this._status = "sentinel";
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
// --- Dep message dispatch (§3.5 singleton default) ---
|
|
1288
|
-
/**
|
|
1289
|
-
* @internal Default per-tier dispatch for incoming dep messages. Called
|
|
1290
|
-
* by `defaultOnMessage`. Updates the DepRecord, triggers wave
|
|
1291
|
-
* completion, and forwards passthrough traffic.
|
|
1292
|
-
*/
|
|
1293
|
-
_onDepMessage(depIndex, msg) {
|
|
1294
|
-
const dep = this._deps[depIndex];
|
|
1295
|
-
const t = msg[0];
|
|
1296
|
-
if (this._inspectorHooks != null) {
|
|
1297
|
-
const ev = { kind: "dep_message", depIndex, message: msg };
|
|
1298
|
-
for (const hook of this._inspectorHooks) hook(ev);
|
|
1299
|
-
}
|
|
1300
|
-
if (t === START) return;
|
|
1301
|
-
if (t === DIRTY) {
|
|
1302
|
-
this._depDirtied(dep);
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
if (t === INVALIDATE) {
|
|
1306
|
-
this._depInvalidated(dep);
|
|
1307
|
-
this._emit(INVALIDATE_ONLY_BATCH);
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
if (t === PAUSE || t === RESUME) {
|
|
1311
|
-
this._emit([msg]);
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
if (t === TEARDOWN) {
|
|
1315
|
-
this._emit(TEARDOWN_ONLY_BATCH);
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
if (t === DATA) {
|
|
1319
|
-
this._depSettledAsData(dep, msg[1]);
|
|
1320
|
-
} else if (t === RESOLVED) {
|
|
1321
|
-
this._depSettledAsResolved(dep);
|
|
1322
|
-
} else if (t === COMPLETE) {
|
|
1323
|
-
this._depSettledAsTerminal(dep, true);
|
|
1324
|
-
} else if (t === ERROR) {
|
|
1325
|
-
this._depSettledAsTerminal(dep, msg[1]);
|
|
1326
|
-
} else {
|
|
1327
|
-
this._emit([msg]);
|
|
1328
|
-
return;
|
|
1329
|
-
}
|
|
1330
|
-
if (!this._fn) {
|
|
1331
|
-
if (t === DATA || t === RESOLVED) {
|
|
1332
|
-
this._emit([msg]);
|
|
1333
|
-
}
|
|
1334
|
-
if (t === COMPLETE || t === ERROR) {
|
|
1335
|
-
this._maybeAutoTerminalAfterWave();
|
|
1336
|
-
}
|
|
1337
|
-
return;
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
// --- Centralized dep-state transitions (A3 settlement counters) ---
|
|
1341
|
-
//
|
|
1342
|
-
// Every mutation to `DepRecord.dirty` / `DepRecord.prevData` /
|
|
1343
|
-
// `DepRecord.terminal` must go through one of these helpers so the
|
|
1344
|
-
// `_dirtyDepCount` and `_sentinelDepCount` counters stay in sync with
|
|
1345
|
-
// the per-record flags. `_maybeRunFnOnSettlement` reads the counters
|
|
1346
|
-
// and never re-scans the `_deps` array.
|
|
1347
|
-
/**
|
|
1348
|
-
* Called when a dep transitions `dirty: false → true` (either from an
|
|
1349
|
-
* incoming DIRTY, or pre-set during `_activate` / `_addDep` /
|
|
1350
|
-
* `_depInvalidated`). No-op if the dep is already dirty. Fires the
|
|
1351
|
-
* downstream DIRTY emit if we're the first to dirty this wave.
|
|
1352
|
-
*/
|
|
1353
|
-
_depDirtied(dep) {
|
|
1354
|
-
if (dep.dirty) return;
|
|
1355
|
-
dep.dirty = true;
|
|
1356
|
-
dep.involvedThisWave = true;
|
|
1357
|
-
this._dirtyDepCount++;
|
|
1358
|
-
if (this._status !== "dirty") {
|
|
1359
|
-
this._emit(DIRTY_ONLY_BATCH);
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* Called when a dep delivers new DATA: clears dirty, stores the payload,
|
|
1364
|
-
* marks wave-has-data, and — if this is the dep's first DATA — clears
|
|
1365
|
-
* its sentinel slot so the first-run gate can open.
|
|
1366
|
-
*/
|
|
1367
|
-
_depSettledAsData(dep, value) {
|
|
1368
|
-
if (dep.dirty) {
|
|
1369
|
-
dep.dirty = false;
|
|
1370
|
-
this._dirtyDepCount--;
|
|
1371
|
-
}
|
|
1372
|
-
dep.involvedThisWave = true;
|
|
1373
|
-
dep.dataBatch.push(value);
|
|
1374
|
-
this._waveHasNewData = true;
|
|
1375
|
-
}
|
|
1376
|
-
/**
|
|
1377
|
-
* Called when a dep emits RESOLVED (wave settled, value unchanged).
|
|
1378
|
-
* Clears dirty; does NOT touch `prevData` / `terminal` / sentinel
|
|
1379
|
-
* count — sentinel only exits on first DATA or terminal, not RESOLVED.
|
|
1380
|
-
*/
|
|
1381
|
-
_depSettledAsResolved(dep) {
|
|
1382
|
-
if (dep.dirty) {
|
|
1383
|
-
dep.dirty = false;
|
|
1384
|
-
this._dirtyDepCount--;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
/**
|
|
1388
|
-
* Called when a dep delivers COMPLETE (`terminal = true`) or ERROR
|
|
1389
|
-
* (`terminal = errorPayload`). Clears dirty, stores the terminal, and
|
|
1390
|
-
* — if the dep had never contributed a DATA yet — leaves sentinel
|
|
1391
|
-
* since the gate treats "terminated without data" as gate-open too.
|
|
1392
|
-
*/
|
|
1393
|
-
_depSettledAsTerminal(dep, terminal) {
|
|
1394
|
-
if (dep.dirty) {
|
|
1395
|
-
dep.dirty = false;
|
|
1396
|
-
this._dirtyDepCount--;
|
|
1397
|
-
}
|
|
1398
|
-
dep.terminal = terminal;
|
|
1399
|
-
dep.involvedThisWave = true;
|
|
1400
|
-
this._hasNewTerminal = true;
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Called when a dep emits INVALIDATE: clears prevData, terminal, and
|
|
1404
|
-
* dataBatch. The dep is now back in the "never delivered a real value"
|
|
1405
|
-
* state — `prevData === undefined` so the sentinel check in fn will fire.
|
|
1406
|
-
*/
|
|
1407
|
-
_depInvalidated(dep) {
|
|
1408
|
-
dep.prevData = void 0;
|
|
1409
|
-
dep.terminal = void 0;
|
|
1410
|
-
dep.dataBatch.length = 0;
|
|
1411
|
-
if (!dep.dirty) {
|
|
1412
|
-
dep.dirty = true;
|
|
1413
|
-
dep.involvedThisWave = true;
|
|
1414
|
-
this._dirtyDepCount++;
|
|
1415
|
-
} else {
|
|
1416
|
-
dep.involvedThisWave = false;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
_maybeRunFnOnSettlement() {
|
|
1420
|
-
if (this._isTerminal && !this._resubscribable) return;
|
|
1421
|
-
if (this._dirtyDepCount > 0) return;
|
|
1422
|
-
if (this._paused) {
|
|
1423
|
-
this._pendingWave = true;
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
if (!this._waveHasNewData && !this._hasNewTerminal && this._hasCalledFnOnce) {
|
|
1427
|
-
this._clearWaveFlags();
|
|
1428
|
-
this._emit(RESOLVED_ONLY_BATCH);
|
|
1429
|
-
this._maybeAutoTerminalAfterWave();
|
|
1430
|
-
return;
|
|
1431
|
-
}
|
|
1432
|
-
if (this._fn) this._execFn();
|
|
1433
|
-
this._maybeAutoTerminalAfterWave();
|
|
1434
|
-
}
|
|
1435
|
-
_maybeAutoTerminalAfterWave() {
|
|
1436
|
-
if (this._deps.length === 0) return;
|
|
1437
|
-
if (this._isTerminal) return;
|
|
1438
|
-
const erroredDep = this._deps.find((d) => d.terminal !== void 0 && d.terminal !== true);
|
|
1439
|
-
if (erroredDep != null) {
|
|
1440
|
-
if (this._autoError) {
|
|
1441
|
-
this._emit([[ERROR, erroredDep.terminal]]);
|
|
1442
|
-
}
|
|
1443
|
-
return;
|
|
1444
|
-
}
|
|
1445
|
-
if (this._autoComplete && this._deps.every((d) => d.terminal !== void 0)) {
|
|
1446
|
-
this._emit(COMPLETE_ONLY_BATCH);
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
// --- Fn execution ---
|
|
1450
|
-
/**
|
|
1451
|
-
* @internal Runs the node fn once. Default cleanup (function form) fires
|
|
1452
|
-
* before the new run; `{ deactivation }` cleanup survives.
|
|
1453
|
-
*/
|
|
1454
|
-
_execFn() {
|
|
1455
|
-
if (!this._fn) return;
|
|
1456
|
-
if (this._isTerminal && !this._resubscribable) return;
|
|
1457
|
-
if (this._isExecutingFn) {
|
|
1458
|
-
this._pendingRerun = true;
|
|
1459
|
-
return;
|
|
1460
|
-
}
|
|
1461
|
-
const prevCleanup = this._cleanup;
|
|
1462
|
-
if (typeof prevCleanup === "function") {
|
|
1463
|
-
this._cleanup = void 0;
|
|
1464
|
-
try {
|
|
1465
|
-
prevCleanup();
|
|
1466
|
-
} catch (err) {
|
|
1467
|
-
this._emit([[ERROR, this._wrapFnError("cleanup threw", err)]]);
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
const batchData = this._deps.map(
|
|
1472
|
-
(d) => !d.involvedThisWave ? void 0 : d.dataBatch.length > 0 ? [...d.dataBatch] : []
|
|
1473
|
-
);
|
|
1474
|
-
const prevData = this._deps.map((d) => d.prevData);
|
|
1475
|
-
for (let i = 0; i < this._deps.length; i++) {
|
|
1476
|
-
const batch = batchData[i];
|
|
1477
|
-
if (batch != null && batch.length > 0) {
|
|
1478
|
-
this._deps[i].prevData = batch[batch.length - 1];
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
const terminalDeps = this._deps.map((d) => d.terminal);
|
|
1482
|
-
const ctx = { prevData, terminalDeps, store: this._store };
|
|
1483
|
-
this._hasCalledFnOnce = true;
|
|
1484
|
-
this._clearWaveFlags();
|
|
1485
|
-
if (this._inspectorHooks != null) {
|
|
1486
|
-
const ev = { kind: "run", batchData, prevData };
|
|
1487
|
-
for (const hook of this._inspectorHooks) hook(ev);
|
|
1488
|
-
}
|
|
1489
|
-
this._isExecutingFn = true;
|
|
1490
|
-
try {
|
|
1491
|
-
const result = this._fn(batchData, this._actions, ctx);
|
|
1492
|
-
if (typeof result === "function") {
|
|
1493
|
-
this._cleanup = result;
|
|
1494
|
-
} else if (result != null && typeof result === "object" && typeof result.deactivation === "function") {
|
|
1495
|
-
this._cleanup = result;
|
|
1496
|
-
}
|
|
1497
|
-
} catch (err) {
|
|
1498
|
-
this._emit([[ERROR, this._wrapFnError("fn threw", err)]]);
|
|
1499
|
-
} finally {
|
|
1500
|
-
this._isExecutingFn = false;
|
|
1501
|
-
if (this._pendingRerun) {
|
|
1502
|
-
this._pendingRerun = false;
|
|
1503
|
-
this._rerunDepth += 1;
|
|
1504
|
-
if (this._rerunDepth > MAX_RERUN_DEPTH) {
|
|
1505
|
-
this._rerunDepth = 0;
|
|
1506
|
-
this._emit([
|
|
1507
|
-
[
|
|
1508
|
-
ERROR,
|
|
1509
|
-
new Error(
|
|
1510
|
-
`Node "${this.name}": _pendingRerun depth exceeded ${MAX_RERUN_DEPTH} \u2014 likely a reactive cycle`
|
|
1511
|
-
)
|
|
1512
|
-
]
|
|
1513
|
-
]);
|
|
1514
|
-
} else {
|
|
1515
|
-
this._maybeRunFnOnSettlement();
|
|
1516
|
-
}
|
|
1517
|
-
} else {
|
|
1518
|
-
this._rerunDepth = 0;
|
|
1519
|
-
}
|
|
1520
|
-
this._clearWaveFlags();
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
_clearWaveFlags() {
|
|
1524
|
-
this._waveHasNewData = false;
|
|
1525
|
-
this._hasNewTerminal = false;
|
|
1526
|
-
for (const d of this._deps) {
|
|
1527
|
-
d.involvedThisWave = false;
|
|
1528
|
-
d.dataBatch.length = 0;
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
_wrapFnError(label, err) {
|
|
1532
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1533
|
-
return new Error(`Node "${this.name}": ${label}: ${msg}`, { cause: err });
|
|
1534
|
-
}
|
|
1535
|
-
// --- Framing (tier sort + synthetic DIRTY prefix) ---
|
|
1536
|
-
/**
|
|
1537
|
-
* @internal Stable tier sort + synthetic DIRTY prefix for an outgoing
|
|
1538
|
-
* batch. Fast path: already-monotone single-tier batches (the common
|
|
1539
|
-
* case from interned singletons like `DIRTY_ONLY_BATCH`) return the
|
|
1540
|
-
* input unchanged. General path: decorate-sort-undecorate into a new
|
|
1541
|
-
* array, then prepend `[DIRTY]` after any tier-0 START entries when
|
|
1542
|
-
* a tier-3 payload is present and the node isn't already dirty.
|
|
1543
|
-
*
|
|
1544
|
-
* Single source of truth for the spec §1.3.1 framing invariant. Every
|
|
1545
|
-
* outgoing path hits `_frameBatch` exactly once via `_emit`.
|
|
1546
|
-
*/
|
|
1547
|
-
_frameBatch(messages) {
|
|
1548
|
-
const tierOf = this._config.tierOf;
|
|
1549
|
-
if (messages.length === 1) {
|
|
1550
|
-
const t = tierOf(messages[0][0]);
|
|
1551
|
-
if (t === 3 && this._status !== "dirty") {
|
|
1552
|
-
return [DIRTY_MSG, messages[0]];
|
|
1553
|
-
}
|
|
1554
|
-
return messages;
|
|
1555
|
-
}
|
|
1556
|
-
let monotone = true;
|
|
1557
|
-
let hasTier3 = false;
|
|
1558
|
-
let hasDirty = false;
|
|
1559
|
-
let prevTier = -1;
|
|
1560
|
-
for (const m of messages) {
|
|
1561
|
-
const tier = tierOf(m[0]);
|
|
1562
|
-
if (tier < prevTier) monotone = false;
|
|
1563
|
-
if (tier === 3) hasTier3 = true;
|
|
1564
|
-
if (m[0] === DIRTY) hasDirty = true;
|
|
1565
|
-
prevTier = tier;
|
|
1566
|
-
}
|
|
1567
|
-
let sorted = messages;
|
|
1568
|
-
if (!monotone) {
|
|
1569
|
-
const indexed = messages.map((m, i) => ({ m, i, tier: tierOf(m[0]) }));
|
|
1570
|
-
indexed.sort((a, b) => a.tier - b.tier || a.i - b.i);
|
|
1571
|
-
sorted = indexed.map((x) => x.m);
|
|
1572
|
-
}
|
|
1573
|
-
if (hasTier3 && !hasDirty && this._status !== "dirty") {
|
|
1574
|
-
let insertAt = 0;
|
|
1575
|
-
while (insertAt < sorted.length && tierOf(sorted[insertAt][0]) === 0) insertAt++;
|
|
1576
|
-
if (insertAt === 0) return [DIRTY_MSG, ...sorted];
|
|
1577
|
-
return [...sorted.slice(0, insertAt), DIRTY_MSG, ...sorted.slice(insertAt)];
|
|
1578
|
-
}
|
|
1579
|
-
return sorted;
|
|
1580
|
-
}
|
|
1581
|
-
// --- Emit pipeline ---
|
|
1582
|
-
/**
|
|
1583
|
-
* @internal The unified dispatch waist — one call = one wave.
|
|
1584
|
-
* See `GRAPHREFLY-SPEC.md` §1.3.1 for protocol context — the stages
|
|
1585
|
-
* below are the implementation order.
|
|
1586
|
-
*
|
|
1587
|
-
* Pipeline stages, in order:
|
|
1588
|
-
*
|
|
1589
|
-
* 1. Terminal filter — post-COMPLETE/ERROR only TEARDOWN/INVALIDATE
|
|
1590
|
-
* still propagate so graph teardown and cache-clear still work.
|
|
1591
|
-
* 2. Tier sort (stable) — the batch can be in any order when it
|
|
1592
|
-
* arrives; the walker downstream (`downWithBatch`) assumes
|
|
1593
|
-
* ascending tier monotone, and so does `_updateState`'s tier-3
|
|
1594
|
-
* slice walk. This is the single source of truth for ordering.
|
|
1595
|
-
* 3. Synthetic DIRTY prefix — if a tier-3 payload is present, no
|
|
1596
|
-
* DIRTY is already in the batch, and the node isn't already in
|
|
1597
|
-
* `"dirty"` status, prepend `[DIRTY]` after any tier-0 START
|
|
1598
|
-
* entries. Guarantees spec §1.3.1 (DIRTY precedes DATA within
|
|
1599
|
-
* the same batch) uniformly across every entry point.
|
|
1600
|
-
* 4. PAUSE/RESUME lock bookkeeping (C0) — update `_pauseLocks`,
|
|
1601
|
-
* derive `_paused`, filter unknown-lockId RESUME, replay
|
|
1602
|
-
* bufferAll buffer on final lock release.
|
|
1603
|
-
* 5. Meta TEARDOWN fan-out — notify meta children before
|
|
1604
|
-
* `_updateState`'s TEARDOWN branch calls `_deactivate`. Hoisted
|
|
1605
|
-
* out of the walk to keep `_updateState` re-entrance-free.
|
|
1606
|
-
* 6. `_updateState` — walk the batch in tier order, advancing
|
|
1607
|
-
* `_cached` / `_status` / `_versioning` and running equals
|
|
1608
|
-
* substitution on tier-3 DATA (§3.5.1). Returns
|
|
1609
|
-
* `{finalMessages, equalsError?}`.
|
|
1610
|
-
* 7. `downWithBatch` dispatch (or bufferAll capture if paused with
|
|
1611
|
-
* `pausable: "resumeAll"`).
|
|
1612
|
-
* 8. Recursive ERROR emission if equals threw mid-walk.
|
|
1613
|
-
*/
|
|
1614
|
-
_emit(messages) {
|
|
1615
|
-
if (messages.length === 0) return;
|
|
1616
|
-
let deliverable = messages;
|
|
1617
|
-
const terminal = this._isTerminal;
|
|
1618
|
-
if (terminal && !this._resubscribable) {
|
|
1619
|
-
const pass = messages.filter((m) => m[0] === TEARDOWN || m[0] === INVALIDATE);
|
|
1620
|
-
if (pass.length === 0) return;
|
|
1621
|
-
deliverable = pass;
|
|
1622
|
-
}
|
|
1623
|
-
deliverable = this._frameBatch(deliverable);
|
|
1624
|
-
let filtered = null;
|
|
1625
|
-
for (let i = 0; i < deliverable.length; i++) {
|
|
1626
|
-
const m = deliverable[i];
|
|
1627
|
-
const t = m[0];
|
|
1628
|
-
if (t !== PAUSE && t !== RESUME) {
|
|
1629
|
-
if (filtered != null) filtered.push(m);
|
|
1630
|
-
continue;
|
|
1631
|
-
}
|
|
1632
|
-
if (m.length < 2) {
|
|
1633
|
-
throw new Error(
|
|
1634
|
-
`Node "${this.name}": [[${t === PAUSE ? "PAUSE" : "RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`
|
|
1635
|
-
);
|
|
1636
|
-
}
|
|
1637
|
-
let forward = true;
|
|
1638
|
-
if (this._pausable !== false) {
|
|
1639
|
-
const lockId = m[1];
|
|
1640
|
-
if (t === PAUSE) {
|
|
1641
|
-
if (this._pauseLocks == null) this._pauseLocks = /* @__PURE__ */ new Set();
|
|
1642
|
-
this._pauseLocks.add(lockId);
|
|
1643
|
-
this._paused = true;
|
|
1644
|
-
if (this._pausable === "resumeAll" && this._pauseBuffer == null) {
|
|
1645
|
-
this._pauseBuffer = [];
|
|
1646
|
-
}
|
|
1647
|
-
} else {
|
|
1648
|
-
if (this._pauseLocks == null || !this._pauseLocks.has(lockId)) {
|
|
1649
|
-
forward = false;
|
|
1650
|
-
} else {
|
|
1651
|
-
this._pauseLocks.delete(lockId);
|
|
1652
|
-
if (this._pauseLocks.size === 0) {
|
|
1653
|
-
this._paused = false;
|
|
1654
|
-
if (this._pauseBuffer != null && this._pauseBuffer.length > 0) {
|
|
1655
|
-
const drain = this._pauseBuffer;
|
|
1656
|
-
this._pauseBuffer = [];
|
|
1657
|
-
this._emit(drain);
|
|
1658
|
-
}
|
|
1659
|
-
if (this._pendingWave) {
|
|
1660
|
-
this._pendingWave = false;
|
|
1661
|
-
this._maybeRunFnOnSettlement();
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
if (!forward) {
|
|
1668
|
-
if (filtered == null) filtered = deliverable.slice(0, i);
|
|
1669
|
-
} else if (filtered != null) {
|
|
1670
|
-
filtered.push(m);
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
if (filtered != null) {
|
|
1674
|
-
if (filtered.length === 0) return;
|
|
1675
|
-
deliverable = filtered;
|
|
1676
|
-
}
|
|
1677
|
-
if (this._hasMeta && deliverable.some((m) => m[0] === TEARDOWN)) {
|
|
1678
|
-
for (const k of Object.keys(this.meta)) {
|
|
1679
|
-
try {
|
|
1680
|
-
this.meta[k]._emit(TEARDOWN_ONLY_BATCH);
|
|
1681
|
-
} catch {
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
const { finalMessages, equalsError } = this._updateState(deliverable);
|
|
1686
|
-
if (finalMessages.length > 0 && this._config.inspectorEnabled) {
|
|
1687
|
-
const inspector = this._config.globalInspector;
|
|
1688
|
-
if (inspector != null) {
|
|
1689
|
-
try {
|
|
1690
|
-
inspector({ kind: "emit", node: this, messages: finalMessages });
|
|
1691
|
-
} catch {
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
if (finalMessages.length > 0) {
|
|
1696
|
-
if (this._paused && this._pausable === "resumeAll" && this._pauseBuffer != null) {
|
|
1697
|
-
const tierOf = this._config.tierOf;
|
|
1698
|
-
const immediate = [];
|
|
1699
|
-
for (const m of finalMessages) {
|
|
1700
|
-
const tier = tierOf(m[0]);
|
|
1701
|
-
if (tier < 3 || tier === 5) {
|
|
1702
|
-
immediate.push(m);
|
|
1703
|
-
} else {
|
|
1704
|
-
this._pauseBuffer.push(m);
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
if (immediate.length > 0) {
|
|
1708
|
-
this._dispatchOrAccumulate(immediate);
|
|
1709
|
-
}
|
|
1710
|
-
} else {
|
|
1711
|
-
this._dispatchOrAccumulate(finalMessages);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
if (equalsError != null) {
|
|
1715
|
-
this._emit([[ERROR, equalsError]]);
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* @internal Walk an outgoing (already-framed) batch, updating own
|
|
1720
|
-
* cache / status / versioning and running equals substitution on
|
|
1721
|
-
* every tier-3 DATA (§3.5.1). Framing — tier sort and synthetic
|
|
1722
|
-
* DIRTY prefix — has already happened upstream in `_frameBatch`.
|
|
1723
|
-
* This walk trusts the input is in monotone tier order and that the
|
|
1724
|
-
* spec §1.3.1 DIRTY/RESOLVED precedence invariant is already
|
|
1725
|
-
* satisfied by the frame.
|
|
1726
|
-
*
|
|
1727
|
-
* Equals substitution: every DATA payload is compared against the
|
|
1728
|
-
* live `_cached`; when equal, the tuple is rewritten to `[RESOLVED]`
|
|
1729
|
-
* in a per-call copy and cache is not re-advanced. `.cache` remains
|
|
1730
|
-
* coherent with "the last DATA payload this node actually sent
|
|
1731
|
-
* downstream".
|
|
1732
|
-
*
|
|
1733
|
-
* Returns `{ finalMessages, equalsError? }`:
|
|
1734
|
-
* - `finalMessages` — the array to deliver to sinks (may be
|
|
1735
|
-
* `messages` unchanged, a rewritten copy with DATA→RESOLVED
|
|
1736
|
-
* substitutions, or a truncated prefix when equals throws mid-walk).
|
|
1737
|
-
* - `equalsError` — present only when the configured `equals` function
|
|
1738
|
-
* threw on some DATA message. `_emit` delivers the prefix first,
|
|
1739
|
-
* then emits a fresh ERROR batch via a recursive `_emit` call so
|
|
1740
|
-
* subscribers observe `[...walked_prefix, ERROR]` in order.
|
|
1741
|
-
*/
|
|
1742
|
-
_updateState(messages) {
|
|
1743
|
-
const tierOf = this._config.tierOf;
|
|
1744
|
-
let rewritten;
|
|
1745
|
-
let equalsError;
|
|
1746
|
-
let abortedAt = -1;
|
|
1747
|
-
let dataCount = 0;
|
|
1748
|
-
for (const m of messages) {
|
|
1749
|
-
if (tierOf(m[0]) === 3) dataCount++;
|
|
1750
|
-
}
|
|
1751
|
-
const checkEquals = dataCount <= 1;
|
|
1752
|
-
let lastDataIdx = -1;
|
|
1753
|
-
if (this._versioning != null && dataCount > 1) {
|
|
1754
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1755
|
-
if (messages[i][0] === DATA) {
|
|
1756
|
-
lastDataIdx = i;
|
|
1757
|
-
break;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
for (let i = 0; i < messages.length; i++) {
|
|
1762
|
-
const m = messages[i];
|
|
1763
|
-
const t = m[0];
|
|
1764
|
-
if (t === DATA) {
|
|
1765
|
-
if (m.length >= 2) {
|
|
1766
|
-
let unchanged = false;
|
|
1767
|
-
if (checkEquals && this._cached !== void 0) {
|
|
1768
|
-
try {
|
|
1769
|
-
unchanged = this._equals(this._cached, m[1]);
|
|
1770
|
-
} catch (err) {
|
|
1771
|
-
equalsError = this._wrapFnError("equals threw", err);
|
|
1772
|
-
abortedAt = i;
|
|
1773
|
-
break;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
if (unchanged) {
|
|
1777
|
-
if (rewritten == null) rewritten = messages.slice(0, i);
|
|
1778
|
-
rewritten.push(RESOLVED_MSG);
|
|
1779
|
-
this._status = "resolved";
|
|
1780
|
-
continue;
|
|
1781
|
-
}
|
|
1782
|
-
this._cached = m[1];
|
|
1783
|
-
if (this._versioning != null) {
|
|
1784
|
-
if (lastDataIdx < 0 || i === lastDataIdx) {
|
|
1785
|
-
advanceVersion(this._versioning, m[1], this._hashFn);
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
this._status = "settled";
|
|
1790
|
-
if (rewritten != null) rewritten.push(m);
|
|
1791
|
-
} else {
|
|
1792
|
-
if (rewritten != null) rewritten.push(m);
|
|
1793
|
-
if (t === DIRTY) {
|
|
1794
|
-
this._status = "dirty";
|
|
1795
|
-
} else if (t === RESOLVED) {
|
|
1796
|
-
this._status = "resolved";
|
|
1797
|
-
} else if (t === COMPLETE) {
|
|
1798
|
-
this._status = "completed";
|
|
1799
|
-
} else if (t === ERROR) {
|
|
1800
|
-
this._status = "errored";
|
|
1801
|
-
} else if (t === INVALIDATE) {
|
|
1802
|
-
this._cached = void 0;
|
|
1803
|
-
this._status = "dirty";
|
|
1804
|
-
const c = this._cleanup;
|
|
1805
|
-
if (typeof c === "function") {
|
|
1806
|
-
this._cleanup = void 0;
|
|
1807
|
-
try {
|
|
1808
|
-
c();
|
|
1809
|
-
} catch {
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
} else if (t === TEARDOWN) {
|
|
1813
|
-
if (this._resetOnTeardown) this._cached = void 0;
|
|
1814
|
-
this._deactivate(
|
|
1815
|
-
/* skipStatusUpdate */
|
|
1816
|
-
true
|
|
1817
|
-
);
|
|
1818
|
-
this._status = "sentinel";
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
const base = abortedAt >= 0 ? rewritten ?? messages.slice(0, abortedAt) : rewritten ?? messages;
|
|
1823
|
-
return equalsError != null ? { finalMessages: base, equalsError } : { finalMessages: base };
|
|
1824
|
-
}
|
|
1825
|
-
_deliverToSinks = (messages) => {
|
|
1826
|
-
if (this._sinks == null) return;
|
|
1827
|
-
if (typeof this._sinks === "function") {
|
|
1828
|
-
this._sinks(messages);
|
|
1829
|
-
return;
|
|
1830
|
-
}
|
|
1831
|
-
const snapshot = [...this._sinks];
|
|
1832
|
-
for (const sink of snapshot) sink(messages);
|
|
1833
|
-
};
|
|
1834
|
-
/**
|
|
1835
|
-
* @internal Dispatch entry point that respects the per-batch emit
|
|
1836
|
-
* accumulator (Bug 2). Inside an explicit `batch()` scope, append to
|
|
1837
|
-
* `_batchPendingMessages` and register a flush hook on first append.
|
|
1838
|
-
* Outside batch — or during a drain (where `flushInProgress` is true
|
|
1839
|
-
* but `batchDepth` is 0) — dispatch synchronously through `downWithBatch`.
|
|
1840
|
-
*
|
|
1841
|
-
* Per-emit state updates (`_frameBatch`, `_updateState`) have already
|
|
1842
|
-
* happened by the time we reach here; only the **downstream delivery**
|
|
1843
|
-
* is coalesced. Cache, version, and status are visible mid-batch on
|
|
1844
|
-
* the emitting node itself.
|
|
1845
|
-
*/
|
|
1846
|
-
_dispatchOrAccumulate(messages) {
|
|
1847
|
-
if (isExplicitlyBatching()) {
|
|
1848
|
-
if (this._batchPendingMessages === null) {
|
|
1849
|
-
this._batchPendingMessages = [];
|
|
1850
|
-
registerBatchFlushHook(() => this._flushBatchPending());
|
|
1851
|
-
}
|
|
1852
|
-
for (const m of messages) this._batchPendingMessages.push(m);
|
|
1853
|
-
return;
|
|
1854
|
-
}
|
|
1855
|
-
downWithBatch(this._deliverToSinks, messages, this._config.tierOf);
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* @internal Flushes the accumulated batch through `downWithBatch` and
|
|
1859
|
-
* clears the pending state. Idempotent — safe to call when pending is
|
|
1860
|
-
* already null or empty (e.g. on a `batch()` throw, where the hook
|
|
1861
|
-
* fires for cleanup but the drainPhase queues are wiped after).
|
|
1862
|
-
*
|
|
1863
|
-
* Critical: the accumulated batch is interleaved per-emit framings like
|
|
1864
|
-
* `[DIRTY, DATA(1), DIRTY, DATA(2)]` — non-monotone tier order. We must
|
|
1865
|
-
* re-frame to sort by tier before handing to `downWithBatch`, which
|
|
1866
|
-
* assumes pre-sorted input. `_frameBatch` also handles the synthetic
|
|
1867
|
-
* DIRTY prepend rule (no-op here — `hasDirty` is true since each
|
|
1868
|
-
* accumulated emit already carries its own DIRTY prefix).
|
|
1869
|
-
*/
|
|
1870
|
-
_flushBatchPending() {
|
|
1871
|
-
const pending = this._batchPendingMessages;
|
|
1872
|
-
if (pending === null) return;
|
|
1873
|
-
this._batchPendingMessages = null;
|
|
1874
|
-
if (pending.length === 0) return;
|
|
1875
|
-
const framed = this._frameBatch(pending);
|
|
1876
|
-
downWithBatch(this._deliverToSinks, framed, this._config.tierOf);
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
var isNodeArray = (value) => Array.isArray(value);
|
|
1880
|
-
var isNodeOptionsObject = (value) => typeof value === "object" && value != null && !Array.isArray(value);
|
|
1881
|
-
function node(depsOrFn, fnOrOpts, optsArg) {
|
|
1882
|
-
const deps = isNodeArray(depsOrFn) ? depsOrFn : [];
|
|
1883
|
-
const fn = typeof depsOrFn === "function" ? depsOrFn : typeof fnOrOpts === "function" ? fnOrOpts : void 0;
|
|
1884
|
-
let opts = {};
|
|
1885
|
-
if (isNodeArray(depsOrFn)) {
|
|
1886
|
-
opts = (isNodeOptionsObject(fnOrOpts) ? fnOrOpts : optsArg) ?? {};
|
|
1887
|
-
} else if (isNodeOptionsObject(depsOrFn)) {
|
|
1888
|
-
opts = depsOrFn;
|
|
1889
|
-
} else {
|
|
1890
|
-
opts = (isNodeOptionsObject(fnOrOpts) ? fnOrOpts : optsArg) ?? {};
|
|
1891
|
-
}
|
|
1892
|
-
return new NodeImpl(deps, fn, opts);
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
// src/core/sugar.ts
|
|
1896
|
-
function state(initial, opts) {
|
|
1897
|
-
return node([], { ...opts, initial });
|
|
1898
|
-
}
|
|
1899
|
-
function producer(fn, opts) {
|
|
1900
|
-
const wrapped = (_data, actions, ctx) => fn(actions, ctx) ?? void 0;
|
|
1901
|
-
return node(wrapped, { describeKind: "producer", ...opts });
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
// src/extra/cron.ts
|
|
1905
|
-
function parseField(field, min, max) {
|
|
1906
|
-
const result = /* @__PURE__ */ new Set();
|
|
1907
|
-
for (const part of field.split(",")) {
|
|
1908
|
-
const [range, stepStr] = part.split("/");
|
|
1909
|
-
const step = stepStr ? Number.parseInt(stepStr, 10) : 1;
|
|
1910
|
-
if (Number.isNaN(step) || step < 1) throw new Error(`Invalid cron step: ${part}`);
|
|
1911
|
-
let start;
|
|
1912
|
-
let end;
|
|
1913
|
-
if (range === "*") {
|
|
1914
|
-
start = min;
|
|
1915
|
-
end = max;
|
|
1916
|
-
} else if (range.includes("-")) {
|
|
1917
|
-
const [a, b] = range.split("-");
|
|
1918
|
-
start = Number.parseInt(a, 10);
|
|
1919
|
-
end = Number.parseInt(b, 10);
|
|
1920
|
-
} else {
|
|
1921
|
-
start = Number.parseInt(range, 10);
|
|
1922
|
-
end = start;
|
|
1923
|
-
}
|
|
1924
|
-
if (Number.isNaN(start) || Number.isNaN(end)) throw new Error(`Invalid cron field: ${field}`);
|
|
1925
|
-
if (start < min || end > max)
|
|
1926
|
-
throw new Error(`Cron field out of range: ${field} (${min}-${max})`);
|
|
1927
|
-
if (start > end) throw new Error(`Invalid cron range: ${start}-${end} in ${field}`);
|
|
1928
|
-
for (let i = start; i <= end; i += step) result.add(i);
|
|
1929
|
-
}
|
|
1930
|
-
return result;
|
|
1931
|
-
}
|
|
1932
|
-
function parseCron(expr) {
|
|
1933
|
-
const parts = expr.trim().split(/\s+/);
|
|
1934
|
-
if (parts.length !== 5) throw new Error(`Invalid cron: expected 5 fields, got ${parts.length}`);
|
|
1935
|
-
return {
|
|
1936
|
-
minutes: parseField(parts[0], 0, 59),
|
|
1937
|
-
hours: parseField(parts[1], 0, 23),
|
|
1938
|
-
daysOfMonth: parseField(parts[2], 1, 31),
|
|
1939
|
-
months: parseField(parts[3], 1, 12),
|
|
1940
|
-
daysOfWeek: parseField(parts[4], 0, 6)
|
|
1941
|
-
};
|
|
1942
|
-
}
|
|
1943
|
-
function matchesCron(schedule, date) {
|
|
1944
|
-
return schedule.minutes.has(date.getMinutes()) && schedule.hours.has(date.getHours()) && schedule.daysOfMonth.has(date.getDate()) && schedule.months.has(date.getMonth() + 1) && schedule.daysOfWeek.has(date.getDay());
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
// src/extra/sources.ts
|
|
1948
|
-
function sourceOpts(opts) {
|
|
1949
|
-
return { describeKind: "producer", ...opts };
|
|
1950
|
-
}
|
|
1951
|
-
function escapeRegexChar(ch) {
|
|
1952
|
-
return /[\\^$+?.()|[\]{}]/.test(ch) ? `\\${ch}` : ch;
|
|
1953
|
-
}
|
|
1954
|
-
function globToRegExp(glob) {
|
|
1955
|
-
let out = "^";
|
|
1956
|
-
for (let i = 0; i < glob.length; i += 1) {
|
|
1957
|
-
const ch = glob[i];
|
|
1958
|
-
if (ch === "*") {
|
|
1959
|
-
const next = glob[i + 1];
|
|
1960
|
-
if (next === "*") {
|
|
1961
|
-
out += ".*";
|
|
1962
|
-
i += 1;
|
|
1963
|
-
} else {
|
|
1964
|
-
out += "[^/]*";
|
|
1965
|
-
}
|
|
1966
|
-
continue;
|
|
1967
|
-
}
|
|
1968
|
-
out += escapeRegexChar(ch);
|
|
1969
|
-
}
|
|
1970
|
-
out += "$";
|
|
1971
|
-
return new RegExp(out);
|
|
1972
|
-
}
|
|
1973
|
-
function matchesAnyPattern(path, patterns) {
|
|
1974
|
-
for (const pattern of patterns) {
|
|
1975
|
-
if (pattern.test(path)) return true;
|
|
1976
|
-
}
|
|
1977
|
-
return false;
|
|
1978
|
-
}
|
|
1979
|
-
function wrapSubscribeHook(inner, before) {
|
|
1980
|
-
const wrapper = node(
|
|
1981
|
-
[inner],
|
|
1982
|
-
(data, a) => {
|
|
1983
|
-
const batch0 = data[0];
|
|
1984
|
-
if (batch0 == null || batch0.length === 0) {
|
|
1985
|
-
a.down([[RESOLVED]]);
|
|
1986
|
-
return;
|
|
1987
|
-
}
|
|
1988
|
-
for (const v of batch0) a.emit(v);
|
|
1989
|
-
},
|
|
1990
|
-
{ describeKind: "derived", initial: inner.cache }
|
|
1991
|
-
);
|
|
1992
|
-
const origSubscribe = wrapper.subscribe.bind(wrapper);
|
|
1993
|
-
wrapper.subscribe = (sink, actor) => {
|
|
1994
|
-
before(sink);
|
|
1995
|
-
return origSubscribe(sink, actor);
|
|
1996
|
-
};
|
|
1997
|
-
return wrapper;
|
|
1998
|
-
}
|
|
1999
|
-
function fromTimer(ms, opts) {
|
|
2000
|
-
const { signal, period, ...rest } = opts ?? {};
|
|
2001
|
-
return producer((a) => {
|
|
2002
|
-
let done = false;
|
|
2003
|
-
let count = 0;
|
|
2004
|
-
let t;
|
|
2005
|
-
let iv;
|
|
2006
|
-
const cleanup = () => {
|
|
2007
|
-
done = true;
|
|
2008
|
-
if (t !== void 0) clearTimeout(t);
|
|
2009
|
-
if (iv !== void 0) clearInterval(iv);
|
|
2010
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2011
|
-
};
|
|
2012
|
-
const finish = () => {
|
|
2013
|
-
if (done) return;
|
|
2014
|
-
if (period != null) {
|
|
2015
|
-
a.emit(count++);
|
|
2016
|
-
iv = setInterval(() => {
|
|
2017
|
-
if (done) return;
|
|
2018
|
-
a.emit(count++);
|
|
2019
|
-
}, period);
|
|
2020
|
-
} else {
|
|
2021
|
-
done = true;
|
|
2022
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2023
|
-
a.emit(count++);
|
|
2024
|
-
a.down([[COMPLETE]]);
|
|
2025
|
-
}
|
|
2026
|
-
};
|
|
2027
|
-
const onAbort = () => {
|
|
2028
|
-
if (done) return;
|
|
2029
|
-
cleanup();
|
|
2030
|
-
a.down([[ERROR, signal.reason]]);
|
|
2031
|
-
};
|
|
2032
|
-
if (signal?.aborted) {
|
|
2033
|
-
onAbort();
|
|
2034
|
-
return;
|
|
2035
|
-
}
|
|
2036
|
-
t = setTimeout(finish, ms);
|
|
2037
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2038
|
-
return cleanup;
|
|
2039
|
-
}, sourceOpts(rest));
|
|
2040
|
-
}
|
|
2041
|
-
function fromRaf(opts) {
|
|
2042
|
-
const { signal, ...rest } = opts ?? {};
|
|
2043
|
-
return producer((a) => {
|
|
2044
|
-
let done = false;
|
|
2045
|
-
let rafId;
|
|
2046
|
-
let fallbackTimer;
|
|
2047
|
-
let abortListenerAdded = false;
|
|
2048
|
-
let visibilityListenerAdded = false;
|
|
2049
|
-
const raf = typeof requestAnimationFrame === "function" ? requestAnimationFrame : void 0;
|
|
2050
|
-
const caf = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : void 0;
|
|
2051
|
-
const doc = typeof document !== "undefined" ? document : void 0;
|
|
2052
|
-
const clearPending = () => {
|
|
2053
|
-
if (rafId !== void 0 && caf) caf(rafId);
|
|
2054
|
-
if (fallbackTimer !== void 0) clearTimeout(fallbackTimer);
|
|
2055
|
-
rafId = void 0;
|
|
2056
|
-
fallbackTimer = void 0;
|
|
2057
|
-
};
|
|
2058
|
-
const cleanup = () => {
|
|
2059
|
-
done = true;
|
|
2060
|
-
clearPending();
|
|
2061
|
-
if (abortListenerAdded) {
|
|
2062
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2063
|
-
abortListenerAdded = false;
|
|
2064
|
-
}
|
|
2065
|
-
if (visibilityListenerAdded && doc) {
|
|
2066
|
-
doc.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2067
|
-
visibilityListenerAdded = false;
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
const onAbort = () => {
|
|
2071
|
-
if (done) return;
|
|
2072
|
-
cleanup();
|
|
2073
|
-
a.down([[ERROR, signal.reason]]);
|
|
2074
|
-
};
|
|
2075
|
-
const tick = (now) => {
|
|
2076
|
-
if (done) return;
|
|
2077
|
-
a.emit(now);
|
|
2078
|
-
scheduleNext();
|
|
2079
|
-
};
|
|
2080
|
-
const scheduleNext = () => {
|
|
2081
|
-
if (done) return;
|
|
2082
|
-
if (raf && (!doc || doc.visibilityState !== "hidden")) {
|
|
2083
|
-
rafId = raf(tick);
|
|
2084
|
-
} else {
|
|
2085
|
-
fallbackTimer = setTimeout(() => tick(performance.now()), 16);
|
|
2086
|
-
}
|
|
2087
|
-
};
|
|
2088
|
-
const onVisibilityChange = () => {
|
|
2089
|
-
if (done) return;
|
|
2090
|
-
clearPending();
|
|
2091
|
-
scheduleNext();
|
|
2092
|
-
};
|
|
2093
|
-
if (signal?.aborted) {
|
|
2094
|
-
onAbort();
|
|
2095
|
-
return cleanup;
|
|
2096
|
-
}
|
|
2097
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2098
|
-
abortListenerAdded = signal !== void 0;
|
|
2099
|
-
if (doc && raf) {
|
|
2100
|
-
doc.addEventListener("visibilitychange", onVisibilityChange);
|
|
2101
|
-
visibilityListenerAdded = true;
|
|
2102
|
-
}
|
|
2103
|
-
scheduleNext();
|
|
2104
|
-
return cleanup;
|
|
2105
|
-
}, sourceOpts(rest));
|
|
2106
|
-
}
|
|
2107
|
-
function fromCron(expr, opts) {
|
|
2108
|
-
const schedule = parseCron(expr);
|
|
2109
|
-
const { tickMs: tickOpt, output, ...rest } = opts ?? {};
|
|
2110
|
-
const tickMs = tickOpt ?? 6e4;
|
|
2111
|
-
const emitDate = output === "date";
|
|
2112
|
-
return producer(
|
|
2113
|
-
(a) => {
|
|
2114
|
-
let lastFiredKey = -1;
|
|
2115
|
-
const check = () => {
|
|
2116
|
-
const now = /* @__PURE__ */ new Date();
|
|
2117
|
-
const key = now.getFullYear() * 1e8 + (now.getMonth() + 1) * 1e6 + now.getDate() * 1e4 + now.getHours() * 100 + now.getMinutes();
|
|
2118
|
-
if (key !== lastFiredKey && matchesCron(schedule, now)) {
|
|
2119
|
-
lastFiredKey = key;
|
|
2120
|
-
a.emit(emitDate ? now : wallClockNs());
|
|
2121
|
-
}
|
|
2122
|
-
};
|
|
2123
|
-
check();
|
|
2124
|
-
const id = setInterval(check, tickMs);
|
|
2125
|
-
return () => clearInterval(id);
|
|
2126
|
-
},
|
|
2127
|
-
{ ...sourceOpts(rest), name: rest.name ?? `cron:${expr}` }
|
|
2128
|
-
);
|
|
2129
|
-
}
|
|
2130
|
-
function fromEvent(target, type, opts) {
|
|
2131
|
-
const { capture, passive, once, ...rest } = opts ?? {};
|
|
2132
|
-
return producer((a) => {
|
|
2133
|
-
const handler = (e) => {
|
|
2134
|
-
a.emit(e);
|
|
2135
|
-
};
|
|
2136
|
-
const options = { capture, passive, once };
|
|
2137
|
-
target.addEventListener(type, handler, options);
|
|
2138
|
-
return () => target.removeEventListener(type, handler, options);
|
|
2139
|
-
}, sourceOpts(rest));
|
|
2140
|
-
}
|
|
2141
|
-
function fromIter(iterable, opts) {
|
|
2142
|
-
return producer((a) => {
|
|
2143
|
-
let cancelled = false;
|
|
2144
|
-
try {
|
|
2145
|
-
for (const x of iterable) {
|
|
2146
|
-
if (cancelled) return;
|
|
2147
|
-
a.emit(x);
|
|
2148
|
-
}
|
|
2149
|
-
if (!cancelled) a.down([[COMPLETE]]);
|
|
2150
|
-
} catch (e) {
|
|
2151
|
-
if (!cancelled) a.down([[ERROR, e]]);
|
|
2152
|
-
}
|
|
2153
|
-
return () => {
|
|
2154
|
-
cancelled = true;
|
|
2155
|
-
};
|
|
2156
|
-
}, sourceOpts(opts));
|
|
2157
|
-
}
|
|
2158
|
-
function isThenable(x) {
|
|
2159
|
-
return x != null && typeof x.then === "function";
|
|
2160
|
-
}
|
|
2161
|
-
function fromPromise(p, opts) {
|
|
2162
|
-
const { signal, ...rest } = opts ?? {};
|
|
2163
|
-
return producer((a) => {
|
|
2164
|
-
let settled = false;
|
|
2165
|
-
const onAbort = () => {
|
|
2166
|
-
if (settled) return;
|
|
2167
|
-
settled = true;
|
|
2168
|
-
a.down([[ERROR, signal.reason]]);
|
|
2169
|
-
};
|
|
2170
|
-
if (signal?.aborted) {
|
|
2171
|
-
onAbort();
|
|
2172
|
-
return;
|
|
2173
|
-
}
|
|
2174
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2175
|
-
void Promise.resolve(p).then(
|
|
2176
|
-
(v) => {
|
|
2177
|
-
if (settled) return;
|
|
2178
|
-
settled = true;
|
|
2179
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2180
|
-
a.emit(v);
|
|
2181
|
-
a.down([[COMPLETE]]);
|
|
2182
|
-
},
|
|
2183
|
-
(e) => {
|
|
2184
|
-
if (settled) return;
|
|
2185
|
-
settled = true;
|
|
2186
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2187
|
-
a.down([[ERROR, e]]);
|
|
2188
|
-
}
|
|
2189
|
-
);
|
|
2190
|
-
return () => {
|
|
2191
|
-
settled = true;
|
|
2192
|
-
signal?.removeEventListener("abort", onAbort);
|
|
2193
|
-
};
|
|
2194
|
-
}, sourceOpts(rest));
|
|
2195
|
-
}
|
|
2196
|
-
function fromAsyncIter(iterable, opts) {
|
|
2197
|
-
const { signal: outerSignal, ...rest } = opts ?? {};
|
|
2198
|
-
return producer((a) => {
|
|
2199
|
-
const ac = new AbortController();
|
|
2200
|
-
const onOuterAbort = () => ac.abort(outerSignal?.reason);
|
|
2201
|
-
if (outerSignal?.aborted) {
|
|
2202
|
-
ac.abort(outerSignal.reason);
|
|
2203
|
-
} else {
|
|
2204
|
-
outerSignal?.addEventListener("abort", onOuterAbort, { once: true });
|
|
2205
|
-
}
|
|
2206
|
-
const signal = outerSignal ?? ac.signal;
|
|
2207
|
-
let cancelled = false;
|
|
2208
|
-
const it = iterable[Symbol.asyncIterator]();
|
|
2209
|
-
const pump = () => {
|
|
2210
|
-
if (cancelled || signal.aborted) return;
|
|
2211
|
-
void Promise.resolve(it.next()).then(
|
|
2212
|
-
(step) => {
|
|
2213
|
-
if (cancelled || signal.aborted) return;
|
|
2214
|
-
if (step.done) {
|
|
2215
|
-
a.down([[COMPLETE]]);
|
|
2216
|
-
return;
|
|
2217
|
-
}
|
|
2218
|
-
a.emit(step.value);
|
|
2219
|
-
pump();
|
|
2220
|
-
},
|
|
2221
|
-
(e) => {
|
|
2222
|
-
if (!cancelled && !signal.aborted) a.down([[ERROR, e]]);
|
|
2223
|
-
}
|
|
2224
|
-
);
|
|
2225
|
-
};
|
|
2226
|
-
pump();
|
|
2227
|
-
return () => {
|
|
2228
|
-
cancelled = true;
|
|
2229
|
-
outerSignal?.removeEventListener("abort", onOuterAbort);
|
|
2230
|
-
ac.abort();
|
|
2231
|
-
void Promise.resolve(it.return?.()).catch(() => void 0);
|
|
2232
|
-
};
|
|
2233
|
-
}, sourceOpts(rest));
|
|
2234
|
-
}
|
|
2235
|
-
function isNode(x) {
|
|
2236
|
-
return x != null && typeof x === "object" && "cache" in x && typeof x.subscribe === "function";
|
|
2237
|
-
}
|
|
2238
|
-
function fromAny(input, opts) {
|
|
2239
|
-
if (isNode(input)) {
|
|
2240
|
-
return input;
|
|
2241
|
-
}
|
|
2242
|
-
if (isThenable(input)) {
|
|
2243
|
-
return fromPromise(input, opts);
|
|
2244
|
-
}
|
|
2245
|
-
if (input !== null && input !== void 0) {
|
|
2246
|
-
const candidate = input;
|
|
2247
|
-
if (typeof candidate[Symbol.asyncIterator] === "function") {
|
|
2248
|
-
return fromAsyncIter(input, opts);
|
|
2249
|
-
}
|
|
2250
|
-
if (typeof candidate[Symbol.iterator] === "function") {
|
|
2251
|
-
return fromIter(input, opts);
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
return of(input);
|
|
2255
|
-
}
|
|
2256
|
-
function of(...values) {
|
|
2257
|
-
return fromIter(values, void 0);
|
|
2258
|
-
}
|
|
2259
|
-
function empty(opts) {
|
|
2260
|
-
return producer((a) => {
|
|
2261
|
-
a.down([[COMPLETE]]);
|
|
2262
|
-
return void 0;
|
|
2263
|
-
}, sourceOpts(opts));
|
|
2264
|
-
}
|
|
2265
|
-
function never(opts) {
|
|
2266
|
-
return producer(() => void 0, sourceOpts(opts));
|
|
2267
|
-
}
|
|
2268
|
-
function throwError(err, opts) {
|
|
2269
|
-
return producer((a) => {
|
|
2270
|
-
a.down([[ERROR, err]]);
|
|
2271
|
-
return void 0;
|
|
2272
|
-
}, sourceOpts(opts));
|
|
2273
|
-
}
|
|
2274
|
-
function forEach(source, fn, opts) {
|
|
2275
|
-
const inner = node(
|
|
2276
|
-
[source],
|
|
2277
|
-
(data, _actions) => {
|
|
2278
|
-
const batch0 = data[0];
|
|
2279
|
-
if (batch0 != null && batch0.length > 0) {
|
|
2280
|
-
for (const v of batch0) fn(v);
|
|
2281
|
-
}
|
|
2282
|
-
},
|
|
2283
|
-
{ describeKind: "effect", ...opts }
|
|
2284
|
-
);
|
|
2285
|
-
return inner.subscribe(() => {
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
function toArray(source, opts) {
|
|
2289
|
-
return node(
|
|
2290
|
-
[source],
|
|
2291
|
-
(data, actions, ctx) => {
|
|
2292
|
-
if (!ctx.store.buf) ctx.store.buf = [];
|
|
2293
|
-
const buf = ctx.store.buf;
|
|
2294
|
-
const batch0 = data[0];
|
|
2295
|
-
if (batch0 != null && batch0.length > 0) {
|
|
2296
|
-
for (const v of batch0) buf.push(v);
|
|
2297
|
-
}
|
|
2298
|
-
if (ctx.terminalDeps[0] === true) {
|
|
2299
|
-
actions.emit([...buf]);
|
|
2300
|
-
actions.down([[COMPLETE]]);
|
|
2301
|
-
return;
|
|
2302
|
-
}
|
|
2303
|
-
if (batch0 == null || batch0.length === 0) {
|
|
2304
|
-
actions.down([[RESOLVED]]);
|
|
2305
|
-
}
|
|
2306
|
-
},
|
|
2307
|
-
{
|
|
2308
|
-
describeKind: "derived",
|
|
2309
|
-
completeWhenDepsComplete: false,
|
|
2310
|
-
...opts
|
|
2311
|
-
}
|
|
2312
|
-
);
|
|
2313
|
-
}
|
|
2314
|
-
function share(source, opts) {
|
|
2315
|
-
return producer(
|
|
2316
|
-
(a) => source.subscribe((msgs) => {
|
|
2317
|
-
a.down(msgs);
|
|
2318
|
-
}),
|
|
2319
|
-
{ ...sourceOpts(opts), initial: source.cache }
|
|
2320
|
-
);
|
|
2321
|
-
}
|
|
2322
|
-
function replay(source, bufferSize, opts) {
|
|
2323
|
-
if (bufferSize < 1) throw new RangeError("replay expects bufferSize >= 1");
|
|
2324
|
-
const buf = [];
|
|
2325
|
-
const inner = producer(
|
|
2326
|
-
(a) => source.subscribe((msgs) => {
|
|
2327
|
-
for (const m of msgs) {
|
|
2328
|
-
if (m[0] === DATA) {
|
|
2329
|
-
buf.push(m[1]);
|
|
2330
|
-
if (buf.length > bufferSize) buf.shift();
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
a.down(msgs);
|
|
2334
|
-
}),
|
|
2335
|
-
{ ...sourceOpts(opts), initial: source.cache }
|
|
2336
|
-
);
|
|
2337
|
-
return wrapSubscribeHook(inner, (sink) => {
|
|
2338
|
-
for (const v of buf) {
|
|
2339
|
-
sink([[DATA, v]]);
|
|
2340
|
-
}
|
|
2341
|
-
});
|
|
2342
|
-
}
|
|
2343
|
-
function cached(source, opts) {
|
|
2344
|
-
return replay(source, 1, opts);
|
|
2345
|
-
}
|
|
2346
|
-
function firstValueFrom(source) {
|
|
2347
|
-
return new Promise((resolve, reject) => {
|
|
2348
|
-
let settled = false;
|
|
2349
|
-
let shouldUnsub = false;
|
|
2350
|
-
let unsub;
|
|
2351
|
-
unsub = source.subscribe((msgs) => {
|
|
2352
|
-
for (const m of msgs) {
|
|
2353
|
-
if (settled) return;
|
|
2354
|
-
if (m[0] === DATA) {
|
|
2355
|
-
settled = true;
|
|
2356
|
-
resolve(m[1]);
|
|
2357
|
-
if (unsub) {
|
|
2358
|
-
unsub();
|
|
2359
|
-
unsub = void 0;
|
|
2360
|
-
} else shouldUnsub = true;
|
|
2361
|
-
return;
|
|
2362
|
-
}
|
|
2363
|
-
if (m[0] === ERROR) {
|
|
2364
|
-
settled = true;
|
|
2365
|
-
reject(m[1]);
|
|
2366
|
-
if (unsub) {
|
|
2367
|
-
unsub();
|
|
2368
|
-
unsub = void 0;
|
|
2369
|
-
} else shouldUnsub = true;
|
|
2370
|
-
return;
|
|
2371
|
-
}
|
|
2372
|
-
if (m[0] === COMPLETE) {
|
|
2373
|
-
settled = true;
|
|
2374
|
-
reject(new Error("completed without DATA"));
|
|
2375
|
-
if (unsub) {
|
|
2376
|
-
unsub();
|
|
2377
|
-
unsub = void 0;
|
|
2378
|
-
} else shouldUnsub = true;
|
|
2379
|
-
return;
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
});
|
|
2383
|
-
if (shouldUnsub) {
|
|
2384
|
-
unsub?.();
|
|
2385
|
-
unsub = void 0;
|
|
2386
|
-
}
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
function firstWhere(source, predicate) {
|
|
2390
|
-
return new Promise((resolve, reject) => {
|
|
2391
|
-
let settled = false;
|
|
2392
|
-
let shouldUnsub = false;
|
|
2393
|
-
let unsub;
|
|
2394
|
-
unsub = source.subscribe((msgs) => {
|
|
2395
|
-
for (const m of msgs) {
|
|
2396
|
-
if (settled) return;
|
|
2397
|
-
if (m[0] === DATA) {
|
|
2398
|
-
const v = m[1];
|
|
2399
|
-
if (predicate(v)) {
|
|
2400
|
-
settled = true;
|
|
2401
|
-
resolve(v);
|
|
2402
|
-
if (unsub) {
|
|
2403
|
-
unsub();
|
|
2404
|
-
unsub = void 0;
|
|
2405
|
-
} else shouldUnsub = true;
|
|
2406
|
-
return;
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
if (m[0] === ERROR) {
|
|
2410
|
-
settled = true;
|
|
2411
|
-
reject(m[1]);
|
|
2412
|
-
if (unsub) {
|
|
2413
|
-
unsub();
|
|
2414
|
-
unsub = void 0;
|
|
2415
|
-
} else shouldUnsub = true;
|
|
2416
|
-
return;
|
|
2417
|
-
}
|
|
2418
|
-
if (m[0] === COMPLETE) {
|
|
2419
|
-
settled = true;
|
|
2420
|
-
reject(new Error("completed without matching value"));
|
|
2421
|
-
if (unsub) {
|
|
2422
|
-
unsub();
|
|
2423
|
-
unsub = void 0;
|
|
2424
|
-
} else shouldUnsub = true;
|
|
2425
|
-
return;
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
});
|
|
2429
|
-
if (shouldUnsub) {
|
|
2430
|
-
unsub?.();
|
|
2431
|
-
unsub = void 0;
|
|
2432
|
-
}
|
|
2433
|
-
});
|
|
2434
|
-
}
|
|
2435
|
-
var shareReplay = replay;
|
|
2436
|
-
function keepalive(n) {
|
|
2437
|
-
return n.subscribe(() => {
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
|
-
function reactiveCounter(cap) {
|
|
2441
|
-
const counter = state(0);
|
|
2442
|
-
return {
|
|
2443
|
-
node: counter,
|
|
2444
|
-
increment() {
|
|
2445
|
-
const current = counter.cache ?? 0;
|
|
2446
|
-
if (current >= cap) return false;
|
|
2447
|
-
counter.down([[DIRTY], [DATA, current + 1]]);
|
|
2448
|
-
return true;
|
|
2449
|
-
},
|
|
2450
|
-
get() {
|
|
2451
|
-
return counter.cache ?? 0;
|
|
2452
|
-
},
|
|
2453
|
-
atCap() {
|
|
2454
|
-
return (counter.cache ?? 0) >= cap;
|
|
2455
|
-
}
|
|
2456
|
-
};
|
|
2457
|
-
}
|
|
2458
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2459
|
-
0 && (module.exports = {
|
|
2460
|
-
cached,
|
|
2461
|
-
empty,
|
|
2462
|
-
escapeRegexChar,
|
|
2463
|
-
firstValueFrom,
|
|
2464
|
-
firstWhere,
|
|
2465
|
-
forEach,
|
|
2466
|
-
fromAny,
|
|
2467
|
-
fromAsyncIter,
|
|
2468
|
-
fromCron,
|
|
2469
|
-
fromEvent,
|
|
2470
|
-
fromIter,
|
|
2471
|
-
fromPromise,
|
|
2472
|
-
fromRaf,
|
|
2473
|
-
fromTimer,
|
|
2474
|
-
globToRegExp,
|
|
2475
|
-
keepalive,
|
|
2476
|
-
matchesAnyPattern,
|
|
2477
|
-
never,
|
|
2478
|
-
of,
|
|
2479
|
-
reactiveCounter,
|
|
2480
|
-
replay,
|
|
2481
|
-
share,
|
|
2482
|
-
shareReplay,
|
|
2483
|
-
throwError,
|
|
2484
|
-
toArray
|
|
2485
|
-
});
|
|
2486
|
-
//# sourceMappingURL=sources.cjs.map
|
|
1
|
+
"use strict";var ve=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var Te=(t,e)=>{for(var n in e)ve(t,n,{get:e[n],enumerable:!0})},Rt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ot(e))!Ct.call(t,s)&&s!==n&&ve(t,s,{get:()=>e[s],enumerable:!(r=Mt(e,s))||r.enumerable});return t};var Dt=t=>Rt(ve({},"__esModule",{value:!0}),t);function V(){return Math.trunc(performance.now()*1e6)}function se(){return Date.now()*1e6}var ie=E(()=>{"use strict"});var J,b,v,w,R,D,X,S,_,p,H,xe,It,Ne,Ft,Lt,ke,Ue,We,$e,Ee,Z=E(()=>{"use strict";J=Symbol.for("graphrefly/START"),b=Symbol.for("graphrefly/DATA"),v=Symbol.for("graphrefly/DIRTY"),w=Symbol.for("graphrefly/RESOLVED"),R=Symbol.for("graphrefly/INVALIDATE"),D=Symbol.for("graphrefly/PAUSE"),X=Symbol.for("graphrefly/RESUME"),S=Symbol.for("graphrefly/TEARDOWN"),_=Symbol.for("graphrefly/COMPLETE"),p=Symbol.for("graphrefly/ERROR"),H=Object.freeze([v]),xe=Object.freeze([w]),It=Object.freeze([R]),Ne=Object.freeze([J]),Ft=Object.freeze([_]),Lt=Object.freeze([S]),ke=Object.freeze([H]),Ue=Object.freeze([xe]),We=Object.freeze([It]),$e=Object.freeze([Ft]),Ee=Object.freeze([Lt])});function je(t){t.registerCodec(Pt)}var Pt,ze=E(()=>{"use strict";Pt={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}}});function ae(t){if(t==null)return Gt;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var Gt,qe=E(()=>{"use strict";Gt={type:"system",id:""}});function Ye(){return U>0||Q}function Ke(){return U>0}function Je(t){U>0?ee.push(t):t()}function Se(t){U+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(U-=1,U===0)if(e){if(!Q){let n=ee.splice(0);for(let r of n)try{r()}catch{}I.length=0,F.length=0,W.length=0}}else Bt()}}function Bt(){let t=!Q;t&&(Q=!0);let e=[],n=0;try{for(;I.length>0||F.length>0||W.length>0||t&&ee.length>0;){if(t&&ee.length>0){let i=ee.splice(0);for(let o of i)try{o()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw I.length=0,F.length=0,W.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(I.length>0?I:F.length>0?F:W).splice(0);for(let i of s)try{i()}catch(o){e.push(o)}}}finally{t&&(Q=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ue(t,e,n){if(e.length===0)return;if(e.length===1){let d=n(e[0][0]);if(d<3||!Ye()){t(e);return}(d>=5?W:d===4?F:I).push(()=>t(e));return}let r=e.length,s=r,i=r,o=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(i=a;a<r&&n(e[a][0])===4;)a++;o=a;let u=Ye();if(s>0){let d=e.slice(0,s);t(d)}if(i>s){let d=e.slice(s,i);u?I.push(()=>t(d)):t(d)}if(o>i){let d=e.slice(i,o);u?F.push(()=>t(d)):t(d)}if(r>o){let d=e.slice(o,r);u?W.push(()=>t(d)):t(d)}}var U,Q,I,F,W,ee,Ae=E(()=>{"use strict";U=0,Q=!1,I=[],F=[],W=[],ee=[]});function Xe(t){t.registerMessageType(J,{tier:0,wireCrossing:!1}),t.registerMessageType(v,{tier:1,wireCrossing:!1}),t.registerMessageType(R,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(D,{tier:2,wireCrossing:!1}),t.registerMessageType(X,{tier:2,wireCrossing:!1}),t.registerMessageType(b,{tier:3,wireCrossing:!0}),t.registerMessageType(w,{tier:3,wireCrossing:!0}),t.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(p,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(S,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var de,Ze=E(()=>{"use strict";Z();de=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});var $,Qe=E(()=>{"use strict";$=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}}});function Me(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(Me);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=Me(t[n]);return e}return null}function Ut(t){let e=Ht.encode(t),n=e.length,r=n*8,s=n+9+63&-64,i=new Uint8Array(s);i.set(e),i[n]=128;let o=new DataView(i.buffer);o.setUint32(s-4,r>>>0,!1),o.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,l=1359893119,f=2600822924,y=528734635,T=1541459225,g=new Uint32Array(64),m=(x,M)=>x>>>M|x<<32-M;for(let x=0;x<s;x+=64){for(let k=0;k<16;k++)g[k]=o.getUint32(x+k*4,!1);for(let k=16;k<64;k++){let Y=g[k-15],K=g[k-2],oe=m(Y,7)^m(Y,18)^Y>>>3,we=m(K,17)^m(K,19)^K>>>10;g[k]=g[k-16]+oe+g[k-7]+we>>>0}let M=a,z=u,q=d,_e=c,C=l,ne=f,re=y,ye=T;for(let k=0;k<64;k++){let Y=m(C,6)^m(C,11)^m(C,25),K=C&ne^~C&re,oe=ye+Y+K+Vt[k]+g[k]>>>0,we=m(M,2)^m(M,13)^m(M,22),St=M&z^M&q^z&q,At=we+St>>>0;ye=re,re=ne,ne=C,C=_e+oe>>>0,_e=q,q=z,z=M,M=oe+At>>>0}a=a+M>>>0,u=u+z>>>0,d=d+q>>>0,c=c+_e>>>0,l=l+C>>>0,f=f+ne>>>0,y=y+re>>>0,T=T+ye>>>0}let h=x=>x.toString(16).padStart(8,"0");return h(a)+h(u)+h(d)+h(c)+h(l)+h(f)+h(y)+h(T)}function Oe(t){let e=Me(t??null),n=JSON.stringify(e);return Ut(n).slice(0,16)}function Wt(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function Ce(t,e,n){let r=n?.id??Wt();if(t===0)return{id:r,version:0};let i=(n?.hash??Oe)(e);return{id:r,version:0,cid:i,prev:null}}function et(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Vt,Ht,tt=E(()=>{"use strict";Vt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ht=new TextEncoder});function ot(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Re(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function ce(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function O(t,e,n){let r=st(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,i={};return st(t)?i=(De(e)?e:n)??{}:De(t)?i=t:i=(De(e)?e:n)??{},new le(r,s,i)}var nt,rt,$t,jt,Ie,le,st,De,fe=E(()=>{"use strict";ze();qe();Ae();ie();Ze();Qe();Z();tt();nt=()=>{},rt=100;$t=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},jt=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let i=s._cached,o=i===void 0?[Ne]:[Ne,[b,i]];s._status==="dirty"&&o.push(H),ue(e,o,s._config.tierOf)},Ie=new de({onMessage:$t,onSubscribe:jt});Xe(Ie);je(Ie);le=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Ie,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Oe;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?Ce(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(ot);let i={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),i[a]=new t([],void 0,d)}Object.freeze(i),this.meta=i,this._hasMeta=Object.keys(i).length>0;let o=this;this._actions={emit(a){o._emit([[b,a]])},down(a){o._emit(ce(a))},up(a){o._emitUp(ce(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let i=this._cached===void 0?void 0:this._cached,o=this._versioning,a=o?.id??n?.id,u=o?.version??0,d=Ce(e,i,{id:a,hash:s});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=ae(e?.actor),i=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,i))throw new $({actor:s,action:i,nodeName:this.name});if(this._extraGuards!=null){for(let o of this._extraGuards)if(!o(s,i))throw new $({actor:s,action:i,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:se()}}down(e,n){let r=ce(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[b,e]])}up(e,n){if(this._deps.length===0)return;let r=ce(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let i of this._deps)i.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let u=ae(n);if(!this._guard(u,"observe"))throw new $({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)Re(u)}this._sinkCount+=1;let i;try{i=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let o=this._isTerminal;if(this._sinkCount===1&&!o)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof i=="function")try{i()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof i=="function"&&i(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,i=this._deps[r];i.unsub=nt,i.unsub=i.node.subscribe(o=>{if(i.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of o)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let i=this._deps[s];if(i.unsub!=null){let o=i.unsub;i.unsub=null;try{o()}catch{}Re(i)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=ot(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ke),r.unsub=nt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let i=this._config.tierOf,o=!1;for(let a of s)i(a[0])>=3&&(o=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);o&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[p,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[p,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}Re(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let i={kind:"dep_message",depIndex:e,message:n};for(let o of this._inspectorHooks)o(i)}if(s!==J){if(s===v){this._depDirtied(r);return}if(s===R){this._depInvalidated(r),this._emit(We);return}if(s===D||s===X){this._emit([n]);return}if(s===S){this._emit(Ee);return}if(s===b)this._depSettledAsData(r,n[1]);else if(s===w)this._depSettledAsResolved(r);else if(s===_)this._depSettledAsTerminal(r,!0);else if(s===p)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===b||s===w)&&this._emit([n]),(s===_||s===p)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ke))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Ue),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[p,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit($e)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(o){this._emit([[p,this._wrapFnError("cleanup threw",o)]]);return}}else if(e!=null&&typeof e=="object"){let o=e.beforeRun;if(typeof o=="function"){e.beforeRun=void 0;try{o()}catch(a){this._emit([[p,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(o=>o.involvedThisWave?o.dataBatch.length>0?[...o.dataBatch]:[]:void 0),r=this._deps.map(o=>o.prevData);for(let o=0;o<this._deps.length;o++){let a=n[o];a!=null&&a.length>0&&(this._deps[o].prevData=a[a.length-1])}let s=this._deps.map(o=>o.terminal),i={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let o={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(o)}this._isExecutingFn=!0;try{let o=this._fn(n,this._actions,i);if(typeof o=="function")this._cleanup=o;else if(o!=null&&typeof o=="object"){let a=o;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=o)}}catch(o){this._emit([[p,this._wrapFnError("fn threw",o)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>rt?(this._rerunDepth=0,this._emit([[p,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${rt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[H,e[0]]:e;let r=!0,s=!1,i=!1,o=-1;for(let u of e){let d=n(u[0]);d<o&&(r=!1),d===3&&(s=!0),u[0]===v&&(i=!0),o=d}let a=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:n(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(s&&!i&&this._status!=="dirty"){let u=0;for(;u<a.length&&n(a[u][0])===0;)u++;return u===0?[H,...a]:[...a.slice(0,u),H,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===S||u[0]===R);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let u=n[a],d=u[0];if(d!==D&&d!==X){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===D?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=u[1];if(d===D)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(u):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===S))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ee)}catch{}let{finalMessages:i,equalsError:o}=this._updateState(n);if(i.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:i})}catch{}}if(i.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of i){let c=a(d[0]);c<3||c===5?u.push(d):this._pauseBuffer.push(d)}u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(i);o!=null&&this._emit([[p,o]])}_updateState(e){let n=this._config.tierOf,r,s,i=-1,o=0;for(let c of e)n(c[0])===3&&o++;let a=o<=1,u=-1;if(this._versioning!=null&&o>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){u=c;break}}for(let c=0;c<e.length;c++){let l=e[c],f=l[0];if(f===b){if(l.length>=2){let y=!1;if(a&&this._cached!==void 0)try{y=this._equals(this._cached,l[1])}catch(T){s=this._wrapFnError("equals threw",T),i=c;break}if(y){r==null&&(r=e.slice(0,c)),r.push(xe),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(u<0||c===u)&&et(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),f===v)this._status="dirty";else if(f===w)this._status="resolved";else if(f===_)this._status="completed";else if(f===p)this._status="errored";else if(f===R){this._cached=void 0,this._status="dirty";let y=this._cleanup;if(typeof y=="function"){this._cleanup=void 0;try{y()}catch{}}else if(y!=null&&typeof y=="object"){let T=y.invalidate;if(typeof T=="function")try{T()}catch{}}}else f===S&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=i>=0?r??e.slice(0,i):r??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Ke()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Je(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ue(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ue(this._deliverToSinks,n,this._config.tierOf)}},st=t=>Array.isArray(t),De=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function it(t,e){return O([],{...e,initial:t})}function N(t,e){return O((r,s,i)=>t(s,i)??void 0,{describeKind:"producer",...e})}var Fe=E(()=>{"use strict";fe()});function te(t,e,n){let r=new Set;for(let s of t.split(",")){let[i,o]=s.split("/"),a=o?Number.parseInt(o,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let u,d;if(i==="*")u=e,d=n;else if(i.includes("-")){let[c,l]=i.split("-");u=Number.parseInt(c,10),d=Number.parseInt(l,10)}else u=Number.parseInt(i,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${t}`);if(u<e||d>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${t}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function at(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:te(e[0],0,59),hours:te(e[1],0,23),daysOfMonth:te(e[2],1,31),months:te(e[3],1,12),daysOfWeek:te(e[4],0,6)}}function ut(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var dt=E(()=>{"use strict"});var mt={};Te(mt,{NS_PER_MS:()=>P,NS_PER_SEC:()=>j,constant:()=>ct,decorrelatedJitter:()=>ht,exponential:()=>ft,fibonacci:()=>pt,linear:()=>lt,resolveBackoffPreset:()=>pe,withMaxAttempts:()=>Yt});function L(t){return t<0?0:t}function zt(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function qt(t,e){return t+Math.random()*(e-t)}function ct(t){let e=L(t);return()=>e}function lt(t,e){let n=L(t),r=e===void 0?n:L(e);return s=>n+r*Math.max(0,s)}function ft(t){let e=L(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=L(t?.maxDelayNs??30*1e9),s=t?.jitter??"none";return i=>{let o;if(e===0)o=0;else if(n===1)o=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,i);d++){if(u>=a){u=a;break}u*=n}o=e*u,o>r&&(o=r)}return zt(o,s)}}function pt(t=100*1e6,e=30*1e9){let n=L(t),r=L(e);function s(i){if(i<=0)return 1;let o=1,a=2;for(let u=1;u<i;u++){let d=o+a;o=a,a=d}return a}return i=>{let o=s(i)*n;return o<=r?o:r}}function ht(t=100*1e6,e=30*1e9){return(n,r,s)=>{let o=Math.min(e,(s??t)*3);return qt(t,o)}}function Yt(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function pe(t){if(t==="constant")return ct(1*1e9);if(t==="linear")return lt(1*1e9);if(t==="exponential")return ft();if(t==="fibonacci")return pt();if(t==="decorrelatedJitter")return ht();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var P,j,Le=E(()=>{"use strict";P=1e6,j=1e9});var G,bt=E(()=>{"use strict";G=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var yt={};Te(yt,{CircuitOpenError:()=>he,RateLimiterOverflowError:()=>me,TimeoutError:()=>be,circuitBreaker:()=>Zt,fallback:()=>sn,rateLimiter:()=>en,retry:()=>Jt,retrySource:()=>Xt,timeout:()=>an,tokenBucket:()=>_t,withBreaker:()=>Qt,withStatus:()=>tn});function B(t){return{describeKind:"derived",...t}}function Kt(t){return t<0?0:t}function ge(t){return t[1]}function gt(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function Jt(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let i=r===void 0?null:typeof r=="string"?pe(r):r;return N(o=>{let a=0,u=!1,d=null,c,l=new G;function f(){c?.(),c=void 0}function y(g){if(u)return;if(a>=s){f(),o.down([[p,g]]);return}let m=i===null?0:i(a,g,d);if(m==null){f(),o.down([[p,g]]);return}let h;try{h=gt(m)}catch{f(),o.down([[p,g]]);return}d=h,a+=1,f();let x=h>0?h/1e6:1;l.start(x,()=>{u||T()})}function T(){l.cancel(),f(),c=t.subscribe(g=>{if(!u)for(let m of g){let h=m[0];if(h===v)o.down([[v]]);else if(h===b)a=0,d=null,o.emit(m[1]);else if(h===w)o.down([[w]]);else if(h===_)f(),o.down([[_]]);else if(h===p){y(ge(m));return}else o.down([m])}})}return T(),()=>{u=!0,l.cancel(),f()}},{...B(),initial:t.cache})}function Xt(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let i=r===void 0?null:typeof r=="string"?pe(r):r;return N(o=>{let a=0,u=!1,d=null,c,l=new G;function f(){c?.(),c=void 0}function y(g){if(u)return;if(a>=s){f(),o.down([[p,g]]);return}let m=i===null?0:i(a,g,d);if(m==null){f(),o.down([[p,g]]);return}let h;try{h=gt(m)}catch{f(),o.down([[p,g]]);return}d=h,a+=1,f();let x=h>0?h/1e6:1;l.start(x,()=>{u||T()})}function T(){l.cancel(),f();let g;try{g=t()}catch(m){y(m);return}c=g.subscribe(m=>{if(!u)for(let h of m){let x=h[0];if(x===v)o.down([[v]]);else if(x===b)a=0,d=null,o.emit(h[1]);else if(x===w)o.down([[w]]);else if(x===_)f(),o.down([[_]]);else if(x===p){y(ge(h));return}else o.down([h])}})}return T(),()=>{u=!0,l.cancel(),f()}},{...B(),initial:e?.initial})}function Zt(t){let e=Math.max(1,t?.failureThreshold??5),n=Kt(t?.cooldownNs??30*1e9),r=t?.cooldown??null,s=Math.max(1,t?.halfOpenMax??1),i=t?.now??V,o="closed",a=0,u=0,d=0,c=n,l=0;function f(){if(!r)return n;let g=r(u);return g!==null?g:n}function y(){o="open",c=f(),d=i(),l=0}return{canExecute(){return o==="closed"?!0:o==="open"?i()-d>=c?(o="half-open",l=1,!0):!1:l<s?(l++,!0):!1},recordSuccess(){o==="half-open"?(o="closed",a=0,u=0):o==="closed"&&(a=0)},recordFailure(g){if(o==="half-open"){u++,y();return}o==="closed"&&(a++,a>=e&&y())},get state(){return o},get failureCount(){return a},reset(){o="closed",a=0,u=0,l=0}}}function Qt(t,e){let n=e?.onOpen??"skip";return r=>{let s=O([],(i,o)=>{function a(){s.meta.breakerState.down([[b,t.state]])}let u=r.subscribe(d=>{for(let c of d){let l=c[0];l===v?o.down([[v]]):l===b?t.canExecute()?(a(),o.emit(c[1])):(a(),n==="error"?o.down([[p,new he]]):o.down([[w]])):l===w?o.down([[w]]):l===_?(t.recordSuccess(),a(),o.down([[_]])):l===p?(t.recordFailure(ge(c)),a(),o.down([c])):o.down([c])}});return a(),u},{...B(),meta:{breakerState:t.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function _t(t,e){if(t<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let n=t,r=V();function s(i){if(e>0){let o=i-r;n=Math.min(t,n+o/1e9*e)}r=i}return{available(){return s(V()),n},tryConsume(i=1){if(i<=0)return!0;let o=V();return s(o),n>=i?(n-=i,!0):!1},putBack(i=1){i<=0||(s(V()),n=Math.min(t,n+i))}}}function en(t,e){let{maxEvents:n,windowNs:r}=e;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let s=e.maxBuffer;if(s!==void 0&&s<1)throw new RangeError("maxBuffer must be >= 1");let i=e.onOverflow??"drop-newest",o=n*1e9/r;return N(a=>{let u=_t(n,o),d=[],c=new G,l=!1,f=1e9/o;function y(){for(;d.length>0;)if(u.tryConsume(1))a.emit(d.shift());else{c.start(Math.max(1,f/1e6),y);return}}let T=t.subscribe(g=>{for(let m of g){if(l)return;let h=m[0];if(h===v)a.down([[v]]);else if(h===b){if(s!==void 0&&d.length>=s){if(i!=="drop-newest")if(i==="drop-oldest")d.shift(),d.push(m[1]);else{l=!0,c.cancel(),d.length=0,a.down([[p,new me(s)]]);return}}else d.push(m[1]);y()}else if(h===w)a.down([[w]]);else if(h===_)l=!0,c.cancel(),d.length=0,a.down([[_]]);else if(h===p)l=!0,c.cancel(),d.length=0,a.down([m]);else if(h===S){l=!0,c.cancel(),d.length=0,a.down([m]);return}else a.down([m])}});return()=>{l=!0,c.cancel(),T()}},{...B(),initial:t.cache})}function tn(t,e){let n=e?.initialStatus??"pending",r=O([],(s,i)=>{let o=n;return r.meta.status.down([[b,n]]),r.meta.error.down([[b,null]]),t.subscribe(u=>{for(let d of u){let c=d[0];if(c===v)i.down([[v]]);else if(c===b)o==="errored"?Se(()=>{r.meta.error.down([[b,null]]),r.meta.status.down([[b,"active"]])}):r.meta.status.down([[b,"active"]]),o="active",i.emit(d[1]);else if(c===w)i.down([[w]]);else if(c===_)r.meta.status.down([[b,"completed"]]),o="completed",i.down([[_]]);else if(c===p){let l=ge(d);Se(()=>{r.meta.error.down([[b,l]]),r.meta.status.down([[b,"errored"]])}),o="errored",i.down([d])}else i.down([d])}})},{...B(),meta:{status:n,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function nn(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function rn(t){return t!=null&&typeof t.then=="function"}function on(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function sn(t,e){return N(n=>{let r,s;function i(){s?.(),s=void 0,nn(e)||rn(e)||on(e)?r=Pe(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[_]]))}return s=t.subscribe(o=>{for(let a of o){let u=a[0];if(u===v)n.down([[v]]);else if(u===b)n.emit(a[1]);else if(u===w)n.down([[w]]);else if(u===_)n.down([[_]]);else if(u===p){i();return}else if(u===S){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...B(),initial:t.cache})}function an(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return N(n=>{let r=!1,s=new G;function i(){let a=e/1e6;s.start(a,()=>{r||(r=!0,o(),n.down([[p,new be(e)]]))})}let o=t.subscribe(a=>{for(let u of a){if(r)return;let d=u[0];if(d===v)n.down([[v]]);else if(d===b)i(),n.emit(u[1]);else if(d===w)n.down([[w]]);else if(d===_){s.cancel(),r=!0,n.down([[_]]);return}else if(d===p){s.cancel(),r=!0,n.down([u]);return}else if(d===S){s.cancel(),r=!0,n.down([u]);return}else n.down([u])}});return i(),()=>{r=!0,s.cancel(),o()}},{...B(),initial:t.cache})}var he,me,be,wt=E(()=>{"use strict";Ae();ie();Z();fe();Fe();Le();vt();bt();he=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};me=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};be=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Mn={};Te(Mn,{awaitSettled:()=>kn,cached:()=>xn,empty:()=>gn,escapeRegexChar:()=>xt,firstValueFrom:()=>Nn,firstWhere:()=>Be,forEach:()=>wn,fromAny:()=>Pe,fromAsyncIter:()=>kt,fromCron:()=>pn,fromEvent:()=>hn,fromIter:()=>Ve,fromPromise:()=>Nt,fromRaf:()=>fn,fromTimer:()=>ln,globToRegExp:()=>un,keepalive:()=>Sn,matchesAnyPattern:()=>dn,never:()=>_n,of:()=>Et,reactiveCounter:()=>An,replay:()=>He,share:()=>Tn,shareReplay:()=>En,throwError:()=>yn,toArray:()=>vn});module.exports=Dt(Mn);function A(t){return{describeKind:"producer",...t}}function xt(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function un(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){t[n+1]==="*"?(e+=".*",n+=1):e+="[^/]*";continue}e+=xt(r)}return e+="$",new RegExp(e)}function dn(t,e){for(let n of e)if(n.test(t))return!0;return!1}function cn(t,e){let n=O([t],(s,i)=>{let o=s[0];if(o==null||o.length===0){i.down([[w]]);return}for(let a of o)i.emit(a)},{describeKind:"derived",initial:t.cache}),r=n.subscribe.bind(n);return n.subscribe=(s,i)=>(e(s),r(s,i)),n}function ln(t,e){let{signal:n,period:r,...s}=e??{};return N(i=>{let o=!1,a=0,u,d,c=()=>{o=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),n?.removeEventListener("abort",f)},l=()=>{o||(r!=null?(i.emit(a++),d=setInterval(()=>{o||i.emit(a++)},r)):(o=!0,n?.removeEventListener("abort",f),i.emit(a++),i.down([[_]])))},f=()=>{o||(c(),i.down([[p,n.reason]]))};if(n?.aborted){f();return}return u=setTimeout(l,t),n?.addEventListener("abort",f,{once:!0}),c},A(s))}function fn(t){let{signal:e,...n}=t??{};return N(r=>{let s=!1,i,o,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,f=()=>{i!==void 0&&c&&c(i),o!==void 0&&clearTimeout(o),i=void 0,o=void 0},y=()=>{s=!0,f(),a&&(e?.removeEventListener("abort",T),a=!1),u&&l&&(l.removeEventListener("visibilitychange",h),u=!1)},T=()=>{s||(y(),r.down([[p,e.reason]]))},g=x=>{s||(r.emit(x),m())},m=()=>{s||(d&&(!l||l.visibilityState!=="hidden")?i=d(g):o=setTimeout(()=>g(performance.now()),16))},h=()=>{s||(f(),m())};return e?.aborted?(T(),y):(e?.addEventListener("abort",T,{once:!0}),a=e!==void 0,l&&d&&(l.addEventListener("visibilitychange",h),u=!0),m(),y)},A(n))}function pn(t,e){let n=at(t),{tickMs:r,output:s,...i}=e??{},o=r??6e4,a=s==="date";return N(u=>{let d=-1,c=()=>{let f=new Date,y=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();y!==d&&ut(n,f)&&(d=y,u.emit(a?f:se()))};c();let l=setInterval(c,o);return()=>clearInterval(l)},{...A(i),name:i.name??`cron:${t}`})}function hn(t,e,n){let{capture:r,passive:s,once:i,...o}=n??{};return N(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:s,once:i};return t.addEventListener(e,u,d),()=>t.removeEventListener(e,u,d)},A(o))}function Ve(t,e){return N(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[_]])}catch(s){r||n.down([[p,s]])}return()=>{r=!0}},A(e))}function mn(t){return t!=null&&typeof t.then=="function"}function Nt(t,e){let{signal:n,...r}=e??{};return N(s=>{let i=!1,o=()=>{i||(i=!0,s.down([[p,n.reason]]))};if(n?.aborted){o();return}return n?.addEventListener("abort",o,{once:!0}),Promise.resolve(t).then(a=>{i||(i=!0,n?.removeEventListener("abort",o),s.emit(a),s.down([[_]]))},a=>{i||(i=!0,n?.removeEventListener("abort",o),s.down([[p,a]]))}),()=>{i=!0,n?.removeEventListener("abort",o)}},A(r))}function kt(t,e){let{signal:n,...r}=e??{};return N(s=>{let i=new AbortController,o=()=>i.abort(n?.reason);n?.aborted?i.abort(n.reason):n?.addEventListener("abort",o,{once:!0});let a=n??i.signal,u=!1,d=t[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(l=>{if(!(u||a.aborted)){if(l.done){s.down([[_]]);return}s.emit(l.value),c()}},l=>{!u&&!a.aborted&&s.down([[p,l]])})};return c(),()=>{u=!0,n?.removeEventListener("abort",o),i.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},A(r))}function bn(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function Pe(t,e){if(bn(t))return t;if(mn(t))return Nt(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return kt(t,e);if(typeof n[Symbol.iterator]=="function")return Ve(t,e)}return Et(t)}function Et(...t){return Ve(t,void 0)}function gn(t){return N(e=>{e.down([[_]])},A(t))}function _n(t){return N(()=>{},A(t))}function yn(t,e){return N(n=>{n.down([[p,t]])},A(e))}function wn(t,e,n){return O([t],(s,i)=>{let o=s[0];if(o!=null&&o.length>0)for(let a of o)e(a)},{describeKind:"effect",...n}).subscribe(()=>{})}function vn(t,e){return O([t],(n,r,s)=>{s.store.buf||(s.store.buf=[]);let i=s.store.buf,o=n[0];if(o!=null&&o.length>0)for(let a of o)i.push(a);if(s.terminalDeps[0]===!0){r.emit([...i]),r.down([[_]]);return}(o==null||o.length===0)&&r.down([[w]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Tn(t,e){return N(n=>t.subscribe(r=>{n.down(r)}),{...A(e),initial:t.cache})}function He(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=N(i=>t.subscribe(o=>{for(let a of o)a[0]===b&&(r.push(a[1]),r.length>e&&r.shift());i.down(o)}),{...A(n),initial:t.cache});return cn(s,i=>{for(let o of r)i([[b,o]])})}function xn(t,e){return He(t,1,e)}function Nn(t){return new Promise((e,n)=>{let r=!1,s=!1,i;i=t.subscribe(o=>{for(let a of o){if(r)return;if(a[0]===b){r=!0,e(a[1]),i?(i(),i=void 0):s=!0;return}if(a[0]===p){r=!0,n(a[1]),i?(i(),i=void 0):s=!0;return}if(a[0]===_){r=!0,n(new Error("completed without DATA")),i?(i(),i=void 0):s=!0;return}}}),s&&(i?.(),i=void 0)})}function Be(t,e){return new Promise((n,r)=>{let s=!1,i=!1,o;o=t.subscribe(a=>{for(let u of a){if(s)return;if(u[0]===b){let d=u[1];if(e(d)){s=!0,n(d),o?(o(),o=void 0):i=!0;return}}if(u[0]===p){s=!0,r(u[1]),o?(o(),o=void 0):i=!0;return}if(u[0]===_){s=!0,r(new Error("completed without matching value")),o?(o(),o=void 0):i=!0;return}}}),i&&(o?.(),o=void 0)})}async function kn(t,e){let n=e?.predicate??(s=>s!=null);if(e?.timeoutMs==null||e.timeoutMs<=0)return await Be(t,n);if(Ge===void 0){let[s,i]=await Promise.all([Promise.resolve().then(()=>(wt(),yt)),Promise.resolve().then(()=>(Le(),mt))]);Ge=s.timeout,Tt=i.NS_PER_MS}let r=Ge(t,e.timeoutMs*Tt);return await Be(r,n)}function Sn(t){return t.subscribe(()=>{})}function An(t){let e=it(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[v],[b,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var Ge,Tt,En,vt=E(()=>{ie();Z();fe();Fe();dt();En=He});vt();0&&(module.exports={awaitSettled,cached,empty,escapeRegexChar,firstValueFrom,firstWhere,forEach,fromAny,fromAsyncIter,fromCron,fromEvent,fromIter,fromPromise,fromRaf,fromTimer,globToRegExp,keepalive,matchesAnyPattern,never,of,reactiveCounter,replay,share,shareReplay,throwError,toArray});
|