@cldmv/slothlet-types 3.15.3 → 3.16.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.
Files changed (58) hide show
  1. package/lib/builders/api-assignment.d.mts +125 -4
  2. package/lib/builders/api_builder.d.mts +104 -7
  3. package/lib/builders/builder.d.mts +82 -1
  4. package/lib/builders/modes-processor.d.mts +66 -3
  5. package/lib/errors.d.mts +114 -19
  6. package/lib/factories/component-base.d.mts +171 -8
  7. package/lib/factories/context.d.mts +22 -4
  8. package/lib/handlers/api-cache-manager.d.mts +209 -20
  9. package/lib/handlers/api-manager.d.mts +539 -38
  10. package/lib/handlers/context-async.d.mts +92 -25
  11. package/lib/handlers/context-live.d.mts +117 -30
  12. package/lib/handlers/framework-internals.d.mts +33 -2
  13. package/lib/handlers/hook-manager.d.mts +306 -73
  14. package/lib/handlers/lifecycle-token.d.mts +48 -3
  15. package/lib/handlers/lifecycle.d.mts +86 -5
  16. package/lib/handlers/materialize-manager.d.mts +76 -8
  17. package/lib/handlers/metadata.d.mts +238 -18
  18. package/lib/handlers/module-manager.d.mts +169 -21
  19. package/lib/handlers/ownership.d.mts +376 -45
  20. package/lib/handlers/permission-manager.d.mts +283 -46
  21. package/lib/handlers/routine-manager.d.mts +425 -0
  22. package/lib/handlers/trusted-root.d.mts +45 -4
  23. package/lib/handlers/unified-wrapper.d.mts +287 -26
  24. package/lib/handlers/version-manager.d.mts +236 -29
  25. package/lib/helpers/caller-pinning.d.mts +21 -2
  26. package/lib/helpers/class-instance-wrapper.d.mts +56 -2
  27. package/lib/helpers/config.d.mts +311 -161
  28. package/lib/helpers/defaults.d.mts +39 -0
  29. package/lib/helpers/eventemitter-context.d.mts +29 -3
  30. package/lib/helpers/eventtarget-context.d.mts +19 -1
  31. package/lib/helpers/eventtarget-property-context.d.mts +21 -0
  32. package/lib/helpers/generate-manifest.d.mts +174 -7
  33. package/lib/helpers/hint-detector.d.mts +22 -2
  34. package/lib/helpers/manifest-resolver.d.mts +100 -1
  35. package/lib/helpers/modes-utils.d.mts +30 -3
  36. package/lib/helpers/module-discovery.d.mts +80 -7
  37. package/lib/helpers/module-manifest-validator.d.mts +36 -13
  38. package/lib/helpers/module-sort.d.mts +64 -1
  39. package/lib/helpers/observer-context.d.mts +21 -0
  40. package/lib/helpers/pattern-matcher.d.mts +43 -3
  41. package/lib/helpers/platform.d.mts +109 -10
  42. package/lib/helpers/resolve-from-caller.d.mts +27 -3
  43. package/lib/helpers/sanitize.d.mts +92 -4
  44. package/lib/helpers/scheduler-context.d.mts +21 -1
  45. package/lib/helpers/utilities.d.mts +52 -4
  46. package/lib/i18n/translations.d.mts +50 -5
  47. package/lib/modes/eager.d.mts +46 -8
  48. package/lib/modes/lazy.d.mts +57 -10
  49. package/lib/processors/flatten.d.mts +116 -56
  50. package/lib/processors/loader.d.mts +77 -10
  51. package/lib/processors/type-generator.d.mts +16 -2
  52. package/lib/processors/typescript.d.mts +169 -13
  53. package/lib/runtime/runtime-asynclocalstorage.d.mts +71 -3
  54. package/lib/runtime/runtime-livebindings.d.mts +37 -2
  55. package/lib/runtime/runtime.d.mts +39 -3
  56. package/lib/typegen/typegen.d.mts +34 -2
  57. package/package.json +5 -23
  58. package/slothlet.d.mts +428 -3
