@cldmv/slothlet 1.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +862 -73
  2. package/dist/lib/engine/README.md +21 -0
  3. package/dist/lib/engine/slothlet_child.mjs +58 -0
  4. package/dist/lib/engine/slothlet_engine.mjs +371 -0
  5. package/dist/lib/engine/slothlet_esm.mjs +229 -0
  6. package/dist/lib/engine/slothlet_helpers.mjs +454 -0
  7. package/dist/lib/engine/slothlet_worker.mjs +148 -0
  8. package/dist/lib/helpers/resolve-from-caller.mjs +141 -0
  9. package/dist/lib/helpers/sanitize.mjs +78 -0
  10. package/dist/lib/modes/slothlet_eager.mjs +80 -0
  11. package/dist/lib/modes/slothlet_lazy.mjs +342 -0
  12. package/dist/lib/runtime/runtime.mjs +249 -0
  13. package/dist/slothlet.mjs +1092 -0
  14. package/index.cjs +81 -0
  15. package/index.mjs +76 -0
  16. package/package.json +136 -14
  17. package/types/dist/lib/engine/slothlet_child.d.mts +2 -0
  18. package/types/dist/lib/engine/slothlet_child.d.mts.map +1 -0
  19. package/types/dist/lib/engine/slothlet_engine.d.mts +31 -0
  20. package/types/dist/lib/engine/slothlet_engine.d.mts.map +1 -0
  21. package/types/dist/lib/engine/slothlet_esm.d.mts +19 -0
  22. package/types/dist/lib/engine/slothlet_esm.d.mts.map +1 -0
  23. package/types/dist/lib/engine/slothlet_helpers.d.mts +24 -0
  24. package/types/dist/lib/engine/slothlet_helpers.d.mts.map +1 -0
  25. package/types/dist/lib/engine/slothlet_worker.d.mts +2 -0
  26. package/types/dist/lib/engine/slothlet_worker.d.mts.map +1 -0
  27. package/types/dist/lib/helpers/resolve-from-caller.d.mts +149 -0
  28. package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -0
  29. package/types/dist/lib/helpers/sanitize.d.mts +138 -0
  30. package/types/dist/lib/helpers/sanitize.d.mts.map +1 -0
  31. package/types/dist/lib/modes/slothlet_eager.d.mts +66 -0
  32. package/types/dist/lib/modes/slothlet_eager.d.mts.map +1 -0
  33. package/types/dist/lib/modes/slothlet_lazy.d.mts +32 -0
  34. package/types/dist/lib/modes/slothlet_lazy.d.mts.map +1 -0
  35. package/types/dist/lib/runtime/runtime.d.mts +49 -0
  36. package/types/dist/lib/runtime/runtime.d.mts.map +1 -0
  37. package/types/dist/slothlet.d.mts +110 -0
  38. package/types/dist/slothlet.d.mts.map +1 -0
  39. package/types/index.d.mts +23 -0
  40. package/slothlet.mjs +0 -1218
