@cldmv/slothlet 3.15.2 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/lib/builders/api-assignment.mjs +1 -1
- package/dist/lib/builders/api_builder.mjs +1 -1
- package/dist/lib/builders/builder.mjs +1 -1
- package/dist/lib/builders/modes-processor.mjs +1 -1
- package/dist/lib/handlers/api-cache-manager.mjs +1 -1
- package/dist/lib/handlers/api-manager.mjs +1 -1
- package/dist/lib/handlers/hook-manager.mjs +1 -1
- package/dist/lib/handlers/module-manager.mjs +1 -1
- package/dist/lib/handlers/ownership.mjs +1 -1
- package/dist/lib/handlers/routine-manager.mjs +17 -0
- package/dist/lib/handlers/unified-wrapper.mjs +1 -1
- package/dist/lib/helpers/config.mjs +1 -1
- package/dist/lib/helpers/defaults.mjs +17 -0
- package/dist/lib/helpers/eventtarget-property-context.mjs +17 -0
- package/dist/lib/helpers/observer-context.mjs +17 -0
- package/dist/lib/helpers/scheduler-context.mjs +1 -1
- package/dist/lib/i18n/languages/en-us.json +2 -0
- package/dist/lib/modes/eager.mjs +1 -1
- package/dist/lib/modes/lazy.mjs +1 -1
- package/dist/lib/processors/flatten.mjs +1 -1
- package/dist/lib/processors/loader.mjs +1 -1
- package/dist/slothlet.mjs +1 -1
- package/index.cjs +20 -0
- package/index.mjs +14 -0
- package/package.json +8 -7
- package/types/stub/devcheck.d.mts +1 -1
- package/types/stub/lib/builders/api-assignment.d.mts +130 -2
- package/types/stub/lib/builders/api_builder.d.mts +109 -2
- package/types/stub/lib/builders/builder.d.mts +87 -2
- package/types/stub/lib/builders/modes-processor.d.mts +71 -2
- package/types/stub/lib/factories/component-base.d.mts +177 -0
- package/types/stub/lib/helpers/caller-pinning.d.mts +22 -2
- package/types/stub/lib/helpers/class-instance-wrapper.d.mts +58 -2
- package/types/stub/lib/helpers/config.d.mts +321 -2
- package/types/stub/lib/helpers/defaults.d.mts +42 -0
- package/types/stub/lib/helpers/eventemitter-context.d.mts +31 -2
- package/types/stub/lib/helpers/eventtarget-context.d.mts +21 -2
- package/types/stub/lib/helpers/eventtarget-property-context.d.mts +23 -0
- package/types/stub/lib/helpers/generate-manifest.d.mts +180 -2
- package/types/stub/lib/helpers/hint-detector.d.mts +27 -2
- package/types/stub/lib/helpers/manifest-resolver.d.mts +101 -2
- package/types/stub/lib/helpers/modes-utils.d.mts +35 -2
- package/types/stub/lib/helpers/module-discovery.d.mts +81 -2
- package/types/stub/lib/helpers/module-manifest-validator.d.mts +37 -2
- package/types/stub/lib/helpers/module-sort.d.mts +65 -2
- package/types/stub/lib/helpers/observer-context.d.mts +23 -0
- package/types/stub/lib/helpers/pattern-matcher.d.mts +44 -2
- package/types/stub/lib/helpers/platform.d.mts +111 -2
- package/types/stub/lib/helpers/resolve-from-caller.d.mts +33 -2
- package/types/stub/lib/helpers/scheduler-context.d.mts +23 -2
- package/types/stub/lib/helpers/utilities.d.mts +57 -2
- package/types/stub/lib/i18n/translations.d.mts +52 -2
- package/types/stub/lib/modes/eager.d.mts +56 -2
- package/types/stub/lib/modes/lazy.d.mts +67 -2
- package/types/stub/lib/processors/flatten.d.mts +123 -2
- package/types/stub/lib/processors/loader.d.mts +83 -2
- package/types/stub/lib/processors/type-generator.d.mts +19 -2
- package/types/stub/lib/processors/typescript.d.mts +174 -2
- package/types/stub/lib/runtime/runtime-asynclocalstorage.d.mts +72 -2
- package/types/stub/lib/runtime/runtime-livebindings.d.mts +38 -2
|
@@ -1,3 +1,88 @@
|
|
|
1
1
|
// AUTO-GENERATED by tools/build/build-typestubs.mjs — do not edit.
|
|
2
|
-
//
|
|
3
|
-
|
|
2
|
+
// Self-contained copy: this subpath is internal and not published by @cldmv/slothlet-types.
|
|
3
|
+
/**
|
|
4
|
+
* API builder class for orchestrating mode-based API construction.
|
|
5
|
+
* @class Builder
|
|
6
|
+
* @extends ComponentBase
|
|
7
|
+
* @package
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Orchestrates API building by delegating to mode-specific builders (eager/lazy).
|
|
11
|
+
* Extends ComponentBase for access to Slothlet configuration and error classes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const builder = new Builder(slothlet);
|
|
15
|
+
* const api = await builder.buildAPI({ dir: "./api" });
|
|
16
|
+
*/
|
|
17
|
+
export class Builder extends ComponentBase {
|
|
18
|
+
static slothletProperty: string;
|
|
19
|
+
/**
|
|
20
|
+
* Create Builder instance.
|
|
21
|
+
* @param {object} slothlet - Slothlet orchestrator instance.
|
|
22
|
+
* @package
|
|
23
|
+
*
|
|
24
|
+
* @description
|
|
25
|
+
* Stores Slothlet reference for accessing configuration and components.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const builder = new Builder(slothlet);
|
|
29
|
+
*/
|
|
30
|
+
constructor(slothlet: object);
|
|
31
|
+
/**
|
|
32
|
+
* Build API from directory or file.
|
|
33
|
+
* @param {Object} options - Build options
|
|
34
|
+
* @param {string} [options.dir] - Directory or file to build from. Required unless `syntheticExports` is set (synthetic / in-memory leaf, #117).
|
|
35
|
+
* @param {string} [options.mode="eager"] - Loading mode (eager or lazy)
|
|
36
|
+
* @param {Object} [options.ownership] - Ownership manager (uses slothlet's if not provided)
|
|
37
|
+
* @param {Object} [options.contextManager] - Context manager (uses slothlet's if not provided)
|
|
38
|
+
* @param {string} [options.instanceID] - Instance ID (uses slothlet's if not provided)
|
|
39
|
+
* @param {Object} [options.config] - Configuration (uses slothlet's if not provided)
|
|
40
|
+
* @param {string} [options.apiPathPrefix=""] - Prefix for API paths (for api.add support)
|
|
41
|
+
* @param {string} [options.collisionContext="initial"] - Collision context
|
|
42
|
+
* @param {string} [options.moduleID] - Stable module identifier (cache key; enables later reload/remove)
|
|
43
|
+
* @param {string|null} [options.cacheBust=null] - Cache-busting value forwarded to the loader/mode
|
|
44
|
+
* @param {string|null} [options.collisionMode=null] - Per-call collision mode override (lazy builds)
|
|
45
|
+
* @param {Function|null} [options.fileFilter=null] - Optional filter function (fileName) => boolean to load specific files only
|
|
46
|
+
* @param {Object|null} [options.syntheticExports=null] - Inline `{ default?, ...named }` exports to build
|
|
47
|
+
* from instead of scanning `dir` (synthetic / in-memory leaf, #117). When set, `dir` is not required.
|
|
48
|
+
* @param {string} [options.syntheticName="synthetic"] - Intermediate key name for the synthetic build.
|
|
49
|
+
* @param {boolean} [options.rootUnwrap=false] - The mount exposes the single root entry's exports
|
|
50
|
+
* directly at the mount path (a single-file or synthetic `api.add()`), so that entry creates no api
|
|
51
|
+
* level and must contribute no path segment either.
|
|
52
|
+
* @returns {Promise<Object>} Raw API object (unwrapped)
|
|
53
|
+
* @public
|
|
54
|
+
*
|
|
55
|
+
* @description
|
|
56
|
+
* Validates inputs and delegates to mode-specific builder (buildEagerAPI or buildLazyAPI).
|
|
57
|
+
* When fileFilter is provided, only files matching the filter are loaded.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const api = await builder.buildAPI({ dir: "./api_tests/api_test", mode: "eager" });
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Load specific file only
|
|
64
|
+
* const api = await builder.buildAPI({
|
|
65
|
+
* dir: "./api_tests/api_test",
|
|
66
|
+
* mode: "eager",
|
|
67
|
+
* fileFilter: (fileName) => fileName === "math.mjs"
|
|
68
|
+
* });
|
|
69
|
+
*/
|
|
70
|
+
public buildAPI(options: {
|
|
71
|
+
dir?: string | undefined;
|
|
72
|
+
mode?: string | undefined;
|
|
73
|
+
ownership?: Object | undefined;
|
|
74
|
+
contextManager?: Object | undefined;
|
|
75
|
+
instanceID?: string | undefined;
|
|
76
|
+
config?: Object | undefined;
|
|
77
|
+
apiPathPrefix?: string | undefined;
|
|
78
|
+
collisionContext?: string | undefined;
|
|
79
|
+
moduleID?: string | undefined;
|
|
80
|
+
cacheBust?: string | null | undefined;
|
|
81
|
+
collisionMode?: string | null | undefined;
|
|
82
|
+
fileFilter?: Function | null | undefined;
|
|
83
|
+
syntheticExports?: Object | null | undefined;
|
|
84
|
+
syntheticName?: string | undefined;
|
|
85
|
+
rootUnwrap?: boolean | undefined;
|
|
86
|
+
}): Promise<Object>;
|
|
87
|
+
}
|
|
88
|
+
import { ComponentBase } from "#factories/component-base";
|
|
@@ -1,3 +1,72 @@
|
|
|
1
1
|
// AUTO-GENERATED by tools/build/build-typestubs.mjs — do not edit.
|
|
2
|
-
//
|
|
3
|
-
|
|
2
|
+
// Self-contained copy: this subpath is internal and not published by @cldmv/slothlet-types.
|
|
3
|
+
/**
|
|
4
|
+
* ModesProcessor - Handles mode-specific file and directory processing.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @extends ComponentBase
|
|
8
|
+
* @package
|
|
9
|
+
*/
|
|
10
|
+
export class ModesProcessor extends ComponentBase {
|
|
11
|
+
static slothletProperty: string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new ModesProcessor instance.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} slothlet - Parent slothlet instance
|
|
16
|
+
*/
|
|
17
|
+
constructor(slothlet: Object);
|
|
18
|
+
/**
|
|
19
|
+
* Recursively walk a directory's scanned files/subdirectories and compose them onto `api`.
|
|
20
|
+
* @param {Object} api - Root api object being built.
|
|
21
|
+
* @param {Array<Object>} files - This directory's own files (from the loader's scan structure).
|
|
22
|
+
* @param {{name: string, path?: string, children: {files: Array, directories: Array}}} directory - This directory's own scan node.
|
|
23
|
+
* @param {number} currentDepth - Recursion depth, for `apiDepth` enforcement.
|
|
24
|
+
* @param {string} mode - `"eager"` or `"lazy"`.
|
|
25
|
+
* @param {boolean} isRoot - Whether this call is the top-level (mount root) invocation.
|
|
26
|
+
* @param {boolean} recursive - Whether to descend into subdirectories at all.
|
|
27
|
+
* @param {boolean} [populateDirectly=false] - Pour this directory's contents directly into `api` (no nested namespace level) — used for transparent-folder and lazy-materialization callers.
|
|
28
|
+
* @param {string} [apiPathPrefix=""] - Dotted api path prefix this directory's own entries are built under.
|
|
29
|
+
* @param {string} [collisionContext="initial"] - `"initial"` or `"api"` — which `config.collision` policy governs this build.
|
|
30
|
+
* @param {string|null} [moduleID=null] - Module id every leaf produced by this call is attributed to.
|
|
31
|
+
* @param {string|null} [sourceFolder=null] - Filesystem path this directory was scanned from, for metadata.
|
|
32
|
+
* @param {string|null} [cacheBust=null] - Cache-busting value forwarded to dynamic imports.
|
|
33
|
+
* @param {string|null} [collisionModeOverride=null] - Per-call override (e.g. `api.add()`'s `forceOverwrite`) that takes precedence over `collisionContext`'s config default for every leaf this call (and its own recursive calls) produces.
|
|
34
|
+
* @param {boolean} [rootUnwrap=false] - The mount exposes its single root entry's exports directly at the mount path (a single-file or synthetic `api.add()`), so that entry creates no api level.
|
|
35
|
+
* @returns {Promise<Function|null>} The root-level default-export contributor function, if one was found at this call's own top level; otherwise `null`.
|
|
36
|
+
* @package
|
|
37
|
+
*/
|
|
38
|
+
processFiles(api: Object, files: Array<Object>, directory: {
|
|
39
|
+
name: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
children: {
|
|
42
|
+
files: any[];
|
|
43
|
+
directories: any[];
|
|
44
|
+
};
|
|
45
|
+
}, currentDepth: number, mode: string, isRoot: boolean, recursive: boolean, populateDirectly?: boolean, apiPathPrefix?: string, collisionContext?: string, moduleID?: string | null, sourceFolder?: string | null, cacheBust?: string | null, collisionModeOverride?: string | null, rootUnwrap?: boolean): Promise<Function | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Create lazy wrapper for subdirectory (lazy mode only)
|
|
48
|
+
* @param {Object} dir - Directory structure to materialize on first access.
|
|
49
|
+
* @param {string} apiPath - Current (already composed) API path for this subdirectory.
|
|
50
|
+
* @param {string} [moduleID] - Owning module id, threaded into the loader and ownership registration.
|
|
51
|
+
* @param {string} [sourceFolder] - Parent's source folder path; this subdirectory's own source folder is derived from it.
|
|
52
|
+
* @param {*} [cacheBust] - Cache-busting token passed through to `loadModule`.
|
|
53
|
+
* @param {Object} [fileFolderCollisionImpl] - Pre-existing implementation properties from a file/folder name collision, merged onto the materialized result so they survive lazy materialization.
|
|
54
|
+
* @param {string} [collisionMode] - Effective (override-or-config-resolved) collision mode to apply within this subdirectory.
|
|
55
|
+
* @param {string} [collisionContext] - Collision context ("initial" | "api") this subdirectory was mounted under, threaded to ownership/ collision-detection calls.
|
|
56
|
+
* @returns {Proxy} Lazy unified wrapper
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
public createLazySubdirectoryWrapper(dir: Object, apiPath: string, moduleID?: string, sourceFolder?: string, cacheBust?: any, fileFolderCollisionImpl?: Object, collisionMode?: string, collisionContext?: string): ProxyConstructor;
|
|
60
|
+
/**
|
|
61
|
+
* Apply root contributor pattern - merge API into root function
|
|
62
|
+
* @param {Object} api - API object with properties
|
|
63
|
+
* @param {Function|null} rootFunction - Root contributor function
|
|
64
|
+
* @param {Object} config - Configuration
|
|
65
|
+
* @param {string} mode - Mode name for debug messages
|
|
66
|
+
* @returns {Promise<Object|Function>} Final API (function if root contributor, object otherwise)
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
public applyRootContributor(api: Object, rootFunction: Function | null, mode: string): Promise<Object | Function>;
|
|
70
|
+
#private;
|
|
71
|
+
}
|
|
72
|
+
import { ComponentBase } from "#factories/component-base";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// AUTO-GENERATED by tools/build/build-typestubs.mjs — do not edit.
|
|
2
|
+
// Self-contained copy: this subpath is internal and not published by @cldmv/slothlet-types.
|
|
3
|
+
/**
|
|
4
|
+
* Base class for Slothlet component classes.
|
|
5
|
+
* @class ComponentBase
|
|
6
|
+
* @package
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* Provides common Slothlet property access for handlers, builders, and processors.
|
|
10
|
+
* All component classes should extend this to gain consistent access to the Slothlet
|
|
11
|
+
* instance's configuration, API references, and error classes. Components are instantiated
|
|
12
|
+
* with a reference to the Slothlet class itself, making them modular extensions.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* class ApiManager extends ComponentBase {
|
|
16
|
+
* constructor(slothlet) {
|
|
17
|
+
* super(slothlet);
|
|
18
|
+
* this.state = { addHistory: [] };
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* someMethod() {
|
|
22
|
+
* if (this.debug?.api) {
|
|
23
|
+
* console.log(`Slothlet: ${this.instanceID}`);
|
|
24
|
+
* }
|
|
25
|
+
* throw new this.SlothletError("INVALID_CONFIG", { reason: "bad input" });
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export class ComponentBase {
|
|
30
|
+
/**
|
|
31
|
+
* Complete set of property names reserved by the slothlet framework.
|
|
32
|
+
*
|
|
33
|
+
* @description
|
|
34
|
+
* These keys are either private wrapper internals, read-only info props exposed
|
|
35
|
+
* through the proxy, write-blocked lifecycle keys, or builtin namespace keys
|
|
36
|
+
* injected at the API root level. Used by all components to distinguish framework
|
|
37
|
+
* internals from user-defined properties when:
|
|
38
|
+
* - Collecting user-set custom properties for preservation across reload
|
|
39
|
+
* (`_collectCustomProperties` in api-manager.mjs)
|
|
40
|
+
* - Extracting child keys for impl reconstruction (`_extractFullImpl`)
|
|
41
|
+
* - Determining whether a set(trap) write should be silently absorbed (`setTrap`)
|
|
42
|
+
* - Filtering what getTrap exposes externally on wrapper proxies
|
|
43
|
+
*
|
|
44
|
+
* Note: `_materialize` is included here (skip for collection/extraction) but
|
|
45
|
+
* setTrap exempts it since the framework needs to write it directly.
|
|
46
|
+
*
|
|
47
|
+
* @type {Set<string>}
|
|
48
|
+
* @static
|
|
49
|
+
*/
|
|
50
|
+
static INTERNAL_KEYS: Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a component base instance.
|
|
53
|
+
* @param {object} slothlet - Slothlet class instance.
|
|
54
|
+
* @package
|
|
55
|
+
*
|
|
56
|
+
* @description
|
|
57
|
+
* Stores the Slothlet reference for access via getters. The Slothlet class itself
|
|
58
|
+
* is passed (not a separate "instance" object), making components modular extensions
|
|
59
|
+
* of Slothlet.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* super(slothlet);
|
|
63
|
+
*/
|
|
64
|
+
constructor(slothlet: object);
|
|
65
|
+
/**
|
|
66
|
+
* Get Slothlet instance via the canonical internal accessor name.
|
|
67
|
+
* @returns {object} Slothlet instance.
|
|
68
|
+
* @package
|
|
69
|
+
*
|
|
70
|
+
* @description
|
|
71
|
+
* Prototype getter — NOT an own property — so the JS Proxy invariant for
|
|
72
|
+
* non-configurable own properties never applies. UnifiedWrapper's getTrap blocks
|
|
73
|
+
* this name via the underscore-filter before it can reach the getter.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const s = this.____slothlet;
|
|
77
|
+
*/
|
|
78
|
+
get ____slothlet(): object;
|
|
79
|
+
/**
|
|
80
|
+
* Get Slothlet instance (internal access).
|
|
81
|
+
* @returns {object} Slothlet instance.
|
|
82
|
+
* @package
|
|
83
|
+
*
|
|
84
|
+
* @description
|
|
85
|
+
* Provides direct access to the Slothlet instance for legacy code compatibility.
|
|
86
|
+
* Prefer using specific getters (config, helpers, handlers) when possible.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* this.slothlet.debug("api", { action: "assigned" });
|
|
90
|
+
*/
|
|
91
|
+
get slothlet(): object;
|
|
92
|
+
/**
|
|
93
|
+
* Get Slothlet configuration.
|
|
94
|
+
* @returns {object} Slothlet configuration object.
|
|
95
|
+
* @package
|
|
96
|
+
*
|
|
97
|
+
* @description
|
|
98
|
+
* Provides access to the Slothlet config for collision modes, debug settings, etc.
|
|
99
|
+
* Named with ____ prefix to avoid shadowing user API names like 'config'.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const collisionMode = this.____config.collision.api;
|
|
103
|
+
*/
|
|
104
|
+
get ____config(): object;
|
|
105
|
+
/**
|
|
106
|
+
* Get Slothlet instance ID.
|
|
107
|
+
* @returns {string} Slothlet instance identifier.
|
|
108
|
+
* @package
|
|
109
|
+
*/
|
|
110
|
+
get instanceID(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Get SlothletError class.
|
|
113
|
+
* @returns {Function} SlothletError constructor.
|
|
114
|
+
* @package
|
|
115
|
+
*
|
|
116
|
+
* @description
|
|
117
|
+
* Provides access to SlothletError without importing in every file.
|
|
118
|
+
* Components can throw errors via `new this.SlothletError(...)`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* throw new this.SlothletError("INVALID_CONFIG", { reason: "missing dir" });
|
|
122
|
+
*/
|
|
123
|
+
get SlothletError(): Function;
|
|
124
|
+
/**
|
|
125
|
+
* Get SlothletWarning class.
|
|
126
|
+
* @returns {Function} SlothletWarning constructor.
|
|
127
|
+
* @package
|
|
128
|
+
*
|
|
129
|
+
* @description
|
|
130
|
+
* Provides access to SlothletWarning without importing in every file.
|
|
131
|
+
* Components can issue warnings via `new this.SlothletWarning(...)`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* new this.SlothletWarning("WARNING_DEPRECATED", { feature: "oldApi" });
|
|
135
|
+
*/
|
|
136
|
+
get SlothletWarning(): Function;
|
|
137
|
+
/**
|
|
138
|
+
* Emit a non-throwing diagnostic lifecycle event (`impl:warning` or `impl:error`).
|
|
139
|
+
* @param {"warning"|"error"} level - Diagnostic level → `impl:warning` or `impl:error`.
|
|
140
|
+
* @param {object} data - Diagnostic payload.
|
|
141
|
+
* @param {string} data.code - i18n code (e.g. "WARN_SYNTHETIC_ROOT_COLLISION") used to translate `message`.
|
|
142
|
+
* @param {object} data.context - Structured context object passed to the diagnostic (also the i18n interpolation params).
|
|
143
|
+
* @param {string} [data.apiPath] - API path where the mutation was attempted ("" / "(root)" for root).
|
|
144
|
+
* @param {string} [data.source] - Command family that produced the diagnostic (addApi | reload | buildAPI | module-mount).
|
|
145
|
+
* @param {string} [data.moduleID] - Module identifier, when one is in scope.
|
|
146
|
+
* @param {Error} [data.error] - The originating Error / SlothletError (impl:error only).
|
|
147
|
+
* @returns {Promise<void>} Resolves once all subscribers (including async ones) have run.
|
|
148
|
+
* @package
|
|
149
|
+
*
|
|
150
|
+
* @description
|
|
151
|
+
* Fires an additive lifecycle event for a diagnostic the framework handled WITHOUT throwing —
|
|
152
|
+
* a warning, or a runtime error a command caught and continued past. Observers registered via
|
|
153
|
+
* `api.slothlet.lifecycle.on("impl:warning"|"impl:error", fn)` — or the construction-time
|
|
154
|
+
* `lifecycle` config option — receive these regardless of the `silent` config: `silent`
|
|
155
|
+
* suppresses console output only, never events. The human-readable `message` is translated
|
|
156
|
+
* from `code` + `context` here so subscribers get a ready-to-display string even when the
|
|
157
|
+
* corresponding SlothletWarning/SlothletError was never constructed (e.g. under `silent`).
|
|
158
|
+
*
|
|
159
|
+
* Emission stays per-site: each diagnostic location calls this explicitly, mirroring how each
|
|
160
|
+
* site constructs its own `this.SlothletWarning`. The SlothletError / SlothletWarning classes
|
|
161
|
+
* remain context-free (no slothlet reference) and are never coupled to the lifecycle emitter.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* await this.emitImplDiagnostic("warning", {
|
|
165
|
+
* apiPath: "", code: "WARN_SYNTHETIC_ROOT_EMPTY", context: { apiPath: "(root)" }, source: "addApi"
|
|
166
|
+
* });
|
|
167
|
+
*/
|
|
168
|
+
emitImplDiagnostic(level: "warning" | "error", data: {
|
|
169
|
+
code: string;
|
|
170
|
+
context: object;
|
|
171
|
+
apiPath?: string | undefined;
|
|
172
|
+
source?: string | undefined;
|
|
173
|
+
moduleID?: string | undefined;
|
|
174
|
+
error?: Error | undefined;
|
|
175
|
+
}): Promise<void>;
|
|
176
|
+
#private;
|
|
177
|
+
}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
// AUTO-GENERATED by tools/build/build-typestubs.mjs — do not edit.
|
|
2
|
-
//
|
|
3
|
-
|
|
2
|
+
// Self-contained copy: this subpath is internal and not published by @cldmv/slothlet-types.
|
|
3
|
+
/**
|
|
4
|
+
* Register the strategy for binding a callback to whoever scheduled it.
|
|
5
|
+
*
|
|
6
|
+
* @param {Function|null} strategy - Takes a callback and returns a replacement that re-enters the
|
|
7
|
+
* registering module's context when it runs. `null` clears the registration.
|
|
8
|
+
* @returns {void}
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function setApiCallerPinner(strategy: Function | null): void;
|
|
12
|
+
/**
|
|
13
|
+
* Bind a callback to the caller active right now, if the runtime supplies a way to.
|
|
14
|
+
*
|
|
15
|
+
* Called by each scheduling boundary at registration time. Returns the callback unchanged when no
|
|
16
|
+
* pinner is registered (the async runtime) or when there is no caller to pin (the host scheduling
|
|
17
|
+
* its own work), so the boundary pays nothing outside a module call.
|
|
18
|
+
*
|
|
19
|
+
* @param {Function} callback - Callback about to be deferred.
|
|
20
|
+
* @returns {Function} The callback, bound to the current caller where one exists.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export function pinToCurrentCaller(callback: Function): Function;
|
|
@@ -1,3 +1,59 @@
|
|
|
1
1
|
// AUTO-GENERATED by tools/build/build-typestubs.mjs — do not edit.
|
|
2
|
-
//
|
|
3
|
-
|
|
2
|
+
// Self-contained copy: this subpath is internal and not published by @cldmv/slothlet-types.
|
|
3
|
+
/**
|
|
4
|
+
* @function runtime_shouldWrapMethod
|
|
5
|
+
* @package
|
|
6
|
+
* @param {*} value - The value to check
|
|
7
|
+
* @param {string|symbol} prop - The property name
|
|
8
|
+
* @returns {boolean} True if the method should be wrapped
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Determines if a method should be wrapped with context preservation.
|
|
12
|
+
* Excludes constructors, Object.prototype methods, and internal methods.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* runtime_shouldWrapMethod(myInstance.method, "method"); // true
|
|
16
|
+
* runtime_shouldWrapMethod(myInstance.constructor, "constructor"); // false
|
|
17
|
+
*/
|
|
18
|
+
export function runtime_shouldWrapMethod(value: any, prop: string | symbol): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @function runtime_isClassInstance
|
|
21
|
+
* @package
|
|
22
|
+
* @param {*} val - The value to check
|
|
23
|
+
* @returns {boolean} True if the value is a class instance that should be wrapped
|
|
24
|
+
*
|
|
25
|
+
* @description
|
|
26
|
+
* Determines if a value is a class instance (not a plain object, array, or primitive)
|
|
27
|
+
* that should have its methods wrapped to preserve AsyncLocalStorage context.
|
|
28
|
+
* Uses systematic exclusion lists for better maintainability.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Check if value is a class instance
|
|
32
|
+
* const isInstance = runtime_isClassInstance(new MyClass());
|
|
33
|
+
*/
|
|
34
|
+
export function runtime_isClassInstance(val: any): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @function runtime_wrapClassInstance
|
|
37
|
+
* @package
|
|
38
|
+
* @param {object} instance - The class instance to wrap
|
|
39
|
+
* @param {object} contextManager - The context manager (async or live)
|
|
40
|
+
* @param {string} instanceID - The slothlet instance ID
|
|
41
|
+
* @param {WeakMap} instanceCache - The cache for wrapped instances
|
|
42
|
+
* @param {object} [capturedWrapper] - Wrapper of the module that created this instance,
|
|
43
|
+
* snapshotted at wrap time. Used as the caller identity for the instance's method calls so
|
|
44
|
+
* that `self.*` calls from a class method are permission-checked as the creating module
|
|
45
|
+
* (the method is neither exempt from nor spuriously denied by the permission layer).
|
|
46
|
+
* @returns {Proxy} A proxied instance with context-aware method calls
|
|
47
|
+
*
|
|
48
|
+
* @description
|
|
49
|
+
* Wraps a class instance so that all method calls maintain the AsyncLocalStorage context.
|
|
50
|
+
* This ensures that calls to methods on returned class instances preserve the slothlet
|
|
51
|
+
* context for runtime imports like `self` and `context`.
|
|
52
|
+
*
|
|
53
|
+
* V3 Adaptation: Uses contextManager.runInContext() instead of V2's runWithCtx().
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Wrap a class instance to preserve context
|
|
57
|
+
* const wrappedInstance = runtime_wrapClassInstance(instance, contextManager, instanceID, instanceCache, creatingWrapper);
|
|
58
|
+
*/
|
|
59
|
+
export function runtime_wrapClassInstance(instance: object, contextManager: object, instanceID: string, instanceCache: WeakMap<any, any>, capturedWrapper?: object): ProxyConstructor;
|