@@ -1,11 +1,110 @@
1
- export let AsyncLocalStorage: null;
2
- export let AsyncResource: null;
3
- export let EventEmitter: null;
4
- export let createRequire: null;
5
- export let fs: null;
6
- export let fsp: null;
1
+ /**
2
+ * @Project: @cldmv/slothlet
3
+ * @Filename: /src/lib/helpers/platform.mjs
4
+ * @Date: 2026-05-29 22:02:43 -07:00 (1780117363)
5
+ * @Author: Nate Corcoran <CLDMV>
6
+ * @Email: <Shinrai@users.noreply.github.com>
7
+ * -----
8
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
9
+ * @Last modified time: 2026-06-03 21:17:59 -07:00 (1780546679)
10
+ * -----
11
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
12
+ */
13
+ /**
14
+ * @fileoverview Single source of truth for Node.js-vs-browser host differences.
15
+ * @module @cldmv/slothlet/helpers/platform
16
+ * @internal
17
+ *
18
+ * @description
19
+ * Slothlet runs in two hosts: Node.js (full filesystem access) and browser /
20
+ * Electron-renderer "browser mode" (no `node:*` builtins, manifest-based loading).
21
+ * Rather than scatter `typeof process` checks and gated `await import("node:*")`
22
+ * blocks across a dozen modules (#123), every host difference is decided ONCE here
23
+ * and the rest of the codebase imports the resolved builtins (or browser shims)
24
+ * plus `isNode` via plain static imports — no `node:*` specifier ever enters the
25
+ * static-import graph a browser must parse.
26
+ *
27
+ * The builtins are pulled in through a single top-level-await `import()` block
28
+ * guarded by `isNode`. In a browser the same exports resolve to `null` (for the
29
+ * Node-only ones, whose every call site is `isNode`-guarded) or to a minimal shim
30
+ * (`util`, which is consumed in both hosts for `inspect` / `types.isProxy`).
31
+ *
32
+ * Anything that genuinely cannot run outside Node and is never reachable from a
33
+ * browser module graph (TypeScript compilation, type generation, manifest
34
+ * generation) keeps its own direct `node:*` imports — routing those through here
35
+ * would only drag build-time-only builtins (`crypto`, `os`) into the shared hub.
36
+ *
37
+ * ## Browser-only branches & coverage (policy)
38
+ * The browser arms here — and in the modules that import `isNode` (the `else`/`: null` shims, the
39
+ * i18n browser paths, the live-mode null-ALS arm) — are UNREACHABLE under the Node coverage run:
40
+ * `process.versions.node` is always truthy there, even in the `platform:"browser"` node-side suites.
41
+ *
42
+ * They are now genuinely covered+counted by a **vitest browser-mode** run (real headless Chromium,
43
+ * Playwright provider — `.configs/vitest.browser.config.mjs`, `tests/browser/*.browser.test.mjs`).
44
+ * Because that run uses the SAME `@vitest/coverage-v8` provider over vite-transformed source as the
45
+ * node run, the two `coverage-final.json` maps align and merge cleanly
46
+ * (`tools/coverage/merge-browser-coverage.mjs`, wired as `npm run coverage:all`). An earlier merge was
47
+ * rejected, but that was of the raw-source Playwright *smoke* (`npm run test:browser`), whose importmap
48
+ * serves raw `src/` — those maps don't align with node's. The vitest-browser run does, which is what
49
+ * makes the merge correct. Only arms unreachable in BOTH hosts (e.g. an exotic non-Node host with no
50
+ * `process`/`navigator`) keep a precise v8 ignore-next comment. The smoke remains as a raw-importmap
51
+ * load check (the path a real consumer uses), not the coverage justification.
52
+ */
7
53
  export const isNode: boolean;
