@callable-recharge/callbag-recharge 0.1.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/README.md +259 -0
- package/dist/backoff-BXsH2Ago.d.cts +25 -0
- package/dist/backoff-BXsH2Ago.d.ts +25 -0
- package/dist/chunk-2BINVZ33.js +2 -0
- package/dist/chunk-2BINVZ33.js.map +1 -0
- package/dist/chunk-2E3ALULW.js +2 -0
- package/dist/chunk-2E3ALULW.js.map +1 -0
- package/dist/chunk-2IM76CX3.js +2 -0
- package/dist/chunk-2IM76CX3.js.map +1 -0
- package/dist/chunk-2KKEBHMR.js +2 -0
- package/dist/chunk-2KKEBHMR.js.map +1 -0
- package/dist/chunk-2P6G236K.js +2 -0
- package/dist/chunk-2P6G236K.js.map +1 -0
- package/dist/chunk-4AANJADQ.js +2 -0
- package/dist/chunk-4AANJADQ.js.map +1 -0
- package/dist/chunk-4WFD6EA7.js +2 -0
- package/dist/chunk-4WFD6EA7.js.map +1 -0
- package/dist/chunk-52WEI2L4.js +2 -0
- package/dist/chunk-52WEI2L4.js.map +1 -0
- package/dist/chunk-52YSBIVX.js +2 -0
- package/dist/chunk-52YSBIVX.js.map +1 -0
- package/dist/chunk-5PJCNPKY.js +2 -0
- package/dist/chunk-5PJCNPKY.js.map +1 -0
- package/dist/chunk-6YHJJXF4.js +2 -0
- package/dist/chunk-6YHJJXF4.js.map +1 -0
- package/dist/chunk-7CQ6XF2G.js +2 -0
- package/dist/chunk-7CQ6XF2G.js.map +1 -0
- package/dist/chunk-7WTS4C5R.js +3 -0
- package/dist/chunk-7WTS4C5R.js.map +1 -0
- package/dist/chunk-A6BNAR7H.js +2 -0
- package/dist/chunk-A6BNAR7H.js.map +1 -0
- package/dist/chunk-BNY43SC2.js +2 -0
- package/dist/chunk-BNY43SC2.js.map +1 -0
- package/dist/chunk-C2BNB3CS.js +2 -0
- package/dist/chunk-C2BNB3CS.js.map +1 -0
- package/dist/chunk-COAIGQ25.js +2 -0
- package/dist/chunk-COAIGQ25.js.map +1 -0
- package/dist/chunk-DBAHFYN4.js +2 -0
- package/dist/chunk-DBAHFYN4.js.map +1 -0
- package/dist/chunk-E63D25PW.js +1 -0
- package/dist/chunk-E63D25PW.js.map +1 -0
- package/dist/chunk-E6EZEFS5.js +2 -0
- package/dist/chunk-E6EZEFS5.js.map +1 -0
- package/dist/chunk-EMNGVHNM.js +2 -0
- package/dist/chunk-EMNGVHNM.js.map +1 -0
- package/dist/chunk-F356J323.js +2 -0
- package/dist/chunk-F356J323.js.map +1 -0
- package/dist/chunk-HKDBOVSA.js +2 -0
- package/dist/chunk-HKDBOVSA.js.map +1 -0
- package/dist/chunk-IJNZ5GDS.js +2 -0
- package/dist/chunk-IJNZ5GDS.js.map +1 -0
- package/dist/chunk-IQUXZNBK.js +2 -0
- package/dist/chunk-IQUXZNBK.js.map +1 -0
- package/dist/chunk-IUHESEXZ.js +2 -0
- package/dist/chunk-IUHESEXZ.js.map +1 -0
- package/dist/chunk-IZ5GFMMK.js +2 -0
- package/dist/chunk-IZ5GFMMK.js.map +1 -0
- package/dist/chunk-JCITTHWJ.js +2 -0
- package/dist/chunk-JCITTHWJ.js.map +1 -0
- package/dist/chunk-JS2FB4B3.js +2 -0
- package/dist/chunk-JS2FB4B3.js.map +1 -0
- package/dist/chunk-K7VPCAZD.js +2 -0
- package/dist/chunk-K7VPCAZD.js.map +1 -0
- package/dist/chunk-KDB2NMLA.js +2 -0
- package/dist/chunk-KDB2NMLA.js.map +1 -0
- package/dist/chunk-LHEWNZ3X.js +2 -0
- package/dist/chunk-LHEWNZ3X.js.map +1 -0
- package/dist/chunk-LM26JNAK.js +2 -0
- package/dist/chunk-LM26JNAK.js.map +1 -0
- package/dist/chunk-M6ZEDHQT.js +2 -0
- package/dist/chunk-M6ZEDHQT.js.map +1 -0
- package/dist/chunk-MJB2RHP4.js +2 -0
- package/dist/chunk-MJB2RHP4.js.map +1 -0
- package/dist/chunk-MKQEMUUJ.js +2 -0
- package/dist/chunk-MKQEMUUJ.js.map +1 -0
- package/dist/chunk-MVAQ5TH7.js +2 -0
- package/dist/chunk-MVAQ5TH7.js.map +1 -0
- package/dist/chunk-NEUWMVR4.js +2 -0
- package/dist/chunk-NEUWMVR4.js.map +1 -0
- package/dist/chunk-NSJJXMWD.js +2 -0
- package/dist/chunk-NSJJXMWD.js.map +1 -0
- package/dist/chunk-NUVYBG4B.js +2 -0
- package/dist/chunk-NUVYBG4B.js.map +1 -0
- package/dist/chunk-O5WOX6C7.js +2 -0
- package/dist/chunk-O5WOX6C7.js.map +1 -0
- package/dist/chunk-O7ITRRPK.js +2 -0
- package/dist/chunk-O7ITRRPK.js.map +1 -0
- package/dist/chunk-OHGZIPRU.js +2 -0
- package/dist/chunk-OHGZIPRU.js.map +1 -0
- package/dist/chunk-PXF7567W.js +2 -0
- package/dist/chunk-PXF7567W.js.map +1 -0
- package/dist/chunk-PYRVYHZG.js +2 -0
- package/dist/chunk-PYRVYHZG.js.map +1 -0
- package/dist/chunk-QECUTAQY.js +2 -0
- package/dist/chunk-QECUTAQY.js.map +1 -0
- package/dist/chunk-QPY7RRUK.js +2 -0
- package/dist/chunk-QPY7RRUK.js.map +1 -0
- package/dist/chunk-QYUTDL4D.js +2 -0
- package/dist/chunk-QYUTDL4D.js.map +1 -0
- package/dist/chunk-UEA4RIP5.js +2 -0
- package/dist/chunk-UEA4RIP5.js.map +1 -0
- package/dist/chunk-UHUNMZJO.js +2 -0
- package/dist/chunk-UHUNMZJO.js.map +1 -0
- package/dist/chunk-W5MQVYXW.js +2 -0
- package/dist/chunk-W5MQVYXW.js.map +1 -0
- package/dist/chunk-WHAGQ74D.js +2 -0
- package/dist/chunk-WHAGQ74D.js.map +1 -0
- package/dist/chunk-WRNNR3U5.js +2 -0
- package/dist/chunk-WRNNR3U5.js.map +1 -0
- package/dist/chunk-X6UCLV7L.js +2 -0
- package/dist/chunk-X6UCLV7L.js.map +1 -0
- package/dist/chunk-XHUZ4TRE.js +2 -0
- package/dist/chunk-XHUZ4TRE.js.map +1 -0
- package/dist/chunk-XISWBEKL.js +2 -0
- package/dist/chunk-XISWBEKL.js.map +1 -0
- package/dist/chunk-YCL7NHHW.js +2 -0
- package/dist/chunk-YCL7NHHW.js.map +1 -0
- package/dist/chunk-YMOLNCDC.js +2 -0
- package/dist/chunk-YMOLNCDC.js.map +1 -0
- package/dist/chunk-ZRKP6HCI.js +2 -0
- package/dist/chunk-ZRKP6HCI.js.map +1 -0
- package/dist/data/index.cjs +3 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +32 -0
- package/dist/data/index.d.ts +32 -0
- package/dist/data/index.js +2 -0
- package/dist/data/index.js.map +1 -0
- package/dist/eviction-DGPP1vHP.d.cts +21 -0
- package/dist/eviction-DGPP1vHP.d.ts +21 -0
- package/dist/extra/buffer.cjs +3 -0
- package/dist/extra/buffer.cjs.map +1 -0
- package/dist/extra/buffer.d.cts +21 -0
- package/dist/extra/buffer.d.ts +21 -0
- package/dist/extra/buffer.js +2 -0
- package/dist/extra/buffer.js.map +1 -0
- package/dist/extra/bufferTime.cjs +3 -0
- package/dist/extra/bufferTime.cjs.map +1 -0
- package/dist/extra/bufferTime.d.cts +15 -0
- package/dist/extra/bufferTime.d.ts +15 -0
- package/dist/extra/bufferTime.js +2 -0
- package/dist/extra/bufferTime.js.map +1 -0
- package/dist/extra/combine.cjs +3 -0
- package/dist/extra/combine.cjs.map +1 -0
- package/dist/extra/combine.d.cts +19 -0
- package/dist/extra/combine.d.ts +19 -0
- package/dist/extra/combine.js +2 -0
- package/dist/extra/combine.js.map +1 -0
- package/dist/extra/concat.cjs +3 -0
- package/dist/extra/concat.cjs.map +1 -0
- package/dist/extra/concat.d.cts +18 -0
- package/dist/extra/concat.d.ts +18 -0
- package/dist/extra/concat.js +2 -0
- package/dist/extra/concat.js.map +1 -0
- package/dist/extra/concatMap.cjs +3 -0
- package/dist/extra/concatMap.cjs.map +1 -0
- package/dist/extra/concatMap.d.cts +25 -0
- package/dist/extra/concatMap.d.ts +25 -0
- package/dist/extra/concatMap.js +2 -0
- package/dist/extra/concatMap.js.map +1 -0
- package/dist/extra/debounce.cjs +3 -0
- package/dist/extra/debounce.cjs.map +1 -0
- package/dist/extra/debounce.d.cts +17 -0
- package/dist/extra/debounce.d.ts +17 -0
- package/dist/extra/debounce.js +2 -0
- package/dist/extra/debounce.js.map +1 -0
- package/dist/extra/delay.cjs +3 -0
- package/dist/extra/delay.cjs.map +1 -0
- package/dist/extra/delay.d.cts +15 -0
- package/dist/extra/delay.d.ts +15 -0
- package/dist/extra/delay.js +2 -0
- package/dist/extra/delay.js.map +1 -0
- package/dist/extra/distinctUntilChanged.cjs +3 -0
- package/dist/extra/distinctUntilChanged.cjs.map +1 -0
- package/dist/extra/distinctUntilChanged.d.cts +16 -0
- package/dist/extra/distinctUntilChanged.d.ts +16 -0
- package/dist/extra/distinctUntilChanged.js +2 -0
- package/dist/extra/distinctUntilChanged.js.map +1 -0
- package/dist/extra/elementAt.cjs +3 -0
- package/dist/extra/elementAt.cjs.map +1 -0
- package/dist/extra/elementAt.d.cts +17 -0
- package/dist/extra/elementAt.d.ts +17 -0
- package/dist/extra/elementAt.js +2 -0
- package/dist/extra/elementAt.js.map +1 -0
- package/dist/extra/empty.cjs +3 -0
- package/dist/extra/empty.cjs.map +1 -0
- package/dist/extra/empty.d.cts +13 -0
- package/dist/extra/empty.d.ts +13 -0
- package/dist/extra/empty.js +2 -0
- package/dist/extra/empty.js.map +1 -0
- package/dist/extra/exhaustMap.cjs +3 -0
- package/dist/extra/exhaustMap.cjs.map +1 -0
- package/dist/extra/exhaustMap.d.cts +21 -0
- package/dist/extra/exhaustMap.d.ts +21 -0
- package/dist/extra/exhaustMap.js +2 -0
- package/dist/extra/exhaustMap.js.map +1 -0
- package/dist/extra/filter.cjs +3 -0
- package/dist/extra/filter.cjs.map +1 -0
- package/dist/extra/filter.d.cts +16 -0
- package/dist/extra/filter.d.ts +16 -0
- package/dist/extra/filter.js +2 -0
- package/dist/extra/filter.js.map +1 -0
- package/dist/extra/find.cjs +3 -0
- package/dist/extra/find.cjs.map +1 -0
- package/dist/extra/find.d.cts +17 -0
- package/dist/extra/find.d.ts +17 -0
- package/dist/extra/find.js +2 -0
- package/dist/extra/find.js.map +1 -0
- package/dist/extra/first.cjs +3 -0
- package/dist/extra/first.cjs.map +1 -0
- package/dist/extra/first.d.cts +15 -0
- package/dist/extra/first.d.ts +15 -0
- package/dist/extra/first.js +2 -0
- package/dist/extra/first.js.map +1 -0
- package/dist/extra/flat.cjs +3 -0
- package/dist/extra/flat.cjs.map +1 -0
- package/dist/extra/flat.d.cts +21 -0
- package/dist/extra/flat.d.ts +21 -0
- package/dist/extra/flat.js +2 -0
- package/dist/extra/flat.js.map +1 -0
- package/dist/extra/forEach.cjs +2 -0
- package/dist/extra/forEach.cjs.map +1 -0
- package/dist/extra/forEach.d.cts +13 -0
- package/dist/extra/forEach.d.ts +13 -0
- package/dist/extra/forEach.js +2 -0
- package/dist/extra/forEach.js.map +1 -0
- package/dist/extra/fromEvent.cjs +3 -0
- package/dist/extra/fromEvent.cjs.map +1 -0
- package/dist/extra/fromEvent.d.cts +14 -0
- package/dist/extra/fromEvent.d.ts +14 -0
- package/dist/extra/fromEvent.js +2 -0
- package/dist/extra/fromEvent.js.map +1 -0
- package/dist/extra/fromIter.cjs +3 -0
- package/dist/extra/fromIter.cjs.map +1 -0
- package/dist/extra/fromIter.d.cts +15 -0
- package/dist/extra/fromIter.d.ts +15 -0
- package/dist/extra/fromIter.js +2 -0
- package/dist/extra/fromIter.js.map +1 -0
- package/dist/extra/fromObs.cjs +3 -0
- package/dist/extra/fromObs.cjs.map +1 -0
- package/dist/extra/fromObs.d.cts +25 -0
- package/dist/extra/fromObs.d.ts +25 -0
- package/dist/extra/fromObs.js +2 -0
- package/dist/extra/fromObs.js.map +1 -0
- package/dist/extra/fromPromise.cjs +3 -0
- package/dist/extra/fromPromise.cjs.map +1 -0
- package/dist/extra/fromPromise.d.cts +16 -0
- package/dist/extra/fromPromise.d.ts +16 -0
- package/dist/extra/fromPromise.js +2 -0
- package/dist/extra/fromPromise.js.map +1 -0
- package/dist/extra/index.cjs +3 -0
- package/dist/extra/index.cjs.map +1 -0
- package/dist/extra/index.d.cts +220 -0
- package/dist/extra/index.d.ts +220 -0
- package/dist/extra/index.js +2 -0
- package/dist/extra/index.js.map +1 -0
- package/dist/extra/interval.cjs +3 -0
- package/dist/extra/interval.cjs.map +1 -0
- package/dist/extra/interval.d.cts +15 -0
- package/dist/extra/interval.d.ts +15 -0
- package/dist/extra/interval.js +2 -0
- package/dist/extra/interval.js.map +1 -0
- package/dist/extra/last.cjs +3 -0
- package/dist/extra/last.cjs.map +1 -0
- package/dist/extra/last.d.cts +16 -0
- package/dist/extra/last.d.ts +16 -0
- package/dist/extra/last.js +2 -0
- package/dist/extra/last.js.map +1 -0
- package/dist/extra/map.cjs +3 -0
- package/dist/extra/map.cjs.map +1 -0
- package/dist/extra/map.d.cts +15 -0
- package/dist/extra/map.d.ts +15 -0
- package/dist/extra/map.js +2 -0
- package/dist/extra/map.js.map +1 -0
- package/dist/extra/merge.cjs +3 -0
- package/dist/extra/merge.cjs.map +1 -0
- package/dist/extra/merge.d.cts +21 -0
- package/dist/extra/merge.d.ts +21 -0
- package/dist/extra/merge.js +2 -0
- package/dist/extra/merge.js.map +1 -0
- package/dist/extra/never.cjs +3 -0
- package/dist/extra/never.cjs.map +1 -0
- package/dist/extra/never.d.cts +13 -0
- package/dist/extra/never.d.ts +13 -0
- package/dist/extra/never.js +2 -0
- package/dist/extra/never.js.map +1 -0
- package/dist/extra/of.cjs +3 -0
- package/dist/extra/of.cjs.map +1 -0
- package/dist/extra/of.d.cts +14 -0
- package/dist/extra/of.d.ts +14 -0
- package/dist/extra/of.js +2 -0
- package/dist/extra/of.js.map +1 -0
- package/dist/extra/pairwise.cjs +3 -0
- package/dist/extra/pairwise.cjs.map +1 -0
- package/dist/extra/pairwise.d.cts +16 -0
- package/dist/extra/pairwise.d.ts +16 -0
- package/dist/extra/pairwise.js +2 -0
- package/dist/extra/pairwise.js.map +1 -0
- package/dist/extra/partition.cjs +3 -0
- package/dist/extra/partition.cjs.map +1 -0
- package/dist/extra/partition.d.cts +24 -0
- package/dist/extra/partition.d.ts +24 -0
- package/dist/extra/partition.js +2 -0
- package/dist/extra/partition.js.map +1 -0
- package/dist/extra/pipeRaw.cjs +3 -0
- package/dist/extra/pipeRaw.cjs.map +1 -0
- package/dist/extra/pipeRaw.d.cts +22 -0
- package/dist/extra/pipeRaw.d.ts +22 -0
- package/dist/extra/pipeRaw.js +2 -0
- package/dist/extra/pipeRaw.js.map +1 -0
- package/dist/extra/remember.cjs +3 -0
- package/dist/extra/remember.cjs.map +1 -0
- package/dist/extra/remember.d.cts +17 -0
- package/dist/extra/remember.d.ts +17 -0
- package/dist/extra/remember.js +2 -0
- package/dist/extra/remember.js.map +1 -0
- package/dist/extra/repeat.cjs +3 -0
- package/dist/extra/repeat.cjs.map +1 -0
- package/dist/extra/repeat.d.cts +29 -0
- package/dist/extra/repeat.d.ts +29 -0
- package/dist/extra/repeat.js +2 -0
- package/dist/extra/repeat.js.map +1 -0
- package/dist/extra/rescue.cjs +3 -0
- package/dist/extra/rescue.cjs.map +1 -0
- package/dist/extra/rescue.d.cts +16 -0
- package/dist/extra/rescue.d.ts +16 -0
- package/dist/extra/rescue.js +2 -0
- package/dist/extra/rescue.js.map +1 -0
- package/dist/extra/retry.cjs +3 -0
- package/dist/extra/retry.cjs.map +1 -0
- package/dist/extra/retry.d.cts +29 -0
- package/dist/extra/retry.d.ts +29 -0
- package/dist/extra/retry.js +2 -0
- package/dist/extra/retry.js.map +1 -0
- package/dist/extra/sample.cjs +3 -0
- package/dist/extra/sample.cjs.map +1 -0
- package/dist/extra/sample.d.cts +15 -0
- package/dist/extra/sample.d.ts +15 -0
- package/dist/extra/sample.js +2 -0
- package/dist/extra/sample.js.map +1 -0
- package/dist/extra/scan.cjs +3 -0
- package/dist/extra/scan.cjs.map +1 -0
- package/dist/extra/scan.d.cts +16 -0
- package/dist/extra/scan.d.ts +16 -0
- package/dist/extra/scan.js +2 -0
- package/dist/extra/scan.js.map +1 -0
- package/dist/extra/share.cjs +2 -0
- package/dist/extra/share.cjs.map +1 -0
- package/dist/extra/share.d.cts +12 -0
- package/dist/extra/share.d.ts +12 -0
- package/dist/extra/share.js +2 -0
- package/dist/extra/share.js.map +1 -0
- package/dist/extra/skip.cjs +3 -0
- package/dist/extra/skip.cjs.map +1 -0
- package/dist/extra/skip.d.cts +16 -0
- package/dist/extra/skip.d.ts +16 -0
- package/dist/extra/skip.js +2 -0
- package/dist/extra/skip.js.map +1 -0
- package/dist/extra/startWith.cjs +3 -0
- package/dist/extra/startWith.cjs.map +1 -0
- package/dist/extra/startWith.d.cts +15 -0
- package/dist/extra/startWith.d.ts +15 -0
- package/dist/extra/startWith.js +2 -0
- package/dist/extra/startWith.js.map +1 -0
- package/dist/extra/subject.cjs +3 -0
- package/dist/extra/subject.cjs.map +1 -0
- package/dist/extra/subject.d.cts +27 -0
- package/dist/extra/subject.d.ts +27 -0
- package/dist/extra/subject.js +2 -0
- package/dist/extra/subject.js.map +1 -0
- package/dist/extra/subscribe.cjs +2 -0
- package/dist/extra/subscribe.cjs.map +1 -0
- package/dist/extra/subscribe.d.cts +19 -0
- package/dist/extra/subscribe.d.ts +19 -0
- package/dist/extra/subscribe.js +2 -0
- package/dist/extra/subscribe.js.map +1 -0
- package/dist/extra/switchMap.cjs +3 -0
- package/dist/extra/switchMap.cjs.map +1 -0
- package/dist/extra/switchMap.d.cts +21 -0
- package/dist/extra/switchMap.d.ts +21 -0
- package/dist/extra/switchMap.js +2 -0
- package/dist/extra/switchMap.js.map +1 -0
- package/dist/extra/take.cjs +3 -0
- package/dist/extra/take.cjs.map +1 -0
- package/dist/extra/take.d.cts +15 -0
- package/dist/extra/take.d.ts +15 -0
- package/dist/extra/take.js +2 -0
- package/dist/extra/take.js.map +1 -0
- package/dist/extra/takeUntil.cjs +3 -0
- package/dist/extra/takeUntil.cjs.map +1 -0
- package/dist/extra/takeUntil.d.cts +20 -0
- package/dist/extra/takeUntil.d.ts +20 -0
- package/dist/extra/takeUntil.js +2 -0
- package/dist/extra/takeUntil.js.map +1 -0
- package/dist/extra/tap.cjs +3 -0
- package/dist/extra/tap.cjs.map +1 -0
- package/dist/extra/tap.d.cts +15 -0
- package/dist/extra/tap.d.ts +15 -0
- package/dist/extra/tap.js +2 -0
- package/dist/extra/tap.js.map +1 -0
- package/dist/extra/throttle.cjs +3 -0
- package/dist/extra/throttle.cjs.map +1 -0
- package/dist/extra/throttle.d.cts +16 -0
- package/dist/extra/throttle.d.ts +16 -0
- package/dist/extra/throttle.js +2 -0
- package/dist/extra/throttle.js.map +1 -0
- package/dist/extra/throwError.cjs +3 -0
- package/dist/extra/throwError.cjs.map +1 -0
- package/dist/extra/throwError.d.cts +13 -0
- package/dist/extra/throwError.d.ts +13 -0
- package/dist/extra/throwError.js +2 -0
- package/dist/extra/throwError.js.map +1 -0
- package/dist/extra/timeout.cjs +3 -0
- package/dist/extra/timeout.cjs.map +1 -0
- package/dist/extra/timeout.d.cts +19 -0
- package/dist/extra/timeout.d.ts +19 -0
- package/dist/extra/timeout.js +2 -0
- package/dist/extra/timeout.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +197 -0
- package/dist/index.d.ts +197 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.cjs +3 -0
- package/dist/memory/index.cjs.map +1 -0
- package/dist/memory/index.d.cts +113 -0
- package/dist/memory/index.d.ts +113 -0
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/orchestrate/index.cjs +3 -0
- package/dist/orchestrate/index.cjs.map +1 -0
- package/dist/orchestrate/index.d.cts +101 -0
- package/dist/orchestrate/index.d.ts +101 -0
- package/dist/orchestrate/index.js +2 -0
- package/dist/orchestrate/index.js.map +1 -0
- package/dist/patterns/createStore/index.cjs +3 -0
- package/dist/patterns/createStore/index.cjs.map +1 -0
- package/dist/patterns/createStore/index.d.cts +55 -0
- package/dist/patterns/createStore/index.d.ts +55 -0
- package/dist/patterns/createStore/index.js +2 -0
- package/dist/patterns/createStore/index.js.map +1 -0
- package/dist/types-BiLijSKv.d.cts +192 -0
- package/dist/types-CIITLkgL.d.ts +192 -0
- package/dist/types-DsAN6Hga.d.cts +86 -0
- package/dist/types-DsAN6Hga.d.ts +86 -0
- package/dist/utils/index.cjs +3 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +8 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +141 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/extra/buffer.ts","../../src/core/protocol.ts","../../src/core/inspector.ts","../../src/core/producer.ts","../../src/core/subscribe.ts"],"sourcesContent":["import { Inspector } from \"../core/inspector\";\nimport { producer } from \"../core/producer\";\nimport { END, START } from \"../core/protocol\";\nimport type { Store, StoreOperator } from \"../core/types\";\nimport { subscribe } from \"./subscribe\";\n\n/**\n * Accumulates upstream values into arrays. When the notifier emits,\n * the buffered array is flushed downstream and a new buffer starts.\n *\n * Stateful: maintains current buffer and last flushed array via producer.\n * get() returns the last flushed array (empty array before first flush).\n *\n * v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).\n * Notifier is subscribed via raw callbag for END detection.\n *\n * Error/completion semantics:\n * - Upstream error → forward error, discard buffer\n * - Upstream completion → flush remaining buffer (if any), then complete\n * - Notifier error → forward error, discard buffer\n * - Notifier completion → flush remaining buffer (if any), then complete\n */\nexport function buffer<A>(notifier: Store<unknown>): StoreOperator<A, A[]> {\n\treturn (input: Store<A>) => {\n\t\tconst store = producer<A[]>(\n\t\t\t({ emit, complete, error }) => {\n\t\t\t\tlet currentBuffer: A[] = [];\n\t\t\t\tlet done = false;\n\n\t\t\t\tfunction flushAndComplete() {\n\t\t\t\t\tif (done) return;\n\t\t\t\t\tdone = true;\n\t\t\t\t\tif (currentBuffer.length > 0) {\n\t\t\t\t\t\tconst flushed = currentBuffer;\n\t\t\t\t\t\tObject.freeze(flushed);\n\t\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\t\temit(flushed);\n\t\t\t\t\t}\n\t\t\t\t\tcomplete();\n\t\t\t\t}\n\n\t\t\t\tfunction forwardError(err: unknown) {\n\t\t\t\t\tif (done) return;\n\t\t\t\t\tdone = true;\n\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\terror(err);\n\t\t\t\t}\n\n\t\t\t\tconst inputUnsub = subscribe(\n\t\t\t\t\tinput,\n\t\t\t\t\t(v) => {\n\t\t\t\t\t\tif (!done) currentBuffer.push(v);\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tonEnd: (err) => {\n\t\t\t\t\t\t\tif (err !== undefined) {\n\t\t\t\t\t\t\t\tforwardError(err);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tflushAndComplete();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Clean up notifier\n\t\t\t\t\t\t\tif (notifierTalkback) {\n\t\t\t\t\t\t\t\tnotifierTalkback(END);\n\t\t\t\t\t\t\t\tnotifierTalkback = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tlet notifierTalkback: ((type: number) => void) | null = null;\n\t\t\t\tnotifier.source(START, (type: number, data: unknown) => {\n\t\t\t\t\tif (type === START) notifierTalkback = data as (type: number) => void;\n\t\t\t\t\tif (type === 1 && !done && currentBuffer.length > 0) {\n\t\t\t\t\t\tconst flushed = currentBuffer;\n\t\t\t\t\t\tObject.freeze(flushed);\n\t\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\t\temit(flushed);\n\t\t\t\t\t}\n\t\t\t\t\tif (type === END) {\n\t\t\t\t\t\tnotifierTalkback = null;\n\t\t\t\t\t\tif (data !== undefined) {\n\t\t\t\t\t\t\tforwardError(data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tflushAndComplete();\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Clean up input\n\t\t\t\t\t\tinputUnsub();\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\tdone = true;\n\t\t\t\t\tif (notifierTalkback) notifierTalkback(END);\n\t\t\t\t\tnotifierTalkback = null;\n\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\tinputUnsub();\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ initial: [] as A[] },\n\t\t);\n\n\t\tInspector.register(store, { kind: \"buffer\" });\n\t\treturn store;\n\t};\n}\n","// ---------------------------------------------------------------------------\n// Protocol — v3 type 3 control channel\n// ---------------------------------------------------------------------------\n// Type 3 (STATE) carries control signals: DIRTY, RESOLVED\n// Type 1 (DATA) carries only real values — never sentinels\n// ---------------------------------------------------------------------------\n\n/** Control signal: \"my value is about to change\" */\nexport const DIRTY = Symbol(\"DIRTY\");\n\n/** Control signal: \"I was dirty but my value didn't change\" */\nexport const RESOLVED = Symbol(\"RESOLVED\");\n\nexport type Signal = typeof DIRTY | typeof RESOLVED;\n\n/** Node status — tracks current lifecycle state (v4) */\nexport type NodeStatus =\n\t| \"DISCONNECTED\"\n\t| \"DIRTY\"\n\t| \"SETTLED\"\n\t| \"RESOLVED\"\n\t| \"COMPLETED\"\n\t| \"ERRORED\";\n\n// ---------------------------------------------------------------------------\n// Integer status constants — pack into _flags for hot-path performance.\n// 3 bits (7-9) encode 6 statuses. Use STATUS_MASK to read/write.\n// ---------------------------------------------------------------------------\nexport const S_DISCONNECTED = 0;\nexport const S_DIRTY = 1;\nexport const S_SETTLED = 2;\nexport const S_RESOLVED = 3;\nexport const S_COMPLETED = 4;\nexport const S_ERRORED = 5;\nexport const STATUS_SHIFT = 7;\nexport const STATUS_MASK = 0b111 << STATUS_SHIFT; // bits 7-9\n\nconst STATUS_STRINGS: NodeStatus[] = [\n\t\"DISCONNECTED\",\n\t\"DIRTY\",\n\t\"SETTLED\",\n\t\"RESOLVED\",\n\t\"COMPLETED\",\n\t\"ERRORED\",\n];\n\n/** Decode integer status bits back to string (for Inspector / tests) */\nexport function decodeStatus(flags: number): NodeStatus {\n\treturn STATUS_STRINGS[(flags & STATUS_MASK) >>> STATUS_SHIFT];\n}\n\n/** Callbag signal types */\nexport const START = 0;\nexport const DATA = 1;\nexport const END = 2;\nexport const STATE = 3;\n\n// ---------------------------------------------------------------------------\n// Batch — defers type 1 value emissions; type 3 DIRTY propagates immediately\n// ---------------------------------------------------------------------------\n\nlet batchDepth = 0;\nconst deferredEmissions: Array<() => void> = [];\n\n// `draining` prevents re-entrant drain when a nested batch() call ends while\n// the outer drain loop is already running. Without it, the inner batch's\n// finally block would see batchDepth===0 and start a second drain, racing the\n// outer loop — potentially double-processing items or clearing the array mid-\n// iteration. With draining=true, the inner batch skips its drain; any items it\n// pushes are picked up by the outer loop (the `for` condition re-evaluates\n// `deferredEmissions.length` on every iteration, so appends during drain are\n// naturally included in the same pass).\nlet draining = false;\n\nexport function batch<T>(fn: () => T): T {\n\tbatchDepth++;\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchDepth--;\n\t\tif (batchDepth === 0 && !draining) {\n\t\t\tdraining = true;\n\t\t\tfor (let i = 0; i < deferredEmissions.length; i++) {\n\t\t\t\tdeferredEmissions[i]();\n\t\t\t}\n\t\t\tdeferredEmissions.length = 0;\n\t\t\tdraining = false;\n\t\t}\n\t}\n}\n\nexport function isBatching(): boolean {\n\treturn batchDepth > 0;\n}\n\nexport function deferEmission(fn: () => void): void {\n\tdeferredEmissions.push(fn);\n}\n\n// ---------------------------------------------------------------------------\n// Connection batching (producer start deferral) — unchanged from v2\n// ---------------------------------------------------------------------------\n\nlet connectDepth = 0;\nconst pendingStarts: Array<() => void> = [];\n\nexport function beginDeferredStart(): void {\n\tconnectDepth++;\n}\n\nexport function endDeferredStart(): void {\n\tconnectDepth--;\n\tif (connectDepth === 0) {\n\t\tfor (let i = 0; i < pendingStarts.length; i++) {\n\t\t\tpendingStarts[i]();\n\t\t}\n\t\tpendingStarts.length = 0;\n\t}\n}\n\nexport function deferStart(start: () => void): void {\n\tif (connectDepth > 0) {\n\t\tpendingStarts.push(start);\n\t} else {\n\t\tstart();\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// teardown — protocol-level graph destruction\n// ---------------------------------------------------------------------------\n// Sends END to all downstream sinks of a store node, cascading through the\n// entire subgraph. After teardown, the node is in COMPLETED state and won't\n// accept new values or subscriptions.\n//\n// Works with any node that uses the output slot model:\n// - ProducerImpl / StateImpl / OperatorImpl → calls .complete()\n// - DerivedImpl → calls ._handleEnd() (no public complete() on derived)\n// ---------------------------------------------------------------------------\n\nexport function teardown(store: { source: (type: number, payload?: any) => void }): void {\n\tconst node = store as any;\n\tif (typeof node.complete === \"function\") {\n\t\tnode.complete();\n\t} else if (typeof node._handleEnd === \"function\") {\n\t\tnode._handleEnd(undefined);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Inspector — static class for observability\n// ---------------------------------------------------------------------------\n// All debug metadata lives here in WeakMaps, not on the store objects.\n// Stores stay lean. Inspector is opt-in overhead.\n//\n// v5: Zero intrusion into primitives. No hooks in hot paths. All methods\n// are static — call directly as Inspector.observe(), Inspector.tap(), etc.\n// - register/registerEdge: metadata collection (called from constructors)\n// - inspect/graph/dumpGraph/snapshot: read-only graph queries\n// - observe/spy/trace: callbag sinks for debugging (subscribe externally)\n// - tap: transparent passthrough wrapper for graph visualization\n// ---------------------------------------------------------------------------\n\nimport type { NodeStatus, Signal } from \"./protocol\";\nimport { DATA, DIRTY, END, RESOLVED, START, STATE } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport interface StoreInfo<T = unknown> {\n\tname: string | undefined;\n\tkind: string;\n\tvalue: T;\n\t/** v4: node lifecycle status */\n\tstatus: NodeStatus | undefined;\n}\n\nexport interface ObserveResult<T> {\n\t/** All DATA (type 1) values received, in order */\n\tvalues: T[];\n\t/** All STATE (type 3) payloads received (DIRTY, RESOLVED, or unknown) */\n\tsignals: Signal[];\n\t/** All events in protocol order: { type, data } */\n\tevents: Array<{ type: \"data\" | \"signal\" | \"end\"; data: unknown }>;\n\t/** Whether END (type 2) has been received */\n\tended: boolean;\n\t/** Error payload from END, if any */\n\tendError: unknown;\n\t/** Count of DIRTY signals received */\n\tdirtyCount: number;\n\t/** Count of RESOLVED signals received */\n\tresolvedCount: number;\n\t/** Store name (from Inspector, if registered) */\n\tname: string | undefined;\n\t/** Disconnect the observer */\n\tdispose: () => void;\n}\n\n// Static-only class is intentional API for Inspector namespace\n// biome-ignore lint/complexity/noStaticOnlyClass: public API surface\nexport class Inspector {\n\t// WeakMaps for metadata — keyed by any graph node (stores, effects, etc.)\n\tprivate static _names = new WeakMap<object, string>();\n\tprivate static _kinds = new WeakMap<object, string>();\n\tprivate static _keys = new WeakMap<object, string>();\n\n\t// WeakRef set for graph() — allows GC of unused nodes\n\tprivate static _stores = new Set<WeakRef<object>>();\n\n\t// Dependency edges: parent key → child keys\n\tprivate static _edges = new Map<string, string[]>();\n\n\t// Unique key generation\n\tprivate static _nextId = 0;\n\tprivate static _usedKeys = new Set<string>();\n\n\t// Enabled flag — when false, register/getName are no-ops\n\tprivate static _explicitEnabled: boolean | null = null;\n\tprivate static _cachedDefault: boolean | null = null;\n\n\tstatic get enabled(): boolean {\n\t\tif (Inspector._explicitEnabled !== null) return Inspector._explicitEnabled;\n\t\tif (Inspector._cachedDefault !== null) return Inspector._cachedDefault;\n\t\ttry {\n\t\t\tInspector._cachedDefault = (globalThis as any).process?.env?.NODE_ENV !== \"production\";\n\t\t} catch {\n\t\t\tInspector._cachedDefault = true;\n\t\t}\n\t\treturn Inspector._cachedDefault;\n\t}\n\n\tstatic set enabled(value: boolean) {\n\t\tInspector._explicitEnabled = value;\n\t}\n\n\t/** Compute a dep-name-based suffix for unique key generation */\n\tprivate static _depSuffix(deps?: object[]): string | undefined {\n\t\tif (!deps?.length) return undefined;\n\t\tconst names = deps.map((d) => Inspector._names.get(d) ?? \"?\");\n\t\tconst joined = names.join(\",\");\n\t\treturn joined.length > 40 ? `${joined.slice(0, 37)}...` : joined;\n\t}\n\n\t/** Resolve a node to its unique graph key */\n\tprivate static _resolveKey(node: object): string {\n\t\treturn Inspector._keys.get(node) ?? Inspector._names.get(node) ?? \"anonymous\";\n\t}\n\n\t/** Register a graph node (store, effect, etc.) with the inspector */\n\tstatic register(node: object, opts?: { name?: string; kind?: string; deps?: object[] }): void {\n\t\tif (!Inspector.enabled) return;\n\t\tif (opts?.name) Inspector._names.set(node, opts.name);\n\t\tif (opts?.kind) Inspector._kinds.set(node, opts.kind);\n\n\t\t// Compute unique key\n\t\tconst id = Inspector._nextId++;\n\t\tlet key = opts?.name;\n\t\tif (key && !Inspector._usedKeys.has(key)) {\n\t\t\t// Unique name — use as-is\n\t\t} else if (key) {\n\t\t\t// Name collision — differentiate with dep names or ID\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${key}(${depSuffix})` : `${key}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t} else {\n\t\t\t// Unnamed — use kind + dep names or ID\n\t\t\tconst kind = opts?.kind ?? \"store\";\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${kind}(${depSuffix})` : `${kind}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t}\n\n\t\tInspector._usedKeys.add(key);\n\t\tInspector._keys.set(node, key);\n\t\tInspector._stores.add(new WeakRef(node));\n\t}\n\n\t/** Register a dependency edge between parent and child nodes */\n\tstatic registerEdge(parent: object, child: object): void {\n\t\tif (!Inspector.enabled) return;\n\t\tconst parentKey = Inspector._resolveKey(parent);\n\t\tconst childKey = Inspector._resolveKey(child);\n\t\tconst children = Inspector._edges.get(parentKey);\n\t\tif (children) {\n\t\t\tif (!children.includes(childKey)) children.push(childKey);\n\t\t} else {\n\t\t\tInspector._edges.set(parentKey, [childKey]);\n\t\t}\n\t}\n\n\t/** Get dependency edges: parent → children */\n\tstatic getEdges(): Map<string, string[]> {\n\t\treturn new Map(Inspector._edges);\n\t}\n\n\t/** Get the name of a node */\n\tstatic getName(node: object): string | undefined {\n\t\tif (!Inspector.enabled) return undefined;\n\t\treturn Inspector._names.get(node);\n\t}\n\n\t/** Get the kind of a node */\n\tstatic getKind(node: object): string | undefined {\n\t\treturn Inspector._kinds.get(node);\n\t}\n\n\t/** Inspect a single graph node — includes status and value (if available) */\n\tstatic inspect<T = unknown>(node: object): StoreInfo<T> {\n\t\treturn {\n\t\t\tname: Inspector._names.get(node),\n\t\t\tkind: Inspector._kinds.get(node) ?? \"unknown\",\n\t\t\tvalue: (typeof (node as any).get === \"function\" ? (node as any).get() : undefined) as T,\n\t\t\tstatus: (node as any)._status,\n\t\t};\n\t}\n\n\t/** Get all living nodes as a Map. Also prunes dead edges from GC'd nodes. */\n\tstatic graph(): Map<string, StoreInfo> {\n\t\tconst result = new Map<string, StoreInfo>();\n\t\tconst livingKeys = new Set<string>();\n\t\tfor (const ref of Inspector._stores) {\n\t\t\tconst node = ref.deref();\n\t\t\tif (!node) {\n\t\t\t\tInspector._stores.delete(ref); // cleanup GC'd refs\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = Inspector._resolveKey(node);\n\t\t\tlivingKeys.add(key);\n\t\t\tresult.set(key, Inspector.inspect(node));\n\t\t}\n\t\t// Prune edges referencing GC'd stores\n\t\tfor (const [key, children] of Inspector._edges) {\n\t\t\tif (!livingKeys.has(key)) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t\tInspector._usedKeys.delete(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst alive = children.filter((c) => livingKeys.has(c));\n\t\t\tif (alive.length === 0) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t} else if (alive.length !== children.length) {\n\t\t\t\tInspector._edges.set(key, alive);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Trace a specific store's value changes (raw callbag — no extra/ dependency) */\n\tstatic trace<T>(store: Store<T>, cb: (value: T, prev: T | undefined) => void): () => void {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tlet prev: T | undefined = store.get();\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) talkback = data;\n\t\t\tif (type === END) {\n\t\t\t\ttalkback = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === 1) {\n\t\t\t\tconst next = data as T;\n\t\t\t\tif (!Object.is(next, prev)) {\n\t\t\t\t\tconst p = prev;\n\t\t\t\t\tprev = next;\n\t\t\t\t\tcb(next, p);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn () => talkback?.(END);\n\t}\n\n\t/** Pretty-print the entire store graph for console/CLI debugging */\n\tstatic dumpGraph(): string {\n\t\tconst g = Inspector.graph();\n\t\tconst edges = Inspector.getEdges();\n\n\t\t// Build reverse map: child key → parent keys (deps)\n\t\tconst depsMap = new Map<string, string[]>();\n\t\tfor (const [parent, children] of edges) {\n\t\t\tfor (const child of children) {\n\t\t\t\tconst deps = depsMap.get(child);\n\t\t\t\tif (deps) {\n\t\t\t\t\tif (!deps.includes(parent)) deps.push(parent);\n\t\t\t\t} else {\n\t\t\t\t\tdepsMap.set(child, [parent]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst lines: string[] = [];\n\t\tfor (const [key, info] of g) {\n\t\t\tconst deps = depsMap.get(key);\n\t\t\tconst children = edges.get(key);\n\t\t\tconst depsStr = deps?.length ? ` ← [${deps.join(\", \")}]` : \"\";\n\t\t\tconst childStr = children?.length ? ` → [${children.join(\", \")}]` : \"\";\n\t\t\tlines.push(\n\t\t\t\t` ${key} (${info.kind}) = ${JSON.stringify(info.value)} [${info.status ?? \"?\"}]${depsStr}${childStr}`,\n\t\t\t);\n\t\t}\n\t\tconst header = `Store Graph (${g.size} nodes):`;\n\t\treturn [header, ...lines].join(\"\\n\");\n\t}\n\n\t/**\n\t * Internal observe implementation shared by observe() and spy().\n\t */\n\tprivate static _observe<T>(\n\t\tstore: Store<T>,\n\t\tlabel?: string,\n\t\tlog?: (...args: any[]) => void,\n\t): ObserveResult<T> {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tconst name = label ?? Inspector.getName(store);\n\t\tconst result: ObserveResult<T> = {\n\t\t\tvalues: [],\n\t\t\tsignals: [],\n\t\t\tevents: [],\n\t\t\tended: false,\n\t\t\tendError: undefined,\n\t\t\tdirtyCount: 0,\n\t\t\tresolvedCount: 0,\n\t\t\tname,\n\t\t\tdispose: () => talkback?.(END),\n\t\t};\n\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\ttalkback = data;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === DATA) {\n\t\t\t\tresult.values.push(data);\n\t\t\t\tresult.events.push({ type: \"data\", data });\n\t\t\t\tif (log) log(`[${name}] DATA:`, data);\n\t\t\t} else if (type === STATE) {\n\t\t\t\tresult.signals.push(data);\n\t\t\t\tresult.events.push({ type: \"signal\", data });\n\t\t\t\tif (data === DIRTY) result.dirtyCount++;\n\t\t\t\telse if (data === RESOLVED) result.resolvedCount++;\n\t\t\t\tif (log) log(`[${name}] STATE:`, data);\n\t\t\t} else if (type === END) {\n\t\t\t\tresult.ended = true;\n\t\t\t\tresult.endError = data;\n\t\t\t\tresult.events.push({ type: \"end\", data });\n\t\t\t\tif (log) log(`[${name}] END`, data !== undefined ? data : \"\");\n\t\t\t\ttalkback = null;\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Observe a store's full callbag protocol — the test-friendly alternative\n\t * to hooks. Captures DATA values, STATE signals, END, and provides\n\t * convenience accessors.\n\t *\n\t * Returns a live observation object — arrays grow as the store emits.\n\t *\n\t * ```ts\n\t * const obs = Inspector.observe(myStore);\n\t * myState.set(5);\n\t * obs.values // [5]\n\t * obs.signals // [DIRTY]\n\t * obs.ended // false\n\t * obs.dirtyCount // 1\n\t * obs.dispose() // stop observing\n\t * ```\n\t */\n\tstatic observe<T>(store: Store<T>): ObserveResult<T> {\n\t\treturn Inspector._observe(store);\n\t}\n\n\t/**\n\t * Create a transparent passthrough wrapper for graph visualization.\n\t * The wrapper delegates `get()` and `source()` to the original store,\n\t * appearing as a distinct node in the Inspector graph. Zero overhead —\n\t * subscribers connect directly to the original store's source.\n\t */\n\tstatic tap<T>(store: Store<T>, name?: string): Store<T> {\n\t\tconst tapName = name ?? `tap(${Inspector.getName(store) ?? \"anon\"})`;\n\t\tconst wrapper: Store<T> = {\n\t\t\tget: () => store.get(),\n\t\t\tsource: store.source,\n\t\t};\n\t\tInspector.register(wrapper, { name: tapName, kind: \"tap\" });\n\t\tInspector.registerEdge(store, wrapper);\n\t\treturn wrapper;\n\t}\n\n\t/**\n\t * Enhanced observe() with logging — for interactive debugging.\n\t * Returns the same observation object as observe(), but also logs each\n\t * event as it happens. Pass a custom logger or defaults to console.log.\n\t */\n\tstatic spy<T>(\n\t\tstore: Store<T>,\n\t\topts?: { name?: string; log?: (...args: any[]) => void },\n\t): ObserveResult<T> {\n\t\tconst label = opts?.name ?? Inspector.getName(store) ?? \"spy\";\n\t\tconst log = opts?.log ?? console.log;\n\t\treturn Inspector._observe(store, label, log);\n\t}\n\n\t/**\n\t * JSON-serializable snapshot of the entire graph — nodes + edges.\n\t * Designed for AI consumption during debugging sessions.\n\t */\n\tstatic snapshot(): {\n\t\tnodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }>;\n\t\tedges: Array<{ from: string; to: string }>;\n\t} {\n\t\tconst g = Inspector.graph();\n\t\tconst edgeMap = Inspector.getEdges();\n\t\tconst nodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }> =\n\t\t\t[];\n\t\tfor (const [key, info] of g) {\n\t\t\tnodes.push({ name: key, kind: info.kind, value: info.value, status: info.status });\n\t\t}\n\t\tconst edges: Array<{ from: string; to: string }> = [];\n\t\tfor (const [parent, children] of edgeMap) {\n\t\t\tfor (const child of children) {\n\t\t\t\tedges.push({ from: parent, to: child });\n\t\t\t}\n\t\t}\n\t\treturn { nodes, edges };\n\t}\n\n\t/** Reset all state (for testing) */\n\tstatic _reset(): void {\n\t\tInspector._names = new WeakMap<object, string>();\n\t\tInspector._kinds = new WeakMap<object, string>();\n\t\tInspector._keys = new WeakMap<object, string>();\n\t\tInspector._stores = new Set<WeakRef<object>>();\n\t\tInspector._edges = new Map();\n\t\tInspector._usedKeys = new Set();\n\t\tInspector._nextId = 0;\n\t\tInspector._explicitEnabled = null;\n\t\tInspector._cachedDefault = null;\n\t}\n}\n","/**\n * General-purpose source primitive. Can emit values, send control signals,\n * complete, and error. Lazy start on first sink, auto-cleanup on last\n * sink disconnect.\n *\n * Stateful: maintains currentValue. get() returns currentValue (or\n * getter(currentValue) when getter option is provided).\n *\n * v4: Output slot model replaces _sinks Set. _output is null (no sinks),\n * a function (single sink — P0 optimization), or a Set (multi sink).\n * _status tracks node lifecycle. autoDirty (default true) sends DIRTY on\n * type 3 before each type 1 DATA. equals option guards emit();\n * resetOnTeardown resets value on stop.\n *\n * v5: _status packed into _flags bits 7-9 for hot-path performance.\n * String status exposed via getter for Inspector/test backward compat.\n *\n * Class-based for V8 hidden class optimization and prototype method sharing.\n * Boolean fields packed into _flags bitmask to reduce hidden class size.\n */\n\nimport { Inspector } from \"./inspector\";\nimport type { Signal } from \"./protocol\";\nimport {\n\tDATA,\n\tDIRTY,\n\tdecodeStatus,\n\tdeferEmission,\n\tdeferStart,\n\tEND,\n\tisBatching,\n\tRESOLVED,\n\tS_COMPLETED,\n\tS_DIRTY,\n\tS_DISCONNECTED,\n\tS_ERRORED,\n\tS_RESOLVED,\n\tS_SETTLED,\n\tSTART,\n\tSTATE,\n\tSTATUS_MASK,\n\tSTATUS_SHIFT,\n} from \"./protocol\";\nimport type { ProducerStore, SourceOptions, Store } from \"./types\";\n\nexport type ProducerFn<T> = (actions: {\n\temit: (value: T) => void;\n\tsignal: (s: Signal) => void;\n\tcomplete: () => void;\n\terror: (e: unknown) => void;\n}) => (() => void) | undefined;\n\nexport type ProducerOpts<T> = SourceOptions<T> & {\n\tautoDirty?: boolean;\n\t_skipInspect?: boolean;\n};\n\n// Flag bits for _flags bitmask (bits 0-6)\nconst P_STARTED = 1;\nconst P_MULTI = 64;\n\n// Exported for subclass fast paths (StateImpl)\nexport const P_COMPLETED = 2;\nexport const P_AUTO_DIRTY = 4;\nconst P_RESET = 8;\nconst P_RESUB = 16;\nexport const P_PENDING = 32;\n\n// Status bits (bits 7-9) — exported for StateImpl fast path\nexport const _STATUS_MASK = STATUS_MASK;\nexport const _S_DIRTY = S_DIRTY << STATUS_SHIFT;\nexport const _S_SETTLED = S_SETTLED << STATUS_SHIFT;\nexport const _S_DISCONNECTED = S_DISCONNECTED << STATUS_SHIFT;\nexport const _S_COMPLETED = S_COMPLETED << STATUS_SHIFT;\nexport const _S_ERRORED = S_ERRORED << STATUS_SHIFT;\nexport const _S_RESOLVED = S_RESOLVED << STATUS_SHIFT;\n\nexport class ProducerImpl<T> {\n\t_value: T | undefined;\n\t_output: ((type: number, data?: any) => void) | Set<any> | null = null;\n\t_flags: number;\n\n\tget _status() {\n\t\treturn decodeStatus(this._flags);\n\t}\n\t_cleanup: (() => void) | undefined;\n\t_fn: ProducerFn<T> | undefined;\n\t_eqFn: ((a: T, b: T) => boolean) | undefined;\n\t_getterFn: ((cached: T | undefined) => T) | undefined;\n\t_initial: T | undefined;\n\n\tconstructor(fn?: ProducerFn<T>, opts?: ProducerOpts<T>) {\n\t\tthis._value = opts?.initial;\n\t\tthis._fn = fn;\n\t\tthis._eqFn = opts?.equals;\n\t\tthis._getterFn = opts?.getter;\n\t\tthis._initial = opts?.initial;\n\n\t\tlet flags = 0;\n\t\tif (opts?.autoDirty !== false) flags |= P_AUTO_DIRTY;\n\t\tif (opts?.resetOnTeardown) flags |= P_RESET;\n\t\tif (opts?.resubscribable) flags |= P_RESUB;\n\t\t// S_DISCONNECTED = 0, so no need to set status bits\n\t\tthis._flags = flags;\n\n\t\t// Bind public API methods so they work when detached (callbag interop,\n\t\t// destructuring, etc.). Replaces per-instance closure functions.\n\t\tthis.source = this.source.bind(this);\n\t\tthis.emit = this.emit.bind(this);\n\t\tthis.signal = this.signal.bind(this);\n\t\tthis.complete = this.complete.bind(this);\n\t\tthis.error = this.error.bind(this);\n\n\t\tif (!opts?._skipInspect) Inspector.register(this as any, { kind: \"producer\", ...opts });\n\t}\n\n\tget(): T | undefined {\n\t\treturn this._getterFn ? this._getterFn(this._value) : this._value;\n\t}\n\n\t/**\n\t * Dispatch a signal to all current subscribers via the output slot.\n\t *\n\t * Safety: P_MULTI flag and _output type are always updated together.\n\t * No reentrancy can occur between the two assignments (source() doesn't\n\t * trigger dispatch, and dispatch doesn't trigger source()). The null-check\n\t * provides an additional guard for the MULTI→null transition path.\n\t */\n\t_dispatch(type: number, data?: any): void {\n\t\tconst output = this._output;\n\t\tif (!output) return;\n\t\tif (this._flags & P_MULTI) {\n\t\t\tfor (const sink of output as Set<any>) sink(type, data);\n\t\t} else {\n\t\t\t(output as (type: number, data?: any) => void)(type, data);\n\t\t}\n\t}\n\n\temit(value: T): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tif (this._eqFn && this._value !== undefined && this._eqFn(this._value as T, value)) return;\n\t\tthis._value = value;\n\t\tif (!this._output) return;\n\t\tif (isBatching()) {\n\t\t\tif (!(this._flags & P_PENDING)) {\n\t\t\t\tthis._flags |= P_PENDING;\n\t\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t}\n\t\t\t\tdeferEmission(() => {\n\t\t\t\t\tthis._flags &= ~P_PENDING;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\t\t\tthis._dispatch(DATA, this._value);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t}\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\tthis._dispatch(DATA, this._value);\n\t\t}\n\t}\n\n\tsignal(s: Signal): void {\n\t\tif (this._flags & P_COMPLETED || !this._output) return;\n\t\tif (s === DIRTY) this._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\telse if (s === RESOLVED) this._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t// Unknown signals: dispatch without _status change (v4 forward-compat)\n\t\tthis._dispatch(STATE, s);\n\t}\n\n\tcomplete(): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_COMPLETED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END);\n\t\t\t}\n\t\t}\n\t}\n\n\terror(e: unknown): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_ERRORED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END, e);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END, e);\n\t\t\t}\n\t\t}\n\t}\n\n\t_start(): void {\n\t\tif (this._flags & P_STARTED || !this._fn) return;\n\t\tthis._flags |= P_STARTED;\n\t\tconst result = this._fn(this as any);\n\t\tthis._cleanup = typeof result === \"function\" ? result : undefined;\n\t}\n\n\t_stop(): void {\n\t\tif (!(this._flags & P_STARTED)) return;\n\t\tthis._flags &= ~P_STARTED;\n\t\tif (this._cleanup) this._cleanup();\n\t\tthis._cleanup = undefined;\n\t\tif (this._flags & P_RESET) this._value = this._initial;\n\t\tif (!(this._flags & P_COMPLETED)) this._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t}\n\n\tsource(type: number, payload?: any): void {\n\t\tif (type === START) {\n\t\t\tconst sink = payload;\n\t\t\tif (this._flags & P_COMPLETED) {\n\t\t\t\tif (this._flags & P_RESUB && this._output === null) {\n\t\t\t\t\tthis._flags = (this._flags & ~(P_COMPLETED | _STATUS_MASK)) | _S_DISCONNECTED;\n\t\t\t\t} else {\n\t\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\t\tsink(END);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._output === null) {\n\t\t\t\tthis._output = sink;\n\t\t\t} else if (!(this._flags & P_MULTI)) {\n\t\t\t\tconst set = new Set<any>();\n\t\t\t\tset.add(this._output);\n\t\t\t\tset.add(sink);\n\t\t\t\tthis._output = set;\n\t\t\t\tthis._flags |= P_MULTI;\n\t\t\t} else {\n\t\t\t\t(this._output as Set<any>).add(sink);\n\t\t\t}\n\t\t\tsink(START, (t: number) => {\n\t\t\t\tif (t === DATA) sink(DATA, this._value);\n\t\t\t\tif (t === END) {\n\t\t\t\t\tif (this._output === null) return;\n\t\t\t\t\tif (this._flags & P_MULTI) {\n\t\t\t\t\t\tconst set = this._output as Set<any>;\n\t\t\t\t\t\tset.delete(sink);\n\t\t\t\t\t\tif (set.size === 1) {\n\t\t\t\t\t\t\tthis._output = set.values().next().value;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t} else if (set.size === 0) {\n\t\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this._output === sink) {\n\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tdeferStart(() => this._start());\n\t\t}\n\t}\n}\n\nexport function producer<T>(\n\tfn: ProducerFn<T> | undefined,\n\topts: ProducerOpts<T> & { initial: T },\n): ProducerStore<T> & Store<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T> {\n\treturn new ProducerImpl<T>(fn, opts) as any;\n}\n","/**\n * Core subscribe — reusable callbag sink connector.\n *\n * Used as the base for:\n * - External subscribe (extra/subscribe re-exports this)\n * - Derived's dep connections (STANDALONE mode)\n * - Effect's dep connections\n *\n * v4: Handles callbag START handshake, filters STATE for user callbacks,\n * provides prev-value tracking. Returns unsub function.\n */\n\nimport { beginDeferredStart, END, endDeferredStart, START } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport function subscribe<T>(\n\tstore: Store<T>,\n\tcb: (value: T, prev: T | undefined) => void,\n\topts?: { onEnd?: (error?: unknown) => void },\n): () => void {\n\tlet talkback: ((type: number) => void) | null = null;\n\n\tbeginDeferredStart();\n\n\t// `prev` is declared after store.source() but the closure only reads it\n\t// after endDeferredStart() triggers producers. By that point prev is already\n\t// set to store.get(). Order: register sink → read baseline → start producers.\n\tstore.source(START, (type: number, data: any) => {\n\t\tif (type === START) talkback = data;\n\t\tif (type === END) {\n\t\t\ttalkback = null;\n\t\t\topts?.onEnd?.(data);\n\t\t\treturn;\n\t\t}\n\t\t// Transparent sink — forwards every DATA to the callback.\n\t\t// Dedup (if desired) belongs in the source (state's equals) or in\n\t\t// an explicit operator (distinctUntilChanged), not here.\n\t\tif (type === 1 /* DATA */) {\n\t\t\tconst next = data as T;\n\t\t\tconst p = prev;\n\t\t\tprev = next;\n\t\t\tcb(next, p);\n\t\t}\n\t});\n\n\t// Baseline: captures current value before producers start. Aligns with\n\t// RxJS Observable semantics — no initial-value callback on subscribe.\n\tlet prev: T | undefined = store.get();\n\n\tendDeferredStart();\n\n\treturn () => talkback?.(END);\n}\n"],"mappings":"ibAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,YAAAE,KAAA,eAAAC,GAAAH,ICQO,IAAMI,EAAQ,OAAO,OAAO,EAGtBC,EAAW,OAAO,UAAU,EAiB5BC,EAAiB,EACjBC,EAAU,EACVC,EAAY,EACZC,EAAa,EACbC,EAAc,EACdC,EAAY,EACZC,EAAe,EACfC,EAAc,GAASD,EAE9BE,GAA+B,CACpC,eACA,QACA,UACA,WACA,YACA,SACD,EAGO,SAASC,EAAaC,EAA2B,CACvD,OAAOF,IAAgBE,EAAQH,KAAiBD,CAAY,CAC7D,CAGO,IAAMK,EAAQ,EACRC,EAAO,EACPC,EAAM,EACNC,EAAQ,EAMjBC,GAAa,EACXC,GAAuC,CAAC,EA6BvC,SAASC,GAAsB,CACrC,OAAOC,GAAa,CACrB,CAEO,SAASC,EAAcC,EAAsB,CACnDC,GAAkB,KAAKD,CAAE,CAC1B,CAMA,IAAIE,EAAe,EACbC,EAAmC,CAAC,EAEnC,SAASC,GAA2B,CAC1CF,GACD,CAEO,SAASG,GAAyB,CAExC,GADAH,IACIA,IAAiB,EAAG,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AOkB,EAAO,CAACC,EAAcC,IAAkB,CAEvD,GADID,IAASD,IAAOF,EAAmBI,GACnCD,IAAS,GAAK,CAACX,GAAQD,EAAc,OAAS,EAAG,CACpD,IAAMG,EAAUH,EAChB,OAAO,OAAOG,CAAO,EACrBH,EAAgB,CAAC,EACjBH,EAAKM,CAAO,CACb,CACIS,IAASF,IACZD,EAAmB,KACfI,IAAS,OACZT,EAAaS,CAAI,EAEjBX,EAAiB,EAGlBI,EAAW,EAEb,CAAC,EAEM,IAAM,CACZL,EAAO,GACHQ,GAAkBA,EAAiBC,CAAG,EAC1CD,EAAmB,KACnBT,EAAgB,CAAC,EACjBM,EAAW,CACZ,CACD,EACA,CAAE,QAAS,CAAC,CAAS,CACtB,EAEA,OAAAQ,EAAU,SAASnB,EAAO,CAAE,KAAM,QAAS,CAAC,EACrCA,CACR,CACD","names":["buffer_exports","__export","buffer","__toCommonJS","DIRTY","RESOLVED","S_DISCONNECTED","S_DIRTY","S_SETTLED","S_RESOLVED","S_COMPLETED","S_ERRORED","STATUS_SHIFT","STATUS_MASK","STATUS_STRINGS","decodeStatus","flags","START","DATA","END","STATE","batchDepth","deferredEmissions","isBatching","batchDepth","deferEmission","fn","deferredEmissions","connectDepth","pendingStarts","beginDeferredStart","endDeferredStart","i","deferStart","start","Inspector","_Inspector","value","deps","joined","d","node","opts","id","key","depSuffix","kind","parent","child","parentKey","childKey","children","result","livingKeys","ref","alive","c","store","cb","talkback","prev","START","type","data","END","next","p","g","edges","depsMap","lines","info","depsStr","childStr","label","log","name","DATA","STATE","DIRTY","RESOLVED","tapName","wrapper","edgeMap","nodes","P_STARTED","P_MULTI","P_COMPLETED","P_AUTO_DIRTY","P_RESET","P_RESUB","P_PENDING","_STATUS_MASK","STATUS_MASK","_S_DIRTY","S_DIRTY","STATUS_SHIFT","_S_SETTLED","S_SETTLED","_S_DISCONNECTED","S_DISCONNECTED","_S_COMPLETED","S_COMPLETED","_S_ERRORED","S_ERRORED","_S_RESOLVED","S_RESOLVED","ProducerImpl","decodeStatus","fn","opts","flags","Inspector","type","data","output","sink","value","isBatching","STATE","DIRTY","deferEmission","DATA","s","RESOLVED","wasMulti","END","e","result","payload","START","_t","set","t","deferStart","producer","subscribe","store","cb","opts","talkback","beginDeferredStart","START","type","data","END","next","p","prev","endDeferredStart","buffer","notifier","input","store","producer","emit","complete","error","currentBuffer","done","flushAndComplete","flushed","forwardError","err","inputUnsub","subscribe","v","notifierTalkback","END","START","type","data","Inspector"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S as Store, a as StoreOperator } from '../types-DsAN6Hga.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Accumulates upstream values into arrays. When the notifier emits,
|
|
5
|
+
* the buffered array is flushed downstream and a new buffer starts.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains current buffer and last flushed array via producer.
|
|
8
|
+
* get() returns the last flushed array (empty array before first flush).
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).
|
|
11
|
+
* Notifier is subscribed via raw callbag for END detection.
|
|
12
|
+
*
|
|
13
|
+
* Error/completion semantics:
|
|
14
|
+
* - Upstream error → forward error, discard buffer
|
|
15
|
+
* - Upstream completion → flush remaining buffer (if any), then complete
|
|
16
|
+
* - Notifier error → forward error, discard buffer
|
|
17
|
+
* - Notifier completion → flush remaining buffer (if any), then complete
|
|
18
|
+
*/
|
|
19
|
+
declare function buffer<A>(notifier: Store<unknown>): StoreOperator<A, A[]>;
|
|
20
|
+
|
|
21
|
+
export { buffer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S as Store, a as StoreOperator } from '../types-DsAN6Hga.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Accumulates upstream values into arrays. When the notifier emits,
|
|
5
|
+
* the buffered array is flushed downstream and a new buffer starts.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains current buffer and last flushed array via producer.
|
|
8
|
+
* get() returns the last flushed array (empty array before first flush).
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).
|
|
11
|
+
* Notifier is subscribed via raw callbag for END detection.
|
|
12
|
+
*
|
|
13
|
+
* Error/completion semantics:
|
|
14
|
+
* - Upstream error → forward error, discard buffer
|
|
15
|
+
* - Upstream completion → flush remaining buffer (if any), then complete
|
|
16
|
+
* - Notifier error → forward error, discard buffer
|
|
17
|
+
* - Notifier completion → flush remaining buffer (if any), then complete
|
|
18
|
+
*/
|
|
19
|
+
declare function buffer<A>(notifier: Store<unknown>): StoreOperator<A, A[]>;
|
|
20
|
+
|
|
21
|
+
export { buffer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var i in t)k(e,i,{get:t[i],enumerable:!0})},ee=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Q(t))!X.call(e,n)&&n!==i&&k(e,n,{get:()=>t[n],enumerable:!(s=J(t,n))||s.enumerable});return e};var te=e=>ee(k({},"__esModule",{value:!0}),e);var le={};Z(le,{bufferTime:()=>ue});module.exports=te(le);var T=Symbol("DIRTY"),y=Symbol("RESOLVED"),P=0,M=1,$=2,j=3,C=4,L=5,h=7,R=7<<h,se=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function K(e){return se[(e&R)>>>h]}var d=0,_=1,l=2,S=3,ne=0,ie=[];function F(){return ne>0}function V(e){ie.push(e)}var m=0,b=[];function Y(){m++}function U(){if(m--,m===0){for(let e=0;e<b.length;e++)b[e]();b.length=0}}function W(e){m>0?b.push(e):e()}var v=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let s=t.map(n=>e._names.get(n)??"?").join(",");return s.length>40?`${s.slice(0,37)}...`:s}static _resolveKey(t){return e._keys.get(t)??e._names.get(t)??"anonymous"}static register(t,i){if(!e.enabled)return;i?.name&&e._names.set(t,i.name),i?.kind&&e._kinds.set(t,i.kind);let s=e._nextId++,n=i?.name;if(!(n&&!e._usedKeys.has(n)))if(n){let o=e._depSuffix(i?.deps);n=o?`${n}(${o})`:`${n}_${s}`,e._usedKeys.has(n)&&(n=`${n}_${s}`)}else{let o=i?.kind??"store",r=e._depSuffix(i?.deps);n=r?`${o}(${r})`:`${o}_${s}`,e._usedKeys.has(n)&&(n=`${n}_${s}`)}e._usedKeys.add(n),e._keys.set(t,n),e._stores.add(new WeakRef(t))}static registerEdge(t,i){if(!e.enabled)return;let s=e._resolveKey(t),n=e._resolveKey(i),o=e._edges.get(s);o?o.includes(n)||o.push(n):e._edges.set(s,[n])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,i=new Set;for(let s of e._stores){let n=s.deref();if(!n){e._stores.delete(s);continue}let o=e._resolveKey(n);i.add(o),t.set(o,e.inspect(n))}for(let[s,n]of e._edges){if(!i.has(s)){e._edges.delete(s),e._usedKeys.delete(s);continue}let o=n.filter(r=>i.has(r));o.length===0?e._edges.delete(s):o.length!==n.length&&e._edges.set(s,o)}return t}static trace(t,i){let s=null,n=t.get();return t.source(d,(o,r)=>{if(o===d&&(s=r),o===l){s=null;return}if(o===1){let u=r;if(!Object.is(u,n)){let a=n;n=u,i(u,a)}}}),()=>s?.(l)}static dumpGraph(){let t=e.graph(),i=e.getEdges(),s=new Map;for(let[r,u]of i)for(let a of u){let f=s.get(a);f?f.includes(r)||f.push(r):s.set(a,[r])}let n=[];for(let[r,u]of t){let a=s.get(r),f=i.get(r),E=a?.length?` \u2190 [${a.join(", ")}]`:"",H=f?.length?` \u2192 [${f.join(", ")}]`:"";n.push(` ${r} (${u.kind}) = ${JSON.stringify(u.value)} [${u.status??"?"}]${E}${H}`)}return[`Store Graph (${t.size} nodes):`,...n].join(`
|
|
2
|
+
`)}static _observe(t,i,s){let n=null,o=i??e.getName(t),r={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:o,dispose:()=>n?.(l)};return t.source(d,(u,a)=>{if(u===d){n=a;return}u===_?(r.values.push(a),r.events.push({type:"data",data:a}),s&&s(`[${o}] DATA:`,a)):u===S?(r.signals.push(a),r.events.push({type:"signal",data:a}),a===T?r.dirtyCount++:a===y&&r.resolvedCount++,s&&s(`[${o}] STATE:`,a)):u===l&&(r.ended=!0,r.endError=a,r.events.push({type:"end",data:a}),s&&s(`[${o}] END`,a!==void 0?a:""),n=null)}),r}static observe(t){return e._observe(t)}static tap(t,i){let s=i??`tap(${e.getName(t)??"anon"})`,n={get:()=>t.get(),source:t.source};return e.register(n,{name:s,kind:"tap"}),e.registerEdge(t,n),n}static spy(t,i){let s=i?.name??e.getName(t)??"spy",n=i?.log??console.log;return e._observe(t,s,n)}static snapshot(){let t=e.graph(),i=e.getEdges(),s=[];for(let[o,r]of t)s.push({name:o,kind:r.kind,value:r.value,status:r.status});let n=[];for(let[o,r]of i)for(let u of r)n.push({from:o,to:u});return{nodes:s,edges:n}}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null}};var D=1,p=64,g=2,O=4,q=8,z=16,A=32,c=R,w=M<<h,B=$<<h,x=P<<h,re=C<<h,oe=L<<h,ae=j<<h,I=class{_value;_output=null;_flags;get _status(){return K(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;constructor(t,i){this._value=i?.initial,this._fn=t,this._eqFn=i?.equals,this._getterFn=i?.getter,this._initial=i?.initial;let s=0;i?.autoDirty!==!1&&(s|=O),i?.resetOnTeardown&&(s|=q),i?.resubscribable&&(s|=z),this._flags=s,this.source=this.source.bind(this),this.emit=this.emit.bind(this),this.signal=this.signal.bind(this),this.complete=this.complete.bind(this),this.error=this.error.bind(this),i?._skipInspect||v.register(this,{kind:"producer",...i})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,i){let s=this._output;if(s)if(this._flags&p)for(let n of s)n(t,i);else s(t,i)}emit(t){this._flags&g||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(F()?this._flags&A||(this._flags|=A,this._flags&O&&(this._flags=this._flags&~c|w,this._dispatch(S,T)),V(()=>{this._flags&=~A,this._flags=this._flags&~c|B,this._dispatch(_,this._value)})):(this._flags&O&&(this._flags=this._flags&~c|w,this._dispatch(S,T)),this._flags=this._flags&~c|B,this._dispatch(_,this._value))))}signal(t){this._flags&g||!this._output||(t===T?this._flags=this._flags&~c|w:t===y&&(this._flags=this._flags&~c|ae),this._dispatch(S,t))}complete(){if(this._flags&g)return;this._flags=(this._flags|g)&~c|re;let t=this._output,i=this._flags&p;if(this._output=null,this._flags&=~p,this._stop(),t)if(i)for(let s of t)s(l);else t(l)}error(t){if(this._flags&g)return;this._flags=(this._flags|g)&~c|oe;let i=this._output,s=this._flags&p;if(this._output=null,this._flags&=~p,this._stop(),i)if(s)for(let n of i)n(l,t);else i(l,t)}_start(){if(this._flags&D||!this._fn)return;this._flags|=D;let t=this._fn(this);this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&D&&(this._flags&=~D,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&q&&(this._value=this._initial),this._flags&g||(this._flags=this._flags&~c|x))}source(t,i){if(t===d){let s=i;if(this._flags&g)if(this._flags&z&&this._output===null)this._flags=this._flags&~(g|c)|x;else{s(d,n=>{}),s(l);return}if(this._output===null)this._output=s;else if(this._flags&p)this._output.add(s);else{let n=new Set;n.add(this._output),n.add(s),this._output=n,this._flags|=p}s(d,n=>{if(n===_&&s(_,this._value),n===l){if(this._output===null)return;if(this._flags&p){let o=this._output;o.delete(s),o.size===1?(this._output=o.values().next().value,this._flags&=~p):o.size===0&&(this._output=null,this._flags&=~p,this._flags=this._flags&~c|x,this._stop())}else this._output===s&&(this._output=null,this._flags=this._flags&~c|x,this._stop())}}),W(()=>this._start())}}};function G(e,t){return new I(e,t)}function N(e,t,i){let s=null;Y(),e.source(d,(o,r)=>{if(o===d&&(s=r),o===l){s=null,i?.onEnd?.(r);return}if(o===1){let u=r,a=n;n=u,t(u,a)}});let n=e.get();return U(),()=>s?.(l)}function ue(e){return t=>{let i=G(({emit:s,error:n,complete:o})=>{let r=[],u=N(t,f=>{r.push(f)},{onEnd:f=>{if(clearInterval(a),f!==void 0)n(f);else{if(r.length>0){let E=r;Object.freeze(E),r=[],s(E)}o()}}}),a=setInterval(()=>{if(r.length>0){let f=r;Object.freeze(f),r=[],s(f)}},e);return()=>{clearInterval(a),r=[],u()}},{initial:[]});return v.register(i,{kind:"bufferTime"}),i}}0&&(module.exports={bufferTime});
|
|
3
|
+
//# sourceMappingURL=bufferTime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/extra/bufferTime.ts","../../src/core/protocol.ts","../../src/core/inspector.ts","../../src/core/producer.ts","../../src/core/subscribe.ts"],"sourcesContent":["import { Inspector } from \"../core/inspector\";\nimport { producer } from \"../core/producer\";\nimport type { Store, StoreOperator } from \"../core/types\";\nimport { subscribe } from \"./subscribe\";\n\n/**\n * Time-windowed buffering. Accumulates upstream values and flushes\n * the buffer every `ms` milliseconds.\n *\n * Stateful: maintains current buffer and last flushed array via producer.\n * get() returns the last flushed array (empty array before first flush).\n *\n * v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).\n * No equals — each flushed array is a new reference.\n */\nexport function bufferTime<A>(ms: number): StoreOperator<A, A[]> {\n\treturn (input: Store<A>) => {\n\t\tconst store = producer<A[]>(\n\t\t\t({ emit, error, complete }) => {\n\t\t\t\tlet currentBuffer: A[] = [];\n\n\t\t\t\tconst unsub = subscribe(\n\t\t\t\t\tinput,\n\t\t\t\t\t(v) => {\n\t\t\t\t\t\tcurrentBuffer.push(v);\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tonEnd: (err) => {\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t\tif (err !== undefined) {\n\t\t\t\t\t\t\t\terror(err);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Flush remaining buffer on completion\n\t\t\t\t\t\t\t\tif (currentBuffer.length > 0) {\n\t\t\t\t\t\t\t\t\tconst flushed = currentBuffer;\n\t\t\t\t\t\t\t\t\tObject.freeze(flushed);\n\t\t\t\t\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\t\t\t\t\temit(flushed);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcomplete();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tconst timer = setInterval(() => {\n\t\t\t\t\tif (currentBuffer.length > 0) {\n\t\t\t\t\t\tconst flushed = currentBuffer;\n\t\t\t\t\t\tObject.freeze(flushed);\n\t\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\t\temit(flushed);\n\t\t\t\t\t}\n\t\t\t\t}, ms);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\tcurrentBuffer = [];\n\t\t\t\t\tunsub();\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ initial: [] as A[] },\n\t\t);\n\n\t\tInspector.register(store, { kind: \"bufferTime\" });\n\t\treturn store;\n\t};\n}\n","// ---------------------------------------------------------------------------\n// Protocol — v3 type 3 control channel\n// ---------------------------------------------------------------------------\n// Type 3 (STATE) carries control signals: DIRTY, RESOLVED\n// Type 1 (DATA) carries only real values — never sentinels\n// ---------------------------------------------------------------------------\n\n/** Control signal: \"my value is about to change\" */\nexport const DIRTY = Symbol(\"DIRTY\");\n\n/** Control signal: \"I was dirty but my value didn't change\" */\nexport const RESOLVED = Symbol(\"RESOLVED\");\n\nexport type Signal = typeof DIRTY | typeof RESOLVED;\n\n/** Node status — tracks current lifecycle state (v4) */\nexport type NodeStatus =\n\t| \"DISCONNECTED\"\n\t| \"DIRTY\"\n\t| \"SETTLED\"\n\t| \"RESOLVED\"\n\t| \"COMPLETED\"\n\t| \"ERRORED\";\n\n// ---------------------------------------------------------------------------\n// Integer status constants — pack into _flags for hot-path performance.\n// 3 bits (7-9) encode 6 statuses. Use STATUS_MASK to read/write.\n// ---------------------------------------------------------------------------\nexport const S_DISCONNECTED = 0;\nexport const S_DIRTY = 1;\nexport const S_SETTLED = 2;\nexport const S_RESOLVED = 3;\nexport const S_COMPLETED = 4;\nexport const S_ERRORED = 5;\nexport const STATUS_SHIFT = 7;\nexport const STATUS_MASK = 0b111 << STATUS_SHIFT; // bits 7-9\n\nconst STATUS_STRINGS: NodeStatus[] = [\n\t\"DISCONNECTED\",\n\t\"DIRTY\",\n\t\"SETTLED\",\n\t\"RESOLVED\",\n\t\"COMPLETED\",\n\t\"ERRORED\",\n];\n\n/** Decode integer status bits back to string (for Inspector / tests) */\nexport function decodeStatus(flags: number): NodeStatus {\n\treturn STATUS_STRINGS[(flags & STATUS_MASK) >>> STATUS_SHIFT];\n}\n\n/** Callbag signal types */\nexport const START = 0;\nexport const DATA = 1;\nexport const END = 2;\nexport const STATE = 3;\n\n// ---------------------------------------------------------------------------\n// Batch — defers type 1 value emissions; type 3 DIRTY propagates immediately\n// ---------------------------------------------------------------------------\n\nlet batchDepth = 0;\nconst deferredEmissions: Array<() => void> = [];\n\n// `draining` prevents re-entrant drain when a nested batch() call ends while\n// the outer drain loop is already running. Without it, the inner batch's\n// finally block would see batchDepth===0 and start a second drain, racing the\n// outer loop — potentially double-processing items or clearing the array mid-\n// iteration. With draining=true, the inner batch skips its drain; any items it\n// pushes are picked up by the outer loop (the `for` condition re-evaluates\n// `deferredEmissions.length` on every iteration, so appends during drain are\n// naturally included in the same pass).\nlet draining = false;\n\nexport function batch<T>(fn: () => T): T {\n\tbatchDepth++;\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchDepth--;\n\t\tif (batchDepth === 0 && !draining) {\n\t\t\tdraining = true;\n\t\t\tfor (let i = 0; i < deferredEmissions.length; i++) {\n\t\t\t\tdeferredEmissions[i]();\n\t\t\t}\n\t\t\tdeferredEmissions.length = 0;\n\t\t\tdraining = false;\n\t\t}\n\t}\n}\n\nexport function isBatching(): boolean {\n\treturn batchDepth > 0;\n}\n\nexport function deferEmission(fn: () => void): void {\n\tdeferredEmissions.push(fn);\n}\n\n// ---------------------------------------------------------------------------\n// Connection batching (producer start deferral) — unchanged from v2\n// ---------------------------------------------------------------------------\n\nlet connectDepth = 0;\nconst pendingStarts: Array<() => void> = [];\n\nexport function beginDeferredStart(): void {\n\tconnectDepth++;\n}\n\nexport function endDeferredStart(): void {\n\tconnectDepth--;\n\tif (connectDepth === 0) {\n\t\tfor (let i = 0; i < pendingStarts.length; i++) {\n\t\t\tpendingStarts[i]();\n\t\t}\n\t\tpendingStarts.length = 0;\n\t}\n}\n\nexport function deferStart(start: () => void): void {\n\tif (connectDepth > 0) {\n\t\tpendingStarts.push(start);\n\t} else {\n\t\tstart();\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// teardown — protocol-level graph destruction\n// ---------------------------------------------------------------------------\n// Sends END to all downstream sinks of a store node, cascading through the\n// entire subgraph. After teardown, the node is in COMPLETED state and won't\n// accept new values or subscriptions.\n//\n// Works with any node that uses the output slot model:\n// - ProducerImpl / StateImpl / OperatorImpl → calls .complete()\n// - DerivedImpl → calls ._handleEnd() (no public complete() on derived)\n// ---------------------------------------------------------------------------\n\nexport function teardown(store: { source: (type: number, payload?: any) => void }): void {\n\tconst node = store as any;\n\tif (typeof node.complete === \"function\") {\n\t\tnode.complete();\n\t} else if (typeof node._handleEnd === \"function\") {\n\t\tnode._handleEnd(undefined);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Inspector — static class for observability\n// ---------------------------------------------------------------------------\n// All debug metadata lives here in WeakMaps, not on the store objects.\n// Stores stay lean. Inspector is opt-in overhead.\n//\n// v5: Zero intrusion into primitives. No hooks in hot paths. All methods\n// are static — call directly as Inspector.observe(), Inspector.tap(), etc.\n// - register/registerEdge: metadata collection (called from constructors)\n// - inspect/graph/dumpGraph/snapshot: read-only graph queries\n// - observe/spy/trace: callbag sinks for debugging (subscribe externally)\n// - tap: transparent passthrough wrapper for graph visualization\n// ---------------------------------------------------------------------------\n\nimport type { NodeStatus, Signal } from \"./protocol\";\nimport { DATA, DIRTY, END, RESOLVED, START, STATE } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport interface StoreInfo<T = unknown> {\n\tname: string | undefined;\n\tkind: string;\n\tvalue: T;\n\t/** v4: node lifecycle status */\n\tstatus: NodeStatus | undefined;\n}\n\nexport interface ObserveResult<T> {\n\t/** All DATA (type 1) values received, in order */\n\tvalues: T[];\n\t/** All STATE (type 3) payloads received (DIRTY, RESOLVED, or unknown) */\n\tsignals: Signal[];\n\t/** All events in protocol order: { type, data } */\n\tevents: Array<{ type: \"data\" | \"signal\" | \"end\"; data: unknown }>;\n\t/** Whether END (type 2) has been received */\n\tended: boolean;\n\t/** Error payload from END, if any */\n\tendError: unknown;\n\t/** Count of DIRTY signals received */\n\tdirtyCount: number;\n\t/** Count of RESOLVED signals received */\n\tresolvedCount: number;\n\t/** Store name (from Inspector, if registered) */\n\tname: string | undefined;\n\t/** Disconnect the observer */\n\tdispose: () => void;\n}\n\n// Static-only class is intentional API for Inspector namespace\n// biome-ignore lint/complexity/noStaticOnlyClass: public API surface\nexport class Inspector {\n\t// WeakMaps for metadata — keyed by any graph node (stores, effects, etc.)\n\tprivate static _names = new WeakMap<object, string>();\n\tprivate static _kinds = new WeakMap<object, string>();\n\tprivate static _keys = new WeakMap<object, string>();\n\n\t// WeakRef set for graph() — allows GC of unused nodes\n\tprivate static _stores = new Set<WeakRef<object>>();\n\n\t// Dependency edges: parent key → child keys\n\tprivate static _edges = new Map<string, string[]>();\n\n\t// Unique key generation\n\tprivate static _nextId = 0;\n\tprivate static _usedKeys = new Set<string>();\n\n\t// Enabled flag — when false, register/getName are no-ops\n\tprivate static _explicitEnabled: boolean | null = null;\n\tprivate static _cachedDefault: boolean | null = null;\n\n\tstatic get enabled(): boolean {\n\t\tif (Inspector._explicitEnabled !== null) return Inspector._explicitEnabled;\n\t\tif (Inspector._cachedDefault !== null) return Inspector._cachedDefault;\n\t\ttry {\n\t\t\tInspector._cachedDefault = (globalThis as any).process?.env?.NODE_ENV !== \"production\";\n\t\t} catch {\n\t\t\tInspector._cachedDefault = true;\n\t\t}\n\t\treturn Inspector._cachedDefault;\n\t}\n\n\tstatic set enabled(value: boolean) {\n\t\tInspector._explicitEnabled = value;\n\t}\n\n\t/** Compute a dep-name-based suffix for unique key generation */\n\tprivate static _depSuffix(deps?: object[]): string | undefined {\n\t\tif (!deps?.length) return undefined;\n\t\tconst names = deps.map((d) => Inspector._names.get(d) ?? \"?\");\n\t\tconst joined = names.join(\",\");\n\t\treturn joined.length > 40 ? `${joined.slice(0, 37)}...` : joined;\n\t}\n\n\t/** Resolve a node to its unique graph key */\n\tprivate static _resolveKey(node: object): string {\n\t\treturn Inspector._keys.get(node) ?? Inspector._names.get(node) ?? \"anonymous\";\n\t}\n\n\t/** Register a graph node (store, effect, etc.) with the inspector */\n\tstatic register(node: object, opts?: { name?: string; kind?: string; deps?: object[] }): void {\n\t\tif (!Inspector.enabled) return;\n\t\tif (opts?.name) Inspector._names.set(node, opts.name);\n\t\tif (opts?.kind) Inspector._kinds.set(node, opts.kind);\n\n\t\t// Compute unique key\n\t\tconst id = Inspector._nextId++;\n\t\tlet key = opts?.name;\n\t\tif (key && !Inspector._usedKeys.has(key)) {\n\t\t\t// Unique name — use as-is\n\t\t} else if (key) {\n\t\t\t// Name collision — differentiate with dep names or ID\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${key}(${depSuffix})` : `${key}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t} else {\n\t\t\t// Unnamed — use kind + dep names or ID\n\t\t\tconst kind = opts?.kind ?? \"store\";\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${kind}(${depSuffix})` : `${kind}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t}\n\n\t\tInspector._usedKeys.add(key);\n\t\tInspector._keys.set(node, key);\n\t\tInspector._stores.add(new WeakRef(node));\n\t}\n\n\t/** Register a dependency edge between parent and child nodes */\n\tstatic registerEdge(parent: object, child: object): void {\n\t\tif (!Inspector.enabled) return;\n\t\tconst parentKey = Inspector._resolveKey(parent);\n\t\tconst childKey = Inspector._resolveKey(child);\n\t\tconst children = Inspector._edges.get(parentKey);\n\t\tif (children) {\n\t\t\tif (!children.includes(childKey)) children.push(childKey);\n\t\t} else {\n\t\t\tInspector._edges.set(parentKey, [childKey]);\n\t\t}\n\t}\n\n\t/** Get dependency edges: parent → children */\n\tstatic getEdges(): Map<string, string[]> {\n\t\treturn new Map(Inspector._edges);\n\t}\n\n\t/** Get the name of a node */\n\tstatic getName(node: object): string | undefined {\n\t\tif (!Inspector.enabled) return undefined;\n\t\treturn Inspector._names.get(node);\n\t}\n\n\t/** Get the kind of a node */\n\tstatic getKind(node: object): string | undefined {\n\t\treturn Inspector._kinds.get(node);\n\t}\n\n\t/** Inspect a single graph node — includes status and value (if available) */\n\tstatic inspect<T = unknown>(node: object): StoreInfo<T> {\n\t\treturn {\n\t\t\tname: Inspector._names.get(node),\n\t\t\tkind: Inspector._kinds.get(node) ?? \"unknown\",\n\t\t\tvalue: (typeof (node as any).get === \"function\" ? (node as any).get() : undefined) as T,\n\t\t\tstatus: (node as any)._status,\n\t\t};\n\t}\n\n\t/** Get all living nodes as a Map. Also prunes dead edges from GC'd nodes. */\n\tstatic graph(): Map<string, StoreInfo> {\n\t\tconst result = new Map<string, StoreInfo>();\n\t\tconst livingKeys = new Set<string>();\n\t\tfor (const ref of Inspector._stores) {\n\t\t\tconst node = ref.deref();\n\t\t\tif (!node) {\n\t\t\t\tInspector._stores.delete(ref); // cleanup GC'd refs\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = Inspector._resolveKey(node);\n\t\t\tlivingKeys.add(key);\n\t\t\tresult.set(key, Inspector.inspect(node));\n\t\t}\n\t\t// Prune edges referencing GC'd stores\n\t\tfor (const [key, children] of Inspector._edges) {\n\t\t\tif (!livingKeys.has(key)) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t\tInspector._usedKeys.delete(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst alive = children.filter((c) => livingKeys.has(c));\n\t\t\tif (alive.length === 0) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t} else if (alive.length !== children.length) {\n\t\t\t\tInspector._edges.set(key, alive);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Trace a specific store's value changes (raw callbag — no extra/ dependency) */\n\tstatic trace<T>(store: Store<T>, cb: (value: T, prev: T | undefined) => void): () => void {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tlet prev: T | undefined = store.get();\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) talkback = data;\n\t\t\tif (type === END) {\n\t\t\t\ttalkback = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === 1) {\n\t\t\t\tconst next = data as T;\n\t\t\t\tif (!Object.is(next, prev)) {\n\t\t\t\t\tconst p = prev;\n\t\t\t\t\tprev = next;\n\t\t\t\t\tcb(next, p);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn () => talkback?.(END);\n\t}\n\n\t/** Pretty-print the entire store graph for console/CLI debugging */\n\tstatic dumpGraph(): string {\n\t\tconst g = Inspector.graph();\n\t\tconst edges = Inspector.getEdges();\n\n\t\t// Build reverse map: child key → parent keys (deps)\n\t\tconst depsMap = new Map<string, string[]>();\n\t\tfor (const [parent, children] of edges) {\n\t\t\tfor (const child of children) {\n\t\t\t\tconst deps = depsMap.get(child);\n\t\t\t\tif (deps) {\n\t\t\t\t\tif (!deps.includes(parent)) deps.push(parent);\n\t\t\t\t} else {\n\t\t\t\t\tdepsMap.set(child, [parent]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst lines: string[] = [];\n\t\tfor (const [key, info] of g) {\n\t\t\tconst deps = depsMap.get(key);\n\t\t\tconst children = edges.get(key);\n\t\t\tconst depsStr = deps?.length ? ` ← [${deps.join(\", \")}]` : \"\";\n\t\t\tconst childStr = children?.length ? ` → [${children.join(\", \")}]` : \"\";\n\t\t\tlines.push(\n\t\t\t\t` ${key} (${info.kind}) = ${JSON.stringify(info.value)} [${info.status ?? \"?\"}]${depsStr}${childStr}`,\n\t\t\t);\n\t\t}\n\t\tconst header = `Store Graph (${g.size} nodes):`;\n\t\treturn [header, ...lines].join(\"\\n\");\n\t}\n\n\t/**\n\t * Internal observe implementation shared by observe() and spy().\n\t */\n\tprivate static _observe<T>(\n\t\tstore: Store<T>,\n\t\tlabel?: string,\n\t\tlog?: (...args: any[]) => void,\n\t): ObserveResult<T> {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tconst name = label ?? Inspector.getName(store);\n\t\tconst result: ObserveResult<T> = {\n\t\t\tvalues: [],\n\t\t\tsignals: [],\n\t\t\tevents: [],\n\t\t\tended: false,\n\t\t\tendError: undefined,\n\t\t\tdirtyCount: 0,\n\t\t\tresolvedCount: 0,\n\t\t\tname,\n\t\t\tdispose: () => talkback?.(END),\n\t\t};\n\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\ttalkback = data;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === DATA) {\n\t\t\t\tresult.values.push(data);\n\t\t\t\tresult.events.push({ type: \"data\", data });\n\t\t\t\tif (log) log(`[${name}] DATA:`, data);\n\t\t\t} else if (type === STATE) {\n\t\t\t\tresult.signals.push(data);\n\t\t\t\tresult.events.push({ type: \"signal\", data });\n\t\t\t\tif (data === DIRTY) result.dirtyCount++;\n\t\t\t\telse if (data === RESOLVED) result.resolvedCount++;\n\t\t\t\tif (log) log(`[${name}] STATE:`, data);\n\t\t\t} else if (type === END) {\n\t\t\t\tresult.ended = true;\n\t\t\t\tresult.endError = data;\n\t\t\t\tresult.events.push({ type: \"end\", data });\n\t\t\t\tif (log) log(`[${name}] END`, data !== undefined ? data : \"\");\n\t\t\t\ttalkback = null;\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Observe a store's full callbag protocol — the test-friendly alternative\n\t * to hooks. Captures DATA values, STATE signals, END, and provides\n\t * convenience accessors.\n\t *\n\t * Returns a live observation object — arrays grow as the store emits.\n\t *\n\t * ```ts\n\t * const obs = Inspector.observe(myStore);\n\t * myState.set(5);\n\t * obs.values // [5]\n\t * obs.signals // [DIRTY]\n\t * obs.ended // false\n\t * obs.dirtyCount // 1\n\t * obs.dispose() // stop observing\n\t * ```\n\t */\n\tstatic observe<T>(store: Store<T>): ObserveResult<T> {\n\t\treturn Inspector._observe(store);\n\t}\n\n\t/**\n\t * Create a transparent passthrough wrapper for graph visualization.\n\t * The wrapper delegates `get()` and `source()` to the original store,\n\t * appearing as a distinct node in the Inspector graph. Zero overhead —\n\t * subscribers connect directly to the original store's source.\n\t */\n\tstatic tap<T>(store: Store<T>, name?: string): Store<T> {\n\t\tconst tapName = name ?? `tap(${Inspector.getName(store) ?? \"anon\"})`;\n\t\tconst wrapper: Store<T> = {\n\t\t\tget: () => store.get(),\n\t\t\tsource: store.source,\n\t\t};\n\t\tInspector.register(wrapper, { name: tapName, kind: \"tap\" });\n\t\tInspector.registerEdge(store, wrapper);\n\t\treturn wrapper;\n\t}\n\n\t/**\n\t * Enhanced observe() with logging — for interactive debugging.\n\t * Returns the same observation object as observe(), but also logs each\n\t * event as it happens. Pass a custom logger or defaults to console.log.\n\t */\n\tstatic spy<T>(\n\t\tstore: Store<T>,\n\t\topts?: { name?: string; log?: (...args: any[]) => void },\n\t): ObserveResult<T> {\n\t\tconst label = opts?.name ?? Inspector.getName(store) ?? \"spy\";\n\t\tconst log = opts?.log ?? console.log;\n\t\treturn Inspector._observe(store, label, log);\n\t}\n\n\t/**\n\t * JSON-serializable snapshot of the entire graph — nodes + edges.\n\t * Designed for AI consumption during debugging sessions.\n\t */\n\tstatic snapshot(): {\n\t\tnodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }>;\n\t\tedges: Array<{ from: string; to: string }>;\n\t} {\n\t\tconst g = Inspector.graph();\n\t\tconst edgeMap = Inspector.getEdges();\n\t\tconst nodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }> =\n\t\t\t[];\n\t\tfor (const [key, info] of g) {\n\t\t\tnodes.push({ name: key, kind: info.kind, value: info.value, status: info.status });\n\t\t}\n\t\tconst edges: Array<{ from: string; to: string }> = [];\n\t\tfor (const [parent, children] of edgeMap) {\n\t\t\tfor (const child of children) {\n\t\t\t\tedges.push({ from: parent, to: child });\n\t\t\t}\n\t\t}\n\t\treturn { nodes, edges };\n\t}\n\n\t/** Reset all state (for testing) */\n\tstatic _reset(): void {\n\t\tInspector._names = new WeakMap<object, string>();\n\t\tInspector._kinds = new WeakMap<object, string>();\n\t\tInspector._keys = new WeakMap<object, string>();\n\t\tInspector._stores = new Set<WeakRef<object>>();\n\t\tInspector._edges = new Map();\n\t\tInspector._usedKeys = new Set();\n\t\tInspector._nextId = 0;\n\t\tInspector._explicitEnabled = null;\n\t\tInspector._cachedDefault = null;\n\t}\n}\n","/**\n * General-purpose source primitive. Can emit values, send control signals,\n * complete, and error. Lazy start on first sink, auto-cleanup on last\n * sink disconnect.\n *\n * Stateful: maintains currentValue. get() returns currentValue (or\n * getter(currentValue) when getter option is provided).\n *\n * v4: Output slot model replaces _sinks Set. _output is null (no sinks),\n * a function (single sink — P0 optimization), or a Set (multi sink).\n * _status tracks node lifecycle. autoDirty (default true) sends DIRTY on\n * type 3 before each type 1 DATA. equals option guards emit();\n * resetOnTeardown resets value on stop.\n *\n * v5: _status packed into _flags bits 7-9 for hot-path performance.\n * String status exposed via getter for Inspector/test backward compat.\n *\n * Class-based for V8 hidden class optimization and prototype method sharing.\n * Boolean fields packed into _flags bitmask to reduce hidden class size.\n */\n\nimport { Inspector } from \"./inspector\";\nimport type { Signal } from \"./protocol\";\nimport {\n\tDATA,\n\tDIRTY,\n\tdecodeStatus,\n\tdeferEmission,\n\tdeferStart,\n\tEND,\n\tisBatching,\n\tRESOLVED,\n\tS_COMPLETED,\n\tS_DIRTY,\n\tS_DISCONNECTED,\n\tS_ERRORED,\n\tS_RESOLVED,\n\tS_SETTLED,\n\tSTART,\n\tSTATE,\n\tSTATUS_MASK,\n\tSTATUS_SHIFT,\n} from \"./protocol\";\nimport type { ProducerStore, SourceOptions, Store } from \"./types\";\n\nexport type ProducerFn<T> = (actions: {\n\temit: (value: T) => void;\n\tsignal: (s: Signal) => void;\n\tcomplete: () => void;\n\terror: (e: unknown) => void;\n}) => (() => void) | undefined;\n\nexport type ProducerOpts<T> = SourceOptions<T> & {\n\tautoDirty?: boolean;\n\t_skipInspect?: boolean;\n};\n\n// Flag bits for _flags bitmask (bits 0-6)\nconst P_STARTED = 1;\nconst P_MULTI = 64;\n\n// Exported for subclass fast paths (StateImpl)\nexport const P_COMPLETED = 2;\nexport const P_AUTO_DIRTY = 4;\nconst P_RESET = 8;\nconst P_RESUB = 16;\nexport const P_PENDING = 32;\n\n// Status bits (bits 7-9) — exported for StateImpl fast path\nexport const _STATUS_MASK = STATUS_MASK;\nexport const _S_DIRTY = S_DIRTY << STATUS_SHIFT;\nexport const _S_SETTLED = S_SETTLED << STATUS_SHIFT;\nexport const _S_DISCONNECTED = S_DISCONNECTED << STATUS_SHIFT;\nexport const _S_COMPLETED = S_COMPLETED << STATUS_SHIFT;\nexport const _S_ERRORED = S_ERRORED << STATUS_SHIFT;\nexport const _S_RESOLVED = S_RESOLVED << STATUS_SHIFT;\n\nexport class ProducerImpl<T> {\n\t_value: T | undefined;\n\t_output: ((type: number, data?: any) => void) | Set<any> | null = null;\n\t_flags: number;\n\n\tget _status() {\n\t\treturn decodeStatus(this._flags);\n\t}\n\t_cleanup: (() => void) | undefined;\n\t_fn: ProducerFn<T> | undefined;\n\t_eqFn: ((a: T, b: T) => boolean) | undefined;\n\t_getterFn: ((cached: T | undefined) => T) | undefined;\n\t_initial: T | undefined;\n\n\tconstructor(fn?: ProducerFn<T>, opts?: ProducerOpts<T>) {\n\t\tthis._value = opts?.initial;\n\t\tthis._fn = fn;\n\t\tthis._eqFn = opts?.equals;\n\t\tthis._getterFn = opts?.getter;\n\t\tthis._initial = opts?.initial;\n\n\t\tlet flags = 0;\n\t\tif (opts?.autoDirty !== false) flags |= P_AUTO_DIRTY;\n\t\tif (opts?.resetOnTeardown) flags |= P_RESET;\n\t\tif (opts?.resubscribable) flags |= P_RESUB;\n\t\t// S_DISCONNECTED = 0, so no need to set status bits\n\t\tthis._flags = flags;\n\n\t\t// Bind public API methods so they work when detached (callbag interop,\n\t\t// destructuring, etc.). Replaces per-instance closure functions.\n\t\tthis.source = this.source.bind(this);\n\t\tthis.emit = this.emit.bind(this);\n\t\tthis.signal = this.signal.bind(this);\n\t\tthis.complete = this.complete.bind(this);\n\t\tthis.error = this.error.bind(this);\n\n\t\tif (!opts?._skipInspect) Inspector.register(this as any, { kind: \"producer\", ...opts });\n\t}\n\n\tget(): T | undefined {\n\t\treturn this._getterFn ? this._getterFn(this._value) : this._value;\n\t}\n\n\t/**\n\t * Dispatch a signal to all current subscribers via the output slot.\n\t *\n\t * Safety: P_MULTI flag and _output type are always updated together.\n\t * No reentrancy can occur between the two assignments (source() doesn't\n\t * trigger dispatch, and dispatch doesn't trigger source()). The null-check\n\t * provides an additional guard for the MULTI→null transition path.\n\t */\n\t_dispatch(type: number, data?: any): void {\n\t\tconst output = this._output;\n\t\tif (!output) return;\n\t\tif (this._flags & P_MULTI) {\n\t\t\tfor (const sink of output as Set<any>) sink(type, data);\n\t\t} else {\n\t\t\t(output as (type: number, data?: any) => void)(type, data);\n\t\t}\n\t}\n\n\temit(value: T): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tif (this._eqFn && this._value !== undefined && this._eqFn(this._value as T, value)) return;\n\t\tthis._value = value;\n\t\tif (!this._output) return;\n\t\tif (isBatching()) {\n\t\t\tif (!(this._flags & P_PENDING)) {\n\t\t\t\tthis._flags |= P_PENDING;\n\t\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t}\n\t\t\t\tdeferEmission(() => {\n\t\t\t\t\tthis._flags &= ~P_PENDING;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\t\t\tthis._dispatch(DATA, this._value);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t}\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\tthis._dispatch(DATA, this._value);\n\t\t}\n\t}\n\n\tsignal(s: Signal): void {\n\t\tif (this._flags & P_COMPLETED || !this._output) return;\n\t\tif (s === DIRTY) this._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\telse if (s === RESOLVED) this._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t// Unknown signals: dispatch without _status change (v4 forward-compat)\n\t\tthis._dispatch(STATE, s);\n\t}\n\n\tcomplete(): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_COMPLETED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END);\n\t\t\t}\n\t\t}\n\t}\n\n\terror(e: unknown): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_ERRORED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END, e);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END, e);\n\t\t\t}\n\t\t}\n\t}\n\n\t_start(): void {\n\t\tif (this._flags & P_STARTED || !this._fn) return;\n\t\tthis._flags |= P_STARTED;\n\t\tconst result = this._fn(this as any);\n\t\tthis._cleanup = typeof result === \"function\" ? result : undefined;\n\t}\n\n\t_stop(): void {\n\t\tif (!(this._flags & P_STARTED)) return;\n\t\tthis._flags &= ~P_STARTED;\n\t\tif (this._cleanup) this._cleanup();\n\t\tthis._cleanup = undefined;\n\t\tif (this._flags & P_RESET) this._value = this._initial;\n\t\tif (!(this._flags & P_COMPLETED)) this._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t}\n\n\tsource(type: number, payload?: any): void {\n\t\tif (type === START) {\n\t\t\tconst sink = payload;\n\t\t\tif (this._flags & P_COMPLETED) {\n\t\t\t\tif (this._flags & P_RESUB && this._output === null) {\n\t\t\t\t\tthis._flags = (this._flags & ~(P_COMPLETED | _STATUS_MASK)) | _S_DISCONNECTED;\n\t\t\t\t} else {\n\t\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\t\tsink(END);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._output === null) {\n\t\t\t\tthis._output = sink;\n\t\t\t} else if (!(this._flags & P_MULTI)) {\n\t\t\t\tconst set = new Set<any>();\n\t\t\t\tset.add(this._output);\n\t\t\t\tset.add(sink);\n\t\t\t\tthis._output = set;\n\t\t\t\tthis._flags |= P_MULTI;\n\t\t\t} else {\n\t\t\t\t(this._output as Set<any>).add(sink);\n\t\t\t}\n\t\t\tsink(START, (t: number) => {\n\t\t\t\tif (t === DATA) sink(DATA, this._value);\n\t\t\t\tif (t === END) {\n\t\t\t\t\tif (this._output === null) return;\n\t\t\t\t\tif (this._flags & P_MULTI) {\n\t\t\t\t\t\tconst set = this._output as Set<any>;\n\t\t\t\t\t\tset.delete(sink);\n\t\t\t\t\t\tif (set.size === 1) {\n\t\t\t\t\t\t\tthis._output = set.values().next().value;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t} else if (set.size === 0) {\n\t\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this._output === sink) {\n\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tdeferStart(() => this._start());\n\t\t}\n\t}\n}\n\nexport function producer<T>(\n\tfn: ProducerFn<T> | undefined,\n\topts: ProducerOpts<T> & { initial: T },\n): ProducerStore<T> & Store<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T> {\n\treturn new ProducerImpl<T>(fn, opts) as any;\n}\n","/**\n * Core subscribe — reusable callbag sink connector.\n *\n * Used as the base for:\n * - External subscribe (extra/subscribe re-exports this)\n * - Derived's dep connections (STANDALONE mode)\n * - Effect's dep connections\n *\n * v4: Handles callbag START handshake, filters STATE for user callbacks,\n * provides prev-value tracking. Returns unsub function.\n */\n\nimport { beginDeferredStart, END, endDeferredStart, START } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport function subscribe<T>(\n\tstore: Store<T>,\n\tcb: (value: T, prev: T | undefined) => void,\n\topts?: { onEnd?: (error?: unknown) => void },\n): () => void {\n\tlet talkback: ((type: number) => void) | null = null;\n\n\tbeginDeferredStart();\n\n\t// `prev` is declared after store.source() but the closure only reads it\n\t// after endDeferredStart() triggers producers. By that point prev is already\n\t// set to store.get(). Order: register sink → read baseline → start producers.\n\tstore.source(START, (type: number, data: any) => {\n\t\tif (type === START) talkback = data;\n\t\tif (type === END) {\n\t\t\ttalkback = null;\n\t\t\topts?.onEnd?.(data);\n\t\t\treturn;\n\t\t}\n\t\t// Transparent sink — forwards every DATA to the callback.\n\t\t// Dedup (if desired) belongs in the source (state's equals) or in\n\t\t// an explicit operator (distinctUntilChanged), not here.\n\t\tif (type === 1 /* DATA */) {\n\t\t\tconst next = data as T;\n\t\t\tconst p = prev;\n\t\t\tprev = next;\n\t\t\tcb(next, p);\n\t\t}\n\t});\n\n\t// Baseline: captures current value before producers start. Aligns with\n\t// RxJS Observable semantics — no initial-value callback on subscribe.\n\tlet prev: T | undefined = store.get();\n\n\tendDeferredStart();\n\n\treturn () => talkback?.(END);\n}\n"],"mappings":"4aAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,gBAAAE,KAAA,eAAAC,GAAAH,ICQO,IAAMI,EAAQ,OAAO,OAAO,EAGtBC,EAAW,OAAO,UAAU,EAiB5BC,EAAiB,EACjBC,EAAU,EACVC,EAAY,EACZC,EAAa,EACbC,EAAc,EACdC,EAAY,EACZC,EAAe,EACfC,EAAc,GAASD,EAE9BE,GAA+B,CACpC,eACA,QACA,UACA,WACA,YACA,SACD,EAGO,SAASC,EAAaC,EAA2B,CACvD,OAAOF,IAAgBE,EAAQH,KAAiBD,CAAY,CAC7D,CAGO,IAAMK,EAAQ,EACRC,EAAO,EACPC,EAAM,EACNC,EAAQ,EAMjBC,GAAa,EACXC,GAAuC,CAAC,EA6BvC,SAASC,GAAsB,CACrC,OAAOC,GAAa,CACrB,CAEO,SAASC,EAAcC,EAAsB,CACnDC,GAAkB,KAAKD,CAAE,CAC1B,CAMA,IAAIE,EAAe,EACbC,EAAmC,CAAC,EAEnC,SAASC,GAA2B,CAC1CF,GACD,CAEO,SAASG,GAAyB,CAExC,GADAH,IACIA,IAAiB,EAAG,CACvB,QAASI,EAAI,EAAGA,EAAIH,EAAc,OAAQG,IACzCH,EAAcG,CAAC,EAAE,EAElBH,EAAc,OAAS,CACxB,CACD,CAEO,SAASI,EAAWC,EAAyB,CAC/CN,EAAe,EAClBC,EAAc,KAAKK,CAAK,EAExBA,EAAM,CAER,CC7EO,IAAMC,EAAN,MAAMC,CAAU,CAEtB,OAAe,OAAS,IAAI,QAC5B,OAAe,OAAS,IAAI,QAC5B,OAAe,MAAQ,IAAI,QAG3B,OAAe,QAAU,IAAI,IAG7B,OAAe,OAAS,IAAI,IAG5B,OAAe,QAAU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,EACPG,EAAIC,EACVA,EAAOF,EACPR,EAAGQ,EAAMC,CAAC,CACX,CACD,CAAC,EAID,IAAIC,EAAsBX,EAAM,IAAI,EAEpC,OAAAY,EAAiB,EAEV,IAAMT,IAAWK,CAAG,CAC5B,CJrCO,SAASK,GAAcC,EAAmC,CAChE,OAAQC,GAAoB,CAC3B,IAAMC,EAAQC,EACb,CAAC,CAAE,KAAAC,EAAM,MAAAC,EAAO,SAAAC,CAAS,IAAM,CAC9B,IAAIC,EAAqB,CAAC,EAEpBC,EAAQC,EACbR,EACCS,GAAM,CACNH,EAAc,KAAKG,CAAC,CACrB,EACA,CACC,MAAQC,GAAQ,CAEf,GADA,cAAcC,CAAK,EACfD,IAAQ,OACXN,EAAMM,CAAG,MACH,CAEN,GAAIJ,EAAc,OAAS,EAAG,CAC7B,IAAMM,EAAUN,EAChB,OAAO,OAAOM,CAAO,EACrBN,EAAgB,CAAC,EACjBH,EAAKS,CAAO,CACb,CACAP,EAAS,CACV,CACD,CACD,CACD,EAEMM,EAAQ,YAAY,IAAM,CAC/B,GAAIL,EAAc,OAAS,EAAG,CAC7B,IAAMM,EAAUN,EAChB,OAAO,OAAOM,CAAO,EACrBN,EAAgB,CAAC,EACjBH,EAAKS,CAAO,CACb,CACD,EAAGb,CAAE,EAEL,MAAO,IAAM,CACZ,cAAcY,CAAK,EACnBL,EAAgB,CAAC,EACjBC,EAAM,CACP,CACD,EACA,CAAE,QAAS,CAAC,CAAS,CACtB,EAEA,OAAAM,EAAU,SAASZ,EAAO,CAAE,KAAM,YAAa,CAAC,EACzCA,CACR,CACD","names":["bufferTime_exports","__export","bufferTime","__toCommonJS","DIRTY","RESOLVED","S_DISCONNECTED","S_DIRTY","S_SETTLED","S_RESOLVED","S_COMPLETED","S_ERRORED","STATUS_SHIFT","STATUS_MASK","STATUS_STRINGS","decodeStatus","flags","START","DATA","END","STATE","batchDepth","deferredEmissions","isBatching","batchDepth","deferEmission","fn","deferredEmissions","connectDepth","pendingStarts","beginDeferredStart","endDeferredStart","i","deferStart","start","Inspector","_Inspector","value","deps","joined","d","node","opts","id","key","depSuffix","kind","parent","child","parentKey","childKey","children","result","livingKeys","ref","alive","c","store","cb","talkback","prev","START","type","data","END","next","p","g","edges","depsMap","lines","info","depsStr","childStr","label","log","name","DATA","STATE","DIRTY","RESOLVED","tapName","wrapper","edgeMap","nodes","P_STARTED","P_MULTI","P_COMPLETED","P_AUTO_DIRTY","P_RESET","P_RESUB","P_PENDING","_STATUS_MASK","STATUS_MASK","_S_DIRTY","S_DIRTY","STATUS_SHIFT","_S_SETTLED","S_SETTLED","_S_DISCONNECTED","S_DISCONNECTED","_S_COMPLETED","S_COMPLETED","_S_ERRORED","S_ERRORED","_S_RESOLVED","S_RESOLVED","ProducerImpl","decodeStatus","fn","opts","flags","Inspector","type","data","output","sink","value","isBatching","STATE","DIRTY","deferEmission","DATA","s","RESOLVED","wasMulti","END","e","result","payload","START","_t","set","t","deferStart","producer","subscribe","store","cb","opts","talkback","beginDeferredStart","START","type","data","END","next","p","prev","endDeferredStart","bufferTime","ms","input","store","producer","emit","error","complete","currentBuffer","unsub","subscribe","v","err","timer","flushed","Inspector"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as StoreOperator } from '../types-DsAN6Hga.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Time-windowed buffering. Accumulates upstream values and flushes
|
|
5
|
+
* the buffer every `ms` milliseconds.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains current buffer and last flushed array via producer.
|
|
8
|
+
* get() returns the last flushed array (empty array before first flush).
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).
|
|
11
|
+
* No equals — each flushed array is a new reference.
|
|
12
|
+
*/
|
|
13
|
+
declare function bufferTime<A>(ms: number): StoreOperator<A, A[]>;
|
|
14
|
+
|
|
15
|
+
export { bufferTime };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as StoreOperator } from '../types-DsAN6Hga.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Time-windowed buffering. Accumulates upstream values and flushes
|
|
5
|
+
* the buffer every `ms` milliseconds.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains current buffer and last flushed array via producer.
|
|
8
|
+
* get() returns the last flushed array (empty array before first flush).
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 2 — each flush starts a new DIRTY+value cycle (autoDirty: true).
|
|
11
|
+
* No equals — each flushed array is a new reference.
|
|
12
|
+
*/
|
|
13
|
+
declare function bufferTime<A>(ms: number): StoreOperator<A, A[]>;
|
|
14
|
+
|
|
15
|
+
export { bufferTime };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var D=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var Y=(n,e)=>{for(var i in e)D(n,i,{get:e[i],enumerable:!0})},W=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of U(e))!V.call(n,t)&&t!==i&&D(n,t,{get:()=>e[t],enumerable:!(s=K(e,t))||s.enumerable});return n};var F=n=>W(D({},"__esModule",{value:!0}),n);var X={};Y(X,{combine:()=>Q});module.exports=F(X);var b=class{_v;_w;constructor(e){this._v=0,this._w=e>32?new Uint32Array((e-1>>>5)+1):null}set(e){let i=this._w;if(i===null)this._v|=1<<e;else{let s=e>>>5,t=1<<(e&31);i[s]&t||(i[s]|=t,this._v++)}}clear(e){let i=this._w;if(i===null)this._v&=~(1<<e);else{let s=e>>>5,t=1<<(e&31);i[s]&t&&(i[s]&=~t,this._v--)}}test(e){let i=this._w;return i===null?(this._v&1<<e)!==0:(i[e>>>5]&1<<(e&31))!==0}empty(){return this._v===0}reset(){this._v=0,this._w?.fill(0)}};var g=Symbol("DIRTY"),S=Symbol("RESOLVED"),w=0,O=1,A=2,I=3,N=4,M=5,p=7,R=7<<p,P=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function $(n){return P[(n&R)>>>p]}var f=0,_=1,l=2,y=3;var T=class n{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static get enabled(){if(n._explicitEnabled!==null)return n._explicitEnabled;if(n._cachedDefault!==null)return n._cachedDefault;try{n._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{n._cachedDefault=!0}return n._cachedDefault}static set enabled(e){n._explicitEnabled=e}static _depSuffix(e){if(!e?.length)return;let s=e.map(t=>n._names.get(t)??"?").join(",");return s.length>40?`${s.slice(0,37)}...`:s}static _resolveKey(e){return n._keys.get(e)??n._names.get(e)??"anonymous"}static register(e,i){if(!n.enabled)return;i?.name&&n._names.set(e,i.name),i?.kind&&n._kinds.set(e,i.kind);let s=n._nextId++,t=i?.name;if(!(t&&!n._usedKeys.has(t)))if(t){let o=n._depSuffix(i?.deps);t=o?`${t}(${o})`:`${t}_${s}`,n._usedKeys.has(t)&&(t=`${t}_${s}`)}else{let o=i?.kind??"store",r=n._depSuffix(i?.deps);t=r?`${o}(${r})`:`${o}_${s}`,n._usedKeys.has(t)&&(t=`${t}_${s}`)}n._usedKeys.add(t),n._keys.set(e,t),n._stores.add(new WeakRef(e))}static registerEdge(e,i){if(!n.enabled)return;let s=n._resolveKey(e),t=n._resolveKey(i),o=n._edges.get(s);o?o.includes(t)||o.push(t):n._edges.set(s,[t])}static getEdges(){return new Map(n._edges)}static getName(e){if(n.enabled)return n._names.get(e)}static getKind(e){return n._kinds.get(e)}static inspect(e){return{name:n._names.get(e),kind:n._kinds.get(e)??"unknown",value:typeof e.get=="function"?e.get():void 0,status:e._status}}static graph(){let e=new Map,i=new Set;for(let s of n._stores){let t=s.deref();if(!t){n._stores.delete(s);continue}let o=n._resolveKey(t);i.add(o),e.set(o,n.inspect(t))}for(let[s,t]of n._edges){if(!i.has(s)){n._edges.delete(s),n._usedKeys.delete(s);continue}let o=t.filter(r=>i.has(r));o.length===0?n._edges.delete(s):o.length!==t.length&&n._edges.set(s,o)}return e}static trace(e,i){let s=null,t=e.get();return e.source(f,(o,r)=>{if(o===f&&(s=r),o===l){s=null;return}if(o===1){let a=r;if(!Object.is(a,t)){let u=t;t=a,i(a,u)}}}),()=>s?.(l)}static dumpGraph(){let e=n.graph(),i=n.getEdges(),s=new Map;for(let[r,a]of i)for(let u of a){let c=s.get(u);c?c.includes(r)||c.push(r):s.set(u,[r])}let t=[];for(let[r,a]of e){let u=s.get(r),c=i.get(r),v=u?.length?` \u2190 [${u.join(", ")}]`:"",h=c?.length?` \u2192 [${c.join(", ")}]`:"";t.push(` ${r} (${a.kind}) = ${JSON.stringify(a.value)} [${a.status??"?"}]${v}${h}`)}return[`Store Graph (${e.size} nodes):`,...t].join(`
|
|
2
|
+
`)}static _observe(e,i,s){let t=null,o=i??n.getName(e),r={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:o,dispose:()=>t?.(l)};return e.source(f,(a,u)=>{if(a===f){t=u;return}a===_?(r.values.push(u),r.events.push({type:"data",data:u}),s&&s(`[${o}] DATA:`,u)):a===y?(r.signals.push(u),r.events.push({type:"signal",data:u}),u===g?r.dirtyCount++:u===S&&r.resolvedCount++,s&&s(`[${o}] STATE:`,u)):a===l&&(r.ended=!0,r.endError=u,r.events.push({type:"end",data:u}),s&&s(`[${o}] END`,u!==void 0?u:""),t=null)}),r}static observe(e){return n._observe(e)}static tap(e,i){let s=i??`tap(${n.getName(e)??"anon"})`,t={get:()=>e.get(),source:e.source};return n.register(t,{name:s,kind:"tap"}),n.registerEdge(e,t),t}static spy(e,i){let s=i?.name??n.getName(e)??"spy",t=i?.log??console.log;return n._observe(e,s,t)}static snapshot(){let e=n.graph(),i=n.getEdges(),s=[];for(let[o,r]of e)s.push({name:o,kind:r.kind,value:r.value,status:r.status});let t=[];for(let[o,r]of i)for(let a of r)t.push({from:o,to:a});return{nodes:s,edges:t}}static _reset(){n._names=new WeakMap,n._kinds=new WeakMap,n._keys=new WeakMap,n._stores=new Set,n._edges=new Map,n._usedKeys=new Set,n._nextId=0,n._explicitEnabled=null,n._cachedDefault=null}};var E=1,k=2,C=4,d=8,j=w<<p,G=O<<p,z=A<<p,H=I<<p,J=N<<p,q=M<<p,m=R,x=class{_value;_output=null;_upstreamTalkbacks=[];_handler=null;_flags;_deps;_init;_getterFn;_initial;get _status(){return $(this._flags)}constructor(e,i,s){this._value=s?.initial,this._initial=s?.initial,this._deps=e,this._init=i,this._getterFn=s?.getter;let t=0;s?.resetOnTeardown&&(t|=k),s?.resubscribable&&(t|=C),this._flags=t,this.source=this.source.bind(this),T.register(this,{kind:s?.kind??"operator",...s,deps:e});for(let o of e)T.registerEdge(o,this)}_dispatch(e,i){let s=this._output;if(s)if(this._flags&d)for(let t of s)t(e,i);else s(e,i)}_connectUpstream(){let e=new Array(this._deps.length).fill(null);this._upstreamTalkbacks=e;let i=!1,s={seed:t=>{i||(this._value=t)},emit:t=>{i||(this._value=t,this._flags=this._flags&~m|z,this._dispatch(_,t))},signal:t=>{i||(t===g?this._flags=this._flags&~m|G:t===S&&(this._flags=this._flags&~m|H),this._dispatch(y,t))},complete:()=>{if(i)return;i=!0,this._flags=(this._flags|E)&~m|J,this._handler=null;for(let r of e)r?.(l);e.fill(null),this._flags&k&&(this._value=this._initial);let t=this._output,o=this._flags&d;if(this._output=null,this._flags&=~d,t)if(o)for(let r of t)r(l);else t(l)},error:t=>{if(i)return;i=!0,this._flags=(this._flags|E)&~m|q,this._handler=null;for(let a of e)a?.(l);e.fill(null),this._flags&k&&(this._value=this._initial);let o=this._output,r=this._flags&d;if(this._output=null,this._flags&=~d,o)if(r)for(let a of o)a(l,t);else o(l,t)},disconnect:t=>{if(t!==void 0)e[t]?.(l),e[t]=null;else{for(let o of e)o?.(l);e.fill(null)}}};this._handler=this._init(s);for(let t=0;t<this._deps.length&&!i;t++){let o=t;this._deps[o].source(f,(r,a)=>{if(r===f){e[o]=a;return}this._handler?.(o,r,a)})}}_disconnectUpstream(){for(let e of this._upstreamTalkbacks)e?.(l);this._upstreamTalkbacks=[],this._handler=null,this._flags=this._flags&~m|j,this._flags&k&&(this._value=this._initial)}get(){if(this._getterFn&&!this._output){let e=this._getterFn(this._value);return this._value=e,e}return this._value}source(e,i){if(e===f){let s=i;if(this._flags&E)if(this._flags&C&&this._output===null)this._flags=this._flags&~(E|m)|j;else{s(f,o=>{}),s(l);return}let t=this._output===null;if(this._output===null)this._output=s;else if(this._flags&d)this._output.add(s);else{let o=new Set;o.add(this._output),o.add(s),this._output=o,this._flags|=d}s(f,o=>{if(o===_&&s(_,this._value),o===l){if(this._output===null)return;if(this._flags&d){let r=this._output;r.delete(s),r.size===1?(this._output=r.values().next().value,this._flags&=~d):r.size===0&&(this._output=null,this._flags&=~d,this._disconnectUpstream())}else this._output===s&&(this._output=null,this._disconnectUpstream())}}),t&&this._connectUpstream()}}};function L(n,e,i){return new x(n,e,i)}function Q(...n){let e=n.map(i=>i.get());return L(n,({emit:i,signal:s,complete:t,error:o})=>{let r=new b(n.length),a=!1,u=n.length;return(c,v,h)=>{if(v===y)if(h===g){let B=r.empty();r.set(c),B&&(a=!1,s(g))}else h===S?r.test(c)&&(r.clear(c),r.empty()&&(a?i([...e]):s(S))):s(h);v===_&&(e[c]=h,r.test(c)?(r.clear(c),a=!0,r.empty()&&i([...e])):r.empty()?(s(g),i([...e])):a=!0),v===l&&(h!==void 0?o(h):(u--,u===0&&t()))}},{kind:"combine",name:"combine",initial:[...e],getter:()=>n.map(i=>i.get())})}0&&(module.exports={combine});
|
|
3
|
+
//# sourceMappingURL=combine.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/extra/combine.ts","../../src/core/bitmask.ts","../../src/core/protocol.ts","../../src/core/inspector.ts","../../src/core/operator.ts"],"sourcesContent":["import { Bitmask } from \"../core/bitmask\";\nimport { operator } from \"../core/operator\";\nimport { DATA, DIRTY, END, RESOLVED, STATE } from \"../core/protocol\";\nimport type { Store } from \"../core/types\";\n\n/**\n * Combines multiple sources into a single store whose value is a tuple\n * of all source values. Recomputes whenever any source changes.\n *\n * Stateful: maintains tuple value via operator()'s cache. get() returns\n * the current tuple of all source values.\n *\n * v3: Tier 1 — uses operator() with multi-dep dirty tracking via bitmask.\n * Forwards DIRTY on first dirty dep; recomputes and emits when all dirty\n * deps have resolved via DATA. If all dirty deps RESOLVED without DATA,\n * forwards RESOLVED (subtree skipping). Always produces a new array ref.\n */\nexport function combine<Sources extends Store<unknown>[]>(\n\t...sources: Sources\n): Store<{ [K in keyof Sources]: Sources[K] extends Store<infer T> ? T : never }> {\n\ttype Result = {\n\t\t[K in keyof Sources]: Sources[K] extends Store<infer T> ? T : never;\n\t};\n\tconst values = sources.map((s) => s.get());\n\n\treturn operator<Result>(\n\t\tsources as Store<unknown>[],\n\t\t({ emit, signal, complete, error }) => {\n\t\t\tconst dirtyDeps = new Bitmask(sources.length);\n\t\t\tlet anyDataReceived = false;\n\t\t\tlet activeCount = sources.length;\n\n\t\t\treturn (dep, type, data) => {\n\t\t\t\tif (type === STATE) {\n\t\t\t\t\tif (data === DIRTY) {\n\t\t\t\t\t\tconst wasClean = dirtyDeps.empty();\n\t\t\t\t\t\tdirtyDeps.set(dep);\n\t\t\t\t\t\tif (wasClean) {\n\t\t\t\t\t\t\tanyDataReceived = false;\n\t\t\t\t\t\t\tsignal(DIRTY);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (data === RESOLVED) {\n\t\t\t\t\t\tif (dirtyDeps.test(dep)) {\n\t\t\t\t\t\t\tdirtyDeps.clear(dep);\n\t\t\t\t\t\t\tif (dirtyDeps.empty()) {\n\t\t\t\t\t\t\t\tif (anyDataReceived) {\n\t\t\t\t\t\t\t\t\temit([...values] as unknown as Result);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsignal(RESOLVED);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsignal(data); // Forward unknown STATE signals (v4 forward-compat)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (type === DATA) {\n\t\t\t\t\tvalues[dep] = data;\n\t\t\t\t\tif (dirtyDeps.test(dep)) {\n\t\t\t\t\t\tdirtyDeps.clear(dep);\n\t\t\t\t\t\tanyDataReceived = true;\n\t\t\t\t\t\tif (dirtyDeps.empty()) {\n\t\t\t\t\t\t\temit([...values] as unknown as Result);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// DATA without prior DIRTY (raw callbag source)\n\t\t\t\t\t\tif (dirtyDeps.empty()) {\n\t\t\t\t\t\t\tsignal(DIRTY);\n\t\t\t\t\t\t\temit([...values] as unknown as Result);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tanyDataReceived = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (type === END) {\n\t\t\t\t\tif (data !== undefined) {\n\t\t\t\t\t\terror(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactiveCount--;\n\t\t\t\t\t\tif (activeCount === 0) complete();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t{\n\t\t\tkind: \"combine\",\n\t\t\tname: \"combine\",\n\t\t\tinitial: [...values] as unknown as Result,\n\t\t\tgetter: () => sources.map((s) => s.get()) as unknown as Result,\n\t\t},\n\t);\n}\n","/**\n * Dirty-dep bitmask — safe for any number of deps.\n *\n * ≤32 deps: stores bitmask as a plain number in `_v` (zero overhead).\n * >32 deps: stores bits in a Uint32Array `_w`, with `_v` tracking the\n * count of set bits for O(1) emptiness checks.\n *\n * In both cases, `empty()` is a single `_v === 0` comparison — no typeof\n * dispatch, no array scan. Method calls on the class prototype are\n * monomorphic (one hidden class for all instances).\n *\n * Used by derived, effect, merge, combine — anywhere dirty-dep tracking\n * needs per-dep bit flags.\n */\n\nexport class Bitmask {\n\t/** Narrow (≤32): bitmask value. Wide (>32): count of set bits. */\n\t_v: number;\n\t/** Uint32Array for >32 deps, null otherwise. */\n\t_w: Uint32Array | null;\n\n\tconstructor(size: number) {\n\t\tthis._v = 0;\n\t\tthis._w = size > 32 ? new Uint32Array(((size - 1) >>> 5) + 1) : null;\n\t}\n\n\tset(i: number): void {\n\t\tconst w = this._w;\n\t\tif (w === null) {\n\t\t\tthis._v |= 1 << i;\n\t\t} else {\n\t\t\tconst idx = i >>> 5;\n\t\t\tconst bit = 1 << (i & 31);\n\t\t\tif (!(w[idx] & bit)) {\n\t\t\t\tw[idx] |= bit;\n\t\t\t\tthis._v++;\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(i: number): void {\n\t\tconst w = this._w;\n\t\tif (w === null) {\n\t\t\tthis._v &= ~(1 << i);\n\t\t} else {\n\t\t\tconst idx = i >>> 5;\n\t\t\tconst bit = 1 << (i & 31);\n\t\t\tif (w[idx] & bit) {\n\t\t\t\tw[idx] &= ~bit;\n\t\t\t\tthis._v--;\n\t\t\t}\n\t\t}\n\t}\n\n\ttest(i: number): boolean {\n\t\tconst w = this._w;\n\t\tif (w === null) return (this._v & (1 << i)) !== 0;\n\t\treturn (w[i >>> 5] & (1 << (i & 31))) !== 0;\n\t}\n\n\t/** O(1) in both narrow and wide paths. */\n\tempty(): boolean {\n\t\treturn this._v === 0;\n\t}\n\n\treset(): void {\n\t\tthis._v = 0;\n\t\tthis._w?.fill(0);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Protocol — v3 type 3 control channel\n// ---------------------------------------------------------------------------\n// Type 3 (STATE) carries control signals: DIRTY, RESOLVED\n// Type 1 (DATA) carries only real values — never sentinels\n// ---------------------------------------------------------------------------\n\n/** Control signal: \"my value is about to change\" */\nexport const DIRTY = Symbol(\"DIRTY\");\n\n/** Control signal: \"I was dirty but my value didn't change\" */\nexport const RESOLVED = Symbol(\"RESOLVED\");\n\nexport type Signal = typeof DIRTY | typeof RESOLVED;\n\n/** Node status — tracks current lifecycle state (v4) */\nexport type NodeStatus =\n\t| \"DISCONNECTED\"\n\t| \"DIRTY\"\n\t| \"SETTLED\"\n\t| \"RESOLVED\"\n\t| \"COMPLETED\"\n\t| \"ERRORED\";\n\n// ---------------------------------------------------------------------------\n// Integer status constants — pack into _flags for hot-path performance.\n// 3 bits (7-9) encode 6 statuses. Use STATUS_MASK to read/write.\n// ---------------------------------------------------------------------------\nexport const S_DISCONNECTED = 0;\nexport const S_DIRTY = 1;\nexport const S_SETTLED = 2;\nexport const S_RESOLVED = 3;\nexport const S_COMPLETED = 4;\nexport const S_ERRORED = 5;\nexport const STATUS_SHIFT = 7;\nexport const STATUS_MASK = 0b111 << STATUS_SHIFT; // bits 7-9\n\nconst STATUS_STRINGS: NodeStatus[] = [\n\t\"DISCONNECTED\",\n\t\"DIRTY\",\n\t\"SETTLED\",\n\t\"RESOLVED\",\n\t\"COMPLETED\",\n\t\"ERRORED\",\n];\n\n/** Decode integer status bits back to string (for Inspector / tests) */\nexport function decodeStatus(flags: number): NodeStatus {\n\treturn STATUS_STRINGS[(flags & STATUS_MASK) >>> STATUS_SHIFT];\n}\n\n/** Callbag signal types */\nexport const START = 0;\nexport const DATA = 1;\nexport const END = 2;\nexport const STATE = 3;\n\n// ---------------------------------------------------------------------------\n// Batch — defers type 1 value emissions; type 3 DIRTY propagates immediately\n// ---------------------------------------------------------------------------\n\nlet batchDepth = 0;\nconst deferredEmissions: Array<() => void> = [];\n\n// `draining` prevents re-entrant drain when a nested batch() call ends while\n// the outer drain loop is already running. Without it, the inner batch's\n// finally block would see batchDepth===0 and start a second drain, racing the\n// outer loop — potentially double-processing items or clearing the array mid-\n// iteration. With draining=true, the inner batch skips its drain; any items it\n// pushes are picked up by the outer loop (the `for` condition re-evaluates\n// `deferredEmissions.length` on every iteration, so appends during drain are\n// naturally included in the same pass).\nlet draining = false;\n\nexport function batch<T>(fn: () => T): T {\n\tbatchDepth++;\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchDepth--;\n\t\tif (batchDepth === 0 && !draining) {\n\t\t\tdraining = true;\n\t\t\tfor (let i = 0; i < deferredEmissions.length; i++) {\n\t\t\t\tdeferredEmissions[i]();\n\t\t\t}\n\t\t\tdeferredEmissions.length = 0;\n\t\t\tdraining = false;\n\t\t}\n\t}\n}\n\nexport function isBatching(): boolean {\n\treturn batchDepth > 0;\n}\n\nexport function deferEmission(fn: () => void): void {\n\tdeferredEmissions.push(fn);\n}\n\n// ---------------------------------------------------------------------------\n// Connection batching (producer start deferral) — unchanged from v2\n// ---------------------------------------------------------------------------\n\nlet connectDepth = 0;\nconst pendingStarts: Array<() => void> = [];\n\nexport function beginDeferredStart(): void {\n\tconnectDepth++;\n}\n\nexport function endDeferredStart(): void {\n\tconnectDepth--;\n\tif (connectDepth === 0) {\n\t\tfor (let i = 0; i < pendingStarts.length; i++) {\n\t\t\tpendingStarts[i]();\n\t\t}\n\t\tpendingStarts.length = 0;\n\t}\n}\n\nexport function deferStart(start: () => void): void {\n\tif (connectDepth > 0) {\n\t\tpendingStarts.push(start);\n\t} else {\n\t\tstart();\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// teardown — protocol-level graph destruction\n// ---------------------------------------------------------------------------\n// Sends END to all downstream sinks of a store node, cascading through the\n// entire subgraph. After teardown, the node is in COMPLETED state and won't\n// accept new values or subscriptions.\n//\n// Works with any node that uses the output slot model:\n// - ProducerImpl / StateImpl / OperatorImpl → calls .complete()\n// - DerivedImpl → calls ._handleEnd() (no public complete() on derived)\n// ---------------------------------------------------------------------------\n\nexport function teardown(store: { source: (type: number, payload?: any) => void }): void {\n\tconst node = store as any;\n\tif (typeof node.complete === \"function\") {\n\t\tnode.complete();\n\t} else if (typeof node._handleEnd === \"function\") {\n\t\tnode._handleEnd(undefined);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Inspector — static class for observability\n// ---------------------------------------------------------------------------\n// All debug metadata lives here in WeakMaps, not on the store objects.\n// Stores stay lean. Inspector is opt-in overhead.\n//\n// v5: Zero intrusion into primitives. No hooks in hot paths. All methods\n// are static — call directly as Inspector.observe(), Inspector.tap(), etc.\n// - register/registerEdge: metadata collection (called from constructors)\n// - inspect/graph/dumpGraph/snapshot: read-only graph queries\n// - observe/spy/trace: callbag sinks for debugging (subscribe externally)\n// - tap: transparent passthrough wrapper for graph visualization\n// ---------------------------------------------------------------------------\n\nimport type { NodeStatus, Signal } from \"./protocol\";\nimport { DATA, DIRTY, END, RESOLVED, START, STATE } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport interface StoreInfo<T = unknown> {\n\tname: string | undefined;\n\tkind: string;\n\tvalue: T;\n\t/** v4: node lifecycle status */\n\tstatus: NodeStatus | undefined;\n}\n\nexport interface ObserveResult<T> {\n\t/** All DATA (type 1) values received, in order */\n\tvalues: T[];\n\t/** All STATE (type 3) payloads received (DIRTY, RESOLVED, or unknown) */\n\tsignals: Signal[];\n\t/** All events in protocol order: { type, data } */\n\tevents: Array<{ type: \"data\" | \"signal\" | \"end\"; data: unknown }>;\n\t/** Whether END (type 2) has been received */\n\tended: boolean;\n\t/** Error payload from END, if any */\n\tendError: unknown;\n\t/** Count of DIRTY signals received */\n\tdirtyCount: number;\n\t/** Count of RESOLVED signals received */\n\tresolvedCount: number;\n\t/** Store name (from Inspector, if registered) */\n\tname: string | undefined;\n\t/** Disconnect the observer */\n\tdispose: () => void;\n}\n\n// Static-only class is intentional API for Inspector namespace\n// biome-ignore lint/complexity/noStaticOnlyClass: public API surface\nexport class Inspector {\n\t// WeakMaps for metadata — keyed by any graph node (stores, effects, etc.)\n\tprivate static _names = new WeakMap<object, string>();\n\tprivate static _kinds = new WeakMap<object, string>();\n\tprivate static _keys = new WeakMap<object, string>();\n\n\t// WeakRef set for graph() — allows GC of unused nodes\n\tprivate static _stores = new Set<WeakRef<object>>();\n\n\t// Dependency edges: parent key → child keys\n\tprivate static _edges = new Map<string, string[]>();\n\n\t// Unique key generation\n\tprivate static _nextId = 0;\n\tprivate static _usedKeys = new Set<string>();\n\n\t// Enabled flag — when false, register/getName are no-ops\n\tprivate static _explicitEnabled: boolean | null = null;\n\tprivate static _cachedDefault: boolean | null = null;\n\n\tstatic get enabled(): boolean {\n\t\tif (Inspector._explicitEnabled !== null) return Inspector._explicitEnabled;\n\t\tif (Inspector._cachedDefault !== null) return Inspector._cachedDefault;\n\t\ttry {\n\t\t\tInspector._cachedDefault = (globalThis as any).process?.env?.NODE_ENV !== \"production\";\n\t\t} catch {\n\t\t\tInspector._cachedDefault = true;\n\t\t}\n\t\treturn Inspector._cachedDefault;\n\t}\n\n\tstatic set enabled(value: boolean) {\n\t\tInspector._explicitEnabled = value;\n\t}\n\n\t/** Compute a dep-name-based suffix for unique key generation */\n\tprivate static _depSuffix(deps?: object[]): string | undefined {\n\t\tif (!deps?.length) return undefined;\n\t\tconst names = deps.map((d) => Inspector._names.get(d) ?? \"?\");\n\t\tconst joined = names.join(\",\");\n\t\treturn joined.length > 40 ? `${joined.slice(0, 37)}...` : joined;\n\t}\n\n\t/** Resolve a node to its unique graph key */\n\tprivate static _resolveKey(node: object): string {\n\t\treturn Inspector._keys.get(node) ?? Inspector._names.get(node) ?? \"anonymous\";\n\t}\n\n\t/** Register a graph node (store, effect, etc.) with the inspector */\n\tstatic register(node: object, opts?: { name?: string; kind?: string; deps?: object[] }): void {\n\t\tif (!Inspector.enabled) return;\n\t\tif (opts?.name) Inspector._names.set(node, opts.name);\n\t\tif (opts?.kind) Inspector._kinds.set(node, opts.kind);\n\n\t\t// Compute unique key\n\t\tconst id = Inspector._nextId++;\n\t\tlet key = opts?.name;\n\t\tif (key && !Inspector._usedKeys.has(key)) {\n\t\t\t// Unique name — use as-is\n\t\t} else if (key) {\n\t\t\t// Name collision — differentiate with dep names or ID\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${key}(${depSuffix})` : `${key}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t} else {\n\t\t\t// Unnamed — use kind + dep names or ID\n\t\t\tconst kind = opts?.kind ?? \"store\";\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${kind}(${depSuffix})` : `${kind}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t}\n\n\t\tInspector._usedKeys.add(key);\n\t\tInspector._keys.set(node, key);\n\t\tInspector._stores.add(new WeakRef(node));\n\t}\n\n\t/** Register a dependency edge between parent and child nodes */\n\tstatic registerEdge(parent: object, child: object): void {\n\t\tif (!Inspector.enabled) return;\n\t\tconst parentKey = Inspector._resolveKey(parent);\n\t\tconst childKey = Inspector._resolveKey(child);\n\t\tconst children = Inspector._edges.get(parentKey);\n\t\tif (children) {\n\t\t\tif (!children.includes(childKey)) children.push(childKey);\n\t\t} else {\n\t\t\tInspector._edges.set(parentKey, [childKey]);\n\t\t}\n\t}\n\n\t/** Get dependency edges: parent → children */\n\tstatic getEdges(): Map<string, string[]> {\n\t\treturn new Map(Inspector._edges);\n\t}\n\n\t/** Get the name of a node */\n\tstatic getName(node: object): string | undefined {\n\t\tif (!Inspector.enabled) return undefined;\n\t\treturn Inspector._names.get(node);\n\t}\n\n\t/** Get the kind of a node */\n\tstatic getKind(node: object): string | undefined {\n\t\treturn Inspector._kinds.get(node);\n\t}\n\n\t/** Inspect a single graph node — includes status and value (if available) */\n\tstatic inspect<T = unknown>(node: object): StoreInfo<T> {\n\t\treturn {\n\t\t\tname: Inspector._names.get(node),\n\t\t\tkind: Inspector._kinds.get(node) ?? \"unknown\",\n\t\t\tvalue: (typeof (node as any).get === \"function\" ? (node as any).get() : undefined) as T,\n\t\t\tstatus: (node as any)._status,\n\t\t};\n\t}\n\n\t/** Get all living nodes as a Map. Also prunes dead edges from GC'd nodes. */\n\tstatic graph(): Map<string, StoreInfo> {\n\t\tconst result = new Map<string, StoreInfo>();\n\t\tconst livingKeys = new Set<string>();\n\t\tfor (const ref of Inspector._stores) {\n\t\t\tconst node = ref.deref();\n\t\t\tif (!node) {\n\t\t\t\tInspector._stores.delete(ref); // cleanup GC'd refs\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = Inspector._resolveKey(node);\n\t\t\tlivingKeys.add(key);\n\t\t\tresult.set(key, Inspector.inspect(node));\n\t\t}\n\t\t// Prune edges referencing GC'd stores\n\t\tfor (const [key, children] of Inspector._edges) {\n\t\t\tif (!livingKeys.has(key)) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t\tInspector._usedKeys.delete(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst alive = children.filter((c) => livingKeys.has(c));\n\t\t\tif (alive.length === 0) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t} else if (alive.length !== children.length) {\n\t\t\t\tInspector._edges.set(key, alive);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Trace a specific store's value changes (raw callbag — no extra/ dependency) */\n\tstatic trace<T>(store: Store<T>, cb: (value: T, prev: T | undefined) => void): () => void {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tlet prev: T | undefined = store.get();\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) talkback = data;\n\t\t\tif (type === END) {\n\t\t\t\ttalkback = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === 1) {\n\t\t\t\tconst next = data as T;\n\t\t\t\tif (!Object.is(next, prev)) {\n\t\t\t\t\tconst p = prev;\n\t\t\t\t\tprev = next;\n\t\t\t\t\tcb(next, p);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn () => talkback?.(END);\n\t}\n\n\t/** Pretty-print the entire store graph for console/CLI debugging */\n\tstatic dumpGraph(): string {\n\t\tconst g = Inspector.graph();\n\t\tconst edges = Inspector.getEdges();\n\n\t\t// Build reverse map: child key → parent keys (deps)\n\t\tconst depsMap = new Map<string, string[]>();\n\t\tfor (const [parent, children] of edges) {\n\t\t\tfor (const child of children) {\n\t\t\t\tconst deps = depsMap.get(child);\n\t\t\t\tif (deps) {\n\t\t\t\t\tif (!deps.includes(parent)) deps.push(parent);\n\t\t\t\t} else {\n\t\t\t\t\tdepsMap.set(child, [parent]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst lines: string[] = [];\n\t\tfor (const [key, info] of g) {\n\t\t\tconst deps = depsMap.get(key);\n\t\t\tconst children = edges.get(key);\n\t\t\tconst depsStr = deps?.length ? ` ← [${deps.join(\", \")}]` : \"\";\n\t\t\tconst childStr = children?.length ? ` → [${children.join(\", \")}]` : \"\";\n\t\t\tlines.push(\n\t\t\t\t` ${key} (${info.kind}) = ${JSON.stringify(info.value)} [${info.status ?? \"?\"}]${depsStr}${childStr}`,\n\t\t\t);\n\t\t}\n\t\tconst header = `Store Graph (${g.size} nodes):`;\n\t\treturn [header, ...lines].join(\"\\n\");\n\t}\n\n\t/**\n\t * Internal observe implementation shared by observe() and spy().\n\t */\n\tprivate static _observe<T>(\n\t\tstore: Store<T>,\n\t\tlabel?: string,\n\t\tlog?: (...args: any[]) => void,\n\t): ObserveResult<T> {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tconst name = label ?? Inspector.getName(store);\n\t\tconst result: ObserveResult<T> = {\n\t\t\tvalues: [],\n\t\t\tsignals: [],\n\t\t\tevents: [],\n\t\t\tended: false,\n\t\t\tendError: undefined,\n\t\t\tdirtyCount: 0,\n\t\t\tresolvedCount: 0,\n\t\t\tname,\n\t\t\tdispose: () => talkback?.(END),\n\t\t};\n\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\ttalkback = data;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === DATA) {\n\t\t\t\tresult.values.push(data);\n\t\t\t\tresult.events.push({ type: \"data\", data });\n\t\t\t\tif (log) log(`[${name}] DATA:`, data);\n\t\t\t} else if (type === STATE) {\n\t\t\t\tresult.signals.push(data);\n\t\t\t\tresult.events.push({ type: \"signal\", data });\n\t\t\t\tif (data === DIRTY) result.dirtyCount++;\n\t\t\t\telse if (data === RESOLVED) result.resolvedCount++;\n\t\t\t\tif (log) log(`[${name}] STATE:`, data);\n\t\t\t} else if (type === END) {\n\t\t\t\tresult.ended = true;\n\t\t\t\tresult.endError = data;\n\t\t\t\tresult.events.push({ type: \"end\", data });\n\t\t\t\tif (log) log(`[${name}] END`, data !== undefined ? data : \"\");\n\t\t\t\ttalkback = null;\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Observe a store's full callbag protocol — the test-friendly alternative\n\t * to hooks. Captures DATA values, STATE signals, END, and provides\n\t * convenience accessors.\n\t *\n\t * Returns a live observation object — arrays grow as the store emits.\n\t *\n\t * ```ts\n\t * const obs = Inspector.observe(myStore);\n\t * myState.set(5);\n\t * obs.values // [5]\n\t * obs.signals // [DIRTY]\n\t * obs.ended // false\n\t * obs.dirtyCount // 1\n\t * obs.dispose() // stop observing\n\t * ```\n\t */\n\tstatic observe<T>(store: Store<T>): ObserveResult<T> {\n\t\treturn Inspector._observe(store);\n\t}\n\n\t/**\n\t * Create a transparent passthrough wrapper for graph visualization.\n\t * The wrapper delegates `get()` and `source()` to the original store,\n\t * appearing as a distinct node in the Inspector graph. Zero overhead —\n\t * subscribers connect directly to the original store's source.\n\t */\n\tstatic tap<T>(store: Store<T>, name?: string): Store<T> {\n\t\tconst tapName = name ?? `tap(${Inspector.getName(store) ?? \"anon\"})`;\n\t\tconst wrapper: Store<T> = {\n\t\t\tget: () => store.get(),\n\t\t\tsource: store.source,\n\t\t};\n\t\tInspector.register(wrapper, { name: tapName, kind: \"tap\" });\n\t\tInspector.registerEdge(store, wrapper);\n\t\treturn wrapper;\n\t}\n\n\t/**\n\t * Enhanced observe() with logging — for interactive debugging.\n\t * Returns the same observation object as observe(), but also logs each\n\t * event as it happens. Pass a custom logger or defaults to console.log.\n\t */\n\tstatic spy<T>(\n\t\tstore: Store<T>,\n\t\topts?: { name?: string; log?: (...args: any[]) => void },\n\t): ObserveResult<T> {\n\t\tconst label = opts?.name ?? Inspector.getName(store) ?? \"spy\";\n\t\tconst log = opts?.log ?? console.log;\n\t\treturn Inspector._observe(store, label, log);\n\t}\n\n\t/**\n\t * JSON-serializable snapshot of the entire graph — nodes + edges.\n\t * Designed for AI consumption during debugging sessions.\n\t */\n\tstatic snapshot(): {\n\t\tnodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }>;\n\t\tedges: Array<{ from: string; to: string }>;\n\t} {\n\t\tconst g = Inspector.graph();\n\t\tconst edgeMap = Inspector.getEdges();\n\t\tconst nodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }> =\n\t\t\t[];\n\t\tfor (const [key, info] of g) {\n\t\t\tnodes.push({ name: key, kind: info.kind, value: info.value, status: info.status });\n\t\t}\n\t\tconst edges: Array<{ from: string; to: string }> = [];\n\t\tfor (const [parent, children] of edgeMap) {\n\t\t\tfor (const child of children) {\n\t\t\t\tedges.push({ from: parent, to: child });\n\t\t\t}\n\t\t}\n\t\treturn { nodes, edges };\n\t}\n\n\t/** Reset all state (for testing) */\n\tstatic _reset(): void {\n\t\tInspector._names = new WeakMap<object, string>();\n\t\tInspector._kinds = new WeakMap<object, string>();\n\t\tInspector._keys = new WeakMap<object, string>();\n\t\tInspector._stores = new Set<WeakRef<object>>();\n\t\tInspector._edges = new Map();\n\t\tInspector._usedKeys = new Set();\n\t\tInspector._nextId = 0;\n\t\tInspector._explicitEnabled = null;\n\t\tInspector._cachedDefault = null;\n\t}\n}\n","/**\n * General-purpose transform primitive. Receives all signal types from upstream\n * deps and decides what to forward.\n *\n * v5: _status packed into _flags bits 7-9 for hot-path performance.\n * String status exposed via getter for Inspector/test backward compat.\n *\n * Class-based for V8 hidden class optimization and prototype method sharing.\n * Boolean fields packed into _flags bitmask to reduce hidden class size.\n */\n\nimport { Inspector } from \"./inspector\";\nimport type { Signal } from \"./protocol\";\nimport {\n\tDATA,\n\tDIRTY,\n\tdecodeStatus,\n\tEND,\n\tRESOLVED,\n\tS_COMPLETED,\n\tS_DIRTY,\n\tS_DISCONNECTED,\n\tS_ERRORED,\n\tS_RESOLVED,\n\tS_SETTLED,\n\tSTART,\n\tSTATE,\n\tSTATUS_MASK,\n\tSTATUS_SHIFT,\n} from \"./protocol\";\nimport type { Actions, SourceOptions, Store } from \"./types\";\n\nexport type OperatorOpts<B> = SourceOptions<B>;\n\n// Flag bits for _flags bitmask (bits 0-6)\nconst O_COMPLETED = 1;\nconst O_RESET = 2;\nconst O_RESUB = 4;\nconst O_MULTI = 8;\n\n// Pre-shifted status constants for hot-path writes\nconst _S_DISCONNECTED = S_DISCONNECTED << STATUS_SHIFT;\nconst _S_DIRTY = S_DIRTY << STATUS_SHIFT;\nconst _S_SETTLED = S_SETTLED << STATUS_SHIFT;\nconst _S_RESOLVED = S_RESOLVED << STATUS_SHIFT;\nconst _S_COMPLETED = S_COMPLETED << STATUS_SHIFT;\nconst _S_ERRORED = S_ERRORED << STATUS_SHIFT;\nconst _STATUS_MASK = STATUS_MASK;\n\nexport class OperatorImpl<B> {\n\t_value: B | undefined;\n\t_output: ((type: number, data?: any) => void) | Set<any> | null = null;\n\t_upstreamTalkbacks: Array<((type: number) => void) | null> = [];\n\t_handler: ((depIndex: number, type: number, data: any) => void) | null = null;\n\t_flags: number;\n\t_deps: Store<unknown>[];\n\t_init: (actions: Actions<B>) => (depIndex: number, type: number, data: any) => void;\n\t_getterFn: ((cached: B | undefined) => B) | undefined;\n\t_initial: B | undefined;\n\n\tget _status() {\n\t\treturn decodeStatus(this._flags);\n\t}\n\n\tconstructor(\n\t\tdeps: Store<unknown>[],\n\t\tinit: (actions: Actions<B>) => (depIndex: number, type: number, data: any) => void,\n\t\topts?: OperatorOpts<B>,\n\t) {\n\t\tthis._value = opts?.initial;\n\t\tthis._initial = opts?.initial;\n\t\tthis._deps = deps;\n\t\tthis._init = init;\n\t\tthis._getterFn = opts?.getter;\n\n\t\tlet flags = 0;\n\t\tif (opts?.resetOnTeardown) flags |= O_RESET;\n\t\tif (opts?.resubscribable) flags |= O_RESUB;\n\t\t// S_DISCONNECTED = 0, so no status bits needed\n\t\tthis._flags = flags;\n\n\t\tthis.source = this.source.bind(this);\n\n\t\tInspector.register(this as any, { kind: opts?.kind ?? \"operator\", ...opts, deps });\n\t\tfor (const dep of deps) Inspector.registerEdge(dep, this as any);\n\t}\n\n\t_dispatch(type: number, data?: any): void {\n\t\tconst output = this._output;\n\t\tif (!output) return;\n\t\tif (this._flags & O_MULTI) {\n\t\t\tfor (const sink of output as Set<any>) sink(type, data);\n\t\t} else {\n\t\t\t(output as (type: number, data?: any) => void)(type, data);\n\t\t}\n\t}\n\n\t_connectUpstream(): void {\n\t\tconst localTalkbacks: Array<((type: number) => void) | null> = new Array(\n\t\t\tthis._deps.length,\n\t\t).fill(null);\n\t\tthis._upstreamTalkbacks = localTalkbacks;\n\n\t\tlet completed = false;\n\n\t\tconst actions: Actions<B> = {\n\t\t\tseed: (value: B) => {\n\t\t\t\tif (completed) return;\n\t\t\t\tthis._value = value;\n\t\t\t},\n\t\t\temit: (value: B) => {\n\t\t\t\tif (completed) return;\n\t\t\t\tthis._value = value;\n\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\t\tthis._dispatch(DATA, value);\n\t\t\t},\n\t\t\tsignal: (s: Signal) => {\n\t\t\t\tif (completed) return;\n\t\t\t\tif (s === DIRTY) this._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\telse if (s === RESOLVED) this._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\t\tthis._dispatch(STATE, s);\n\t\t\t},\n\t\t\tcomplete: () => {\n\t\t\t\tif (completed) return;\n\t\t\t\tcompleted = true;\n\t\t\t\tthis._flags = ((this._flags | O_COMPLETED) & ~_STATUS_MASK) | _S_COMPLETED;\n\t\t\t\tthis._handler = null;\n\t\t\t\tfor (const tb of localTalkbacks) tb?.(END);\n\t\t\t\tlocalTalkbacks.fill(null);\n\t\t\t\tif (this._flags & O_RESET) this._value = this._initial;\n\t\t\t\tconst output = this._output;\n\t\t\t\tconst wasMulti = this._flags & O_MULTI;\n\t\t\t\tthis._output = null;\n\t\t\t\tthis._flags &= ~O_MULTI;\n\t\t\t\tif (output) {\n\t\t\t\t\tif (wasMulti) {\n\t\t\t\t\t\tfor (const sink of output as Set<any>) sink(END);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t(output as (type: number, data?: any) => void)(END);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: (e: unknown) => {\n\t\t\t\tif (completed) return;\n\t\t\t\tcompleted = true;\n\t\t\t\tthis._flags = ((this._flags | O_COMPLETED) & ~_STATUS_MASK) | _S_ERRORED;\n\t\t\t\tthis._handler = null;\n\t\t\t\tfor (const tb of localTalkbacks) tb?.(END);\n\t\t\t\tlocalTalkbacks.fill(null);\n\t\t\t\tif (this._flags & O_RESET) this._value = this._initial;\n\t\t\t\tconst output = this._output;\n\t\t\t\tconst wasMulti = this._flags & O_MULTI;\n\t\t\t\tthis._output = null;\n\t\t\t\tthis._flags &= ~O_MULTI;\n\t\t\t\tif (output) {\n\t\t\t\t\tif (wasMulti) {\n\t\t\t\t\t\tfor (const sink of output as Set<any>) sink(END, e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t(output as (type: number, data?: any) => void)(END, e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdisconnect: (dep?: number) => {\n\t\t\t\tif (dep !== undefined) {\n\t\t\t\t\tlocalTalkbacks[dep]?.(END);\n\t\t\t\t\tlocalTalkbacks[dep] = null;\n\t\t\t\t} else {\n\t\t\t\t\tfor (const tb of localTalkbacks) tb?.(END);\n\t\t\t\t\tlocalTalkbacks.fill(null);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tthis._handler = this._init(actions);\n\n\t\tfor (let i = 0; i < this._deps.length; i++) {\n\t\t\tif (completed) break;\n\t\t\tconst depIndex = i;\n\t\t\tthis._deps[depIndex].source(START, (type: number, data: any) => {\n\t\t\t\tif (type === START) {\n\t\t\t\t\tlocalTalkbacks[depIndex] = data;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._handler?.(depIndex, type, data);\n\t\t\t});\n\t\t}\n\t}\n\n\t_disconnectUpstream(): void {\n\t\tfor (const tb of this._upstreamTalkbacks) tb?.(END);\n\t\tthis._upstreamTalkbacks = [];\n\t\tthis._handler = null;\n\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\tif (this._flags & O_RESET) this._value = this._initial;\n\t}\n\n\tget(): B {\n\t\tif (this._getterFn && !this._output) {\n\t\t\tconst v = this._getterFn(this._value);\n\t\t\tthis._value = v;\n\t\t\treturn v;\n\t\t}\n\t\treturn this._value as B;\n\t}\n\n\tsource(type: number, payload?: any): void {\n\t\tif (type === START) {\n\t\t\tconst sink = payload;\n\t\t\tif (this._flags & O_COMPLETED) {\n\t\t\t\tif (this._flags & O_RESUB && this._output === null) {\n\t\t\t\t\tthis._flags = (this._flags & ~(O_COMPLETED | _STATUS_MASK)) | _S_DISCONNECTED;\n\t\t\t\t} else {\n\t\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\t\tsink(END);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst wasEmpty = this._output === null;\n\t\t\tif (this._output === null) {\n\t\t\t\tthis._output = sink;\n\t\t\t} else if (!(this._flags & O_MULTI)) {\n\t\t\t\tconst set = new Set<any>();\n\t\t\t\tset.add(this._output);\n\t\t\t\tset.add(sink);\n\t\t\t\tthis._output = set;\n\t\t\t\tthis._flags |= O_MULTI;\n\t\t\t} else {\n\t\t\t\t(this._output as Set<any>).add(sink);\n\t\t\t}\n\t\t\tsink(START, (t: number) => {\n\t\t\t\tif (t === DATA) sink(DATA, this._value);\n\t\t\t\tif (t === END) {\n\t\t\t\t\tif (this._output === null) return;\n\t\t\t\t\tif (this._flags & O_MULTI) {\n\t\t\t\t\t\tconst set = this._output as Set<any>;\n\t\t\t\t\t\tset.delete(sink);\n\t\t\t\t\t\tif (set.size === 1) {\n\t\t\t\t\t\t\tthis._output = set.values().next().value;\n\t\t\t\t\t\t\tthis._flags &= ~O_MULTI;\n\t\t\t\t\t\t} else if (set.size === 0) {\n\t\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\t\tthis._flags &= ~O_MULTI;\n\t\t\t\t\t\t\tthis._disconnectUpstream();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this._output === sink) {\n\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\tthis._disconnectUpstream();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (wasEmpty) {\n\t\t\t\tthis._connectUpstream();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function operator<B>(\n\tdeps: Store<unknown>[],\n\tinit: (actions: Actions<B>) => (depIndex: number, type: number, data: any) => void,\n\topts?: OperatorOpts<B>,\n): Store<B> {\n\treturn new OperatorImpl<B>(deps, init, opts) as any;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCeO,IAAMI,EAAN,KAAc,CAEpB,GAEA,GAEA,YAAYC,EAAc,CACzB,KAAK,GAAK,EACV,KAAK,GAAKA,EAAO,GAAK,IAAI,aAAcA,EAAO,IAAO,GAAK,CAAC,EAAI,IACjE,CAEA,IAAIC,EAAiB,CACpB,IAAMC,EAAI,KAAK,GACf,GAAIA,IAAM,KACT,KAAK,IAAM,GAAKD,MACV,CACN,IAAME,EAAMF,IAAM,EACZG,EAAM,IAAMH,EAAI,IAChBC,EAAEC,CAAG,EA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,EACZ,GAAID,IAASE,EAAO,CACnB,IAAMC,EAAWT,EAAU,MAAM,EACjCA,EAAU,IAAII,CAAG,EACbK,IACHP,EAAkB,GAClBL,EAAOW,CAAK,EAEd,MAAWF,IAASI,EACfV,EAAU,KAAKI,CAAG,IACrBJ,EAAU,MAAMI,CAAG,EACfJ,EAAU,MAAM,IACfE,EACHN,EAAK,CAAC,GAAGH,CAAM,CAAsB,EAErCI,EAAOa,CAAQ,IAKlBb,EAAOS,CAAI,EAGTD,IAASM,IACZlB,EAAOW,CAAG,EAAIE,EACVN,EAAU,KAAKI,CAAG,GACrBJ,EAAU,MAAMI,CAAG,EACnBF,EAAkB,GACdF,EAAU,MAAM,GACnBJ,EAAK,CAAC,GAAGH,CAAM,CAAsB,GAIlCO,EAAU,MAAM,GACnBH,EAAOW,CAAK,EACZZ,EAAK,CAAC,GAAGH,CAAM,CAAsB,GAErCS,EAAkB,IAIjBG,IAASO,IACRN,IAAS,OACZP,EAAMO,CAAI,GAEVH,IACIA,IAAgB,GAAGL,EAAS,GAGnC,CACD,EACA,CACC,KAAM,UACN,KAAM,UACN,QAAS,CAAC,GAAGL,CAAM,EACnB,OAAQ,IAAMD,EAAQ,IAAKE,GAAMA,EAAE,IAAI,CAAC,CACzC,CACD,CACD","names":["combine_exports","__export","combine","__toCommonJS","Bitmask","size","i","w","idx","bit","DIRTY","RESOLVED","S_DISCONNECTED","S_DIRTY","S_SETTLED","S_RESOLVED","S_COMPLETED","S_ERRORED","STATUS_SHIFT","STATUS_MASK","STATUS_STRINGS","decodeStatus","flags","START","DATA","END","STATE","Inspector","_Inspector","value","deps","joined","d","node","opts","id","key","depSuffix","kind","parent","child","parentKey","childKey","children","result","livingKeys","ref","alive","c","store","cb","talkback","prev","START","type","data","END","next","p","g","edges","depsMap","lines","info","depsStr","childStr","label","log","name","DATA","STATE","DIRTY","RESOLVED","tapName","wrapper","edgeMap","nodes","O_COMPLETED","O_RESET","O_RESUB","O_MULTI","_S_DISCONNECTED","S_DISCONNECTED","STATUS_SHIFT","_S_DIRTY","S_DIRTY","_S_SETTLED","S_SETTLED","_S_RESOLVED","S_RESOLVED","_S_COMPLETED","S_COMPLETED","_S_ERRORED","S_ERRORED","_STATUS_MASK","STATUS_MASK","OperatorImpl","decodeStatus","deps","init","opts","flags","Inspector","dep","type","data","output","sink","localTalkbacks","completed","actions","value","DATA","s","DIRTY","RESOLVED","STATE","tb","END","wasMulti","e","i","depIndex","START","v","payload","_t","wasEmpty","set","t","operator","combine","sources","values","s","operator","emit","signal","complete","error","dirtyDeps","Bitmask","anyDataReceived","activeCount","dep","type","data","STATE","DIRTY","wasClean","RESOLVED","DATA","END"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { S as Store } from '../types-DsAN6Hga.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combines multiple sources into a single store whose value is a tuple
|
|
5
|
+
* of all source values. Recomputes whenever any source changes.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains tuple value via operator()'s cache. get() returns
|
|
8
|
+
* the current tuple of all source values.
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 1 — uses operator() with multi-dep dirty tracking via bitmask.
|
|
11
|
+
* Forwards DIRTY on first dirty dep; recomputes and emits when all dirty
|
|
12
|
+
* deps have resolved via DATA. If all dirty deps RESOLVED without DATA,
|
|
13
|
+
* forwards RESOLVED (subtree skipping). Always produces a new array ref.
|
|
14
|
+
*/
|
|
15
|
+
declare function combine<Sources extends Store<unknown>[]>(...sources: Sources): Store<{
|
|
16
|
+
[K in keyof Sources]: Sources[K] extends Store<infer T> ? T : never;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export { combine };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { S as Store } from '../types-DsAN6Hga.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combines multiple sources into a single store whose value is a tuple
|
|
5
|
+
* of all source values. Recomputes whenever any source changes.
|
|
6
|
+
*
|
|
7
|
+
* Stateful: maintains tuple value via operator()'s cache. get() returns
|
|
8
|
+
* the current tuple of all source values.
|
|
9
|
+
*
|
|
10
|
+
* v3: Tier 1 — uses operator() with multi-dep dirty tracking via bitmask.
|
|
11
|
+
* Forwards DIRTY on first dirty dep; recomputes and emits when all dirty
|
|
12
|
+
* deps have resolved via DATA. If all dirty deps RESOLVED without DATA,
|
|
13
|
+
* forwards RESOLVED (subtree skipping). Always produces a new array ref.
|
|
14
|
+
*/
|
|
15
|
+
declare function combine<Sources extends Store<unknown>[]>(...sources: Sources): Store<{
|
|
16
|
+
[K in keyof Sources]: Sources[K] extends Store<infer T> ? T : never;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export { combine };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var i in t)k(e,i,{get:t[i],enumerable:!0})},Z=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!Q.call(e,n)&&n!==i&&k(e,n,{get:()=>t[n],enumerable:!(s=H(t,n))||s.enumerable});return e};var ee=e=>Z(k({},"__esModule",{value:!0}),e);var ue={};X(ue,{concat:()=>ae});module.exports=ee(ue);var v=Symbol("DIRTY"),m=Symbol("RESOLVED"),I=0,P=1,M=2,$=3,j=4,C=5,g=7,R=7<<g,te=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function L(e){return te[(e&R)>>>g]}var f=0,h=1,l=2,T=3,se=0,ne=[];function K(){return se>0}function F(e){ne.push(e)}var y=0,E=[];function V(){y++}function Y(){if(y--,y===0){for(let e=0;e<E.length;e++)E[e]();E.length=0}}function U(e){y>0?E.push(e):e()}var b=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let s=t.map(n=>e._names.get(n)??"?").join(",");return s.length>40?`${s.slice(0,37)}...`:s}static _resolveKey(t){return e._keys.get(t)??e._names.get(t)??"anonymous"}static register(t,i){if(!e.enabled)return;i?.name&&e._names.set(t,i.name),i?.kind&&e._kinds.set(t,i.kind);let s=e._nextId++,n=i?.name;if(!(n&&!e._usedKeys.has(n)))if(n){let r=e._depSuffix(i?.deps);n=r?`${n}(${r})`:`${n}_${s}`,e._usedKeys.has(n)&&(n=`${n}_${s}`)}else{let r=i?.kind??"store",o=e._depSuffix(i?.deps);n=o?`${r}(${o})`:`${r}_${s}`,e._usedKeys.has(n)&&(n=`${n}_${s}`)}e._usedKeys.add(n),e._keys.set(t,n),e._stores.add(new WeakRef(t))}static registerEdge(t,i){if(!e.enabled)return;let s=e._resolveKey(t),n=e._resolveKey(i),r=e._edges.get(s);r?r.includes(n)||r.push(n):e._edges.set(s,[n])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,i=new Set;for(let s of e._stores){let n=s.deref();if(!n){e._stores.delete(s);continue}let r=e._resolveKey(n);i.add(r),t.set(r,e.inspect(n))}for(let[s,n]of e._edges){if(!i.has(s)){e._edges.delete(s),e._usedKeys.delete(s);continue}let r=n.filter(o=>i.has(o));r.length===0?e._edges.delete(s):r.length!==n.length&&e._edges.set(s,r)}return t}static trace(t,i){let s=null,n=t.get();return t.source(f,(r,o)=>{if(r===f&&(s=o),r===l){s=null;return}if(r===1){let u=o;if(!Object.is(u,n)){let a=n;n=u,i(u,a)}}}),()=>s?.(l)}static dumpGraph(){let t=e.graph(),i=e.getEdges(),s=new Map;for(let[o,u]of i)for(let a of u){let c=s.get(a);c?c.includes(o)||c.push(o):s.set(a,[o])}let n=[];for(let[o,u]of t){let a=s.get(o),c=i.get(o),S=a?.length?` \u2190 [${a.join(", ")}]`:"",B=c?.length?` \u2192 [${c.join(", ")}]`:"";n.push(` ${o} (${u.kind}) = ${JSON.stringify(u.value)} [${u.status??"?"}]${S}${B}`)}return[`Store Graph (${t.size} nodes):`,...n].join(`
|
|
2
|
+
`)}static _observe(t,i,s){let n=null,r=i??e.getName(t),o={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:r,dispose:()=>n?.(l)};return t.source(f,(u,a)=>{if(u===f){n=a;return}u===h?(o.values.push(a),o.events.push({type:"data",data:a}),s&&s(`[${r}] DATA:`,a)):u===T?(o.signals.push(a),o.events.push({type:"signal",data:a}),a===v?o.dirtyCount++:a===m&&o.resolvedCount++,s&&s(`[${r}] STATE:`,a)):u===l&&(o.ended=!0,o.endError=a,o.events.push({type:"end",data:a}),s&&s(`[${r}] END`,a!==void 0?a:""),n=null)}),o}static observe(t){return e._observe(t)}static tap(t,i){let s=i??`tap(${e.getName(t)??"anon"})`,n={get:()=>t.get(),source:t.source};return e.register(n,{name:s,kind:"tap"}),e.registerEdge(t,n),n}static spy(t,i){let s=i?.name??e.getName(t)??"spy",n=i?.log??console.log;return e._observe(t,s,n)}static snapshot(){let t=e.graph(),i=e.getEdges(),s=[];for(let[r,o]of t)s.push({name:r,kind:o.kind,value:o.value,status:o.status});let n=[];for(let[r,o]of i)for(let u of o)n.push({from:r,to:u});return{nodes:s,edges:n}}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null}};var D=1,p=64,_=2,O=4,W=8,q=16,A=32,d=R,w=P<<g,G=M<<g,x=I<<g,ie=j<<g,re=C<<g,oe=$<<g,N=class{_value;_output=null;_flags;get _status(){return L(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;constructor(t,i){this._value=i?.initial,this._fn=t,this._eqFn=i?.equals,this._getterFn=i?.getter,this._initial=i?.initial;let s=0;i?.autoDirty!==!1&&(s|=O),i?.resetOnTeardown&&(s|=W),i?.resubscribable&&(s|=q),this._flags=s,this.source=this.source.bind(this),this.emit=this.emit.bind(this),this.signal=this.signal.bind(this),this.complete=this.complete.bind(this),this.error=this.error.bind(this),i?._skipInspect||b.register(this,{kind:"producer",...i})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,i){let s=this._output;if(s)if(this._flags&p)for(let n of s)n(t,i);else s(t,i)}emit(t){this._flags&_||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(K()?this._flags&A||(this._flags|=A,this._flags&O&&(this._flags=this._flags&~d|w,this._dispatch(T,v)),F(()=>{this._flags&=~A,this._flags=this._flags&~d|G,this._dispatch(h,this._value)})):(this._flags&O&&(this._flags=this._flags&~d|w,this._dispatch(T,v)),this._flags=this._flags&~d|G,this._dispatch(h,this._value))))}signal(t){this._flags&_||!this._output||(t===v?this._flags=this._flags&~d|w:t===m&&(this._flags=this._flags&~d|oe),this._dispatch(T,t))}complete(){if(this._flags&_)return;this._flags=(this._flags|_)&~d|ie;let t=this._output,i=this._flags&p;if(this._output=null,this._flags&=~p,this._stop(),t)if(i)for(let s of t)s(l);else t(l)}error(t){if(this._flags&_)return;this._flags=(this._flags|_)&~d|re;let i=this._output,s=this._flags&p;if(this._output=null,this._flags&=~p,this._stop(),i)if(s)for(let n of i)n(l,t);else i(l,t)}_start(){if(this._flags&D||!this._fn)return;this._flags|=D;let t=this._fn(this);this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&D&&(this._flags&=~D,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&W&&(this._value=this._initial),this._flags&_||(this._flags=this._flags&~d|x))}source(t,i){if(t===f){let s=i;if(this._flags&_)if(this._flags&q&&this._output===null)this._flags=this._flags&~(_|d)|x;else{s(f,n=>{}),s(l);return}if(this._output===null)this._output=s;else if(this._flags&p)this._output.add(s);else{let n=new Set;n.add(this._output),n.add(s),this._output=n,this._flags|=p}s(f,n=>{if(n===h&&s(h,this._value),n===l){if(this._output===null)return;if(this._flags&p){let r=this._output;r.delete(s),r.size===1?(this._output=r.values().next().value,this._flags&=~p):r.size===0&&(this._output=null,this._flags&=~p,this._flags=this._flags&~d|x,this._stop())}else this._output===s&&(this._output=null,this._flags=this._flags&~d|x,this._stop())}}),U(()=>this._start())}}};function z(e,t){return new N(e,t)}function ae(...e){return z(({emit:t,signal:i,complete:s,error:n})=>{let r=0,o=null;function u(){if(r>=e.length){s();return}let a=e[r++];V(),a.source(f,(c,S)=>{if(c===f){o=S;return}c===T&&i(S),c===h&&t(S),c===l&&(o=null,S!==void 0?n(S):u())}),Y()}return u(),()=>{o&&o(l)}},{autoDirty:!1})}0&&(module.exports={concat});
|
|
3
|
+
//# sourceMappingURL=concat.cjs.map
|