@cldmv/slothlet 2.5.4 → 2.5.6
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/dist/lib/helpers/api_builder.mjs +145 -26
- package/dist/lib/helpers/multidefault.mjs +12 -2
- package/dist/lib/modes/slothlet_eager.mjs +1 -1
- package/dist/lib/modes/slothlet_lazy.mjs +25 -1
- package/dist/lib/runtime/runtime.mjs +12 -1
- package/dist/slothlet.mjs +96 -9
- package/package.json +1 -1
- package/types/dist/lib/helpers/api_builder.d.mts.map +1 -1
- package/types/dist/lib/helpers/multidefault.d.mts +8 -3
- package/types/dist/lib/helpers/multidefault.d.mts.map +1 -1
- package/types/dist/lib/modes/slothlet_lazy.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts.map +1 -1
|
@@ -20,7 +20,28 @@
|
|
|
20
20
|
|
|
21
21
|
import fs from "node:fs/promises";
|
|
22
22
|
import path from "node:path";
|
|
23
|
+
import { types as utilTypes } from "node:util";
|
|
23
24
|
import { pathToFileURL } from "node:url";
|
|
25
|
+
import { multidefault_analyzeModules } from "@cldmv/slothlet/helpers/multidefault";
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function isLikelySerializable(val) {
|
|
33
|
+
const type = typeof val;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if (type !== "object" || val === null) {
|
|
37
|
+
return type === "string" || type === "number" || type === "boolean" || type === "undefined";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
Array.isArray(val) || val instanceof Date || val instanceof RegExp || val?.constructor === Object || typeof val.toJSON === "function"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
24
45
|
|
|
25
46
|
|
|
26
47
|
|
|
@@ -28,10 +49,18 @@ import { pathToFileURL } from "node:url";
|
|
|
28
49
|
|
|
29
50
|
|
|
30
51
|
export async function analyzeModule(modulePath, options = {}) {
|
|
31
|
-
const { debug = false } = options;
|
|
52
|
+
const { debug = false, instance = null } = options;
|
|
32
53
|
|
|
33
54
|
const moduleUrl = pathToFileURL(modulePath).href;
|
|
34
|
-
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
let importUrl = moduleUrl;
|
|
58
|
+
if (instance && instance.instanceId) {
|
|
59
|
+
const separator = moduleUrl.includes("?") ? "&" : "?";
|
|
60
|
+
importUrl = `${moduleUrl}${separator}slothlet_instance=${instance.instanceId}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const rawModule = await import(importUrl);
|
|
35
64
|
|
|
36
65
|
|
|
37
66
|
let processedModule = rawModule;
|
|
@@ -187,9 +216,115 @@ export function processModuleFromAnalysis(analysis, options = {}) {
|
|
|
187
216
|
const obj = processedModule.default;
|
|
188
217
|
|
|
189
218
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
const namedExportsToAdd = Object.entries(processedModule).filter(
|
|
220
|
+
([exportName, exportValue]) => exportName !== "default" && exportValue !== obj
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
if (namedExportsToAdd.length > 0) {
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
const isCustomProxy = utilTypes?.isProxy?.(obj) ?? false;
|
|
227
|
+
|
|
228
|
+
if (isCustomProxy) {
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
for (const [exportName, exportValue] of namedExportsToAdd) {
|
|
232
|
+
const apiKey = instance._toapiPathKey(exportName);
|
|
233
|
+
obj[apiKey] = exportValue;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
const proxyWithStructure = obj;
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
proxyWithStructure.default = obj;
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if (!proxyWithStructure.toJSON) {
|
|
263
|
+
Object.defineProperty(proxyWithStructure, "toJSON", {
|
|
264
|
+
value: function () {
|
|
265
|
+
|
|
266
|
+
const serializable = {};
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
for (const key of Reflect.ownKeys(this)) {
|
|
270
|
+
|
|
271
|
+
if (typeof key !== "string") continue;
|
|
272
|
+
|
|
273
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(this, key);
|
|
274
|
+
if (!descriptor || !descriptor.enumerable) continue;
|
|
275
|
+
|
|
276
|
+
if (key === "default") {
|
|
277
|
+
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const value = this[key];
|
|
282
|
+
if (typeof value === "function") {
|
|
283
|
+
serializable[key] = "[Function]";
|
|
284
|
+
} else if (isLikelySerializable(value)) {
|
|
285
|
+
|
|
286
|
+
serializable[key] = value;
|
|
287
|
+
} else {
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
JSON.stringify(value);
|
|
291
|
+
serializable[key] = value;
|
|
292
|
+
} catch {
|
|
293
|
+
serializable[key] = "[Non-serializable value]";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
serializable._slothlet_proxy_info = {
|
|
300
|
+
type: "proxy",
|
|
301
|
+
circular_reference: "Property .default points to this object (excluded from serialization)",
|
|
302
|
+
warning: "This is a slothlet API proxy with circular .default reference"
|
|
303
|
+
};
|
|
304
|
+
return serializable;
|
|
305
|
+
},
|
|
306
|
+
writable: false,
|
|
307
|
+
enumerable: false,
|
|
308
|
+
configurable: true
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
for (const [exportName, exportValue] of namedExportsToAdd) {
|
|
314
|
+
const apiKey = instance._toapiPathKey(exportName);
|
|
315
|
+
if (!(apiKey in proxyWithStructure)) {
|
|
316
|
+
proxyWithStructure[apiKey] = exportValue;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return proxyWithStructure;
|
|
321
|
+
} else {
|
|
322
|
+
|
|
323
|
+
for (const [exportName, exportValue] of namedExportsToAdd) {
|
|
324
|
+
obj[instance._toapiPathKey(exportName)] = exportValue;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return obj;
|
|
193
328
|
}
|
|
194
329
|
}
|
|
195
330
|
|
|
@@ -235,8 +370,7 @@ export async function analyzeDirectoryStructure(categoryPath, options = {}) {
|
|
|
235
370
|
|
|
236
371
|
let multiDefaultAnalysis = null;
|
|
237
372
|
if (processingStrategy === "multi-file") {
|
|
238
|
-
|
|
239
|
-
multiDefaultAnalysis = await multidefault_analyzeModules(moduleFiles, categoryPath, debug);
|
|
373
|
+
multiDefaultAnalysis = await multidefault_analyzeModules(moduleFiles, categoryPath, { debug, instance });
|
|
240
374
|
}
|
|
241
375
|
|
|
242
376
|
|
|
@@ -387,6 +521,7 @@ export function getFlatteningDecision(options) {
|
|
|
387
521
|
|
|
388
522
|
moduleHasDefault = !!mod.default,
|
|
389
523
|
categoryName,
|
|
524
|
+
|
|
390
525
|
totalModules = 1
|
|
391
526
|
} = options;
|
|
392
527
|
|
|
@@ -822,8 +957,7 @@ export async function buildCategoryStructure(categoryPath, options = {}) {
|
|
|
822
957
|
const categoryModules = {};
|
|
823
958
|
|
|
824
959
|
|
|
825
|
-
const
|
|
826
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, debug);
|
|
960
|
+
const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, { debug, instance });
|
|
827
961
|
const { totalDefaultExports, hasMultipleDefaultExports, selfReferentialFiles, defaultExportFiles: analysisDefaults } = analysis;
|
|
828
962
|
|
|
829
963
|
|
|
@@ -857,11 +991,6 @@ export async function buildCategoryStructure(categoryPath, options = {}) {
|
|
|
857
991
|
const fileName = path.basename(file.name, moduleExt);
|
|
858
992
|
const apiPathKey = instance._toapiPathKey(fileName);
|
|
859
993
|
|
|
860
|
-
if (debug && moduleName === "config") {
|
|
861
|
-
console.log(`[DEBUG] Processing config file: ${file.name}, moduleName: ${moduleName}`);
|
|
862
|
-
console.log(`[DEBUG] selfReferentialFiles has config? ${selfReferentialFiles.has(moduleName)}`);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
994
|
|
|
866
995
|
let mod = null;
|
|
867
996
|
let analysis = null;
|
|
@@ -968,8 +1097,7 @@ export async function buildRootAPI(dir, options = {}) {
|
|
|
968
1097
|
|
|
969
1098
|
if (moduleFiles.length > 0) {
|
|
970
1099
|
|
|
971
|
-
const
|
|
972
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, dir, debug);
|
|
1100
|
+
const analysis = await multidefault_analyzeModules(moduleFiles, dir, { debug, instance });
|
|
973
1101
|
const { hasMultipleDefaultExports, selfReferentialFiles } = analysis;
|
|
974
1102
|
|
|
975
1103
|
|
|
@@ -1071,9 +1199,6 @@ export async function buildCategoryDecisions(categoryPath, options = {}) {
|
|
|
1071
1199
|
console.log(`[DEBUG] buildCategoryDecisions called with path: ${categoryPath}, mode: ${mode}`);
|
|
1072
1200
|
}
|
|
1073
1201
|
|
|
1074
|
-
const fs = await import("fs/promises");
|
|
1075
|
-
const path = await import("path");
|
|
1076
|
-
|
|
1077
1202
|
const files = await fs.readdir(categoryPath, { withFileTypes: true });
|
|
1078
1203
|
const moduleFiles = files.filter((f) => instance._shouldIncludeFile(f));
|
|
1079
1204
|
const categoryName = instance._toapiPathKey(path.basename(categoryPath));
|
|
@@ -1258,11 +1383,6 @@ export async function buildCategoryDecisions(categoryPath, options = {}) {
|
|
|
1258
1383
|
|
|
1259
1384
|
decisions.shouldFlatten = false;
|
|
1260
1385
|
decisions.preferredName = moduleName;
|
|
1261
|
-
if (debug && moduleName === "nest") {
|
|
1262
|
-
console.log(
|
|
1263
|
-
`[DEBUG] buildCategoryDecisions single-file default: moduleName="${moduleName}" shouldFlatten=false preferredName="${decisions.preferredName}"`
|
|
1264
|
-
);
|
|
1265
|
-
}
|
|
1266
1386
|
return decisions;
|
|
1267
1387
|
}
|
|
1268
1388
|
|
|
@@ -1273,8 +1393,7 @@ export async function buildCategoryDecisions(categoryPath, options = {}) {
|
|
|
1273
1393
|
}
|
|
1274
1394
|
|
|
1275
1395
|
|
|
1276
|
-
const
|
|
1277
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, debug);
|
|
1396
|
+
const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, { debug, instance });
|
|
1278
1397
|
|
|
1279
1398
|
decisions.multifileAnalysis = analysis;
|
|
1280
1399
|
|
|
@@ -16,10 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
|
|
20
|
+
|
|
19
21
|
import path from "path";
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
async function multidefault_analyzeModules(moduleFiles, baseDir,
|
|
24
|
+
async function multidefault_analyzeModules(moduleFiles, baseDir, options = {}) {
|
|
25
|
+
const { debug = false, instance = null } = options;
|
|
23
26
|
const selfReferentialFiles = new Set();
|
|
24
27
|
const rawModuleCache = new Map();
|
|
25
28
|
const defaultExportFiles = [];
|
|
@@ -36,7 +39,14 @@ async function multidefault_analyzeModules(moduleFiles, baseDir, debug = false)
|
|
|
36
39
|
const moduleFilePath = path.resolve(baseDir, file.name);
|
|
37
40
|
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
let importUrl = `file://${moduleFilePath.replace(/\\/g, "/")}`;
|
|
43
|
+
if (instance && instance.instanceId) {
|
|
44
|
+
const separator = importUrl.includes("?") ? "&" : "?";
|
|
45
|
+
importUrl = `${importUrl}${separator}slothlet_instance=${instance.instanceId}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const rawImport = await import(importUrl);
|
|
40
50
|
|
|
41
51
|
|
|
42
52
|
const isCjsFile = moduleExt === ".cjs";
|
|
@@ -38,7 +38,7 @@ export async function create(dir, maxDepth = Infinity, currentDepth = 0) {
|
|
|
38
38
|
const moduleFiles = entries.filter((e) => this._shouldIncludeFile(e));
|
|
39
39
|
const defaultExportFiles = [];
|
|
40
40
|
|
|
41
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, dir, this.config.debug);
|
|
41
|
+
const analysis = await multidefault_analyzeModules(moduleFiles, dir, { debug: this.config.debug, instance: this });
|
|
42
42
|
|
|
43
43
|
const { totalDefaultExports, hasMultipleDefaultExports, selfReferentialFiles, defaultExportFiles: analysisDefaults } = analysis;
|
|
44
44
|
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import fs from "node:fs/promises";
|
|
21
21
|
import { readdirSync } from "node:fs";
|
|
22
22
|
import path from "node:path";
|
|
23
|
+
import { types as utilTypes } from "node:util";
|
|
23
24
|
import { runWithCtx } from "@cldmv/slothlet/runtime";
|
|
24
25
|
import { processModuleForAPI } from "@cldmv/slothlet/helpers/api_builder";
|
|
25
26
|
import { multidefault_analyzeModules } from "@cldmv/slothlet/helpers/multidefault";
|
|
@@ -37,7 +38,7 @@ export async function create(dir, maxDepth = Infinity, currentDepth = 0) {
|
|
|
37
38
|
const defaultExportFiles = [];
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, dir, instance.config.debug);
|
|
41
|
+
const analysis = await multidefault_analyzeModules(moduleFiles, dir, { debug: instance.config.debug, instance });
|
|
41
42
|
|
|
42
43
|
const { totalDefaultExports, hasMultipleDefaultExports, selfReferentialFiles, defaultExportFiles: analysisDefaults } = analysis;
|
|
43
44
|
|
|
@@ -170,6 +171,29 @@ function replacePlaceholder(parent, key, placeholder, value, instance, depth) {
|
|
|
170
171
|
if (parent[key] !== placeholder) return;
|
|
171
172
|
|
|
172
173
|
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
const isCustomProxy = value && typeof value === "object" && (utilTypes?.isProxy?.(value) ?? false);
|
|
178
|
+
|
|
179
|
+
if (isCustomProxy) {
|
|
180
|
+
if (instance?.config?.debug) {
|
|
181
|
+
console.log(`[lazy][materialize] detected custom Proxy for ${key}, replacing placeholder to avoid memory leaks (${typeof value})`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
|
|
186
|
+
const testAccess = value && typeof value === "object";
|
|
187
|
+
if (!testAccess) {
|
|
188
|
+
console.warn(`[lazy][materialize] Custom proxy for ${key} failed basic validation, but continuing with replacement`);
|
|
189
|
+
}
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.warn(`[lazy][materialize] Custom proxy for ${key} validation failed:`, error.message, "but continuing with replacement");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
173
197
|
let finalKey = key;
|
|
174
198
|
if (typeof value === "function" && value.name && value.name.toLowerCase() === key.toLowerCase() && value.name !== key) {
|
|
175
199
|
|
|
@@ -286,7 +286,18 @@ function runtime_mutateLiveBinding(target, contextKey) {
|
|
|
286
286
|
if (key !== "_impl") delete target[key];
|
|
287
287
|
}
|
|
288
288
|
for (const [key, value] of Object.entries(source)) {
|
|
289
|
-
|
|
289
|
+
try {
|
|
290
|
+
target[key] = value;
|
|
291
|
+
} catch (error) {
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
if (error instanceof TypeError && error.message.includes("read only")) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
290
301
|
}
|
|
291
302
|
if (typeof source._impl === "function") {
|
|
292
303
|
target._impl = source._impl;
|
package/dist/slothlet.mjs
CHANGED
|
@@ -19,11 +19,17 @@
|
|
|
19
19
|
|
|
20
20
|
import fs from "node:fs/promises";
|
|
21
21
|
import path from "node:path";
|
|
22
|
+
import { types as utilTypes } from "node:util";
|
|
22
23
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
23
24
|
|
|
24
25
|
import { resolvePathFromCaller } from "@cldmv/slothlet/helpers/resolve-from-caller";
|
|
25
26
|
import { sanitizePathName } from "@cldmv/slothlet/helpers/sanitize";
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
analyzeModule,
|
|
29
|
+
processModuleFromAnalysis,
|
|
30
|
+
getCategoryBuildingDecisions,
|
|
31
|
+
buildCategoryDecisions
|
|
32
|
+
} from "@cldmv/slothlet/helpers/api_builder";
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
|
|
@@ -112,6 +118,7 @@ const slothletObject = {
|
|
|
112
118
|
config: { lazy: false, apiDepth: Infinity, debug: DEBUG, dir: null, sanitize: null },
|
|
113
119
|
_dispose: null,
|
|
114
120
|
_boundAPIShutdown: null,
|
|
121
|
+
instanceId: null,
|
|
115
122
|
|
|
116
123
|
|
|
117
124
|
async create(options = {}) {
|
|
@@ -121,6 +128,9 @@ const slothletObject = {
|
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
|
|
131
|
+
this.instanceId = `slothlet_${Date.now()}_${Math.random().toString(36).slice(2, 11).padEnd(9, "0")}`;
|
|
132
|
+
|
|
133
|
+
|
|
124
134
|
if (!this.modes) {
|
|
125
135
|
this.modes = {};
|
|
126
136
|
const modesDir = path.join(__dirname, "lib", "modes");
|
|
@@ -338,7 +348,6 @@ const slothletObject = {
|
|
|
338
348
|
const { currentDepth = 0, maxDepth = Infinity, mode = "eager", subdirHandler } = options;
|
|
339
349
|
|
|
340
350
|
|
|
341
|
-
const { buildCategoryDecisions } = await import("@cldmv/slothlet/helpers/api_builder");
|
|
342
351
|
const decisions = await buildCategoryDecisions(categoryPath, {
|
|
343
352
|
currentDepth,
|
|
344
353
|
maxDepth,
|
|
@@ -390,9 +399,6 @@ const slothletObject = {
|
|
|
390
399
|
}
|
|
391
400
|
|
|
392
401
|
|
|
393
|
-
if (this.config.debug && moduleName === "nest") {
|
|
394
|
-
console.log(`[DEBUG] Single-file default case for nest: moduleName="${moduleName}" mod keys=[${Object.keys(mod)}]`);
|
|
395
|
-
}
|
|
396
402
|
return { [moduleName]: mod };
|
|
397
403
|
}
|
|
398
404
|
|
|
@@ -444,13 +450,94 @@ const slothletObject = {
|
|
|
444
450
|
switch (flattenType) {
|
|
445
451
|
case "single-default-object": {
|
|
446
452
|
|
|
447
|
-
const flattened = { ...mod.default };
|
|
448
453
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
454
|
+
let flattened;
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
const defaultExport = mod.default;
|
|
458
|
+
const hasNamedExports = Object.keys(mod).some((k) => k !== "default");
|
|
459
|
+
|
|
460
|
+
if (hasNamedExports && defaultExport && typeof defaultExport === "object") {
|
|
461
|
+
|
|
462
|
+
const isProxy = utilTypes?.isProxy?.(defaultExport) ?? false;
|
|
463
|
+
|
|
464
|
+
if (isProxy) {
|
|
465
|
+
|
|
466
|
+
flattened = defaultExport;
|
|
467
|
+
let assignmentFailed = false;
|
|
468
|
+
|
|
469
|
+
const failedMap = new Map();
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
473
|
+
if (key !== "default") {
|
|
474
|
+
try {
|
|
475
|
+
flattened[key] = value;
|
|
476
|
+
} catch (e) {
|
|
477
|
+
|
|
478
|
+
assignmentFailed = true;
|
|
479
|
+
failedMap.set(key, value);
|
|
480
|
+
if (this.config?.debug) {
|
|
481
|
+
console.warn(
|
|
482
|
+
`Could not assign '${key}' to proxy object in module '${moduleName}' at '${categoryPath}':`,
|
|
483
|
+
e.message
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
if (assignmentFailed) {
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
const originalProxy = flattened;
|
|
501
|
+
flattened = new Proxy(originalProxy, {
|
|
502
|
+
get(target, prop, receiver) {
|
|
503
|
+
|
|
504
|
+
if (failedMap.has(prop)) return failedMap.get(prop);
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
return Reflect.get(target, prop, receiver);
|
|
508
|
+
},
|
|
509
|
+
has(target, prop) {
|
|
510
|
+
|
|
511
|
+
if (failedMap.has(prop)) return true;
|
|
512
|
+
return Reflect.has(target, prop);
|
|
513
|
+
},
|
|
514
|
+
ownKeys(target) {
|
|
515
|
+
const originalKeys = Reflect.ownKeys(target);
|
|
516
|
+
const failedKeys = Array.from(failedMap.keys());
|
|
517
|
+
return [...new Set([...originalKeys, ...failedKeys])];
|
|
518
|
+
},
|
|
519
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
520
|
+
if (failedMap.has(prop)) {
|
|
521
|
+
return { configurable: true, enumerable: true, value: failedMap.get(prop) };
|
|
522
|
+
}
|
|
523
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
|
|
529
|
+
flattened = { ...defaultExport };
|
|
530
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
531
|
+
if (key !== "default") {
|
|
532
|
+
flattened[key] = value;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
452
535
|
}
|
|
536
|
+
} else {
|
|
537
|
+
|
|
538
|
+
flattened = defaultExport;
|
|
453
539
|
}
|
|
540
|
+
|
|
454
541
|
categoryModules[apiPathKey] = flattened;
|
|
455
542
|
break;
|
|
456
543
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_builder.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/api_builder.mjs"],"names":[],"mappings":"
|
|
1
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B,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,CAAC,CAmR3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,kCAtBW,MAAM,YAEd;IAA0B,IAAI,GAAtB,OAAO;IACU,QAAQ,GAAzB,MAAM;IACU,QAAQ,EAAxB,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,WAAS,CAAC,CA2HpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qDAvBW,MAAM,YAEd;IAAyB,YAAY,GAA7B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACW,IAAI,GAArB,MAAM;IACa,aAAa;IAChB,QAAQ,EAAxB,MAAM;CACd,GAAU,OAAO,CAAC,MAAM,CAAC,CAyZ3B"}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* @private
|
|
5
5
|
* @param {Array<{name: string}>} moduleFiles - Array of module file objects with name property
|
|
6
6
|
* @param {string} baseDir - Base directory path containing the modules
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {object} [options={}] - Configuration options
|
|
8
|
+
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
9
|
+
* @param {object|null} [options.instance=null] - Slothlet instance for cache isolation
|
|
8
10
|
* @returns {Promise<{
|
|
9
11
|
* totalDefaultExports: number,
|
|
10
12
|
* hasMultipleDefaultExports: boolean,
|
|
@@ -13,14 +15,17 @@
|
|
|
13
15
|
* defaultExportFiles: Array<{fileName: string, rawModule: object}>
|
|
14
16
|
* }>} Analysis results
|
|
15
17
|
* @example // Internal usage in slothlet modes
|
|
16
|
-
* const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, config.debug);
|
|
18
|
+
* const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, { debug: config.debug, instance });
|
|
17
19
|
* if (analysis.hasMultipleDefaultExports) {
|
|
18
20
|
* // Handle multi-default context
|
|
19
21
|
* }
|
|
20
22
|
*/
|
|
21
23
|
export function multidefault_analyzeModules(moduleFiles: Array<{
|
|
22
24
|
name: string;
|
|
23
|
-
}>, baseDir: string,
|
|
25
|
+
}>, baseDir: string, options?: {
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
instance?: object | null;
|
|
28
|
+
}): Promise<{
|
|
24
29
|
totalDefaultExports: number;
|
|
25
30
|
hasMultipleDefaultExports: boolean;
|
|
26
31
|
selfReferentialFiles: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multidefault.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/multidefault.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multidefault.d.mts","sourceRoot":"","sources":["../../../../dist/lib/helpers/multidefault.mjs"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,yDAlBW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,WACrB,MAAM,YAEd;IAA0B,KAAK,GAAvB,OAAO;IACe,QAAQ,GAA9B,MAAM,GAAC,IAAI;CACnB,GAAU,OAAO,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,kBAAkB,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CACjE,CAAC,CA8FJ;AAED;;;;;;;;GAQG;AACH,0DALW,MAAM,GACJ,OAAO,CAWnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,4DAvBG;IAAyB,yBAAyB,EAA1C,OAAO;IACU,gBAAgB,EAAjC,OAAO;IACU,iBAAiB,EAAlC,OAAO;IACgB,UAAU,EAAjC,KAAK,CAAC,MAAM,CAAC;IACG,UAAU,EAA1B,MAAM;IACU,gBAAgB,EAAhC,MAAM;IACY,KAAK,GAAvB,OAAO;CACf,GAAU;IACR,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAA;CACf,CA4FH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slothlet_lazy.d.mts","sourceRoot":"","sources":["../../../../dist/lib/modes/slothlet_lazy.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slothlet_lazy.d.mts","sourceRoot":"","sources":["../../../../dist/lib/modes/slothlet_lazy.mjs"],"names":[],"mappings":"AAiKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,4BAtBW,MAAM,aACN,MAAM,iBACN,MAAM,GACJ,OAAO,CAAC,WAAS,MAAM,CAAC,CA4JpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"AAuCA;;;;;GAKG;AACH,wBAHU,qBAAqB,CAGkB;AAsB1C,gCAdI,MAAM,yBAEN,GAAG,gBAED,GAAG,CA6Bf;AAiBM,0BAZM,MAAM,GAAC,IAAI,CAY0B;AAiL3C,iCAjBI,MAAM,YAgIhB;
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","sourceRoot":"","sources":["../../../../dist/lib/runtime/runtime.mjs"],"names":[],"mappings":"AAuCA;;;;;GAKG;AACH,wBAHU,qBAAqB,CAGkB;AAsB1C,gCAdI,MAAM,yBAEN,GAAG,gBAED,GAAG,CA6Bf;AAiBM,0BAZM,MAAM,GAAC,IAAI,CAY0B;AAiL3C,iCAjBI,MAAM,YAgIhB;AAuSD;;;;;;;;;;;;;GAaG;AACH,mBATU,WAAS,MAAM,CAS6B;AAEtD;;;;;;;;;;;;;GAaG;AACH,sBATU,MAAM,CAS4C;AAE5D;;;;;;;;;;;;;GAaG;AACH,wBATU,MAAM,CASgD;;kCA3rB9B,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slothlet.d.mts","sourceRoot":"","sources":["../../dist/slothlet.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slothlet.d.mts","sourceRoot":"","sources":["../../dist/slothlet.mjs"],"names":[],"mappings":"AA05CA;;;;;;;;;GASG;AACH,kDARW,WAAS,MAAM,UACf,WAAS,MAAM,QAwCzB;AA9yCD;;;;;;;GAOG;AACH,mBAJU,MAAM,CAIO;AAEvB;;;;;GAKG;AACH,sBAJU,MAAM,CAIU;AAE1B;;;;;GAKG;AACH,wBAJU,MAAM,CAIY;;;;;;;;;UAiyCd,MAAM;;;;;;WAIN,OAAO;;;;;;;eAGP,MAAM;;;;;;;;YAIN,OAAO;;;;;;;;WAKP,MAAM;;;;;;;eAKN,MAAM;;;;;;cAIN,MAAM;;;;;;gBAGN,MAAM;;;;;;eAMjB;QAA8B,UAAU,GAA7B,OAAO;QACY,gBAAgB,GAAnC,OAAO;QACY,gBAAgB,GAAnC,OAAO;QACW,KAAK,GAClC;YAAqC,KAAK,GAA/B,MAAM,EAAE;YACkB,gBAAgB,GAA1C,MAAM,EAAE;YACkB,KAAK,GAA/B,MAAM,EAAE;YACkB,KAAK,GAA/B,MAAM,EAAE;SACrB;KAAA;;AAz0CD;;;;;;;;GAQG;AACH,mCAJW,eAAe,GACb,OAAO,CAAC,WAAS,MAAM,CAAC,CAiCpC"}
|