8
- export function loadJson(ref: any): any;
9
- export let path: null;
10
- export let url: null;
11
- export let util: null;
54
+ /**
55
+ * Resolved Node.js builtins (Node host) or browser shims / `null` (browser host).
56
+ *
57
+ * Each is initialized to `null` and reassigned to the real builtin inside the `isNode`
58
+ * block below; in a browser the Node-only ones stay `null` (every call site is
59
+ * `isNode`-guarded) and `util` becomes a minimal shim. Annotated `any` (not bare `null`,
60
+ * which would make a TS consumer treat them as non-callable, nor the precise
61
+ * `typeof import("node:*")` shape, which would force `@types/node` onto every consumer —
62
+ * including browser ones — and break the no-extra-types export contract). `any` keeps them
63
+ * usable from TS while the polymorphic real-module / shim / `null` behavior is documented here.
64
+ * @private
65
+ */
66
+ /** @type {any} */
67
+ export let fs: any;
68
+ /** @type {any} */
69
+ export let fsp: any;
70
+ /** @type {any} */
71
+ export let path: any;
72
+ /** @type {any} */
73
+ export let url: any;
74
+ /** @type {any} */
75
+ export let util: any;
76
+ /** @type {any} */
77
+ export let EventEmitter: any;
78
+ /** @type {any} */
79
+ export let AsyncLocalStorage: any;
80
+ /** @type {any} */
81
+ export let AsyncResource: any;
82
+ /** @type {any} */
83
+ export let createRequire: any;
84
+ /**
85
+ * Load and parse JSON, branching on host — this is the single place that knows how each
86
+ * environment reads JSON.
87
+ *
88
+ * @description
89
+ * - **Node**: synchronous `fs.readFileSync` + parse. Returns the parsed object directly (or
90
+ * `null` on a read/parse failure). `ref` is a filesystem path or `file:` URL.
91
+ * - **Browser**: asynchronous dynamic `import(ref, { with: { type: "json" } })`. Returns a
92
+ * `Promise<object|null>` — a miss resolves to `null` (callers keep their bundled default;
93
+ * a failed import also surfaces a console error, which is harmless). `ref` is a module
94
+ * specifier resolvable via the page's importmap (e.g. `@cldmv/slothlet/i18n/language/es-mx.json`).
95
+ *
96
+ * The return type is therefore polymorphic by host: `object|null` in Node, `Promise<object|null>`
97
+ * in a browser. Callers that already branch on `isNode` consume the matching form directly;
98
+ * `await loadJson(...)` is safe in both (awaiting a non-promise is a no-op).
99
+ *
100
+ * @param {string} ref - Filesystem path / `file:` URL (Node) or importmap specifier (browser).
101
+ * @returns {object|null|Promise<object|null>} Parsed JSON (Node, sync) or a promise of it (browser).
102
+ * @internal
103
+ *
104
+ * @example
105
+ * // Node (sync):
106
+ * const pkg = loadJson(new URL("../../package.json", import.meta.url));
107
+ * // Browser (async):
108
+ * const es = await loadJson("@cldmv/slothlet/i18n/language/es-mx.json");
109
+ */
110
+ export function loadJson(ref: string): object | null | Promise<object | null>;
@@ -1,8 +1,32 @@
1
+ /**
2
+ * Path resolver component
3
+ * @class Resolver
4
+ * @extends ComponentBase
5
+ * @package
6
+ */
1
7
  export class Resolver extends ComponentBase {
2
8
  static slothletProperty: string;
3
- getStack(skipFn: any): string | undefined;
4
- toFsPath(v: any): any;
5
- resolvePathFromCaller(rel: any): any;
9
+ /**
10
+ * Get V8 stack trace as CallSite array.
11
+ * @param {Function} [skipFn] - Optional function to skip from stack trace
12
+ * @returns {Array} Array of CallSite objects
13
+ * @public
14
+ */
15
+ public getStack(skipFn?: Function): any[];
16
+ /**
17
+ * Convert file:// URL to filesystem path or return as-is.
18
+ * @param {any} v - Value to convert
19
+ * @returns {string|null} Filesystem path or null
20
+ * @public
21
+ */
22
+ public toFsPath(v: any): string | null;
23
+ /**
24
+ * Resolve relative path from caller's context.
25
+ * @param {string} rel - Relative path to resolve
26
+ * @returns {string} Absolute filesystem path
27
+ * @public
28
+ */
29
+ public resolvePathFromCaller(rel: string): string;
6
30
  #private;
7
31
  }
