lanka 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{LankaSharedStoreLocator-zS2kLu-S.d.ts → ALankaLocator-BUCCz0Q5.d.ts} +1 -47
- package/dist/ILankaReadableVM-BoPzHEPV.d.ts +72 -0
- package/dist/{ILankaScenarioVM-DpKFL3iE.d.ts → ILankaScenario-DQd9ZfUw.d.ts} +1 -30
- package/dist/{ILankaScenarioMetadata-Dj4GCqmX.d.ts → ILankaScenarioMetadata-BsDp0Bzm.d.ts} +1 -1
- package/dist/ILankaScenarioVM-DKwjbIRq.d.ts +30 -0
- package/dist/{LankaScenarioLocator-CAENLhDO.d.ts → LankaScenarioVMRegistry-DySAOaj2.d.ts} +4 -37
- package/dist/_extend/index.d.ts +235 -7
- package/dist/_extend/index.js +152 -12
- package/dist/_extend/index.js.map +1 -1
- package/dist/_internal/index.d.ts +13 -8
- package/dist/_internal/index.js +9 -3
- package/dist/_internal/index.js.map +1 -1
- package/dist/{activeRuntime-BYd2D6Lx.d.ts → activeRuntime-ByucLPhj.d.ts} +55 -4
- package/dist/bootstrap/index.d.ts +15 -10
- package/dist/bootstrap/index.js +14 -9
- package/dist/chunk-24MUFFHF.js +43 -0
- package/dist/chunk-24MUFFHF.js.map +1 -0
- package/dist/chunk-3R2NO47A.js +35 -0
- package/dist/chunk-3R2NO47A.js.map +1 -0
- package/dist/{chunk-5MAQVBI2.js → chunk-42CWYVZJ.js} +44 -61
- package/dist/chunk-42CWYVZJ.js.map +1 -0
- package/dist/{chunk-D27MREPB.js → chunk-7DQUF2QR.js} +2 -2
- package/dist/{chunk-UJEC7H6K.js → chunk-BHQ2SQ7P.js} +2 -2
- package/dist/chunk-BMF4TM2Z.js +22 -0
- package/dist/chunk-BMF4TM2Z.js.map +1 -0
- package/dist/{chunk-C2HP7CRD.js → chunk-FII3PW2G.js} +2 -2
- package/dist/{chunk-DTO27QFR.js → chunk-H5TIUKRK.js} +2 -2
- package/dist/chunk-JZJ6GXX3.js +12 -0
- package/dist/chunk-JZJ6GXX3.js.map +1 -0
- package/dist/{chunk-B7EYIAW7.js → chunk-MKKMTLOY.js} +47 -13
- package/dist/chunk-MKKMTLOY.js.map +1 -0
- package/dist/{chunk-UE2C76OR.js → chunk-N3275IPH.js} +2 -69
- package/dist/chunk-N3275IPH.js.map +1 -0
- package/dist/{chunk-O5ROO7QF.js → chunk-NWEHOMTS.js} +3 -3
- package/dist/{chunk-NDCJBO47.js → chunk-O5EUTNR6.js} +2 -2
- package/dist/{chunk-RKYKK6MN.js → chunk-RUMUFHSL.js} +2 -2
- package/dist/chunk-SBITVBF7.js +49 -0
- package/dist/chunk-SBITVBF7.js.map +1 -0
- package/dist/{chunk-UBGXDTXC.js → chunk-SO7D5E7O.js} +22 -16
- package/dist/chunk-SO7D5E7O.js.map +1 -0
- package/dist/chunk-UDP6IXDS.js +17 -0
- package/dist/chunk-UDP6IXDS.js.map +1 -0
- package/dist/{chunk-BGVDPDX4.js → chunk-XGMXT4XZ.js} +20 -3
- package/dist/chunk-XGMXT4XZ.js.map +1 -0
- package/dist/config/index.js +3 -3
- package/dist/{createLanka-NrlvN-WQ.d.ts → createLanka-DvUGu9Hl.d.ts} +2 -2
- package/dist/{createLankaScope-BiFxNQgl.d.ts → createLankaScope-CVoV0EwO.d.ts} +1 -1
- package/dist/errors/index.js +3 -3
- package/dist/gateway/index.js +6 -6
- package/dist/index.d.ts +14 -9
- package/dist/index.js +15 -10
- package/dist/locator/gateway/lanka-gateway-locator/LankaGatewayLocator.d.ts +18 -0
- package/dist/locator/gateway/lanka-gateway-locator/LankaGatewayLocator.js +9 -0
- package/dist/locator/gateway/lanka-gateway-locator/LankaGatewayLocator.js.map +1 -0
- package/dist/locator/index.d.ts +4 -2
- package/dist/locator/index.js +6 -3
- package/dist/locator/index.js.map +1 -1
- package/dist/locator/scenario/lanka-scenario-locator/LankaScenarioLocator.d.ts +60 -0
- package/dist/locator/scenario/lanka-scenario-locator/LankaScenarioLocator.js +12 -0
- package/dist/locator/scenario/lanka-scenario-locator/LankaScenarioLocator.js.map +1 -0
- package/dist/locator/shared-store/lanka-shared-store-locator/LankaSharedStoreLocator.d.ts +22 -0
- package/dist/locator/shared-store/lanka-shared-store-locator/LankaSharedStoreLocator.js +9 -0
- package/dist/locator/shared-store/lanka-shared-store-locator/LankaSharedStoreLocator.js.map +1 -0
- package/dist/locator/singleton/lanka-singleton-locator/LankaSingletonLocator.d.ts +30 -0
- package/dist/locator/singleton/lanka-singleton-locator/LankaSingletonLocator.js +9 -0
- package/dist/locator/singleton/lanka-singleton-locator/LankaSingletonLocator.js.map +1 -0
- package/dist/logger/index.js +3 -3
- package/dist/mock/index.js +3 -3
- package/dist/scenario/index.d.ts +29 -3
- package/dist/scenario/index.js +5 -5
- package/dist/stream/index.d.ts +17 -12
- package/dist/viewmodel/index.d.ts +139 -28
- package/dist/viewmodel/index.js +95 -126
- package/dist/viewmodel/index.js.map +1 -1
- package/package.json +3 -4
- package/skills/lanka-core/SKILL.md +18 -16
- package/skills/lanka-core/reference.md +135 -58
- package/skills/lanka-packages/SKILL.md +94 -22
- package/dist/chunk-5MAQVBI2.js.map +0 -1
- package/dist/chunk-B7EYIAW7.js.map +0 -1
- package/dist/chunk-BGVDPDX4.js.map +0 -1
- package/dist/chunk-UBGXDTXC.js.map +0 -1
- package/dist/chunk-UE2C76OR.js.map +0 -1
- /package/dist/{chunk-D27MREPB.js.map → chunk-7DQUF2QR.js.map} +0 -0
- /package/dist/{chunk-UJEC7H6K.js.map → chunk-BHQ2SQ7P.js.map} +0 -0
- /package/dist/{chunk-C2HP7CRD.js.map → chunk-FII3PW2G.js.map} +0 -0
- /package/dist/{chunk-DTO27QFR.js.map → chunk-H5TIUKRK.js.map} +0 -0
- /package/dist/{chunk-O5ROO7QF.js.map → chunk-NWEHOMTS.js.map} +0 -0
- /package/dist/{chunk-NDCJBO47.js.map → chunk-O5EUTNR6.js.map} +0 -0
- /package/dist/{chunk-RKYKK6MN.js.map → chunk-RUMUFHSL.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/viewmodel/_abstractions/lanka-vm-environment/ALankaVMEnvironment.ts","../../src/viewmodel/_abstractions/lanka-vm/ALankaVM.ts","../../src/viewmodel/_internal/create-lanka-blind-spot-trap/createLankaBlindSpotTrap.ts","../../src/viewmodel/_internal/create-lanka-scenario-binder/createLankaScenarioBinder.ts","../../src/viewmodel/_internal/create-lanka-tracked-hook/createLankaTrackedHook.ts","../../src/viewmodel/_utils/resolve-lanka-dependency/resolveLankaDependency.ts","../../src/viewmodel/_factories/create-lanka-vm/createLankaVM.ts","../../src/viewmodel/_internal/create-lazy-lanka-hook/createLazyLankaHook.ts","../../src/viewmodel/_factories/create-lazy-lanka-vm/createLazyLankaVM.ts","../../src/viewmodel/_abstractions/lanka-stateless-vm/ALankaStatelessVM.ts","../../src/viewmodel/_factories/create-stateless-lanka-vm/createStatelessLankaVM.ts","../../src/viewmodel/_factories/create-lazy-stateless-lanka-vm/createLazyStatelessLankaVM.ts","../../src/viewmodel/_factories/create-shared-store-lanka-vm/createSharedStoreLankaVM.ts","../../src/viewmodel/_factories/create-lazy-shared-store-lanka-vm/createLazySharedStoreLankaVM.ts","../../src/viewmodel/_abstractions/lanka-shared-store-vm/ALankaSharedStoreVM.ts","../../src/viewmodel/_abstractions/lanka-shared-store/ALankaSharedStore.ts","../../src/viewmodel/_factories/create-lanka-shared-store/createLankaSharedStore.ts"],"sourcesContent":["import type { ILankaVMLifecycleHooks } from \"../../_interfaces/ILankaVMLifecycleHooks\";\n\n/**\n * What every ViewModel is given, and the two moments it is told about.\n *\n * The three ViewModel shapes — stateful, stateless, over a shared store — differ\n * in where their state lives and in nothing else about this: each is handed a\n * data layer and a set of collaborators, and each is told when its scenarios are\n * bound and when they are about to be unbound.\n *\n * Stated once because a fifth hook added to two of the three is exactly the\n * divergence `skills/parity/SKILL.md` is written against, and three copies of a\n * default is how that starts.\n *\n * It is not a role and nothing extends it directly: the three bases do, and a\n * consumer extends one of them.\n */\nexport abstract class ALankaVMEnvironment<\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> {\n\t/** What `createGateways` answered: the data layer, kept apart from services. */\n\tprotected gateways!: TGateways;\n\n\t/** What `createServices` answered: everything that is not a gateway. */\n\tprotected services!: Services;\n\n\t/** The data layer, built once per ViewModel. */\n\tprotected createGateways(): TGateways {\n\t\treturn {} as TGateways;\n\t}\n\n\t/** Non-gateway collaborators, built once per ViewModel. */\n\tprotected createServices(): Services {\n\t\treturn {} as Services;\n\t}\n\n\t/**\n\t * Runs once the scenarios are bound: inside `startLanka()` for a ViewModel built\n\t * at module level, inside `build()` for one built after bootstrap — in both\n\t * cases before any screen has read the hook the build returns.\n\t */\n\tprotected onInit(): void {}\n\n\t/**\n\t * Runs when the ViewModel is released — the framework instance disposed, or a\n\t * lazy ViewModel's `dispose()` — after its scenario subscriptions are gone.\n\t */\n\tprotected onReset(): void {}\n\n\t/**\n\t * The two moments above as the scenario binder receives them: present only\n\t * where this ViewModel took them.\n\t *\n\t * Framework plumbing, not an extension point — a ViewModel overrides `onInit`\n\t * and `onReset`, never this. Protected because the three bases call it, and\n\t * named after `toStyleContext` for the same reason: a derived view of the\n\t * protected surface, assembled by the framework.\n\t *\n\t * Why \"took them\" decides anything: `onInit` runs inside `initializeScenario`,\n\t * which bootstrap alone calls, on the ViewModels registered with it.\n\t * Registration used to follow scenario bindings only, so a ViewModel that\n\t * overrode `onInit` and bound nothing was never initialised — silently. Now a\n\t * declared hook registers the ViewModel too, and a default no-op must not\n\t * count, or every ViewModel would sit in the scenario registry for nothing.\n\t * The functional bridges declare theirs as own properties over these methods,\n\t * which is what this comparison sees.\n\t */\n\tprotected toLifecycleHooks(): ILankaVMLifecycleHooks {\n\t\tconst defaults = ALankaVMEnvironment.prototype;\n\t\tconst hooks: ILankaVMLifecycleHooks = {};\n\n\t\tif (this.onInit !== defaults.onInit) hooks.onInit = () => this.onInit();\n\t\tif (this.onReset !== defaults.onReset) hooks.onReset = () => this.onReset();\n\n\t\treturn hooks;\n\t}\n}\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { create, StoreApi, UseBoundStore } from \"zustand\";\nimport { getLankaFlags } from \"../../../config/get-lanka-flags/getLankaFlags\";\nimport { createLankaBlindSpotTrap } from \"../../_internal/create-lanka-blind-spot-trap/createLankaBlindSpotTrap\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\nimport { createLankaTrackedHook } from \"../../_internal/create-lanka-tracked-hook/createLankaTrackedHook\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport type { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport type { ILankaVMContext } from \"../../_interfaces/ILankaVMContext\";\nimport type { TLankaVMEnhancer } from \"../../_types/TLankaVMEnhancer\";\nimport type { TLankaVMStateCreator } from \"../../_types/TLankaVMStateCreator\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type { TUnknownLankaScenarioBinding } from \"../../_types/TUnknownLankaScenarioBinding\";\n\n/**\n * A ViewModel written as a class: the state a screen reads, and the only place a\n * gateway is called from.\n *\n * This is the implementation of the role, and `createLankaVM` is the same thing\n * reached the other way — a subclass built from an options object. Neither style\n * can do what the other cannot, because there is nothing here to diverge from.\n *\n * The protected surface IS the functional context, member for member:\n * `set`, `get`, `gateways`, `services`, `trigger`. What the config supplies as a\n * value or a thunk, the class supplies by overriding a method of the same name —\n * `states`, `scenarioHandlers`, `enhancers`, `onInit`, `onReset` — with the two\n * dependency suppliers named `createGateways` and `createServices`, because\n * `gateways` and `services` already name what they answer. `toLifecycleHooks`\n * is protected too and is not one of these: it is how the framework reads the\n * two hooks, and a ViewModel overrides the hooks, never it.\n *\n * ```ts\n * class TodoVM extends ALankaVM<ITodoState, ITodoActions, ITodoGateways> {\n * \tprotected readonly name = \"TodoVM\";\n *\n * \tprotected states(): ITodoState {\n * \t\treturn { todos: [], isLoading: false };\n * \t}\n *\n * \tprotected createGateways(): ITodoGateways {\n * \t\treturn { todo: new TodoGateway() };\n * \t}\n *\n * \tprotected createActions(): ITodoActions {\n * \t\treturn {\n * \t\t\tload: async () => {\n * \t\t\t\tthis.set({ isLoading: true });\n * \t\t\t\tthis.set({ todos: await this.gateways.todo.list(), isLoading: false });\n * \t\t\t},\n * \t\t};\n * \t}\n * }\n *\n * export const useTodoVM = new TodoVM().build();\n * ```\n *\n * The access-tracking blind spot the functional style documents is the same one\n * here, and `enableAccessTrackingOptimization` is the same switch. A consumer\n * re-renders only for state keys it READ off the returned proxy; an action that\n * DERIVES a value reads the store through `get`, which the proxy never sees, so a\n * component whose only link to a key is such a getter never re-renders for it. In\n * development the mismatch announces itself by name rather than by a frozen\n * screen. Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs, the scenario registry and the blind-spot warning. */\n\tprotected abstract readonly name: string;\n\n\t/**\n\t * Turn off when one broad consumer reads most fields, or when an action derives\n\t * what the screen shows — proxy tracking then costs more than it saves, and in\n\t * the second case it cannot see the read at all.\n\t */\n\tprotected readonly enableAccessTrackingOptimization: boolean = true;\n\n\t/** Writes state. Available from `createActions` onwards, never before. */\n\tprotected set!: StoreApi<State & Actions & ILankaScenarioVM>[\"setState\"];\n\n\t/** Reads state. The read a tracked hook cannot see — hence the switch above. */\n\tprotected get!: () => State & Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger = <TData>(scenario: ILankaScenario<TData>, data?: TData): void => {\n\t\tscenario.trigger(data);\n\t};\n\n\t/** The reactive fields the screen reads. */\n\tprotected states(): State {\n\t\treturn {} as State;\n\t}\n\n\t/**\n\t * The scenarios this ViewModel listens to, unsubscribed for it on reset.\n\t *\n\t * Returning a FACTORY postpones building the list until bind time, which is\n\t * what a ViewModel declared at module level needs when its entries name their\n\t * scenarios through the locator. See `TLankaScenarioBindingsDeclaration`.\n\t */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tTUnknownLankaScenarioBinding<State & Actions, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** Store middleware — `persist`, `lankaDevtools` — the last one applied outermost. */\n\tprotected enhancers(): TLankaVMEnhancer<State & Actions & ILankaScenarioVM>[] {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/**\n\t * The protected surface as an object, for the functional style.\n\t *\n\t * Assembled INSIDE the class because that is the only place `protected` can be\n\t * read — a context built from outside could carry only the public half, which is\n\t * the wrong half. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tprotected toStyleContext(): ILankaVMContext<\n\t\tState & Actions & ILankaScenarioVM,\n\t\tTGateways,\n\t\tServices\n\t> {\n\t\treturn {\n\t\t\tset: this.set,\n\t\t\tget: this.get,\n\t\t\tgateways: this.gateways,\n\t\t\tservices: this.services,\n\t\t\ttrigger: this.trigger,\n\t\t};\n\t}\n\n\t/** Builds the hook a screen calls. One store per call. */\n\tpublic build(): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>> {\n\t\ttype TFullState = State & Actions & ILankaScenarioVM;\n\n\t\tlankaLogger.printViewModelLog(\"START Create VM\", this.name);\n\n\t\tconst blindSpot = createLankaBlindSpotTrap(\n\t\t\tthis.name,\n\t\t\tgetLankaFlags().isDevelopment === true,\n\t\t);\n\n\t\t// One binder per ViewModel, built OUTSIDE the state creator: a middleware may\n\t\t// run the creator more than once, and the binder's verdict on bootstrap is\n\t\t// read after the store exists. The bindings are passed through unopened — a\n\t\t// factory is called at bind time, which is the whole point of that form.\n\t\tconst hooks = this.toLifecycleHooks();\n\t\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\t\tname: this.name,\n\t\t\tbindings: this.scenarioHandlers(),\n\t\t\tcontext: () => this.toStyleContext(),\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\n\t\tconst stateCreator: TLankaVMStateCreator<TFullState> = (set, get) => {\n\t\t\tthis.set = set;\n\t\t\tthis.get = blindSpot.observeGet(get);\n\t\t\tthis.gateways = this.createGateways();\n\t\t\tthis.services = this.createServices();\n\n\t\t\tconst actions = blindSpot.observeActions(this.createActions());\n\n\t\t\treturn {\n\t\t\t\t...this.states(),\n\t\t\t\t...actions,\n\t\t\t\tinitializeScenario,\n\t\t\t\tresetScenario,\n\t\t\t};\n\t\t};\n\n\t\tconst enhancedCreator = this.enhancers().reduce<TLankaVMStateCreator<TFullState>>(\n\t\t\t(creator, enhance) => enhance(creator),\n\t\t\tstateCreator,\n\t\t);\n\n\t\tconst store = create<TFullState>()(enhancedCreator);\n\n\t\tconst registerScenarioViewModel = (viewModel: ILankaScenarioVM): void => {\n\t\t\tif (needsBootstrap) {\n\t\t\t\tlankaScenarioBootstrap.registerViewModel(viewModel, this.name);\n\t\t\t}\n\t\t};\n\n\t\tif (!this.enableAccessTrackingOptimization) {\n\t\t\tregisterScenarioViewModel(store.getState());\n\t\t\tlankaLogger.printViewModelLog(\"FINISH Create VM\", this.name);\n\n\t\t\treturn store;\n\t\t}\n\n\t\tconst useOptimizedViewModel = createLankaTrackedHook<TFullState>({\n\t\t\tsubscribe: (onChange) => store.subscribe(onChange),\n\t\t\treadState: () => store.getState(),\n\t\t\tonUntrackedChange: blindSpot.isArmed ? blindSpot.report : undefined,\n\t\t}) as UseBoundStore<StoreApi<TFullState>>;\n\n\t\tuseOptimizedViewModel.setState = store.setState;\n\t\tuseOptimizedViewModel.getState = store.getState;\n\t\tuseOptimizedViewModel.getInitialState = store.getInitialState;\n\t\tuseOptimizedViewModel.subscribe = store.subscribe;\n\n\t\tregisterScenarioViewModel(useOptimizedViewModel.getState());\n\n\t\tlankaLogger.printViewModelLog(\"FINISH Create VM\", this.name);\n\n\t\treturn useOptimizedViewModel;\n\t}\n}\n","export interface ILankaBlindSpotTrap {\n\t/** Whether the trap is armed. Everything below is inert when it is not. */\n\treadonly isArmed: boolean;\n\t/** Wraps `get` so reads made inside an action are attributed to it. */\n\tobserveGet: <TState>(get: () => TState) => () => TState;\n\t/** Wraps the actions so the trap knows which one is running. */\n\tobserveActions: <TActions extends object>(declared: TActions) => TActions;\n\t/** Reports a change that will not re-render, when the component reads the key. */\n\treport: (\n\t\ttrackedKeys: Set<string>,\n\t\tnext: Record<string, unknown>,\n\t\tprev: Record<string, unknown>,\n\t) => void;\n}\n\n/**\n * The blind spot: a key the component reads through a GETTER.\n *\n * Access tracking sees direct reads off the proxy. A key reached only inside a\n * derived getter is invisible to it, so a change to that key re-renders nothing\n * and the screen freezes with no error anywhere.\n *\n * The trap watches which keys each action reads through `get()`, and warns when\n * one of those changes without a tracked key changing with it.\n *\n * Development only: in production this is work on a hot path plus console noise\n * for somebody who does not write the code. Disarmed, every method is identity.\n */\nexport const createLankaBlindSpotTrap = (\n\tviewModelName: string,\n\tisArmed: boolean,\n): ILankaBlindSpotTrap => {\n\tif (!isArmed) {\n\t\treturn {\n\t\t\tisArmed: false,\n\t\t\tobserveGet: (get) => get,\n\t\t\tobserveActions: (declared) => declared,\n\t\t\treport: () => undefined,\n\t\t};\n\t}\n\n\t/** Action name → state keys it read through `get()`, past the proxy. */\n\tconst indirectReads = new Map<string, Set<string>>();\n\t/** Keys already warned about: a second warning adds nothing. */\n\tconst warnedKeys = new Set<string>();\n\tlet activeActionName: string | null = null;\n\n\treturn {\n\t\tisArmed: true,\n\n\t\tobserveGet<TState>(get: () => TState): () => TState {\n\t\t\treturn () => {\n\t\t\t\tconst state = get();\n\t\t\t\tconst actionName = activeActionName;\n\t\t\t\tif (actionName === null) return state;\n\n\t\t\t\treturn new Proxy(state as object, {\n\t\t\t\t\tget(target, prop, receiver) {\n\t\t\t\t\t\tif (typeof prop === \"string\") {\n\t\t\t\t\t\t\tlet keys = indirectReads.get(actionName);\n\t\t\t\t\t\t\tif (!keys) {\n\t\t\t\t\t\t\t\tkeys = new Set<string>();\n\t\t\t\t\t\t\t\tindirectReads.set(actionName, keys);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tkeys.add(prop);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Reflect.get(target, prop, receiver) as unknown;\n\t\t\t\t\t},\n\t\t\t\t}) as TState;\n\t\t\t};\n\t\t},\n\n\t\tobserveActions<TActions extends object>(declared: TActions): TActions {\n\t\t\tconst observed = { ...declared } as Record<string, unknown>;\n\n\t\t\tfor (const [name, value] of Object.entries(declared)) {\n\t\t\t\tif (typeof value !== \"function\") continue;\n\n\t\t\t\tobserved[name] = (...args: unknown[]) => {\n\t\t\t\t\t// Restored rather than cleared: actions call each other, and clearing\n\t\t\t\t\t// would attribute the caller's later reads to nobody.\n\t\t\t\t\tconst previous = activeActionName;\n\t\t\t\t\tactiveActionName = name;\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn (value as (...a: unknown[]) => unknown)(...args);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tactiveActionName = previous;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn observed as TActions;\n\t\t},\n\n\t\treport(trackedKeys, next, prev): void {\n\t\t\tfor (const [changedKey, value] of Object.entries(next)) {\n\t\t\t\tif (Object.is(value, prev[changedKey])) continue;\n\t\t\t\tif (trackedKeys.has(changedKey) || warnedKeys.has(changedKey)) continue;\n\n\t\t\t\t// Not every untracked key is a fault: not reading what you do not need\n\t\t\t\t// is exactly what tracking exists for. The fault is a key the component\n\t\t\t\t// DOES read — through a getter taken off the proxy.\n\t\t\t\tconst viaGetter = [...trackedKeys].some((key) =>\n\t\t\t\t\tindirectReads.get(key)?.has(changedKey),\n\t\t\t\t);\n\t\t\t\tif (!viaGetter) continue;\n\n\t\t\t\twarnedKeys.add(changedKey);\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[lanka] ${viewModelName}: key \"${changedKey}\" changed but no re-render will follow. ` +\n\t\t\t\t\t\t`The component reads it only through a getter, and tracking sees direct proxy reads only. ` +\n\t\t\t\t\t\t`Set enableAccessTrackingOptimization: false on this ViewModel — ` +\n\t\t\t\t\t\t`destructuring the key in the view \"for the side effect\" reads as dead code and will not survive a refactor.`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n};\n","import type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\n\n/**\n * A subscription option bag, as wide as the bus accepts.\n *\n * The binder passes it through and reads only `usedBy`; naming the rest here\n * would make this file a second declaration of the bus's options.\n */\nexport type TLankaScenarioBindingOptions = Record<string, unknown> & { usedBy?: string };\n\n/**\n * What the binder needs of a binding, and nothing more.\n *\n * Structural rather than the concrete `ILankaScenarioBinding`: three ViewModel\n * families declare their own binding type over their own context, and the binder\n * only ever calls `subscribe` and `handler`.\n */\nexport interface ILankaScenarioBindingLike<TContext, TData = unknown> {\n\tscenario: {\n\t\teventType: string;\n\t\tsubscribe: (\n\t\t\tcallback: (data?: TData) => void,\n\t\t\toptions?: TLankaScenarioBindingOptions,\n\t\t) => () => void;\n\t};\n\thandler: (context: TContext) => (data?: TData) => void;\n\toptions?: TLankaScenarioBindingOptions;\n}\n\nexport interface ILankaScenarioBinderConfig<TContext> {\n\t/** The ViewModel's name, reported to the bus as the subscriber. */\n\tname: string;\n\t/**\n\t * What to bind. A ViewModel with none still gets a working binder.\n\t *\n\t * A factory is read at BIND time — like `context` below, and for the same\n\t * reason: an entry that names its scenario through the locator must not be\n\t * built while the declaring module is evaluated. See\n\t * `TLankaScenarioBindingsDeclaration`.\n\t */\n\tbindings?: TLankaScenarioBindingsDeclaration<ILankaScenarioBindingLike<TContext>>;\n\t/** The context handlers are built with, read at bind time. */\n\tcontext: () => TContext;\n\tonInit?: (context: TContext) => void;\n\tonReset?: (context: TContext) => void;\n}\n\nexport interface ILankaScenarioBinder {\n\t/** Whether the bindings are live. */\n\treadonly isInitialized: boolean;\n\t/**\n\t * Whether bootstrap must know this ViewModel: it has scenarios to bind, or a\n\t * lifecycle moment to be told about. `onInit` runs inside `initializeScenario`,\n\t * which only bootstrap calls, so a ViewModel that is not registered never hears\n\t * either hook.\n\t */\n\treadonly needsBootstrap: boolean;\n\t/** Subscribes every binding once. A second call does nothing. */\n\tinitializeScenario: () => void;\n\t/** Releases every subscription and allows a later re-initialisation. */\n\tresetScenario: () => void;\n}\n\n/**\n * The bindings as declared, opened at the moment of binding.\n *\n * Its own function because WHEN this runs is the point: a factory form exists so\n * that the locator lookups inside the entries happen after the framework\n * instance does, and the only call site is inside `initializeScenario`.\n */\nconst readBindings = <TContext>(\n\tdeclared: TLankaScenarioBindingsDeclaration<ILankaScenarioBindingLike<TContext>> | undefined,\n): readonly ILankaScenarioBindingLike<TContext>[] =>\n\ttypeof declared === \"function\" ? declared() : (declared ?? []);\n\n/**\n * Whether bootstrap must be told about the ViewModel: something to bind, or a\n * lifecycle moment to be told about.\n *\n * Decided here, once, for all three ViewModel families: each wrote the bindings\n * half of this and none wrote the lifecycle half, so a ViewModel with a hook and\n * no scenarios was never initialised. A factory counts as bindings WITHOUT being\n * opened — opening it here would be the module-scope locator read the form\n * exists to postpone. See `TLankaScenarioBindingsDeclaration`.\n */\nconst needsBootstrap = <TContext>(config: ILankaScenarioBinderConfig<TContext>): boolean =>\n\ttypeof config.bindings === \"function\" ||\n\t(config.bindings !== undefined && config.bindings.length > 0) ||\n\tconfig.onInit !== undefined ||\n\tconfig.onReset !== undefined;\n\n/**\n * The scenario lifetime of a ViewModel: bind once, release on reset.\n *\n * All three ViewModel families need exactly this, and all three had written it\n * out — two with an array plus a Set of seen event types, one with a Map. The\n * Map is the shape kept, because it does both jobs with one structure: the key\n * prevents a second subscription to the same event, and the value is the\n * function that releases THIS subscription.\n *\n * Releasing by callback identity, which an array invites, removes the first\n * entry carrying that callback rather than the caller's own — two handlers whose\n * closures compare equal cancel each other.\n */\nexport const createLankaScenarioBinder = <TContext>(\n\tconfig: ILankaScenarioBinderConfig<TContext>,\n): ILankaScenarioBinder => {\n\tconst subscriptions = new Map<string, () => void>();\n\tlet isInitialized = false;\n\n\treturn {\n\t\tneedsBootstrap: needsBootstrap(config),\n\t\tget isInitialized(): boolean {\n\t\t\treturn isInitialized;\n\t\t},\n\n\t\tinitializeScenario(): void {\n\t\t\tif (isInitialized) return;\n\n\t\t\tconst context = config.context();\n\n\t\t\tfor (const binding of readBindings(config.bindings)) {\n\t\t\t\tconst key = binding.scenario.eventType;\n\t\t\t\tif (subscriptions.has(key)) continue;\n\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tbinding.scenario.subscribe(binding.handler(context), {\n\t\t\t\t\t\tusedBy: config.name,\n\t\t\t\t\t\t...binding.options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconfig.onInit?.(context);\n\t\t\tisInitialized = true;\n\t\t},\n\n\t\tresetScenario(): void {\n\t\t\tfor (const release of subscriptions.values()) release();\n\t\t\tsubscriptions.clear();\n\t\t\tisInitialized = false;\n\n\t\t\tconfig.onReset?.(config.context());\n\t\t},\n\t};\n};\n","import { useCallback, useRef, useSyncExternalStore } from \"react\";\n\nexport interface ILankaTrackedHookConfig<TState extends object> {\n\t/**\n\t * Subscribes to the source, reporting both states already in FULL shape.\n\t *\n\t * A shared-store ViewModel composes its full state from a store slice, so the\n\t * shaping happens here rather than inside the hook: the hook compares states,\n\t * it does not know how one is assembled.\n\t */\n\tsubscribe: (onChange: (next: TState, prev: TState) => void) => () => void;\n\t/** The current full state. */\n\treadState: () => TState;\n\t/**\n\t * Called when a change touched no tracked key, so no re-render will follow.\n\t *\n\t * The one seam the two ViewModel families differ on: only the plain factory\n\t * reports the blind spot, and only in development.\n\t */\n\tonUntrackedChange?: (\n\t\ttrackedKeys: Set<string>,\n\t\tnext: Record<string, unknown>,\n\t\tprev: Record<string, unknown>,\n\t) => void;\n}\n\nconst asRecord = (state: object): Record<string, unknown> => state as Record<string, unknown>;\n\n/**\n * The access-tracking hook every ViewModel factory renders through.\n *\n * Without a selector the component receives a Proxy that records which keys it\n * read; the next change re-renders only if one of THOSE keys moved. With a\n * selector the selector decides and tracking is bypassed.\n *\n * Both ViewModel families needed exactly this, and differed only in where the\n * state comes from — a store of their own, or a slice of a shared one. Those are\n * the two parameters above; the eighty lines below were copied.\n */\nexport const createLankaTrackedHook = <TState extends object>(\n\tconfig: ILankaTrackedHookConfig<TState>,\n) => {\n\treturn (selector?: (state: TState) => unknown): unknown => {\n\t\tconst selectorRef = useRef(selector);\n\t\tselectorRef.current = selector;\n\n\t\tconst trackedKeysRef = useRef<Set<string>>(new Set());\n\t\tconst trackedStateRef = useRef<TState | null>(null);\n\t\tconst trackedProxyRef = useRef<TState | null>(null);\n\n\t\t/**\n\t\t * Stable identity; the empty dependency list is deliberate.\n\t\t *\n\t\t * `useSyncExternalStore` keeps `subscribe` in an effect keyed on its\n\t\t * identity, so an inline arrow makes React tear the subscription down and\n\t\t * rebuild it on EVERY render of EVERY connected component — measured at 201\n\t\t * subscriptions for 200 renders. The body reads only refs and the\n\t\t * factory-scope config, never a prop or a render-scoped value, so there is\n\t\t * nothing for `[]` to capture stale.\n\t\t */\n\t\tconst subscribe = useCallback(\n\t\t\t(onStoreChange: () => void) =>\n\t\t\t\tconfig.subscribe((nextState, prevState) => {\n\t\t\t\t\tif (selectorRef.current) {\n\t\t\t\t\t\tonStoreChange();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst trackedKeys = trackedKeysRef.current;\n\t\t\t\t\tif (trackedKeys.size === 0) {\n\t\t\t\t\t\tonStoreChange();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst next = asRecord(nextState);\n\t\t\t\t\tconst prev = asRecord(prevState);\n\n\t\t\t\t\tfor (const key of trackedKeys) {\n\t\t\t\t\t\tif (!Object.is(next[key], prev[key])) {\n\t\t\t\t\t\t\tonStoreChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Reaching here means NO re-render will follow. If the changed key is\n\t\t\t\t\t// linked to the component through a getter it read, the screen froze.\n\t\t\t\t\tconfig.onUntrackedChange?.(trackedKeys, next, prev);\n\t\t\t\t}),\n\t\t\t[],\n\t\t);\n\n\t\treturn useSyncExternalStore(subscribe, readTracked, readUntracked);\n\n\t\tfunction readTracked(): unknown {\n\t\t\tconst state = config.readState();\n\t\t\tconst activeSelector = selectorRef.current;\n\n\t\t\tif (activeSelector) return activeSelector(state);\n\n\t\t\tif (trackedStateRef.current === state && trackedProxyRef.current) {\n\t\t\t\treturn trackedProxyRef.current;\n\t\t\t}\n\n\t\t\tconst trackedKeys = new Set<string>();\n\t\t\tconst proxyState = new Proxy(state, {\n\t\t\t\tget(target, prop, receiver) {\n\t\t\t\t\tif (typeof prop === \"string\") {\n\t\t\t\t\t\ttrackedKeys.add(prop);\n\t\t\t\t\t}\n\t\t\t\t\treturn Reflect.get(target, prop, receiver);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttrackedKeysRef.current = trackedKeys;\n\t\t\ttrackedStateRef.current = state;\n\t\t\ttrackedProxyRef.current = proxyState;\n\n\t\t\treturn proxyState;\n\t\t}\n\n\t\t/**\n\t\t * The server snapshot: the state itself, never the Proxy.\n\t\t *\n\t\t * Tracking exists to skip renders a client would otherwise do; a server\n\t\t * renders once, and handing it a recording Proxy would only add work whose\n\t\t * result nothing reads.\n\t\t */\n\t\tfunction readUntracked(): unknown {\n\t\t\tconst state = config.readState();\n\t\t\tconst activeSelector = selectorRef.current;\n\n\t\t\treturn activeSelector ? activeSelector(state) : state;\n\t\t}\n\t};\n};\n","/**\n * A dependency bag given either directly or as a factory.\n *\n * The factory form exists so a ViewModel declared at module level does not\n * resolve its gateways at import time: the locator needs an active framework\n * instance, and a module body runs before one exists.\n */\nexport type TLankaDependencyBag<TBag extends object> = TBag | (() => TBag) | undefined;\n\n/**\n * Reads a dependency bag, whichever form it was declared in.\n *\n * All three ViewModel factories wrote this out twice each — once for gateways,\n * once for services — which is six copies of one three-line decision.\n */\nexport const resolveLankaDependency = <TBag extends object>(\n\tdeclared: TLankaDependencyBag<TBag>,\n): TBag => {\n\tif (typeof declared === \"function\") return declared();\n\treturn declared ?? ({} as TBag);\n};\n","import { StoreApi, UseBoundStore } from \"zustand\";\nimport { ALankaVM } from \"../../_abstractions/lanka-vm/ALankaVM\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\n\n/**\n * The functional style of `ALankaVM`: a ViewModel declared as an options object.\n *\n * Everything it can do, the class can do, because this IS the class — the hooks a\n * subclass overrides arrive here as config fields of the same names, and the\n * protected surface arrives as the `ctx` every hook is handed. What a ViewModel is\n * and how it binds scenarios is documented once, on `ALankaVM`.\n *\n * ⚠️ ACCESS-TRACKING BLIND SPOT. A consumer re-renders only for state keys it READ\n * off the returned proxy. An action that DERIVES a value (`getSomeView()`) reads the\n * store through `get()`, which the proxy never sees — so a component whose only link\n * to a state key is such a getter will never re-render when that key changes.\n *\n * Set `enableAccessTrackingOptimization: false` on such a ViewModel. Do NOT patch it\n * in the view by destructuring the underlying keys for their side effect only: that\n * reads as dead code, so a refactor, an unused-variable cleanup or a lint autofix\n * removes it and the screen silently freezes again. `MeetingReportViewModel` carries\n * the worked example (its report toggles froze exactly that way, twice).\n *\n * In development the mismatch ANNOUNCES ITSELF: the framework sees that a key\n * changed, that no re-render will follow, and that the component reads that key\n * through a getter — and warns with the ViewModel and key names. \"Remember to\n * set the flag\" is not a mechanism.\n */\nexport function createLankaVM<State extends object, Actions extends object>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Record<string, never>>,\n): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Services>,\n): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Record<string, never>>,\n): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): UseBoundStore<StoreApi<State & Actions & ILankaScenarioVM>> {\n\t/**\n\t * The bridge subclass lives here rather than in a shared helper because\n\t * `toStyleContext` is `protected`: only a class body deriving from `ALankaVM`\n\t * may read it. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tclass FunctionalVM extends ALankaVM<State, Actions, TGateways, Services> {\n\t\tprotected readonly name = config.name;\n\n\t\tprotected override readonly enableAccessTrackingOptimization =\n\t\t\tconfig.enableAccessTrackingOptimization ?? true;\n\n\t\tprotected override states(): State {\n\t\t\treturn config.states ?? ({} as State);\n\t\t}\n\n\t\tprotected override scenarioHandlers(): NonNullable<typeof config.scenarioHandlers> {\n\t\t\treturn config.scenarioHandlers ?? [];\n\t\t}\n\n\t\tprotected override enhancers(): NonNullable<typeof config.enhancers> {\n\t\t\treturn config.enhancers ?? [];\n\t\t}\n\n\t\tprotected override createGateways(): TGateways {\n\t\t\treturn resolveLankaDependency(config.gateways);\n\t\t}\n\n\t\tprotected override createServices(): Services {\n\t\t\treturn resolveLankaDependency(config.services);\n\t\t}\n\n\t\tprotected createActions(): Actions {\n\t\t\treturn config.createActions(this.toStyleContext());\n\t\t}\n\n\t\t// The config's hooks become this instance's OWN `onInit`/`onReset`, assigned\n\t\t// only when declared. An unconditional method override would make the base\n\t\t// read every functional ViewModel as taking both hooks and register it with\n\t\t// bootstrap for nothing; an own property is seen by the same test a class\n\t\t// override is, and `this.onInit()` means the same thing in both styles.\n\t\tpublic constructor() {\n\t\t\tsuper();\n\t\t\tconst { onInit, onReset } = config;\n\n\t\t\tif (onInit) this.onInit = () => onInit(this.toStyleContext());\n\t\t\tif (onReset) this.onReset = () => onReset(this.toStyleContext());\n\t\t}\n\t}\n\n\treturn new FunctionalVM().build();\n}\n","import { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\n\n/**\n * What a lazy hook needs of the store behind it.\n *\n * Stated rather than cast: releasing a ViewModel means unsubscribing its\n * scenarios, so the mechanism does require this much — and every store it is\n * given has it, because `ILankaScenarioVM` is part of all three VM states.\n */\nexport interface ILankaReleasableStore {\n\tgetState: () => { resetScenario: () => void };\n}\n\n/** What every lazy factory is handed: a name for the log, and how to build. */\nexport interface ILankaLazyHookConfig<TStore> {\n\t/** The ViewModel's name, as the log line says it. */\n\tname: string;\n\t/** What the log calls this kind of ViewModel — `VM`, `slVM`, `ssVM`. */\n\tkind: string;\n\t/** Builds the real store. Called at most once until `release`. */\n\tcreate: () => TStore;\n}\n\n/** A lazily built store: everything the store is, plus `dispose`. */\nexport type TLazyLankaHook<TStore> = TStore & { dispose: () => void };\n\n/** The one store a lazy hook stands in front of, built at most once. */\ninterface ILankaLazySlot<TStore> {\n\tget: () => TStore;\n\trelease: () => void;\n}\n\n/**\n * Build once, release on demand: the state a lazy hook is made of.\n *\n * Separate from the forwarding below because they answer different questions —\n * WHEN the store exists, and WHERE a call goes. Read together they were one\n * function of fifty lines, which the composition canon calls what it is.\n */\nconst lazySlot = <TStore extends ILankaReleasableStore>(\n\tconfig: ILankaLazyHookConfig<TStore>,\n): ILankaLazySlot<TStore> => {\n\tlet store: TStore | null = null;\n\n\treturn {\n\t\tget: () => {\n\t\t\tif (!store) {\n\t\t\t\tlankaLogger.printViewModelLog(\n\t\t\t\t\t`LAZY: Creating ${config.kind} on first access`,\n\t\t\t\t\tconfig.name,\n\t\t\t\t);\n\t\t\t\tstore = config.create();\n\t\t\t}\n\t\t\treturn store;\n\t\t},\n\n\t\t/**\n\t\t * Releases the store. The next access builds a new one.\n\t\t *\n\t\t * Scenario subscriptions go first, through `resetScenario` — the same path\n\t\t * the between-tests reset uses. Dropping the reference without\n\t\t * unsubscribing would leave the bus holding handlers that write into a\n\t\t * discarded store.\n\t\t *\n\t\t * On a slot that never built, this does NOTHING: building a store in order\n\t\t * to destroy it is work with no result, and it would resurrect a ViewModel\n\t\t * a closed screen had just released.\n\t\t */\n\t\trelease: () => {\n\t\t\tif (!store) return;\n\t\t\tstore.getState().resetScenario();\n\t\t\tstore = null;\n\t\t},\n\t};\n};\n\n/**\n * How a member reaches the store: through a wrapper, always.\n *\n * The trap returns a FUNCTION for every member rather than the member itself, so\n * reading `useVM.setState` builds nothing and calling it builds the store. A trap\n * that resolved eagerly would end laziness the moment a devtool, a spread or a\n * debugger looked at the object — which is most of the ways an object is looked\n * at.\n *\n * `dispose` is the exception in both directions: it is not the store's, and it\n * must not build one.\n *\n * ## The thenable trap\n *\n * `then` is answered with `undefined`, never with a wrapper, and that line is\n * load-bearing. `await` and `Promise.resolve` decide whether a value is a\n * promise by READING `.then` and checking it is callable: a trap that returns a\n * function for every name says yes to that question for an object that is not a\n * promise. The runtime then calls it as `then(resolve, reject)`, the wrapper\n * forwards to a store member that does not exist, gets `undefined`, and neither\n * callback is ever invoked — so the `await` hangs FOREVER, with no error and no\n * stack.\n *\n * That makes `await someLazyVM` and every `async` function that RETURNS one a\n * silent deadlock, which is a shape a test harness reaches for constantly:\n * `const vm = await load()` resolves a promise with the proxy, and resolution\n * adopts a thenable. It cost an afternoon in a consumer's suite, where nineteen\n * tests timed out at 30s each and named their own first line.\n *\n * `catch` and `finally` are excluded with it. They are not part of the\n * thenable check, but an object answering `then` alone while a caller treats it\n * as a promise is the more confusing half of the same mistake — and no zustand\n * store has a member by either name.\n */\nconst PROMISE_MEMBERS: ReadonlySet<string | symbol> = new Set([\"then\", \"catch\", \"finally\"]);\n\nconst forwardEveryMember =\n\t<TStore>(slot: ILankaLazySlot<TStore>) =>\n\t(_target: object, property: string | symbol): unknown => {\n\t\tif (property === \"dispose\") return slot.release;\n\t\tif (PROMISE_MEMBERS.has(property)) return undefined;\n\n\t\treturn (...args: unknown[]) => {\n\t\t\tconst built = slot.get();\n\t\t\tconst member = (built as Record<string | symbol, unknown>)[property];\n\n\t\t\t// Every member of a zustand store is a method, and so is every one a\n\t\t\t// ViewModel adds — `getStoreState` included. A value member cannot be\n\t\t\t// classified without building the store first, which is the one thing a\n\t\t\t// property READ may not do, so it is handed back from the call instead:\n\t\t\t// `useVM.whatever()` gives the value.\n\t\t\treturn typeof member === \"function\"\n\t\t\t\t? (member as (...rest: unknown[]) => unknown).apply(built, args)\n\t\t\t\t: member;\n\t\t};\n\t};\n\n/**\n * The lazy half of every ViewModel factory, written once.\n *\n * Three factories used to carry this mechanism: build on first access, keep the\n * store, hand every member through, release on `dispose`. They differed in the\n * one line that builds — and, as it turned out, in which members they had\n * remembered to hand through.\n *\n * ## Why a Proxy rather than a list of members\n *\n * The three copies attached members BY HAND, and the three lists differed:\n * `getState` + `getInitialState` + `setState` + `subscribe` for the plain one,\n * `getState` alone for the stateless, `getState` + `getStoreState` for the\n * shared-store. Each list matched its own type, so nothing was broken — but the\n * plain one MIRRORS a zustand store, and a mirror is a promise to keep in step\n * with something somebody else releases. The day zustand adds a member, three\n * files have to hear about it.\n *\n * A Proxy cannot be incomplete. What the built store has, the lazy hook has, and\n * the type each factory declares is what narrows it back down to that variant's\n * contract — a lazy variant promises exactly what its eager twin promises, plus\n * `dispose`.\n */\nexport const createLazyLankaHook = <TStore extends ILankaReleasableStore>(\n\tconfig: ILankaLazyHookConfig<TStore>,\n): TLazyLankaHook<TStore> => {\n\tconst slot = lazySlot(config);\n\n\t// The hook itself: a function, so `useVM()` and `useVM(selector)` work before\n\t// anything is built.\n\tconst hook = (selector?: (state: unknown) => unknown): unknown => {\n\t\tconst built = slot.get() as unknown as (chosen?: unknown) => unknown;\n\t\treturn selector ? built(selector) : built();\n\t};\n\n\treturn new Proxy(hook, { get: forwardEveryMember(slot) }) as unknown as TLazyLankaHook<TStore>;\n};\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { createLazyLankaHook } from \"../../_internal/create-lazy-lanka-hook/createLazyLankaHook\";\nimport { createLankaVM } from \"../create-lanka-vm/createLankaVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\n\nexport function createLazyLankaVM<State extends object, Actions extends object>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Record<string, never>>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, Record<string, never>, Record<string, never>>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Services>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, Record<string, never>, Services>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Record<string, never>>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, TGateways, Record<string, never>>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, TGateways, Services>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\n/**\n * The lazy `createLankaVM`: nothing is built until a screen asks.\n *\n * For a ViewModel a session may never open — a settings screen, an admin panel,\n * a route behind a flag. The eager factory builds its store at module load, and\n * this one waits, which is the difference between paying for every screen the\n * application has and paying for the screens it shows.\n *\n * The mechanism is `createLazyLankaHook`, shared with the stateless and\n * shared-store variants, so all three hand through every member the store has\n * and release the same way. This file is the one line that says what gets built.\n */\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaVMConfig<State, Actions, TGateways, Services>) {\n\treturn createLazyLankaHook({\n\t\tname: config.name,\n\t\tkind: \"VM\",\n\t\tcreate: () => createLankaVM(config),\n\t});\n}\n\n/**\n * A lazy ViewModel hook: everything an ordinary store does, plus `dispose`.\n */\nexport type TLazyLankaVM<TStore, TFullState> = TStore & {\n\tgetState: () => TFullState;\n\tdispose: () => void;\n};\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\nimport type { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type {\n\tILankaStatelessScenarioBinding,\n\tILankaStatelessVMContext,\n\tTLankaSetState,\n\tTLankaStatelessVMHook,\n} from \"../../_factories/create-stateless-lanka-vm/createStatelessLankaVM\";\n\n/**\n * A ViewModel that holds no reactive state: actions, and what they orchestrate.\n *\n * The second rung of the ladder in `core/README.md` written as a class. A screen\n * that reads nothing and only DOES things — a sign-out, a share sheet, a form\n * whose fields live in the form library — pays for a zustand store it never\n * reads; this is the same role without one.\n *\n * The protected surface IS the functional context, member for member: `set`,\n * `get`, `gateways`, `services`, `trigger`. What the config supplies as a value\n * or a thunk, the class supplies by overriding a method of the same name, with\n * the two dependency suppliers named `createGateways` and `createServices`\n * because `gateways` and `services` already name what they answer.\n * `toLifecycleHooks` is protected too and is not one of these: it is how the\n * framework reads `onInit` and `onReset`, and a ViewModel overrides those,\n * never it.\n *\n * ```ts\n * class SessionVM extends ALankaStatelessVM<ISessionActions, ISessionGateways> {\n * \tprotected readonly name = \"SessionVM\";\n *\n * \tprotected createGateways(): ISessionGateways {\n * \t\treturn { session: new SessionGateway() };\n * \t}\n *\n * \tprotected createActions(): ISessionActions {\n * \t\treturn {\n * \t\t\tsignOut: async () => {\n * \t\t\t\tawait this.gateways.session.signOut();\n * \t\t\t\tthis.trigger(sessionEnded);\n * \t\t\t},\n * \t\t};\n * \t}\n * }\n *\n * export const useSessionVM = new SessionVM().build();\n * ```\n *\n * Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaStatelessVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs, the scenario registry and any warning. */\n\tprotected abstract readonly name: string;\n\n\t/** Writes state. Available from `createActions` onwards, never before. */\n\tprotected set!: TLankaSetState<Actions & ILankaScenarioVM>;\n\n\t/** Reads what the actions have written, including the actions themselves. */\n\tprotected get!: () => Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger = <TData>(scenario: ILankaScenario<TData>, data?: TData): void => {\n\t\tscenario.trigger(data);\n\t};\n\n\t/**\n\t * The scenarios this ViewModel listens to, unsubscribed for it on reset.\n\t *\n\t * Returning a FACTORY postpones building the list until bind time. See\n\t * `TLankaScenarioBindingsDeclaration`.\n\t */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tILankaStatelessScenarioBinding<unknown, Actions & ILankaScenarioVM, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/**\n\t * The protected surface as an object, for the functional style.\n\t *\n\t * Assembled INSIDE the class because that is the only place `protected` can be\n\t * read. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tprotected toStyleContext(): ILankaStatelessVMContext<\n\t\tActions & ILankaScenarioVM,\n\t\tTGateways,\n\t\tServices\n\t> {\n\t\treturn {\n\t\t\tset: this.set,\n\t\t\tget: this.get,\n\t\t\tgateways: this.gateways,\n\t\t\tservices: this.services,\n\t\t\ttrigger: this.trigger,\n\t\t};\n\t}\n\n\t/** Builds the hook a screen calls. One ViewModel per call. */\n\tpublic build(): TLankaStatelessVMHook<Actions> {\n\t\ttype TFullState = Actions & ILankaScenarioVM;\n\n\t\tlankaLogger.printViewModelLog(\"START Create slVM\", this.name);\n\n\t\tlet state = {} as TFullState;\n\n\t\tthis.get = () => state;\n\t\tthis.set = (partial, replace) => {\n\t\t\tconst next =\n\t\t\t\ttypeof partial === \"function\"\n\t\t\t\t\t? (partial as (current: TFullState) => TFullState)(state)\n\t\t\t\t\t: partial;\n\n\t\t\tstate = replace ? (next as TFullState) : { ...state, ...next };\n\t\t};\n\n\t\tthis.gateways = this.createGateways();\n\t\tthis.services = this.createServices();\n\n\t\tconst actions = this.createActions();\n\n\t\tconst hooks = this.toLifecycleHooks();\n\t\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\t\tname: this.name,\n\t\t\tbindings: this.scenarioHandlers(),\n\t\t\tcontext: () => this.toStyleContext(),\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\n\t\tstate = { ...state, ...actions, initializeScenario, resetScenario };\n\n\t\tif (needsBootstrap) {\n\t\t\tlankaScenarioBootstrap.registerViewModel(state, this.name);\n\t\t}\n\n\t\tconst useStatelessViewModel = ((selector?: (full: TFullState) => unknown) =>\n\t\t\tselector ? selector(state) : state) as TLankaStatelessVMHook<Actions>;\n\n\t\tuseStatelessViewModel.getState = () => state;\n\n\t\tlankaLogger.printViewModelLog(\"FINISH Create slVM\", this.name);\n\n\t\treturn useStatelessViewModel;\n\t}\n}\n","import type { TLankaReplayRequest } from \"../../../scenario/event-bus/lanka-event-bus-instance/LankaEventBusInstance\";\nimport type { TLankaScenarioHandler } from \"../../_types/TLankaScenarioHandler\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { ALankaStatelessVM } from \"../../_abstractions/lanka-stateless-vm/ALankaStatelessVM\";\nimport { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\n\nexport type TLankaSetState<TState> = (\n\tpartial: TState | Partial<TState> | ((state: TState) => TState | Partial<TState>),\n\treplace?: boolean,\n) => void;\n\nexport interface ILankaStatelessVMContext<\n\tTState,\n\tTGateways extends object,\n\tTServices extends object,\n> {\n\tset: TLankaSetState<TState>;\n\tget: () => TState;\n\tgateways: TGateways;\n\tservices: TServices;\n\ttrigger: <T>(scenario: ILankaScenario<T>, data?: T) => void;\n}\n\nexport interface ILankaStatelessScenarioBinding<\n\tTData,\n\tTState extends object,\n\tTGateways extends object,\n\tTServices extends object,\n> {\n\tscenario: ILankaScenario<TData>;\n\thandler: (\n\t\tctx: ILankaStatelessVMContext<TState, TGateways, TServices>,\n\t) => TLankaScenarioHandler<TData>;\n\toptions?: {\n\t\tpriority?: number;\n\t\treplay?: TLankaReplayRequest;\n\t\tusedBy?: string;\n\t};\n}\n\nexport type TLankaStatelessVMConfig<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> = {\n\tname: string;\n\tcreateActions: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => Actions;\n\t/** A FACTORY is read at bind time — see `TLankaScenarioBindingsDeclaration`. */\n\tscenarioHandlers?: TLankaScenarioBindingsDeclaration<\n\t\tILankaStatelessScenarioBinding<unknown, Actions & ILankaScenarioVM, TGateways, Services>\n\t>;\n\tservices?: Services | (() => Services);\n\tgateways?: TGateways | (() => TGateways);\n\tonInit?: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => void;\n\tonReset?: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => void;\n};\n\nexport type TLankaStatelessVMHook<Actions extends object> = {\n\t<TSelected = Actions & ILankaScenarioVM>(\n\t\tselector?: (full: Actions & ILankaScenarioVM) => TSelected,\n\t): TSelected;\n\tgetState: () => Actions & ILankaScenarioVM;\n};\n\nexport function createStatelessLankaVM<Actions extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Record<string, never>>,\n): TLankaStatelessVMHook<Actions>;\n\nexport function createStatelessLankaVM<Actions extends object, Services extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Services>,\n): TLankaStatelessVMHook<Actions>;\n\nexport function createStatelessLankaVM<Actions extends object, TGateways extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Record<string, never>>,\n): TLankaStatelessVMHook<Actions>;\n\nexport function createStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(config: TLankaStatelessVMConfig<Actions, TGateways, Services>): TLankaStatelessVMHook<Actions>;\n\n/**\n * The functional style of `ALankaStatelessVM`: actions declared as an options object.\n *\n * Same outward shape as the stateful factory — a hook-like function with\n * `getState` — and no zustand store under it, because a ViewModel that holds\n * nothing has nothing to subscribe to. What it is and how it binds scenarios is\n * documented once, on the class.\n */\nexport function createStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: TLankaStatelessVMConfig<Actions, TGateways, Services>): TLankaStatelessVMHook<Actions> {\n\t/**\n\t * The bridge subclass lives here rather than in a shared helper because\n\t * `toStyleContext` is `protected`: only a class body deriving from\n\t * `ALankaStatelessVM` may read it. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tclass FunctionalStatelessVM extends ALankaStatelessVM<Actions, TGateways, Services> {\n\t\tprotected readonly name = config.name;\n\n\t\tprotected override scenarioHandlers(): NonNullable<typeof config.scenarioHandlers> {\n\t\t\treturn config.scenarioHandlers ?? [];\n\t\t}\n\n\t\tprotected override createGateways(): TGateways {\n\t\t\treturn resolveLankaDependency(config.gateways);\n\t\t}\n\n\t\tprotected override createServices(): Services {\n\t\t\treturn resolveLankaDependency(config.services);\n\t\t}\n\n\t\tprotected createActions(): Actions {\n\t\t\treturn config.createActions(this.toStyleContext());\n\t\t}\n\n\t\t// Own properties, assigned only when declared — see the same constructor in\n\t\t// `createLankaVM` for why not a method override.\n\t\tpublic constructor() {\n\t\t\tsuper();\n\t\t\tconst { onInit, onReset } = config;\n\n\t\t\tif (onInit) this.onInit = () => onInit(this.toStyleContext());\n\t\t\tif (onReset) this.onReset = () => onReset(this.toStyleContext());\n\t\t}\n\t}\n\n\treturn new FunctionalStatelessVM().build();\n}\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { createStatelessLankaVM } from \"../create-stateless-lanka-vm/createStatelessLankaVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\nimport { createLazyLankaHook } from \"../../_internal/create-lazy-lanka-hook/createLazyLankaHook\";\n\nexport type TLankaStatelessVMConfig<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> = Omit<ILankaVMConfig<object, Actions, TGateways, Services>, \"states\"> & {\n\tstates?: never;\n};\n\ntype TLazyStatelessReturn<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n> = ReturnType<typeof createStatelessLankaVM<Actions, TGateways, Services>> & {\n\tgetState: () => Actions & ILankaScenarioVM;\n\tdispose: () => void;\n};\n\nexport function createLazyStatelessLankaVM<Actions extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Record<string, never>>,\n): TLazyStatelessReturn<Actions, Record<string, never>, Record<string, never>>;\n\nexport function createLazyStatelessLankaVM<Actions extends object, Services extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Services>,\n): TLazyStatelessReturn<Actions, Record<string, never>, Services>;\n\nexport function createLazyStatelessLankaVM<Actions extends object, TGateways extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Record<string, never>>,\n): TLazyStatelessReturn<Actions, TGateways, Record<string, never>>;\n\nexport function createLazyStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Services>,\n): TLazyStatelessReturn<Actions, TGateways, Services>;\n\n/**\n * The lazy `createStatelessLankaVM`: nothing is built until a screen asks.\n *\n * The mechanism is `createLazyLankaHook` — build on first access, hand every\n * member through, release on `dispose` — and this file is the one line that says\n * WHICH ViewModel is built. It used to be a copy of that mechanism, and the copy\n * had forgotten `setState`, `subscribe` and `getInitialState`: typed as the whole\n * store, absent at runtime.\n */\nexport function createLazyStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: TLankaStatelessVMConfig<Actions, TGateways, Services>) {\n\treturn createLazyLankaHook({\n\t\tname: config.name,\n\t\tkind: \"slVM\",\n\t\tcreate: () => createStatelessLankaVM(config),\n\t});\n}\n","import { useStore } from \"zustand\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\nimport { createLankaTrackedHook } from \"../../_internal/create-lanka-tracked-hook/createLankaTrackedHook\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport type {\n\tILankaSharedStoreVMConfig,\n\tTLankaSharedStoreVMHook,\n} from \"../../_interfaces/ILankaSharedStoreVMConfig\";\nimport type { ILankaSharedStoreVMContext } from \"../../_interfaces/ILankaSharedStoreVMContext\";\nimport { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\n\n/**\n * Factory for ViewModels backed by an external shared store instance.\n * Multiple ViewModels can be created on top of the same store instance.\n */\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n>(\n\tconfig: ILankaSharedStoreVMConfig<\n\t\tStoreState,\n\t\tActions,\n\t\tStore,\n\t\tRecord<string, never>,\n\t\tRecord<string, never>\n\t>,\n): TLankaSharedStoreVMHook<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, Record<string, never>, Services>,\n): TLankaSharedStoreVMHook<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Record<string, never>>,\n): TLankaSharedStoreVMHook<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>,\n): TLankaSharedStoreVMHook<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>) {\n\tlankaLogger.printViewModelLog(\"START Create ssVM\", config.name);\n\n\ttype TFullState = StoreState & Actions & ILankaScenarioVM;\n\n\t/**\n\t * Unsubscribe functions, plus the event types already subscribed to.\n\t *\n\t * Two separate jobs, kept separate: the array releases subscriptions, the set\n\t * prevents subscribing to one event type twice.\n\t */\n\tlet actions = {} as Actions;\n\n\tconst gateways = resolveLankaDependency(config.gateways);\n\tconst services = resolveLankaDependency(config.services);\n\n\tlet lastStoreStateRef: StoreState | null = null;\n\tlet lastFullStateRef: TFullState | null = null;\n\n\tconst buildFullState = (storeState: StoreState): TFullState => {\n\t\tif (lastStoreStateRef === storeState && lastFullStateRef) {\n\t\t\treturn lastFullStateRef;\n\t\t}\n\n\t\tlastStoreStateRef = storeState;\n\t\tlastFullStateRef = {\n\t\t\t...storeState,\n\t\t\t...actions,\n\t\t\tinitializeScenario,\n\t\t\tresetScenario,\n\t\t};\n\n\t\treturn lastFullStateRef;\n\t};\n\n\tconst getFullState = (): TFullState => buildFullState(config.store.getState());\n\n\tconst ctx: ILankaSharedStoreVMContext<StoreState, TFullState, Store, TGateways, Services> = {\n\t\tset: (partial, replace) => config.store.setState(partial, replace),\n\t\tgetStore: () => config.store.getState(),\n\t\tget: () => getFullState(),\n\t\tstore: config.store,\n\t\tgateways,\n\t\tservices,\n\t\ttrigger: (scenario, data) => scenario.trigger(data),\n\t};\n\n\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\tname: config.name,\n\t\tbindings: config.scenarioHandlers,\n\t\tcontext: () => ctx,\n\t\tonInit: config.onInit,\n\t\tonReset: config.onReset,\n\t});\n\n\tactions = config.createActions(ctx);\n\tlastStoreStateRef = null;\n\tlastFullStateRef = null;\n\tconst isAccessTrackingEnabled = config.enableAccessTrackingOptimization ?? true;\n\n\tconst useTrackedSharedStoreViewModel = createLankaTrackedHook<TFullState>({\n\t\tsubscribe: (onChange) =>\n\t\t\tconfig.store.subscribe((storeState, prevStoreState) => {\n\t\t\t\tonChange(buildFullState(storeState), buildFullState(prevStoreState));\n\t\t\t}),\n\t\treadState: getFullState,\n\t}) as TLankaSharedStoreVMHook<StoreState, Actions>;\n\n\tconst useUntrackedSharedStoreViewModel = ((selector?: (state: TFullState) => unknown) =>\n\t\tuseStore(config.store.getApi(), (storeState) => {\n\t\t\tconst fullState = buildFullState(storeState);\n\n\t\t\tif (selector) {\n\t\t\t\treturn selector(fullState);\n\t\t\t}\n\n\t\t\treturn fullState;\n\t\t})) as TLankaSharedStoreVMHook<StoreState, Actions>;\n\n\tconst useSharedStoreViewModel = isAccessTrackingEnabled\n\t\t? useTrackedSharedStoreViewModel\n\t\t: useUntrackedSharedStoreViewModel;\n\n\tuseSharedStoreViewModel.getState = () => getFullState();\n\tuseSharedStoreViewModel.getStoreState = () => config.store.getState();\n\n\tif (needsBootstrap) {\n\t\tconst scenarioViewModel: ILankaScenarioVM = {\n\t\t\tinitializeScenario,\n\t\t\tresetScenario,\n\t\t};\n\t\tlankaScenarioBootstrap.registerViewModel(scenarioViewModel, config.name);\n\t}\n\n\tlankaLogger.printViewModelLog(\"FINISH Create ssVM\", config.name);\n\n\treturn useSharedStoreViewModel;\n}\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\nimport { createLazyLankaHook } from \"../../_internal/create-lazy-lanka-hook/createLazyLankaHook\";\nimport { createSharedStoreLankaVM } from \"../create-shared-store-lanka-vm/createSharedStoreLankaVM\";\nimport type { ILankaSharedStoreVMConfig } from \"../../_interfaces/ILankaSharedStoreVMConfig\";\n\n/**\n * What a lazy shared-store ViewModel is, in the type as well as at runtime.\n *\n * The overloads used to promise the eager factory's return and nothing else, so\n * `dispose` and `getStoreState` existed on the object and not in the type: a\n * consumer releasing a closed screen's ViewModel got a compile error for calling\n * something that was there.\n */\ntype TLazySharedStoreReturn<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n> = ReturnType<typeof createSharedStoreLankaVM<StoreState, Actions, Store, TGateways, Services>> & {\n\tgetState: () => StoreState & Actions & ILankaScenarioVM;\n\tgetStoreState: () => StoreState;\n\tdispose: () => void;\n};\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n>(\n\tconfig: ILankaSharedStoreVMConfig<\n\t\tStoreState,\n\t\tActions,\n\t\tStore,\n\t\tRecord<string, never>,\n\t\tRecord<string, never>\n\t>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, Record<string, never>, Record<string, never>>;\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Record<string, never>>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, TGateways, Record<string, never>>;\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, TGateways, Services>;\n\n/**\n * The lazy `createSharedStoreLankaVM`: nothing is built until a screen asks.\n *\n * The mechanism is `createLazyLankaHook`; this file is the one line that says\n * which ViewModel gets built. `dispose` releases THIS ViewModel's scenario\n * subscriptions and never the shared store — the store is shared, other\n * ViewModels stand on it, and taking its state away is not this one's decision.\n * That is the hook's behaviour, not a special case here: it resets the scenario\n * and drops its reference, and a shared store outlives both.\n */\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>) {\n\treturn createLazyLankaHook({\n\t\tname: config.name,\n\t\tkind: \"ssVM\",\n\t\tcreate: () => createSharedStoreLankaVM(config),\n\t});\n}\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { createSharedStoreLankaVM } from \"../../_factories/create-shared-store-lanka-vm/createSharedStoreLankaVM\";\nimport type { ALankaSharedStore } from \"../lanka-shared-store/ALankaSharedStore\";\nimport type { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { ILankaSharedStoreVMContext } from \"../../_interfaces/ILankaSharedStoreVMContext\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type {\n\tILankaSharedStoreScenarioBinding,\n\tTLankaSharedStoreVMHook,\n} from \"../../_interfaces/ILankaSharedStoreVMConfig\";\n\n/**\n * A ViewModel over a store several ViewModels share, written as a class.\n *\n * The third rung of the ladder in `core/README.md`: reach for it only when two\n * ViewModels must CO-EDIT one state — a list and the badge that counts it, a\n * form and the header that says it is dirty. What the class adds over the\n * stateful base is where the state lives: in the store it is given, so `set`\n * writes there and `getStore` reads it.\n *\n * ```ts\n * class BadgeVM extends ALankaSharedStoreVM<ISelection, IBadgeActions, TodoStore> {\n * \tprotected readonly name = \"BadgeVM\";\n *\n * \tpublic constructor(store: TodoStore) {\n * \t\tsuper(store);\n * \t}\n *\n * \tprotected createActions(): IBadgeActions {\n * \t\treturn { clear: () => this.set({ selectedId: null }) };\n * \t}\n * }\n * ```\n *\n * Unlike its two siblings this one is a thin adapter rather than the\n * implementation: the store, the tracked hook and the two memoised state\n * references are the factory's, and duplicating them here would be the second\n * implementation the parity canon exists to prevent. What it gives a class-style\n * consumer is the same protected surface under the same names — plus\n * `toLifecycleHooks`, the framework's reading of `onInit`/`onReset`, which is\n * not an extension point.\n *\n * Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaSharedStoreVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs and in the scenario registry. */\n\tprotected abstract readonly name: string;\n\n\t/** The store this ViewModel and its siblings share. */\n\tprotected readonly store: Store;\n\n\t/** Writes into the shared store, which every reader of it hears about. */\n\tprotected set!: ILankaSharedStoreVMContext<\n\t\tStoreState,\n\t\tStoreState & Actions & ILankaScenarioVM,\n\t\tStore,\n\t\tTGateways,\n\t\tServices\n\t>[\"set\"];\n\n\t/** Reads the store's own state, without this ViewModel's actions on top. */\n\tprotected getStore!: () => StoreState;\n\n\t/** Reads the store's state WITH the actions, which is what a screen sees. */\n\tprotected get!: () => StoreState & Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger!: ILankaSharedStoreVMContext<\n\t\tStoreState,\n\t\tStoreState & Actions & ILankaScenarioVM,\n\t\tStore,\n\t\tTGateways,\n\t\tServices\n\t>[\"trigger\"];\n\n\tpublic constructor(store: Store) {\n\t\tsuper();\n\t\tthis.store = store;\n\t}\n\n\t/**\n\t * Turn off when one broad consumer reads most fields of the store — proxy\n\t * tracking then costs more than it saves.\n\t */\n\tprotected readonly enableAccessTrackingOptimization: boolean = true;\n\n\t/** The scenarios this ViewModel listens to, unsubscribed for it on reset. */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tILankaSharedStoreScenarioBinding<unknown, StoreState, Actions, Store, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/** Builds the hook a screen calls. One ViewModel per call. */\n\tpublic build(): TLankaSharedStoreVMHook<StoreState, Actions> {\n\t\tconst hooks = this.toLifecycleHooks();\n\n\t\treturn createSharedStoreLankaVM<StoreState, Actions, Store, TGateways, Services>({\n\t\t\tname: this.name,\n\t\t\tstore: this.store,\n\t\t\tenableAccessTrackingOptimization: this.enableAccessTrackingOptimization,\n\t\t\tgateways: () => this.createGateways(),\n\t\t\tservices: () => this.createServices(),\n\t\t\tscenarioHandlers: this.scenarioHandlers(),\n\t\t\tcreateActions: (context) => {\n\t\t\t\t// The context arrives here and becomes the protected surface, under the\n\t\t\t\t// same names it carries: a consumer who switches styles moves the same\n\t\t\t\t// call from `set(...)` to `this.set(...)` and changes nothing else.\n\t\t\t\tthis.set = context.set;\n\t\t\t\tthis.getStore = context.getStore;\n\t\t\t\tthis.get = context.get;\n\t\t\t\tthis.gateways = context.gateways;\n\t\t\t\tthis.services = context.services;\n\t\t\t\tthis.trigger = context.trigger;\n\n\t\t\t\treturn this.createActions();\n\t\t\t},\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\t}\n}\n","import { createStore, StoreApi } from \"zustand/vanilla\";\n\n/**\n * Base abstraction for shared feature stores.\n *\n * A store built on this class is resolved through the shared-store locator and\n * reused across several ViewModels.\n */\nexport abstract class ALankaSharedStore<TState extends object> {\n\tprivate readonly api: StoreApi<TState>;\n\tprivate readonly createInitialState: () => TState;\n\n\tprotected constructor(createInitialState: () => TState) {\n\t\tthis.createInitialState = createInitialState;\n\t\tthis.api = createStore<TState>()(() => this.createInitialState());\n\t}\n\n\tpublic getApi(): StoreApi<TState> {\n\t\treturn this.api;\n\t}\n\n\tpublic getState(): TState {\n\t\treturn this.api.getState();\n\t}\n\n\tpublic setState(\n\t\tpartial: TState | Partial<TState> | ((state: TState) => TState | Partial<TState>),\n\t\treplace?: boolean,\n\t): void {\n\t\tconst resolved = typeof partial === \"function\" ? partial(this.api.getState()) : partial;\n\n\t\tif (replace) {\n\t\t\tthis.api.setState(resolved as TState, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.api.setState(resolved);\n\t}\n\n\tpublic subscribe(listener: (state: TState, prevState: TState) => void) {\n\t\treturn this.api.subscribe(listener);\n\t}\n\n\t/**\n\t * Back to what the store was built with.\n\t *\n\t * Public, and it was not: while this was `protected` only a subclass could\n\t * reset, so the class style had a capability the functional one could not\n\t * reach — the asymmetry `skills/parity/SKILL.md` forbids. A shared store needs\n\t * explicit reset points (see the ladder in `core/README.md`), and the\n\t * application that owns them is outside the class either way.\n\t */\n\tpublic reset(): void {\n\t\tthis.api.setState(this.createInitialState(), true);\n\t}\n}\n","import { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\n\n/**\n * A shared store, without writing a class whose body is one function.\n *\n * A shared store is the third rung of the ladder in `core/README.md`: reach for\n * it only when several ViewModels must CO-EDIT one state. Most stores have no\n * behaviour of their own — the state and how to build it fresh is the whole\n * declaration — and this is the shape for those.\n *\n * One implementation: what comes back is an `ALankaSharedStore`, so a reset, a\n * subscription and the zustand api behave identically either way.\n */\nexport const createLankaSharedStore = <TState extends object>(\n\tcreateInitialState: () => TState,\n): ALankaSharedStore<TState> => {\n\tclass FunctionalSharedStore extends ALankaSharedStore<TState> {\n\t\tpublic constructor() {\n\t\t\tsuper(createInitial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AC1CO,IAAM,yBAAyB,CACrC,uBAC+B;AAAA,EAC/B,MAAM,8BAA8B,kBAA0B;AAAA,IACtD,cAAc;AACpB,YAAM,kBAAkB;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,IAAI,sBAAsB;AAClC;","names":["needsBootstrap","needsBootstrap","needsBootstrap"]}
|
|
1
|
+
{"version":3,"sources":["../../src/viewmodel/_abstractions/lanka-vm-environment/ALankaVMEnvironment.ts","../../src/viewmodel/_abstractions/lanka-vm/ALankaVM.ts","../../src/viewmodel/_internal/create-lanka-blind-spot-trap/createLankaBlindSpotTrap.ts","../../src/viewmodel/_internal/create-lanka-scenario-binder/createLankaScenarioBinder.ts","../../src/viewmodel/_utils/resolve-lanka-dependency/resolveLankaDependency.ts","../../src/viewmodel/_factories/create-lanka-vm/createLankaVM.ts","../../src/viewmodel/_internal/create-lazy-lanka-vm-proxy/createLazyLankaVMProxy.ts","../../src/viewmodel/_factories/create-lazy-lanka-vm/createLazyLankaVM.ts","../../src/viewmodel/_abstractions/lanka-stateless-vm/ALankaStatelessVM.ts","../../src/viewmodel/_factories/create-stateless-lanka-vm/createStatelessLankaVM.ts","../../src/viewmodel/_factories/create-lazy-stateless-lanka-vm/createLazyStatelessLankaVM.ts","../../src/viewmodel/_factories/create-shared-store-lanka-vm/createSharedStoreLankaVM.ts","../../src/viewmodel/_factories/create-lazy-shared-store-lanka-vm/createLazySharedStoreLankaVM.ts","../../src/viewmodel/_abstractions/lanka-shared-store-vm/ALankaSharedStoreVM.ts","../../src/viewmodel/_abstractions/lanka-shared-store/ALankaSharedStore.ts","../../src/viewmodel/_factories/create-lanka-shared-store/createLankaSharedStore.ts","../../src/viewmodel/_factories/create-lanka-shallow-hold/createLankaShallowHold.ts"],"sourcesContent":["import type { ILankaVMLifecycleHooks } from \"../../_interfaces/ILankaVMLifecycleHooks\";\n\n/**\n * What every ViewModel is given, and the two moments it is told about.\n *\n * The three ViewModel shapes — stateful, stateless, over a shared store — differ\n * in where their state lives and in nothing else about this: each is handed a\n * data layer and a set of collaborators, and each is told when its scenarios are\n * bound and when they are about to be unbound.\n *\n * Stated once because a fifth hook added to two of the three is exactly the\n * divergence `skills/parity/SKILL.md` is written against, and three copies of a\n * default is how that starts.\n *\n * It is not a role and nothing extends it directly: the three bases do, and a\n * consumer extends one of them.\n */\nexport abstract class ALankaVMEnvironment<\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> {\n\t/** What `createGateways` answered: the data layer, kept apart from services. */\n\tprotected gateways!: TGateways;\n\n\t/** What `createServices` answered: everything that is not a gateway. */\n\tprotected services!: Services;\n\n\t/** The data layer, built once per ViewModel. */\n\tprotected createGateways(): TGateways {\n\t\treturn {} as TGateways;\n\t}\n\n\t/** Non-gateway collaborators, built once per ViewModel. */\n\tprotected createServices(): Services {\n\t\treturn {} as Services;\n\t}\n\n\t/**\n\t * Runs once the scenarios are bound: inside `startLanka()` for a ViewModel built\n\t * at module level, inside `build()` for one built after bootstrap — in both\n\t * cases before any screen has read the hook the build returns.\n\t */\n\tprotected onInit(): void {}\n\n\t/**\n\t * Runs when the ViewModel is released — the framework instance disposed, or a\n\t * lazy ViewModel's `dispose()` — after its scenario subscriptions are gone.\n\t */\n\tprotected onReset(): void {}\n\n\t/**\n\t * The two moments above as the scenario binder receives them: present only\n\t * where this ViewModel took them.\n\t *\n\t * Framework plumbing, not an extension point — a ViewModel overrides `onInit`\n\t * and `onReset`, never this. Protected because the three bases call it, and\n\t * named after `toStyleContext` for the same reason: a derived view of the\n\t * protected surface, assembled by the framework.\n\t *\n\t * Why \"took them\" decides anything: `onInit` runs inside `initializeScenario`,\n\t * which bootstrap alone calls, on the ViewModels registered with it.\n\t * Registration used to follow scenario bindings only, so a ViewModel that\n\t * overrode `onInit` and bound nothing was never initialised — silently. Now a\n\t * declared hook registers the ViewModel too, and a default no-op must not\n\t * count, or every ViewModel would sit in the scenario registry for nothing.\n\t * The functional bridges declare theirs as own properties over these methods,\n\t * which is what this comparison sees.\n\t */\n\tprotected toLifecycleHooks(): ILankaVMLifecycleHooks {\n\t\tconst defaults = ALankaVMEnvironment.prototype;\n\t\tconst hooks: ILankaVMLifecycleHooks = {};\n\n\t\tif (this.onInit !== defaults.onInit) hooks.onInit = () => this.onInit();\n\t\tif (this.onReset !== defaults.onReset) hooks.onReset = () => this.onReset();\n\n\t\treturn hooks;\n\t}\n}\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { createStore, StoreApi } from \"zustand/vanilla\";\nimport { getLankaFlags } from \"../../../config/get-lanka-flags/getLankaFlags\";\nimport { createLankaBlindSpotTrap } from \"../../_internal/create-lanka-blind-spot-trap/createLankaBlindSpotTrap\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\nimport { lankaBlindSpotRegistry } from \"../../_internal/lanka-blind-spot-registry/lankaBlindSpotRegistry\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport type { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport type { ILankaVM } from \"../../_interfaces/ILankaVM\";\nimport type { ILankaVMContext } from \"../../_interfaces/ILankaVMContext\";\nimport type { TLankaVMEnhancer } from \"../../_types/TLankaVMEnhancer\";\nimport type { TLankaVMStateCreator } from \"../../_types/TLankaVMStateCreator\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type { TUnknownLankaScenarioBinding } from \"../../_types/TUnknownLankaScenarioBinding\";\n\n/**\n * A ViewModel written as a class: the state a screen reads, and the only place a\n * gateway is called from.\n *\n * This is the implementation of the role, and `createLankaVM` is the same thing\n * reached the other way — a subclass built from an options object. Neither style\n * can do what the other cannot, because there is nothing here to diverge from.\n *\n * The protected surface IS the functional context, member for member:\n * `set`, `get`, `gateways`, `services`, `trigger`. What the config supplies as a\n * value or a thunk, the class supplies by overriding a method of the same name —\n * `states`, `scenarioHandlers`, `enhancers`, `onInit`, `onReset` — with the two\n * dependency suppliers named `createGateways` and `createServices`, because\n * `gateways` and `services` already name what they answer. `toLifecycleHooks`\n * is protected too and is not one of these: it is how the framework reads the\n * two hooks, and a ViewModel overrides the hooks, never it.\n *\n * ```ts\n * class TodoVM extends ALankaVM<ITodoState, ITodoActions, ITodoGateways> {\n * \tprotected readonly name = \"TodoVM\";\n *\n * \tprotected states(): ITodoState {\n * \t\treturn { todos: [], isLoading: false };\n * \t}\n *\n * \tprotected createGateways(): ITodoGateways {\n * \t\treturn { todo: new TodoGateway() };\n * \t}\n *\n * \tprotected createActions(): ITodoActions {\n * \t\treturn {\n * \t\t\tload: async () => {\n * \t\t\t\tthis.set({ isLoading: true });\n * \t\t\t\tthis.set({ todos: await this.gateways.todo.list(), isLoading: false });\n * \t\t\t},\n * \t\t};\n * \t}\n * }\n *\n * export const useTodoVM = new TodoVM().build();\n * ```\n *\n * The access-tracking blind spot the functional style documents is the same one\n * here, and `enableAccessTrackingOptimization` is the same switch. A consumer\n * re-renders only for state keys it READ off the returned proxy; an action that\n * DERIVES a value reads the store through `get`, which the proxy never sees, so a\n * component whose only link to a key is such a getter never re-renders for it. In\n * development the mismatch announces itself by name rather than by a frozen\n * screen. Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs, the scenario registry and the blind-spot warning. */\n\tprotected abstract readonly name: string;\n\n\t/**\n\t * Turn off when one broad consumer reads most fields, or when an action derives\n\t * what the screen shows — proxy tracking then costs more than it saves, and in\n\t * the second case it cannot see the read at all.\n\t */\n\tprotected readonly enableAccessTrackingOptimization: boolean = true;\n\n\t/** Writes state. Available from `createActions` onwards, never before. */\n\tprotected set!: StoreApi<State & Actions & ILankaScenarioVM>[\"setState\"];\n\n\t/** Reads state. The read a tracked hook cannot see — hence the switch above. */\n\tprotected get!: () => State & Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger = <TData>(scenario: ILankaScenario<TData>, data?: TData): void => {\n\t\tscenario.trigger(data);\n\t};\n\n\t/** The reactive fields the screen reads. */\n\tprotected states(): State {\n\t\treturn {} as State;\n\t}\n\n\t/**\n\t * The scenarios this ViewModel listens to, unsubscribed for it on reset.\n\t *\n\t * Returning a FACTORY postpones building the list until bind time, which is\n\t * what a ViewModel declared at module level needs when its entries name their\n\t * scenarios through the locator. See `TLankaScenarioBindingsDeclaration`.\n\t */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tTUnknownLankaScenarioBinding<State & Actions, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** Store middleware — `persist`, `lankaDevtools` — the last one applied outermost. */\n\tprotected enhancers(): TLankaVMEnhancer<State & Actions & ILankaScenarioVM>[] {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/**\n\t * The protected surface as an object, for the functional style.\n\t *\n\t * Assembled INSIDE the class because that is the only place `protected` can be\n\t * read — a context built from outside could carry only the public half, which is\n\t * the wrong half. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tprotected toStyleContext(): ILankaVMContext<\n\t\tState & Actions & ILankaScenarioVM,\n\t\tTGateways,\n\t\tServices\n\t> {\n\t\treturn {\n\t\t\tset: this.set,\n\t\t\tget: this.get,\n\t\t\tgateways: this.gateways,\n\t\t\tservices: this.services,\n\t\t\ttrigger: this.trigger,\n\t\t};\n\t}\n\n\t/**\n\t * Builds the ViewModel a screen reads. One store per call.\n\t *\n\t * What comes back is a STORE, not a hook: `getState`, `subscribe`, `setState`,\n\t * plus the name and the tracking flag. A screen reaches it through its\n\t * framework's binding — `useLankaVM(todoVM)` from `@lankajs/react`,\n\t * `@lankajs/vue` and the rest of the shelf — and a program with no framework\n\t * at all reads `getState()` and `subscribe()` directly.\n\t */\n\tpublic build(): ILankaVM<State & Actions & ILankaScenarioVM> {\n\t\ttype TFullState = State & Actions & ILankaScenarioVM;\n\n\t\tlankaLogger.printViewModelLog(\"START Create VM\", this.name);\n\n\t\tconst blindSpot = createLankaBlindSpotTrap(\n\t\t\tthis.name,\n\t\t\tgetLankaFlags().isDevelopment === true,\n\t\t);\n\n\t\t// One binder per ViewModel, built OUTSIDE the state creator: a middleware may\n\t\t// run the creator more than once, and the binder's verdict on bootstrap is\n\t\t// read after the store exists. The bindings are passed through unopened — a\n\t\t// factory is called at bind time, which is the whole point of that form.\n\t\tconst hooks = this.toLifecycleHooks();\n\t\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\t\tname: this.name,\n\t\t\tbindings: this.scenarioHandlers(),\n\t\t\tcontext: () => this.toStyleContext(),\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\n\t\tconst stateCreator: TLankaVMStateCreator<TFullState> = (set, get) => {\n\t\t\tthis.set = set;\n\t\t\tthis.get = blindSpot.observeGet(get);\n\t\t\tthis.gateways = this.createGateways();\n\t\t\tthis.services = this.createServices();\n\n\t\t\tconst actions = blindSpot.observeActions(this.createActions());\n\n\t\t\treturn {\n\t\t\t\t...this.states(),\n\t\t\t\t...actions,\n\t\t\t\tinitializeScenario,\n\t\t\t\tresetScenario,\n\t\t\t};\n\t\t};\n\n\t\tconst enhancedCreator = this.enhancers().reduce<TLankaVMStateCreator<TFullState>>(\n\t\t\t(creator, enhance) => enhance(creator),\n\t\t\tstateCreator,\n\t\t);\n\n\t\tconst store = createStore<TFullState>()(enhancedCreator);\n\n\t\t/**\n\t\t * The two members the port adds to what a store already answers.\n\t\t *\n\t\t * A vanilla store is most of `ILankaVM` already — `getState`, `subscribe`,\n\t\t * `getInitialState`, `setState` — and what it cannot know is who it belongs\n\t\t * to and what this ViewModel decided about tracking. Attached rather than\n\t\t * wrapped, so the object a screen holds IS the store: no extra hop, and\n\t\t * every zustand middleware a consumer applied still reaches it.\n\t\t *\n\t\t * Non-enumerable, because they are a description of the ViewModel rather\n\t\t * than part of its state, and a spread of the store should not pick them up.\n\t\t */\n\t\tconst viewModel: ILankaVM<TFullState> = Object.defineProperties(store, {\n\t\t\tname: { value: this.name, enumerable: false, configurable: true },\n\t\t\tisAccessTracked: {\n\t\t\t\tvalue: this.enableAccessTrackingOptimization,\n\t\t\t\tenumerable: false,\n\t\t\t\tconfigurable: true,\n\t\t\t},\n\t\t}) as unknown as ILankaVM<TFullState>;\n\n\t\tlankaBlindSpotRegistry.remember(viewModel, blindSpot);\n\n\t\tif (needsBootstrap) {\n\t\t\tlankaScenarioBootstrap.registerViewModel(store.getState(), this.name);\n\t\t}\n\n\t\tlankaLogger.printViewModelLog(\"FINISH Create VM\", this.name);\n\n\t\treturn viewModel;\n\t}\n}\n","export interface ILankaBlindSpotTrap {\n\t/** Whether the trap is armed. Everything below is inert when it is not. */\n\treadonly isArmed: boolean;\n\t/** Wraps `get` so reads made inside an action are attributed to it. */\n\tobserveGet: <TState>(get: () => TState) => () => TState;\n\t/** Wraps the actions so the trap knows which one is running. */\n\tobserveActions: <TActions extends object>(declared: TActions) => TActions;\n\t/** Reports a change that will not re-render, when the component reads the key. */\n\treport: (\n\t\ttrackedKeys: Set<string>,\n\t\tnext: Record<string, unknown>,\n\t\tprev: Record<string, unknown>,\n\t) => void;\n}\n\n/**\n * The blind spot: a key the component reads through a GETTER.\n *\n * Access tracking sees direct reads off the proxy. A key reached only inside a\n * derived getter is invisible to it, so a change to that key re-renders nothing\n * and the screen freezes with no error anywhere.\n *\n * The trap watches which keys each action reads through `get()`, and warns when\n * one of those changes without a tracked key changing with it.\n *\n * Development only: in production this is work on a hot path plus console noise\n * for somebody who does not write the code. Disarmed, every method is identity.\n */\nexport const createLankaBlindSpotTrap = (\n\tviewModelName: string,\n\tisArmed: boolean,\n): ILankaBlindSpotTrap => {\n\tif (!isArmed) {\n\t\treturn {\n\t\t\tisArmed: false,\n\t\t\tobserveGet: (get) => get,\n\t\t\tobserveActions: (declared) => declared,\n\t\t\treport: () => undefined,\n\t\t};\n\t}\n\n\t/** Action name → state keys it read through `get()`, past the proxy. */\n\tconst indirectReads = new Map<string, Set<string>>();\n\t/** Keys already warned about: a second warning adds nothing. */\n\tconst warnedKeys = new Set<string>();\n\tlet activeActionName: string | null = null;\n\n\treturn {\n\t\tisArmed: true,\n\n\t\tobserveGet<TState>(get: () => TState): () => TState {\n\t\t\treturn () => {\n\t\t\t\tconst state = get();\n\t\t\t\tconst actionName = activeActionName;\n\t\t\t\tif (actionName === null) return state;\n\n\t\t\t\treturn new Proxy(state as object, {\n\t\t\t\t\tget(target, prop, receiver) {\n\t\t\t\t\t\tif (typeof prop === \"string\") {\n\t\t\t\t\t\t\tlet keys = indirectReads.get(actionName);\n\t\t\t\t\t\t\tif (!keys) {\n\t\t\t\t\t\t\t\tkeys = new Set<string>();\n\t\t\t\t\t\t\t\tindirectReads.set(actionName, keys);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tkeys.add(prop);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Reflect.get(target, prop, receiver) as unknown;\n\t\t\t\t\t},\n\t\t\t\t}) as TState;\n\t\t\t};\n\t\t},\n\n\t\tobserveActions<TActions extends object>(declared: TActions): TActions {\n\t\t\tconst observed = { ...declared } as Record<string, unknown>;\n\n\t\t\tfor (const [name, value] of Object.entries(declared)) {\n\t\t\t\tif (typeof value !== \"function\") continue;\n\n\t\t\t\tobserved[name] = (...args: unknown[]) => {\n\t\t\t\t\t// Restored rather than cleared: actions call each other, and clearing\n\t\t\t\t\t// would attribute the caller's later reads to nobody.\n\t\t\t\t\tconst previous = activeActionName;\n\t\t\t\t\tactiveActionName = name;\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn (value as (...a: unknown[]) => unknown)(...args);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tactiveActionName = previous;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn observed as TActions;\n\t\t},\n\n\t\treport(trackedKeys, next, prev): void {\n\t\t\tfor (const [changedKey, value] of Object.entries(next)) {\n\t\t\t\tif (Object.is(value, prev[changedKey])) continue;\n\t\t\t\tif (trackedKeys.has(changedKey) || warnedKeys.has(changedKey)) continue;\n\n\t\t\t\t// Not every untracked key is a fault: not reading what you do not need\n\t\t\t\t// is exactly what tracking exists for. The fault is a key the component\n\t\t\t\t// DOES read — through a getter taken off the proxy.\n\t\t\t\tconst viaGetter = [...trackedKeys].some((key) =>\n\t\t\t\t\tindirectReads.get(key)?.has(changedKey),\n\t\t\t\t);\n\t\t\t\tif (!viaGetter) continue;\n\n\t\t\t\twarnedKeys.add(changedKey);\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[lanka] ${viewModelName}: key \"${changedKey}\" changed but no re-render will follow. ` +\n\t\t\t\t\t\t`The component reads it only through a getter, and tracking sees direct proxy reads only. ` +\n\t\t\t\t\t\t`Set enableAccessTrackingOptimization: false on this ViewModel — ` +\n\t\t\t\t\t\t`destructuring the key in the view \"for the side effect\" reads as dead code and will not survive a refactor.`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n};\n","import type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\n\n/**\n * A subscription option bag, as wide as the bus accepts.\n *\n * The binder passes it through and reads only `usedBy`; naming the rest here\n * would make this file a second declaration of the bus's options.\n */\nexport type TLankaScenarioBindingOptions = Record<string, unknown> & { usedBy?: string };\n\n/**\n * What the binder needs of a binding, and nothing more.\n *\n * Structural rather than the concrete `ILankaScenarioBinding`: three ViewModel\n * families declare their own binding type over their own context, and the binder\n * only ever calls `subscribe` and `handler`.\n */\nexport interface ILankaScenarioBindingLike<TContext, TData = unknown> {\n\tscenario: {\n\t\teventType: string;\n\t\tsubscribe: (\n\t\t\tcallback: (data?: TData) => void,\n\t\t\toptions?: TLankaScenarioBindingOptions,\n\t\t) => () => void;\n\t};\n\thandler: (context: TContext) => (data?: TData) => void;\n\toptions?: TLankaScenarioBindingOptions;\n}\n\nexport interface ILankaScenarioBinderConfig<TContext> {\n\t/** The ViewModel's name, reported to the bus as the subscriber. */\n\tname: string;\n\t/**\n\t * What to bind. A ViewModel with none still gets a working binder.\n\t *\n\t * A factory is read at BIND time — like `context` below, and for the same\n\t * reason: an entry that names its scenario through the locator must not be\n\t * built while the declaring module is evaluated. See\n\t * `TLankaScenarioBindingsDeclaration`.\n\t */\n\tbindings?: TLankaScenarioBindingsDeclaration<ILankaScenarioBindingLike<TContext>>;\n\t/** The context handlers are built with, read at bind time. */\n\tcontext: () => TContext;\n\tonInit?: (context: TContext) => void;\n\tonReset?: (context: TContext) => void;\n}\n\nexport interface ILankaScenarioBinder {\n\t/** Whether the bindings are live. */\n\treadonly isInitialized: boolean;\n\t/**\n\t * Whether bootstrap must know this ViewModel: it has scenarios to bind, or a\n\t * lifecycle moment to be told about. `onInit` runs inside `initializeScenario`,\n\t * which only bootstrap calls, so a ViewModel that is not registered never hears\n\t * either hook.\n\t */\n\treadonly needsBootstrap: boolean;\n\t/** Subscribes every binding once. A second call does nothing. */\n\tinitializeScenario: () => void;\n\t/** Releases every subscription and allows a later re-initialisation. */\n\tresetScenario: () => void;\n}\n\n/**\n * The bindings as declared, opened at the moment of binding.\n *\n * Its own function because WHEN this runs is the point: a factory form exists so\n * that the locator lookups inside the entries happen after the framework\n * instance does, and the only call site is inside `initializeScenario`.\n */\nconst readBindings = <TContext>(\n\tdeclared: TLankaScenarioBindingsDeclaration<ILankaScenarioBindingLike<TContext>> | undefined,\n): readonly ILankaScenarioBindingLike<TContext>[] =>\n\ttypeof declared === \"function\" ? declared() : (declared ?? []);\n\n/**\n * Whether bootstrap must be told about the ViewModel: something to bind, or a\n * lifecycle moment to be told about.\n *\n * Decided here, once, for all three ViewModel families: each wrote the bindings\n * half of this and none wrote the lifecycle half, so a ViewModel with a hook and\n * no scenarios was never initialised. A factory counts as bindings WITHOUT being\n * opened — opening it here would be the module-scope locator read the form\n * exists to postpone. See `TLankaScenarioBindingsDeclaration`.\n */\nconst needsBootstrap = <TContext>(config: ILankaScenarioBinderConfig<TContext>): boolean =>\n\ttypeof config.bindings === \"function\" ||\n\t(config.bindings !== undefined && config.bindings.length > 0) ||\n\tconfig.onInit !== undefined ||\n\tconfig.onReset !== undefined;\n\n/**\n * The scenario lifetime of a ViewModel: bind once, release on reset.\n *\n * All three ViewModel families need exactly this, and all three had written it\n * out — two with an array plus a Set of seen event types, one with a Map. The\n * Map is the shape kept, because it does both jobs with one structure: the key\n * prevents a second subscription to the same event, and the value is the\n * function that releases THIS subscription.\n *\n * Releasing by callback identity, which an array invites, removes the first\n * entry carrying that callback rather than the caller's own — two handlers whose\n * closures compare equal cancel each other.\n */\nexport const createLankaScenarioBinder = <TContext>(\n\tconfig: ILankaScenarioBinderConfig<TContext>,\n): ILankaScenarioBinder => {\n\tconst subscriptions = new Map<string, () => void>();\n\tlet isInitialized = false;\n\n\treturn {\n\t\tneedsBootstrap: needsBootstrap(config),\n\t\tget isInitialized(): boolean {\n\t\t\treturn isInitialized;\n\t\t},\n\n\t\tinitializeScenario(): void {\n\t\t\tif (isInitialized) return;\n\n\t\t\tconst context = config.context();\n\n\t\t\tfor (const binding of readBindings(config.bindings)) {\n\t\t\t\tconst key = binding.scenario.eventType;\n\t\t\t\tif (subscriptions.has(key)) continue;\n\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tbinding.scenario.subscribe(binding.handler(context), {\n\t\t\t\t\t\tusedBy: config.name,\n\t\t\t\t\t\t...binding.options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconfig.onInit?.(context);\n\t\t\tisInitialized = true;\n\t\t},\n\n\t\tresetScenario(): void {\n\t\t\tfor (const release of subscriptions.values()) release();\n\t\t\tsubscriptions.clear();\n\t\t\tisInitialized = false;\n\n\t\t\tconfig.onReset?.(config.context());\n\t\t},\n\t};\n};\n","/**\n * A dependency bag given either directly or as a factory.\n *\n * The factory form exists so a ViewModel declared at module level does not\n * resolve its gateways at import time: the locator needs an active framework\n * instance, and a module body runs before one exists.\n */\nexport type TLankaDependencyBag<TBag extends object> = TBag | (() => TBag) | undefined;\n\n/**\n * Reads a dependency bag, whichever form it was declared in.\n *\n * All three ViewModel factories wrote this out twice each — once for gateways,\n * once for services — which is six copies of one three-line decision.\n */\nexport const resolveLankaDependency = <TBag extends object>(\n\tdeclared: TLankaDependencyBag<TBag>,\n): TBag => {\n\tif (typeof declared === \"function\") return declared();\n\treturn declared ?? ({} as TBag);\n};\n","import type { ILankaVM } from \"../../_interfaces/ILankaVM\";\nimport { ALankaVM } from \"../../_abstractions/lanka-vm/ALankaVM\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\n\n/**\n * The functional style of `ALankaVM`: a ViewModel declared as an options object.\n *\n * Everything it can do, the class can do, because this IS the class — the hooks a\n * subclass overrides arrive here as config fields of the same names, and the\n * protected surface arrives as the `ctx` every hook is handed. What a ViewModel is\n * and how it binds scenarios is documented once, on `ALankaVM`.\n *\n * ⚠️ ACCESS-TRACKING BLIND SPOT. A consumer re-renders only for state keys it READ\n * off the returned proxy. An action that DERIVES a value (`getSomeView()`) reads the\n * store through `get()`, which the proxy never sees — so a component whose only link\n * to a state key is such a getter will never re-render when that key changes.\n *\n * Set `enableAccessTrackingOptimization: false` on such a ViewModel. Do NOT patch it\n * in the view by destructuring the underlying keys for their side effect only: that\n * reads as dead code, so a refactor, an unused-variable cleanup or a lint autofix\n * removes it and the screen silently freezes again. `MeetingReportViewModel` carries\n * the worked example (its report toggles froze exactly that way, twice).\n *\n * In development the mismatch ANNOUNCES ITSELF: the framework sees that a key\n * changed, that no re-render will follow, and that the component reads that key\n * through a getter — and warns with the ViewModel and key names. \"Remember to\n * set the flag\" is not a mechanism.\n */\nexport function createLankaVM<State extends object, Actions extends object>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Record<string, never>>,\n): ILankaVM<State & Actions & ILankaScenarioVM>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Services>,\n): ILankaVM<State & Actions & ILankaScenarioVM>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Record<string, never>>,\n): ILankaVM<State & Actions & ILankaScenarioVM>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): ILankaVM<State & Actions & ILankaScenarioVM>;\n\nexport function createLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): ILankaVM<State & Actions & ILankaScenarioVM> {\n\t/**\n\t * The bridge subclass lives here rather than in a shared helper because\n\t * `toStyleContext` is `protected`: only a class body deriving from `ALankaVM`\n\t * may read it. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tclass FunctionalVM extends ALankaVM<State, Actions, TGateways, Services> {\n\t\tprotected readonly name = config.name;\n\n\t\tprotected override readonly enableAccessTrackingOptimization =\n\t\t\tconfig.enableAccessTrackingOptimization ?? true;\n\n\t\tprotected override states(): State {\n\t\t\treturn config.states ?? ({} as State);\n\t\t}\n\n\t\tprotected override scenarioHandlers(): NonNullable<typeof config.scenarioHandlers> {\n\t\t\treturn config.scenarioHandlers ?? [];\n\t\t}\n\n\t\tprotected override enhancers(): NonNullable<typeof config.enhancers> {\n\t\t\treturn config.enhancers ?? [];\n\t\t}\n\n\t\tprotected override createGateways(): TGateways {\n\t\t\treturn resolveLankaDependency(config.gateways);\n\t\t}\n\n\t\tprotected override createServices(): Services {\n\t\t\treturn resolveLankaDependency(config.services);\n\t\t}\n\n\t\tprotected createActions(): Actions {\n\t\t\treturn config.createActions(this.toStyleContext());\n\t\t}\n\n\t\t// The config's hooks become this instance's OWN `onInit`/`onReset`, assigned\n\t\t// only when declared. An unconditional method override would make the base\n\t\t// read every functional ViewModel as taking both hooks and register it with\n\t\t// bootstrap for nothing; an own property is seen by the same test a class\n\t\t// override is, and `this.onInit()` means the same thing in both styles.\n\t\tpublic constructor() {\n\t\t\tsuper();\n\t\t\tconst { onInit, onReset } = config;\n\n\t\t\tif (onInit) this.onInit = () => onInit(this.toStyleContext());\n\t\t\tif (onReset) this.onReset = () => onReset(this.toStyleContext());\n\t\t}\n\t}\n\n\treturn new FunctionalVM().build();\n}\n","import { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\n\n/**\n * What a lazy ViewModel needs of the one behind it.\n *\n * Stated rather than cast: releasing a ViewModel means unsubscribing its\n * scenarios, so the mechanism does require this much — and every store it is\n * given has it, because `ILankaScenarioVM` is part of all three VM states.\n */\nexport interface ILankaReleasableStore {\n\tgetState: () => { resetScenario: () => void };\n}\n\n/**\n * What every lazy factory is handed.\n *\n * `name` and `isAccessTracked` are here rather than read off the built\n * ViewModel because they are the two members of the port that are VALUES, and a\n * property read may not build anything — see the trap below. Both are known\n * from the config the eager factory was given, so answering them costs nothing\n * and a devtool inspecting a lazy ViewModel does not construct it.\n */\nexport interface ILankaLazyVMConfig<TStore> {\n\t/** The ViewModel's name, as the log line and the port both say it. */\n\tname: string;\n\t/** What the log calls this kind of ViewModel — `VM`, `slVM`, `ssVM`. */\n\tkind: string;\n\t/** What this ViewModel decided about access tracking. */\n\tisAccessTracked: boolean;\n\t/** Builds the real ViewModel. Called at most once until `release`. */\n\tcreate: () => TStore;\n}\n\n/** A lazily built ViewModel: everything it is, plus `dispose`. */\nexport type TLazyLankaVMProxy<TStore> = TStore & { dispose: () => void };\n\n/** The one ViewModel a lazy proxy stands in front of, built at most once. */\ninterface ILankaLazySlot<TStore> {\n\tget: () => TStore;\n\trelease: () => void;\n}\n\n/**\n * Build once, release on demand: the state a lazy hook is made of.\n *\n * Separate from the forwarding below because they answer different questions —\n * WHEN the store exists, and WHERE a call goes. Read together they were one\n * function of fifty lines, which the composition canon calls what it is.\n */\nconst lazySlot = <TStore extends ILankaReleasableStore>(\n\tconfig: ILankaLazyVMConfig<TStore>,\n): ILankaLazySlot<TStore> => {\n\tlet store: TStore | null = null;\n\n\treturn {\n\t\tget: () => {\n\t\t\tif (!store) {\n\t\t\t\tlankaLogger.printViewModelLog(\n\t\t\t\t\t`LAZY: Creating ${config.kind} on first access`,\n\t\t\t\t\tconfig.name,\n\t\t\t\t);\n\t\t\t\tstore = config.create();\n\t\t\t}\n\t\t\treturn store;\n\t\t},\n\n\t\t/**\n\t\t * Releases the store. The next access builds a new one.\n\t\t *\n\t\t * Scenario subscriptions go first, through `resetScenario` — the same path\n\t\t * the between-tests reset uses. Dropping the reference without\n\t\t * unsubscribing would leave the bus holding handlers that write into a\n\t\t * discarded store.\n\t\t *\n\t\t * On a slot that never built, this does NOTHING: building a store in order\n\t\t * to destroy it is work with no result, and it would resurrect a ViewModel\n\t\t * a closed screen had just released.\n\t\t */\n\t\trelease: () => {\n\t\t\tif (!store) return;\n\t\t\tstore.getState().resetScenario();\n\t\t\tstore = null;\n\t\t},\n\t};\n};\n\n/**\n * How a member reaches the store: through a wrapper, always.\n *\n * The trap returns a FUNCTION for every member rather than the member itself, so\n * reading `useVM.setState` builds nothing and calling it builds the store. A trap\n * that resolved eagerly would end laziness the moment a devtool, a spread or a\n * debugger looked at the object — which is most of the ways an object is looked\n * at.\n *\n * `dispose` is the exception in both directions: it is not the store's, and it\n * must not build one.\n *\n * ## The thenable trap\n *\n * `then` is answered with `undefined`, never with a wrapper, and that line is\n * load-bearing. `await` and `Promise.resolve` decide whether a value is a\n * promise by READING `.then` and checking it is callable: a trap that returns a\n * function for every name says yes to that question for an object that is not a\n * promise. The runtime then calls it as `then(resolve, reject)`, the wrapper\n * forwards to a store member that does not exist, gets `undefined`, and neither\n * callback is ever invoked — so the `await` hangs FOREVER, with no error and no\n * stack.\n *\n * That makes `await someLazyVM` and every `async` function that RETURNS one a\n * silent deadlock, which is a shape a test harness reaches for constantly:\n * `const vm = await load()` resolves a promise with the proxy, and resolution\n * adopts a thenable. It cost an afternoon in a consumer's suite, where nineteen\n * tests timed out at 30s each and named their own first line.\n *\n * `catch` and `finally` are excluded with it. They are not part of the\n * thenable check, but an object answering `then` alone while a caller treats it\n * as a promise is the more confusing half of the same mistake — and no zustand\n * store has a member by either name.\n */\nconst PROMISE_MEMBERS: ReadonlySet<string | symbol> = new Set([\"then\", \"catch\", \"finally\"]);\n\nconst forwardEveryMember =\n\t<TStore>(slot: ILankaLazySlot<TStore>, config: ILankaLazyVMConfig<TStore>) =>\n\t(_target: object, property: string | symbol): unknown => {\n\t\tif (property === \"dispose\") return slot.release;\n\t\tif (PROMISE_MEMBERS.has(property)) return undefined;\n\n\t\t// The port's two VALUE members, answered from the config without building.\n\t\t// A binding reads both before it subscribes — `useLankaVM` asks\n\t\t// `isAccessTracked` on its first render — so forwarding them as functions\n\t\t// would have made every lazy ViewModel eager the moment a screen mounted,\n\t\t// which is the whole feature.\n\t\tif (property === \"name\") return config.name;\n\t\tif (property === \"isAccessTracked\") return config.isAccessTracked;\n\n\t\treturn (...args: unknown[]) => {\n\t\t\tconst built = slot.get();\n\t\t\tconst member = (built as Record<string | symbol, unknown>)[property];\n\n\t\t\t// Every remaining member of a ViewModel is a method — `getState`,\n\t\t\t// `subscribe`, `setState`, `getStoreState`. A value member cannot be\n\t\t\t// classified without building first, which is the one thing a property\n\t\t\t// READ may not do, so it is handed back from the call instead:\n\t\t\t// `lazyVM.whatever()` gives the value.\n\t\t\treturn typeof member === \"function\"\n\t\t\t\t? (member as (...rest: unknown[]) => unknown).apply(built, args)\n\t\t\t\t: member;\n\t\t};\n\t};\n\n/**\n * The lazy half of every ViewModel factory, written once.\n *\n * Three factories used to carry this mechanism: build on first access, keep the\n * store, hand every member through, release on `dispose`. They differed in the\n * one line that builds — and, as it turned out, in which members they had\n * remembered to hand through.\n *\n * ## Why a Proxy rather than a list of members\n *\n * The three copies attached members BY HAND, and the three lists differed:\n * `getState` + `getInitialState` + `setState` + `subscribe` for the plain one,\n * `getState` alone for the stateless, `getState` + `getStoreState` for the\n * shared-store. Each list matched its own type, so nothing was broken — but the\n * plain one MIRRORS a zustand store, and a mirror is a promise to keep in step\n * with something somebody else releases. The day zustand adds a member, three\n * files have to hear about it.\n *\n * A Proxy cannot be incomplete. What the built store has, the lazy hook has, and\n * the type each factory declares is what narrows it back down to that variant's\n * contract — a lazy variant promises exactly what its eager twin promises, plus\n * `dispose`.\n */\nexport const createLazyLankaVMProxy = <TStore extends ILankaReleasableStore>(\n\tconfig: ILankaLazyVMConfig<TStore>,\n): TLazyLankaVMProxy<TStore> => {\n\tconst slot = lazySlot(config);\n\n\t// An ordinary object is the target, where it used to be a function: a\n\t// ViewModel is read through a binding now, not called, so there is no call\n\t// signature left to stand in front of.\n\treturn new Proxy(\n\t\t{},\n\t\t{ get: forwardEveryMember(slot, config) },\n\t) as unknown as TLazyLankaVMProxy<TStore>;\n};\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { createLazyLankaVMProxy } from \"../../_internal/create-lazy-lanka-vm-proxy/createLazyLankaVMProxy\";\nimport { createLankaVM } from \"../create-lanka-vm/createLankaVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\n\nexport function createLazyLankaVM<State extends object, Actions extends object>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Record<string, never>>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, Record<string, never>, Record<string, never>>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, Record<string, never>, Services>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, Record<string, never>, Services>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Record<string, never>>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, TGateways, Record<string, never>>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaVMConfig<State, Actions, TGateways, Services>,\n): TLazyLankaVM<\n\tReturnType<typeof createLankaVM<State, Actions, TGateways, Services>>,\n\tState & Actions & ILankaScenarioVM\n>;\n\n/**\n * The lazy `createLankaVM`: nothing is built until a screen asks.\n *\n * For a ViewModel a session may never open — a settings screen, an admin panel,\n * a route behind a flag. The eager factory builds its store at module load, and\n * this one waits, which is the difference between paying for every screen the\n * application has and paying for the screens it shows.\n *\n * The mechanism is `createLazyLankaVMProxy`, shared with the stateless and\n * shared-store variants, so all three hand through every member the store has\n * and release the same way. This file is the one line that says what gets built.\n */\nexport function createLazyLankaVM<\n\tState extends object,\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaVMConfig<State, Actions, TGateways, Services>) {\n\treturn createLazyLankaVMProxy({\n\t\tname: config.name,\n\t\tkind: \"VM\",\n\t\tisAccessTracked: config.enableAccessTrackingOptimization ?? true,\n\t\tcreate: () => createLankaVM(config),\n\t});\n}\n\n/**\n * A lazy ViewModel hook: everything an ordinary store does, plus `dispose`.\n */\nexport type TLazyLankaVM<TStore, TFullState> = TStore & {\n\tgetState: () => TFullState;\n\tdispose: () => void;\n};\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\nimport type { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type {\n\tILankaStatelessScenarioBinding,\n\tILankaStatelessVMContext,\n\tTLankaSetState,\n} from \"../../_factories/create-stateless-lanka-vm/createStatelessLankaVM\";\nimport type { ILankaReadableVM } from \"../../_interfaces/ILankaReadableVM\";\n\n/**\n * A ViewModel that holds no reactive state: actions, and what they orchestrate.\n *\n * The second rung of the ladder in `core/README.md` written as a class. A screen\n * that reads nothing and only DOES things — a sign-out, a share sheet, a form\n * whose fields live in the form library — pays for a zustand store it never\n * reads; this is the same role without one.\n *\n * The protected surface IS the functional context, member for member: `set`,\n * `get`, `gateways`, `services`, `trigger`. What the config supplies as a value\n * or a thunk, the class supplies by overriding a method of the same name, with\n * the two dependency suppliers named `createGateways` and `createServices`\n * because `gateways` and `services` already name what they answer.\n * `toLifecycleHooks` is protected too and is not one of these: it is how the\n * framework reads `onInit` and `onReset`, and a ViewModel overrides those,\n * never it.\n *\n * ```ts\n * class SessionVM extends ALankaStatelessVM<ISessionActions, ISessionGateways> {\n * \tprotected readonly name = \"SessionVM\";\n *\n * \tprotected createGateways(): ISessionGateways {\n * \t\treturn { session: new SessionGateway() };\n * \t}\n *\n * \tprotected createActions(): ISessionActions {\n * \t\treturn {\n * \t\t\tsignOut: async () => {\n * \t\t\t\tawait this.gateways.session.signOut();\n * \t\t\t\tthis.trigger(sessionEnded);\n * \t\t\t},\n * \t\t};\n * \t}\n * }\n *\n * export const useSessionVM = new SessionVM().build();\n * ```\n *\n * Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaStatelessVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs, the scenario registry and any warning. */\n\tprotected abstract readonly name: string;\n\n\t/** Writes state. Available from `createActions` onwards, never before. */\n\tprotected set!: TLankaSetState<Actions & ILankaScenarioVM>;\n\n\t/** Reads what the actions have written, including the actions themselves. */\n\tprotected get!: () => Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger = <TData>(scenario: ILankaScenario<TData>, data?: TData): void => {\n\t\tscenario.trigger(data);\n\t};\n\n\t/**\n\t * The scenarios this ViewModel listens to, unsubscribed for it on reset.\n\t *\n\t * Returning a FACTORY postpones building the list until bind time. See\n\t * `TLankaScenarioBindingsDeclaration`.\n\t */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tILankaStatelessScenarioBinding<unknown, Actions & ILankaScenarioVM, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/**\n\t * The protected surface as an object, for the functional style.\n\t *\n\t * Assembled INSIDE the class because that is the only place `protected` can be\n\t * read. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tprotected toStyleContext(): ILankaStatelessVMContext<\n\t\tActions & ILankaScenarioVM,\n\t\tTGateways,\n\t\tServices\n\t> {\n\t\treturn {\n\t\t\tset: this.set,\n\t\t\tget: this.get,\n\t\t\tgateways: this.gateways,\n\t\t\tservices: this.services,\n\t\t\ttrigger: this.trigger,\n\t\t};\n\t}\n\n\t/**\n\t * Builds the ViewModel a screen reads. One per call.\n\t *\n\t * What comes back answers the read half of the port and nothing more: there\n\t * is no store to write to from outside, because there is no state to write.\n\t */\n\tpublic build(): ILankaReadableVM<Actions & ILankaScenarioVM> {\n\t\ttype TFullState = Actions & ILankaScenarioVM;\n\n\t\tlankaLogger.printViewModelLog(\"START Create slVM\", this.name);\n\n\t\tlet state = {} as TFullState;\n\n\t\tthis.get = () => state;\n\t\tthis.set = (partial, replace) => {\n\t\t\tconst next =\n\t\t\t\ttypeof partial === \"function\"\n\t\t\t\t\t? (partial as (current: TFullState) => TFullState)(state)\n\t\t\t\t\t: partial;\n\n\t\t\tstate = replace ? (next as TFullState) : { ...state, ...next };\n\t\t};\n\n\t\tthis.gateways = this.createGateways();\n\t\tthis.services = this.createServices();\n\n\t\tconst actions = this.createActions();\n\n\t\tconst hooks = this.toLifecycleHooks();\n\t\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\t\tname: this.name,\n\t\t\tbindings: this.scenarioHandlers(),\n\t\t\tcontext: () => this.toStyleContext(),\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\n\t\tstate = { ...state, ...actions, initializeScenario, resetScenario };\n\n\t\tif (needsBootstrap) {\n\t\t\tlankaScenarioBootstrap.registerViewModel(state, this.name);\n\t\t}\n\n\t\t/**\n\t\t * The port over a ViewModel with nothing that changes.\n\t\t *\n\t\t * `subscribe` returns an unsubscribe and never calls the listener, which is\n\t\t * the honest implementation rather than a stub: a stateless ViewModel holds\n\t\t * actions and no reactive fields, so there is no next state to report. That\n\t\t * is what lets one binding serve all three shapes without asking which it\n\t\t * was handed.\n\t\t *\n\t\t * `isAccessTracked` is false for the same reason — there are no keys whose\n\t\t * reads could be worth recording, and a binding that tried would pay for a\n\t\t * Proxy over an object that never moves.\n\t\t */\n\t\tconst statelessViewModel: ILankaReadableVM<TFullState> = {\n\t\t\tname: this.name,\n\t\t\tgetState: () => state,\n\t\t\tsubscribe: () => () => undefined,\n\t\t\tisAccessTracked: false,\n\t\t};\n\n\t\tlankaLogger.printViewModelLog(\"FINISH Create slVM\", this.name);\n\n\t\treturn statelessViewModel;\n\t}\n}\n","import type { ILankaReadableVM } from \"../../_interfaces/ILankaReadableVM\";\nimport type { TLankaReplayRequest } from \"../../../scenario/event-bus/lanka-event-bus-instance/LankaEventBusInstance\";\nimport type { TLankaScenarioHandler } from \"../../_types/TLankaScenarioHandler\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { ALankaStatelessVM } from \"../../_abstractions/lanka-stateless-vm/ALankaStatelessVM\";\nimport { ILankaScenario } from \"../../../scenario/_interfaces/ILankaScenario\";\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\n\nexport type TLankaSetState<TState> = (\n\tpartial: TState | Partial<TState> | ((state: TState) => TState | Partial<TState>),\n\treplace?: boolean,\n) => void;\n\nexport interface ILankaStatelessVMContext<\n\tTState,\n\tTGateways extends object,\n\tTServices extends object,\n> {\n\tset: TLankaSetState<TState>;\n\tget: () => TState;\n\tgateways: TGateways;\n\tservices: TServices;\n\ttrigger: <T>(scenario: ILankaScenario<T>, data?: T) => void;\n}\n\nexport interface ILankaStatelessScenarioBinding<\n\tTData,\n\tTState extends object,\n\tTGateways extends object,\n\tTServices extends object,\n> {\n\tscenario: ILankaScenario<TData>;\n\thandler: (\n\t\tctx: ILankaStatelessVMContext<TState, TGateways, TServices>,\n\t) => TLankaScenarioHandler<TData>;\n\toptions?: {\n\t\tpriority?: number;\n\t\treplay?: TLankaReplayRequest;\n\t\tusedBy?: string;\n\t};\n}\n\nexport type TLankaStatelessVMConfig<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> = {\n\tname: string;\n\tcreateActions: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => Actions;\n\t/** A FACTORY is read at bind time — see `TLankaScenarioBindingsDeclaration`. */\n\tscenarioHandlers?: TLankaScenarioBindingsDeclaration<\n\t\tILankaStatelessScenarioBinding<unknown, Actions & ILankaScenarioVM, TGateways, Services>\n\t>;\n\tservices?: Services | (() => Services);\n\tgateways?: TGateways | (() => TGateways);\n\tonInit?: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => void;\n\tonReset?: (\n\t\tctx: ILankaStatelessVMContext<Actions & ILankaScenarioVM, TGateways, Services>,\n\t) => void;\n};\n\n/**\n * @deprecated since 2.0.0 - use ILankaReadableVM, which is what a stateless\n * ViewModel now IS: `createStatelessLankaVM` answers a readable ViewModel rather\n * than a React hook, so the word \"Hook\" in this name no longer describes\n * anything. The alias is kept because a published name is never removed, and it\n * resolves to exactly the type the factory returns.\n */\nexport type TLankaStatelessVMHook<Actions extends object> = ILankaReadableVM<\n\tActions & ILankaScenarioVM\n>;\n\nexport function createStatelessLankaVM<Actions extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Record<string, never>>,\n): ILankaReadableVM<Actions & ILankaScenarioVM>;\n\nexport function createStatelessLankaVM<Actions extends object, Services extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Services>,\n): ILankaReadableVM<Actions & ILankaScenarioVM>;\n\nexport function createStatelessLankaVM<Actions extends object, TGateways extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Record<string, never>>,\n): ILankaReadableVM<Actions & ILankaScenarioVM>;\n\nexport function createStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Services>,\n): ILankaReadableVM<Actions & ILankaScenarioVM>;\n\n/**\n * The functional style of `ALankaStatelessVM`: actions declared as an options object.\n *\n * Same outward shape as the stateful factory — a readable ViewModel — and no\n * zustand store under it, because a ViewModel that holds nothing has nothing to\n * subscribe to. What it is and how it binds scenarios is documented once, on the\n * class.\n */\nexport function createStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: TLankaStatelessVMConfig<Actions, TGateways, Services>): TLankaStatelessVMHook<Actions> {\n\t/**\n\t * The bridge subclass lives here rather than in a shared helper because\n\t * `toStyleContext` is `protected`: only a class body deriving from\n\t * `ALankaStatelessVM` may read it. Canon: `skills/parity/SKILL.md` section 3a.\n\t */\n\tclass FunctionalStatelessVM extends ALankaStatelessVM<Actions, TGateways, Services> {\n\t\tprotected readonly name = config.name;\n\n\t\tprotected override scenarioHandlers(): NonNullable<typeof config.scenarioHandlers> {\n\t\t\treturn config.scenarioHandlers ?? [];\n\t\t}\n\n\t\tprotected override createGateways(): TGateways {\n\t\t\treturn resolveLankaDependency(config.gateways);\n\t\t}\n\n\t\tprotected override createServices(): Services {\n\t\t\treturn resolveLankaDependency(config.services);\n\t\t}\n\n\t\tprotected createActions(): Actions {\n\t\t\treturn config.createActions(this.toStyleContext());\n\t\t}\n\n\t\t// Own properties, assigned only when declared — see the same constructor in\n\t\t// `createLankaVM` for why not a method override.\n\t\tpublic constructor() {\n\t\t\tsuper();\n\t\t\tconst { onInit, onReset } = config;\n\n\t\t\tif (onInit) this.onInit = () => onInit(this.toStyleContext());\n\t\t\tif (onReset) this.onReset = () => onReset(this.toStyleContext());\n\t\t}\n\t}\n\n\treturn new FunctionalStatelessVM().build();\n}\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { createStatelessLankaVM } from \"../create-stateless-lanka-vm/createStatelessLankaVM\";\nimport type { ILankaVMConfig } from \"../../_interfaces/ILankaVMConfig\";\nimport { createLazyLankaVMProxy } from \"../../_internal/create-lazy-lanka-vm-proxy/createLazyLankaVMProxy\";\n\nexport type TLankaStatelessVMConfig<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> = Omit<ILankaVMConfig<object, Actions, TGateways, Services>, \"states\"> & {\n\tstates?: never;\n};\n\ntype TLazyStatelessReturn<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n> = ReturnType<typeof createStatelessLankaVM<Actions, TGateways, Services>> & {\n\tgetState: () => Actions & ILankaScenarioVM;\n\tdispose: () => void;\n};\n\nexport function createLazyStatelessLankaVM<Actions extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Record<string, never>>,\n): TLazyStatelessReturn<Actions, Record<string, never>, Record<string, never>>;\n\nexport function createLazyStatelessLankaVM<Actions extends object, Services extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, Record<string, never>, Services>,\n): TLazyStatelessReturn<Actions, Record<string, never>, Services>;\n\nexport function createLazyStatelessLankaVM<Actions extends object, TGateways extends object>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Record<string, never>>,\n): TLazyStatelessReturn<Actions, TGateways, Record<string, never>>;\n\nexport function createLazyStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: TLankaStatelessVMConfig<Actions, TGateways, Services>,\n): TLazyStatelessReturn<Actions, TGateways, Services>;\n\n/**\n * The lazy `createStatelessLankaVM`: nothing is built until a screen asks.\n *\n * The mechanism is `createLazyLankaVMProxy` — build on first access, hand every\n * member through, release on `dispose` — and this file is the one line that says\n * WHICH ViewModel is built. It used to be a copy of that mechanism, and the copy\n * had forgotten `setState`, `subscribe` and `getInitialState`: typed as the whole\n * store, absent at runtime.\n */\nexport function createLazyStatelessLankaVM<\n\tActions extends object,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: TLankaStatelessVMConfig<Actions, TGateways, Services>) {\n\treturn createLazyLankaVMProxy({\n\t\tname: config.name,\n\t\tkind: \"slVM\",\n\t\t// A stateless ViewModel has no reactive fields, so there is nothing whose\n\t\t// reads could be worth recording — the eager one answers false too.\n\t\tisAccessTracked: false,\n\t\tcreate: () => createStatelessLankaVM(config),\n\t});\n}\n","import type { ILankaSharedStoreVM } from \"../../_interfaces/ILankaSharedStoreVMConfig\";\nimport { resolveLankaDependency } from \"../../_utils/resolve-lanka-dependency/resolveLankaDependency\";\nimport { createLankaScenarioBinder } from \"../../_internal/create-lanka-scenario-binder/createLankaScenarioBinder\";\n\nimport { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { lankaScenarioBootstrap } from \"../../../scenario/lanka-scenario-bootstrap/LankaScenarioBootstrap\";\nimport { lankaLogger } from \"../../../logger/lanka-logger/LankaLogger\";\nimport type { ILankaSharedStoreVMConfig } from \"../../_interfaces/ILankaSharedStoreVMConfig\";\nimport type { ILankaSharedStoreVMContext } from \"../../_interfaces/ILankaSharedStoreVMContext\";\nimport { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\n\n/**\n * Factory for ViewModels backed by an external shared store instance.\n * Multiple ViewModels can be created on top of the same store instance.\n */\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n>(\n\tconfig: ILankaSharedStoreVMConfig<\n\t\tStoreState,\n\t\tActions,\n\t\tStore,\n\t\tRecord<string, never>,\n\t\tRecord<string, never>\n\t>,\n): ILankaSharedStoreVM<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, Record<string, never>, Services>,\n): ILankaSharedStoreVM<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Record<string, never>>,\n): ILankaSharedStoreVM<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>,\n): ILankaSharedStoreVM<StoreState, Actions>;\n\nexport function createSharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>) {\n\tlankaLogger.printViewModelLog(\"START Create ssVM\", config.name);\n\n\ttype TFullState = StoreState & Actions & ILankaScenarioVM;\n\n\t/**\n\t * Unsubscribe functions, plus the event types already subscribed to.\n\t *\n\t * Two separate jobs, kept separate: the array releases subscriptions, the set\n\t * prevents subscribing to one event type twice.\n\t */\n\tlet actions = {} as Actions;\n\n\tconst gateways = resolveLankaDependency(config.gateways);\n\tconst services = resolveLankaDependency(config.services);\n\n\tlet lastStoreStateRef: StoreState | null = null;\n\tlet lastFullStateRef: TFullState | null = null;\n\n\tconst buildFullState = (storeState: StoreState): TFullState => {\n\t\tif (lastStoreStateRef === storeState && lastFullStateRef) {\n\t\t\treturn lastFullStateRef;\n\t\t}\n\n\t\tlastStoreStateRef = storeState;\n\t\tlastFullStateRef = {\n\t\t\t...storeState,\n\t\t\t...actions,\n\t\t\tinitializeScenario,\n\t\t\tresetScenario,\n\t\t};\n\n\t\treturn lastFullStateRef;\n\t};\n\n\tconst getFullState = (): TFullState => buildFullState(config.store.getState());\n\n\tconst ctx: ILankaSharedStoreVMContext<StoreState, TFullState, Store, TGateways, Services> = {\n\t\tset: (partial, replace) => config.store.setState(partial, replace),\n\t\tgetStore: () => config.store.getState(),\n\t\tget: () => getFullState(),\n\t\tstore: config.store,\n\t\tgateways,\n\t\tservices,\n\t\ttrigger: (scenario, data) => scenario.trigger(data),\n\t};\n\n\tconst { initializeScenario, resetScenario, needsBootstrap } = createLankaScenarioBinder({\n\t\tname: config.name,\n\t\tbindings: config.scenarioHandlers,\n\t\tcontext: () => ctx,\n\t\tonInit: config.onInit,\n\t\tonReset: config.onReset,\n\t});\n\n\tactions = config.createActions(ctx);\n\tlastStoreStateRef = null;\n\tlastFullStateRef = null;\n\tconst isAccessTrackingEnabled = config.enableAccessTrackingOptimization ?? true;\n\n\t/**\n\t * The port over a slice of somebody else's store.\n\t *\n\t * `subscribe` is where the SHAPING happens — the store reports its own slice,\n\t * and both states are composed into full shape before a listener sees them.\n\t * Doing it here rather than in a binding is what lets one binding serve this\n\t * shape and the plain one without knowing which it was handed.\n\t *\n\t * Two ViewModels over one store therefore each hear every change to it, and\n\t * each decides for itself — through its reader's access tracking — whether the\n\t * change is worth a render.\n\t */\n\tconst sharedStoreViewModel: ILankaSharedStoreVM<StoreState, Actions> = {\n\t\tname: config.name,\n\t\tgetState: getFullState,\n\t\tgetStoreState: () => config.store.getState(),\n\t\tisAccessTracked: isAccessTrackingEnabled,\n\t\tsubscribe: (listener) =>\n\t\t\tconfig.store.subscribe((storeState, prevStoreState) => {\n\t\t\t\tlistener(buildFullState(storeState), buildFullState(prevStoreState));\n\t\t\t}),\n\t};\n\n\tif (needsBootstrap) {\n\t\tconst scenarioViewModel: ILankaScenarioVM = {\n\t\t\tinitializeScenario,\n\t\t\tresetScenario,\n\t\t};\n\t\tlankaScenarioBootstrap.registerViewModel(scenarioViewModel, config.name);\n\t}\n\n\tlankaLogger.printViewModelLog(\"FINISH Create ssVM\", config.name);\n\n\treturn sharedStoreViewModel;\n}\n","import { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\nimport { createLazyLankaVMProxy } from \"../../_internal/create-lazy-lanka-vm-proxy/createLazyLankaVMProxy\";\nimport { createSharedStoreLankaVM } from \"../create-shared-store-lanka-vm/createSharedStoreLankaVM\";\nimport type { ILankaSharedStoreVMConfig } from \"../../_interfaces/ILankaSharedStoreVMConfig\";\n\n/**\n * What a lazy shared-store ViewModel is, in the type as well as at runtime.\n *\n * The overloads used to promise the eager factory's return and nothing else, so\n * `dispose` and `getStoreState` existed on the object and not in the type: a\n * consumer releasing a closed screen's ViewModel got a compile error for calling\n * something that was there.\n */\ntype TLazySharedStoreReturn<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n> = ReturnType<typeof createSharedStoreLankaVM<StoreState, Actions, Store, TGateways, Services>> & {\n\tgetState: () => StoreState & Actions & ILankaScenarioVM;\n\tgetStoreState: () => StoreState;\n\tdispose: () => void;\n};\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n>(\n\tconfig: ILankaSharedStoreVMConfig<\n\t\tStoreState,\n\t\tActions,\n\t\tStore,\n\t\tRecord<string, never>,\n\t\tRecord<string, never>\n\t>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, Record<string, never>, Record<string, never>>;\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Record<string, never>>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, TGateways, Record<string, never>>;\n\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object,\n\tServices extends object,\n>(\n\tconfig: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>,\n): TLazySharedStoreReturn<StoreState, Actions, Store, TGateways, Services>;\n\n/**\n * The lazy `createSharedStoreLankaVM`: nothing is built until a screen asks.\n *\n * The mechanism is `createLazyLankaVMProxy`; this file is the one line that says\n * which ViewModel gets built. `dispose` releases THIS ViewModel's scenario\n * subscriptions and never the shared store — the store is shared, other\n * ViewModels stand on it, and taking its state away is not this one's decision.\n * That is the hook's behaviour, not a special case here: it resets the scenario\n * and drops its reference, and a shared store outlives both.\n */\nexport function createLazySharedStoreLankaVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n>(config: ILankaSharedStoreVMConfig<StoreState, Actions, Store, TGateways, Services>) {\n\treturn createLazyLankaVMProxy({\n\t\tname: config.name,\n\t\tkind: \"ssVM\",\n\t\tisAccessTracked: config.enableAccessTrackingOptimization ?? true,\n\t\tcreate: () => createSharedStoreLankaVM(config),\n\t});\n}\n","import { ALankaVMEnvironment } from \"../lanka-vm-environment/ALankaVMEnvironment\";\nimport { createSharedStoreLankaVM } from \"../../_factories/create-shared-store-lanka-vm/createSharedStoreLankaVM\";\nimport type { ALankaSharedStore } from \"../lanka-shared-store/ALankaSharedStore\";\nimport type { ILankaScenarioVM } from \"../../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { ILankaSharedStoreVMContext } from \"../../_interfaces/ILankaSharedStoreVMContext\";\nimport type { TLankaScenarioBindingsDeclaration } from \"../../_types/TLankaScenarioBindingsDeclaration\";\nimport type {\n\tILankaSharedStoreScenarioBinding,\n\tTLankaSharedStoreVMHook,\n} from \"../../_interfaces/ILankaSharedStoreVMConfig\";\n\n/**\n * A ViewModel over a store several ViewModels share, written as a class.\n *\n * The third rung of the ladder in `core/README.md`: reach for it only when two\n * ViewModels must CO-EDIT one state — a list and the badge that counts it, a\n * form and the header that says it is dirty. What the class adds over the\n * stateful base is where the state lives: in the store it is given, so `set`\n * writes there and `getStore` reads it.\n *\n * ```ts\n * class BadgeVM extends ALankaSharedStoreVM<ISelection, IBadgeActions, TodoStore> {\n * \tprotected readonly name = \"BadgeVM\";\n *\n * \tpublic constructor(store: TodoStore) {\n * \t\tsuper(store);\n * \t}\n *\n * \tprotected createActions(): IBadgeActions {\n * \t\treturn { clear: () => this.set({ selectedId: null }) };\n * \t}\n * }\n * ```\n *\n * Unlike its two siblings this one is a thin adapter rather than the\n * implementation: the store, the tracked hook and the two memoised state\n * references are the factory's, and duplicating them here would be the second\n * implementation the parity canon exists to prevent. What it gives a class-style\n * consumer is the same protected surface under the same names — plus\n * `toLifecycleHooks`, the framework's reading of `onInit`/`onReset`, which is\n * not an extension point.\n *\n * Canon: `skills/parity/SKILL.md`.\n */\nexport abstract class ALankaSharedStoreVM<\n\tStoreState extends object,\n\tActions extends object,\n\tStore extends ALankaSharedStore<StoreState>,\n\tTGateways extends object = Record<string, never>,\n\tServices extends object = Record<string, never>,\n> extends ALankaVMEnvironment<TGateways, Services> {\n\t/** Names the ViewModel in the logs and in the scenario registry. */\n\tprotected abstract readonly name: string;\n\n\t/** The store this ViewModel and its siblings share. */\n\tprotected readonly store: Store;\n\n\t/** Writes into the shared store, which every reader of it hears about. */\n\tprotected set!: ILankaSharedStoreVMContext<\n\t\tStoreState,\n\t\tStoreState & Actions & ILankaScenarioVM,\n\t\tStore,\n\t\tTGateways,\n\t\tServices\n\t>[\"set\"];\n\n\t/** Reads the store's own state, without this ViewModel's actions on top. */\n\tprotected getStore!: () => StoreState;\n\n\t/** Reads the store's state WITH the actions, which is what a screen sees. */\n\tprotected get!: () => StoreState & Actions & ILankaScenarioVM;\n\n\t/** Fires a scenario, which every ViewModel bound to it then hears. */\n\tprotected trigger!: ILankaSharedStoreVMContext<\n\t\tStoreState,\n\t\tStoreState & Actions & ILankaScenarioVM,\n\t\tStore,\n\t\tTGateways,\n\t\tServices\n\t>[\"trigger\"];\n\n\tpublic constructor(store: Store) {\n\t\tsuper();\n\t\tthis.store = store;\n\t}\n\n\t/**\n\t * Turn off when one broad consumer reads most fields of the store — proxy\n\t * tracking then costs more than it saves.\n\t */\n\tprotected readonly enableAccessTrackingOptimization: boolean = true;\n\n\t/** The scenarios this ViewModel listens to, unsubscribed for it on reset. */\n\tprotected scenarioHandlers(): TLankaScenarioBindingsDeclaration<\n\t\tILankaSharedStoreScenarioBinding<unknown, StoreState, Actions, Store, TGateways, Services>\n\t> {\n\t\treturn [];\n\t}\n\n\t/** The actions the screen calls. Written against `this.set` and `this.get`. */\n\tprotected abstract createActions(): Actions;\n\n\t/** Builds the hook a screen calls. One ViewModel per call. */\n\tpublic build(): TLankaSharedStoreVMHook<StoreState, Actions> {\n\t\tconst hooks = this.toLifecycleHooks();\n\n\t\treturn createSharedStoreLankaVM<StoreState, Actions, Store, TGateways, Services>({\n\t\t\tname: this.name,\n\t\t\tstore: this.store,\n\t\t\tenableAccessTrackingOptimization: this.enableAccessTrackingOptimization,\n\t\t\tgateways: () => this.createGateways(),\n\t\t\tservices: () => this.createServices(),\n\t\t\tscenarioHandlers: this.scenarioHandlers(),\n\t\t\tcreateActions: (context) => {\n\t\t\t\t// The context arrives here and becomes the protected surface, under the\n\t\t\t\t// same names it carries: a consumer who switches styles moves the same\n\t\t\t\t// call from `set(...)` to `this.set(...)` and changes nothing else.\n\t\t\t\tthis.set = context.set;\n\t\t\t\tthis.getStore = context.getStore;\n\t\t\t\tthis.get = context.get;\n\t\t\t\tthis.gateways = context.gateways;\n\t\t\t\tthis.services = context.services;\n\t\t\t\tthis.trigger = context.trigger;\n\n\t\t\t\treturn this.createActions();\n\t\t\t},\n\t\t\tonInit: hooks.onInit,\n\t\t\tonReset: hooks.onReset,\n\t\t});\n\t}\n}\n","import { createStore, StoreApi } from \"zustand/vanilla\";\n\n/**\n * Base abstraction for shared feature stores.\n *\n * A store built on this class is resolved through the shared-store locator and\n * reused across several ViewModels.\n */\nexport abstract class ALankaSharedStore<TState extends object> {\n\tprivate readonly api: StoreApi<TState>;\n\tprivate readonly createInitialState: () => TState;\n\n\tprotected constructor(createInitialState: () => TState) {\n\t\tthis.createInitialState = createInitialState;\n\t\tthis.api = createStore<TState>()(() => this.createInitialState());\n\t}\n\n\tpublic getApi(): StoreApi<TState> {\n\t\treturn this.api;\n\t}\n\n\tpublic getState(): TState {\n\t\treturn this.api.getState();\n\t}\n\n\tpublic setState(\n\t\tpartial: TState | Partial<TState> | ((state: TState) => TState | Partial<TState>),\n\t\treplace?: boolean,\n\t): void {\n\t\tconst resolved = typeof partial === \"function\" ? partial(this.api.getState()) : partial;\n\n\t\tif (replace) {\n\t\t\tthis.api.setState(resolved as TState, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.api.setState(resolved);\n\t}\n\n\tpublic subscribe(listener: (state: TState, prevState: TState) => void) {\n\t\treturn this.api.subscribe(listener);\n\t}\n\n\t/**\n\t * Back to what the store was built with.\n\t *\n\t * Public, and it was not: while this was `protected` only a subclass could\n\t * reset, so the class style had a capability the functional one could not\n\t * reach — the asymmetry `skills/parity/SKILL.md` forbids. A shared store needs\n\t * explicit reset points (see the ladder in `core/README.md`), and the\n\t * application that owns them is outside the class either way.\n\t */\n\tpublic reset(): void {\n\t\tthis.api.setState(this.createInitialState(), true);\n\t}\n}\n","import { ALankaSharedStore } from \"../../_abstractions/lanka-shared-store/ALankaSharedStore\";\n\n/**\n * A shared store, without writing a class whose body is one function.\n *\n * A shared store is the third rung of the ladder in `core/README.md`: reach for\n * it only when several ViewModels must CO-EDIT one state. Most stores have no\n * behaviour of their own — the state and how to build it fresh is the whole\n * declaration — and this is the shape for those.\n *\n * One implementation: what comes back is an `ALankaSharedStore`, so a reset, a\n * subscription and the zustand api behave identically either way.\n */\nexport const createLankaSharedStore = <TState extends object>(\n\tcreateInitialState: () => TState,\n): ALankaSharedStore<TState> => {\n\tclass FunctionalSharedStore extends ALankaSharedStore<TState> {\n\t\tpublic constructor() {\n\t\t\tsuper(createInitialState);\n\t\t}\n\t}\n\n\treturn new FunctionalSharedStore();\n};\n","/**\n * Compares two selections one level deep.\n *\n * Own keys, same count, `Object.is` on each value. Arrays included, because an\n * array IS an object with numeric keys and a selection like `state.todos.map(…)`\n * is the commonest thing there is.\n *\n * Unbranded, because it is a pure function over plain values and holds nothing —\n * `skills/naming/SKILL.md`, the prefix table. Not exported: what a consumer\n * needs is the hold below, and a second name for the predicate would be a second\n * promise to keep.\n */\nconst isShallowEqual = (a: unknown, b: unknown): boolean => {\n\tif (Object.is(a, b)) return true;\n\tif (typeof a !== \"object\" || a === null || typeof b !== \"object\" || b === null) return false;\n\n\tconst left = Object.keys(a);\n\tconst right = Object.keys(b);\n\tif (left.length !== right.length) return false;\n\n\treturn left.every(\n\t\t(key) =>\n\t\t\tObject.hasOwn(b as Record<string, unknown>, key) &&\n\t\t\tObject.is((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]),\n\t);\n};\n\n/**\n * Keeps a selection's IDENTITY while nothing in it moved.\n *\n * ```ts\n * const hold = createLankaShallowHold<{ title: string; status: string }>();\n *\n * // in any binding on the shelf\n * const view = useLankaVM(missionVM, (state) => hold({\n * \ttitle: state.title,\n * \tstatus: state.status,\n * }));\n * ```\n *\n * ## What it is for\n *\n * A selector narrows what a reader depends on, and a selector that BUILDS its\n * answer — `(state) => ({ a: state.a })`, `(state) => rows.filter(…)`, the shape\n * a consumer reaches for first — cannot say so. Every binding compares the new\n * selection with the last one by identity, and a fresh object is never identical\n * to anything, so the reader wakes for every change in the ViewModel including\n * the keys the selector exists to ignore. This is the comparison that makes the\n * selection mean something.\n *\n * A selector answering a PRIMITIVE never needed it, which is what makes the cost\n * quiet: the shape that is free and the shape that repaints on everything look\n * the same on the page.\n *\n * ## Why it is in core and not in a binding\n *\n * It was `useLankaShallow` in `@lankajs/react` and nowhere else, and that made it\n * a CAPABILITY one member of the shelf had and four did not. An idiom is a\n * spelling; this changes which notifications reach a reader, and it encodes a\n * policy — one level deep, own keys, `Object.is` — that five packages inventing\n * separately would answer five ways. `skills/parity/SKILL.md` 3c: a binding that\n * needs more than the port gives it has found something that belongs in core, for\n * everybody.\n *\n * `useLankaShallow` keeps working and is now React's spelling over this. It has\n * to exist there and cannot exist here: a React component re-runs the hook on\n * every render, so the holding has to survive a render while the SELECTOR stays\n * the current one — which is a `useRef`, and a ref is not something core can\n * have.\n *\n * ## Why it holds a value and not a selector\n *\n * `createLankaShallowSelector(selector)` was the other shape and it cannot serve\n * React: the wrapper would be rebuilt whenever the selector's identity moved, and\n * an inline arrow is a new function every render, so the holding would reset\n * before it ever held anything. Taking the VALUE puts the state in the only place\n * every framework can keep it, and the extra line at a call site is the price of\n * one name that works in all five rather than two that each work in some.\n *\n * ## One level, and it says so by failing\n *\n * Deeper would mean walking a state of unknown size on every read, which is the\n * cost a reader took a selector to avoid. A selection with a nested object wants\n * a selector that picks the leaves.\n */\nexport const createLankaShallowHold = <TValue>(): ((next: TValue) => TValue) => {\n\tlet held: TValue | undefined;\n\tlet holding = false;\n\n\treturn (next: TValue): TValue => {\n\t\t// `holding` rather than `held !== undefined`: a selection that legitimately\n\t\t// answers `undefined` is a selection, and a flag is the difference between\n\t\t// \"nothing yet\" and \"nothing, and that is the answer\".\n\t\tif (holding && isShallowEqual(held, next)) return held as TValue;\n\n\t\tholding = true;\n\t\theld = next;\n\n\t\treturn next;\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBO,IAAe,sBAAf,MAAe,qBAGpB;AAAA;AAAA,EAES;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA,iBAA4B;AACrC,WAAO,CAAC;AAAA,EACT;AAAA;AAAA,EAGU,iBAA2B;AACpC,WAAO,CAAC;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,SAAe;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB,UAAgB;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBjB,mBAA2C;AACpD,UAAM,WAAW,qBAAoB;AACrC,UAAM,QAAgC,CAAC;AAEvC,QAAI,KAAK,WAAW,SAAS,OAAQ,OAAM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AAA,EAWO,QAAc;AACpB,SAAK,IAAI,SAAS,KAAK,mBAAmB,GAAG,IAAI;AAAA,EAClD;AACD;;;AC1CO,IAAM,yBAAyB,CACrC,uBAC+B;AAAA,EAC/B,MAAM,8BAA8B,kBAA0B;AAAA,IACtD,cAAc;AACpB,YAAM,kBAAkB;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,IAAI,sBAAsB;AAClC;;;ACXA,IAAM,iBAAiB,CAAC,GAAY,MAAwB;AAC3D,MAAI,OAAO,GAAG,GAAG,CAAC,EAAG,QAAO;AAC5B,MAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM,KAAM,QAAO;AAEvF,QAAM,OAAO,OAAO,KAAK,CAAC;AAC1B,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,MAAI,KAAK,WAAW,MAAM,OAAQ,QAAO;AAEzC,SAAO,KAAK;AAAA,IACX,CAAC,QACA,OAAO,OAAO,GAA8B,GAAG,KAC/C,OAAO,GAAI,EAA8B,GAAG,GAAI,EAA8B,GAAG,CAAC;AAAA,EACpF;AACD;AA4DO,IAAM,yBAAyB,MAA0C;AAC/E,MAAI;AACJ,MAAI,UAAU;AAEd,SAAO,CAAC,SAAyB;AAIhC,QAAI,WAAW,eAAe,MAAM,IAAI,EAAG,QAAO;AAElD,cAAU;AACV,WAAO;AAEP,WAAO;AAAA,EACR;AACD;","names":["needsBootstrap","needsBootstrap","needsBootstrap","createStore"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lanka",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "core: Fourteen subsystems,
|
|
5
|
+
"description": "core: Fourteen subsystems, one peer dependency, six extension points.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -93,10 +93,9 @@
|
|
|
93
93
|
"@standard-schema/spec": "^1.0.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@lankajs/tool-testing": "^
|
|
96
|
+
"@lankajs/tool-testing": "^2.0.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"react": "^19.2.0",
|
|
100
99
|
"zustand": "^5.0.10"
|
|
101
100
|
},
|
|
102
101
|
"scripts": {
|
|
@@ -5,13 +5,15 @@ license: MIT
|
|
|
5
5
|
metadata:
|
|
6
6
|
author: lankajs
|
|
7
7
|
package: lanka
|
|
8
|
-
version: "
|
|
8
|
+
version: "2.0.1"
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# lanka — core
|
|
12
12
|
|
|
13
|
-
Layered
|
|
14
|
-
|
|
13
|
+
Layered application framework: **gateways → ViewModels → views**, scenarios over an
|
|
14
|
+
event bus, a locator for resolution. It binds no UI library — reading a ViewModel
|
|
15
|
+
from a screen is `@lankajs/react`, `@lankajs/vue`, `@lankajs/svelte`,
|
|
16
|
+
`@lankajs/solid` or `@lankajs/angular`, all publishing `useLankaVM`. `reference.md` beside this file is
|
|
15
17
|
the full guide; read it when a detail here is not enough.
|
|
16
18
|
|
|
17
19
|
> [!NOTE]
|
|
@@ -238,12 +240,12 @@ behaviour: a field array, validation per keystroke, one field depending on
|
|
|
238
240
|
another, `touched`/`dirty` as behaviour — or under SSR with pre-filled values,
|
|
239
241
|
because a ViewModel is one store per process and `hydrateLankaVM` applies once.
|
|
240
242
|
|
|
241
|
-
|
|
|
242
|
-
|
|
|
243
|
-
| values, `touched`/`dirty`, per-input messages, `isSubmitting`
|
|
244
|
-
| `defaultValues`, the server's version, the save, `trigger`, navigation | the ViewModel
|
|
245
|
-
| an input's ASYNCHRONOUS check
|
|
246
|
-
| where a failure goes
|
|
243
|
+
| | Owner |
|
|
244
|
+
| ---------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
245
|
+
| values, `touched`/`dirty`, per-input messages, `isSubmitting` | the form |
|
|
246
|
+
| `defaultValues`, the server's version, the save, `trigger`, navigation | the ViewModel |
|
|
247
|
+
| an input's ASYNCHRONOUS check | a ViewModel action — a resolver may not call a gateway |
|
|
248
|
+
| where a failure goes | the ViewModel decides, by `kind` |
|
|
247
249
|
|
|
248
250
|
**One schema, three readers.** The validation port speaks Standard Schema, and so
|
|
249
251
|
do the form libraries: the same object is the form's resolver and the gateway's
|
|
@@ -290,13 +292,13 @@ decides. Resetting the form erases what they were typing.
|
|
|
290
292
|
|
|
291
293
|
## Symptom → cause
|
|
292
294
|
|
|
293
|
-
| What you see
|
|
294
|
-
|
|
|
295
|
-
| a scenario handler never fires
|
|
296
|
-
| a locator name resolves to a refusal
|
|
297
|
-
| the screen freezes with no error
|
|
298
|
-
| "module not found" for `@lanka_di/…`
|
|
299
|
-
| a test sees another test's events
|
|
295
|
+
| What you see | What it is |
|
|
296
|
+
| --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
297
|
+
| a scenario handler never fires | `lanka.bootstrap()` was never awaited, or the ViewModel was built after it |
|
|
298
|
+
| a locator name resolves to a refusal | registered after construction, or never registered |
|
|
299
|
+
| the screen freezes with no error | a key read through a getter, past the tracking proxy — set `enableAccessTrackingOptimization: false` on that ViewModel |
|
|
300
|
+
| "module not found" for `@lanka_di/…` | `@lankajs/tool-di` is not installed, or the alias is missing |
|
|
301
|
+
| a test sees another test's events | the instance was replaced without `dispose()` — use `resetLanka()` |
|
|
300
302
|
| "lanka used before an instance existed", only in a BUILT bundle | a ViewModel read the locator while its own module was evaluated, ahead of `createLanka` — declare `scenarioHandlers` as a factory (below) |
|
|
301
303
|
|
|
302
304
|
Do **not** fix the frozen screen by destructuring a value "for the side effect":
|