lanka 2.2.0 → 2.2.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/_extend/index.js +18 -18
- package/dist/_internal/index.js +1 -1
- package/dist/bootstrap/index.d.ts +2 -2
- package/dist/bootstrap/index.js +11 -11
- package/dist/chunk-2ICKGQXS.js +21 -0
- package/dist/chunk-2ICKGQXS.js.map +1 -0
- package/dist/{chunk-JX47U5DC.js → chunk-4VFVACSL.js} +4 -4
- package/dist/{chunk-UX4A7TBG.js → chunk-532WVMAF.js} +14 -14
- package/dist/chunk-532WVMAF.js.map +1 -0
- package/dist/{chunk-6TNWBT6T.js → chunk-AMLUKB6A.js} +2 -2
- package/dist/{chunk-HYT5NSIB.js → chunk-DKLOCKS4.js} +2 -2
- package/dist/{chunk-IB2LRYDK.js → chunk-EH5WZSRJ.js} +5 -5
- package/dist/{chunk-BZNDUUTA.js → chunk-JGJBFELR.js} +2 -2
- package/dist/{chunk-RZGBLXXL.js → chunk-L27FF2IH.js} +3 -3
- package/dist/{chunk-3OQ3JZGT.js → chunk-M4BK6GBV.js} +2 -2
- package/dist/{chunk-NPJSZLTB.js → chunk-NMFNEVNE.js} +2 -2
- package/dist/{chunk-FR2FRJME.js → chunk-SP5OUTWF.js} +2 -2
- package/dist/{chunk-MLKTN4OV.js → chunk-XTVEHYIZ.js} +20 -7
- package/dist/{chunk-MLKTN4OV.js.map → chunk-XTVEHYIZ.js.map} +1 -1
- package/dist/config/index.js +3 -3
- package/dist/{createLanka-DxKZkmWe.d.ts → createLanka-AuiMfPL9.d.ts} +2 -2
- package/dist/errors/index.js +3 -3
- package/dist/gateway/index.js +7 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -14
- package/dist/locator/index.d.ts +108 -108
- package/dist/locator/index.js +35 -9
- package/dist/locator/index.js.map +1 -1
- package/dist/locator/scenario/lanka-scenario-locator/LankaScenarioLocator.js +5 -5
- package/dist/logger/index.js +3 -3
- package/dist/mock/index.js +3 -3
- package/dist/scenario/index.js +5 -5
- package/dist/stream/index.d.ts +1 -1
- package/dist/viewmodel/index.js +5 -5
- package/package.json +2 -2
- package/skills/lanka-core/SKILL.md +3 -1
- package/skills/lanka-core/reference.md +1 -1
- package/skills/lanka-packages/SKILL.md +1 -1
- package/dist/chunk-R365QEN2.js +0 -59
- package/dist/chunk-R365QEN2.js.map +0 -1
- package/dist/chunk-UX4A7TBG.js.map +0 -1
- /package/dist/{chunk-JX47U5DC.js.map → chunk-4VFVACSL.js.map} +0 -0
- /package/dist/{chunk-6TNWBT6T.js.map → chunk-AMLUKB6A.js.map} +0 -0
- /package/dist/{chunk-HYT5NSIB.js.map → chunk-DKLOCKS4.js.map} +0 -0
- /package/dist/{chunk-IB2LRYDK.js.map → chunk-EH5WZSRJ.js.map} +0 -0
- /package/dist/{chunk-BZNDUUTA.js.map → chunk-JGJBFELR.js.map} +0 -0
- /package/dist/{chunk-RZGBLXXL.js.map → chunk-L27FF2IH.js.map} +0 -0
- /package/dist/{chunk-3OQ3JZGT.js.map → chunk-M4BK6GBV.js.map} +0 -0
- /package/dist/{chunk-NPJSZLTB.js.map → chunk-NMFNEVNE.js.map} +0 -0
- /package/dist/{chunk-FR2FRJME.js.map → chunk-SP5OUTWF.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/_internal/active-runtime/lankaCopies.ts","../src/_internal/active-runtime/activeRuntime.ts"],"sourcesContent":["/**\n * Which COPIES of the package are on this page, and whether any of them runs.\n *\n * A copy is one evaluation of this module — one bundle's `lanka`. Two instances\n * of one copy are the isolation `createLanka` promises; two copies are what a\n * build produces when separately bundled modules each carry their own `lanka`,\n * and then each copy's pointer knows only its own runtime. A scenario triggered\n * through one never reaches a ViewModel registered with the other, and nothing\n * anywhere reports it.\n *\n * The only place two copies can meet is the global object, under a name every\n * copy agrees on without importing anything: `Symbol.for`.\n *\n * Dependency-free for the same reason `activeRuntime.ts` is — it imports nothing\n * and adds no edge to the module graph. That is also what keeps hot reload from\n * reading as a second copy: an update re-evaluates the edited module and its\n * IMPORTERS, and a module that imports nothing is on no such path unless it is\n * the file being edited. A full reload starts a new global object.\n */\n\n/**\n * One copy, as the others see it: `null` while it has no runtime, otherwise\n * whether that runtime runs in development.\n */\nexport type TLankaCopyState = () => boolean | null;\n\nconst COPIES = Symbol.for(\"lanka.copies\");\n\nconst copies = (): Set<TLankaCopyState> => {\n\tconst global = globalThis as Record<symbol, Set<TLankaCopyState> | undefined>;\n\treturn (global[COPIES] ??= new Set<TLankaCopyState>());\n};\n\nlet thisCopy: TLankaCopyState | null = null;\nlet warned = false;\n\nconst otherCopies = (): TLankaCopyState[] => [...copies()].filter((copy) => copy !== thisCopy);\n\n/** Whether a copy of the package other than this one has a runtime. */\nconst anotherIsRunning = (): boolean => otherCopies().some((copy) => copy() !== null);\n\n/**\n * Once per copy, and only in development: a production page with two copies may\n * be two isolated applications on purpose, and the reader who can fix a build\n * is the one running it locally.\n */\nconst warnOnce = (): void => {\n\tif (warned) return;\n\n\twarned = true;\n\tconsole.warn(\n\t\t\"[lanka] two copies of lanka are on this page. Each copy has its own \" +\n\t\t\t\"runtime, so a scenario triggered through one never reaches a ViewModel \" +\n\t\t\t\"registered with the other. If the modules on this page are meant to share \" +\n\t\t\t\"state, ship ONE lanka: a singleton in Module Federation's `shared`, an \" +\n\t\t\t\"import map, or `lanka` external in every module's build. If they are \" +\n\t\t\t\"meant to be isolated, this is expected.\",\n\t);\n};\n\n/**\n * Puts this copy on the page's list, when the copy LOADS.\n *\n * Loading is the one moment a copy that is never started does anything the page\n * can see — and never starting is the commonest form of the accident: the shell\n * started lanka, a module bundled its own and saw no reason to. Whether to warn\n * is the RUNNING copy's call, since this one has no flags yet.\n */\nconst join = (state: TLankaCopyState): void => {\n\tthisCopy = state;\n\tcopies().add(state);\n\n\tif (otherCopies().some((copy) => copy() === true)) warnOnce();\n};\n\n/**\n * Called on every activation, which is not a hot path: `createLanka`, its\n * `bootstrap`, and one instance per request on a server.\n */\nconst noteActivation = (isDevelopment: boolean): void => {\n\t// Re-added, not assumed: whatever cleared the global list — a test between\n\t// cases — must not make a running copy invisible to the next one.\n\tif (thisCopy) copies().add(thisCopy);\n\n\tif (isDevelopment && anotherIsRunning()) warnOnce();\n};\n\n/**\n * The three questions a copy asks of the page, as one table: they share this\n * copy's identity and its one warning, so they are one subject.\n */\nexport const lankaCopies = Object.freeze({ join, noteActivation, anotherIsRunning });\n","import type { LankaEventBusInstance } from \"../../scenario/event-bus/lanka-event-bus-instance/LankaEventBusInstance\";\nimport type { LankaScenariosRegistry } from \"../../scenario/_registries/lanka-scenarios-registry/LankaScenariosRegistry\";\nimport type { LankaScenarioVMRegistry } from \"../../scenario/_registries/lanka-scenario-vm-registry/LankaScenarioVMRegistry\";\nimport type { ILankaRuntimeConfig } from \"../../config/_interfaces/ILankaRuntimeConfig\";\nimport type { ILankaInFlightCounter } from \"../../gateway/inflight/lankaHttpInFlight\";\nimport type { ILankaScenarioVM } from \"../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { TLankaRequestMiddleware } from \"../../gateway/request/lankaRequestMiddleware\";\nimport type { LankaGatewayLocator } from \"../../locator/gateway/lanka-gateway-locator/LankaGatewayLocator\";\nimport type { LankaScenarioLocator } from \"../../locator/scenario/lanka-scenario-locator/LankaScenarioLocator\";\nimport type { LankaSingletonLocator } from \"../../locator/singleton/lanka-singleton-locator/LankaSingletonLocator\";\nimport type { LankaSharedStoreLocator } from \"../../locator/shared-store/lanka-shared-store-locator/LankaSharedStoreLocator\";\nimport { lankaCopies } from \"./lankaCopies\";\n\n/**\n * The pointer to the framework instance that ambient facades resolve to.\n *\n * ## Why this module is separate and imports no value\n *\n * Framework state belongs to an instance (`createLanka`), but the callers of\n * `lankaEventBus.dispatch`, `getLankaFlags()`, `lankaSingletons.foo`, `lankaHttpInFlight` —\n * the ambient facades cannot hold one — a user-extended `ALankaScenario`, the\n * static `LankaScenarioBootstrap` — so they ask which instance is active.\n *\n * The module is dependency-free DELIBERATELY: every import here is `import type`\n * and disappears at compile time, except `lankaCopies`, which imports nothing\n * itself. Otherwise there would be a cycle\n * `createLanka → locator → gateway → config → createLanka`, and module\n * evaluation order would start deciding what ends up `undefined`.\n *\n * This is still a global pointer. Real isolation belongs to whoever holds an\n * instance: their own bus, registries and counter. The facades serve ONE active\n * instance — exactly what an application with one needs.\n */\nexport interface ILankaRuntime {\n\treadonly eventBus: LankaEventBusInstance;\n\treadonly scenarios: LankaScenariosRegistry;\n\treadonly viewModels: LankaScenarioVMRegistry;\n\treadonly inFlight: ILankaInFlightCounter;\n\t/**\n\t * Request wrappers, in registration order: the first wraps them all.\n\t *\n\t * An array, not a set: order carries meaning — retry must sit outside request\n\t * signing, or the second attempt goes out unsigned.\n\t */\n\treadonly requestMiddleware: readonly TLankaRequestMiddleware[];\n\t/** Default response deadline. `undefined` means no limit. */\n\treadonly requestTimeoutMs: number | undefined;\n\treadonly locators: {\n\t\treadonly gateways: LankaGatewayLocator;\n\t\treadonly scenarios: LankaScenarioLocator;\n\t\treadonly singletons: LankaSingletonLocator;\n\t\treadonly sharedStores: LankaSharedStoreLocator;\n\t};\n\treadonly config: ILankaRuntimeConfig;\n\t/**\n\t * Bootstrap state of the scenario layer.\n\t *\n\t * A mutable object rather than contract fields: `LankaScenarioBootstrap` is an\n\t * ambient facade and must write here without holding an instance.\n\t */\n\treadonly scenarioState: {\n\t\tbootstrapped: boolean;\n\t\tinitialized: WeakSet<ILankaScenarioVM>;\n\t};\n\tsetConfig(patch: ILankaRuntimeConfig): void;\n\tgetFlags(): NonNullable<ILankaRuntimeConfig[\"flags\"]>;\n}\n\n/**\n * How \"which instance is active\" is answered.\n *\n * A strategy, because the answer depends on where the code runs. In a browser\n * there is one instance per document and a module-level pointer IS the answer. In\n * a server process there is one instance per REQUEST, and a module-level pointer\n * is the bug: the last request to start would answer for all of them.\n */\nexport type TLankaRuntimeResolver = () => ILankaRuntime | null;\n\n/**\n * How \"which SCOPE is this\" is answered, which is a different question.\n *\n * `TLankaRuntimeResolver` answers which framework INSTANCE serves a call, and on\n * a server that is one per request. This answers which unit of work the call\n * belongs to, and the two are not interchangeable: `runInLankaServerScope`\n * creates its instance INSIDE the scope, and `createLanka` activates every\n * instance it builds — so the process pointer and the scope's runtime are the\n * same object during a request, and nothing downstream can tell \"inside a\n * scope\" from \"after one ended\".\n *\n * That distinction is what a per-scope lifetime needs. Without it a call made\n * outside every request resolves against the LAST request's runtime and is\n * handed the last stranger's state, which is the failure a scope exists to\n * abolish.\n *\n * Core ships no resolver here either, and knows only that the question exists.\n */\nexport type TLankaScopeResolver = () => object | null;\n\nlet active: ILankaRuntime | null = null;\nlet resolveRuntime: TLankaRuntimeResolver | null = null;\nlet resolveScope: TLankaScopeResolver | null = null;\n\nexport function setActiveLankaRuntime(runtime: ILankaRuntime | null): void {\n\tactive = runtime;\n\n\tif (runtime) lankaCopies.noteActivation(runtime.getFlags().isDevelopment === true);\n}\n\n// What another copy of the package asks this one, registered as this copy loads.\nlankaCopies.join(() => (active === null ? null : active.getFlags().isDevelopment === true));\n\n/**\n * Replaces the strategy, or restores the default one with `null`.\n *\n * The installed resolver is the WHOLE answer — the module-level pointer is not\n * consulted behind it. That is deliberate: a fallback would turn \"this ran\n * outside a request\" from a loud error into one request quietly reading another\n * request's instance, which is the failure this seam exists to make impossible.\n *\n * Core ships no resolver and knows of none. What installs one is a package that\n * knows the shape of a request; core knows only that the question has more than\n * one answer.\n */\nexport function setLankaRuntimeResolver(resolver: TLankaRuntimeResolver | null): void {\n\tresolveRuntime = resolver;\n}\n\n/**\n * The PROCESS's own instance, read without asking the strategy.\n *\n * `getActiveRuntime` consults the installed resolver and is the answer for\n * almost everything. This is the one question it cannot answer: what a call\n * would have resolved to if nobody had installed a resolver at all.\n *\n * It exists for a resolver that wants to DEFER. A server's resolver answers from\n * its request scope, and a process that also holds an ambient instance — a\n * worker with a cache, a dev server between reloads, a suite between cases —\n * has a right answer outside every scope that the resolver cannot see. Without\n * this, the first request in such a process makes every later ambient call fail\n * for the life of it.\n *\n * Not a fallback inside `getActiveRuntime`, deliberately: a resolver that wants\n * to defer says so, and one that wants a call outside its scope to fail loudly\n * goes on failing loudly. The choice belongs to whoever knows what a scope is.\n */\nexport function getLankaProcessRuntime(): ILankaRuntime | null {\n\treturn active;\n}\n\nexport function getActiveRuntime(): ILankaRuntime | null {\n\treturn resolveRuntime ? resolveRuntime() : active;\n}\n\n/**\n * Installs the strategy that says which unit of work a call belongs to.\n *\n * Installed by whoever knows what a scope IS — `@lankajs/host` wraps a request\n * in `AsyncLocalStorage` and answers from its store. A browser installs none,\n * and that is the right answer there: a tab is one scope for its whole life.\n */\nexport function setLankaScopeResolver(resolver: TLankaScopeResolver | null): void {\n\tresolveScope = resolver;\n}\n\n/** Whether anything at all knows how to answer \"which scope\". */\nexport function hasLankaScopeResolver(): boolean {\n\treturn resolveScope !== null;\n}\n\n/**\n * The current unit of work, or `null`.\n *\n * `null` means two different things and the caller has to tell them apart with\n * `hasLankaScopeResolver`: with no resolver installed there are no scopes and a\n * process-wide lifetime is correct; with one installed it means this call ran\n * OUTSIDE every scope, which on a server is a mistake worth failing on.\n */\nexport function getActiveLankaScope(): object | null {\n\treturn resolveScope ? resolveScope() : null;\n}\n\n/**\n * The active instance, or a loud failure.\n *\n * No fallback, deliberately, for the same reason `getLankaHost` has none: an\n * instance created silently on the fly would mean subscriptions went to one bus\n * and events to another, and the divergence would surface three layers away.\n */\nexport function requireActiveRuntime(): ILankaRuntime {\n\t// The strategy is read here rather than through `getActiveRuntime()`: this is\n\t// the hottest path in the framework — every ambient facade, every request,\n\t// every dispatch — and a call that only forwards is a call that shows up in\n\t// `perf/`.\n\tconst runtime = resolveRuntime ? resolveRuntime() : active;\n\n\tif (!runtime) {\n\t\tthrow new Error(\n\t\t\tresolveRuntime\n\t\t\t\t? \"lanka has no instance for this call. A runtime resolver is installed and \" +\n\t\t\t\t\t\t\"answered with none, which on a server means the code ran outside a \" +\n\t\t\t\t\t\t\"request scope — start one, or do this work inside it.\"\n\t\t\t\t: lankaCopies.anotherIsRunning()\n\t\t\t\t\t? \"lanka used before an instance existed in THIS copy of the package, \" +\n\t\t\t\t\t\t\"while another copy of lanka on this page has one. The module calling \" +\n\t\t\t\t\t\t\"it bundled its own lanka; ship one — a singleton in Module \" +\n\t\t\t\t\t\t\"Federation's `shared`, an import map, or `lanka` external in its build.\"\n\t\t\t\t\t: \"lanka used before an instance existed. Call createLanka({ host }) and \" +\n\t\t\t\t\t\t\"activate it.\",\n\t\t);\n\t}\n\n\treturn runtime;\n}\n"],"mappings":";AA0BA,IAAM,SAAS,uBAAO,IAAI,cAAc;AAExC,IAAM,SAAS,MAA4B;AAC1C,QAAM,SAAS;AACf,SAAQ,OAAO,MAAM,MAAM,oBAAI,IAAqB;AACrD;AAEA,IAAI,WAAmC;AACvC,IAAI,SAAS;AAEb,IAAM,cAAc,MAAyB,CAAC,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,SAAS,QAAQ;AAG7F,IAAM,mBAAmB,MAAe,YAAY,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,IAAI;AAOpF,IAAM,WAAW,MAAY;AAC5B,MAAI,OAAQ;AAEZ,WAAS;AACT,UAAQ;AAAA,IACP;AAAA,EAMD;AACD;AAUA,IAAM,OAAO,CAAC,UAAiC;AAC9C,aAAW;AACX,SAAO,EAAE,IAAI,KAAK;AAElB,MAAI,YAAY,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,IAAI,EAAG,UAAS;AAC7D;AAMA,IAAM,iBAAiB,CAAC,kBAAiC;AAGxD,MAAI,SAAU,QAAO,EAAE,IAAI,QAAQ;AAEnC,MAAI,iBAAiB,iBAAiB,EAAG,UAAS;AACnD;AAMO,IAAM,cAAc,OAAO,OAAO,EAAE,MAAM,gBAAgB,iBAAiB,CAAC;;;ACOnF,IAAI,SAA+B;AACnC,IAAI,iBAA+C;AACnD,IAAI,eAA2C;AAExC,SAAS,sBAAsB,SAAqC;AAC1E,WAAS;AAET,MAAI,QAAS,aAAY,eAAe,QAAQ,SAAS,EAAE,kBAAkB,IAAI;AAClF;AAGA,YAAY,KAAK,MAAO,WAAW,OAAO,OAAO,OAAO,SAAS,EAAE,kBAAkB,IAAK;AAcnF,SAAS,wBAAwB,UAA8C;AACrF,mBAAiB;AAClB;AAoBO,SAAS,yBAA+C;AAC9D,SAAO;AACR;AAEO,SAAS,mBAAyC;AACxD,SAAO,iBAAiB,eAAe,IAAI;AAC5C;AASO,SAAS,sBAAsB,UAA4C;AACjF,iBAAe;AAChB;AAGO,SAAS,wBAAiC;AAChD,SAAO,iBAAiB;AACzB;AAUO,SAAS,sBAAqC;AACpD,SAAO,eAAe,aAAa,IAAI;AACxC;AASO,SAAS,uBAAsC;AAKrD,QAAM,UAAU,iBAAiB,eAAe,IAAI;AAEpD,MAAI,CAAC,SAAS;AACb,UAAM,IAAI;AAAA,MACT,iBACG,2MAGA,YAAY,iBAAiB,IAC5B,oRAIA;AAAA,IAEL;AAAA,EACD;AAEA,SAAO;AACR;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/_internal/active-runtime/lankaCopies.ts","../src/_internal/active-runtime/activeRuntime.ts"],"sourcesContent":["/**\n * Which COPIES of the package are on this page, and whether any of them runs.\n *\n * A copy is one evaluation of this module — one bundle's `lanka`. Two instances\n * of one copy are the isolation `createLanka` promises; two copies are what a\n * build produces when separately bundled modules each carry their own `lanka`,\n * and then each copy's pointer knows only its own runtime. A scenario triggered\n * through one never reaches a ViewModel registered with the other, and nothing\n * anywhere reports it.\n *\n * The only place two copies can meet is the global object, under a name every\n * copy agrees on without importing anything: `Symbol.for`.\n *\n * Dependency-free for the same reason `activeRuntime.ts` is — it imports nothing\n * and adds no edge to the module graph. That is also what keeps hot reload from\n * reading as a second copy: an update re-evaluates the edited module and its\n * IMPORTERS, and a module that imports nothing is on no such path unless it is\n * the file being edited. A full reload starts a new global object.\n */\n\n/**\n * One copy, as the others see it: `null` while it has no runtime, otherwise\n * whether that runtime runs in development.\n */\nexport type TLankaCopyState = () => boolean | null;\n\nconst COPIES = Symbol.for(\"lanka.copies\");\n\nconst copies = (): Set<TLankaCopyState> => {\n\tconst global = globalThis as Record<symbol, Set<TLankaCopyState> | undefined>;\n\treturn (global[COPIES] ??= new Set<TLankaCopyState>());\n};\n\nlet thisCopy: TLankaCopyState | null = null;\nlet warned = false;\n\nconst otherCopies = (): TLankaCopyState[] => [...copies()].filter((copy) => copy !== thisCopy);\n\n/** Whether a copy of the package other than this one has a runtime. */\nconst anotherIsRunning = (): boolean => otherCopies().some((copy) => copy() !== null);\n\n/**\n * Once per copy, and only in development: a production page with two copies may\n * be two isolated applications on purpose, and the reader who can fix a build\n * is the one running it locally.\n */\nconst warnOnce = (): void => {\n\tif (warned) return;\n\n\twarned = true;\n\tconsole.warn(\n\t\t\"[lanka] two copies of lanka are on this page. Each copy has its own \" +\n\t\t\t\"runtime, so a scenario triggered through one never reaches a ViewModel \" +\n\t\t\t\"registered with the other. If the modules on this page are meant to share \" +\n\t\t\t\"state, ship ONE lanka: a singleton in Module Federation's `shared`, an \" +\n\t\t\t\"import map, or `lanka` external in every module's build. If they are \" +\n\t\t\t\"meant to be isolated, this is expected.\",\n\t);\n};\n\n/**\n * Puts this copy on the page's list, when the copy LOADS.\n *\n * Loading is the one moment a copy that is never started does anything the page\n * can see — and never starting is the commonest form of the accident: the shell\n * started lanka, a module bundled its own and saw no reason to. Whether to warn\n * is the RUNNING copy's call, since this one has no flags yet.\n */\nconst join = (state: TLankaCopyState): void => {\n\tthisCopy = state;\n\tcopies().add(state);\n\n\tif (otherCopies().some((copy) => copy() === true)) warnOnce();\n};\n\n/**\n * Called on every activation, which is not a hot path: `createLanka`, its\n * `bootstrap`, and one instance per request on a server.\n */\nconst noteActivation = (isDevelopment: boolean): void => {\n\t// Re-added, not assumed: whatever cleared the global list — a test between\n\t// cases — must not make a running copy invisible to the next one.\n\tif (thisCopy) copies().add(thisCopy);\n\n\tif (isDevelopment && anotherIsRunning()) warnOnce();\n};\n\n/**\n * The three questions a copy asks of the page, as one table: they share this\n * copy's identity and its one warning, so they are one subject.\n */\nexport const lankaCopies = Object.freeze({ join, noteActivation, anotherIsRunning });\n","import type { LankaEventBusInstance } from \"../../scenario/event-bus/lanka-event-bus-instance/LankaEventBusInstance\";\nimport type { LankaScenariosRegistry } from \"../../scenario/_registries/lanka-scenarios-registry/LankaScenariosRegistry\";\nimport type { LankaScenarioVMRegistry } from \"../../scenario/_registries/lanka-scenario-vm-registry/LankaScenarioVMRegistry\";\nimport type { ILankaRuntimeConfig } from \"../../config/_interfaces/ILankaRuntimeConfig\";\nimport type { ILankaInFlightCounter } from \"../../gateway/inflight/lankaHttpInFlight\";\nimport type { ILankaScenarioVM } from \"../../scenario/_interfaces/ILankaScenarioVM\";\nimport type { TLankaRequestMiddleware } from \"../../gateway/request/lankaRequestMiddleware\";\nimport type { LankaGatewayLocator } from \"../../locator/gateway/lanka-gateway-locator/LankaGatewayLocator\";\nimport type { LankaScenarioLocator } from \"../../locator/scenario/lanka-scenario-locator/LankaScenarioLocator\";\nimport type { LankaSingletonLocator } from \"../../locator/singleton/lanka-singleton-locator/LankaSingletonLocator\";\nimport type { LankaSharedStoreLocator } from \"../../locator/shared-store/lanka-shared-store-locator/LankaSharedStoreLocator\";\nimport { lankaCopies } from \"./lankaCopies\";\n\n/**\n * The pointer to the framework instance that ambient facades resolve to.\n *\n * ## Why this module is separate and imports no value\n *\n * Framework state belongs to an instance (`createLanka`), but the callers of\n * `lankaEventBus.dispatch`, `getLankaFlags()`, `lankaSingletons.foo`, `lankaHttpInFlight` —\n * the ambient facades cannot hold one — a user-extended `ALankaScenario`, the\n * static `LankaScenarioBootstrap` — so they ask which instance is active.\n *\n * The module is dependency-free DELIBERATELY: every import here is `import type`\n * and disappears at compile time, except `lankaCopies`, which imports nothing\n * itself. Otherwise there would be a cycle\n * `createLanka → locator → gateway → config → createLanka`, and module\n * evaluation order would start deciding what ends up `undefined`.\n *\n * This is still a global pointer. Real isolation belongs to whoever holds an\n * instance: their own bus, registries and counter. The facades serve ONE active\n * instance — exactly what an application with one needs.\n */\nexport interface ILankaRuntime {\n\treadonly eventBus: LankaEventBusInstance;\n\treadonly scenarios: LankaScenariosRegistry;\n\treadonly viewModels: LankaScenarioVMRegistry;\n\treadonly inFlight: ILankaInFlightCounter;\n\t/**\n\t * Request wrappers, in registration order: the first wraps them all.\n\t *\n\t * An array, not a set: order carries meaning — retry must sit outside request\n\t * signing, or the second attempt goes out unsigned.\n\t */\n\treadonly requestMiddleware: readonly TLankaRequestMiddleware[];\n\t/** Default response deadline. `undefined` means no limit. */\n\treadonly requestTimeoutMs: number | undefined;\n\treadonly locators: {\n\t\treadonly gateways: LankaGatewayLocator;\n\t\treadonly scenarios: LankaScenarioLocator;\n\t\treadonly singletons: LankaSingletonLocator;\n\t\treadonly sharedStores: LankaSharedStoreLocator;\n\t};\n\treadonly config: ILankaRuntimeConfig;\n\t/**\n\t * Bootstrap state of the scenario layer.\n\t *\n\t * A mutable object rather than contract fields: `LankaScenarioBootstrap` is an\n\t * ambient facade and must write here without holding an instance.\n\t */\n\treadonly scenarioState: {\n\t\tbootstrapped: boolean;\n\t\tinitialized: WeakSet<ILankaScenarioVM>;\n\t};\n\tsetConfig(patch: ILankaRuntimeConfig): void;\n\tgetFlags(): NonNullable<ILankaRuntimeConfig[\"flags\"]>;\n}\n\n/**\n * How \"which instance is active\" is answered.\n *\n * A strategy, because the answer depends on where the code runs. In a browser\n * there is one instance per document and a module-level pointer IS the answer. In\n * a server process there is one instance per REQUEST, and a module-level pointer\n * is the bug: the last request to start would answer for all of them.\n */\nexport type TLankaRuntimeResolver = () => ILankaRuntime | null;\n\n/**\n * How \"which SCOPE is this\" is answered, which is a different question.\n *\n * `TLankaRuntimeResolver` answers which framework INSTANCE serves a call, and on\n * a server that is one per request. This answers which unit of work the call\n * belongs to, and the two are not interchangeable: `runInLankaServerScope`\n * creates its instance INSIDE the scope, and `createLanka` activates every\n * instance it builds — so the process pointer and the scope's runtime are the\n * same object during a request, and nothing downstream can tell \"inside a\n * scope\" from \"after one ended\".\n *\n * That distinction is what a per-scope lifetime needs. Without it a call made\n * outside every request resolves against the LAST request's runtime and is\n * handed the last stranger's state, which is the failure a scope exists to\n * abolish.\n *\n * Core ships no resolver here either, and knows only that the question exists.\n */\nexport type TLankaScopeResolver = () => object | null;\n\nlet active: ILankaRuntime | null = null;\nlet resolveRuntime: TLankaRuntimeResolver | null = null;\nlet resolveScope: TLankaScopeResolver | null = null;\n\n/**\n * Whether THIS copy has ever had an instance — what tells \"not yet\" from \"no\n * longer\" when a call finds none. Without it the one message named a missing\n * `createLanka` for a page that had been rendering off one for minutes.\n */\nlet hadInstance = false;\n\nexport function setActiveLankaRuntime(runtime: ILankaRuntime | null): void {\n\tactive = runtime;\n\n\tif (runtime) {\n\t\thadInstance = true;\n\t\tlankaCopies.noteActivation(runtime.getFlags().isDevelopment === true);\n\t}\n}\n\n// What another copy of the package asks this one, registered as this copy loads.\nlankaCopies.join(() => (active === null ? null : active.getFlags().isDevelopment === true));\n\n/**\n * Replaces the strategy, or restores the default one with `null`.\n *\n * The installed resolver is the WHOLE answer — the module-level pointer is not\n * consulted behind it. That is deliberate: a fallback would turn \"this ran\n * outside a request\" from a loud error into one request quietly reading another\n * request's instance, which is the failure this seam exists to make impossible.\n *\n * Core ships no resolver and knows of none. What installs one is a package that\n * knows the shape of a request; core knows only that the question has more than\n * one answer.\n */\nexport function setLankaRuntimeResolver(resolver: TLankaRuntimeResolver | null): void {\n\tresolveRuntime = resolver;\n}\n\n/**\n * The PROCESS's own instance, read without asking the strategy.\n *\n * `getActiveRuntime` consults the installed resolver and is the answer for\n * almost everything. This is the one question it cannot answer: what a call\n * would have resolved to if nobody had installed a resolver at all.\n *\n * It exists for a resolver that wants to DEFER. A server's resolver answers from\n * its request scope, and a process that also holds an ambient instance — a\n * worker with a cache, a dev server between reloads, a suite between cases —\n * has a right answer outside every scope that the resolver cannot see. Without\n * this, the first request in such a process makes every later ambient call fail\n * for the life of it.\n *\n * Not a fallback inside `getActiveRuntime`, deliberately: a resolver that wants\n * to defer says so, and one that wants a call outside its scope to fail loudly\n * goes on failing loudly. The choice belongs to whoever knows what a scope is.\n */\nexport function getLankaProcessRuntime(): ILankaRuntime | null {\n\treturn active;\n}\n\nexport function getActiveRuntime(): ILankaRuntime | null {\n\treturn resolveRuntime ? resolveRuntime() : active;\n}\n\n/**\n * Installs the strategy that says which unit of work a call belongs to.\n *\n * Installed by whoever knows what a scope IS — `@lankajs/host` wraps a request\n * in `AsyncLocalStorage` and answers from its store. A browser installs none,\n * and that is the right answer there: a tab is one scope for its whole life.\n */\nexport function setLankaScopeResolver(resolver: TLankaScopeResolver | null): void {\n\tresolveScope = resolver;\n}\n\n/** Whether anything at all knows how to answer \"which scope\". */\nexport function hasLankaScopeResolver(): boolean {\n\treturn resolveScope !== null;\n}\n\n/**\n * The current unit of work, or `null`.\n *\n * `null` means two different things and the caller has to tell them apart with\n * `hasLankaScopeResolver`: with no resolver installed there are no scopes and a\n * process-wide lifetime is correct; with one installed it means this call ran\n * OUTSIDE every scope, which on a server is a mistake worth failing on.\n */\nexport function getActiveLankaScope(): object | null {\n\treturn resolveScope ? resolveScope() : null;\n}\n\n/**\n * The same page keeping a stale evaluation of lanka beside a fresh one, which\n * is not a bundling accident: a dev server kept the page open while lanka was\n * upgraded or reinstalled, and a module loaded afterwards got the new files.\n */\nconst RELOADED_UNDER_AN_OPEN_PAGE =\n\t\"a dev server kept this page open while lanka was upgraded or reinstalled, and \" +\n\t\"a module loaded since then got the new files: reload the page\";\n\n/**\n * Why a call found no instance — four different causes, each with its own fix.\n *\n * Out of line, and only ever built on the way to a throw: the success path of\n * `requireActiveRuntime` stays exactly what it was.\n */\nfunction noInstanceMessage(): string {\n\tif (resolveRuntime) {\n\t\treturn (\n\t\t\t\"lanka has no instance for this call. A runtime resolver is installed and \" +\n\t\t\t\"answered with none, which on a server means the code ran outside a \" +\n\t\t\t\"request scope — start one, or do this work inside it.\"\n\t\t);\n\t}\n\n\tif (lankaCopies.anotherIsRunning()) {\n\t\treturn (\n\t\t\t\"lanka used before an instance existed in THIS copy of the package, while \" +\n\t\t\t\"another copy of lanka on this page has one. Either the module calling it \" +\n\t\t\t\"bundled its own lanka — ship one: a singleton in Module Federation's \" +\n\t\t\t\"`shared`, an import map, or `lanka` external in its build — or \" +\n\t\t\t`${RELOADED_UNDER_AN_OPEN_PAGE}.`\n\t\t);\n\t}\n\n\tif (hadInstance) {\n\t\treturn (\n\t\t\t\"lanka has no instance: one was active in this copy and has been cleared — \" +\n\t\t\t\"disposed, or deactivated by whatever manages instances here — and none has \" +\n\t\t\t\"been activated since. Either the call outlived it (a timer, a subscription \" +\n\t\t\t\"or a pending request still running after dispose), or a new one is due: \" +\n\t\t\t\"createLanka({ host }) and activate it.\"\n\t\t);\n\t}\n\n\t// A copy from before 2.2.0 never announces itself, so a stale one beside\n\t// this fresh one lands here rather than in the branch above.\n\treturn (\n\t\t\"lanka used before an instance existed. Call createLanka({ host }) and activate \" +\n\t\t\"it. If that already ran on this page, it ran in another evaluation of lanka \" +\n\t\t\"and this one started empty — most often, \" +\n\t\t`${RELOADED_UNDER_AN_OPEN_PAGE}; or a module bundled a copy older than lanka ` +\n\t\t\"2.2.0, which does not announce itself to this one.\"\n\t);\n}\n\n/**\n * The active instance, or a loud failure.\n *\n * No fallback, deliberately, for the same reason `getLankaHost` has none: an\n * instance created silently on the fly would mean subscriptions went to one bus\n * and events to another, and the divergence would surface three layers away.\n */\nexport function requireActiveRuntime(): ILankaRuntime {\n\t// The strategy is read here rather than through `getActiveRuntime()`: this is\n\t// the hottest path in the framework — every ambient facade, every request,\n\t// every dispatch — and a call that only forwards is a call that shows up in\n\t// `perf/`.\n\tconst runtime = resolveRuntime ? resolveRuntime() : active;\n\n\tif (!runtime) throw new Error(noInstanceMessage());\n\n\treturn runtime;\n}\n"],"mappings":";AA0BA,IAAM,SAAS,uBAAO,IAAI,cAAc;AAExC,IAAM,SAAS,MAA4B;AAC1C,QAAM,SAAS;AACf,SAAQ,OAAO,MAAM,MAAM,oBAAI,IAAqB;AACrD;AAEA,IAAI,WAAmC;AACvC,IAAI,SAAS;AAEb,IAAM,cAAc,MAAyB,CAAC,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,SAAS,QAAQ;AAG7F,IAAM,mBAAmB,MAAe,YAAY,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,IAAI;AAOpF,IAAM,WAAW,MAAY;AAC5B,MAAI,OAAQ;AAEZ,WAAS;AACT,UAAQ;AAAA,IACP;AAAA,EAMD;AACD;AAUA,IAAM,OAAO,CAAC,UAAiC;AAC9C,aAAW;AACX,SAAO,EAAE,IAAI,KAAK;AAElB,MAAI,YAAY,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,IAAI,EAAG,UAAS;AAC7D;AAMA,IAAM,iBAAiB,CAAC,kBAAiC;AAGxD,MAAI,SAAU,QAAO,EAAE,IAAI,QAAQ;AAEnC,MAAI,iBAAiB,iBAAiB,EAAG,UAAS;AACnD;AAMO,IAAM,cAAc,OAAO,OAAO,EAAE,MAAM,gBAAgB,iBAAiB,CAAC;;;ACOnF,IAAI,SAA+B;AACnC,IAAI,iBAA+C;AACnD,IAAI,eAA2C;AAO/C,IAAI,cAAc;AAEX,SAAS,sBAAsB,SAAqC;AAC1E,WAAS;AAET,MAAI,SAAS;AACZ,kBAAc;AACd,gBAAY,eAAe,QAAQ,SAAS,EAAE,kBAAkB,IAAI;AAAA,EACrE;AACD;AAGA,YAAY,KAAK,MAAO,WAAW,OAAO,OAAO,OAAO,SAAS,EAAE,kBAAkB,IAAK;AAcnF,SAAS,wBAAwB,UAA8C;AACrF,mBAAiB;AAClB;AAoBO,SAAS,yBAA+C;AAC9D,SAAO;AACR;AAEO,SAAS,mBAAyC;AACxD,SAAO,iBAAiB,eAAe,IAAI;AAC5C;AASO,SAAS,sBAAsB,UAA4C;AACjF,iBAAe;AAChB;AAGO,SAAS,wBAAiC;AAChD,SAAO,iBAAiB;AACzB;AAUO,SAAS,sBAAqC;AACpD,SAAO,eAAe,aAAa,IAAI;AACxC;AAOA,IAAM,8BACL;AASD,SAAS,oBAA4B;AACpC,MAAI,gBAAgB;AACnB,WACC;AAAA,EAIF;AAEA,MAAI,YAAY,iBAAiB,GAAG;AACnC,WACC,uSAIG,2BAA2B;AAAA,EAEhC;AAEA,MAAI,aAAa;AAChB,WACC;AAAA,EAMF;AAIA,SACC,4MAGG,2BAA2B;AAGhC;AASO,SAAS,uBAAsC;AAKrD,QAAM,UAAU,iBAAiB,eAAe,IAAI;AAEpD,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,kBAAkB,CAAC;AAEjD,SAAO;AACR;","names":[]}
|
package/dist/config/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "../chunk-XESL274R.js";
|
|
4
4
|
import {
|
|
5
5
|
getLankaHost
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-JGJBFELR.js";
|
|
7
7
|
import {
|
|
8
8
|
getLankaFlags
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-SP5OUTWF.js";
|
|
10
|
+
import "../chunk-XTVEHYIZ.js";
|
|
11
11
|
export {
|
|
12
12
|
createLankaHost,
|
|
13
13
|
getLankaFlags,
|
|
@@ -45,8 +45,8 @@ interface ILankaPlugin {
|
|
|
45
45
|
*
|
|
46
46
|
* **Ambient facades** — `lankaEventBus.dispatch`, `lankaSingletons.foo`,
|
|
47
47
|
* `getLankaFlags()`, `lankaHttpInFlight` — resolve THE ONE active instance
|
|
48
|
-
* (`
|
|
49
|
-
* a facade cannot offer it.
|
|
48
|
+
* (`_internal/active-runtime/activeRuntime.ts`). Isolation belongs to whoever
|
|
49
|
+
* holds an instance; a facade cannot offer it.
|
|
50
50
|
*
|
|
51
51
|
* One thing stays at module level deliberately: `ALankaScenario` collects
|
|
52
52
|
* constructed scenarios into a static pool. That is a REGISTRY OF DEFINITIONS,
|
package/dist/errors/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLankaApiError,
|
|
3
3
|
handleLankaApiError
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-DKLOCKS4.js";
|
|
5
5
|
import "../chunk-J5LA3Q6D.js";
|
|
6
6
|
import {
|
|
7
7
|
LankaError
|
|
8
8
|
} from "../chunk-G32H73QY.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-JGJBFELR.js";
|
|
10
|
+
import "../chunk-XTVEHYIZ.js";
|
|
11
11
|
|
|
12
12
|
// src/errors/read-lanka-field-errors/readLankaFieldErrors.ts
|
|
13
13
|
var NONE = Object.freeze([]);
|
package/dist/gateway/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
lankaStandardValidator
|
|
3
3
|
} from "../chunk-HVSQOMRE.js";
|
|
4
|
+
import "../chunk-CRIRTOLB.js";
|
|
4
5
|
import {
|
|
5
6
|
composeLankaRequestMiddleware
|
|
6
7
|
} from "../chunk-YR4MZXMU.js";
|
|
7
|
-
import "../chunk-CRIRTOLB.js";
|
|
8
8
|
import {
|
|
9
9
|
lankaHttpInFlight
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-NMFNEVNE.js";
|
|
11
11
|
import {
|
|
12
12
|
handleLankaApiError
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-DKLOCKS4.js";
|
|
14
14
|
import "../chunk-J5LA3Q6D.js";
|
|
15
15
|
import {
|
|
16
16
|
LankaError
|
|
17
17
|
} from "../chunk-G32H73QY.js";
|
|
18
18
|
import {
|
|
19
19
|
getLankaHost
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-JGJBFELR.js";
|
|
21
21
|
import {
|
|
22
22
|
lankaLogger
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-AMLUKB6A.js";
|
|
24
24
|
import {
|
|
25
25
|
getLankaFlags
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-SP5OUTWF.js";
|
|
27
27
|
import {
|
|
28
28
|
getActiveRuntime
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-XTVEHYIZ.js";
|
|
30
30
|
|
|
31
31
|
// src/gateway/request/_abstractions/lanka-request/ALankaRequest.ts
|
|
32
32
|
function classifyTransportError(error, timedOut) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as ILankaBootstrapConfig, a as ILankaInstance, b as ILankaInstanceConfig, c as ILankaPlugin, d as ILankaScenarioBootstrapConfig, e as ILankaServiceConfig, f as createLanka } from './createLanka-
|
|
1
|
+
export { I as ILankaBootstrapConfig, a as ILankaInstance, b as ILankaInstanceConfig, c as ILankaPlugin, d as ILankaScenarioBootstrapConfig, e as ILankaServiceConfig, f as createLanka } from './createLanka-AuiMfPL9.js';
|
|
2
2
|
export { ALankaPlugin, ILankaStartOptions, TLankaStartConfig, resetActiveLanka, startLanka } from './bootstrap/index.js';
|
|
3
3
|
export { ILankaRoleFactory, ILankaRoleOpening, TLankaRoleOpener, defineLankaRole } from './role/index.js';
|
|
4
4
|
export { ILankaHostConfig, createLankaHost, getLankaFlags, getLankaHost } from './config/index.js';
|
package/dist/index.js
CHANGED
|
@@ -6,33 +6,33 @@ import {
|
|
|
6
6
|
createLanka,
|
|
7
7
|
resetActiveLanka,
|
|
8
8
|
startLanka
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-532WVMAF.js";
|
|
10
|
+
import "./chunk-M4BK6GBV.js";
|
|
11
11
|
import "./chunk-BMF4TM2Z.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-EH5WZSRJ.js";
|
|
13
|
+
import "./chunk-24MUFFHF.js";
|
|
14
|
+
import "./chunk-3R2NO47A.js";
|
|
15
|
+
import "./chunk-JZJ6GXX3.js";
|
|
16
|
+
import "./chunk-N3275IPH.js";
|
|
17
|
+
import "./chunk-4VFVACSL.js";
|
|
18
|
+
import "./chunk-L27FF2IH.js";
|
|
15
19
|
import {
|
|
16
20
|
createLankaHost
|
|
17
21
|
} from "./chunk-XESL274R.js";
|
|
18
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-NMFNEVNE.js";
|
|
19
23
|
import {
|
|
20
24
|
LankaError
|
|
21
25
|
} from "./chunk-G32H73QY.js";
|
|
22
26
|
import {
|
|
23
27
|
getLankaHost
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-3R2NO47A.js";
|
|
26
|
-
import "./chunk-24MUFFHF.js";
|
|
27
|
-
import "./chunk-JZJ6GXX3.js";
|
|
28
|
-
import "./chunk-N3275IPH.js";
|
|
28
|
+
} from "./chunk-JGJBFELR.js";
|
|
29
29
|
import {
|
|
30
30
|
lankaLogger
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-AMLUKB6A.js";
|
|
32
32
|
import {
|
|
33
33
|
getLankaFlags
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-SP5OUTWF.js";
|
|
35
|
+
import "./chunk-XTVEHYIZ.js";
|
|
36
36
|
export {
|
|
37
37
|
ALankaPlugin,
|
|
38
38
|
LankaError,
|
package/dist/locator/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import * as GatewaysModule from '@lanka_di/Gateways';
|
|
|
4
4
|
import { A as ALankaGateway } from '../ALankaGateway-BrVPaZN5.js';
|
|
5
5
|
import * as ScenariosModule from '@lanka_di/Scenarios';
|
|
6
6
|
import * as SingletonsModule from '@lanka_di/Singletons';
|
|
7
|
+
export { ILankaSingletonLocatorConfig } from './singleton/lanka-singleton-locator/LankaSingletonLocator.js';
|
|
7
8
|
import * as SharedStoresModule from '@lanka_di/SharedStores';
|
|
8
9
|
import { A as ALankaSharedStore } from '../ALankaSharedStore-B7uepuuk.js';
|
|
9
10
|
export { ILankaSharedStoreLocatorConfig } from './shared-store/lanka-shared-store-locator/LankaSharedStoreLocator.js';
|
|
10
|
-
export { ILankaSingletonLocatorConfig } from './singleton/lanka-singleton-locator/LankaSingletonLocator.js';
|
|
11
11
|
import '../LankaScenarioVMRegistry-CFzCpIFd.js';
|
|
12
12
|
import '../ILankaScenarioVM-DKwjbIRq.js';
|
|
13
13
|
import '../lankaStandardValidator-BUFnysK0.js';
|
|
@@ -15,109 +15,6 @@ import '@standard-schema/spec';
|
|
|
15
15
|
import '../ILankaFieldError-D5931-vT.js';
|
|
16
16
|
import 'zustand/vanilla';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* The singleton marker: "this class is published by the application in
|
|
20
|
-
* `lankaSingletons`".
|
|
21
|
-
*
|
|
22
|
-
* ## Why a marker when the class is exported anyway
|
|
23
|
-
*
|
|
24
|
-
* The other three locators have one: a gateway extends `ALankaGateway`, a
|
|
25
|
-
* scenario has a `name`, a store extends `ALankaSharedStore`. Without a marker
|
|
26
|
-
* the selection is "anything that is a function with a prototype", so a stray
|
|
27
|
-
* export in the barrel — a helper, a companion class, an accidental re-export —
|
|
28
|
-
* becomes part of the public `lankaSingletons.*`, and a typo in a name is caught
|
|
29
|
-
* at runtime on first use, far from where it was made.
|
|
30
|
-
*
|
|
31
|
-
* ## A base class rather than a field
|
|
32
|
-
*
|
|
33
|
-
* A marker field can be put on anything, an object included, and the type would
|
|
34
|
-
* again stop telling a class from a non-class. Inheritance also gives TypeScript
|
|
35
|
-
* something it can select on in a mapped type.
|
|
36
|
-
*
|
|
37
|
-
* The class is empty deliberately: all it carries is the statement "I am meant
|
|
38
|
-
* for the locator".
|
|
39
|
-
*/
|
|
40
|
-
declare abstract class ALankaSingleton {
|
|
41
|
-
/**
|
|
42
|
-
* A runtime check, for the locator, which cannot see types.
|
|
43
|
-
*
|
|
44
|
-
* Looks at the prototype chain rather than the name: names are lost to
|
|
45
|
-
* minification, and a name check would work only until the build.
|
|
46
|
-
*/
|
|
47
|
-
static is(candidate: unknown): boolean;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Singleton classes, read from the consumer's barrel.
|
|
52
|
-
*
|
|
53
|
-
* Adding one takes two steps and no registration:
|
|
54
|
-
*
|
|
55
|
-
* 1. write the class;
|
|
56
|
-
* 2. add ONE export line to `.lanka_di/lankaSingletons.ts` at the project root.
|
|
57
|
-
*
|
|
58
|
-
* The type below is derived from that module's exports, so the property name
|
|
59
|
-
* and the instance type appear by themselves.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Turns a PascalCase class name into a camelCase property name: `UserProfile` → `userProfile`.
|
|
64
|
-
*/
|
|
65
|
-
type TPascalToCamelCase$3<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
66
|
-
/** Whether a type is a class constructor. */
|
|
67
|
-
/**
|
|
68
|
-
* A class marked as a singleton.
|
|
69
|
-
*
|
|
70
|
-
* Selecting on "is a constructor" admits anything, so a stray barrel export
|
|
71
|
-
* silently becomes part of the public `lankaSingletons.*` and a typo is caught at
|
|
72
|
-
* runtime on first use.
|
|
73
|
-
*/
|
|
74
|
-
type TIsSingletonClass<T> = T extends new () => infer Instance ? Instance extends ALankaSingleton ? true : false : false;
|
|
75
|
-
/**
|
|
76
|
-
* Builds the singletons type from the barrel's exports.
|
|
77
|
-
*
|
|
78
|
-
* Derived automatically; no list has to be maintained by hand.
|
|
79
|
-
*/
|
|
80
|
-
type TLankaSingletons = {
|
|
81
|
-
[K in keyof typeof SingletonsModule as TIsSingletonClass<(typeof SingletonsModule)[K]> extends true ? TPascalToCamelCase$3<K & string> : never]: (typeof SingletonsModule)[K] extends new () => infer Instance ? Instance : never;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
declare const lankaSingletons: TLankaSingletons;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Shared-store classes read from the consumer's barrel.
|
|
88
|
-
*
|
|
89
|
-
* Adding one takes two steps and no registration:
|
|
90
|
-
*
|
|
91
|
-
* 1. write a class extending `ALankaSharedStore`;
|
|
92
|
-
* 2. add ONE export line to `.lanka_di/lankaSharedStores.ts` at the project root.
|
|
93
|
-
*
|
|
94
|
-
* The type below is derived from that module's exports, so the property name
|
|
95
|
-
* and the instance type appear by themselves.
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Turns a PascalCase class name into a camelCase property name: `RoleEditorStore` → `roleEditorStore`.
|
|
100
|
-
*/
|
|
101
|
-
type TPascalToCamelCase$2<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
102
|
-
/** Whether the type is a shared-store class. */
|
|
103
|
-
type TIsSharedStoreClass<T> = T extends new () => infer Instance ? Instance extends ALankaSharedStore<object> ? true : false : false;
|
|
104
|
-
/**
|
|
105
|
-
* Builds the shared-store type from every export of the barrel.
|
|
106
|
-
*
|
|
107
|
-
* Derived automatically; no list has to be maintained by hand.
|
|
108
|
-
*/
|
|
109
|
-
type TLankaSharedStores = {
|
|
110
|
-
[K in keyof typeof SharedStoresModule as TIsSharedStoreClass<(typeof SharedStoresModule)[K]> extends true ? TPascalToCamelCase$2<K & string> : never]: (typeof SharedStoresModule)[K] extends new () => infer Instance ? Instance : never;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Access to every shared store at once.
|
|
115
|
-
*
|
|
116
|
-
* An `ALankaSharedStore` subclass appears here by itself once it is exported from
|
|
117
|
-
* `@lanka_di/SharedStores`. The property is camelCase, the class name PascalCase.
|
|
118
|
-
*/
|
|
119
|
-
declare const lankaSharedStores: TLankaSharedStores;
|
|
120
|
-
|
|
121
18
|
/**
|
|
122
19
|
* Gateway classes read from the consumer's barrel.
|
|
123
20
|
*
|
|
@@ -133,7 +30,7 @@ declare const lankaSharedStores: TLankaSharedStores;
|
|
|
133
30
|
/**
|
|
134
31
|
* Turns a PascalCase class name into a camelCase property name: `UserGateway` → `userGateway`.
|
|
135
32
|
*/
|
|
136
|
-
type TPascalToCamelCase$
|
|
33
|
+
type TPascalToCamelCase$3<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
137
34
|
/** Whether the type is a gateway class — an `ALankaGateway` subclass. */
|
|
138
35
|
type TIsGatewayClass<T> = T extends new () => infer Instance ? Instance extends ALankaGateway<unknown> ? true : false : false;
|
|
139
36
|
/**
|
|
@@ -142,7 +39,7 @@ type TIsGatewayClass<T> = T extends new () => infer Instance ? Instance extends
|
|
|
142
39
|
* Derived automatically; no list has to be maintained by hand.
|
|
143
40
|
*/
|
|
144
41
|
type TLankaGateways = {
|
|
145
|
-
[K in keyof typeof GatewaysModule as TIsGatewayClass<(typeof GatewaysModule)[K]> extends true ? TPascalToCamelCase$
|
|
42
|
+
[K in keyof typeof GatewaysModule as TIsGatewayClass<(typeof GatewaysModule)[K]> extends true ? TPascalToCamelCase$3<K & string> : never]: (typeof GatewaysModule)[K] extends new () => infer Instance ? Instance : never;
|
|
146
43
|
};
|
|
147
44
|
|
|
148
45
|
/**
|
|
@@ -175,13 +72,13 @@ declare const lankaGateways: TLankaGateways;
|
|
|
175
72
|
/**
|
|
176
73
|
* Turns a PascalCase class name into a camelCase property name: `SessionUpdated` → `sessionUpdated`.
|
|
177
74
|
*/
|
|
178
|
-
type TPascalToCamelCase<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
75
|
+
type TPascalToCamelCase$2<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
179
76
|
/** Extracts the scenario name from the constructor. */
|
|
180
77
|
type TExtractScenarioName<T> = T extends new () => infer Instance ? Instance extends {
|
|
181
78
|
readonly name: infer N;
|
|
182
79
|
} ? N extends string ? N : never : never : never;
|
|
183
80
|
/** Derives the property name from a scenario constructor. */
|
|
184
|
-
type TScenarioPropertyName<T> = TPascalToCamelCase<TExtractScenarioName<T>>;
|
|
81
|
+
type TScenarioPropertyName<T> = TPascalToCamelCase$2<TExtractScenarioName<T>>;
|
|
185
82
|
/** Whether the type is a scenario class — a constructor yielding a named instance. */
|
|
186
83
|
type TIsScenarioClass<T> = T extends new () => infer Instance ? Instance extends {
|
|
187
84
|
readonly name: string;
|
|
@@ -212,6 +109,38 @@ type TLankaScenarios = {
|
|
|
212
109
|
*/
|
|
213
110
|
declare const lankaScenarios: TLankaScenarios;
|
|
214
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The singleton marker: "this class is published by the application in
|
|
114
|
+
* `lankaSingletons`".
|
|
115
|
+
*
|
|
116
|
+
* ## Why a marker when the class is exported anyway
|
|
117
|
+
*
|
|
118
|
+
* The other three locators have one: a gateway extends `ALankaGateway`, a
|
|
119
|
+
* scenario has a `name`, a store extends `ALankaSharedStore`. Without a marker
|
|
120
|
+
* the selection is "anything that is a function with a prototype", so a stray
|
|
121
|
+
* export in the barrel — a helper, a companion class, an accidental re-export —
|
|
122
|
+
* becomes part of the public `lankaSingletons.*`, and a typo in a name is caught
|
|
123
|
+
* at runtime on first use, far from where it was made.
|
|
124
|
+
*
|
|
125
|
+
* ## A base class rather than a field
|
|
126
|
+
*
|
|
127
|
+
* A marker field can be put on anything, an object included, and the type would
|
|
128
|
+
* again stop telling a class from a non-class. Inheritance also gives TypeScript
|
|
129
|
+
* something it can select on in a mapped type.
|
|
130
|
+
*
|
|
131
|
+
* The class is empty deliberately: all it carries is the statement "I am meant
|
|
132
|
+
* for the locator".
|
|
133
|
+
*/
|
|
134
|
+
declare abstract class ALankaSingleton {
|
|
135
|
+
/**
|
|
136
|
+
* A runtime check, for the locator, which cannot see types.
|
|
137
|
+
*
|
|
138
|
+
* Looks at the prototype chain rather than the name: names are lost to
|
|
139
|
+
* minification, and a name check would work only until the build.
|
|
140
|
+
*/
|
|
141
|
+
static is(candidate: unknown): boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
215
144
|
/**
|
|
216
145
|
* The functional style of `ALankaSingleton`: a singleton declared by a function.
|
|
217
146
|
*
|
|
@@ -236,4 +165,75 @@ declare const lankaScenarios: TLankaScenarios;
|
|
|
236
165
|
*/
|
|
237
166
|
declare const createLankaSingleton: <TInstance extends object>(build: () => TInstance) => new () => TInstance;
|
|
238
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Singleton classes, read from the consumer's barrel.
|
|
170
|
+
*
|
|
171
|
+
* Adding one takes two steps and no registration:
|
|
172
|
+
*
|
|
173
|
+
* 1. write the class;
|
|
174
|
+
* 2. add ONE export line to `.lanka_di/lankaSingletons.ts` at the project root.
|
|
175
|
+
*
|
|
176
|
+
* The type below is derived from that module's exports, so the property name
|
|
177
|
+
* and the instance type appear by themselves.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Turns a PascalCase class name into a camelCase property name: `UserProfile` → `userProfile`.
|
|
182
|
+
*/
|
|
183
|
+
type TPascalToCamelCase$1<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
184
|
+
/** Whether a type is a class constructor. */
|
|
185
|
+
/**
|
|
186
|
+
* A class marked as a singleton.
|
|
187
|
+
*
|
|
188
|
+
* Selecting on "is a constructor" admits anything, so a stray barrel export
|
|
189
|
+
* silently becomes part of the public `lankaSingletons.*` and a typo is caught at
|
|
190
|
+
* runtime on first use.
|
|
191
|
+
*/
|
|
192
|
+
type TIsSingletonClass<T> = T extends new () => infer Instance ? Instance extends ALankaSingleton ? true : false : false;
|
|
193
|
+
/**
|
|
194
|
+
* Builds the singletons type from the barrel's exports.
|
|
195
|
+
*
|
|
196
|
+
* Derived automatically; no list has to be maintained by hand.
|
|
197
|
+
*/
|
|
198
|
+
type TLankaSingletons = {
|
|
199
|
+
[K in keyof typeof SingletonsModule as TIsSingletonClass<(typeof SingletonsModule)[K]> extends true ? TPascalToCamelCase$1<K & string> : never]: (typeof SingletonsModule)[K] extends new () => infer Instance ? Instance : never;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare const lankaSingletons: TLankaSingletons;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Shared-store classes read from the consumer's barrel.
|
|
206
|
+
*
|
|
207
|
+
* Adding one takes two steps and no registration:
|
|
208
|
+
*
|
|
209
|
+
* 1. write a class extending `ALankaSharedStore`;
|
|
210
|
+
* 2. add ONE export line to `.lanka_di/lankaSharedStores.ts` at the project root.
|
|
211
|
+
*
|
|
212
|
+
* The type below is derived from that module's exports, so the property name
|
|
213
|
+
* and the instance type appear by themselves.
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Turns a PascalCase class name into a camelCase property name: `RoleEditorStore` → `roleEditorStore`.
|
|
218
|
+
*/
|
|
219
|
+
type TPascalToCamelCase<S extends string> = S extends `${infer P1}${infer P2}` ? `${Lowercase<P1>}${P2}` : S;
|
|
220
|
+
/** Whether the type is a shared-store class. */
|
|
221
|
+
type TIsSharedStoreClass<T> = T extends new () => infer Instance ? Instance extends ALankaSharedStore<object> ? true : false : false;
|
|
222
|
+
/**
|
|
223
|
+
* Builds the shared-store type from every export of the barrel.
|
|
224
|
+
*
|
|
225
|
+
* Derived automatically; no list has to be maintained by hand.
|
|
226
|
+
*/
|
|
227
|
+
type TLankaSharedStores = {
|
|
228
|
+
[K in keyof typeof SharedStoresModule as TIsSharedStoreClass<(typeof SharedStoresModule)[K]> extends true ? TPascalToCamelCase<K & string> : never]: (typeof SharedStoresModule)[K] extends new () => infer Instance ? Instance : never;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Access to every shared store at once.
|
|
233
|
+
*
|
|
234
|
+
* An `ALankaSharedStore` subclass appears here by itself once it is exported from
|
|
235
|
+
* `@lanka_di/SharedStores`. The property is camelCase, the class name PascalCase.
|
|
236
|
+
*/
|
|
237
|
+
declare const lankaSharedStores: TLankaSharedStores;
|
|
238
|
+
|
|
239
239
|
export { ALankaSingleton, type TLankaGateways, type TLankaScenarios, type TLankaSharedStores, type TLankaSingletons, createLankaSingleton, lankaGateways, lankaScenarios, lankaSharedStores, lankaSingletons };
|
package/dist/locator/index.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createLankaLocatorProxy
|
|
3
|
-
|
|
4
|
-
lankaSingletons
|
|
5
|
-
} from "../chunk-R365QEN2.js";
|
|
6
|
-
import "../chunk-3R2NO47A.js";
|
|
7
|
-
import "../chunk-24MUFFHF.js";
|
|
8
|
-
import "../chunk-JZJ6GXX3.js";
|
|
9
|
-
import "../chunk-N3275IPH.js";
|
|
2
|
+
createLankaLocatorProxy
|
|
3
|
+
} from "../chunk-2ICKGQXS.js";
|
|
10
4
|
import {
|
|
11
5
|
requireActiveRuntime
|
|
12
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-XTVEHYIZ.js";
|
|
13
7
|
|
|
14
8
|
// src/locator/gateway/_facades/lanka-gateways/lankaGateways.ts
|
|
15
9
|
var gatewayLocator = {
|
|
@@ -59,6 +53,38 @@ var createLankaSingleton = (build) => {
|
|
|
59
53
|
}
|
|
60
54
|
return FunctionalSingleton;
|
|
61
55
|
};
|
|
56
|
+
|
|
57
|
+
// src/locator/singleton/_facades/lanka-singletons/lankaSingletons.ts
|
|
58
|
+
var singletonLocator = {
|
|
59
|
+
get: (propertyName) => requireActiveRuntime().locators.singletons.get(propertyName)
|
|
60
|
+
};
|
|
61
|
+
var lankaSingletons = createLankaLocatorProxy({
|
|
62
|
+
locator: singletonLocator,
|
|
63
|
+
protectedProperties: [
|
|
64
|
+
"clearCache",
|
|
65
|
+
"register",
|
|
66
|
+
"registerInstance",
|
|
67
|
+
"unregister",
|
|
68
|
+
"isRegistered"
|
|
69
|
+
],
|
|
70
|
+
errorPrefix: "Cannot access singleton"
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/locator/shared-store/_facades/lanka-shared-stores/lankaSharedStores.ts
|
|
74
|
+
var sharedStoreLocator = {
|
|
75
|
+
get: (propertyName) => requireActiveRuntime().locators.sharedStores.get(propertyName)
|
|
76
|
+
};
|
|
77
|
+
var lankaSharedStores = createLankaLocatorProxy({
|
|
78
|
+
locator: sharedStoreLocator,
|
|
79
|
+
protectedProperties: [
|
|
80
|
+
"clearCache",
|
|
81
|
+
"register",
|
|
82
|
+
"registerInstance",
|
|
83
|
+
"unregister",
|
|
84
|
+
"isRegistered"
|
|
85
|
+
],
|
|
86
|
+
errorPrefix: "Cannot access shared store"
|
|
87
|
+
});
|
|
62
88
|
export {
|
|
63
89
|
ALankaSingleton,
|
|
64
90
|
createLankaSingleton,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/locator/gateway/_facades/lanka-gateways/lankaGateways.ts","../../src/locator/scenario/_facades/lanka-scenarios/lankaScenarios.ts","../../src/locator/singleton/_abstractions/lanka-singleton/ALankaSingleton.ts","../../src/locator/singleton/_factories/create-lanka-singleton/createLankaSingleton.ts"],"sourcesContent":["import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport type { TLankaGateways } from \"../../_types/TLankaGateways\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\nimport type { ALankaGateway } from \"../../../../gateway/_abstractions/lanka-gateway/ALankaGateway\";\n\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state would let two\n * frameworks in one process resolve the same gateway. The proxy stays at module\n * level because it has hundreds of call sites; only the cache moved.\n */\nconst gatewayLocator: ILankaLocator<ALankaGateway<unknown>> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.gateways.get(propertyName),\n};\n\n/**\n * Access to every gateway at once.\n *\n * An `ALankaGateway` subclass appears here by itself. The property is camelCase,\n * the gateway name is PascalCase.\n *\n * ```ts\n * import { lankaGateways } from \"lanka\";\n *\n * const user = await lankaGateways.userGateway.getById(1);\n * const list = await lankaGateways.companyGateway.getList({ page: 1 });\n * ```\n */\nexport const lankaGateways = createLankaLocatorProxy<ALankaGateway<unknown>, TLankaGateways>({\n\tlocator: gatewayLocator,\n\tprotectedProperties: [\"clearCache\"],\n\terrorPrefix: \"Cannot access gateway\",\n});\n","import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\nimport type { ILankaScenario } from \"../../../../scenario/_interfaces/ILankaScenario\";\nimport { TLankaScenarios } from \"../../_types/TLankaScenarios\";\n\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state would let two\n * frameworks in one process resolve the same scenario. The proxy stays at module\n * level because it has hundreds of call sites; only the cache moved.\n */\nconst scenarioLocator: ILankaLocator<ILankaScenario<unknown>> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.scenarios.get(propertyName),\n};\n\n/**\n * Access to every scenario at once.\n *\n * An `ALankaScenario` subclass appears here by itself. The property is camelCase,\n * the scenario name is PascalCase.\n *\n * ```ts\n * import { lankaScenarios } from \"lanka\";\n *\n * lankaScenarios.sessionUpdated.trigger({ user });\n * lankaScenarios.usersListRefresh.trigger({ reason: \"create\" });\n *\n * lankaScenarios.usersListRefresh.subscribe((data) => { ... });\n * ```\n */\nexport const lankaScenarios = createLankaLocatorProxy<ILankaScenario<unknown>, TLankaScenarios>({\n\tlocator: scenarioLocator,\n\terrorPrefix: \"Cannot access scenario\",\n});\n","/**\n * The singleton marker: \"this class is published by the application in\n * `lankaSingletons`\".\n *\n * ## Why a marker when the class is exported anyway\n *\n * The other three locators have one: a gateway extends `ALankaGateway`, a\n * scenario has a `name`, a store extends `ALankaSharedStore`. Without a marker\n * the selection is \"anything that is a function with a prototype\", so a stray\n * export in the barrel — a helper, a companion class, an accidental re-export —\n * becomes part of the public `lankaSingletons.*`, and a typo in a name is caught\n * at runtime on first use, far from where it was made.\n *\n * ## A base class rather than a field\n *\n * A marker field can be put on anything, an object included, and the type would\n * again stop telling a class from a non-class. Inheritance also gives TypeScript\n * something it can select on in a mapped type.\n *\n * The class is empty deliberately: all it carries is the statement \"I am meant\n * for the locator\".\n */\nexport abstract class ALankaSingleton {\n\t/**\n\t * A runtime check, for the locator, which cannot see types.\n\t *\n\t * Looks at the prototype chain rather than the name: names are lost to\n\t * minification, and a name check would work only until the build.\n\t */\n\tstatic is(candidate: unknown): boolean {\n\t\tif (typeof candidate !== \"function\") return false;\n\n\t\tlet proto: unknown = Object.getPrototypeOf(candidate) as unknown;\n\t\twhile (typeof proto === \"function\") {\n\t\t\tif (proto === ALankaSingleton) return true;\n\t\t\tproto = Object.getPrototypeOf(proto) as unknown;\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { ALankaSingleton } from \"../../_abstractions/lanka-singleton/ALankaSingleton\";\n\n/**\n * The functional style of `ALankaSingleton`: a singleton declared by a function.\n *\n * A singleton is a role — an application writes many — and this is the same role\n * the class style declares by extending the marker. What comes back IS a subclass\n * of `ALankaSingleton`, so the locator discovers it in the consumer's barrel,\n * builds it on first use and caches it, exactly as it does a hand-written class.\n *\n * ```ts\n * export const PlaygroundClock = createLankaSingleton(() => ({\n * \tnow: () => Date.now(),\n * }));\n * ```\n *\n * The result is exported under a PascalCase name because it is a class: the\n * locator resolves `lankaSingletons.playgroundClock` by that export name, and a\n * camelCase one would read as the instance while being the constructor.\n *\n * The builder runs at first resolution, not here — a singleton declared in a\n * module body must not touch a runtime that does not exist yet. Canon:\n * `skills/parity/SKILL.md`.\n */\nexport const createLankaSingleton = <TInstance extends object>(\n\tbuild: () => TInstance,\n): new () => TInstance => {\n\tclass FunctionalSingleton extends ALankaSingleton {\n\t\tpublic constructor() {\n\t\t\tsuper();\n\n\t\t\t// A constructor answering an object is what makes the two styles one\n\t\t\t// implementation: the locator constructs a marked class either way, and\n\t\t\t// what it gets back is what the builder returned.\n\t\t\treturn build();\n\t\t}\n\t}\n\n\treturn FunctionalSingleton as unknown as new () => TInstance;\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,IAAM,iBAAwD;AAAA,EAC7D,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,SAAS,IAAI,YAAY;AACzF;AAeO,IAAM,gBAAgB,wBAAgE;AAAA,EAC5F,SAAS;AAAA,EACT,qBAAqB,CAAC,YAAY;AAAA,EAClC,aAAa;AACd,CAAC;;;ACrBD,IAAM,kBAA0D;AAAA,EAC/D,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,UAAU,IAAI,YAAY;AAC1F;AAiBO,IAAM,iBAAiB,wBAAkE;AAAA,EAC/F,SAAS;AAAA,EACT,aAAa;AACd,CAAC;;;ACbM,IAAe,kBAAf,MAAe,iBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrC,OAAO,GAAG,WAA6B;AACtC,QAAI,OAAO,cAAc,WAAY,QAAO;AAE5C,QAAI,QAAiB,OAAO,eAAe,SAAS;AACpD,WAAO,OAAO,UAAU,YAAY;AACnC,UAAI,UAAU,iBAAiB,QAAO;AACtC,cAAQ,OAAO,eAAe,KAAK;AAAA,IACpC;AACA,WAAO;AAAA,EACR;AACD;;;ACfO,IAAM,uBAAuB,CACnC,UACyB;AAAA,EACzB,MAAM,4BAA4B,gBAAgB;AAAA,IAC1C,cAAc;AACpB,YAAM;AAKN,aAAO,MAAM;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AACR;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/locator/gateway/_facades/lanka-gateways/lankaGateways.ts","../../src/locator/scenario/_facades/lanka-scenarios/lankaScenarios.ts","../../src/locator/singleton/_abstractions/lanka-singleton/ALankaSingleton.ts","../../src/locator/singleton/_factories/create-lanka-singleton/createLankaSingleton.ts","../../src/locator/singleton/_facades/lanka-singletons/lankaSingletons.ts","../../src/locator/shared-store/_facades/lanka-shared-stores/lankaSharedStores.ts"],"sourcesContent":["import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport type { TLankaGateways } from \"../../_types/TLankaGateways\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\nimport type { ALankaGateway } from \"../../../../gateway/_abstractions/lanka-gateway/ALankaGateway\";\n\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state would let two\n * frameworks in one process resolve the same gateway. The proxy stays at module\n * level because it has hundreds of call sites; only the cache moved.\n */\nconst gatewayLocator: ILankaLocator<ALankaGateway<unknown>> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.gateways.get(propertyName),\n};\n\n/**\n * Access to every gateway at once.\n *\n * An `ALankaGateway` subclass appears here by itself. The property is camelCase,\n * the gateway name is PascalCase.\n *\n * ```ts\n * import { lankaGateways } from \"lanka\";\n *\n * const user = await lankaGateways.userGateway.getById(1);\n * const list = await lankaGateways.companyGateway.getList({ page: 1 });\n * ```\n */\nexport const lankaGateways = createLankaLocatorProxy<ALankaGateway<unknown>, TLankaGateways>({\n\tlocator: gatewayLocator,\n\tprotectedProperties: [\"clearCache\"],\n\terrorPrefix: \"Cannot access gateway\",\n});\n","import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\nimport type { ILankaScenario } from \"../../../../scenario/_interfaces/ILankaScenario\";\nimport { TLankaScenarios } from \"../../_types/TLankaScenarios\";\n\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state would let two\n * frameworks in one process resolve the same scenario. The proxy stays at module\n * level because it has hundreds of call sites; only the cache moved.\n */\nconst scenarioLocator: ILankaLocator<ILankaScenario<unknown>> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.scenarios.get(propertyName),\n};\n\n/**\n * Access to every scenario at once.\n *\n * An `ALankaScenario` subclass appears here by itself. The property is camelCase,\n * the scenario name is PascalCase.\n *\n * ```ts\n * import { lankaScenarios } from \"lanka\";\n *\n * lankaScenarios.sessionUpdated.trigger({ user });\n * lankaScenarios.usersListRefresh.trigger({ reason: \"create\" });\n *\n * lankaScenarios.usersListRefresh.subscribe((data) => { ... });\n * ```\n */\nexport const lankaScenarios = createLankaLocatorProxy<ILankaScenario<unknown>, TLankaScenarios>({\n\tlocator: scenarioLocator,\n\terrorPrefix: \"Cannot access scenario\",\n});\n","/**\n * The singleton marker: \"this class is published by the application in\n * `lankaSingletons`\".\n *\n * ## Why a marker when the class is exported anyway\n *\n * The other three locators have one: a gateway extends `ALankaGateway`, a\n * scenario has a `name`, a store extends `ALankaSharedStore`. Without a marker\n * the selection is \"anything that is a function with a prototype\", so a stray\n * export in the barrel — a helper, a companion class, an accidental re-export —\n * becomes part of the public `lankaSingletons.*`, and a typo in a name is caught\n * at runtime on first use, far from where it was made.\n *\n * ## A base class rather than a field\n *\n * A marker field can be put on anything, an object included, and the type would\n * again stop telling a class from a non-class. Inheritance also gives TypeScript\n * something it can select on in a mapped type.\n *\n * The class is empty deliberately: all it carries is the statement \"I am meant\n * for the locator\".\n */\nexport abstract class ALankaSingleton {\n\t/**\n\t * A runtime check, for the locator, which cannot see types.\n\t *\n\t * Looks at the prototype chain rather than the name: names are lost to\n\t * minification, and a name check would work only until the build.\n\t */\n\tstatic is(candidate: unknown): boolean {\n\t\tif (typeof candidate !== \"function\") return false;\n\n\t\tlet proto: unknown = Object.getPrototypeOf(candidate) as unknown;\n\t\twhile (typeof proto === \"function\") {\n\t\t\tif (proto === ALankaSingleton) return true;\n\t\t\tproto = Object.getPrototypeOf(proto) as unknown;\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { ALankaSingleton } from \"../../_abstractions/lanka-singleton/ALankaSingleton\";\n\n/**\n * The functional style of `ALankaSingleton`: a singleton declared by a function.\n *\n * A singleton is a role — an application writes many — and this is the same role\n * the class style declares by extending the marker. What comes back IS a subclass\n * of `ALankaSingleton`, so the locator discovers it in the consumer's barrel,\n * builds it on first use and caches it, exactly as it does a hand-written class.\n *\n * ```ts\n * export const PlaygroundClock = createLankaSingleton(() => ({\n * \tnow: () => Date.now(),\n * }));\n * ```\n *\n * The result is exported under a PascalCase name because it is a class: the\n * locator resolves `lankaSingletons.playgroundClock` by that export name, and a\n * camelCase one would read as the instance while being the constructor.\n *\n * The builder runs at first resolution, not here — a singleton declared in a\n * module body must not touch a runtime that does not exist yet. Canon:\n * `skills/parity/SKILL.md`.\n */\nexport const createLankaSingleton = <TInstance extends object>(\n\tbuild: () => TInstance,\n): new () => TInstance => {\n\tclass FunctionalSingleton extends ALankaSingleton {\n\t\tpublic constructor() {\n\t\t\tsuper();\n\n\t\t\t// A constructor answering an object is what makes the two styles one\n\t\t\t// implementation: the locator constructs a marked class either way, and\n\t\t\t// what it gets back is what the builder returned.\n\t\t\treturn build();\n\t\t}\n\t}\n\n\treturn FunctionalSingleton as unknown as new () => TInstance;\n};\n","import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport type { TLankaSingletons } from \"../../../_types/TLankaSingletons\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\n\n/**\n * Access to every singleton at once.\n *\n * A class appears here by itself as soon as the consumer's barrel exports it.\n * The property is camelCase, the class name PascalCase.\n *\n * ```ts\n * import { lankaSingletons } from \"lanka\";\n *\n * const profile = lankaSingletons.userProfile;\n * ```\n *\n * `LankaSingletonLocator` itself registers a class or a ready object by hand —\n * for tests and for objects that arrive already built. Those methods are NOT\n * called through this proxy: `registerSingleton`,\n * `registerSingletonInstance`, `unregisterSingleton`, `isRegistered` and\n * `clearCache` are closed here deliberately, or reaching for them would read as\n * a request for a singleton by that name and the failure would come from the\n * wrong place.\n */\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state means two\n * frameworks in one process resolve the same gateway. The proxy stays in\n * place; what moved is the cache.\n */\nconst singletonLocator: ILankaLocator<unknown> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.singletons.get(propertyName),\n};\n\nexport const lankaSingletons = createLankaLocatorProxy<unknown, TLankaSingletons>({\n\tlocator: singletonLocator,\n\tprotectedProperties: [\n\t\t\"clearCache\",\n\t\t\"register\",\n\t\t\"registerInstance\",\n\t\t\"unregister\",\n\t\t\"isRegistered\",\n\t],\n\terrorPrefix: \"Cannot access singleton\",\n});\n","import { requireActiveRuntime } from \"../../../../_internal/active-runtime/activeRuntime\";\nimport type { ILankaLocator } from \"../../../_interfaces/ILankaLocator\";\nimport { createLankaLocatorProxy } from \"../../../_factories/create-lanka-locator-proxy/createLankaLocatorProxy\";\nimport { ALankaSharedStore } from \"../../../../viewmodel/_abstractions/lanka-shared-store/ALankaSharedStore\";\nimport type { TLankaSharedStores } from \"../../_types/TLankaSharedStores\";\n\n/**\n * The locator comes from the active instance rather than being created here.\n *\n * The cache of resolved objects is state, and module-level state would let two\n * frameworks in one process resolve the same store. The proxy stays at module\n * level because it has hundreds of call sites; only the cache moved.\n */\nconst sharedStoreLocator: ILankaLocator<ALankaSharedStore<object>> = {\n\tget: (propertyName: string) => requireActiveRuntime().locators.sharedStores.get(propertyName),\n};\n\n/**\n * Access to every shared store at once.\n *\n * An `ALankaSharedStore` subclass appears here by itself once it is exported from\n * `@lanka_di/SharedStores`. The property is camelCase, the class name PascalCase.\n */\nexport const lankaSharedStores = createLankaLocatorProxy<\n\tALankaSharedStore<object>,\n\tTLankaSharedStores\n>({\n\tlocator: sharedStoreLocator,\n\tprotectedProperties: [\n\t\t\"clearCache\",\n\t\t\"register\",\n\t\t\"registerInstance\",\n\t\t\"unregister\",\n\t\t\"isRegistered\",\n\t],\n\terrorPrefix: \"Cannot access shared store\",\n});\n"],"mappings":";;;;;;;;AAaA,IAAM,iBAAwD;AAAA,EAC7D,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,SAAS,IAAI,YAAY;AACzF;AAeO,IAAM,gBAAgB,wBAAgE;AAAA,EAC5F,SAAS;AAAA,EACT,qBAAqB,CAAC,YAAY;AAAA,EAClC,aAAa;AACd,CAAC;;;ACrBD,IAAM,kBAA0D;AAAA,EAC/D,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,UAAU,IAAI,YAAY;AAC1F;AAiBO,IAAM,iBAAiB,wBAAkE;AAAA,EAC/F,SAAS;AAAA,EACT,aAAa;AACd,CAAC;;;ACbM,IAAe,kBAAf,MAAe,iBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrC,OAAO,GAAG,WAA6B;AACtC,QAAI,OAAO,cAAc,WAAY,QAAO;AAE5C,QAAI,QAAiB,OAAO,eAAe,SAAS;AACpD,WAAO,OAAO,UAAU,YAAY;AACnC,UAAI,UAAU,iBAAiB,QAAO;AACtC,cAAQ,OAAO,eAAe,KAAK;AAAA,IACpC;AACA,WAAO;AAAA,EACR;AACD;;;ACfO,IAAM,uBAAuB,CACnC,UACyB;AAAA,EACzB,MAAM,4BAA4B,gBAAgB;AAAA,IAC1C,cAAc;AACpB,YAAM;AAKN,aAAO,MAAM;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AACR;;;ACPA,IAAM,mBAA2C;AAAA,EAChD,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,WAAW,IAAI,YAAY;AAC3F;AAEO,IAAM,kBAAkB,wBAAmD;AAAA,EACjF,SAAS;AAAA,EACT,qBAAqB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,aAAa;AACd,CAAC;;;ACjCD,IAAM,qBAA+D;AAAA,EACpE,KAAK,CAAC,iBAAyB,qBAAqB,EAAE,SAAS,aAAa,IAAI,YAAY;AAC7F;AAQO,IAAM,oBAAoB,wBAG/B;AAAA,EACD,SAAS;AAAA,EACT,qBAAqB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,aAAa;AACd,CAAC;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LankaScenarioLocator
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-RZGBLXXL.js";
|
|
3
|
+
} from "../../../chunk-EH5WZSRJ.js";
|
|
5
4
|
import "../../../chunk-N3275IPH.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-
|
|
5
|
+
import "../../../chunk-L27FF2IH.js";
|
|
6
|
+
import "../../../chunk-AMLUKB6A.js";
|
|
7
|
+
import "../../../chunk-SP5OUTWF.js";
|
|
8
|
+
import "../../../chunk-XTVEHYIZ.js";
|
|
9
9
|
export {
|
|
10
10
|
LankaScenarioLocator
|
|
11
11
|
};
|
package/dist/logger/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LankaLogger,
|
|
3
3
|
lankaLogger
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-AMLUKB6A.js";
|
|
5
|
+
import "../chunk-SP5OUTWF.js";
|
|
6
|
+
import "../chunk-XTVEHYIZ.js";
|
|
7
7
|
export {
|
|
8
8
|
LankaLogger,
|
|
9
9
|
lankaLogger
|
package/dist/mock/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
lankaLogger
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-AMLUKB6A.js";
|
|
4
4
|
import {
|
|
5
5
|
getLankaFlags
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-SP5OUTWF.js";
|
|
7
|
+
import "../chunk-XTVEHYIZ.js";
|
|
8
8
|
|
|
9
9
|
// src/_internal/sleep.ts
|
|
10
10
|
var sleep = (ms = 300) => {
|