8
32
  import { ComponentBase } from "#factories/component-base";
@@ -1,9 +1,97 @@
1
+ /**
2
+ * Standalone sanitizePropertyName function for backward compatibility
3
+ * @param {string} input - Input string to sanitize
4
+ * @param {object} options - Sanitization options
5
+ * @returns {string} Sanitized property name
6
+ * @public
7
+ */
8
+ export function sanitizePropertyName(input: string, options?: object): string;
9
+ /**
10
+ * Advanced filename sanitization with rule-based transformation
11
+ * @extends ComponentBase
12
+ * @public
13
+ */
1
14
  export class Sanitize extends ComponentBase {
2
15
  static slothletProperty: string;
3
- sanitizePropertyName(input: any, options?: {}): string;
4
- getModuleId(filePath: any, baseDir: any): any;
5
- shouldPreserveFunctionCase(name: any): boolean;
16
+ /**
17
+ * Advanced sanitization function with configurable rule-based transformation
18
+ *
19
+ * @description
20
+ * Converts arbitrary strings (filenames, path segments) into valid JavaScript identifiers
21
+ * suitable for dot-notation property access. Supports sophisticated rule-based transformation
22
+ * with glob patterns, case preservation, and intelligent segment handling.
23
+ *
24
+ * @param {string} input - String to sanitize
25
+ * @param {Object} [options={}] - Sanitization configuration
26
+ * @param {boolean} [options.lowerFirst=true] - Lowercase first character of first segment
27
+ * @param {boolean} [options.preserveAllUpper=false] - Preserve all-uppercase identifiers
28
+ * @param {boolean} [options.preserveAllLower=false] - Preserve all-lowercase identifiers
29
+ * @param {Object} [options.rules={}] - Transformation rules
30
+ * @param {string[]} [options.rules.leave=[]] - Preserve exactly (case-sensitive, supports globs)
31
+ * @param {string[]} [options.rules.leaveInsensitive=[]] - Preserve exactly (case-insensitive, supports globs)
32
+ * @param {string[]} [options.rules.upper=[]] - Force UPPERCASE (supports globs and **STRING**)
33
+ * @param {string[]} [options.rules.lower=[]] - Force lowercase (supports globs and **STRING**)
34
+ * @returns {string} Valid JavaScript identifier
35
+ * @public
36
+ *
37
+ * @example
38
+ * // Basic usage
39
+ * sanitizePropertyName("auto-ip"); // "autoIp"
40
+ * sanitizePropertyName("root-math"); // "rootMath"
41
+ *
42
+ * @example
43
+ * // Rule-based transformation
44
+ * sanitizePropertyName("auto-ip", {
45
+ * rules: { upper: ["*-ip"] }
46
+ * }); // "autoIP"
47
+ *
48
+ * @example
49
+ * // Boundary-requiring patterns
50
+ * sanitizePropertyName("parseJsonData", {
51
+ * rules: { upper: ["**json**"] }
52
+ * }); // "parseJSONData"
53
+ *
54
+ * @example
55
+ * // Case preservation
56
+ * sanitizePropertyName("COMMON_APPS", {
57
+ * preserveAllUpper: true
58
+ * }); // "COMMON_APPS"
59
+ *
60
+ * @example
61
+ * // Multiple rules
62
+ * sanitizePropertyName("get-api-status", {
63
+ * rules: {
64
+ * upper: ["*-api-*", "http"],
65
+ * lower: ["xml"]
66
+ * }
67
+ * }); // "getAPIStatus"
68
+ */
69
+ public sanitizePropertyName(input: string, options?: {
70
+ lowerFirst?: boolean | undefined;
71
+ preserveAllUpper?: boolean | undefined;
72
+ preserveAllLower?: boolean | undefined;
73
+ rules?: {
74
+ leave?: string[] | undefined;
75
+ leaveInsensitive?: string[] | undefined;
76
+ upper?: string[] | undefined;
77
+ lower?: string[] | undefined;
78
+ } | undefined;
79
+ }): string;
80
+ /**
81
+ * Get module ID from file path
82
+ * @param {string} filePath - Full file path
83
+ * @param {string} baseDir - Base directory
84
+ * @returns {string} Module ID
85
+ * @public
86
+ */
87
+ public getModuleId(filePath: string, baseDir: string): string;
88
+ /**
89
+ * Check if filename represents a special function name that should preserve case
90
+ * @param {string} name - Name to check
91
+ * @returns {boolean} True if special case should be preserved
92
+ * @public
93
+ */
94
+ public shouldPreserveFunctionCase(name: string): boolean;
6
95
  #private;
7
96
  }