@@ -0,0 +1,141 @@
1
+ /*
2
+ Copyright 2025 CLDMV/Shinrai
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+
18
+
19
+
20
+ import fs from "node:fs";
21
+ import path from "node:path";
22
+ import { fileURLToPath, pathToFileURL } from "node:url";
23
+
24
+
25
+
26
+
27
+ export const toFsPath = (v) => (v && String(v).startsWith("file://") ? fileURLToPath(String(v)) : v ? String(v) : null);
28
+
29
+
30
+ export function getStack(skipFn) {
31
+ const orig = Error.prepareStackTrace;
32
+ try {
33
+ Error.prepareStackTrace = (_, s) => s;
34
+ const e = new Error("Stack trace");
35
+ if (skipFn) Error.captureStackTrace(e, skipFn);
36
+ return e.stack || [];
37
+ } finally {
38
+ Error.prepareStackTrace = orig;
39
+ }
40
+ }
41
+
42
+ const THIS_FILE = fileURLToPath(import.meta.url);
43
+ const THIS_DIR = path.dirname(THIS_FILE);
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+ function pickPrimaryBaseFile() {
53
+ const files = [];
54
+ for (const cs of getStack(pickPrimaryBaseFile)) {
55
+ const f = toFsPath(cs?.getFileName?.());
56
+ if (!f) continue;
57
+ if (f.startsWith?.("node:internal")) continue;
58
+ files.push(f);
59
+ }
60
+
61
+ let iSloth = -1;
62
+ for (let i = 0; i < files.length; i++) {
63
+ if (path.basename(files[i]).toLowerCase() === "slothlet.mjs") iSloth = i;
64
+ }
65
+ if (iSloth !== -1) {
66
+ const j = iSloth + 1;
67
+ if (j < files.length) {
68
+ const b = path.basename(files[j]).toLowerCase();
69
+ if (/^index\.(mjs|cjs|js)$/.test(b) && j + 1 < files.length) return files[j + 1];
70
+ return files[j];
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+
76
+
77
+ function pickFallbackBaseFile() {
78
+ for (const cs of getStack(pickFallbackBaseFile)) {
79
+ const f = toFsPath(cs?.getFileName?.());
80
+ if (!f) continue;
81
+ if (f.startsWith?.("node:internal")) continue;
82
+ if (f === THIS_FILE) continue;
83
+ if (f.startsWith(THIS_DIR + path.sep)) continue;
84
+ if (path.basename(f).toLowerCase() === "slothlet.mjs") continue;
85
+ return f;
86
+ }
87
+ return THIS_FILE;
88
+ }
89
+
90
+
91
+
92
+
93
+ function resolveWith(rel, makePrimary, exists, makeFallback) {
94
+ if (typeof rel !== "string") throw new TypeError("rel must be a string");
95
+
96
+
97
+ const primaryBase = pickPrimaryBaseFile() ?? pickFallbackBaseFile();
98
+ const primary = makePrimary(primaryBase, rel);
99
+ if (exists(primary)) return primary;
100
+
101
+ const fbBase = pickFallbackBaseFile();
102
+ return makeFallback(fbBase, rel);
103
+ }
104
+
105
+
106
+
107
+
108
+ export function resolvePathFromCaller(rel) {
109
+
110
+ if (rel.startsWith?.("file://")) return fileURLToPath(rel);
111
+ if (path.isAbsolute(rel)) return rel;
112
+
113
+ return resolveWith(
114
+ rel,
115
+
116
+ (baseFile, r) => path.resolve(path.dirname(baseFile), r),
117
+
118
+ (candidate) => fs.existsSync(candidate),
119
+
120
+ (baseFile, r) => path.resolve(path.dirname(baseFile), r)
121
+ );
122
+ }
123
+
124
+
125
+ export function resolveUrlFromCaller(rel) {
126
+
127
+ if (rel.startsWith?.("file://")) return rel;
128
+ if (path.isAbsolute(rel)) return pathToFileURL(rel).href;
129
+
130
+ return resolveWith(
131
+ rel,
132
+
133
+ (baseFile, r) => new URL(r, pathToFileURL(baseFile)).href,
134
+
135
+ (href) => fs.existsSync(fileURLToPath(href)),
136
+
137
+ (baseFile, r) => new URL(r, pathToFileURL(baseFile)).href
138
+ );
139
+ }
140
+
141
+
@@ -0,0 +1,78 @@
1
+ /*
2
+ Copyright 2025 CLDMV/Shinrai
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+
18
+
19
+
20
+ export function sanitizePathName(input, opts = {}) {
21
+ const { lowerFirst = true, rules = {} } = opts;
22
+
23
+ const L = (rules.leave || []).map((s) => String(s).toLowerCase());
24
+ const U = (rules.upper || []).map((s) => String(s).toLowerCase());
25
+ const W = (rules.lower || []).map((s) => String(s).toLowerCase());
26
+
27
+ const isValidId = (s) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(s);
28
+
29
+ let s = String(input).trim();
30
+
31
+
32
+ if (isValidId(s)) return s;
33
+
34
+
35
+ let parts = s.split(/[^A-Za-z0-9_$]+/).filter(Boolean);
36
+ if (parts.length === 0) return "_";
37
+
38
+
39
+
40
+ while (parts.length && !/^[A-Za-z_$]/.test(parts[0][0])) {
41
+ parts[0] = parts[0].replace(/^[^A-Za-z_$]+/, "");
42
+ if (!parts[0]) parts.shift();
43
+ }
44
+ if (parts.length === 0) return "_";
45
+
46
+ const applyRule = (seg, index) => {
47
+ const key = seg.toLowerCase();
48
+
49
+
50
+ if (L.includes(key)) return seg;
51
+
52
+
53
+ if (U.includes(key)) return seg.toUpperCase();
54
+
55
+
56
+ if (W.includes(key)) return seg.toLowerCase();
57
+
58
+
59
+ if (index === 0) {
60
+
61
+ return lowerFirst ? seg[0].toLowerCase() + seg.slice(1) : seg;
62
+ }
63
+
64
+ return seg[0].toUpperCase() + seg.slice(1);
65
+ };
66
+
67
+
68
+ let out = parts.map((seg, i) => applyRule(seg.replace(/[^A-Za-z0-9_$]/g, ""), i)).join("");
69
+
70
+
71
+ out = out.replace(/[^A-Za-z0-9_$]/g, "");
72
+ if (!out || !/^[A-Za-z_$]/.test(out[0])) out = "_" + out;
73
+
74
+ return out;
75
+ }
76
+
77
+
78
+
@@ -0,0 +1,80 @@
1
+ /*
2
+ Copyright 2025 CLDMV/Shinrai
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+
18
+
19
+
20
+
21
+ import fs from "fs/promises";
22
+ import path from "path";
23
+
24
+
25
+
26
+
27
+
28
+
29
+ export async function create(dir, rootLevel = true, maxDepth = Infinity, currentDepth = 0) {
30
+
31
+ const entries = await fs.readdir(dir, { withFileTypes: true });
32
+ const api = {};
33
+
34
+ const rootNamedExports = {};
35
+
36
+ let rootDefaultFunction = null;
37
+
38
+ if (rootLevel) {
39
+ for (const entry of entries) {
40
+ if (this._shouldIncludeFile(entry)) {
41
+ const ext = path.extname(entry.name);
42
+ const fileName = path.basename(entry.name, ext);
43
+ const apiKey = this._toApiKey(fileName);
44
+ const mod = await this._loadSingleModule(path.join(dir, entry.name), true);
45
+ if (mod && typeof mod.default === "function") {
46
+ if (!rootDefaultFunction) rootDefaultFunction = mod.default;
47
+ for (const [key, value] of Object.entries(mod)) {
48
+ if (key !== "default") api[key] = value;
49
+ }
50
+ } else {
51
+ api[apiKey] = mod;
52
+ for (const [key, value] of Object.entries(mod)) {
53
+ rootNamedExports[key] = value;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ for (const entry of entries) {
61
+ if (entry.isDirectory() && !entry.name.startsWith(".") && currentDepth < maxDepth) {
62
+ const categoryPath = path.join(dir, entry.name);
63
+ api[this._toApiKey(entry.name)] = await this._loadCategory(categoryPath, currentDepth + 1, maxDepth);
64
+ }
65
+ }
66
+
67
+ let finalApi;
68
+ if (rootDefaultFunction) {
69
+ Object.assign(rootDefaultFunction, api);
70
+ finalApi = rootDefaultFunction;
71
+ } else {
72
+ finalApi = api;
73
+ }
74
+
75
+
76
+
77
+
78
+
79
+ return finalApi;
80
+ }
@@ -0,0 +1,342 @@
1
+ /*
2
+ Copyright 2025 CLDMV/Shinrai
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+
18
+ import fs from "fs/promises";
19
+ import path from "path";
20
+ import { runWithCtx } from "@cldmv/slothlet/runtime";
21
+
22
+
23
+ export async function create(dir, rootLevel = true, maxDepth = Infinity, currentDepth = 0) {
24
+ const instance = this;
25
+ const entries = await fs.readdir(dir, { withFileTypes: true });
26
+ let api = {};
27
+ let rootDefaultFn = null;
28
+
29
+
30
+ if (rootLevel) {
31
+ for (const entry of entries) {
32
+ if (instance._shouldIncludeFile(entry)) {
33
+ const ext = path.extname(entry.name);
34
+ const fileName = path.basename(entry.name, ext);
35
+ const apiKey = instance._toApiKey(fileName);
36
+ const mod = await instance._loadSingleModule(path.join(dir, entry.name), true);
37
+ if (mod && typeof mod.default === "function") {
38
+ if (!rootDefaultFn) rootDefaultFn = mod.default;
39
+ for (const [k, v] of Object.entries(mod)) {
40
+ if (k !== "default") api[k] = v;
41
+ }
42
+ } else {
43
+ api[apiKey] = mod;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+
50
+ if (rootDefaultFn) {
51
+ Object.assign(rootDefaultFn, api);
52
+ api = rootDefaultFn;
53
+ }
54
+
55
+
56
+ for (const entry of entries) {
57
+ if (entry.isDirectory() && !entry.name.startsWith(".") && currentDepth < maxDepth) {
58
+ const key = instance._toApiKey(entry.name);
59
+ const subDirPath = path.join(dir, entry.name);
60
+ const parent = api;
61
+ const depth = 1;
62
+ const proxy = createFolderProxy({
63
+ subDirPath,
64
+ key,
65
+ parent,
66
+ instance,
67
+ depth,
68
+ maxDepth,
69
+ pathParts: [key]
70
+ });
71
+ parent[key] = proxy;
72
+ }
73
+ }
74
+
75
+ return api;
76
+ }
77
+
78
+
79
+ function replacePlaceholder(parent, key, placeholder, value, instance, depth) {
80
+ if (!parent || !key) return;
81
+ if (parent[key] !== placeholder) return;
82
+
83
+
84
+ let finalKey = key;
85
+ if (typeof value === "function" && value.name && value.name.toLowerCase() === key.toLowerCase() && value.name !== key) {
86
+
87
+ finalKey = value.name;
88
+
89
+
90
+ if (finalKey !== key && key in parent) {
91
+ try {
92
+ delete parent[key];
93
+ } catch {
94
+
95
+ }
96
+ }
97
+ }
98
+
99
+ try {
100
+ Object.defineProperty(parent, finalKey, { value, writable: true, enumerable: true, configurable: true });
101
+ } catch {
102
+ parent[finalKey] = value;
103
+ }
104
+ if (instance?.config?.debug) {
105
+ console.log(`[lazy][materialize] replaced ${key}${finalKey !== key ? ` -> ${finalKey}` : ""} (${typeof value})`);
106
+ }
107
+ if (depth === 1 && typeof instance?.updateBoundApiProperty === "function") {
108
+ instance.updateBoundApiProperty(finalKey, parent[finalKey]);
109
+ }
110
+ }
111
+
112
+
113
+ function createFolderProxy({ subDirPath, key, parent, instance, depth, maxDepth, pathParts }) {
114
+ let materialized = null;
115
+ let inFlight = null;
116
+
117
+
118
+ async function _materialize() {
119
+ if (materialized) return materialized;
120
+ if (inFlight) return inFlight;
121
+
122
+
123
+ const lazy_materializeCategory = async () => {
124
+ const value = await instance._buildCategory(subDirPath, {
125
+ currentDepth: depth,
126
+ maxDepth,
127
+ mode: "lazy",
128
+ subdirHandler: ({ subDirPath: nestedPath, key: nestedKey, categoryModules, currentDepth: cd, maxDepth: md }) =>
129
+ createFolderProxy({
130
+ subDirPath: nestedPath,
131
+ key: nestedKey,
132
+ parent: categoryModules,
133
+ instance,
134
+ depth: cd + 1,
135
+ maxDepth: md,
136
+ pathParts: [...pathParts, nestedKey]
137
+ })
138
+ });
139
+ materialized = value;
140
+ if (instance?.config?.debug) {
141
+ try {
142
+ const infoKeys = materialized && typeof materialized === "object" ? Object.keys(materialized) : [];
143
+ const todayType = materialized && materialized.today ? typeof materialized.today : "n/a";
144
+ console.log(
145
+ `[lazy][debug] materialized key='${key}' path='${subDirPath}' type=${typeof materialized} keys=${JSON.stringify(
146
+ infoKeys
147
+ )} todayType=${todayType}`
148
+ );
149
+ } catch {
150
+
151
+ }
152
+ }
153
+
154
+ replacePlaceholder(parent, key, placeholder, materialized, instance, depth);
155
+
156
+ if (instance.config.debug) {
157
+ try {
158
+ const type = typeof materialized;
159
+ const keys = type === "object" && materialized ? Object.keys(materialized) : [];
160
+ console.log(
161
+ `[lazy][debug] materialized '${pathParts.join("/")}' -> type=${type} keys=${JSON.stringify(keys)} parentHas=${
162
+ parent[key] === materialized
163
+ }`
164
+ );
165
+ } catch {
166
+
167
+ }
168
+ }
169
+ placeholder.__materialized = materialized;
170
+ return materialized;
171
+ };
172
+ inFlight = lazy_materializeCategory();
173
+ try {
174
+ return await inFlight;
175
+ } finally {
176
+ inFlight = null;
177
+ }
178
+ }
179
+
180
+
181
+ async function lazy_invoke(thisArg, ...args) {
182
+ const value = await _materialize();
183
+ if (typeof value === "function") {
184
+
185
+ const ctx = instance.boundapi?.__ctx;
186
+ if (ctx) {
187
+ return runWithCtx(ctx, value, thisArg, args);
188
+ } else {
189
+ return value.apply(thisArg, args);
190
+ }
191
+ }
192
+
193
+
194
+ return value;
195
+ }
196
+
197
+
198
+
199
+ function lazy_lazyTarget(...args) {
200
+ return lazy_invoke(this, ...args);
201
+ }
202
+
203
+ Object.defineProperty(lazy_lazyTarget, "__materialized", { value: null, writable: true, enumerable: false, configurable: true });
204
+
205
+ Object.defineProperty(lazy_lazyTarget, "__slothletPath", { value: subDirPath, enumerable: false, configurable: true });
206
+
207
+ Object.defineProperty(lazy_lazyTarget, "_materialize", { value: _materialize, enumerable: false, configurable: true, writable: true });
208
+
209
+
210
+ try {
211
+ Object.defineProperty(lazy_lazyTarget, "name", { value: `lazyFolder_${key}`, configurable: true });
212
+ } catch {
213
+
214
+ }
215
+
216
+ const placeholder = new Proxy(lazy_lazyTarget, {
217
+ apply(_t, thisArg, args) {
218
+ return lazy_invoke(thisArg, ...args);
219
+ },
220
+ get(_t, prop, _) {
221
+ if (prop === "__materialized") return materialized;
222
+ if (prop === "_materialize") return _materialize;
223
+ if (prop === "then") return undefined;
224
+
225
+ if (materialized) {
226
+ if (materialized && (typeof materialized === "object" || typeof materialized === "function")) return materialized[prop];
227
+ return undefined;
228
+ }
229
+
230
+ if (!inFlight) inFlight = _materialize();
231
+
232
+
233
+
234
+
235
+ return new Proxy(
236
+
237
+ function lazy_propertyAccessor(...args) {
238
+ return inFlight.then(
239
+
240
+ function lazy_handleResolvedValue(resolved) {
241
+ const value = resolved ? resolved[prop] : undefined;
242
+ if (typeof value === "function") {
243
+
244
+ const ctx = instance.boundapi?.__ctx;
245
+ if (ctx) {
246
+ return runWithCtx(ctx, value, this, args);
247
+ } else {
248
+ return value.apply(this, args);
249
+ }
250
+ }
251
+ return value;
252
+ }
253
+ );
254
+ },
255
+ {
256
+
257
+ get(target, subProp) {
258
+ if (subProp === "name") return `lazy_${prop}`;
259
+ if (subProp === "length") return 0;
260
+
261
+ return new Proxy(
262
+ function lazy_deepPropertyAccessor() {},
263
+ {
264
+ apply(target, thisArg, args) {
265
+
266
+ if (materialized) {
267
+ const value = materialized[prop];
268
+ if (value && typeof value[subProp] === "function") {
269
+
270
+ const ctx = instance.boundapi?.__ctx;
271
+ if (ctx) {
272
+ return runWithCtx(ctx, value[subProp], thisArg, args);
273
+ } else {
274
+ return value[subProp].apply(thisArg, args);
275
+ }
276
+ }
277
+ return value ? value[subProp] : undefined;
278
+ }
279
+
280
+
281
+ if (!inFlight) inFlight = _materialize();
282
+ return inFlight.then(
283
+
284
+ function lazy_handleDeepResolvedValue(resolved) {
285
+ const value = resolved ? resolved[prop] : undefined;
286
+ if (value && typeof value[subProp] === "function") {
287
+
288
+ const ctx = instance.boundapi?.__ctx;
289
+ if (ctx) {
290
+ return runWithCtx(ctx, value[subProp], thisArg, args);
291
+ } else {
292
+ return value[subProp].apply(thisArg, args);
293
+ }
294
+ }
295
+ return value ? value[subProp] : undefined;
296
+ }
297
+ );
298
+ }
299
+ }
300
+ );
301
+ }
302
+ }
303
+ );
304
+ },
305
+ has(_t, prop) {
306
+ if (materialized && (typeof materialized === "object" || typeof materialized === "function")) return prop in materialized;
307
+ return false;
308
+ },
309
+ ownKeys() {
310
+ const baseKeys = Reflect.ownKeys(lazy_lazyTarget);
311
+ if (!materialized) return baseKeys;
312
+ if (typeof materialized === "object" || typeof materialized === "function") {
313
+ const matKeys = Reflect.ownKeys(materialized);
314
+ return Array.from(new Set([...baseKeys, ...matKeys]));
315
+ }
316
+ return baseKeys;
317
+ },
318
+ getOwnPropertyDescriptor(_t, prop) {
319
+ if (prop === "_materialize") {
320
+
321
+ return Reflect.getOwnPropertyDescriptor(lazy_lazyTarget, "_materialize");
322
+ }
323
+ if (prop === "__materialized") {
324
+ return { configurable: true, enumerable: false, writable: true, value: materialized };
325
+ }
326
+ if (prop === "prototype") {
327
+
328
+ return Object.getOwnPropertyDescriptor(lazy_lazyTarget, "prototype");
329
+ }
330
+ if (materialized && (typeof materialized === "object" || typeof materialized === "function")) {
331
+ const d = Object.getOwnPropertyDescriptor(materialized, prop);
332
+ if (d) return { ...d, configurable: true };
333
+ }
334
+
335
+ const td = Object.getOwnPropertyDescriptor(lazy_lazyTarget, prop);
336
+ if (td) return { ...td, configurable: true };
337
+ return undefined;
338
+ }
339
+ });
340
+
341
+ return placeholder;
342
+ }