@cldmv/slothlet 2.3.2 → 2.4.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/dist/slothlet.mjs CHANGED
@@ -420,6 +420,21 @@ const slothletObject = {
420
420
 
421
421
 
422
422
  const categoryModules = {};
423
+
424
+
425
+ const defaultExportFiles = [];
426
+ for (const file of moduleFiles) {
427
+ const moduleExt = path.extname(file.name);
428
+ const moduleName = this._toApiKey(path.basename(file.name, moduleExt));
429
+ const tempMod = await this._loadSingleModule(path.join(categoryPath, file.name));
430
+
431
+ if (typeof tempMod === "function" && (tempMod.__slothletDefault === true || !tempMod.name || tempMod.name === "default")) {
432
+ defaultExportFiles.push({ file, moduleName, mod: tempMod });
433
+ }
434
+ }
435
+
436
+ const hasMultipleDefaultExports = defaultExportFiles.length > 1;
437
+
423
438
  for (const file of moduleFiles) {
424
439
  const moduleExt = path.extname(file.name);
425
440
  const moduleName = this._toApiKey(path.basename(file.name, moduleExt));
@@ -444,27 +459,42 @@ const slothletObject = {
444
459
  Object.assign(categoryModules, mod);
445
460
  }
446
461
  } else if (typeof mod === "function") {
447
- const fnName = mod.name && mod.name !== "default" ? mod.name : moduleName;
448
- try {
449
- Object.defineProperty(mod, "name", { value: fnName, configurable: true });
450
- } catch {
451
-
452
- }
453
-
454
-
455
462
 
456
463
  let apiKey;
457
- if (fnName && fnName.toLowerCase() === moduleName.toLowerCase() && fnName !== moduleName) {
464
+ if (hasMultipleDefaultExports && (mod.__slothletDefault === true || !mod.name || mod.name === "default")) {
458
465
 
459
- apiKey = fnName;
466
+ apiKey = moduleName;
467
+ try {
468
+ Object.defineProperty(mod, "name", { value: moduleName, configurable: true });
469
+ } catch {
470
+
471
+ }
460
472
  if (this.config.debug) {
461
- console.log(`[DEBUG] Using function name '${fnName}' instead of module name '${moduleName}'`);
473
+ console.log(`[DEBUG] Multi-default detected: using filename '${moduleName}' for default export`);
462
474
  }
463
475
  } else {
464
476
 
465
- apiKey = this._toApiKey(fnName);
466
- if (this.config.debug) {
467
- console.log(`[DEBUG] Using sanitized key '${apiKey}' for function '${fnName}' (module: '${moduleName}')`);
477
+ const fnName = mod.name && mod.name !== "default" ? mod.name : moduleName;
478
+ try {
479
+ Object.defineProperty(mod, "name", { value: fnName, configurable: true });
480
+ } catch {
481
+
482
+ }
483
+
484
+
485
+
486
+ if (fnName && fnName.toLowerCase() === moduleName.toLowerCase() && fnName !== moduleName) {
487
+
488
+ apiKey = fnName;
489
+ if (this.config.debug) {
490
+ console.log(`[DEBUG] Using function name '${fnName}' instead of module name '${moduleName}'`);
491
+ }
492
+ } else {
493
+
494
+ apiKey = this._toApiKey(fnName);
495
+ if (this.config.debug) {
496
+ console.log(`[DEBUG] Using sanitized key '${apiKey}' for function '${fnName}' (module: '${moduleName}')`);
497
+ }
468
498
  }
469
499
  }
470
500
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/slothlet",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "moduleVersions": {
5
5
  "lazy": "1.0.0",
6
6
  "eager": "1.0.0"
@@ -1 +1 @@
1
- {"version":3,"file":"slothlet.d.mts","sourceRoot":"","sources":["../../dist/slothlet.mjs"],"names":[],"mappings":"AA04CA;;;;;;;;;GASG;AACH,kDARW,WAAS,MAAM,UACf,WAAS,MAAM,QAwCzB;AAryCD;;;;;;;GAOG;AACH,mBAJU,MAAM,CAIO;AAEvB;;;;;GAKG;AACH,sBAJU,MAAM,CAIU;AAE1B;;;;;GAKG;AACH,wBAJU,MAAM,CAIY;;;;;;;;;UAwxCd,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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