8
- export function sanitizePropertyName(input: any, options?: {}): string;
9
97
  import { ComponentBase } from "#factories/component-base";
@@ -1,2 +1,22 @@
1
- export function disableSchedulerPatching(): void;
1
+ /**
2
+ * Pin deferred callbacks to the module that schedules them.
3
+ *
4
+ * Called once globally when the first instance is created; later calls are ignored, matching how
5
+ * EventEmitter patching behaves. Costs nothing when no runtime registered a pinning strategy — the
6
+ * wrapper hands the callback straight through.
7
+ *
8
+ * @returns {void}
9
+ * @public
10
+ */
2
11
  export function enableSchedulerPatching(): void;
12
+ /**
13
+ * Restore the original scheduler entry points.
14
+ *
15
+ * Restores an entry point only when the wrapper installed here is still the one in place. Anything
16
+ * that replaced a scheduler afterwards — a test runner's fake timers being the usual case — owns that
17
+ * slot and its own restore, and writing over it would strand the process on a stale function.
18
+ *
19
+ * @returns {void}
20
+ * @public
21
+ */
22
+ export function disableSchedulerPatching(): void;
@@ -1,8 +1,56 @@
1
+ /**
2
+ * General utility functions
3
+ * @class Utilities
4
+ * @extends ComponentBase
5
+ * @package
6
+ */
1
7
  export class Utilities extends ComponentBase {
2
8
  static slothletProperty: string;
3
- isPlainObject(obj: any): boolean;
4
- deepMerge(target: any, source: any): any;
5
- deepClone(obj: any): any;
6
- generateId(): string;
9
+ /**
10
+ * Check if value is a plain object
11
+ * @param {*} obj - Value to check
12
+ * @returns {boolean} True if plain object
13
+ * @public
14
+ */
15
+ public isPlainObject(obj: any): boolean;
16
+ /**
17
+ * Deep merge two plain objects recursively.
18
+ *
19
+ * Differences from a simple spread:
20
+ * - Recursively merges nested plain objects rather than replacing them.
21
+ * - Uses `hasOwnProperty` to skip prototype-chain keys (no prototype pollution).
22
+ * - Non-plain values (arrays, class instances, primitives) are always copied by
23
+ * value from `source`, never merged.
24
+ * - When `source[key]` is a plain object but `target[key]` is not (or absent),
25
+ * the merge starts from `{}` so the returned sub-tree is always a fresh copy.
26
+ * - If either top-level argument is not a plain object, returns `source` as-is.
27
+ *
28
+ * @param {unknown} target - Base object (not mutated).
29
+ * @param {unknown} source - Source object whose keys are merged in.
30
+ * @returns {unknown} New merged object, or `source` as-is if either argument is not a plain object.
31
+ * @public
32
+ */
33
+ public deepMerge(target: unknown, source: unknown): unknown;
34
+ /**
35
+ * Deep clone a value, handling Proxy objects and functions that `structuredClone`
36
+ * cannot serialise.
37
+ *
38
+ * Strategy:
39
+ * 1. Try `structuredClone` — fast and spec-correct for plain data.
40
+ * 2. Fall back to a manual recursive copy for Proxies, callables, and other
41
+ * non-serialisable objects; errors on individual property clones are swallowed
42
+ * and the original reference is retained for that key.
43
+ *
44
+ * @param {unknown} obj - Value to clone.
45
+ * @returns {unknown} Deep clone of `obj`.
46
+ * @public
47
+ */
48
+ public deepClone(obj: unknown): unknown;
49
+ /**
50
+ * Generate unique ID
51
+ * @returns {string} Unique identifier
52
+ * @public
53
+ */
54
+ public generateId(): string;
7
55
  }
