@cldmv/slothlet 2.11.0 → 3.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/AGENT-USAGE.md +355 -325
- package/README.md +554 -238
- package/dist/lib/builders/api-assignment.mjs +605 -0
- package/dist/lib/builders/api_builder.mjs +1073 -0
- package/dist/lib/builders/builder.mjs +94 -0
- package/dist/lib/builders/modes-processor.mjs +1816 -0
- package/dist/lib/errors.mjs +227 -0
- package/dist/lib/factories/component-base.mjs +96 -0
- package/dist/lib/factories/context.mjs +38 -0
- package/dist/lib/handlers/api-cache-manager.mjs +216 -0
- package/dist/lib/handlers/api-manager.mjs +2364 -0
- package/dist/lib/handlers/context-async.mjs +184 -0
- package/dist/lib/handlers/context-live.mjs +184 -0
- package/dist/lib/handlers/hook-manager.mjs +789 -0
- package/dist/lib/handlers/lifecycle-token.mjs +44 -0
- package/dist/lib/handlers/lifecycle.mjs +131 -0
- package/dist/lib/handlers/materialize-manager.mjs +64 -0
- package/dist/lib/handlers/metadata.mjs +500 -0
- package/dist/lib/handlers/ownership.mjs +338 -0
- package/dist/lib/handlers/unified-wrapper.mjs +3031 -0
- package/dist/lib/helpers/class-instance-wrapper.mjs +125 -0
- package/dist/lib/helpers/config.mjs +343 -0
- package/dist/lib/helpers/eventemitter-context.mjs +365 -0
- package/dist/lib/helpers/hint-detector.mjs +63 -0
- package/dist/lib/helpers/modes-utils.mjs +53 -0
- package/dist/lib/helpers/resolve-from-caller.mjs +123 -117
- package/dist/lib/helpers/sanitize.mjs +247 -168
- package/dist/lib/helpers/utilities.mjs +46 -81
- package/dist/lib/i18n/languages/de-de.json +377 -0
- package/dist/lib/i18n/languages/en-gb.json +377 -0
- package/dist/lib/i18n/languages/en-us.json +377 -0
- package/dist/lib/i18n/languages/es-mx.json +377 -0
- package/dist/lib/i18n/languages/fr-fr.json +377 -0
- package/dist/lib/i18n/languages/hi-in.json +377 -0
- package/dist/lib/i18n/languages/ja-jp.json +377 -0
- package/dist/lib/i18n/languages/ko-kr.json +377 -0
- package/dist/lib/i18n/languages/pt-br.json +377 -0
- package/dist/lib/i18n/languages/ru-ru.json +377 -0
- package/dist/lib/i18n/languages/zh-cn.json +377 -0
- package/dist/lib/i18n/translations.mjs +140 -0
- package/dist/lib/modes/eager.mjs +75 -0
- package/dist/lib/modes/lazy.mjs +97 -0
- package/dist/lib/processors/flatten.mjs +453 -0
- package/dist/lib/processors/loader.mjs +355 -0
- package/dist/lib/processors/type-generator.mjs +291 -0
- package/dist/lib/processors/typescript.mjs +188 -0
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +80 -522
- package/dist/lib/runtime/runtime-livebindings.mjs +45 -390
- package/dist/lib/runtime/runtime.mjs +39 -159
- package/dist/slothlet.mjs +525 -744
- package/docs/API-RULES.md +338 -486
- package/index.cjs +4 -4
- package/index.mjs +82 -45
- package/package.json +143 -30
- package/types/dist/lib/builders/api-assignment.d.mts +97 -0
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -0
- package/types/dist/lib/builders/api_builder.d.mts +96 -0
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -0
- package/types/dist/lib/builders/builder.d.mts +60 -0
- package/types/dist/lib/builders/builder.d.mts.map +1 -0
- package/types/dist/lib/builders/modes-processor.d.mts +32 -0
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -0
- package/types/dist/lib/errors.d.mts +118 -0
- package/types/dist/lib/errors.d.mts.map +1 -0
- package/types/dist/lib/factories/component-base.d.mts +182 -0
- package/types/dist/lib/factories/component-base.d.mts.map +1 -0
- package/types/dist/lib/factories/context.d.mts +26 -0
- package/types/dist/lib/factories/context.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts +208 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-manager.d.mts +392 -0
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-async.d.mts +66 -0
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-live.d.mts +65 -0
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -0
- package/types/dist/lib/handlers/hook-manager.d.mts +199 -0
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts +49 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle.d.mts +90 -0
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts +75 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/metadata.d.mts +215 -0
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -0
- package/types/dist/lib/handlers/ownership.d.mts +170 -0
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts +250 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +54 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/config.d.mts +96 -0
- package/types/dist/lib/helpers/config.d.mts.map +1 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts +31 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -0
- package/types/dist/lib/helpers/hint-detector.d.mts +20 -0
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -0
- package/types/dist/lib/helpers/modes-utils.d.mts +35 -0
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -0
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +29 -145
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +95 -94
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +53 -116
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +39 -0
- package/types/dist/lib/i18n/translations.d.mts.map +1 -0
- package/types/dist/lib/modes/eager.d.mts +36 -0
- package/types/dist/lib/modes/eager.d.mts.map +1 -0
- package/types/dist/lib/modes/lazy.d.mts +49 -0
- package/types/dist/lib/modes/lazy.d.mts.map +1 -0
- package/types/dist/lib/processors/flatten.d.mts +114 -0
- package/types/dist/lib/processors/flatten.d.mts.map +1 -0
- package/types/dist/lib/processors/loader.d.mts +47 -0
- package/types/dist/lib/processors/loader.d.mts.map +1 -0
- package/types/dist/lib/processors/type-generator.d.mts +19 -0
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -0
- package/types/dist/lib/processors/typescript.d.mts +55 -0
- package/types/dist/lib/processors/typescript.d.mts.map +1 -0
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +47 -42
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +34 -65
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +39 -9
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +184 -111
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +1 -3
- package/dist/lib/engine/README.md +0 -21
- package/dist/lib/engine/slothlet_child.mjs +0 -59
- package/dist/lib/engine/slothlet_engine.mjs +0 -372
- package/dist/lib/engine/slothlet_esm.mjs +0 -230
- package/dist/lib/engine/slothlet_helpers.mjs +0 -455
- package/dist/lib/engine/slothlet_worker.mjs +0 -149
- package/dist/lib/helpers/als-eventemitter.mjs +0 -256
- package/dist/lib/helpers/api_builder/add_api.mjs +0 -553
- package/dist/lib/helpers/api_builder/analysis.mjs +0 -532
- package/dist/lib/helpers/api_builder/construction.mjs +0 -495
- package/dist/lib/helpers/api_builder/decisions.mjs +0 -748
- package/dist/lib/helpers/api_builder/metadata.mjs +0 -248
- package/dist/lib/helpers/api_builder.mjs +0 -41
- package/dist/lib/helpers/auto-wrap.mjs +0 -62
- package/dist/lib/helpers/hooks.mjs +0 -389
- package/dist/lib/helpers/instance-manager.mjs +0 -111
- package/dist/lib/helpers/metadata-api.mjs +0 -201
- package/dist/lib/helpers/multidefault.mjs +0 -216
- package/dist/lib/modes/slothlet_eager.mjs +0 -154
- package/dist/lib/modes/slothlet_lazy.mjs +0 -594
- package/docs/API-RULES-CONDITIONS.md +0 -712
- package/types/dist/lib/engine/slothlet_child.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_child.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_engine.d.mts +0 -31
- package/types/dist/lib/engine/slothlet_engine.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_esm.d.mts +0 -19
- package/types/dist/lib/engine/slothlet_esm.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_helpers.d.mts +0 -25
- package/types/dist/lib/engine/slothlet_helpers.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_worker.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_worker.d.mts.map +0 -1
- package/types/dist/lib/helpers/als-eventemitter.d.mts +0 -56
- package/types/dist/lib/helpers/als-eventemitter.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/add_api.d.mts +0 -102
- package/types/dist/lib/helpers/api_builder/add_api.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/analysis.d.mts +0 -189
- package/types/dist/lib/helpers/api_builder/analysis.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/construction.d.mts +0 -107
- package/types/dist/lib/helpers/api_builder/construction.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/decisions.d.mts +0 -213
- package/types/dist/lib/helpers/api_builder/decisions.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/metadata.d.mts +0 -99
- package/types/dist/lib/helpers/api_builder/metadata.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder.d.mts +0 -6
- package/types/dist/lib/helpers/api_builder.d.mts.map +0 -1
- package/types/dist/lib/helpers/auto-wrap.d.mts +0 -49
- package/types/dist/lib/helpers/auto-wrap.d.mts.map +0 -1
- package/types/dist/lib/helpers/hooks.d.mts +0 -342
- package/types/dist/lib/helpers/hooks.d.mts.map +0 -1
- package/types/dist/lib/helpers/instance-manager.d.mts +0 -41
- package/types/dist/lib/helpers/instance-manager.d.mts.map +0 -1
- package/types/dist/lib/helpers/metadata-api.d.mts +0 -132
- package/types/dist/lib/helpers/metadata-api.d.mts.map +0 -1
- package/types/dist/lib/helpers/multidefault.d.mts +0 -90
- package/types/dist/lib/helpers/multidefault.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_eager.d.mts +0 -65
- package/types/dist/lib/modes/slothlet_eager.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_lazy.d.mts +0 -31
- package/types/dist/lib/modes/slothlet_lazy.d.mts.map +0 -1
- package/types/index.d.mts.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eager mode component - builds APIs by loading all modules immediately.
|
|
3
|
+
* @class EagerMode
|
|
4
|
+
* @extends ComponentBase
|
|
5
|
+
* @package
|
|
6
|
+
*/
|
|
7
|
+
export class EagerMode extends ComponentBase {
|
|
8
|
+
static slothletProperty: string;
|
|
9
|
+
/**
|
|
10
|
+
* Build API in eager mode (load all modules immediately).
|
|
11
|
+
* @param {Object} options - Build options
|
|
12
|
+
* @param {string} options.dir - Directory path to load from
|
|
13
|
+
* @param {string} [options.apiPathPrefix=""] - Prefix for API paths
|
|
14
|
+
* @param {string} [options.collisionContext="initial"] - Collision context
|
|
15
|
+
* @param {string} [options.moduleID] - Module ID
|
|
16
|
+
* @param {number} [options.apiDepth=Infinity] - Maximum directory depth
|
|
17
|
+
* @param {string|null} [options.cacheBust=null] - Cache-busting value
|
|
18
|
+
* @param {Function|null} [options.fileFilter=null] - Optional filter (fileName) => boolean
|
|
19
|
+
* @returns {Promise<Object>} Built API object
|
|
20
|
+
* @public
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const api = await slothlet.modes.eager.buildAPI({ dir: "./api", moduleID: "base" });
|
|
24
|
+
*/
|
|
25
|
+
public buildAPI({ dir, apiPathPrefix, collisionContext, moduleID, apiDepth, cacheBust, fileFilter }: {
|
|
26
|
+
dir: string;
|
|
27
|
+
apiPathPrefix?: string;
|
|
28
|
+
collisionContext?: string;
|
|
29
|
+
moduleID?: string;
|
|
30
|
+
apiDepth?: number;
|
|
31
|
+
cacheBust?: string | null;
|
|
32
|
+
fileFilter?: Function | null;
|
|
33
|
+
}): Promise<any>;
|
|
34
|
+
}
|
|
35
|
+
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
36
|
+
//# sourceMappingURL=eager.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager.d.mts","sourceRoot":"","sources":["../../../../dist/lib/modes/eager.mjs"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH;IACC,gCAAkC;IAWlC;;;;;;;;;;;;;;;OAeG;IACH,qGAbG;QAAwB,GAAG,EAAnB,MAAM;QACW,aAAa,GAA9B,MAAM;QACW,gBAAgB,GAAjC,MAAM;QACW,QAAQ,GAAzB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACgB,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,UAAU,GAAlC,WAAS,IAAI;KACrB,GAAU,OAAO,KAAQ,CAgD3B;CACD;8BA/E6B,0CAA0C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy mode component - builds APIs with deferred (on-demand) loading.
|
|
3
|
+
* @class LazyMode
|
|
4
|
+
* @extends ComponentBase
|
|
5
|
+
* @package
|
|
6
|
+
*/
|
|
7
|
+
export class LazyMode extends ComponentBase {
|
|
8
|
+
static slothletProperty: string;
|
|
9
|
+
/**
|
|
10
|
+
* Create a named async materialization function for lazy subdirectories.
|
|
11
|
+
* @param {string} apiPath - API path to derive the function name from.
|
|
12
|
+
* @param {Function} handler - Async handler that performs materialization.
|
|
13
|
+
* @returns {Function} Named async materialization function.
|
|
14
|
+
* @public
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const fn = lazyMode.createNamedMaterializeFunc('api.math', async () => ({ add: (a,b) => a+b }));
|
|
18
|
+
*/
|
|
19
|
+
public createNamedMaterializeFunc(apiPath: string, handler: Function): Function;
|
|
20
|
+
/**
|
|
21
|
+
* Build API in lazy mode (proxy-based deferred loading).
|
|
22
|
+
* @param {Object} options - Build options
|
|
23
|
+
* @param {string} options.dir - Directory to build from
|
|
24
|
+
* @param {string} [options.apiPathPrefix=""] - Prefix for API paths
|
|
25
|
+
* @param {string} [options.collisionContext="initial"] - Collision context
|
|
26
|
+
* @param {string|null} [options.collisionMode=null] - Collision mode override from api.add()
|
|
27
|
+
* @param {string} [options.moduleID] - Module ID
|
|
28
|
+
* @param {number} [options.apiDepth=Infinity] - Maximum directory depth
|
|
29
|
+
* @param {string|null} [options.cacheBust=null] - Cache-busting value
|
|
30
|
+
* @param {Function|null} [options.fileFilter=null] - Optional filter (fileName) => boolean
|
|
31
|
+
* @returns {Promise<Object>} Built API object with lazy proxies
|
|
32
|
+
* @public
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const api = await slothlet.modes.lazy.buildAPI({ dir: "./api", moduleID: "base" });
|
|
36
|
+
*/
|
|
37
|
+
public buildAPI({ dir, apiPathPrefix, collisionContext, collisionMode, moduleID, apiDepth, cacheBust, fileFilter }: {
|
|
38
|
+
dir: string;
|
|
39
|
+
apiPathPrefix?: string;
|
|
40
|
+
collisionContext?: string;
|
|
41
|
+
collisionMode?: string | null;
|
|
42
|
+
moduleID?: string;
|
|
43
|
+
apiDepth?: number;
|
|
44
|
+
cacheBust?: string | null;
|
|
45
|
+
fileFilter?: Function | null;
|
|
46
|
+
}): Promise<any>;
|
|
47
|
+
}
|
|
48
|
+
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
49
|
+
//# sourceMappingURL=lazy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.mts","sourceRoot":"","sources":["../../../../dist/lib/modes/lazy.mjs"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH;IACC,gCAAiC;IAWjC;;;;;;;;;OASG;IACH,2CARW,MAAM,+BAmBhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,oHAdG;QAAwB,GAAG,EAAnB,MAAM;QACW,aAAa,GAA9B,MAAM;QACW,gBAAgB,GAAjC,MAAM;QACgB,aAAa,GAAnC,MAAM,GAAC,IAAI;QACM,QAAQ,GAAzB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACgB,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,UAAU,GAAlC,WAAS,IAAI;KACrB,GAAU,OAAO,KAAQ,CAwD3B;CACD;8BA/G6B,0CAA0C"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattening decision processor
|
|
3
|
+
* @class Flatten
|
|
4
|
+
* @extends ComponentBase
|
|
5
|
+
* @package
|
|
6
|
+
*/
|
|
7
|
+
export class Flatten extends ComponentBase {
|
|
8
|
+
static slothletProperty: string;
|
|
9
|
+
/**
|
|
10
|
+
* Core flattening decision function.
|
|
11
|
+
* Implements conditions C01-C07 from getFlatteningDecision().
|
|
12
|
+
* @param {object} options - Decision options
|
|
13
|
+
* @param {object} options.mod - Module exports
|
|
14
|
+
* @param {string} options.moduleName - Sanitized module name
|
|
15
|
+
* @param {string} options.categoryName - Category/folder name
|
|
16
|
+
* @param {object} options.analysis - Export analysis
|
|
17
|
+
* @param {boolean} options.hasMultipleDefaults - Multiple defaults in folder
|
|
18
|
+
* @param {array} options.moduleKeys - Keys from module
|
|
19
|
+
* @param {function} options.t - Translation function
|
|
20
|
+
* @returns {Promise<object>} Flattening decision
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
public getFlatteningDecision(options: {
|
|
24
|
+
mod: object;
|
|
25
|
+
moduleName: string;
|
|
26
|
+
categoryName: string;
|
|
27
|
+
analysis: object;
|
|
28
|
+
hasMultipleDefaults: boolean;
|
|
29
|
+
moduleKeys: any[];
|
|
30
|
+
t: Function;
|
|
31
|
+
}): Promise<object>;
|
|
32
|
+
/**
|
|
33
|
+
* Build module content for API assignment.
|
|
34
|
+
*
|
|
35
|
+
* Canonical implementation of the C08-C09b content-building rules, including
|
|
36
|
+
* AddApi detection and collision handling. Previously this logic was inlined
|
|
37
|
+
* inside modes-processor.mjs; it now lives here so the processor stays focused
|
|
38
|
+
* on wrapping and assignment concerns only.
|
|
39
|
+
*
|
|
40
|
+
* Collision config, modesUtils helpers, and SlothletWarning are accessed
|
|
41
|
+
* directly through {@link this.slothlet} / {@link this.slothlet.config} — no caller
|
|
42
|
+
* plumbing required.
|
|
43
|
+
*
|
|
44
|
+
* @param {object} options - Processing options.
|
|
45
|
+
* @param {object} options.mod - Module exports.
|
|
46
|
+
* @param {object} options.decision - Flattening decision from getFlatteningDecision.
|
|
47
|
+
* @param {string} options.moduleName - Sanitized module name (used for C08 auto-flatten key lookup).
|
|
48
|
+
* @param {string} options.propertyName - Resolved preferred name (decision.preferredName || moduleName).
|
|
49
|
+
* @param {string[]} options.moduleKeys - Named export keys (excluding "default").
|
|
50
|
+
* @param {object} options.analysis - { hasDefault, hasNamed, defaultExportType }.
|
|
51
|
+
* @param {object} [options.file=null] - File descriptor for AddApi detection via file.name / file.fullName.
|
|
52
|
+
* @param {string} [options.collisionContext="initial"] - Collision context ("initial" | "api").
|
|
53
|
+
* @param {string} [options.apiPathPrefix=""] - API path prefix for collision error messages.
|
|
54
|
+
* @returns {{ moduleContent: object|Function }} Built module content ready for wrapping/assignment.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
public processModuleForAPI(options: {
|
|
58
|
+
mod: object;
|
|
59
|
+
decision: object;
|
|
60
|
+
moduleName: string;
|
|
61
|
+
propertyName: string;
|
|
62
|
+
moduleKeys: string[];
|
|
63
|
+
analysis: object;
|
|
64
|
+
file?: object;
|
|
65
|
+
collisionContext?: string;
|
|
66
|
+
apiPathPrefix?: string;
|
|
67
|
+
}): {
|
|
68
|
+
moduleContent: object | Function;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Build category-level flattening decisions.
|
|
72
|
+
* Implements conditions C10-C33 from buildCategoryDecisions().
|
|
73
|
+
* @param {object} options - Category options
|
|
74
|
+
* @param {string} options.categoryName - Category name
|
|
75
|
+
* @param {object} options.mod - Module exports
|
|
76
|
+
* @param {string} options.moduleName - Module name
|
|
77
|
+
* @param {string} options.fileBaseName - File base name
|
|
78
|
+
* @param {object} options.analysis - Export analysis
|
|
79
|
+
* @param {array} options.moduleKeys - Module keys
|
|
80
|
+
* @param {number} options.currentDepth - Current depth
|
|
81
|
+
* @param {array} options.moduleFiles - Files in category
|
|
82
|
+
* @param {function} options.t - Translation function
|
|
83
|
+
* @returns {Promise<object>} Category decision
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
public buildCategoryDecisions(options: {
|
|
87
|
+
categoryName: string;
|
|
88
|
+
mod: object;
|
|
89
|
+
moduleName: string;
|
|
90
|
+
fileBaseName: string;
|
|
91
|
+
analysis: object;
|
|
92
|
+
moduleKeys: any[];
|
|
93
|
+
currentDepth: number;
|
|
94
|
+
moduleFiles: any[];
|
|
95
|
+
t: Function;
|
|
96
|
+
}): Promise<object>;
|
|
97
|
+
/**
|
|
98
|
+
* Decide whether a named export should be attached to a callable default export.
|
|
99
|
+
*
|
|
100
|
+
* Returns false when the named export is the same reference as the default (re-export
|
|
101
|
+
* pattern), or when the export key matches the function name (self-referential export).
|
|
102
|
+
*
|
|
103
|
+
* @param {string} key - Named export key.
|
|
104
|
+
* @param {unknown} value - Named export value.
|
|
105
|
+
* @param {Function} defaultFunc - Wrapped callable default export.
|
|
106
|
+
* @param {Function} originalDefault - Original default export.
|
|
107
|
+
* @returns {boolean} True if the export should be attached.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
public shouldAttachNamedExport(key: string, value: unknown, defaultFunc: Function, originalDefault: Function): boolean;
|
|
111
|
+
#private;
|
|
112
|
+
}
|
|
113
|
+
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
114
|
+
//# sourceMappingURL=flatten.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.mts","sourceRoot":"","sources":["../../../../dist/lib/processors/flatten.mjs"],"names":[],"mappings":"AA8BA;;;;;GAKG;AACH;IACC,gCAAoC;IAgEpC;;;;;;;;;;;;;OAaG;IACH,sCAVG;QAAwB,GAAG,EAAnB,MAAM;QACU,UAAU,EAA1B,MAAM;QACU,YAAY,EAA5B,MAAM;QACU,QAAQ,EAAxB,MAAM;QACW,mBAAmB,EAApC,OAAO;QACQ,UAAU;QACP,CAAC;KAC3B,GAAU,OAAO,CAAC,MAAM,CAAC,CAiG3B;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,oCAZG;QAA0B,GAAG,EAArB,MAAM;QACY,QAAQ,EAA1B,MAAM;QACY,UAAU,EAA5B,MAAM;QACY,YAAY,EAA9B,MAAM;QACY,UAAU,EAA5B,MAAM,EAAE;QACU,QAAQ,EAA1B,MAAM;QACa,IAAI,GAAvB,MAAM;QACa,gBAAgB,GAAnC,MAAM;QACa,aAAa,GAAhC,MAAM;KACd,GAAU;QAAE,aAAa,EAAE,MAAM,WAAS,CAAA;KAAE,CAqI9C;IAED;;;;;;;;;;;;;;;OAeG;IACH,uCAZG;QAAwB,YAAY,EAA5B,MAAM;QACU,GAAG,EAAnB,MAAM;QACU,UAAU,EAA1B,MAAM;QACU,YAAY,EAA5B,MAAM;QACU,QAAQ,EAAxB,MAAM;QACS,UAAU;QACT,YAAY,EAA5B,MAAM;QACS,WAAW;QACR,CAAC;KAC3B,GAAU,OAAO,CAAC,MAAM,CAAC,CAiJ3B;IAED;;;;;;;;;;;;OAYG;IACH,oCAPW,MAAM,SACN,OAAO,qDAGL,OAAO,CAiBnB;;CACD;8BAhhB6B,0CAA0C"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader component for module loading, directory scanning, and API merging
|
|
3
|
+
* @class Loader
|
|
4
|
+
* @extends ComponentBase
|
|
5
|
+
* @package
|
|
6
|
+
*/
|
|
7
|
+
export class Loader extends ComponentBase {
|
|
8
|
+
static slothletProperty: string;
|
|
9
|
+
constructor(slothlet: any);
|
|
10
|
+
/**
|
|
11
|
+
* Load a single module
|
|
12
|
+
* @param {string} filePath - Path to module file
|
|
13
|
+
* @param {string} [instanceID] - Slothlet instance ID for cache busting
|
|
14
|
+
* @param {string} [moduleID] - Module ID for additional cache busting (used in api.slothlet.api.add)
|
|
15
|
+
* @param {number|null} [cacheBust=null] - Timestamp for reload cache busting (forces fresh import)
|
|
16
|
+
* @returns {Promise<Object>} Loaded module
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
public loadModule(filePath: string, instanceID?: string, moduleID?: string, cacheBust?: number | null): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Scan directory for module files
|
|
22
|
+
* @param {string} dir - Directory to scan
|
|
23
|
+
* @param {Object} [options={}] - Scan options
|
|
24
|
+
* @param {boolean} [options.isRootScan=true] - Whether this is the root directory scan (shows empty dir warning)
|
|
25
|
+
* @param {number} [options.currentDepth=0] - Current traversal depth
|
|
26
|
+
* @param {number} [options.maxDepth=Infinity] - Maximum traversal depth
|
|
27
|
+
* @param {Function|null} [options.fileFilter=null] - Optional filter function (fileName) => boolean to load specific files only
|
|
28
|
+
* @returns {Promise<Object>} Directory structure
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
public scanDirectory(dir: string, options?: {
|
|
32
|
+
isRootScan?: boolean;
|
|
33
|
+
currentDepth?: number;
|
|
34
|
+
maxDepth?: number;
|
|
35
|
+
fileFilter?: Function | null;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Extract exports from module
|
|
39
|
+
* @param {Object} module - Loaded module
|
|
40
|
+
* @returns {Object} Extracted exports
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
public extractExports(module: any): any;
|
|
44
|
+
#private;
|
|
45
|
+
}
|
|
46
|
+
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
47
|
+
//# sourceMappingURL=loader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.mts","sourceRoot":"","sources":["../../../../dist/lib/processors/loader.mjs"],"names":[],"mappings":"AA8BA;;;;;GAKG;AACH;IACC,gCAAmC;IAEnC,2BAEC;IAED;;;;;;;;OAQG;IACH,4BAPW,MAAM,eACN,MAAM,aACN,MAAM,cACN,MAAM,GAAC,IAAI,GACT,OAAO,KAAQ,CAwK3B;IAuCD;;;;;;;;;;OAUG;IACH,0BATW,MAAM,YAEd;QAA0B,UAAU,GAA5B,OAAO;QACU,YAAY,GAA7B,MAAM;QACW,QAAQ,GAAzB,MAAM;QACkB,UAAU,GAAlC,WAAS,IAAI;KACrB,GAAU,OAAO,KAAQ,CA0F3B;IAED;;;;;OAKG;IACH,wCAoCC;;CACD;8BAnX6B,0CAA0C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate TypeScript declaration file for a Slothlet API
|
|
3
|
+
* @param {object} api - The loaded Slothlet API
|
|
4
|
+
* @param {object} options - Generation options
|
|
5
|
+
* @param {string} options.output - Output file path for .d.ts
|
|
6
|
+
* @param {string} options.interfaceName - Name of the interface to generate
|
|
7
|
+
* @param {boolean} [options.includeDocumentation=true] - Include JSDoc comments
|
|
8
|
+
* @returns {Promise<{output: string, filePath: string}>} Generated declaration and output path
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function generateTypes(api: object, options: {
|
|
12
|
+
output: string;
|
|
13
|
+
interfaceName: string;
|
|
14
|
+
includeDocumentation?: boolean;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
output: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=type-generator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-generator.d.mts","sourceRoot":"","sources":["../../../../dist/lib/processors/type-generator.mjs"],"names":[],"mappings":"AA8CA;;;;;;;;;GASG;AACH,mCARW,MAAM,WAEd;IAAwB,MAAM,EAAtB,MAAM;IACU,aAAa,EAA7B,MAAM;IACY,oBAAoB,GAAtC,OAAO;CACf,GAAU,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAqDvD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform TypeScript code to JavaScript using esbuild
|
|
3
|
+
* @param {string} filePath - Path to the TypeScript file
|
|
4
|
+
* @param {object} [options={}] - esbuild transform options
|
|
5
|
+
* @param {string} [options.target] - ECMAScript target version (default: "es2020")
|
|
6
|
+
* @param {string} [options.format] - Module format (default: "esm")
|
|
7
|
+
* @param {boolean} [options.sourcemap] - Generate source maps (default: false)
|
|
8
|
+
* @returns {Promise<string>} Transformed JavaScript code
|
|
9
|
+
* @throws {SlothletError} If transformation fails
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export function transformTypeScript(filePath: string, options?: {
|
|
13
|
+
target?: string;
|
|
14
|
+
format?: string;
|
|
15
|
+
sourcemap?: boolean;
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a data URL for dynamic import with cache busting
|
|
19
|
+
* @param {string} code - JavaScript code to encode
|
|
20
|
+
* @returns {string} Data URL suitable for dynamic import
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export function createDataUrl(code: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Transform TypeScript code to JavaScript using tsc with type checking
|
|
26
|
+
* @param {string} filePath - Path to the TypeScript file
|
|
27
|
+
* @param {object} [options={}] - TypeScript compiler options
|
|
28
|
+
* @param {string} [options.target] - ECMAScript target version (default: "ES2020")
|
|
29
|
+
* @param {string} [options.module] - Module format (default: "ESNext")
|
|
30
|
+
* @param {boolean} [options.strict] - Enable strict type checking (default: true)
|
|
31
|
+
* @param {boolean} [options.skipTypeCheck] - Skip type checking and only transform (default: false)
|
|
32
|
+
* @param {string} [options.typeDefinitionPath] - Path to .d.ts file for type checking
|
|
33
|
+
* @returns {Promise<{code: string, diagnostics: object[]}>} Transformed code and type diagnostics
|
|
34
|
+
* @throws {SlothletError} If transformation fails
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export function transformTypeScriptStrict(filePath: string, options?: {
|
|
38
|
+
target?: string;
|
|
39
|
+
module?: string;
|
|
40
|
+
strict?: boolean;
|
|
41
|
+
skipTypeCheck?: boolean;
|
|
42
|
+
typeDefinitionPath?: string;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
code: string;
|
|
45
|
+
diagnostics: object[];
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Format TypeScript diagnostics into readable error messages
|
|
49
|
+
* @param {object[]} diagnostics - TypeScript diagnostic objects
|
|
50
|
+
* @param {object} ts - TypeScript module instance
|
|
51
|
+
* @returns {string[]} Array of formatted error messages
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
export function formatDiagnostics(diagnostics: object[], ts: object): string[];
|
|
55
|
+
//# sourceMappingURL=typescript.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.mts","sourceRoot":"","sources":["../../../../dist/lib/processors/typescript.mjs"],"names":[],"mappings":"AAqEA;;;;;;;;;;GAUG;AACH,8CATW,MAAM,YAEd;IAAyB,MAAM,GAAvB,MAAM;IACW,MAAM,GAAvB,MAAM;IACY,SAAS,GAA3B,OAAO;CACf,GAAU,OAAO,CAAC,MAAM,CAAC,CAiB3B;AAED;;;;;GAKG;AACH,oCAJW,MAAM,GACJ,MAAM,CAQlB;AAED;;;;;;;;;;;;GAYG;AACH,oDAXW,MAAM,YAEd;IAAyB,MAAM,GAAvB,MAAM;IACW,MAAM,GAAvB,MAAM;IACY,MAAM,GAAxB,OAAO;IACW,aAAa,GAA/B,OAAO;IACU,kBAAkB,GAAnC,MAAM;CACd,GAAU,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CA6F1D;AAED;;;;;;GAMG;AACH,+CALW,MAAM,EAAE,MACR,MAAM,GACJ,MAAM,EAAE,CAapB"}
|
|
@@ -1,67 +1,72 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @type {AsyncLocalStorageType}
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export const sharedALS: AsyncLocalStorageType;
|
|
8
|
-
/**
|
|
9
|
-
* Per-request AsyncLocalStorage instance for request-scoped context.
|
|
10
|
-
* Stores temporary context data that merges with instance context.
|
|
11
|
-
* @type {AsyncLocalStorageType}
|
|
2
|
+
* Live binding to the current API (self-reference)
|
|
3
|
+
* @type {Proxy}
|
|
12
4
|
* @public
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* A proxy that provides access to the full API object within the current context.
|
|
8
|
+
* Automatically resolves to the correct instance's API in AsyncLocalStorage context.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { self } from "@cldmv/slothlet/runtime/async";
|
|
12
|
+
*
|
|
13
|
+
* export function callOtherFunction() {
|
|
14
|
+
* // Call another function in the same API
|
|
15
|
+
* return self.otherFunction();
|
|
16
|
+
* }
|
|
13
17
|
*/
|
|
14
|
-
export const
|
|
15
|
-
export function runWithCtx(ctx: object, fn: Function, thisArg: any, args: any[]): any;
|
|
16
|
-
export function getCtx(): object | null;
|
|
17
|
-
export function makeWrapper(ctx: object): Function;
|
|
18
|
+
export const self: ProxyConstructor;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
* @export module:@cldmv/slothlet/runtime
|
|
20
|
+
* User-provided context object
|
|
21
|
+
* @type {Proxy}
|
|
22
22
|
* @public
|
|
23
|
-
* @type {function|object}
|
|
24
23
|
*
|
|
25
24
|
* @description
|
|
26
|
-
*
|
|
25
|
+
* A proxy that provides access to user-provided context data (e.g., request data, user info).
|
|
26
|
+
* Can be set via `slothlet.run()` or `slothlet.scope()`.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* import { context } from "@cldmv/slothlet/runtime/async";
|
|
30
|
+
*
|
|
31
|
+
* export function getUserInfo() {
|
|
32
|
+
* // Access user-provided context
|
|
33
|
+
* return {
|
|
34
|
+
* userId: context.userId,
|
|
35
|
+
* userName: context.userName
|
|
36
|
+
* };
|
|
37
|
+
* }
|
|
31
38
|
*/
|
|
32
|
-
export const
|
|
39
|
+
export const context: ProxyConstructor;
|
|
33
40
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* @export module:@cldmv/slothlet/runtime
|
|
41
|
+
* Reference to initialization reference object
|
|
42
|
+
* @type {Proxy}
|
|
37
43
|
* @public
|
|
38
|
-
* @type {object}
|
|
39
44
|
*
|
|
40
45
|
* @description
|
|
41
|
-
*
|
|
46
|
+
* The reference object is merged directly into the API at initialization using the add API system.
|
|
47
|
+
* It is NOT available as a runtime export. Access it directly from the API or via api.slothlet.diag.reference().
|
|
42
48
|
*
|
|
43
49
|
* @example
|
|
44
|
-
* //
|
|
45
|
-
*
|
|
50
|
+
* // Reference merged into API - access directly:
|
|
51
|
+
* export function useReferenceData() {
|
|
52
|
+
* return self.myData; // if reference had myData property
|
|
53
|
+
* }
|
|
46
54
|
*/
|
|
47
|
-
export const context: object;
|
|
48
55
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
* @export module:@cldmv/slothlet/runtime
|
|
56
|
+
* Current instance ID
|
|
57
|
+
* @type {Proxy}
|
|
52
58
|
* @public
|
|
53
|
-
* @type {object}
|
|
54
59
|
*
|
|
55
60
|
* @description
|
|
56
|
-
*
|
|
61
|
+
* A proxy that provides access to the current slothlet instance ID.
|
|
62
|
+
* Useful for debugging and tracking which instance is handling a request.
|
|
57
63
|
*
|
|
58
64
|
* @example
|
|
59
|
-
*
|
|
60
|
-
*
|
|
65
|
+
* import { instanceID } from "@cldmv/slothlet/runtime/async";
|
|
66
|
+
*
|
|
67
|
+
* export function getInstanceInfo() {
|
|
68
|
+
* return { instanceID };
|
|
69
|
+
* }
|
|
61
70
|
*/
|
|
62
|
-
export const
|
|
63
|
-
export { metadataAPI };
|
|
64
|
-
export type AsyncLocalStorageType = AsyncLocalStorage<any>;
|
|
65
|
-
import { metadataAPI } from "@cldmv/slothlet/helpers/metadata-api";
|
|
66
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
71
|
+
export const instanceID: ProxyConstructor;
|
|
67
72
|
//# sourceMappingURL=runtime-asynclocalstorage.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-asynclocalstorage.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-asynclocalstorage.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-asynclocalstorage.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-asynclocalstorage.mjs"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;;;;;GAgBG;AACH,oCAgCE;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uCAkCE;AAEF;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,0CAqBE"}
|
|
@@ -1,69 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* ensuring CJS runtime imports detect the correct instance.
|
|
5
|
-
* @param {object} ctx - Context object containing instanceId
|
|
6
|
-
* @param {Function} fn - Function to execute
|
|
7
|
-
* @param {any} thisArg - The this argument
|
|
8
|
-
* @param {Array} args - The function arguments
|
|
9
|
-
* @returns {any} The function result
|
|
10
|
-
*/
|
|
11
|
-
export function runWithCtx(ctx: object, fn: Function, thisArg: any, args: any[]): any;
|
|
12
|
-
/**
|
|
13
|
-
* Create a wrapper function that sets __slothletPath on API functions.
|
|
14
|
-
* Required for hook pattern matching to work correctly.
|
|
15
|
-
* @internal
|
|
16
|
-
* @param {object} ctx - The context to bind
|
|
17
|
-
* @returns {function} A wrapper function that proxies the API
|
|
18
|
-
*/
|
|
19
|
-
export function makeWrapper(ctx: object): Function;
|
|
20
|
-
/**
|
|
21
|
-
* Legacy context management functions - kept for backwards compatibility
|
|
22
|
-
* but may not be needed with instance detection approach.
|
|
23
|
-
*/
|
|
24
|
-
export function getContext(): any;
|
|
25
|
-
export function setContext(newContext: any): void;
|
|
26
|
-
/**
|
|
27
|
-
* Per-request AsyncLocalStorage instance for request-scoped context.
|
|
28
|
-
* Works alongside live bindings to provide per-request context isolation.
|
|
29
|
-
* @type {AsyncLocalStorage}
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export const requestALS: AsyncLocalStorage<any>;
|
|
33
|
-
/**
|
|
34
|
-
* Live-binding reference to the current API instance.
|
|
35
|
-
* Automatically resolves to the appropriate instance based on calling context.
|
|
36
|
-
* @type {object}
|
|
2
|
+
* Live binding to the current API (self-reference)
|
|
3
|
+
* @type {Proxy}
|
|
37
4
|
* @public
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* A proxy that provides direct access to the current instance's API.
|
|
8
|
+
* In live mode, this directly references the active instance without AsyncLocalStorage.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { self } from "@cldmv/slothlet/runtime/live";
|
|
12
|
+
*
|
|
13
|
+
* export function callOtherFunction() {
|
|
14
|
+
* return self.otherFunction();
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export const self: ProxyConstructor;
|
|
18
|
+
/**
|
|
19
|
+
* User-provided context object
|
|
20
|
+
* @type {Proxy}
|
|
51
21
|
* @public
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
import { metadataAPI } from "@cldmv/slothlet/helpers/metadata-api";
|
|
22
|
+
*
|
|
23
|
+
* @description
|
|
24
|
+
* A proxy that provides access to user-provided context data.
|
|
25
|
+
* In live mode, this directly accesses the current instance's context.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { context } from "@cldmv/slothlet/runtime/live";
|
|
29
|
+
*
|
|
30
|
+
* export function getUserInfo() {
|
|
31
|
+
* return {
|
|
32
|
+
* userId: context.userId,
|
|
33
|
+
* userName: context.userName
|
|
34
|
+
* };
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
export const context: ProxyConstructor;
|
|
69
38
|
//# sourceMappingURL=runtime-livebindings.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-livebindings.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-livebindings.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-livebindings.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime-livebindings.mjs"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;;GAeG;AACH,oCAgCE;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,uCAkCE"}
|
|
@@ -1,10 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Live binding to the current API instance. Resolves to the running Slothlet proxy,
|
|
3
|
+
* giving API modules access to all other API methods without import cycles.
|
|
4
|
+
*
|
|
5
|
+
* @memberof module:@cldmv/slothlet/runtime
|
|
6
|
+
* @type {object}
|
|
7
|
+
* @example
|
|
8
|
+
* import { self } from "@cldmv/slothlet/runtime";
|
|
9
|
+
* // Inside an API function:
|
|
10
|
+
* const result = await self.math.add(1, 2);
|
|
11
|
+
*/
|
|
12
|
+
export const self: object;
|
|
13
|
+
/**
|
|
14
|
+
* The current ambient context object. Seeded at instance startup via `config.context` and
|
|
15
|
+
* persists for the lifetime of the instance. `api.slothlet.context.run()` and `.scope()` can
|
|
16
|
+
* temporarily override it for the duration of a single call, after which the previous context
|
|
17
|
+
* is restored. Readable and writable.
|
|
18
|
+
*
|
|
19
|
+
* @memberof module:@cldmv/slothlet/runtime
|
|
20
|
+
* @type {object}
|
|
21
|
+
* @example
|
|
22
|
+
* import { context } from "@cldmv/slothlet/runtime";
|
|
23
|
+
* // Read the ambient context set via config.context or written by a previous call:
|
|
24
|
+
* const userId = context.userId;
|
|
25
|
+
* // context.run() overrides it only for the duration of that one call:
|
|
26
|
+
* await api.slothlet.context.run({ userId: 42 }, myFn);
|
|
27
|
+
*/
|
|
28
|
+
export const context: object;
|
|
29
|
+
/**
|
|
30
|
+
* Current Slothlet instance identifier. Unique per `slothlet()` call; useful when
|
|
31
|
+
* multiple Slothlet instances coexist and you need to identify which one is active.
|
|
32
|
+
*
|
|
33
|
+
* @memberof module:@cldmv/slothlet/runtime
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @example
|
|
36
|
+
* import { instanceID } from "@cldmv/slothlet/runtime";
|
|
37
|
+
* console.log(instanceID); // e.g. "slothlet-1"
|
|
38
|
+
*/
|
|
39
|
+
export const instanceID: string;
|
|
10
40
|
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"AAkEA;;;;;;;;;;GAUG;AACH,mBANU,MAAM,CAgCd;AAEF;;;;;;;;;;;;;;GAcG;AACH,sBARU,MAAM,CAiCd;AAEF;;;;;;;;;GASG;AACH,yBALU,MAAM,CAiBd"}
|