@logixjs/core 0.0.1 → 0.0.2
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/LICENSE +201 -0
- package/dist/{Bound-BN1DQ_lM.d.ts → Bound-CEa1ihvH.d.ts} +2 -2
- package/dist/{Bound-BPIfH9SS.d.cts → Bound-CNLNkC7c.d.cts} +2 -2
- package/dist/Bound.cjs +620 -163
- package/dist/Bound.cjs.map +1 -1
- package/dist/Bound.d.cts +3 -3
- package/dist/Bound.d.ts +3 -3
- package/dist/Bound.js +14 -14
- package/dist/{Debug-Bq8Sqjcr.d.cts → Debug-BhMYr-1i.d.cts} +3 -3
- package/dist/{Debug-B5q5Bkzx.d.ts → Debug-ByM7m4Ft.d.ts} +3 -3
- package/dist/Debug.cjs +553 -32
- package/dist/Debug.cjs.map +1 -1
- package/dist/Debug.d.cts +10 -8
- package/dist/Debug.d.ts +10 -8
- package/dist/Debug.js +12 -10
- package/dist/EffectOp.cjs.map +1 -1
- package/dist/EffectOp.js +2 -3
- package/dist/EffectOp.js.map +1 -1
- package/dist/Env.cjs +664 -6
- package/dist/Env.cjs.map +1 -1
- package/dist/Env.js +5 -2
- package/dist/ExternalStore-BAz83PVq.d.cts +60 -0
- package/dist/ExternalStore-BYWPbYs8.d.ts +60 -0
- package/dist/ExternalStore.cjs +746 -0
- package/dist/ExternalStore.cjs.map +1 -0
- package/dist/ExternalStore.d.cts +4 -0
- package/dist/ExternalStore.d.ts +4 -0
- package/dist/ExternalStore.js +19 -0
- package/dist/ExternalStore.js.map +1 -0
- package/dist/{Flow-1fZT8MpX.d.cts → Flow-BlSoMmhV.d.cts} +2 -2
- package/dist/{Flow-BhpjE22E.d.ts → Flow-CQSGve5c.d.ts} +2 -2
- package/dist/Flow.cjs +2 -2
- package/dist/Flow.cjs.map +1 -1
- package/dist/Flow.d.cts +4 -4
- package/dist/Flow.d.ts +4 -4
- package/dist/Flow.js +7 -8
- package/dist/{Handle-D_cLW1Z3.d.ts → Handle-B7PSmsrY.d.ts} +1 -1
- package/dist/{Handle-D8D1zPb_.d.cts → Handle-ByovhL-c.d.cts} +1 -1
- package/dist/Handle.d.cts +3 -3
- package/dist/Handle.d.ts +3 -3
- package/dist/{Kernel-CnGE1Fyk.d.ts → Kernel-DGSpS4GM.d.ts} +2 -2
- package/dist/{Kernel-8kC-jOda.d.cts → Kernel-DZAk-Mrn.d.cts} +2 -2
- package/dist/Kernel.cjs +680 -22
- package/dist/Kernel.cjs.map +1 -1
- package/dist/Kernel.d.cts +10 -8
- package/dist/Kernel.d.ts +10 -8
- package/dist/Kernel.js +7 -4
- package/dist/{Link-Db7975nU.d.ts → Link-Cm4eR9n0.d.ts} +10 -3
- package/dist/{Link-fX8x1eCK.d.cts → Link-DF8i8iWR.d.cts} +10 -3
- package/dist/Link.cjs +1128 -86
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.d.cts +3 -3
- package/dist/Link.d.ts +3 -3
- package/dist/Link.js +30 -25
- package/dist/{Logic-DRh4sDZj.d.cts → Logic-BcQA0AvE.d.cts} +1 -1
- package/dist/{Logic-BRjEMr-W.d.ts → Logic-OotSE1xw.d.ts} +1 -1
- package/dist/Logic.d.cts +3 -3
- package/dist/Logic.d.ts +3 -3
- package/dist/{MatchBuilder-CJk5oCkR.d.cts → MatchBuilder-BNDJ8waF.d.ts} +1 -1
- package/dist/{MatchBuilder-0QOc-nlU.d.ts → MatchBuilder-CvZ5WY1B.d.cts} +1 -1
- package/dist/MatchBuilder.d.cts +4 -4
- package/dist/MatchBuilder.d.ts +4 -4
- package/dist/Middleware-D8tUDLv_.d.cts +100 -0
- package/dist/Middleware-DS7CbTTN.d.ts +100 -0
- package/dist/Middleware.cjs +461 -13
- package/dist/Middleware.cjs.map +1 -1
- package/dist/Middleware.d.cts +2 -86
- package/dist/Middleware.d.ts +2 -86
- package/dist/Middleware.js +13 -11
- package/dist/{Module-DnzluX2J.d.ts → Module-CFj0I2yE.d.ts} +45 -18
- package/dist/{Module-B_0xRDMR.d.cts → Module-DpXPW9EQ.d.cts} +45 -18
- package/dist/Module.cjs +8583 -5741
- package/dist/Module.cjs.map +1 -1
- package/dist/Module.d.cts +5 -4
- package/dist/Module.d.ts +5 -4
- package/dist/Module.js +32 -27
- package/dist/ModuleTag-BcVF6z7B.d.ts +113 -0
- package/dist/ModuleTag-DuZXo_NS.d.cts +113 -0
- package/dist/ModuleTag.cjs +2609 -1232
- package/dist/ModuleTag.cjs.map +1 -1
- package/dist/ModuleTag.d.cts +4 -4
- package/dist/ModuleTag.d.ts +4 -4
- package/dist/ModuleTag.js +28 -25
- package/dist/{Observability-cY4kLn0S.d.ts → Observability-D-ZWeEVb.d.ts} +22 -15
- package/dist/{Observability-COqEvp2C.d.cts → Observability-V7sRMYTh.d.cts} +22 -15
- package/dist/Observability.cjs +1938 -640
- package/dist/Observability.cjs.map +1 -1
- package/dist/Observability.d.cts +4 -4
- package/dist/Observability.d.ts +4 -4
- package/dist/Observability.js +21 -19
- package/dist/{Process-mL8fHDSB.d.cts → Process-B55aJMFk.d.cts} +29 -4
- package/dist/{Process-CM9xbMdP.d.ts → Process-DvhFEwUS.d.ts} +29 -4
- package/dist/Process.cjs +1122 -85
- package/dist/Process.cjs.map +1 -1
- package/dist/Process.d.cts +4 -3
- package/dist/Process.d.ts +4 -3
- package/dist/Process.js +27 -22
- package/dist/{ReadQuery-BlMwhe-F.d.ts → ReadQuery-C4vZ8Prc.d.ts} +2 -2
- package/dist/{ReadQuery-SinbStGF.d.ts → ReadQuery-CafjlJQo.d.cts} +1 -1
- package/dist/{ReadQuery-SinbStGF.d.cts → ReadQuery-CafjlJQo.d.ts} +1 -1
- package/dist/{ReadQuery-CL5XlXts.d.cts → ReadQuery-mc0NgrFV.d.cts} +2 -2
- package/dist/ReadQuery.cjs +3 -3
- package/dist/ReadQuery.cjs.map +1 -1
- package/dist/ReadQuery.d.cts +2 -2
- package/dist/ReadQuery.d.ts +2 -2
- package/dist/ReadQuery.js +3 -3
- package/dist/{Reflection-CQnKwPXj.d.ts → Reflection-C8xZ267q.d.ts} +88 -7
- package/dist/{Reflection-Kabo1mlU.d.cts → Reflection-DP7Vsv3f.d.cts} +88 -7
- package/dist/Reflection.cjs +2934 -1553
- package/dist/Reflection.cjs.map +1 -1
- package/dist/Reflection.d.cts +14 -11
- package/dist/Reflection.d.ts +14 -11
- package/dist/Reflection.js +26 -21
- package/dist/Resource.cjs +670 -12
- package/dist/Resource.cjs.map +1 -1
- package/dist/Resource.js +6 -3
- package/dist/Root.cjs +675 -17
- package/dist/Root.cjs.map +1 -1
- package/dist/Root.js +7 -3
- package/dist/{Runtime-CtyzZG4i.d.ts → Runtime-BWc9YfUB.d.ts} +37 -7
- package/dist/{Runtime-B-aL-f29.d.cts → Runtime-PShIC4DW.d.cts} +37 -7
- package/dist/Runtime.cjs +1899 -809
- package/dist/Runtime.cjs.map +1 -1
- package/dist/Runtime.d.cts +14 -11
- package/dist/Runtime.d.ts +14 -11
- package/dist/Runtime.js +33 -28
- package/dist/ScopeRegistry.cjs +668 -10
- package/dist/ScopeRegistry.cjs.map +1 -1
- package/dist/ScopeRegistry.js +6 -3
- package/dist/{StateTrait-OWhbj12c.d.cts → StateTrait-CQsDlXJm.d.cts} +23 -6
- package/dist/{StateTrait-BGsZghTz.d.ts → StateTrait-YvJzVDKl.d.ts} +23 -6
- package/dist/StateTrait.cjs +1475 -370
- package/dist/StateTrait.cjs.map +1 -1
- package/dist/StateTrait.d.cts +7 -5
- package/dist/StateTrait.d.ts +7 -5
- package/dist/StateTrait.js +17 -14
- package/dist/{TraitLifecycle-LdIWmKlg.d.ts → TraitLifecycle-CjIBICAA.d.ts} +2 -2
- package/dist/{TraitLifecycle-CwV5WPFX.d.cts → TraitLifecycle-NmqGiXPC.d.cts} +2 -2
- package/dist/TraitLifecycle.cjs +489 -32
- package/dist/TraitLifecycle.cjs.map +1 -1
- package/dist/TraitLifecycle.d.cts +4 -4
- package/dist/TraitLifecycle.d.ts +4 -4
- package/dist/TraitLifecycle.js +7 -7
- package/dist/Workflow-BlFG_20_.d.cts +414 -0
- package/dist/Workflow-CW9S_aAP.d.ts +414 -0
- package/dist/Workflow.cjs +2977 -0
- package/dist/Workflow.cjs.map +1 -0
- package/dist/Workflow.d.cts +7 -0
- package/dist/Workflow.d.ts +7 -0
- package/dist/Workflow.js +55 -0
- package/dist/Workflow.js.map +1 -0
- package/dist/{chunk-G5ZBFPNU.js → chunk-2A4UKO2D.js} +2 -2
- package/dist/chunk-2DE6D42I.js +248 -0
- package/dist/chunk-2DE6D42I.js.map +1 -0
- package/dist/{chunk-ANLBCBDC.js → chunk-2DVLMSOE.js} +6 -6
- package/dist/{chunk-BE3HW4FY.js → chunk-34CF6OGE.js} +14 -16
- package/dist/chunk-34CF6OGE.js.map +1 -0
- package/dist/{chunk-ZFY7U2FR.js → chunk-3LPIXG56.js} +43 -3
- package/dist/chunk-3LPIXG56.js.map +1 -0
- package/dist/chunk-3VZYDNXZ.js +10 -0
- package/dist/chunk-3VZYDNXZ.js.map +1 -0
- package/dist/{chunk-3TMODYZV.js → chunk-3XO4HR6V.js} +2 -2
- package/dist/chunk-46FGVWRF.js +817 -0
- package/dist/chunk-46FGVWRF.js.map +1 -0
- package/dist/chunk-4LODUXFI.js +288 -0
- package/dist/chunk-4LODUXFI.js.map +1 -0
- package/dist/{chunk-GMPEOUP2.js → chunk-4MZ7BT3R.js} +2 -2
- package/dist/chunk-4MZ7BT3R.js.map +1 -0
- package/dist/{chunk-TKZ7MEIA.js → chunk-53GVPGSM.js} +2 -2
- package/dist/{chunk-KP7MUZNX.js → chunk-5W2V2NVJ.js} +2 -2
- package/dist/chunk-5W2V2NVJ.js.map +1 -0
- package/dist/chunk-6DACKW3D.js +613 -0
- package/dist/chunk-6DACKW3D.js.map +1 -0
- package/dist/chunk-AQ7L2QZ5.js +1395 -0
- package/dist/chunk-AQ7L2QZ5.js.map +1 -0
- package/dist/{chunk-NZJKFF45.js → chunk-C2UZZQ76.js} +2 -2
- package/dist/chunk-CCKP5Z6F.js +701 -0
- package/dist/chunk-CCKP5Z6F.js.map +1 -0
- package/dist/chunk-CUKM2XUW.js +27 -0
- package/dist/{chunk-QCHIQWAJ.js.map → chunk-CUKM2XUW.js.map} +1 -1
- package/dist/{chunk-M2RGJPXX.js → chunk-DBD6Q6JH.js} +3 -3
- package/dist/{chunk-ZGDVUPTM.js → chunk-EB4RGQO3.js} +2 -2
- package/dist/{chunk-PAYXCY6A.js → chunk-G7ESIQTI.js} +12 -14
- package/dist/chunk-G7ESIQTI.js.map +1 -0
- package/dist/chunk-GPBAZQ23.js +348 -0
- package/dist/chunk-GPBAZQ23.js.map +1 -0
- package/dist/{chunk-OFADUJWJ.js → chunk-I4LCE5OY.js} +3 -5
- package/dist/{chunk-OFADUJWJ.js.map → chunk-I4LCE5OY.js.map} +1 -1
- package/dist/{chunk-DFNM3WX2.js → chunk-IMCC6TBN.js} +158 -39
- package/dist/chunk-IMCC6TBN.js.map +1 -0
- package/dist/{chunk-76WT3HOR.js → chunk-IROZNQAF.js} +22 -21
- package/dist/chunk-IROZNQAF.js.map +1 -0
- package/dist/{chunk-TAAPQVZN.js → chunk-ISKNULNH.js} +2 -2
- package/dist/chunk-J3CWXIPV.js +242 -0
- package/dist/chunk-J3CWXIPV.js.map +1 -0
- package/dist/{chunk-PYOE4VSI.js → chunk-JBKYRTCS.js} +224 -161
- package/dist/chunk-JBKYRTCS.js.map +1 -0
- package/dist/{chunk-66ALHVEX.js → chunk-KKIAYH4X.js} +3 -3
- package/dist/{chunk-3RMKLXHX.js → chunk-KLDVG3SY.js} +2 -2
- package/dist/{chunk-BABLDP24.js → chunk-KSZQYSEH.js} +3 -3
- package/dist/chunk-KSZQYSEH.js.map +1 -0
- package/dist/{chunk-CW6T36TN.js → chunk-M3M7JFAH.js} +4 -4
- package/dist/chunk-M3M7JFAH.js.map +1 -0
- package/dist/{chunk-THATMZXD.js → chunk-MLB253V2.js} +2 -2
- package/dist/{chunk-THATMZXD.js.map → chunk-MLB253V2.js.map} +1 -1
- package/dist/{chunk-JGIWG6SR.js → chunk-MS77U77X.js} +664 -550
- package/dist/chunk-MS77U77X.js.map +1 -0
- package/dist/chunk-MW4FA3MW.js +23 -0
- package/dist/chunk-MW4FA3MW.js.map +1 -0
- package/dist/chunk-MYKNINNN.js +228 -0
- package/dist/chunk-MYKNINNN.js.map +1 -0
- package/dist/{chunk-4CQAV7YB.js → chunk-O6TTQXTY.js} +2 -2
- package/dist/{chunk-NBD3KUOZ.js → chunk-OJDJ4VDQ.js} +35 -24
- package/dist/chunk-OJDJ4VDQ.js.map +1 -0
- package/dist/{chunk-NQZ2OSGR.js → chunk-PVZEMNJY.js} +9 -9
- package/dist/chunk-PVZEMNJY.js.map +1 -0
- package/dist/chunk-RN26DV2M.js +271 -0
- package/dist/chunk-RN26DV2M.js.map +1 -0
- package/dist/{chunk-JCXGZRMU.js → chunk-RQQW3IQC.js} +3 -3
- package/dist/chunk-RQQW3IQC.js.map +1 -0
- package/dist/{chunk-24VULZ7A.js → chunk-TKOGZDD6.js} +3 -3
- package/dist/{chunk-EGK3KN7B.js → chunk-TQYLVXGY.js} +70 -39
- package/dist/chunk-TQYLVXGY.js.map +1 -0
- package/dist/{chunk-QMM6O4CD.js → chunk-UACD2CL2.js} +15 -3
- package/dist/{chunk-QMM6O4CD.js.map → chunk-UACD2CL2.js.map} +1 -1
- package/dist/{chunk-M3WTHJHJ.js → chunk-VH575UTV.js} +30 -34
- package/dist/chunk-VH575UTV.js.map +1 -0
- package/dist/{chunk-AUIR5O6W.js → chunk-WWBMC24F.js} +9 -15
- package/dist/chunk-WWBMC24F.js.map +1 -0
- package/dist/{chunk-JWOYLO27.js → chunk-WYJUJV4L.js} +80 -7
- package/dist/chunk-WYJUJV4L.js.map +1 -0
- package/dist/{chunk-EY4NZKDR.js → chunk-XFMMPYNU.js} +2 -2
- package/dist/chunk-Y4VRBIS6.js +35 -0
- package/dist/chunk-Y4VRBIS6.js.map +1 -0
- package/dist/{chunk-DMBALCE2.js → chunk-ZC7MSQ5U.js} +77 -4
- package/dist/chunk-ZC7MSQ5U.js.map +1 -0
- package/dist/{chunk-OGWBVHB3.js → chunk-ZCK6SCOE.js} +67 -8
- package/dist/chunk-ZCK6SCOE.js.map +1 -0
- package/dist/{chunk-IHVBV5C2.js → chunk-ZTFTABXV.js} +2 -1
- package/dist/chunk-ZTFTABXV.js.map +1 -0
- package/dist/index.cjs +9532 -5017
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -27
- package/dist/index.d.ts +163 -27
- package/dist/index.js +119 -56
- package/dist/index.js.map +1 -1
- package/dist/{ir-BMP7yxJJ.d.cts → ir-C-Zm_GlZ.d.cts} +1 -1
- package/dist/{ir-DUOz6H-5.d.ts → ir-DGyGiwVe.d.ts} +1 -1
- package/dist/{module-k7m3txak.d.ts → module-DqQ1U-Me.d.ts} +129 -100
- package/dist/{module-B8CBqIZ_.d.cts → module-doenaCsZ.d.cts} +129 -100
- package/package.json +12 -1
- package/dist/ModuleTag-C8FHY_sY.d.ts +0 -93
- package/dist/ModuleTag-EGbgBMpZ.d.cts +0 -93
- package/dist/chunk-3QMIVH35.js +0 -43
- package/dist/chunk-3QMIVH35.js.map +0 -1
- package/dist/chunk-76WT3HOR.js.map +0 -1
- package/dist/chunk-AUIR5O6W.js.map +0 -1
- package/dist/chunk-BABLDP24.js.map +0 -1
- package/dist/chunk-BE3HW4FY.js.map +0 -1
- package/dist/chunk-CW6T36TN.js.map +0 -1
- package/dist/chunk-DFNM3WX2.js.map +0 -1
- package/dist/chunk-DMBALCE2.js.map +0 -1
- package/dist/chunk-EGK3KN7B.js.map +0 -1
- package/dist/chunk-GMPEOUP2.js.map +0 -1
- package/dist/chunk-IHVBV5C2.js.map +0 -1
- package/dist/chunk-JCXGZRMU.js.map +0 -1
- package/dist/chunk-JGIWG6SR.js.map +0 -1
- package/dist/chunk-JWOYLO27.js.map +0 -1
- package/dist/chunk-KIXAU3GM.js +0 -137
- package/dist/chunk-KIXAU3GM.js.map +0 -1
- package/dist/chunk-KP7MUZNX.js.map +0 -1
- package/dist/chunk-M3WTHJHJ.js.map +0 -1
- package/dist/chunk-M7IYCTJV.js +0 -79
- package/dist/chunk-M7IYCTJV.js.map +0 -1
- package/dist/chunk-NBD3KUOZ.js.map +0 -1
- package/dist/chunk-NQZ2OSGR.js.map +0 -1
- package/dist/chunk-OGWBVHB3.js.map +0 -1
- package/dist/chunk-PAYXCY6A.js.map +0 -1
- package/dist/chunk-PYOE4VSI.js.map +0 -1
- package/dist/chunk-QCHIQWAJ.js +0 -21
- package/dist/chunk-VZB726PE.js +0 -93
- package/dist/chunk-VZB726PE.js.map +0 -1
- package/dist/chunk-W3TEWHLO.js +0 -568
- package/dist/chunk-W3TEWHLO.js.map +0 -1
- package/dist/chunk-ZFLHVFUC.js +0 -192
- package/dist/chunk-ZFLHVFUC.js.map +0 -1
- package/dist/chunk-ZFY7U2FR.js.map +0 -1
- /package/dist/{chunk-G5ZBFPNU.js.map → chunk-2A4UKO2D.js.map} +0 -0
- /package/dist/{chunk-ANLBCBDC.js.map → chunk-2DVLMSOE.js.map} +0 -0
- /package/dist/{chunk-3TMODYZV.js.map → chunk-3XO4HR6V.js.map} +0 -0
- /package/dist/{chunk-TKZ7MEIA.js.map → chunk-53GVPGSM.js.map} +0 -0
- /package/dist/{chunk-NZJKFF45.js.map → chunk-C2UZZQ76.js.map} +0 -0
- /package/dist/{chunk-M2RGJPXX.js.map → chunk-DBD6Q6JH.js.map} +0 -0
- /package/dist/{chunk-ZGDVUPTM.js.map → chunk-EB4RGQO3.js.map} +0 -0
- /package/dist/{chunk-TAAPQVZN.js.map → chunk-ISKNULNH.js.map} +0 -0
- /package/dist/{chunk-66ALHVEX.js.map → chunk-KKIAYH4X.js.map} +0 -0
- /package/dist/{chunk-3RMKLXHX.js.map → chunk-KLDVG3SY.js.map} +0 -0
- /package/dist/{chunk-4CQAV7YB.js.map → chunk-O6TTQXTY.js.map} +0 -0
- /package/dist/{chunk-24VULZ7A.js.map → chunk-TKOGZDD6.js.map} +0 -0
- /package/dist/{chunk-EY4NZKDR.js.map → chunk-XFMMPYNU.js.map} +0 -0
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { D as Draft } from './Logic-DRh4sDZj.cjs';
|
|
3
|
-
import { N as NormalizedActionTokens, b as ActionDefs } from './action-DiMDD_0v.cjs';
|
|
4
|
-
import { F as FieldPath, A as AnySchema, i as ModuleShape, q as ActionsFromMap, R as ReducersFromMap, M as ModuleTag$1, p as ActionOf, h as AnyModuleShape, B as BoundApi, m as ModuleHandle, G as ModuleHandleUnion, k as ModuleImpl, j as ModuleLogic, l as ModuleRuntime, v as StateChangeWithMeta, u as StateCommitMeta, s as StateCommitMode, t as StateCommitPriority, o as StateOf } from './module-B8CBqIZ_.cjs';
|
|
5
|
-
|
|
6
|
-
type NoInfer_<T> = [T][T extends any ? 0 : never];
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Reducer helper:
|
|
10
|
-
* - `Reducer.mutate` provides the same mutative style as `$.state.mutate`.
|
|
11
|
-
* - Internally uses mutative-based immutable updates to map "in-place draft mutation" into a pure `(state, action) => state`.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* const Counter = Logix.ModuleTag.make("Counter", {
|
|
16
|
-
* state: CounterState,
|
|
17
|
-
* actions: CounterActions,
|
|
18
|
-
* reducers: {
|
|
19
|
-
* inc: Logix.ModuleTag.Reducer.mutate((draft, _payload) => {
|
|
20
|
-
* draft.count += 1
|
|
21
|
-
* }),
|
|
22
|
-
* },
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* yield* $.reducer(
|
|
26
|
-
* "setValue",
|
|
27
|
-
* Logix.ModuleTag.Reducer.mutate((draft, payload) => {
|
|
28
|
-
* draft.value = payload
|
|
29
|
-
* }),
|
|
30
|
-
* )
|
|
31
|
-
*/
|
|
32
|
-
declare const Reducer: {
|
|
33
|
-
mutate: <S, A extends {
|
|
34
|
-
readonly payload?: any;
|
|
35
|
-
}>(mutator: (draft: Draft<S>, payload: A["payload"]) => void) => ((state: S, action: A, sink?: (path: string | FieldPath) => void) => S);
|
|
36
|
-
mutateMap: <R extends Readonly<Record<string, ((state: any, action: any, sink?: (path: string | FieldPath) => void) => any) | undefined>>>(mutators: { readonly [K in keyof NoInfer_<R>]?: (draft: Draft<Parameters<NonNullable<NoInfer_<R>[K]>>[0]>, payload: Parameters<NonNullable<NoInfer_<R>[K]>>[1] extends {
|
|
37
|
-
readonly payload: infer P;
|
|
38
|
-
} ? P : Parameters<NonNullable<NoInfer_<R>[K]>>[1] extends {
|
|
39
|
-
readonly payload?: infer P;
|
|
40
|
-
} ? P | undefined : never) => void; }) => R;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* A simplified Shape definition helper, designed for Action Maps.
|
|
44
|
-
* @example type MyShape = Shape<typeof MyState, typeof MyActionMap>
|
|
45
|
-
*/
|
|
46
|
-
type Shape<S extends AnySchema, M extends Record<string, AnySchema>> = ModuleShape<S, Schema.Schema<ActionsFromMap<NormalizedActionTokens<M & ActionDefs>>>, NormalizedActionTokens<M & ActionDefs>>;
|
|
47
|
-
/**
|
|
48
|
-
* ModuleTag.make:
|
|
49
|
-
* - Defines a domain module Tag using the given id and state/actions/reducers.
|
|
50
|
-
* - The returned ModuleTag is both a Context.Tag and a factory carrying its Shape.
|
|
51
|
-
*
|
|
52
|
-
* Note: since 022, the old `Module` (Tag identity) was renamed to `ModuleTag`; use `Logix.Module` for module definition objects.
|
|
53
|
-
*/
|
|
54
|
-
declare const make: <Id extends string, SSchema extends AnySchema, ADefs extends ActionDefs>(id: Id, def: {
|
|
55
|
-
readonly state: SSchema;
|
|
56
|
-
readonly actions: ADefs;
|
|
57
|
-
readonly reducers?: ReducersFromMap<SSchema, ADefs>;
|
|
58
|
-
/**
|
|
59
|
-
* traits:
|
|
60
|
-
* - Used to attach a StateTraitSpec (see specs/000-module-traits-runtime).
|
|
61
|
-
* - The current implementation builds a Program during ModuleTag.make, and injects a setup-only Logic in `ModuleTag.implement`
|
|
62
|
-
* to call `StateTrait.install`.
|
|
63
|
-
* (Note: if you use `ModuleTag.live` to export a Layer and want trait behavior, call `StateTrait.install` explicitly in logics,
|
|
64
|
-
* or use `ModuleTag.implement` instead.)
|
|
65
|
-
*/
|
|
66
|
-
readonly traits?: unknown;
|
|
67
|
-
}) => ModuleTag$1<Id, ModuleShape<SSchema, Schema.Schema<ActionsFromMap<NormalizedActionTokens<ADefs>>>, NormalizedActionTokens<ADefs>>>;
|
|
68
|
-
|
|
69
|
-
declare const ModuleTag_ActionOf: typeof ActionOf;
|
|
70
|
-
declare const ModuleTag_ActionsFromMap: typeof ActionsFromMap;
|
|
71
|
-
declare const ModuleTag_AnyModuleShape: typeof AnyModuleShape;
|
|
72
|
-
declare const ModuleTag_AnySchema: typeof AnySchema;
|
|
73
|
-
declare const ModuleTag_BoundApi: typeof BoundApi;
|
|
74
|
-
declare const ModuleTag_ModuleHandle: typeof ModuleHandle;
|
|
75
|
-
declare const ModuleTag_ModuleHandleUnion: typeof ModuleHandleUnion;
|
|
76
|
-
declare const ModuleTag_ModuleImpl: typeof ModuleImpl;
|
|
77
|
-
declare const ModuleTag_ModuleLogic: typeof ModuleLogic;
|
|
78
|
-
declare const ModuleTag_ModuleRuntime: typeof ModuleRuntime;
|
|
79
|
-
declare const ModuleTag_ModuleShape: typeof ModuleShape;
|
|
80
|
-
declare const ModuleTag_Reducer: typeof Reducer;
|
|
81
|
-
declare const ModuleTag_ReducersFromMap: typeof ReducersFromMap;
|
|
82
|
-
type ModuleTag_Shape<S extends AnySchema, M extends Record<string, AnySchema>> = Shape<S, M>;
|
|
83
|
-
declare const ModuleTag_StateChangeWithMeta: typeof StateChangeWithMeta;
|
|
84
|
-
declare const ModuleTag_StateCommitMeta: typeof StateCommitMeta;
|
|
85
|
-
declare const ModuleTag_StateCommitMode: typeof StateCommitMode;
|
|
86
|
-
declare const ModuleTag_StateCommitPriority: typeof StateCommitPriority;
|
|
87
|
-
declare const ModuleTag_StateOf: typeof StateOf;
|
|
88
|
-
declare const ModuleTag_make: typeof make;
|
|
89
|
-
declare namespace ModuleTag {
|
|
90
|
-
export { ModuleTag_ActionOf as ActionOf, ModuleTag_ActionsFromMap as ActionsFromMap, ModuleTag_AnyModuleShape as AnyModuleShape, ModuleTag_AnySchema as AnySchema, ModuleTag_BoundApi as BoundApi, ModuleTag_ModuleHandle as ModuleHandle, ModuleTag_ModuleHandleUnion as ModuleHandleUnion, ModuleTag_ModuleImpl as ModuleImpl, ModuleTag_ModuleLogic as ModuleLogic, ModuleTag_ModuleRuntime as ModuleRuntime, ModuleTag_ModuleShape as ModuleShape, ModuleTag$1 as ModuleTag, ModuleTag_Reducer as Reducer, ModuleTag_ReducersFromMap as ReducersFromMap, type ModuleTag_Shape as Shape, ModuleTag_StateChangeWithMeta as StateChangeWithMeta, ModuleTag_StateCommitMeta as StateCommitMeta, ModuleTag_StateCommitMode as StateCommitMode, ModuleTag_StateCommitPriority as StateCommitPriority, ModuleTag_StateOf as StateOf, ModuleTag_make as make };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { ModuleTag as M, Reducer as R, type Shape as S, make as m };
|
package/dist/chunk-3QMIVH35.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/internal/runtime/core/env.ts
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
var getNodeEnv = () => {
|
|
4
|
-
try {
|
|
5
|
-
const env = globalThis?.process?.env;
|
|
6
|
-
return typeof env?.NODE_ENV === "string" ? env.NODE_ENV : void 0;
|
|
7
|
-
} catch {
|
|
8
|
-
return void 0;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
var isDevEnv = () => getNodeEnv() !== "production";
|
|
12
|
-
var getDefaultStateTxnInstrumentation = () => isDevEnv() ? "full" : "light";
|
|
13
|
-
var StateTransactionConfigTagImpl = class extends Context.Tag("@logixjs/core/StateTransactionRuntimeConfig")() {
|
|
14
|
-
};
|
|
15
|
-
var StateTransactionConfigTag = StateTransactionConfigTagImpl;
|
|
16
|
-
var ReadQueryStrictGateConfigTagImpl = class extends Context.Tag("@logixjs/core/ReadQueryStrictGateRuntimeConfig")() {
|
|
17
|
-
};
|
|
18
|
-
var ReadQueryStrictGateConfigTag = ReadQueryStrictGateConfigTagImpl;
|
|
19
|
-
var ReplayModeConfigTagImpl = class extends Context.Tag("@logixjs/core/ReplayModeConfig")() {
|
|
20
|
-
};
|
|
21
|
-
var ReplayModeConfigTag = ReplayModeConfigTagImpl;
|
|
22
|
-
var StateTransactionOverridesTagImpl = class extends Context.Tag("@logixjs/core/StateTransactionOverrides")() {
|
|
23
|
-
};
|
|
24
|
-
var StateTransactionOverridesTag = StateTransactionOverridesTagImpl;
|
|
25
|
-
var ConcurrencyPolicyTagImpl = class extends Context.Tag("@logixjs/core/ConcurrencyPolicy")() {
|
|
26
|
-
};
|
|
27
|
-
var ConcurrencyPolicyTag = ConcurrencyPolicyTagImpl;
|
|
28
|
-
var ConcurrencyPolicyOverridesTagImpl = class extends Context.Tag("@logixjs/core/ConcurrencyPolicyOverrides")() {
|
|
29
|
-
};
|
|
30
|
-
var ConcurrencyPolicyOverridesTag = ConcurrencyPolicyOverridesTagImpl;
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
getNodeEnv,
|
|
34
|
-
isDevEnv,
|
|
35
|
-
getDefaultStateTxnInstrumentation,
|
|
36
|
-
StateTransactionConfigTag,
|
|
37
|
-
ReadQueryStrictGateConfigTag,
|
|
38
|
-
ReplayModeConfigTag,
|
|
39
|
-
StateTransactionOverridesTag,
|
|
40
|
-
ConcurrencyPolicyTag,
|
|
41
|
-
ConcurrencyPolicyOverridesTag
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=chunk-3QMIVH35.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/core/env.ts"],"sourcesContent":["import { Context, Layer } from 'effect'\nimport type { TraitConvergeRequestedMode } from '../../state-trait/model.js'\nimport type { ReadQueryStrictGateConfig } from './ReadQuery.js'\n\n// Unified runtime env detection, avoiding bundlers inlining NODE_ENV at build time.\nexport const getNodeEnv = (): string | undefined => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const env = (globalThis as any)?.process?.env\n return typeof env?.NODE_ENV === 'string' ? env.NODE_ENV : undefined\n } catch {\n return undefined\n }\n}\n\nexport const isDevEnv = (): boolean => getNodeEnv() !== 'production'\n\nexport type StateTransactionInstrumentation = 'full' | 'light'\n\n/**\n * getDefaultStateTxnInstrumentation:\n * - Currently chooses default instrumentation by NODE_ENV:\n * - dev / test: full (keep patches and snapshots for debugging).\n * - production: light (keep minimal semantics to reduce overhead).\n * - May evolve with finer-grained overrides in Runtime.make / Module.make.\n */\nexport const getDefaultStateTxnInstrumentation = (): StateTransactionInstrumentation => (isDevEnv() ? 'full' : 'light')\n\n/**\n * Runtime-level StateTransaction config Service:\n * - Provided at the app layer by Logix.Runtime.make / AppRuntime.makeApp.\n * - ModuleRuntime.make can read runtime-level defaults from Env.\n *\n * Notes:\n * - instrumentation is only a runtime-level default.\n * - Explicit instrumentation in ModuleImpl / ModuleRuntimeOptions has higher priority.\n */\nexport interface StateTransactionRuntimeConfig {\n readonly instrumentation?: StateTransactionInstrumentation\n /**\n * StateTrait derived converge budget (ms):\n * - Exceeding the budget triggers a soft degrade (freeze derived fields, preserve base writes and 0/1 commit semantics).\n * - Default is 200ms (aligned with the 007 spec threshold).\n */\n readonly traitConvergeBudgetMs?: number\n /**\n * Auto-mode decision budget (ms):\n * - Only used during the decision phase when requestedMode=\"auto\".\n * - Exceeding the budget must immediately fall back to full (and record evidence).\n */\n readonly traitConvergeDecisionBudgetMs?: number\n /**\n * StateTrait converge scheduling strategy:\n * - full: full topo execution (current default; safest).\n * - dirty: minimal triggering based on dirtyPaths + deps in the txn window (requires accurate deps).\n */\n readonly traitConvergeMode?: TraitConvergeRequestedMode\n /**\n * 043: Trait converge time-slicing (explicit opt-in). Disabled by default.\n */\n readonly traitConvergeTimeSlicing?: TraitConvergeTimeSlicingPatch\n /**\n * 060: Txn Lanes (priority scheduling for transaction follow-up work). Enabled by default since 062.\n */\n readonly txnLanes?: TxnLanesPatch\n /**\n * Runtime-level per-module overrides (hotfix path):\n * - Only affects converge behavior for the specified moduleId.\n * - Lower priority than Provider overrides.\n */\n readonly traitConvergeOverridesByModuleId?: Readonly<Record<string, StateTransactionTraitConvergeOverrides>>\n /**\n * 060: Txn Lanes runtime_module overrides (hotfix / gradual tuning).\n * - Only affects the specified moduleId.\n * - Lower priority than Provider overrides.\n */\n readonly txnLanesOverridesByModuleId?: Readonly<Record<string, TxnLanesPatch>>\n}\n\nclass StateTransactionConfigTagImpl extends Context.Tag('@logixjs/core/StateTransactionRuntimeConfig')<\n StateTransactionConfigTagImpl,\n StateTransactionRuntimeConfig\n>() {}\n\nexport const StateTransactionConfigTag = StateTransactionConfigTagImpl\n\nexport type ReadQueryStrictGateRuntimeConfig = ReadQueryStrictGateConfig\n\nclass ReadQueryStrictGateConfigTagImpl extends Context.Tag('@logixjs/core/ReadQueryStrictGateRuntimeConfig')<\n ReadQueryStrictGateConfigTagImpl,\n ReadQueryStrictGateRuntimeConfig\n>() {}\n\nexport const ReadQueryStrictGateConfigTag = ReadQueryStrictGateConfigTagImpl\n\nexport type ReplayMode = 'live' | 'replay'\n\nexport interface ReplayModeConfig {\n readonly mode: ReplayMode\n}\n\nclass ReplayModeConfigTagImpl extends Context.Tag('@logixjs/core/ReplayModeConfig')<\n ReplayModeConfigTagImpl,\n ReplayModeConfig\n>() {}\n\nexport const ReplayModeConfigTag = ReplayModeConfigTagImpl\n\nexport const replayModeLayer = (mode: ReplayMode): Layer.Layer<ReplayModeConfigTagImpl, never, never> =>\n Layer.succeed(ReplayModeConfigTag, { mode })\n\nexport interface StateTransactionTraitConvergeOverrides {\n readonly traitConvergeMode?: TraitConvergeRequestedMode\n readonly traitConvergeBudgetMs?: number\n readonly traitConvergeDecisionBudgetMs?: number\n readonly traitConvergeTimeSlicing?: TraitConvergeTimeSlicingPatch\n}\n\nexport interface TxnLanesPatch {\n /**\n * enabled: whether Txn Lanes is enabled (default on since 062).\n * - undefined: default enabled (when not explicitly configured)\n * - false: disabled (returns to baseline behavior)\n * - true: enabled (only affects scheduling of follow-up work outside the transaction; transactions remain synchronous)\n */\n readonly enabled?: boolean\n /**\n * overrideMode: runtime temporary override (for debugging/rollback/comparison).\n * - forced_off: forcibly disables Txn Lanes (returns to baseline behavior).\n * - forced_sync: forces fully synchronous execution (ignores non-urgent deferral and time-slicing; used for comparisons).\n *\n * Notes:\n * - Override precedence follows StateTransactionOverrides: provider > runtime_module > runtime_default > builtin.\n * - Overrides must be explainable by evidence (see 060 LaneEvidence reasons).\n */\n readonly overrideMode?: 'forced_off' | 'forced_sync'\n /** non-urgent work loop slice budget (ms). */\n readonly budgetMs?: number\n /** Non-urgent backlog coalescing window (ms). */\n readonly debounceMs?: number\n /** Max lag upper bound (ms): exceeding it triggers an explainable starvation protection (forced catch-up). */\n readonly maxLagMs?: number\n /** Whether to allow coalescing/canceling intermediate non-urgent work (must preserve eventual consistency). */\n readonly allowCoalesce?: boolean\n /**\n * Yield strategy for the non-urgent work loop (progressive enhancement).\n * - baseline: uses only time budget + hard upper bound\n * - inputPending: when supported by browsers, also consults `navigator.scheduling.isInputPending`\n */\n readonly yieldStrategy?: 'baseline' | 'inputPending'\n}\n\nexport interface TraitConvergeTimeSlicingPatch {\n /**\n * enabled:\n * - false/undefined: disabled (default)\n * - true: enables time-slicing (only affects computed/link explicitly marked as deferred)\n */\n readonly enabled?: boolean\n /**\n * debounceMs: coalescing interval (ms) for the deferral window; merges high-frequency inputs into one deferred flush.\n */\n readonly debounceMs?: number\n /**\n * maxLagMs: max lag upper bound (ms); exceeding it triggers an explainable forced flush (starvation protection).\n */\n readonly maxLagMs?: number\n}\n\n/**\n * Provider-scoped StateTransactionOverrides (delta overrides):\n * - Used to inject more local overrides into a Provider subtree on top of inherited global runtime config.\n * - Override precedence: provider > runtime_module > runtime_default > builtin.\n */\nexport interface StateTransactionOverrides {\n readonly traitConvergeMode?: TraitConvergeRequestedMode\n readonly traitConvergeBudgetMs?: number\n readonly traitConvergeDecisionBudgetMs?: number\n readonly traitConvergeTimeSlicing?: TraitConvergeTimeSlicingPatch\n readonly traitConvergeOverridesByModuleId?: Readonly<Record<string, StateTransactionTraitConvergeOverrides>>\n /** 060: Txn Lanes provider-level overrides (delta overrides). */\n readonly txnLanes?: TxnLanesPatch\n /** 060: Txn Lanes provider_module overrides (by moduleId). */\n readonly txnLanesOverridesByModuleId?: Readonly<Record<string, TxnLanesPatch>>\n}\n\nclass StateTransactionOverridesTagImpl extends Context.Tag('@logixjs/core/StateTransactionOverrides')<\n StateTransactionOverridesTagImpl,\n StateTransactionOverrides\n>() {}\n\nexport const StateTransactionOverridesTag = StateTransactionOverridesTagImpl\n\nexport type ConcurrencyLimit = number | 'unbounded'\n\nexport interface ConcurrencyPolicyPatch {\n readonly concurrencyLimit?: ConcurrencyLimit\n readonly losslessBackpressureCapacity?: number\n readonly allowUnbounded?: boolean\n readonly pressureWarningThreshold?: {\n readonly backlogCount?: number\n readonly backlogDurationMs?: number\n }\n readonly warningCooldownMs?: number\n}\n\n/**\n * Runtime-level ConcurrencyPolicy:\n * - Provided at the app layer by Logix.Runtime.make / AppRuntime.makeApp.\n * - ModuleRuntime merges sources via a resolver (builtin/runtime_module/provider, etc.).\n *\n * Notes:\n * - overridesByModuleId is used for runtime_module hot-switching (hotfix / gradual tuning) and is lower priority than provider overrides.\n */\nexport interface ConcurrencyPolicy extends ConcurrencyPolicyPatch {\n readonly overridesByModuleId?: Readonly<Record<string, ConcurrencyPolicyPatch>>\n}\n\nclass ConcurrencyPolicyTagImpl extends Context.Tag('@logixjs/core/ConcurrencyPolicy')<\n ConcurrencyPolicyTagImpl,\n ConcurrencyPolicy\n>() {}\n\nexport const ConcurrencyPolicyTag = ConcurrencyPolicyTagImpl\n\n/**\n * Provider-scoped ConcurrencyPolicyOverrides (delta overrides):\n * - Used to inject more local overrides into a Provider subtree on top of inherited global runtime config.\n * - Override precedence: provider > runtime_module > runtime_default > builtin.\n */\nexport interface ConcurrencyPolicyOverrides extends ConcurrencyPolicyPatch {\n readonly overridesByModuleId?: Readonly<Record<string, ConcurrencyPolicyPatch>>\n}\n\nclass ConcurrencyPolicyOverridesTagImpl extends Context.Tag('@logixjs/core/ConcurrencyPolicyOverrides')<\n ConcurrencyPolicyOverridesTagImpl,\n ConcurrencyPolicyOverrides\n>() {}\n\nexport const ConcurrencyPolicyOverridesTag = ConcurrencyPolicyOverridesTagImpl\n"],"mappings":";AAAA,SAAS,SAAS,aAAa;AAKxB,IAAM,aAAa,MAA0B;AAClD,MAAI;AAEF,UAAM,MAAO,YAAoB,SAAS;AAC1C,WAAO,OAAO,KAAK,aAAa,WAAW,IAAI,WAAW;AAAA,EAC5D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,IAAM,WAAW,MAAe,WAAW,MAAM;AAWjD,IAAM,oCAAoC,MAAwC,SAAS,IAAI,SAAS;AAqD/G,IAAM,gCAAN,cAA4C,QAAQ,IAAI,6CAA6C,EAGnG,EAAE;AAAC;AAEE,IAAM,4BAA4B;AAIzC,IAAM,mCAAN,cAA+C,QAAQ,IAAI,gDAAgD,EAGzG,EAAE;AAAC;AAEE,IAAM,+BAA+B;AAQ5C,IAAM,0BAAN,cAAsC,QAAQ,IAAI,gCAAgC,EAGhF,EAAE;AAAC;AAEE,IAAM,sBAAsB;AAgFnC,IAAM,mCAAN,cAA+C,QAAQ,IAAI,yCAAyC,EAGlG,EAAE;AAAC;AAEE,IAAM,+BAA+B;AA2B5C,IAAM,2BAAN,cAAuC,QAAQ,IAAI,iCAAiC,EAGlF,EAAE;AAAC;AAEE,IAAM,uBAAuB;AAWpC,IAAM,oCAAN,cAAgD,QAAQ,IAAI,0CAA0C,EAGpG,EAAE;AAAC;AAEE,IAAM,gCAAgC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ModuleTag.ts","../src/internal/runtime/core/ModuleTraits.ts"],"sourcesContent":["import { Effect, FiberRef, Layer, Schema } from 'effect'\nimport * as Logic from './Logic.js'\nimport * as Action from './internal/action.js'\nimport * as ModuleFactory from './internal/runtime/ModuleFactory.js'\nimport type { FieldPath } from './internal/field-path.js'\nimport { mutateWithoutPatches, mutateWithPatchPaths } from './internal/runtime/core/mutativePatches.js'\nimport { getBoundInternals, setModuleTraitsProgram } from './internal/runtime/core/runtimeInternalsAccessor.js'\nimport * as Debug from './internal/runtime/core/DebugSink.js'\nimport * as LogicUnitMeta from './internal/runtime/core/LogicUnitMeta.js'\nimport type {\n ActionsFromMap,\n AnyModuleShape,\n AnySchema,\n BoundApi,\n ActionOf,\n ModuleImpl,\n ModuleLogic,\n ModuleShape,\n ModuleRuntime,\n ModuleTag,\n ModuleHandle,\n ModuleHandleUnion,\n StateChangeWithMeta,\n StateCommitMeta,\n StateCommitMode,\n StateCommitPriority,\n ReducersFromMap,\n StateOf,\n} from './internal/module.js'\nimport * as StateTrait from './StateTrait.js'\nimport type { StateTraitProgram } from './StateTrait.js'\nimport * as ModuleTraitsRegistry from './internal/debug/ModuleTraitsRegistry.js'\nimport * as ModuleTraits from './internal/runtime/core/ModuleTraits.js'\n\ntype NoInfer_<T> = [T][T extends any ? 0 : never]\n\n/**\n * Public exports for core type definitions such as ModuleTag / ModuleRuntime / ModuleImpl.\n *\n * Kept aligned with `.codex/skills/project-guide/references/runtime-logix/logix-core/api/02-module-and-logic-api.md`.\n * Concrete type definitions live in internal/module.ts; this module wires the factory implementation.\n */\nexport type {\n AnySchema,\n AnyModuleShape,\n ModuleShape,\n ModuleLogic,\n ModuleImpl,\n ModuleRuntime,\n ModuleTag,\n ModuleHandle,\n ModuleHandleUnion,\n StateOf,\n ActionsFromMap,\n ReducersFromMap,\n BoundApi,\n ActionOf,\n StateCommitMode,\n StateCommitPriority,\n StateCommitMeta,\n StateChangeWithMeta,\n} from './internal/module.js'\n\n/**\n * Reducer helper:\n * - `Reducer.mutate` provides the same mutative style as `$.state.mutate`.\n * - Internally uses mutative-based immutable updates to map \"in-place draft mutation\" into a pure `(state, action) => state`.\n *\n * @example\n *\n * const Counter = Logix.ModuleTag.make(\"Counter\", {\n * state: CounterState,\n * actions: CounterActions,\n * reducers: {\n * inc: Logix.ModuleTag.Reducer.mutate((draft, _payload) => {\n * draft.count += 1\n * }),\n * },\n * })\n *\n * yield* $.reducer(\n * \"setValue\",\n * Logix.ModuleTag.Reducer.mutate((draft, payload) => {\n * draft.value = payload\n * }),\n * )\n */\nexport const Reducer = {\n mutate:\n <S, A extends { readonly payload?: any }>(\n mutator: (draft: Logic.Draft<S>, payload: A['payload']) => void,\n ): ((state: S, action: A, sink?: (path: string | FieldPath) => void) => S) =>\n (state, action, sink) => {\n const payload = (action as any)?.payload as A['payload']\n if (!sink) {\n return mutateWithoutPatches(state as S, (draft) => {\n mutator(draft as Logic.Draft<S>, payload)\n })\n }\n\n const { nextState, patchPaths } = mutateWithPatchPaths(state as S, (draft) => {\n mutator(draft as Logic.Draft<S>, payload)\n })\n\n for (const path of patchPaths) {\n sink(path)\n }\n\n return nextState\n },\n\n mutateMap: <\n R extends Readonly<\n Record<string, ((state: any, action: any, sink?: (path: string | FieldPath) => void) => any) | undefined>\n >,\n >(mutators: {\n readonly [K in keyof NoInfer_<R>]?: (\n draft: Logic.Draft<Parameters<NonNullable<NoInfer_<R>[K]>>[0]>,\n payload: Parameters<NonNullable<NoInfer_<R>[K]>>[1] extends { readonly payload: infer P }\n ? P\n : Parameters<NonNullable<NoInfer_<R>[K]>>[1] extends { readonly payload?: infer P }\n ? P | undefined\n : never,\n ) => void\n }): R => {\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(mutators)) {\n const mutator = (mutators as any)[key]\n if (typeof mutator !== 'function') continue\n out[key] = Reducer.mutate(mutator as any)\n }\n return out as any\n },\n}\n\n/**\n * A simplified Shape definition helper, designed for Action Maps.\n * @example type MyShape = Shape<typeof MyState, typeof MyActionMap>\n */\nexport type Shape<S extends AnySchema, M extends Record<string, AnySchema>> = ModuleShape<\n S,\n Schema.Schema<ActionsFromMap<Action.NormalizedActionTokens<M & Action.ActionDefs>>>,\n Action.NormalizedActionTokens<M & Action.ActionDefs>\n>\n\nconst makeImpl = <Id extends string, SSchema extends AnySchema, AMap extends Record<string, Action.AnyActionToken>>(\n id: Id,\n def: {\n readonly state: SSchema\n readonly actions: AMap\n readonly reducers?: ReducersFromMap<SSchema, AMap>\n },\n): ModuleTag<Id, ModuleShape<SSchema, Schema.Schema<ActionsFromMap<AMap>>, AMap>> =>\n ModuleFactory.Module(id, def) as ModuleTag<Id, ModuleShape<SSchema, Schema.Schema<ActionsFromMap<AMap>>, AMap>>\n\n/**\n * ModuleTag.make:\n * - Defines a domain module Tag using the given id and state/actions/reducers.\n * - The returned ModuleTag is both a Context.Tag and a factory carrying its Shape.\n *\n * Note: since 022, the old `Module` (Tag identity) was renamed to `ModuleTag`; use `Logix.Module` for module definition objects.\n */\nexport const make = <Id extends string, SSchema extends AnySchema, ADefs extends Action.ActionDefs>(\n id: Id,\n def: {\n readonly state: SSchema\n readonly actions: ADefs\n readonly reducers?: ReducersFromMap<SSchema, ADefs>\n /**\n * traits:\n * - Used to attach a StateTraitSpec (see specs/000-module-traits-runtime).\n * - The current implementation builds a Program during ModuleTag.make, and injects a setup-only Logic in `ModuleTag.implement`\n * to call `StateTrait.install`.\n * (Note: if you use `ModuleTag.live` to export a Layer and want trait behavior, call `StateTrait.install` explicitly in logics,\n * or use `ModuleTag.implement` instead.)\n */\n readonly traits?: unknown\n },\n): ModuleTag<\n Id,\n ModuleShape<\n SSchema,\n Schema.Schema<ActionsFromMap<Action.NormalizedActionTokens<ADefs>>>,\n Action.NormalizedActionTokens<ADefs>\n >\n> => {\n const actions = Action.normalizeActions(def.actions)\n const moduleTag = makeImpl(id, {\n state: def.state,\n actions,\n reducers: def.reducers as any,\n })\n\n type Sh = ModuleShape<\n SSchema,\n Schema.Schema<ActionsFromMap<Action.NormalizedActionTokens<ADefs>>>,\n Action.NormalizedActionTokens<ADefs>\n >\n\n const stateSchema = def.state as Schema.Schema<any, any>\n const moduleTraitsSpec = def.traits as StateTrait.StateTraitSpec<any> | undefined\n const baseProgram: StateTraitProgram<any> | undefined = moduleTraitsSpec\n ? StateTrait.build(stateSchema as any, moduleTraitsSpec as any)\n : undefined\n\n if (baseProgram) {\n // For TraitLifecycle/Debug/Devtools reads (definition-side hidden slot).\n setModuleTraitsProgram(moduleTag as any, baseProgram)\n ModuleTraitsRegistry.registerModuleProgram(id, baseProgram as StateTraitProgram<any>)\n }\n\n // 023: consolidate the trait \"declaration/merge entry points\" into the setup phase:\n // - module-level traits register as contributions first;\n // - logic-level declares via $.traits.declare;\n // - finally, finalize → freeze → build/install in one shot.\n\n const makeModuleTraitsContributionLogic = (traits: unknown): ModuleLogic<Sh, never, never> => {\n const logic = moduleTag.logic(($) => ({\n setup: Effect.sync(() => {\n if (!traits || typeof traits !== 'object') return\n // module-level provenance uses moduleId as the stable anchor\n // (aligned with 023 data-model: originType=module, originId=moduleId).\n // Note: traitsSpec still reuses StateTraitSpec; do not introduce a second IR.\n const internals = getBoundInternals($ as any)\n internals.traits.registerModuleTraitsContribution({\n traits,\n provenance: {\n originType: 'module',\n originId: id,\n originIdKind: 'explicit',\n originLabel: `module:${id}`,\n },\n })\n }),\n run: Effect.void,\n })) as ModuleLogic<Sh, never, never>\n\n LogicUnitMeta.attachLogicUnitMeta(logic as any, {\n id: '__logix_internal:traits:module_contrib',\n kind: 'internal',\n name: 'traits:module_contrib',\n moduleId: id,\n })\n return logic\n }\n\n const makeFinalizeTraitsLogic = (): ModuleLogic<Sh, never, never> => {\n const logic = moduleTag.logic(($) => ({\n setup: Effect.gen(function* () {\n const internals = getBoundInternals($ as any)\n const diagnosticsLevel = yield* FiberRef.get(Debug.currentDiagnosticsLevel)\n\n const contributions = internals.traits.getModuleTraitsContributions()\n let merged: ModuleTraits.TraitSpec\n let snapshot: ModuleTraits.ModuleTraitsSnapshot\n\n try {\n ;({ merged, snapshot } = ModuleTraits.finalizeTraitContributions({\n moduleId: id,\n contributions,\n }))\n } catch (cause) {\n if (\n diagnosticsLevel !== 'off' &&\n cause &&\n typeof cause === 'object' &&\n (cause as any)._tag === 'ModuleTraitsConflictError'\n ) {\n const conflicts = Array.isArray((cause as any).conflicts)\n ? ((cause as any).conflicts as ReadonlyArray<unknown>)\n : []\n const traitIds = conflicts\n .map((c: any) => (c && typeof c === 'object' ? (c as any).traitId : undefined))\n .filter((t): t is string => typeof t === 'string' && t.length > 0)\n .slice(0, 20)\n\n const data =\n diagnosticsLevel === 'full'\n ? {\n conflictCount: conflicts.length,\n conflicts,\n }\n : {\n conflictCount: conflicts.length,\n traitIds,\n }\n\n yield* Debug.record({\n type: 'trace:module:traits:conflict',\n moduleId: id,\n instanceId: internals.instanceId,\n data,\n } as any)\n }\n\n throw cause\n }\n\n internals.traits.setModuleTraitsSnapshot(snapshot)\n internals.traits.freezeModuleTraits()\n\n if (diagnosticsLevel !== 'off') {\n const data =\n diagnosticsLevel === 'full'\n ? {\n digest: snapshot.digest,\n count: snapshot.traits.length,\n traits: snapshot.traits,\n provenanceIndex: snapshot.provenanceIndex,\n }\n : {\n digest: snapshot.digest,\n count: snapshot.traits.length,\n }\n\n yield* Debug.record({\n type: 'trace:module:traits',\n moduleId: id,\n instanceId: internals.instanceId,\n data,\n } as any)\n }\n\n if (Object.keys(merged).length === 0) {\n return\n }\n\n const onlyModuleLevel = contributions.length === 1 && contributions[0]?.provenance?.originType === 'module'\n\n // Build a one-shot Program from the final merged Spec, and install it during initialization.\n // - If there is only a module-level contribution, reuse the program built in ModuleTag.make (useful for Debug/TraitLifecycle).\n const program =\n onlyModuleLevel && baseProgram ? baseProgram : StateTrait.build(stateSchema as any, merged as any)\n\n // For TraitLifecycle/Debug/Devtools reads (definition-side hidden slot).\n setModuleTraitsProgram(moduleTag as any, program)\n ModuleTraitsRegistry.registerModuleProgram(id, program as StateTraitProgram<any>)\n\n yield* StateTrait.install($ as unknown as BoundApi<any, any>, program)\n }),\n run: Effect.void,\n })) as ModuleLogic<Sh, never, never>\n\n LogicUnitMeta.attachLogicUnitMeta(logic as any, {\n id: '__logix_internal:traits:finalize',\n kind: 'internal',\n name: 'traits:finalize',\n moduleId: id,\n })\n\n return logic\n }\n\n // Wrap implement: inject (1) optional module-level contribution logic, and (2) required finalize+install logic.\n const originalImplement = moduleTag.implement\n ;(moduleTag as any).implement = (<R = never>(config: {\n initial: StateOf<typeof moduleTag.shape>\n logics?: Array<ModuleLogic<typeof moduleTag.shape, R, any>>\n imports?: ReadonlyArray<Layer.Layer<any, any, any> | ModuleImpl<any, AnyModuleShape, any>>\n processes?: ReadonlyArray<Effect.Effect<void, any, any>>\n }) => {\n const userLogics = (config.logics ?? []) as Array<ModuleLogic<typeof moduleTag.shape, R, any>>\n\n const moduleLevel = def.traits ? [makeModuleTraitsContributionLogic(def.traits) as any] : []\n\n const finalize = makeFinalizeTraitsLogic() as ModuleLogic<typeof moduleTag.shape, R, any>\n\n const mergedLogics = [...moduleLevel, ...userLogics, finalize]\n\n return originalImplement<R>({\n ...config,\n logics: mergedLogics,\n })\n }) as typeof moduleTag.implement\n\n return moduleTag\n}\n","import { fnv1a32, stableStringify } from '../../digest.js'\n\nexport type TraitId = string\n\nexport type TraitOriginType = 'module' | 'logicUnit'\nexport type TraitOriginIdKind = 'explicit' | 'derived'\n\nexport interface TraitProvenance {\n readonly originType: TraitOriginType\n readonly originId: string\n readonly originIdKind: TraitOriginIdKind\n /**\n * Human-readable label for Devtools/error messages (e.g. \"logicUnit:Profile#1\").\n */\n readonly originLabel: string\n /**\n * Optional location summary (e.g. file path / callsite); for navigation only and not used for semantic decisions.\n */\n readonly path?: string\n}\n\n/**\n * TraitSpec:\n * - Minimal representation of \"trait declarations\": a record keyed by traitId.\n * - The concrete value shape is defined by the specific trait system (e.g. StateTraitSpec).\n * - Value serializability is not constrained here (runtime install may depend on functions), but snapshots/evidence exports\n * must only include serializable subsets.\n */\nexport type TraitSpec = object\n\nexport interface TraitContribution {\n readonly traits: TraitSpec\n readonly provenance: TraitProvenance\n}\n\nexport interface ModuleTraitItem {\n readonly traitId: TraitId\n readonly name: string\n readonly description?: string\n}\n\nexport type TraitConflictKind = 'duplicate_traitId' | 'missing_requires' | 'excludes_violation'\n\nexport interface TraitConflict {\n readonly kind: TraitConflictKind\n readonly traitId: TraitId\n readonly sources: ReadonlyArray<TraitProvenance>\n readonly missing?: ReadonlyArray<TraitId>\n readonly present?: ReadonlyArray<TraitId>\n}\n\nexport class ModuleTraitsConflictError extends Error {\n readonly _tag = 'ModuleTraitsConflictError'\n\n constructor(\n readonly moduleId: string,\n readonly conflicts: ReadonlyArray<TraitConflict>,\n ) {\n super(\n [\n `[ModuleTraitsConflictError] Conflicting traitIds found (moduleId=${moduleId}).`,\n ...conflicts.map((c) =>\n c.kind === 'duplicate_traitId'\n ? `- duplicate ${c.traitId}: ${c.sources.map((s) => `${s.originType}:${s.originId}`).join(', ')}`\n : c.kind === 'missing_requires'\n ? `- missing requires for ${c.traitId}: ${(c.missing ?? []).join(', ')}; sources=${c.sources\n .map((s) => `${s.originType}:${s.originId}`)\n .join(', ')}`\n : `- excludes violation for ${c.traitId}: present=${(c.present ?? []).join(', ')}; sources=${c.sources\n .map((s) => `${s.originType}:${s.originId}`)\n .join(', ')}`,\n ),\n ].join('\\n'),\n )\n }\n}\n\nexport interface ModuleTraitsSnapshot {\n readonly moduleId: string\n readonly digest: string\n readonly traits: ReadonlyArray<ModuleTraitItem>\n readonly provenanceIndex: Record<TraitId, TraitProvenance>\n}\n\nconst toProvenanceKey = (p: TraitProvenance): string =>\n `${p.originType}:${p.originId}:${p.originIdKind}:${p.originLabel}:${p.path ?? ''}`\n\nconst compareProvenance = (a: TraitProvenance, b: TraitProvenance): number => {\n const type = a.originType.localeCompare(b.originType)\n if (type !== 0) return type\n const id = a.originId.localeCompare(b.originId)\n if (id !== 0) return id\n const kind = a.originIdKind.localeCompare(b.originIdKind)\n if (kind !== 0) return kind\n const label = a.originLabel.localeCompare(b.originLabel)\n if (label !== 0) return label\n return String(a.path ?? '').localeCompare(String(b.path ?? ''))\n}\n\nconst originTypeOrder = (t: TraitOriginType): number => (t === 'module' ? 0 : 1)\n\nconst compareTraitIdByProvenance = (\n a: { readonly traitId: TraitId; readonly provenance: TraitProvenance },\n b: { readonly traitId: TraitId; readonly provenance: TraitProvenance },\n): number => {\n const ta = originTypeOrder(a.provenance.originType) - originTypeOrder(b.provenance.originType)\n if (ta !== 0) return ta\n const oa = a.provenance.originId.localeCompare(b.provenance.originId)\n if (oa !== 0) return oa\n return a.traitId.localeCompare(b.traitId)\n}\n\nconst extractStringArray = (value: unknown): ReadonlyArray<string> => {\n if (!Array.isArray(value)) return []\n const out: Array<string> = []\n for (const v of value) {\n if (typeof v !== 'string') continue\n const s = v.trim()\n if (!s) continue\n out.push(s)\n }\n return out\n}\n\nconst getTraitRequires = (value: unknown): ReadonlyArray<TraitId> => {\n if (!value || typeof value !== 'object') return []\n const direct = extractStringArray((value as any).requires)\n return direct\n}\n\nconst getTraitExcludes = (value: unknown): ReadonlyArray<TraitId> => {\n if (!value || typeof value !== 'object') return []\n const direct = extractStringArray((value as any).excludes)\n return direct\n}\n\nconst getTraitName = (traitId: TraitId, value: unknown): string => {\n if (value && typeof value === 'object') {\n const n = (value as any).name\n if (typeof n === 'string' && n.trim().length > 0) return n.trim()\n }\n return traitId\n}\n\nconst getTraitDescription = (value: unknown): string | undefined => {\n if (value && typeof value === 'object') {\n const d = (value as any).description\n if (typeof d === 'string' && d.trim().length > 0) return d.trim()\n }\n return undefined\n}\n\nexport const finalizeTraitContributions = (args: {\n readonly moduleId: string\n readonly contributions: ReadonlyArray<TraitContribution>\n}): { readonly merged: TraitSpec; readonly snapshot: ModuleTraitsSnapshot } => {\n const traitById = new Map<TraitId, { readonly value: unknown; readonly provenance: TraitProvenance }>()\n\n const duplicateSources = new Map<TraitId, Array<TraitProvenance>>()\n\n const contributions = [...args.contributions].sort((a, b) => compareProvenance(a.provenance, b.provenance))\n\n for (const c of contributions) {\n const traits = c.traits\n if (!traits || typeof traits !== 'object') continue\n for (const traitId of Object.keys(traits).sort((a, b) => a.localeCompare(b))) {\n const value = (traits as Record<string, unknown>)[traitId]\n if (value === undefined) continue\n\n const prev = traitById.get(traitId)\n if (!prev) {\n traitById.set(traitId, { value, provenance: c.provenance })\n continue\n }\n\n const sources = duplicateSources.get(traitId) ?? [prev.provenance]\n sources.push(c.provenance)\n duplicateSources.set(traitId, sources)\n }\n }\n\n const conflicts: Array<TraitConflict> = []\n const registerConflict = (conflict: TraitConflict) => {\n const unique = new Map<string, TraitProvenance>()\n for (const s of conflict.sources) {\n unique.set(toProvenanceKey(s), s)\n }\n conflicts.push({\n ...conflict,\n sources: Array.from(unique.values()).sort(compareProvenance),\n })\n }\n\n // 1) duplicate traitId conflicts\n for (const traitId of Array.from(duplicateSources.keys()).sort((a, b) => a.localeCompare(b))) {\n registerConflict({\n kind: 'duplicate_traitId',\n traitId,\n sources: duplicateSources.get(traitId) ?? [],\n })\n }\n\n const merged: Record<string, unknown> = {}\n const provenanceIndex: Record<string, TraitProvenance> = {}\n const traits: Array<ModuleTraitItem> = []\n\n const entries: Array<{ readonly traitId: TraitId; readonly value: unknown; readonly provenance: TraitProvenance }> =\n []\n for (const traitId of traitById.keys()) {\n const entry = traitById.get(traitId)\n if (!entry) continue\n entries.push({ traitId, value: entry.value, provenance: entry.provenance })\n }\n\n const ids = entries\n .slice()\n .sort(compareTraitIdByProvenance)\n .map((e) => e.traitId)\n\n for (const traitId of ids) {\n const entry = traitById.get(traitId)\n if (!entry) continue\n merged[traitId] = entry.value\n provenanceIndex[traitId] = entry.provenance\n traits.push({\n traitId,\n name: getTraitName(traitId, entry.value),\n description: getTraitDescription(entry.value),\n })\n }\n\n // 2) consistency checks (FR-007): requires / excludes\n const present = new Set(ids)\n\n for (const traitId of ids) {\n const entry = traitById.get(traitId)\n if (!entry) continue\n\n const requires = getTraitRequires(entry.value)\n if (requires.length > 0) {\n const missing = requires.filter((r) => !present.has(r))\n if (missing.length > 0) {\n registerConflict({\n kind: 'missing_requires',\n traitId,\n missing: Array.from(new Set(missing)).sort((a, b) => a.localeCompare(b)),\n sources: [entry.provenance],\n })\n }\n }\n\n const excludes = getTraitExcludes(entry.value)\n if (excludes.length > 0) {\n const presentExcluded = excludes.filter((e) => present.has(e))\n if (presentExcluded.length > 0) {\n const otherSources: Array<TraitProvenance> = []\n for (const otherId of presentExcluded) {\n const other = traitById.get(otherId)\n if (other) otherSources.push(other.provenance)\n }\n registerConflict({\n kind: 'excludes_violation',\n traitId,\n present: Array.from(new Set(presentExcluded)).sort((a, b) => a.localeCompare(b)),\n sources: [entry.provenance, ...otherSources],\n })\n }\n }\n }\n\n if (conflicts.length > 0) {\n const kindOrder: Record<TraitConflictKind, number> = {\n duplicate_traitId: 0,\n missing_requires: 1,\n excludes_violation: 2,\n }\n conflicts.sort((a, b) => {\n const k = kindOrder[a.kind] - kindOrder[b.kind]\n if (k !== 0) return k\n return a.traitId.localeCompare(b.traitId)\n })\n throw new ModuleTraitsConflictError(args.moduleId, conflicts)\n }\n\n const digestBase = {\n moduleId: args.moduleId,\n traits,\n provenanceIndex,\n } as const\n\n const digest = `mtraits:023:${fnv1a32(stableStringify(digestBase))}`\n\n return {\n merged,\n snapshot: {\n moduleId: args.moduleId,\n digest,\n traits,\n provenanceIndex,\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,QAAQ,gBAA+B;;;ACmDzC,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAGnD,YACW,UACA,WACT;AACA;AAAA,MACE;AAAA,QACE,oEAAoE,QAAQ;AAA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Ac,IAAI,SAAS,CAAC,kCAAkC,IAAI,MAAM,CAAQ,IAAI,CAAC;AAE3F,UAAM,WAAW,wBAAwB;AAEzC,UAAM,eAAe,CAAC,GAAG,aAAa,GAAG,YAAY,QAAQ;AAE7D,WAAO,kBAAqB;AAAA,MAC1B,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":["traits"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/root.ts","../src/internal/runtime/core/RootContext.ts"],"sourcesContent":["import { Context, Deferred, Effect, Layer } from 'effect'\nimport { isDevEnv } from './runtime/core/env.js'\nimport { RootContextTag, type RootContext } from './runtime/core/RootContext.js'\n\nexport type RootResolveEntrypoint = 'logic.root.resolve' | 'logic.$.root.resolve'\n\nexport interface RootResolveOptions {\n readonly entrypoint?: RootResolveEntrypoint\n /**\n * Whether to wait when RootContext is not ready yet:\n * - Default false: avoid misuse during layer/setup which can deadlock.\n * - `$.root.resolve` passes true in the run phase (run-only), allowing Env assembly to complete.\n */\n readonly waitForReady?: boolean\n}\n\nconst tagIdOf = (tag: Context.Tag<any, any>): string =>\n typeof (tag as any)?.id === 'string'\n ? String((tag as any).id)\n : typeof (tag as any)?.key === 'string'\n ? String((tag as any).key)\n : '<unknown tag>'\n\nconst makeMissingRootProviderError = (\n tag: Context.Tag<any, any>,\n entrypoint: RootResolveEntrypoint,\n extra?: string,\n): Error => {\n const dev = isDevEnv()\n const tokenId = tagIdOf(tag)\n const fix: string[] = dev\n ? [\n '- Provide it when creating the runtime tree (Logix.Runtime.make(...,{ layer }) / ManagedRuntime.make(Layer.mergeAll(...))).',\n \"- If you're in React and want the current runtime environment singleton, use useModule(ModuleTag).\",\n '- Do not rely on nested RuntimeProvider.layer to mock Root.resolve.',\n ]\n : []\n\n const message = dev\n ? [\n '[MissingRootProviderError] Cannot resolve Tag from root provider.',\n extra ? `\\n${extra}` : '',\n `tokenId: ${tokenId}`,\n `entrypoint: ${entrypoint}`,\n 'mode: global',\n 'startScope: root',\n '',\n 'fix:',\n ...fix,\n ]\n .filter((s) => s.length > 0)\n .join('\\n')\n : '[MissingRootProviderError] tag not found in root provider'\n\n const err = new Error(message)\n err.name = 'MissingRootProviderError'\n ;(err as any).tokenId = tokenId\n ;(err as any).entrypoint = entrypoint\n ;(err as any).mode = 'global'\n ;(err as any).startScope = { kind: 'root' }\n ;(err as any).fix = fix\n return err\n}\n\n/**\n * resolve\n *\n * Resolve a Tag explicitly from the root provider of the current Runtime tree (ServiceTag / ModuleTag).\n *\n * Semantics:\n * - Always reads rootContext; unaffected by nearer-scope Layer/Context overrides.\n * - For ModuleTag: expresses root singleton semantics only (not used for multi-instance selection).\n */\nexport const resolve = <Id, Svc>(\n tag: Context.Tag<Id, Svc>,\n options?: RootResolveOptions,\n): Effect.Effect<Svc, never, any> =>\n Effect.gen(function* () {\n const entrypoint: RootResolveEntrypoint = options?.entrypoint ?? 'logic.root.resolve'\n\n const root = yield* RootContextTag\n\n const rootContext = root.context ?? (options?.waitForReady ? yield* root.ready : undefined)\n\n if (!rootContext) {\n return yield* Effect.die(\n makeMissingRootProviderError(tag as Context.Tag<any, any>, entrypoint, 'reason: rootContextNotReady'),\n )\n }\n\n try {\n return Context.get(rootContext, tag as Context.Tag<any, any>) as Svc\n } catch {\n return yield* Effect.die(makeMissingRootProviderError(tag as Context.Tag<any, any>, entrypoint))\n }\n })\n\n/**\n * layerFromContext(tests/perf only)\n *\n * Provide a \"ready immediately\" RootContext for Root.resolve.\n * - `ready` is fulfilled immediately to avoid extra waits when waitForReady=true.\n */\nexport const layerFromContext = (context: Context.Context<any>): Layer.Layer<any, never, any> =>\n Layer.scoped(\n RootContextTag,\n Effect.gen(function* () {\n const ready = yield* Deferred.make<Context.Context<any>>()\n yield* Deferred.succeed(ready, context)\n const root: RootContext = { context, ready }\n return root\n }),\n )\n","import { Context, Deferred } from 'effect'\n\nexport interface RootContext {\n context: Context.Context<any> | undefined\n readonly ready: Deferred.Deferred<Context.Context<any>, never>\n readonly appId?: string\n readonly appModuleIds?: ReadonlyArray<string>\n}\n\nclass RootContextTagImpl extends Context.Tag('@logixjs/core/RootContext')<RootContextTagImpl, RootContext>() {}\n\nexport const RootContextTag = RootContextTagImpl\n"],"mappings":";;;;;AAAA,SAAS,WAAAA,UAAS,YAAAC,WAAU,QAAQ,aAAa;;;ACAjD,SAAS,eAAyB;AASlC,IAAM,qBAAN,cAAiC,QAAQ,IAAI,2BAA2B,EAAmC,EAAE;AAAC;AAEvG,IAAM,iBAAiB;;;ADK9B,IAAM,UAAU,CAAC,QACf,OAAQ,KAAa,OAAO,WACxB,OAAQ,IAAY,EAAE,IACtB,OAAQ,KAAa,QAAQ,WAC3B,OAAQ,IAAY,GAAG,IACvB;AAER,IAAM,+BAA+B,CACnC,KACA,YACA,UACU;AACV,QAAM,MAAM,SAAS;AACrB,QAAM,UAAU,QAAQ,GAAG;AAC3B,QAAM,MAAgB,MAClB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF,IACA,CAAC;AAEL,QAAM,UAAU,MACZ;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,EAAK,KAAK,KAAK;AAAA,IACvB,YAAY,OAAO;AAAA,IACnB,eAAe,UAAU;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,EACG,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1B,KAAK,IAAI,IACZ;AAEJ,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,MAAI,OAAO;AACV,EAAC,IAAY,UAAU;AACvB,EAAC,IAAY,aAAa;AAC1B,EAAC,IAAY,OAAO;AACpB,EAAC,IAAY,aAAa,EAAE,MAAM,OAAO;AACzC,EAAC,IAAY,MAAM;AACpB,SAAO;AACT;AAWO,IAAM,UAAU,CACrB,KACA,YAEA,OAAO,IAAI,aAAa;AACtB,QAAM,aAAoC,SAAS,cAAc;AAEjE,QAAM,OAAO,OAAO;AAEpB,QAAM,cAAc,KAAK,YAAY,SAAS,eAAe,OAAO,KAAK,QAAQ;AAEjF,MAAI,CAAC,aAAa;AAChB,WAAO,OAAO,OAAO;AAAA,MACnB,6BAA6B,KAA8B,YAAY,6BAA6B;AAAA,IACtG;AAAA,EACF;AAEA,MAAI;AACF,WAAOC,SAAQ,IAAI,aAAa,GAA4B;AAAA,EAC9D,QAAQ;AACN,WAAO,OAAO,OAAO,IAAI,6BAA6B,KAA8B,UAAU,CAAC;AAAA,EACjG;AACF,CAAC;AAQI,IAAM,mBAAmB,CAAC,YAC/B,MAAM;AAAA,EACJ;AAAA,EACA,OAAO,IAAI,aAAa;AACtB,UAAM,QAAQ,OAAOC,UAAS,KAA2B;AACzD,WAAOA,UAAS,QAAQ,OAAO,OAAO;AACtC,UAAM,OAAoB,EAAE,SAAS,MAAM;AAC3C,WAAO;AAAA,EACT,CAAC;AACH;","names":["Context","Deferred","Context","Deferred"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/state-trait/rowid.ts","../src/internal/runtime/core/ReplayLog.ts"],"sourcesContent":["export type RowId = string\n\nexport interface ListConfig {\n readonly path: string\n readonly trackBy?: string\n}\n\nexport type ListRemovalListener = (rowId: RowId) => void\n\ntype Segment = string | number\n\nconst parseSegments = (path: string): ReadonlyArray<Segment> => {\n if (!path) return []\n return path.split('.').map((seg) => (/^[0-9]+$/.test(seg) ? Number(seg) : seg))\n}\n\nexport const getAtPath = (state: any, path: string): any => {\n if (!path || state == null) return state\n const segments = parseSegments(path)\n let current: any = state\n for (const seg of segments) {\n if (current == null) return undefined\n if (typeof seg === 'number') {\n current = Array.isArray(current) ? current[seg] : current[String(seg)]\n continue\n }\n current = current[seg]\n }\n return current\n}\n\nexport const setAtPathMutating = (draft: unknown, path: string, value: unknown): void => {\n if (!path) return\n const segments = parseSegments(path)\n if (segments.length === 0) return\n\n let current: any = draft\n for (let i = 0; i < segments.length - 1; i++) {\n const key = segments[i]!\n const nextKey = segments[i + 1]!\n\n const next = current?.[key as any]\n if (next == null || typeof next !== 'object') {\n current[key as any] = typeof nextKey === 'number' ? [] : {}\n }\n current = current[key as any]\n }\n\n const last = segments[segments.length - 1]!\n current[last as any] = value\n}\n\nexport const unsetAtPathMutating = (draft: unknown, path: string): void => {\n if (!path) return\n const segments = parseSegments(path)\n if (segments.length === 0) return\n\n let current: any = draft\n for (let i = 0; i < segments.length - 1; i++) {\n const key = segments[i]!\n const next = current?.[key as any]\n if (next == null || typeof next !== 'object') {\n return\n }\n current = next\n }\n\n const last = segments[segments.length - 1]!\n if (Array.isArray(current) && typeof last === 'number') {\n current[last] = undefined\n return\n }\n\n if (current && typeof current === 'object') {\n delete current[last as any]\n }\n}\n\nexport const joinPath = (prefix: string, suffix: string): string => {\n if (!prefix) return suffix\n if (!suffix) return prefix\n return `${prefix}.${suffix}`\n}\n\nexport interface ListItemFieldPath {\n readonly listPath: string\n readonly itemPath: string\n}\n\n/**\n * parseListItemFieldPath:\n * - Recognize a list.item field path like \"items[].profileResource\".\n * - Supports nested arrays: returns listPath/itemPath for the innermost list.\n */\nexport const parseListItemFieldPath = (fieldPath: string): ListItemFieldPath | undefined => {\n const raw = typeof fieldPath === 'string' ? fieldPath.trim() : ''\n if (!raw) return undefined\n\n const segments = raw.split('.').filter(Boolean)\n let lastListSeg = -1\n for (let i = 0; i < segments.length; i++) {\n if (segments[i]!.endsWith('[]')) lastListSeg = i\n }\n if (lastListSeg < 0) return undefined\n\n const strip = (seg: string): string => (seg.endsWith('[]') ? seg.slice(0, -2) : seg)\n\n const listPath = segments\n .slice(0, lastListSeg + 1)\n .map(strip)\n .join('.')\n\n const itemPath = segments\n .slice(lastListSeg + 1)\n .map(strip)\n .join('.')\n\n return { listPath, itemPath }\n}\n\nexport const toListItemValuePath = (listPath: string, index: number, itemPath: string): string =>\n itemPath ? `${listPath}.${index}.${itemPath}` : `${listPath}.${index}`\n\ntype ListState = {\n readonly listPath: string\n readonly parentRowId?: RowId\n readonly itemsRef: ReadonlyArray<unknown>\n readonly ids: ReadonlyArray<RowId>\n readonly indexById: ReadonlyMap<RowId, number>\n readonly trackBy?: string\n}\n\nconst readTrackBy = (item: unknown, trackBy: string): unknown => {\n if (!item || typeof item !== 'object') return undefined\n const segments = trackBy.split('.')\n let current: any = item\n for (const seg of segments) {\n if (current == null) return undefined\n current = current[seg as any]\n }\n return current\n}\n\nconst didReorderByReference = (prevItems: ReadonlyArray<unknown>, nextItems: ReadonlyArray<unknown>): boolean => {\n const buckets = new Map<unknown, Array<number>>()\n for (let i = 0; i < prevItems.length; i++) {\n const item = prevItems[i]\n const list = buckets.get(item) ?? []\n list.push(i)\n buckets.set(item, list)\n }\n\n for (let nextIndex = 0; nextIndex < nextItems.length; nextIndex++) {\n const item = nextItems[nextIndex]\n const q = buckets.get(item)\n if (!q || q.length === 0) continue\n const prevIndex = q.shift()!\n if (prevIndex !== nextIndex) {\n return true\n }\n }\n\n return false\n}\n\nconst hasStableTrackByKeys = (items: ReadonlyArray<unknown>, trackBy: string): boolean =>\n items.every((item) => readTrackBy(item, trackBy) !== undefined)\n\nconst isSameTrackBySequence = (\n prevItems: ReadonlyArray<unknown>,\n nextItems: ReadonlyArray<unknown>,\n trackBy: string,\n): boolean => {\n if (prevItems.length !== nextItems.length) return false\n for (let i = 0; i < prevItems.length; i++) {\n if (!Object.is(readTrackBy(prevItems[i], trackBy), readTrackBy(nextItems[i], trackBy))) {\n return false\n }\n }\n return true\n}\n\nconst reconcileIds = (\n prev: ListState | undefined,\n nextItems: ReadonlyArray<unknown>,\n trackBy?: string,\n makeRowId?: () => RowId,\n): { readonly ids: ReadonlyArray<RowId>; readonly removed: ReadonlyArray<RowId> } => {\n const nextRowId =\n makeRowId ??\n (() => {\n let rowSeq = 0\n return () => {\n rowSeq += 1\n return `r${rowSeq}`\n }\n })()\n\n if (!prev) {\n return {\n ids: nextItems.map(() => nextRowId()),\n removed: [],\n }\n }\n\n if (prev.itemsRef === nextItems) {\n return {\n ids: prev.ids,\n removed: [],\n }\n }\n\n // Important: keep RowId stable under \"non-structural changes\" (field updates / object clones only),\n // otherwise in-flight state and caches would be invalidated needlessly.\n const sameLength = prev.itemsRef.length === nextItems.length\n if (sameLength) {\n // trackBy case: if the key sequence is identical, we can reuse old ids;\n // otherwise we must reconcile by key (avoid misclassifying clone+reorder as \"no reorder\").\n if (trackBy) {\n const canUseKeys = hasStableTrackByKeys(prev.itemsRef, trackBy) && hasStableTrackByKeys(nextItems, trackBy)\n if (canUseKeys) {\n if (isSameTrackBySequence(prev.itemsRef, nextItems, trackBy)) {\n return {\n ids: prev.ids,\n removed: [],\n }\n }\n } else {\n // If trackBy keys are not available, fall back to reference-level detection (keep stability for \"cloned but not reordered\").\n if (!didReorderByReference(prev.itemsRef, nextItems)) {\n return {\n ids: prev.ids,\n removed: [],\n }\n }\n }\n } else if (!didReorderByReference(prev.itemsRef, nextItems)) {\n return {\n ids: prev.ids,\n removed: [],\n }\n }\n }\n\n const keyOf = (item: unknown): unknown => {\n if (!trackBy) return item\n const k = readTrackBy(item, trackBy)\n return k !== undefined ? k : item\n }\n\n const buckets = new Map<unknown, Array<RowId>>()\n for (let i = 0; i < prev.itemsRef.length; i++) {\n const key = keyOf(prev.itemsRef[i])\n const list = buckets.get(key) ?? []\n list.push(prev.ids[i]!)\n buckets.set(key, list)\n }\n\n const ids: Array<RowId> = []\n for (let i = 0; i < nextItems.length; i++) {\n const key = keyOf(nextItems[i])\n const list = buckets.get(key)\n if (list && list.length > 0) {\n ids.push(list.shift()!)\n } else {\n ids.push(nextRowId())\n }\n }\n\n const removed: Array<RowId> = []\n for (const list of buckets.values()) {\n removed.push(...list)\n }\n\n return { ids, removed }\n}\n\nconst buildIndexById = (ids: ReadonlyArray<RowId>): ReadonlyMap<RowId, number> => {\n const map = new Map<RowId, number>()\n for (let i = 0; i < ids.length; i++) {\n map.set(ids[i]!, i)\n }\n return map\n}\n\nexport class RowIdStore {\n private readonly lists = new Map<string, ListState>()\n private readonly removalListeners = new Map<string, Set<ListRemovalListener>>()\n private readonly rowIdIndex = new Map<\n RowId,\n { readonly key: string; readonly listPath: string; readonly index: number }\n >()\n private nextRowSeq = 0\n\n constructor(private readonly instanceId?: string) {}\n\n private listKey = (listPath: string, parentRowId?: RowId): string =>\n parentRowId ? `${listPath}@@${parentRowId}` : listPath\n\n private makeRowId = (): RowId => {\n this.nextRowSeq += 1\n return this.instanceId ? `${this.instanceId}::r${this.nextRowSeq}` : `r${this.nextRowSeq}`\n }\n\n private notifyRemoved(listPath: string, rowId: RowId): void {\n const listeners = this.removalListeners.get(listPath)\n if (!listeners || listeners.size === 0) return\n for (const fn of listeners) {\n try {\n fn(rowId)\n } catch {\n // listener failures should never break runtime behavior\n }\n }\n }\n\n private removeDescendants(parentRowId: RowId): void {\n const keys: Array<string> = []\n for (const [k, st] of this.lists.entries()) {\n if (st.parentRowId === parentRowId) keys.push(k)\n }\n\n for (const key of keys) {\n const st = this.lists.get(key)\n if (!st) continue\n this.lists.delete(key)\n for (let i = 0; i < st.ids.length; i++) {\n const rowId = st.ids[i]!\n this.rowIdIndex.delete(rowId)\n this.notifyRemoved(st.listPath, rowId)\n this.removeDescendants(rowId)\n }\n }\n }\n\n onRemoved(listPath: string, listener: ListRemovalListener): () => void {\n const set = this.removalListeners.get(listPath) ?? new Set<ListRemovalListener>()\n set.add(listener)\n this.removalListeners.set(listPath, set)\n return () => {\n const current = this.removalListeners.get(listPath)\n if (!current) return\n current.delete(listener)\n if (current.size === 0) this.removalListeners.delete(listPath)\n }\n }\n\n getRowId(listPath: string, index: number, parentRowId?: RowId): RowId | undefined {\n const state = this.lists.get(this.listKey(listPath, parentRowId))\n return state ? state.ids[index] : undefined\n }\n\n getIndex(listPath: string, rowId: RowId): number | undefined {\n const info = this.rowIdIndex.get(rowId)\n if (!info) return undefined\n if (info.listPath !== listPath) return undefined\n return info.index\n }\n\n /**\n * ensureList:\n * - Align RowID mapping for the given listPath with the current items.\n * - Returns the latest ids (index -> RowId).\n */\n ensureList(\n listPath: string,\n items: ReadonlyArray<unknown>,\n trackBy?: string,\n parentRowId?: RowId,\n ): ReadonlyArray<RowId> {\n const key = this.listKey(listPath, parentRowId)\n const prev = this.lists.get(key)\n const { ids, removed } = reconcileIds(prev, items, trackBy ?? prev?.trackBy, this.makeRowId)\n\n const next: ListState = {\n listPath,\n parentRowId,\n itemsRef: items,\n ids,\n indexById: buildIndexById(ids),\n trackBy: trackBy ?? prev?.trackBy,\n }\n this.lists.set(key, next)\n\n if (removed.length > 0) {\n for (const rowId of removed) {\n this.rowIdIndex.delete(rowId)\n this.notifyRemoved(listPath, rowId)\n this.removeDescendants(rowId)\n }\n }\n\n // Refresh the reverse rowId -> index mapping (index changes are allowed).\n for (let i = 0; i < ids.length; i++) {\n const rowId = ids[i]!\n this.rowIdIndex.set(rowId, { key, listPath, index: i })\n }\n\n return ids\n }\n\n /**\n * updateAll:\n * - After each commit, align RowID mappings for all known lists.\n * - configs come from list declarations in StateTraitProgram.spec (may include trackBy).\n */\n updateAll(state: unknown, configs: ReadonlyArray<ListConfig>): void {\n const cfgByPath = new Map<string, ListConfig>()\n const paths: Array<string> = []\n for (const cfg of configs) {\n if (!cfg || typeof cfg.path !== 'string') continue\n const p = cfg.path.trim()\n if (!p) continue\n cfgByPath.set(p, cfg)\n paths.push(p)\n }\n\n const pathSet = new Set(paths)\n\n const parentOf = (path: string): string | undefined => {\n const segments = path.split('.').filter(Boolean)\n let best: string | undefined\n for (let i = 1; i < segments.length; i++) {\n const prefix = segments.slice(0, i).join('.')\n if (pathSet.has(prefix)) best = prefix\n }\n return best\n }\n\n const parentByPath = new Map<string, string | undefined>()\n const suffixByPath = new Map<string, string>()\n const childrenByParent = new Map<string | undefined, Array<string>>()\n\n for (const path of paths) {\n const parent = parentOf(path)\n parentByPath.set(path, parent)\n const suffix = parent ? path.slice(parent.length + 1) : path\n suffixByPath.set(path, suffix)\n const list = childrenByParent.get(parent) ?? []\n list.push(path)\n childrenByParent.set(parent, list)\n }\n\n // roots first (and deterministic traversal)\n const roots = (childrenByParent.get(undefined) ?? []).slice().sort((a, b) => a.localeCompare(b))\n\n const visit = (listPath: string, parentRowId: RowId | undefined, listValue: unknown): void => {\n const cfg = cfgByPath.get(listPath)\n const items = Array.isArray(listValue) ? (listValue as ReadonlyArray<unknown>) : []\n const ids = this.ensureList(listPath, items, cfg?.trackBy, parentRowId)\n\n const children = (childrenByParent.get(listPath) ?? []).slice().sort((a, b) => a.localeCompare(b))\n if (children.length === 0) return\n\n for (let i = 0; i < items.length; i++) {\n const row = items[i]\n const rowId = ids[i]\n if (!rowId) continue\n for (const childPath of children) {\n const suffix = suffixByPath.get(childPath) ?? ''\n const childValue = suffix ? getAtPath(row as any, suffix) : undefined\n visit(childPath, rowId, childValue)\n }\n }\n }\n\n for (const root of roots) {\n const value = getAtPath(state as any, root)\n visit(root, undefined, value)\n }\n }\n}\n\nexport const collectListConfigs = (spec: Record<string, unknown>): ReadonlyArray<ListConfig> => {\n const configs: Array<ListConfig> = []\n for (const key in spec) {\n if (!Object.prototype.hasOwnProperty.call(spec, key)) continue\n const raw = spec[key]\n if (!raw || typeof raw !== 'object') continue\n const tag = (raw as any)._tag\n if (tag !== 'StateTraitList') continue\n const trackBy = (raw as any).identityHint?.trackBy\n configs.push({\n path: key,\n trackBy: typeof trackBy === 'string' ? trackBy : undefined,\n })\n }\n return configs\n}\n","import { Context, Effect, Layer } from 'effect'\n\nexport type ResourceSnapshotPhase = 'idle' | 'loading' | 'success' | 'error'\n\nexport type ReplayLogEvent =\n | {\n readonly _tag: 'ResourceSnapshot'\n readonly resourceId: string\n readonly fieldPath: string\n readonly keyHash?: string\n /**\n * Optional: source concurrency policy (e.g. \"switch\" / \"exhaust-trailing\").\n * - Must remain slim & serializable.\n * - Used by Devtools/replay to explain why old results are dropped / why trailing happens.\n */\n readonly concurrency?: string\n readonly phase: ResourceSnapshotPhase\n readonly snapshot: unknown\n readonly timestamp: number\n readonly moduleId?: string\n readonly instanceId?: string\n }\n | {\n readonly _tag: 'InvalidateRequest'\n readonly timestamp: number\n readonly moduleId?: string\n readonly instanceId?: string\n readonly kind: 'resource' | 'query'\n readonly target: string\n readonly meta?: unknown\n }\n\nexport type ResourceSnapshotEvent = Extract<ReplayLogEvent, { readonly _tag: 'ResourceSnapshot' }>\n\nexport interface ReplayLogService {\n readonly record: (event: ReplayLogEvent) => Effect.Effect<void>\n readonly snapshot: Effect.Effect<ReadonlyArray<ReplayLogEvent>>\n readonly resetCursor: Effect.Effect<void>\n readonly consumeNext: (predicate: (event: ReplayLogEvent) => boolean) => Effect.Effect<ReplayLogEvent | undefined>\n readonly consumeNextResourceSnapshot: (params: {\n readonly resourceId: string\n readonly fieldPath: string\n readonly keyHash?: string\n readonly phase?: ResourceSnapshotPhase\n }) => Effect.Effect<ResourceSnapshotEvent | undefined>\n}\n\nexport class ReplayLog extends Context.Tag('@logixjs/core/ReplayLog')<ReplayLog, ReplayLogService>() {}\n\nexport const make = (initial?: ReadonlyArray<ReplayLogEvent>): ReplayLogService => {\n const events: Array<ReplayLogEvent> = initial ? Array.from(initial) : []\n let cursor = 0\n\n const consumeNext = (predicate: (event: ReplayLogEvent) => boolean): Effect.Effect<ReplayLogEvent | undefined> =>\n Effect.sync(() => {\n for (let i = cursor; i < events.length; i++) {\n const event = events[i]\n if (!predicate(event)) continue\n cursor = i + 1\n return event\n }\n return undefined\n })\n\n const consumeNextResourceSnapshot = (params: {\n readonly resourceId: string\n readonly fieldPath: string\n readonly keyHash?: string\n readonly phase?: ResourceSnapshotPhase\n }): Effect.Effect<ResourceSnapshotEvent | undefined> =>\n consumeNext((event): event is ResourceSnapshotEvent => {\n if (event._tag !== 'ResourceSnapshot') return false\n if (event.resourceId !== params.resourceId) return false\n if (event.fieldPath !== params.fieldPath) return false\n if (params.keyHash !== undefined && event.keyHash !== params.keyHash) {\n return false\n }\n if (params.phase !== undefined && event.phase !== params.phase) {\n return false\n }\n return true\n }).pipe(Effect.map((event) => event as ResourceSnapshotEvent | undefined))\n\n return {\n record: (event) => Effect.sync(() => events.push(event)),\n snapshot: Effect.sync(() => events.slice()),\n resetCursor: Effect.sync(() => {\n cursor = 0\n }),\n consumeNext,\n consumeNextResourceSnapshot,\n }\n}\n\nexport const layer = (initial?: ReadonlyArray<ReplayLogEvent>): Layer.Layer<ReplayLog, never, never> =>\n Layer.succeed(ReplayLog, make(initial))\n\nexport const record = (event: ReplayLogEvent): Effect.Effect<void, never, ReplayLog> =>\n Effect.gen(function* () {\n const log = yield* ReplayLog\n yield* log.record(event)\n })\n\nexport const snapshot: Effect.Effect<ReadonlyArray<ReplayLogEvent>, never, ReplayLog> = Effect.gen(function* () {\n const log = yield* ReplayLog\n return yield* log.snapshot\n})\n\nexport const resetCursor: Effect.Effect<void, never, ReplayLog> = Effect.gen(function* () {\n const log = yield* ReplayLog\n yield* log.resetCursor\n})\n\nexport const consumeNextResourceSnapshot = (params: {\n readonly resourceId: string\n readonly fieldPath: string\n readonly keyHash?: string\n readonly phase?: ResourceSnapshotPhase\n}): Effect.Effect<ResourceSnapshotEvent | undefined, never, ReplayLog> =>\n Effect.gen(function* () {\n const log = yield* ReplayLog\n return yield* log.consumeNextResourceSnapshot(params)\n })\n"],"mappings":";;;;;AAWA,IAAM,gBAAgB,CAAC,SAAyC;AAC9D,MAAI,CAAC,KAAM,QAAO,CAAC;AACnB,SAAO,KAAK,MAAM,GAAG,EAAE,IAAI,CAAC,QAAS,WAAW,KAAK,GAAG,IAAI,OAAO,GAAG,IAAI,GAAI;AAChF;AAEO,IAAM,YAAY,CAAC,OAAY,SAAsB;AAC1D,MAAI,CAAC,QAAQ,SAAS,KAAM,QAAO;AACnC,QAAM,WAAW,cAAc,IAAI;AACnC,MAAI,UAAe;AACnB,aAAW,OAAO,UAAU;AAC1B,QAAI,WAAW,KAAM,QAAO;AAC5B,QAAI,OAAO,QAAQ,UAAU;AAC3B,gBAAU,MAAM,QAAQ,OAAO,IAAI,QAAQ,GAAG,IAAI,QA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CAAC,UAAU,KAA0C,CAAC;AAE3E,SAAO;AAAA,IACL,QAAQ,CAAC,UAAU,OAAO,KAAK,MAAM,OAAO,KAAK,KAAK,CAAC;AAAA,IACvD,UAAU,OAAO,KAAK,MAAM,OAAO,MAAM,CAAC;AAAA,IAC1C,aAAa,OAAO,KAAK,MAAM;AAC7B,eAAS;AAAA,IACX,CAAC;AAAA,IACD;AAAA,IACA,6BAAAA;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,CAAC,YACpB,MAAM,QAAQ,WAAW,KAAK,OAAO,CAAC;AAEjC,IAAM,SAAS,CAAC,UACrB,OAAO,IAAI,aAAa;AACtB,QAAM,MAAM,OAAO;AACnB,SAAO,IAAI,OAAO,KAAK;AACzB,CAAC;AAEI,IAAM,WAA2E,OAAO,IAAI,aAAa;AAC9G,QAAM,MAAM,OAAO;AACnB,SAAO,OAAO,IAAI;AACpB,CAAC;AAEM,IAAM,cAAqD,OAAO,IAAI,aAAa;AACxF,QAAM,MAAM,OAAO;AACnB,SAAO,IAAI;AACb,CAAC;AAEM,IAAM,8BAA8B,CAAC,WAM1C,OAAO,IAAI,aAAa;AACtB,QAAM,MAAM,OAAO;AACnB,SAAO,OAAO,IAAI,4BAA4B,MAAM;AACtD,CAAC;","names":["consumeNextResourceSnapshot"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/core/mutativePatches.ts","../src/internal/runtime/core/BoundApiRuntime.ts","../src/internal/runtime/core/Lifecycle.ts","../src/internal/runtime/core/LogicDiagnostics.ts"],"sourcesContent":["import { create, type Patches } from 'mutative'\nimport type { FieldPath } from '../../field-path.js'\nimport { isFieldPathSegment } from '../../field-path.js'\n\nexport type PatchPath = FieldPath\n\nexport const mutateWithoutPatches = <S>(base: S, mutator: (draft: S) => void): S => {\n return create(base, mutator as any) as unknown as S\n}\n\nconst toPatchFieldPath = (path: unknown): PatchPath | '*' | undefined => {\n if (typeof path === 'string') {\n const trimmed = path.trim()\n return trimmed.length > 0 ? '*' : undefined\n }\n\n if (!Array.isArray(path)) return undefined\n\n const parts: Array<string> = []\n for (const seg of path) {\n if (typeof seg === 'string') {\n if (isFieldPathSegment(seg)) parts.push(seg)\n continue\n }\n }\n\n if (parts.length === 0) return '*'\n return parts\n}\n\nexport const mutateWithPatchPaths = <S>(\n base: S,\n mutator: (draft: S) => void,\n): { readonly nextState: S; readonly patchPaths: ReadonlyArray<PatchPath | '*'> } => {\n const out = create(base, mutator as any, {\n enablePatches: {\n pathAsArray: true,\n arrayLengthAssignment: false,\n },\n }) as unknown\n\n if (!Array.isArray(out)) {\n return { nextState: out as S, patchPaths: [] }\n }\n\n const nextState = out[0] as S\n const patches = (out[1] ?? []) as Patches<{ pathAsArray: true; arrayLengthAssignment: false }>\n\n const dedup = new Map<string, PatchPath | '*'>()\n for (const patch of patches) {\n const p = toPatchFieldPath((patch as any)?.path)\n if (!p) continue\n const key = p === '*' ? '*' : JSON.stringify(p)\n if (!dedup.has(key)) dedup.set(key, p)\n }\n\n return {\n nextState,\n patchPaths: Array.from(dedup.values()),\n }\n}\n","import { Context, Effect, FiberRef, Option, Schema, Stream, SubscriptionRef } from 'effect'\nimport { create } from 'mutative'\nimport type * as Logix from './module.js'\nimport * as Logic from './LogicMiddleware.js'\nimport * as Action from '../../action.js'\nimport * as TaskRunner from './TaskRunner.js'\nimport { mutateWithPatchPaths } from './mutativePatches.js'\nimport * as FlowRuntime from './FlowRuntime.js'\nimport * as MatchBuilder from './MatchBuilder.js'\nimport * as Platform from './Platform.js'\nimport * as Lifecycle from './Lifecycle.js'\nimport * as Debug from './DebugSink.js'\nimport * as LogicDiagnostics from './LogicDiagnostics.js'\nimport { isDevEnv } from './env.js'\nimport { RunSessionTag } from '../../observability/runSession.js'\nimport * as Root from '../../root.js'\nimport type { RuntimeInternals } from './RuntimeInternals.js'\nimport type * as ModuleTraits from './ModuleTraits.js'\nimport { getRuntimeInternals, setBoundInternals } from './runtimeInternalsAccessor.js'\nimport type { AnyModuleShape, ModuleRuntime, StateOf, ActionOf } from './module.js'\n\n// Local IntentBuilder factory; equivalent to the old internal/dsl/LogicBuilder.makeIntentBuilderFactory.\nconst LogicBuilderFactory = <Sh extends AnyModuleShape, R = never>(\n runtime: ModuleRuntime<StateOf<Sh>, ActionOf<Sh>>,\n runtimeInternals: RuntimeInternals,\n) => {\n const flowApi = FlowRuntime.make<Sh, R>(runtime, runtimeInternals)\n\n return <T>(stream: Stream.Stream<T>, triggerName?: string): Logic.IntentBuilder<T, Sh, R> => {\n const runWithStateTransaction: TaskRunner.TaskRunnerRuntime['runWithStateTransaction'] = (origin, body) =>\n runtimeInternals.txn.runWithStateTransaction(origin as any, body)\n\n const taskRunnerRuntime: TaskRunner.TaskRunnerRuntime = {\n moduleId: runtime.moduleId,\n instanceId: runtimeInternals.instanceId,\n runWithStateTransaction,\n resolveConcurrencyPolicy: runtimeInternals.concurrency.resolveConcurrencyPolicy,\n }\n\n const builder = {\n debounce: (ms: number) =>\n LogicBuilderFactory<Sh, R>(runtime, runtimeInternals)(flowApi.debounce<T>(ms)(stream), triggerName),\n throttle: (ms: number) =>\n LogicBuilderFactory<Sh, R>(runtime, runtimeInternals)(flowApi.throttle<T>(ms)(stream), triggerName),\n filter: (predicate: (value: T) => boolean) =>\n LogicBuilderFactory<Sh, R>(runtime, runtimeInternals)(flowApi.filter(predicate)(stream), triggerName),\n map: <U>(f: (value: T) => U) =>\n LogicBuilderFactory<Sh, R>(runtime, runtimeInternals)(stream.pipe(Stream.map(f)), triggerName),\n run<A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n options?: Logic.OperationOptions,\n ): Logic.Of<Sh, R & R2, void, E> {\n return flowApi.run<T, A, E, R2>(eff, options)(stream)\n },\n runLatest<A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n options?: Logic.OperationOptions,\n ): Logic.Of<Sh, R & R2, void, E> {\n return flowApi.runLatest<T, A, E, R2>(eff, options)(stream)\n },\n runExhaust<A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n options?: Logic.OperationOptions,\n ): Logic.Of<Sh, R & R2, void, E> {\n return flowApi.runExhaust<T, A, E, R2>(eff, options)(stream)\n },\n runParallel<A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n options?: Logic.OperationOptions,\n ): Logic.Of<Sh, R & R2, void, E> {\n return flowApi.runParallel<T, A, E, R2>(eff, options)(stream)\n },\n runFork: <A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n ): Logic.Of<Sh, R & R2, void, E> =>\n Effect.forkScoped(flowApi.run<T, A, E, R2>(eff)(stream)).pipe(Effect.asVoid) as Logic.Of<Sh, R & R2, void, E>,\n runParallelFork: <A = void, E = never, R2 = unknown>(\n eff: Logic.Of<Sh, R & R2, A, E> | ((p: T) => Logic.Of<Sh, R & R2, A, E>),\n ): Logic.Of<Sh, R & R2, void, E> =>\n Effect.forkScoped(flowApi.runParallel<T, A, E, R2>(eff)(stream)).pipe(Effect.asVoid) as Logic.Of<\n Sh,\n R & R2,\n void,\n E\n >,\n runTask: <A = void, E = never, R2 = unknown>(\n config: TaskRunner.TaskRunnerConfig<T, Sh, R & R2, A, E>,\n ): Logic.Of<Sh, R & R2, void, never> =>\n TaskRunner.makeTaskRunner<T, Sh, R & R2, A, E>(stream, 'task', taskRunnerRuntime, {\n ...config,\n triggerName: config.triggerName ?? triggerName,\n }) as Logic.Of<Sh, R & R2, void, never>,\n runParallelTask: <A = void, E = never, R2 = unknown>(\n config: TaskRunner.TaskRunnerConfig<T, Sh, R & R2, A, E>,\n ): Logic.Of<Sh, R & R2, void, never> =>\n TaskRunner.makeTaskRunner<T, Sh, R & R2, A, E>(stream, 'parallel', taskRunnerRuntime, {\n ...config,\n triggerName: config.triggerName ?? triggerName,\n }) as Logic.Of<Sh, R & R2, void, never>,\n runLatestTask: <A = void, E = never, R2 = unknown>(\n config: TaskRunner.TaskRunnerConfig<T, Sh, R & R2, A, E>,\n ): Logic.Of<Sh, R & R2, void, never> =>\n TaskRunner.makeTaskRunner<T, Sh, R & R2, A, E>(stream, 'latest', taskRunnerRuntime, {\n ...config,\n triggerName: config.triggerName ?? triggerName,\n }) as Logic.Of<Sh, R & R2, void, never>,\n runExhaustTask: <A = void, E = never, R2 = unknown>(\n config: TaskRunner.TaskRunnerConfig<T, Sh, R & R2, A, E>,\n ): Logic.Of<Sh, R & R2, void, never> =>\n TaskRunner.makeTaskRunner<T, Sh, R & R2, A, E>(stream, 'exhaust', taskRunnerRuntime, {\n ...config,\n triggerName: config.triggerName ?? triggerName,\n }) as Logic.Of<Sh, R & R2, void, never>,\n toStream: () => stream,\n update: (\n reducer: (prev: StateOf<Sh>, payload: T) => StateOf<Sh> | Effect.Effect<StateOf<Sh>, any, any>,\n ): Logic.Of<Sh, R, void, never> =>\n Stream.runForEach(stream, (payload) =>\n taskRunnerRuntime.runWithStateTransaction(\n {\n kind: 'watcher:update',\n name: triggerName,\n },\n () =>\n Effect.gen(function* () {\n const prev = (yield* runtime.getState) as StateOf<Sh>\n const next = reducer(prev, payload)\n if (Effect.isEffect(next)) {\n const exit = yield* Effect.exit(next as Effect.Effect<StateOf<Sh>, any, any>)\n if (exit._tag === 'Failure') {\n yield* Effect.logError('Flow error', exit.cause)\n return\n }\n yield* runtime.setState(exit.value as StateOf<Sh>)\n return\n }\n yield* runtime.setState(next as StateOf<Sh>)\n }),\n ),\n ).pipe(Effect.catchAllCause((cause) => Effect.logError('Flow error', cause))) as Logic.Of<Sh, R, void, never>,\n mutate: (reducer: (draft: Logic.Draft<StateOf<Sh>>, payload: T) => void): Logic.Of<Sh, R, void, never> =>\n Stream.runForEach(stream, (payload) =>\n taskRunnerRuntime.runWithStateTransaction(\n {\n kind: 'watcher:mutate',\n name: triggerName,\n },\n () =>\n Effect.gen(function* () {\n const prev = (yield* runtime.getState) as StateOf<Sh>\n const recordPatch = runtimeInternals.txn.recordStatePatch\n const updateDraft = runtimeInternals.txn.updateDraft\n\n const { nextState, patchPaths } = mutateWithPatchPaths(prev as StateOf<Sh>, (draft) => {\n reducer(draft as Logic.Draft<StateOf<Sh>>, payload)\n })\n\n for (const path of patchPaths) {\n recordPatch(path, 'unknown')\n }\n\n updateDraft(nextState)\n }),\n ),\n ).pipe(Effect.catchAllCause((cause) => Effect.logError('Flow error', cause))) as Logic.Of<Sh, R, void, never>,\n } as Omit<Logic.IntentBuilder<T, Sh, R>, 'pipe'>\n\n const pipe: Logic.IntentBuilder<T, Sh, R>['pipe'] = function (this: unknown) {\n // eslint-disable-next-line prefer-rest-params\n const fns = arguments as unknown as ReadonlyArray<\n (self: Logic.IntentBuilder<T, Sh, R>) => Logic.IntentBuilder<T, Sh, R>\n >\n let acc: Logic.IntentBuilder<T, Sh, R> = builder as Logic.IntentBuilder<T, Sh, R>\n for (let i = 0; i < fns.length; i++) {\n acc = fns[i](acc)\n }\n return acc\n }\n\n return Object.assign(builder, { pipe }) as Logic.IntentBuilder<T, Sh, R>\n }\n}\nimport type { BoundApi } from './module.js'\n\n/**\n * BoundApi implementation: creates a pre-bound `$` for a given Store shape + runtime.\n *\n * Note: public types and entrypoint signatures live in api/BoundApi.ts; this file only hosts the implementation.\n */\nexport function make<Sh extends Logix.AnyModuleShape, R = never>(\n shape: Sh,\n runtime: Logix.ModuleRuntime<Logix.StateOf<Sh>, Logix.ActionOf<Sh>>,\n options?: {\n readonly getPhase?: () => 'setup' | 'run'\n readonly phaseService?: LogicDiagnostics.LogicPhaseService\n readonly moduleId?: string\n readonly logicUnit?: LogicDiagnostics.LogicUnitService\n },\n): BoundApi<Sh, R> {\n const runtimeInternals = getRuntimeInternals(runtime as any)\n\n const getPhase = options?.getPhase ?? (() => 'run')\n const getCurrentPhase = (): 'setup' | 'run' => {\n const phaseService = options?.phaseService\n const phase = phaseService?.current ?? getPhase()\n return phase === 'setup' ? 'setup' : 'run'\n }\n const guardRunOnly = (kind: string, api: string) => {\n const phaseService = options?.phaseService\n const phase = phaseService?.current ?? getPhase()\n if (phase === 'setup') {\n throw LogicDiagnostics.makeLogicPhaseError(kind, api, 'setup', options?.moduleId)\n }\n }\n const flowApi = FlowRuntime.make<Sh, R>(runtime, runtimeInternals)\n\n const makeIntentBuilder = (runtime_: Logix.ModuleRuntime<any, any>) =>\n LogicBuilderFactory<Sh, R>(runtime_, runtimeInternals)\n const withLifecycle = <A>(\n available: (manager: Lifecycle.LifecycleManager) => Effect.Effect<A, never, any>,\n missing: () => Effect.Effect<A, never, any>,\n ) =>\n Effect.serviceOption(Lifecycle.LifecycleContext).pipe(\n Effect.flatMap((maybe) =>\n Option.match(maybe, {\n onSome: available,\n onNone: missing,\n }),\n ),\n )\n const withPlatform = (invoke: (platform: Platform.Service) => Effect.Effect<void, never, any>) =>\n Effect.serviceOption(Platform.Tag).pipe(\n Effect.flatMap((maybe) =>\n Option.match(maybe, {\n onSome: invoke,\n onNone: () => Effect.void,\n }),\n ),\n )\n\n const emitSetupOnlyViolation = (api: string): Effect.Effect<void> =>\n Debug.record({\n type: 'diagnostic',\n moduleId: runtime.moduleId,\n instanceId: runtime.instanceId,\n code: 'logic::invalid_phase',\n severity: 'error',\n message: `${api} is setup-only and is not allowed in run phase.`,\n hint:\n 'Move $.lifecycle.* calls to the synchronous part of Module.logic builder (before return) for registration; ' +\n 'for dynamic resource cleanup in the run phase, use Effect.acquireRelease / Scope finalizer instead of registering onDestroy late.',\n kind: 'lifecycle_in_run',\n })\n\n const createIntentBuilder = <T>(stream: Stream.Stream<T>, triggerName?: string) =>\n makeIntentBuilder(runtime)(stream, triggerName)\n\n const onceInRunSession = (key: string): Effect.Effect<boolean, never, any> =>\n Effect.serviceOption(RunSessionTag).pipe(\n Effect.map((maybe) => (Option.isSome(maybe) ? maybe.value.local.once(key) : true)),\n )\n\n let cachedDiagnosticsLevel: Debug.DiagnosticsLevel | undefined\n\n const isModuleLike = (\n value: unknown,\n ): value is {\n readonly _kind: 'ModuleDef' | 'Module'\n readonly id: string\n readonly tag: Context.Tag<any, Logix.ModuleRuntime<any, any>>\n readonly schemas?: Record<string, unknown>\n readonly meta?: Record<string, unknown>\n readonly dev?: { readonly source?: { readonly file: string; readonly line: number; readonly column: number } }\n } =>\n Boolean(\n value &&\n typeof value === 'object' &&\n ((value as any)._kind === 'ModuleDef' || (value as any)._kind === 'Module') &&\n 'tag' in (value as object) &&\n Context.isTag((value as any).tag),\n )\n\n const buildModuleHandle = (\n tag: Context.Tag<any, Logix.ModuleRuntime<any, any>>,\n rt: Logix.ModuleRuntime<any, any>,\n ): unknown => {\n const actionsProxy: Logix.ModuleHandle<any>['actions'] = new Proxy(\n {},\n {\n get: (_target, prop) => (payload: unknown) =>\n rt.dispatch({\n _tag: prop as string,\n payload,\n }),\n },\n ) as Logix.ModuleHandle<any>['actions']\n\n const handle: Logix.ModuleHandle<any> = {\n read: (selector) => Effect.map(rt.getState, selector),\n changes: rt.changes,\n dispatch: rt.dispatch,\n actions$: rt.actions$,\n actions: actionsProxy,\n }\n\n const EXTEND_HANDLE = Symbol.for('logix.module.handle.extend')\n const extend = (tag as any)?.[EXTEND_HANDLE] as\n | ((runtime: Logix.ModuleRuntime<any, any>, base: Logix.ModuleHandle<any>) => unknown)\n | undefined\n\n return typeof extend === 'function' ? (extend(rt, handle) ?? handle) : handle\n }\n\n const emitModuleDescriptorOnce = (\n module: {\n readonly id: string\n readonly tag: any\n readonly schemas?: Record<string, unknown>\n readonly meta?: Record<string, unknown>\n readonly dev?: { readonly source?: { readonly file: string; readonly line: number; readonly column: number } }\n },\n rt: Logix.ModuleRuntime<any, any>,\n ): Effect.Effect<void, never, any> =>\n Effect.gen(function* () {\n // Hot-path guard: never emit events when diagnostics are off.\n if (cachedDiagnosticsLevel === 'off') return\n\n const key = `module_descriptor:${String(rt.instanceId ?? 'unknown')}`\n const shouldEmit = yield* onceInRunSession(key)\n if (!shouldEmit) return\n\n const actionKeys = Object.keys((module.tag as any)?.shape?.actionMap ?? {})\n\n const internalSymbol = Symbol.for('logix.module.internal')\n const internal = (module as any)[internalSymbol] as { readonly mounted?: ReadonlyArray<any> } | undefined\n\n const logicUnits = (internal?.mounted ?? []).map((u: any) => ({\n kind: String(u?.kind ?? 'user'),\n id: String(u?.id ?? ''),\n derived: u?.derived ? true : undefined,\n name: typeof u?.name === 'string' ? u.name : undefined,\n }))\n\n const schemaKeys = module.schemas && typeof module.schemas === 'object' ? Object.keys(module.schemas) : undefined\n\n const meta = module.meta && typeof module.meta === 'object' ? module.meta : undefined\n\n const source = module.dev?.source\n\n const traitsSnapshot = runtimeInternals.traits.getModuleTraitsSnapshot()\n const traits = traitsSnapshot\n ? {\n digest: traitsSnapshot.digest,\n count: traitsSnapshot.traits.length,\n }\n : undefined\n\n const data = {\n id: module.id,\n moduleId: String(rt.moduleId),\n instanceId: String(rt.instanceId),\n actionKeys,\n logicUnits,\n schemaKeys,\n meta,\n source,\n traits,\n }\n\n yield* Debug.record({\n type: 'trace:module:descriptor',\n moduleId: rt.moduleId,\n instanceId: rt.instanceId,\n data,\n } as any)\n })\n\n /**\n * strict: resolve a Module runtime only from the current Effect environment.\n *\n * Notes:\n * - With multiple roots / instances, any process-wide registry cannot express the correct semantics.\n * - A missing provider is a wiring error: fail deterministically and provide actionable hints (more details in dev/test).\n */\n const resolveModuleRuntime = (\n tag: Context.Tag<any, Logix.ModuleRuntime<any, any>>,\n ): Effect.Effect<Logix.ModuleRuntime<any, any>, never, any> =>\n Effect.gen(function* () {\n const requestedModuleId = typeof (tag as any)?.id === 'string' ? ((tag as any).id as string) : undefined\n const fromModuleId = typeof options?.moduleId === 'string' ? options.moduleId : runtime.moduleId\n\n // self: always allow resolving the current ModuleRuntime (both Bound.make and runtime injection paths).\n if (requestedModuleId && requestedModuleId === runtime.moduleId) {\n return runtime as unknown as Logix.ModuleRuntime<any, any>\n }\n\n const fromImports = runtimeInternals.imports.get(tag as unknown as Context.Tag<any, any>)\n if (fromImports) {\n return fromImports as unknown as Logix.ModuleRuntime<any, any>\n }\n\n // Bound.make (no moduleId context): allow resolving from the current Effect env (useful for tests/scaffolding).\n if (typeof options?.moduleId !== 'string') {\n const fromEnv = yield* Effect.serviceOption(tag as any)\n if (Option.isSome(fromEnv)) {\n return fromEnv.value as unknown as Logix.ModuleRuntime<any, any>\n }\n }\n\n // 2) Not found: die immediately — this is a wiring error; guide the caller to fix the composition.\n const tokenId = requestedModuleId ?? '<unknown module id>'\n const fix: string[] = isDevEnv()\n ? [\n '- Provide the child implementation in the same scope (imports).',\n ` Example: ${fromModuleId ?? 'ParentModule'}.implement({ imports: [${requestedModuleId ?? 'ChildModule'}.impl], ... })`,\n '- If you intentionally want a root singleton, provide it at app root (Runtime.make(...,{ layer }) / root imports),',\n ' and use Root.resolve(ModuleTag) (instead of $.use) at the callsite.',\n ]\n : []\n\n const err = new Error(\n isDevEnv()\n ? [\n '[MissingModuleRuntimeError] Cannot resolve ModuleRuntime for ModuleTag.',\n '',\n `tokenId: ${tokenId}`,\n 'entrypoint: logic.$.use',\n 'mode: strict',\n `from: ${fromModuleId ?? '<unknown module id>'}`,\n `startScope: moduleId=${fromModuleId ?? '<unknown>'}, instanceId=${String(runtime.instanceId ?? '<unknown>')}`,\n '',\n 'fix:',\n ...fix,\n ].join('\\n')\n : '[MissingModuleRuntimeError] module runtime not found',\n )\n\n ;(err as any).tokenId = tokenId\n ;(err as any).entrypoint = 'logic.$.use'\n ;(err as any).mode = 'strict'\n ;(err as any).from = fromModuleId\n ;(err as any).startScope = {\n moduleId: fromModuleId,\n instanceId: String(runtime.instanceId ?? '<unknown>'),\n }\n ;(err as any).fix = fix\n\n err.name = 'MissingModuleRuntimeError'\n return yield* Effect.die(err)\n })\n\n const stateApi: BoundApi<Sh, R>['state'] = {\n read: runtime.getState,\n update: (f) =>\n Effect.gen(function* () {\n const inTxn = yield* FiberRef.get(TaskRunner.inSyncTransactionFiber)\n if (inTxn) {\n const prev = yield* runtime.getState\n return yield* runtime.setState(f(prev))\n }\n\n const body = () => Effect.flatMap(runtime.getState, (prev) => runtime.setState(f(prev)))\n\n return yield* runtimeInternals\n ? runtimeInternals.txn.runWithStateTransaction({ kind: 'state', name: 'update' } as any, body)\n : body()\n }),\n mutate: (f) =>\n Effect.gen(function* () {\n const recordPatch = runtimeInternals?.txn.recordStatePatch\n const updateDraft = runtimeInternals?.txn.updateDraft\n\n const inTxn = yield* FiberRef.get(TaskRunner.inSyncTransactionFiber)\n if (inTxn) {\n const prev = yield* runtime.getState\n const { nextState, patchPaths } = mutateWithPatchPaths(prev as Logix.StateOf<Sh>, (draft) => {\n f(draft as Logic.Draft<Logix.StateOf<Sh>>)\n })\n\n for (const path of patchPaths) {\n recordPatch?.(path, 'unknown')\n }\n\n updateDraft?.(nextState)\n return\n }\n\n const body = () =>\n Effect.gen(function* () {\n const prev = yield* runtime.getState\n const { nextState, patchPaths } = mutateWithPatchPaths(prev as Logix.StateOf<Sh>, (draft) => {\n f(draft as Logic.Draft<Logix.StateOf<Sh>>)\n })\n\n for (const path of patchPaths) {\n recordPatch?.(path, 'unknown')\n }\n\n updateDraft?.(nextState)\n })\n\n return yield* runtimeInternals\n ? runtimeInternals.txn.runWithStateTransaction({ kind: 'state', name: 'mutate' } as any, body)\n : body()\n }),\n ref: runtime.ref,\n }\n\n const actions = shape.actionMap as BoundApi<Sh, R>['actions']\n\n const dispatcherCache = new Map<string, (...args: any[]) => Effect.Effect<void, any, any>>()\n\n const hasAction = (key: string): boolean => Object.prototype.hasOwnProperty.call(actions as any, key)\n\n const dispatchers: BoundApi<Sh, R>['dispatchers'] = new Proxy({} as any, {\n get: (_target, prop) => {\n if (typeof prop !== 'string') return undefined\n if (!hasAction(prop)) return undefined\n\n const cached = dispatcherCache.get(prop)\n if (cached) return cached\n\n const token = (actions as any)[prop] as Action.AnyActionToken\n const fn = (...args: any[]) => runtime.dispatch((token as any)(...args))\n\n dispatcherCache.set(prop, fn)\n return fn\n },\n has: (_target, prop) => typeof prop === 'string' && hasAction(prop),\n ownKeys: () => Object.keys(actions as any),\n getOwnPropertyDescriptor: (_target, prop) => {\n if (typeof prop !== 'string') return undefined\n if (!hasAction(prop)) return undefined\n return { enumerable: true, configurable: true }\n },\n }) as unknown as BoundApi<Sh, R>['dispatchers']\n\n const dispatch: BoundApi<Sh, R>['dispatch'] = (...args: any[]) => {\n const [first, second] = args\n\n if (typeof first === 'string') {\n return runtime.dispatch({ _tag: first, payload: second } as Logix.ActionOf<Sh>)\n }\n\n if (Action.isActionToken(first)) {\n return runtime.dispatch((first as any)(second))\n }\n\n return runtime.dispatch(first as Logix.ActionOf<Sh>)\n }\n\n const matchApi = <V>(value: V): Logic.FluentMatch<V> => MatchBuilder.makeMatch(value)\n\n const matchTagApi = <V extends { _tag: string }>(value: V): Logic.FluentMatchTag<V> =>\n MatchBuilder.makeMatchTag(value)\n\n // Primary reducer registration: write into the reducer map via the runtime's internal registrar.\n const reducer: BoundApi<Sh, R>['reducer'] = (tag, fn) => {\n return Effect.sync(() => {\n runtimeInternals.txn.registerReducer(String(tag), fn as any)\n }) as any\n }\n\n const effect: BoundApi<Sh, R>['effect'] = (token, handler) =>\n Effect.gen(function* () {\n if (!Action.isActionToken(token)) {\n return yield* Effect.dieMessage('[BoundApi.effect] token must be an ActionToken')\n }\n\n const phase = getCurrentPhase()\n const logicUnit = options?.logicUnit\n\n yield* runtimeInternals.effects.registerEffect({\n actionTag: token.tag,\n handler: handler as any,\n phase,\n ...(logicUnit\n ? {\n logicUnit: {\n logicUnitId: logicUnit.logicUnitId,\n logicUnitLabel: logicUnit.logicUnitLabel,\n path: logicUnit.path,\n },\n }\n : {}),\n })\n }) as any\n\n const api: BoundApi<Sh, R> = {\n root: {\n resolve: (tag: any) => {\n guardRunOnly('root_resolve_in_setup', '$.root.resolve')\n return Root.resolve(tag, {\n entrypoint: 'logic.$.root.resolve',\n waitForReady: true,\n }) as any\n },\n },\n state: stateApi,\n actions,\n dispatchers,\n dispatch,\n flow: flowApi,\n match: matchApi,\n matchTag: matchTagApi,\n lifecycle: {\n onInitRequired: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onInitRequired') as any\n }\n runtimeInternals.lifecycle.registerInitRequired(eff as any)\n return Effect.void as any\n },\n onStart: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onStart') as any\n }\n runtimeInternals.lifecycle.registerStart(eff as any)\n return Effect.void as any\n },\n onInit: (eff: Logic.Of<Sh, R, void, never>) => {\n // Legacy alias: same semantics as onInitRequired (to reduce migration friction).\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onInit') as any\n }\n runtimeInternals.lifecycle.registerInitRequired(eff as any)\n return Effect.void as any\n },\n onDestroy: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onDestroy') as any\n }\n runtimeInternals.lifecycle.registerDestroy(eff as any)\n return Effect.void as any\n },\n onError: (\n handler: (\n cause: import('effect').Cause.Cause<unknown>,\n context: Lifecycle.ErrorContext,\n ) => Effect.Effect<void, never, R>,\n ) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onError') as any\n }\n runtimeInternals.lifecycle.registerOnError(handler as any)\n return Effect.void as any\n },\n onSuspend: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onSuspend') as any\n }\n runtimeInternals.lifecycle.registerPlatformSuspend(Effect.asVoid(eff as Effect.Effect<void, never, any>))\n return Effect.void as any\n },\n onResume: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onResume') as any\n }\n runtimeInternals.lifecycle.registerPlatformResume(Effect.asVoid(eff as Effect.Effect<void, never, any>))\n return Effect.void as any\n },\n onReset: (eff: Logic.Of<Sh, R, void, never>) => {\n if (getCurrentPhase() === 'run') {\n return emitSetupOnlyViolation('$.lifecycle.onReset') as any\n }\n runtimeInternals.lifecycle.registerPlatformReset(Effect.asVoid(eff as Effect.Effect<void, never, any>))\n return Effect.void as any\n },\n },\n traits: {\n declare: (traits: ModuleTraits.TraitSpec) => {\n if (getCurrentPhase() === 'run') {\n throw LogicDiagnostics.makeLogicPhaseError(\n 'traits_declare_in_run',\n '$.traits.declare',\n 'run',\n options?.moduleId,\n )\n }\n\n if (!traits || typeof traits !== 'object') {\n throw new Error('[InvalidTraitsDeclaration] $.traits.declare expects an object.')\n }\n\n const logicUnit = options?.logicUnit ?? {\n logicUnitId: 'unknown',\n logicUnitIdKind: 'derived' as const,\n logicUnitLabel: 'logicUnit:unknown',\n path: undefined as string | undefined,\n }\n\n runtimeInternals.traits.registerModuleTraitsContribution({\n traits,\n provenance: {\n originType: 'logicUnit',\n originId: logicUnit.logicUnitId,\n originIdKind: logicUnit.logicUnitIdKind,\n originLabel: logicUnit.logicUnitLabel,\n path: logicUnit.path,\n },\n })\n },\n source: {\n refresh: (fieldPath: string, options?: { readonly force?: boolean }) =>\n Effect.gen(function* () {\n const handler = runtimeInternals.traits.getSourceRefreshHandler(fieldPath) as\n | ((state: Logix.StateOf<Sh>) => Effect.Effect<void, never, any>)\n | undefined\n if (!handler) {\n // If no refresh handler is registered, treat it as a no-op to avoid throwing when StateTraitProgram is not installed.\n return yield* Effect.void\n }\n\n const force = options?.force === true\n const runHandler = (state: Logix.StateOf<Sh>) =>\n force ? Effect.locally(TaskRunner.forceSourceRefresh, true)(handler(state)) : handler(state)\n\n // Never call enqueueTransaction inside the transaction window (it can deadlock):\n // - Run the handler inside the current transaction so it writes to the draft via bound.state.mutate.\n // - The outer transaction window is responsible for commit + debug aggregation.\n const inTxn = yield* FiberRef.get(TaskRunner.inSyncTransactionFiber)\n if (inTxn) {\n const state = (yield* runtime.getState) as Logix.StateOf<Sh>\n return yield* runHandler(state)\n }\n\n // Treat one source-refresh as a dedicated transaction entry.\n return yield* runtimeInternals.txn.runWithStateTransaction(\n {\n kind: 'source-refresh',\n name: fieldPath,\n } as any,\n () =>\n Effect.gen(function* () {\n const state = (yield* runtime.getState) as Logix.StateOf<Sh>\n return yield* runHandler(state)\n }),\n )\n }),\n },\n },\n reducer,\n effect,\n use: new Proxy(() => {}, {\n apply: (_target, _thisArg, [arg]) => {\n guardRunOnly('use_in_setup', '$.use')\n if (isModuleLike(arg)) {\n const domain = arg\n const tag = domain.tag as unknown as Context.Tag<any, Logix.ModuleRuntime<any, any>>\n\n const resolveAndBuild = resolveModuleRuntime(tag).pipe(Effect.map((rt) => buildModuleHandle(tag, rt)))\n\n const resolveWithDescriptor = resolveModuleRuntime(tag).pipe(\n Effect.tap((rt) => emitModuleDescriptorOnce(domain, rt)),\n Effect.map((rt) => buildModuleHandle(tag, rt)),\n )\n\n const detectAndSelect = FiberRef.get(Debug.currentDiagnosticsLevel).pipe(\n Effect.tap((level) => {\n cachedDiagnosticsLevel = level\n }),\n Effect.flatMap((level) => (level === 'off' ? resolveAndBuild : resolveWithDescriptor)),\n )\n\n // 022 perf gate: when diagnostics are off, $.use(module) and $.use(module.tag) must be equivalent with zero extra overhead.\n // Constraint: Effect is a value (reusable), so we must one-time cache at execution time instead of branching at construction time.\n return Effect.suspend(() => {\n if (cachedDiagnosticsLevel === 'off') {\n return resolveAndBuild\n }\n\n if (cachedDiagnosticsLevel !== undefined) {\n return resolveWithDescriptor\n }\n\n return detectAndSelect\n }) as unknown as Logic.Of<Sh, R, any, never>\n }\n if (Context.isTag(arg)) {\n const candidate = arg as { _kind?: unknown }\n\n // Module: return a read-only ModuleHandle view.\n if (candidate._kind === 'ModuleTag') {\n return resolveModuleRuntime(arg as any).pipe(\n Effect.map((rt: Logix.ModuleRuntime<any, any>) => buildModuleHandle(arg as any, rt)),\n ) as unknown as Logic.Of<Sh, R, any, never>\n }\n\n // Regular service tag: read the service from Env.\n return arg as unknown as Logic.Of<Sh, R, any, never>\n }\n return Effect.die('BoundApi.use: unsupported argument') as unknown as Logic.Of<Sh, R, any, never>\n },\n }) as unknown as BoundApi<Sh, R>['use'],\n onAction: new Proxy(() => {}, {\n apply: (_target, _thisArg, args) => {\n guardRunOnly('use_in_setup', '$.onAction')\n const arg = args[0]\n if (Action.isActionToken(arg)) {\n const tag = arg.tag\n return createIntentBuilder(\n runtime.actions$.pipe(\n Stream.filter((a: any) => a._tag === tag || a.type === tag),\n Stream.map((a: any) => a.payload),\n ),\n tag,\n )\n }\n if (typeof arg === 'function') {\n return createIntentBuilder(runtime.actions$.pipe(Stream.filter(arg)))\n }\n if (typeof arg === 'string') {\n return createIntentBuilder(\n runtime.actions$.pipe(Stream.filter((a: any) => a._tag === arg || a.type === arg)),\n arg,\n )\n }\n if (typeof arg === 'object' && arg !== null) {\n if ('_tag' in arg) {\n return createIntentBuilder(\n runtime.actions$.pipe(Stream.filter((a: any) => a._tag === (arg as any)._tag)),\n String((arg as any)._tag),\n )\n }\n if (Schema.isSchema(arg)) {\n return createIntentBuilder(\n runtime.actions$.pipe(\n Stream.filter((a: any) => {\n const result = Schema.decodeUnknownSync(arg as Schema.Schema<any, any, never>)(a)\n return !!result\n }),\n ),\n )\n }\n }\n return createIntentBuilder(runtime.actions$)\n },\n get: (_target, prop) => {\n guardRunOnly('use_in_setup', '$.onAction')\n if (typeof prop === 'string') {\n return createIntentBuilder(\n runtime.actions$.pipe(Stream.filter((a: any) => a._tag === prop || a.type === prop)),\n prop,\n )\n }\n return undefined\n },\n }) as unknown as BoundApi<Sh, R>['onAction'],\n onState: (selector: (s: Logix.StateOf<Sh>) => any) => {\n guardRunOnly('use_in_setup', '$.onState')\n return createIntentBuilder(runtime.changes(selector))\n },\n on: (stream: Stream.Stream<any>) => {\n guardRunOnly('use_in_setup', '$.on')\n return createIntentBuilder(stream)\n },\n } as any\n\n setBoundInternals(api as any, runtimeInternals)\n\n return api\n}\n","import { Cause, Context, Effect, Ref } from 'effect'\nimport { toSerializableErrorSummary } from './errorSummary.js'\nimport * as Debug from './DebugSink.js'\n\nexport type Phase = 'init' | 'run' | 'destroy' | 'platform'\n\nexport type Hook = 'initRequired' | 'start' | 'destroy' | 'suspend' | 'resume' | 'reset' | 'unknown'\n\nexport type TaskKind = 'initRequired' | 'start' | 'destroy' | 'platformSuspend' | 'platformResume' | 'platformReset'\n\nexport interface ErrorContext {\n readonly phase: Phase\n readonly hook: Hook\n readonly moduleId: string\n readonly instanceId: string\n readonly taskId?: string\n readonly txnSeq?: number\n readonly opSeq?: number\n /**\n * For diagnostics only: an implementation-side marker indicating where the error originated,\n * e.g. \"logic.fork\" / \"initRequired\" / \"start\".\n *\n * Note: this field must be serializable and must not become a protocol anchor.\n */\n readonly origin?: string\n}\n\nexport interface ModuleRuntimeIdentity {\n readonly moduleId: string\n readonly instanceId: string\n readonly runtimeLabel?: string\n}\n\nexport type InstanceStatus = 'creating' | 'initializing' | 'ready' | 'failed' | 'terminating' | 'terminated'\n\nexport interface InitProgress {\n readonly total: number\n readonly completed: number\n readonly current?: number\n readonly startedAt?: number\n}\n\nexport type LifecycleOutcome =\n | { readonly status: 'success' }\n | {\n readonly status: 'failure'\n readonly error: import('./errorSummary.js').SerializableErrorSummary\n }\n\nexport interface LifecycleStatus {\n readonly identity: ModuleRuntimeIdentity\n readonly status: InstanceStatus\n readonly initOutcome?: LifecycleOutcome\n readonly initProgress?: InitProgress\n}\n\nexport interface TaskRef {\n readonly taskId: string\n readonly kind: TaskKind\n readonly order: number\n readonly name?: string\n readonly fatalOnFailure?: boolean\n}\n\nexport interface LifecycleTask extends TaskRef {\n readonly effect: Effect.Effect<void, never, any>\n}\n\nexport interface Budgets {\n /** Per-instance lifecycle event budget (aligned with specs/011 data-model; default ≤ 20). */\n readonly maxEventsPerInstance: number\n /** Per-event size budget (aligned with specs/011 data-model; default ≤ 4KB). */\n readonly maxEventBytes: number\n}\n\nexport interface LifecycleManager {\n readonly identity: ModuleRuntimeIdentity\n readonly budgets: Budgets\n\n readonly registerPlatformSuspend: (\n effect: Effect.Effect<void, never, any>,\n options?: { readonly name?: string },\n ) => void\n readonly registerPlatformResume: (\n effect: Effect.Effect<void, never, any>,\n options?: { readonly name?: string },\n ) => void\n readonly registerPlatformReset: (\n effect: Effect.Effect<void, never, any>,\n options?: { readonly name?: string },\n ) => void\n\n readonly registerInitRequired: (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => void\n readonly registerStart: (\n effect: Effect.Effect<void, never, any>,\n options?: { readonly name?: string; readonly fatalOnFailure?: boolean },\n ) => void\n readonly registerDestroy: (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => void\n readonly registerOnError: (\n handler: (cause: Cause.Cause<unknown>, context: ErrorContext) => Effect.Effect<void, never, any>,\n ) => void\n\n readonly getStatus: Effect.Effect<LifecycleStatus>\n readonly setStatus: (\n status: InstanceStatus,\n patch?: {\n readonly initOutcome?: LifecycleOutcome | undefined\n readonly initProgress?: InitProgress | undefined\n readonly runtimeLabel?: string | undefined\n },\n ) => Effect.Effect<void>\n\n readonly notifyError: (cause: Cause.Cause<unknown>, context: ErrorContext) => Effect.Effect<void, never, any>\n\n readonly runPlatformSuspend: Effect.Effect<void, never, any>\n readonly runPlatformResume: Effect.Effect<void, never, any>\n readonly runPlatformReset: Effect.Effect<void, never, any>\n\n readonly runInitRequired: Effect.Effect<void, unknown, any>\n readonly runStart: Effect.Effect<void, never, any>\n readonly runDestroy: Effect.Effect<void, never, any>\n\n /** Diagnostics only: whether any onError handler has been registered. */\n readonly hasOnErrorHandlers: Effect.Effect<boolean>\n\n /** Tests/diagnostics only: read a snapshot of registered tasks (immutable view). */\n readonly getTaskSnapshot: Effect.Effect<\n Readonly<{\n readonly initRequired: ReadonlyArray<TaskRef>\n readonly start: ReadonlyArray<TaskRef>\n readonly destroy: ReadonlyArray<TaskRef>\n readonly platformSuspend: ReadonlyArray<TaskRef>\n readonly platformResume: ReadonlyArray<TaskRef>\n readonly platformReset: ReadonlyArray<TaskRef>\n }>,\n never,\n never\n >\n}\n\nexport const LifecycleContext = Context.GenericTag<LifecycleManager>('@logixjs/LifecycleManager')\n\nconst safeRun = (label: string, eff: Effect.Effect<void, any, any>) =>\n eff.pipe(\n Effect.matchCauseEffect({\n onSuccess: () => Effect.void,\n onFailure: (cause) => Effect.logError(`[${label}] failed: ${Cause.pretty(cause)}`),\n }),\n )\n\nconst makeTaskId = (kind: TaskKind, order: number): string => `${kind}:${order}`\n\nexport const makeLifecycleManager = (identity: ModuleRuntimeIdentity): Effect.Effect<LifecycleManager> =>\n Effect.gen(function* () {\n const budgets: Budgets = {\n maxEventsPerInstance: 20,\n maxEventBytes: 4 * 1024,\n }\n\n const statusRef = yield* Ref.make<LifecycleStatus>({\n identity,\n status: 'creating',\n })\n\n const initRequired: LifecycleTask[] = []\n const start: LifecycleTask[] = []\n const destroy: LifecycleTask[] = []\n const platformSuspend: LifecycleTask[] = []\n const platformResume: LifecycleTask[] = []\n const platformReset: LifecycleTask[] = []\n const onErrorHandlers: Array<\n (cause: Cause.Cause<unknown>, context: ErrorContext) => Effect.Effect<void, never, any>\n > = []\n\n const getStatus: Effect.Effect<LifecycleStatus> = Ref.get(statusRef)\n\n const recordPhase = (phase: Phase, name: string, payload?: unknown): Effect.Effect<void, never, any> =>\n Debug.record({\n type: 'lifecycle:phase',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n phase,\n name,\n payload,\n })\n\n const setStatus = (\n status: InstanceStatus,\n patch?: {\n readonly initOutcome?: LifecycleOutcome | undefined\n readonly initProgress?: InitProgress | undefined\n readonly runtimeLabel?: string | undefined\n },\n ) =>\n Ref.update(statusRef, (prev) => ({\n ...prev,\n identity: {\n ...prev.identity,\n ...(patch?.runtimeLabel ? { runtimeLabel: patch.runtimeLabel } : null),\n },\n status,\n ...(patch?.initOutcome !== undefined ? { initOutcome: patch.initOutcome } : null),\n ...(patch?.initProgress !== undefined ? { initProgress: patch.initProgress } : null),\n }))\n\n const registerInitRequired = (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => {\n const order = initRequired.length\n initRequired.push({\n taskId: makeTaskId('initRequired', order),\n kind: 'initRequired',\n order,\n name: options?.name,\n effect,\n })\n }\n\n const registerStart = (\n effect: Effect.Effect<void, never, any>,\n options?: { readonly name?: string; readonly fatalOnFailure?: boolean },\n ) => {\n const order = start.length\n start.push({\n taskId: makeTaskId('start', order),\n kind: 'start',\n order,\n name: options?.name,\n fatalOnFailure: options?.fatalOnFailure,\n effect,\n })\n }\n\n const registerDestroy = (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => {\n const order = destroy.length\n destroy.push({\n taskId: makeTaskId('destroy', order),\n kind: 'destroy',\n order,\n name: options?.name,\n effect,\n })\n }\n\n const registerOnError = (\n handler: (cause: Cause.Cause<unknown>, context: ErrorContext) => Effect.Effect<void, never, any>,\n ) => {\n onErrorHandlers.push(handler)\n }\n\n const registerPlatformSuspend = (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => {\n const order = platformSuspend.length\n platformSuspend.push({\n taskId: makeTaskId('platformSuspend', order),\n kind: 'platformSuspend',\n order,\n name: options?.name,\n effect,\n })\n }\n\n const registerPlatformResume = (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => {\n const order = platformResume.length\n platformResume.push({\n taskId: makeTaskId('platformResume', order),\n kind: 'platformResume',\n order,\n name: options?.name,\n effect,\n })\n }\n\n const registerPlatformReset = (effect: Effect.Effect<void, never, any>, options?: { readonly name?: string }) => {\n const order = platformReset.length\n platformReset.push({\n taskId: makeTaskId('platformReset', order),\n kind: 'platformReset',\n order,\n name: options?.name,\n effect,\n })\n }\n\n const notifyError = (cause: Cause.Cause<unknown>, context: ErrorContext) => {\n // Interrupt/cancel should not be reported as an error.\n if (Cause.isInterrupted(cause)) {\n return Effect.void\n }\n\n return Debug.record({\n type: 'lifecycle:error',\n moduleId: context.moduleId,\n instanceId: context.instanceId,\n cause,\n phase: context.phase,\n hook: context.hook,\n taskId: context.taskId,\n txnSeq: context.txnSeq,\n opSeq: context.opSeq,\n origin: context.origin,\n }).pipe(\n Effect.zipRight(\n Effect.forEach(\n onErrorHandlers,\n (handler) =>\n handler(cause, context).pipe(\n Effect.catchAllCause((inner) => Effect.logError(`[lifecycle.onError] failed: ${Cause.pretty(inner)}`)),\n ),\n { discard: true },\n ),\n ),\n )\n }\n\n const runInitRequired: Effect.Effect<void, unknown, any> = Effect.gen(function* () {\n const total = initRequired.length\n if (total === 0) {\n yield* setStatus('ready', {\n initProgress: { total: 0, completed: 0 },\n initOutcome: { status: 'success' },\n })\n return\n }\n\n const startedAt = Date.now()\n yield* recordPhase('init', 'initRequired:start', { total })\n yield* setStatus('initializing', {\n initProgress: { total, completed: 0, current: 0, startedAt },\n })\n\n let completed = 0\n for (let i = 0; i < initRequired.length; i++) {\n yield* setStatus('initializing', {\n initProgress: { total, completed, current: i, startedAt },\n })\n\n const task = initRequired[i]\n const exit = yield* Effect.exit(task.effect)\n\n if (exit._tag === 'Success') {\n completed += 1\n yield* setStatus('initializing', {\n initProgress: { total, completed, current: i + 1, startedAt },\n })\n continue\n }\n\n const summary = toSerializableErrorSummary(exit.cause)\n yield* notifyError(exit.cause, {\n phase: 'init',\n hook: 'initRequired',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'initRequired',\n })\n\n yield* setStatus('failed', {\n initProgress: { total, completed, current: i, startedAt },\n initOutcome: { status: 'failure', error: summary.errorSummary },\n })\n\n return yield* Effect.failCause(exit.cause)\n }\n\n yield* recordPhase('init', 'initRequired:success', { total })\n yield* setStatus('ready', {\n initProgress: { total, completed, current: total, startedAt },\n initOutcome: { status: 'success' },\n })\n })\n\n const runStart: Effect.Effect<void, never, any> = recordPhase('run', 'start:schedule', {\n total: start.length,\n }).pipe(\n Effect.zipRight(\n Effect.forEach(\n start,\n (task) =>\n Effect.forkScoped(\n task.effect.pipe(\n Effect.catchAllCause((cause) =>\n notifyError(cause, {\n phase: 'run',\n hook: 'start',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'start',\n }),\n ),\n ),\n ).pipe(Effect.asVoid),\n { discard: true, concurrency: 'unbounded' },\n ),\n ),\n )\n\n const runDestroy: Effect.Effect<void, never, any> = Effect.gen(function* () {\n yield* recordPhase('destroy', 'destroy:start', { total: destroy.length })\n yield* setStatus('terminating')\n\n // destroy: run in reverse registration order (LIFO), best-effort (one failure does not block others).\n for (let i = destroy.length - 1; i >= 0; i--) {\n const task = destroy[i]\n yield* safeRun(\n 'lifecycle.onDestroy',\n task.effect.pipe(\n Effect.catchAllCause((cause) =>\n notifyError(cause, {\n phase: 'destroy',\n hook: 'destroy',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'destroy',\n }),\n ),\n ),\n )\n }\n\n yield* setStatus('terminated')\n yield* recordPhase('destroy', 'destroy:done', { total: destroy.length })\n })\n\n const runPlatformSuspend: Effect.Effect<void, never, any> = Effect.gen(function* () {\n if (platformSuspend.length === 0) return\n\n yield* recordPhase('platform', 'signal:suspend', { total: platformSuspend.length })\n for (const task of platformSuspend) {\n yield* safeRun(\n 'lifecycle.onSuspend',\n task.effect.pipe(\n Effect.catchAllCause((cause) =>\n notifyError(cause, {\n phase: 'platform',\n hook: 'suspend',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'platform.suspend',\n }),\n ),\n ),\n )\n }\n })\n\n const runPlatformResume: Effect.Effect<void, never, any> = Effect.gen(function* () {\n if (platformResume.length === 0) return\n\n yield* recordPhase('platform', 'signal:resume', { total: platformResume.length })\n for (const task of platformResume) {\n yield* safeRun(\n 'lifecycle.onResume',\n task.effect.pipe(\n Effect.catchAllCause((cause) =>\n notifyError(cause, {\n phase: 'platform',\n hook: 'resume',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'platform.resume',\n }),\n ),\n ),\n )\n }\n })\n\n const runPlatformReset: Effect.Effect<void, never, any> = Effect.gen(function* () {\n if (platformReset.length === 0) return\n\n yield* recordPhase('platform', 'signal:reset', { total: platformReset.length })\n for (const task of platformReset) {\n yield* safeRun(\n 'lifecycle.onReset',\n task.effect.pipe(\n Effect.catchAllCause((cause) =>\n notifyError(cause, {\n phase: 'platform',\n hook: 'reset',\n moduleId: identity.moduleId,\n instanceId: identity.instanceId,\n taskId: task.taskId,\n origin: 'platform.reset',\n }),\n ),\n ),\n )\n }\n })\n\n const getTaskSnapshot: LifecycleManager['getTaskSnapshot'] = Effect.sync(() => ({\n initRequired: initRequired.map(({ effect: _eff, ...rest }) => rest),\n start: start.map(({ effect: _eff, ...rest }) => rest),\n destroy: destroy.map(({ effect: _eff, ...rest }) => rest),\n platformSuspend: platformSuspend.map(({ effect: _eff, ...rest }) => rest),\n platformResume: platformResume.map(({ effect: _eff, ...rest }) => rest),\n platformReset: platformReset.map(({ effect: _eff, ...rest }) => rest),\n }))\n\n const hasOnErrorHandlers: LifecycleManager['hasOnErrorHandlers'] = Effect.sync(() => onErrorHandlers.length > 0)\n\n return {\n identity,\n budgets,\n registerPlatformSuspend,\n registerPlatformResume,\n registerPlatformReset,\n registerInitRequired,\n registerStart,\n registerDestroy,\n registerOnError,\n getStatus,\n setStatus,\n notifyError,\n runPlatformSuspend,\n runPlatformResume,\n runPlatformReset,\n runInitRequired,\n runStart,\n runDestroy,\n hasOnErrorHandlers,\n getTaskSnapshot,\n }\n })\n","import { Cause, Context, Effect } from 'effect'\nimport * as Debug from './DebugSink.js'\nimport { isDevEnv } from './env.js'\n\nconst phaseDiagnosticsEnabled = (): boolean => isDevEnv()\n\n/**\n * Logic diagnostics:\n * - Currently focuses on initialization noise caused by missing Env services (\"Service not found\").\n *\n * Design intent:\n * - In recommended usage, Runtime / React layers provide Env correctly.\n * - In some startup timing windows, Logic may try to read services before Env is fully provided.\n * - Such errors often occur once, do not change final semantics, but pollute logs.\n *\n * Therefore we emit a warning diagnostic via Debug, explaining likely causes and investigation paths.\n * The real error semantics are still handled by lifecycle.onError / AppRuntime.onError.\n */\n\nconst SERVICE_NOT_FOUND_PREFIX = 'Service not found:'\n\n/**\n * If the Cause contains a `Service not found: ...` error, emit a warning diagnostic:\n * - code: logic::env_service_not_found\n * - message: the original error message\n * - hint: explains this is known startup timing noise and suggests what to check\n */\nexport const emitEnvServiceNotFoundDiagnosticIfNeeded = (\n cause: Cause.Cause<unknown>,\n moduleId?: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n let pretty: string\n try {\n pretty = Cause.pretty(cause, { renderErrorCause: true })\n } catch {\n return\n }\n\n if (!pretty.includes(SERVICE_NOT_FOUND_PREFIX)) {\n return\n }\n\n // 1) Warning diagnostic for the missing Env service itself\n yield* Debug.record({\n type: 'diagnostic',\n moduleId,\n code: 'logic::env_service_not_found',\n severity: 'warning',\n message: pretty,\n hint:\n 'Logic attempted to access an Env service before it was provided. This is a known initialization timing noise in Runtime/React integration. ' +\n \"If it happens once during early startup and everything works afterward, it's likely harmless; \" +\n 'if it persists or correlates with app issues, verify Runtime.make / RuntimeProvider.layer provides the service.',\n })\n\n // 2) In some cases (e.g. accessing Env too early during Logic setup), we also want to surface\n // logic::invalid_phase to suggest moving Env access to the run section.\n //\n // Because we cannot reliably determine the phase at this point, this is only a supplemental signal.\n // The real phase guard is still handled by LogicPhaseError + emitInvalidPhaseDiagnosticIfNeeded.\n yield* Debug.record({\n type: 'diagnostic',\n moduleId,\n code: 'logic::invalid_phase',\n severity: 'error',\n message: '$.use is not allowed before Env is fully ready.',\n hint:\n 'Avoid reading services during setup or before Env is ready; ' +\n 'move Env access to the Logic run section, or wrap init via $.lifecycle.onInitRequired.',\n kind: 'env_service_not_ready',\n })\n })\n\nexport interface LogicPhaseError extends Error {\n readonly _tag: 'LogicPhaseError'\n readonly kind: string\n readonly api?: string\n readonly phase: 'setup' | 'run'\n readonly moduleId?: string\n}\n\nexport interface LogicPhaseService {\n readonly current: 'setup' | 'run'\n}\n\nexport const LogicPhaseServiceTag = Context.GenericTag<LogicPhaseService>('@logixjs/LogicPhaseService')\n\n/**\n * LogicUnitService:\n * - Injected while executing each mounted logic unit (scope = the logic unit's setup/run fiber).\n * - Used for trait provenance and other \"bound to the current logic unit\" information (aligned with 022-module logicUnitId).\n *\n * Constraints:\n * - Read-only (must not mutate runtime state); only a provenance/diagnostics anchor.\n */\nexport interface LogicUnitService {\n readonly logicUnitId: string\n readonly logicUnitIdKind: 'explicit' | 'derived'\n readonly logicUnitLabel: string\n readonly path?: string\n}\n\nexport class LogicUnitServiceTag extends Context.Tag('@logixjs/LogicUnitService')<\n LogicUnitServiceTag,\n LogicUnitService\n>() {}\n\nexport const makeLogicPhaseError = (\n kind: string,\n api: string,\n phase: 'setup' | 'run',\n moduleId?: string,\n): LogicPhaseError =>\n Object.assign(new Error(`[LogicPhaseError] ${api} is not allowed in ${phase} phase (kind=${kind}).`), {\n _tag: 'LogicPhaseError',\n kind,\n api,\n phase,\n moduleId,\n }) as LogicPhaseError\n\n/**\n * Extracts LogicPhaseError from a Cause and emits it as a diagnostic:\n * - code: logic::invalid_phase\n * - kind: concrete violation kind (e.g. use_in_setup)\n */\nexport const emitInvalidPhaseDiagnosticIfNeeded = (\n cause: Cause.Cause<unknown>,\n moduleId?: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n if (!phaseDiagnosticsEnabled()) {\n return\n }\n\n const allErrors = [...Cause.failures(cause), ...Cause.defects(cause)]\n\n for (const err of allErrors) {\n const logicErr = err as any\n if (logicErr && logicErr._tag === 'LogicPhaseError') {\n const phaseErr = logicErr as LogicPhaseError\n const hint =\n phaseErr.kind === 'use_in_setup' || phaseErr.kind === 'lifecycle_in_setup'\n ? 'The setup phase must not read Env/services or run long-lived logic; move the relevant calls to the run phase.'\n : phaseErr.kind === 'lifecycle_in_run'\n ? 'Do not register $.lifecycle.* in the run phase (setup-only). Move lifecycle registrations to the synchronous part of Module.logic builder (before return).'\n : phaseErr.kind === 'traits_in_run' || phaseErr.kind === 'traits_declare_in_run'\n ? 'Traits are frozen after setup; move $.traits.declare to LogicPlan.setup or the setup registration phase of Module.logic builder.'\n : 'Move logic to the run phase; keep setup for registrations only.'\n\n yield* Debug.record({\n type: 'diagnostic',\n moduleId: phaseErr.moduleId ?? moduleId,\n code: 'logic::invalid_phase',\n severity: 'error',\n message: `${phaseErr.api ?? phaseErr.kind} is not allowed in ${phaseErr.phase} phase.`,\n hint,\n kind: phaseErr.kind,\n })\n\n // Return after the first LogicPhaseError match.\n return\n }\n }\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAA4B;AAM9B,IAAM,uBAAuB,CAAI,MAAS,YAAmC;AAClF,SAAO,OAAO,MAAM,OAAc;AACpC;AAEA,IAAM,mBAAmB,CAAC,SAA+C;AACvE,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,UAAU,KAAK,KAAK;AAC1B,WAAO,QAAQ,SAAS,IAAI,MAAM;AAAA,EACpC;AAEA,MAAI,CAAC,MAAM,QAAQ,IAAI,EAAG,QAAO;AAEjC,QAAM,QAAuB,CAAC;AAC9B,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,QAAQ,UAAU;AAC3B,UAAI,mBAAmB,GAAG,EAAG,OAAM,KAAK,GAAG;AAC3C;AAAA,IACF;AAAA,EACF;AAEA,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO;AACT;AAEO,IAAM,uBAAuB,CAClC,MACA,YACmF;AACnF,QAAM,MAAM,OAAO,MAAM,SAAgB;AAAA,IACvC,eAAe;AAAA,MACb,aAAa;AAAA,MACb,uBAAuB;AAAA,IACzB;AAAA,EACF,CAAC;AAED,MAAI,CAAC,MAA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KAAK,OAAO,OAAO,CAAC,MAAW,EAAE,SAAS,QAAQ,EAAE,SAAS,IAAI,CAAC;AAAA,YACnF;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,IACD,SAAS,CAAC,aAA4C;AACpD,mBAAa,gBAAgB,WAAW;AACxC,aAAO,oBAAoB,QAAQ,QAAQ,QAAQ,CAAC;AAAA,IACtD;AAAA,IACA,IAAI,CAAC,WAA+B;AAClC,mBAAa,gBAAgB,MAAM;AACnC,aAAO,oBAAoB,MAAM;AAAA,IACnC;AAAA,EACF;AAEA,oBAAkB,KAAY,gBAAgB;AAE9C,SAAO;AACT;","names":["Context","Effect","Cause","Context","Effect","Effect","Cause","Context","Effect","make","api","Context","options"]}
|