8
56
  import { ComponentBase } from "#factories/component-base";
@@ -1,6 +1,51 @@
1
+ /**
2
+ * Set current language (synchronous)
3
+ * Merges requested language translations over default English translations
4
+ * @param {string} lang - Language code
5
+ * @public
6
+ */
7
+ export function setLanguage(lang: string): void;
8
+ /**
9
+ * Set the current language asynchronously — the browser-capable path.
10
+ *
11
+ * @description
12
+ * Mirrors {@link setLanguage}, but awaits the locale load so it works in a browser, where locales
13
+ * arrive via dynamic `import(…, { with: { type: "json" } })` rather than the filesystem. In Node it
14
+ * awaits the same synchronous read (the await is a no-op). A failed load warns and keeps the bundled
15
+ * English default. Use this when you need to *await* a locale switch (e.g. in an Electron renderer).
16
+ * @param {string} lang - Language code (e.g. "es-mx").
17
+ * @returns {Promise<void>}
18
+ * @public
19
+ */
20
+ export function setLanguageAsync(lang: string): Promise<void>;
21
+ /**
22
+ * Get current language
23
+ * @returns {string} Language code
24
+ * @public
25
+ */
1
26
  export function getLanguage(): string;
2
- export function initI18n(options?: {}): void;
3
- export function setLanguage(lang: any): void;
4
- export function setLanguageAsync(lang: any): Promise<void>;
5
- export function t(errorCode: any, params?: {}): any;
6
- export function translate(errorCode: any, params?: {}): any;
27
+ /**
28
+ * Translate error message with interpolation
29
+ * @param {string} errorCode - Error code
30
+ * @param {Object} params - Parameters for interpolation
31
+ * @returns {string} Translated message
32
+ * @public
33
+ */
34
+ export function translate(errorCode: string, params?: Object): string;
35
+ /**
36
+ * Initialize i18n system (synchronous)
37
+ * @param {Object} options - Options
38
+ * @param {string} [options.language] - Language code (auto-detect if not provided)
39
+ * @public
40
+ */
41
+ export function initI18n(options?: {
42
+ language?: string | undefined;
43
+ }): void;
44
+ /**
45
+ * Translate error message with interpolation
46
+ * @param {string} errorCode - Error code
47
+ * @param {Object} params - Parameters for interpolation
48
+ * @returns {string} Translated message
49
+ * @public
50
+ */
51
+ export function t(errorCode: string, params?: Object): string;
@@ -1,17 +1,55 @@
1
+ /**
2
+ * Eager mode component - builds APIs by loading all modules immediately.
3
+ * @class EagerMode
4
+ * @extends ComponentBase
5
+ * @package
6
+ */
1
7
  export class EagerMode extends ComponentBase {
2
8
  static slothletProperty: string;
3
- buildAPI({ dir, apiPathPrefix, collisionContext, moduleID, apiDepth, cacheBust, fileFilter, hidden, scanHiddenFolders, preloadedStructure, rootUnwrap }: {
4
- dir: any;
9
+ /**
10
+ * Create EagerMode instance.
11
+ * @param {object} slothlet - Slothlet orchestrator instance.
12
+ * @package
13
+ */
14
+ constructor(slothlet: object);
15
+ /**
16
+ * Build API in eager mode (load all modules immediately).
17
+ * @param {Object} options - Build options
18
+ * @param {string} options.dir - Directory path to load from
19
+ * @param {string} [options.apiPathPrefix=""] - Prefix for API paths
20
+ * @param {string} [options.collisionContext="initial"] - Collision context
21
+ * @param {string|null} [options.collisionMode=null] - Per-call collision mode override (e.g. from `api.add()`'s `forceOverwrite`) — see `lazy.mjs`'s identical parameter
22
+ * @param {string} [options.moduleID] - Module ID
23
+ * @param {number} [options.apiDepth=DEFAULT_API_DEPTH] - Maximum directory depth ({@link DEFAULT_API_DEPTH})
24
+ * @param {string|null} [options.cacheBust=null] - Cache-busting value
25
+ * @param {Function|null} [options.fileFilter=null] - Optional filter (fileName) => boolean
26
+ * @param {string|string[]|null} [options.hidden=null] - Glob(s) hiding files/folders, matched against each entry's path relative to the API root
27
+ * @param {boolean} [options.scanHiddenFolders=false] - Deprecated: restore the pre-v3.11 scanning of `.`/`__`-prefixed folders
28
+ * @param {Object|null} [options.preloadedStructure=null] - Pre-built `{ files, directories }` structure
29
+ * to use instead of scanning `dir` (synthetic / in-memory build, #117). Each synthetic file entry
30
+ * carries its exports directly so no module is loaded from disk.
31
+ * @param {boolean} [options.rootUnwrap=false] - The mount exposes the single root entry's exports
32
+ * directly at the mount path (a single-file or synthetic `api.add()`), so that entry creates no api
33
+ * level and must contribute no path segment either.
34
+ * @returns {Promise<Object>} Built API object
35
+ * @public
36
+ *
37
+ * @example
38
+ * const api = await slothlet.modes.eager.buildAPI({ dir: "./api", moduleID: "base" });
39
+ */
40
+ public buildAPI({ dir, apiPathPrefix, collisionContext, collisionMode, moduleID, apiDepth, cacheBust, fileFilter, hidden, scanHiddenFolders, preloadedStructure, rootUnwrap }: {
41
+ dir: string;
5
42
  apiPathPrefix?: string | undefined;
6
43
  collisionContext?: string | undefined;
7
- moduleID: any;
44
+ collisionMode?: string | null | undefined;
45
+ moduleID?: string | undefined;
8
46
  apiDepth?: number | undefined;
9
- cacheBust?: null | undefined;
10
- fileFilter?: null | undefined;
11
- hidden?: null | undefined;
47
+ cacheBust?: string | null | undefined;
48
+ fileFilter?: Function | null | undefined;
49
+ hidden?: string | string[] | null | undefined;
12
50
  scanHiddenFolders?: boolean | undefined;
13
- preloadedStructure?: null | undefined;
51
+ preloadedStructure?: Object | null | undefined;
14
52
  rootUnwrap?: boolean | undefined;
15
- }): Promise<any>;
53
+ }): Promise<Object>;
16
54
  }
17
55
  import { ComponentBase } from "#factories/component-base";
@@ -1,19 +1,66 @@
1
+ /**
2
+ * Lazy mode component - builds APIs with deferred (on-demand) loading.
3
+ * @class LazyMode
4
+ * @extends ComponentBase
5
+ * @package
6
+ */
1
7
  export class LazyMode extends ComponentBase {
2
8
  static slothletProperty: string;
3
- createNamedMaterializeFunc(apiPath: any, handler: any): (...args: any[]) => Promise<any>;
4
- buildAPI({ dir, apiPathPrefix, collisionContext, collisionMode, moduleID, apiDepth, cacheBust, fileFilter, hidden, scanHiddenFolders, preloadedStructure, rootUnwrap }: {
5
- dir: any;
9
+ /**
10
+ * Create LazyMode instance.
11
+ * @param {object} slothlet - Slothlet orchestrator instance.
12
+ * @package
13
+ */
14
+ constructor(slothlet: object);
15
+ /**
16
+ * Create a named async materialization function for lazy subdirectories.
17
+ * @param {string} apiPath - API path to derive the function name from.
18
+ * @param {Function} handler - Async handler that performs materialization.
19
+ * @returns {Function} Named async materialization function.
20
+ * @public
21
+ *
22
+ * @example
23
+ * const fn = lazyMode.createNamedMaterializeFunc('api.math', async () => ({ add: (a,b) => a+b }));
24
+ */
25
+ public createNamedMaterializeFunc(apiPath: string, handler: Function): Function;
26
+ /**
27
+ * Build API in lazy mode (proxy-based deferred loading).
28
+ * @param {Object} options - Build options
29
+ * @param {string} options.dir - Directory to build from
30
+ * @param {string} [options.apiPathPrefix=""] - Prefix for API paths
31
+ * @param {string} [options.collisionContext="initial"] - Collision context
32
+ * @param {string|null} [options.collisionMode=null] - Collision mode override from api.add()
33
+ * @param {string} [options.moduleID] - Module ID
34
+ * @param {number} [options.apiDepth=DEFAULT_API_DEPTH] - Maximum directory depth ({@link DEFAULT_API_DEPTH})
35
+ * @param {string|null} [options.cacheBust=null] - Cache-busting value
36
+ * @param {Function|null} [options.fileFilter=null] - Optional filter (fileName) => boolean
37
+ * @param {string|string[]|null} [options.hidden=null] - Glob(s) hiding files/folders, matched against each entry's path relative to the API root
38
+ * @param {boolean} [options.scanHiddenFolders=false] - Deprecated: restore the pre-v3.11 scanning of `.`/`__`-prefixed folders
39
+ * @param {Object|null} [options.preloadedStructure=null] - Pre-built `{ files, directories }` structure
40
+ * to use instead of scanning `dir` (synthetic / in-memory build, #117). Each synthetic file entry
41
+ * carries its exports directly so no module is loaded from disk.
42
+ * @param {boolean} [options.rootUnwrap=false] - The mount exposes the single root entry's exports
43
+ * directly at the mount path (a single-file or synthetic `api.add()`), so that entry creates no api
44
+ * level and must contribute no path segment either.
45
+ * @returns {Promise<Object>} Built API object with lazy proxies
46
+ * @public
47
+ *
48
+ * @example
49
+ * const api = await slothlet.modes.lazy.buildAPI({ dir: "./api", moduleID: "base" });
50
+ */
51
+ public buildAPI({ dir, apiPathPrefix, collisionContext, collisionMode, moduleID, apiDepth, cacheBust, fileFilter, hidden, scanHiddenFolders, preloadedStructure, rootUnwrap }: {
52
+ dir: string;
6
53
  apiPathPrefix?: string | undefined;
7
54
  collisionContext?: string | undefined;
8
- collisionMode?: null | undefined;
9
- moduleID: any;
55
+ collisionMode?: string | null | undefined;
56
+ moduleID?: string | undefined;
10
57
  apiDepth?: number | undefined;
11
- cacheBust?: null | undefined;
12
- fileFilter?: null | undefined;
13
- hidden?: null | undefined;
58
+ cacheBust?: string | null | undefined;
59
+ fileFilter?: Function | null | undefined;
60
+ hidden?: string | string[] | null | undefined;
14
61
  scanHiddenFolders?: boolean | undefined;
15
- preloadedStructure?: null | undefined;
62
+ preloadedStructure?: Object | null | undefined;
16
63
  rootUnwrap?: boolean | undefined;
17
- }): Promise<any>;
64
+ }): Promise<Object>;
18
65
  }
19
66
  import { ComponentBase } from "#factories/component-base";