@cldmv/slothlet 2.11.0 → 3.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.
- package/AGENT-USAGE.md +355 -325
- package/README.md +554 -238
- package/dist/lib/builders/api-assignment.mjs +605 -0
- package/dist/lib/builders/api_builder.mjs +1073 -0
- package/dist/lib/builders/builder.mjs +94 -0
- package/dist/lib/builders/modes-processor.mjs +1816 -0
- package/dist/lib/errors.mjs +227 -0
- package/dist/lib/factories/component-base.mjs +96 -0
- package/dist/lib/factories/context.mjs +38 -0
- package/dist/lib/handlers/api-cache-manager.mjs +216 -0
- package/dist/lib/handlers/api-manager.mjs +2364 -0
- package/dist/lib/handlers/context-async.mjs +184 -0
- package/dist/lib/handlers/context-live.mjs +184 -0
- package/dist/lib/handlers/hook-manager.mjs +789 -0
- package/dist/lib/handlers/lifecycle-token.mjs +44 -0
- package/dist/lib/handlers/lifecycle.mjs +131 -0
- package/dist/lib/handlers/materialize-manager.mjs +64 -0
- package/dist/lib/handlers/metadata.mjs +500 -0
- package/dist/lib/handlers/ownership.mjs +338 -0
- package/dist/lib/handlers/unified-wrapper.mjs +3031 -0
- package/dist/lib/helpers/class-instance-wrapper.mjs +125 -0
- package/dist/lib/helpers/config.mjs +343 -0
- package/dist/lib/helpers/eventemitter-context.mjs +365 -0
- package/dist/lib/helpers/hint-detector.mjs +63 -0
- package/dist/lib/helpers/modes-utils.mjs +53 -0
- package/dist/lib/helpers/resolve-from-caller.mjs +123 -117
- package/dist/lib/helpers/sanitize.mjs +247 -168
- package/dist/lib/helpers/utilities.mjs +46 -81
- package/dist/lib/i18n/languages/de-de.json +377 -0
- package/dist/lib/i18n/languages/en-gb.json +377 -0
- package/dist/lib/i18n/languages/en-us.json +377 -0
- package/dist/lib/i18n/languages/es-mx.json +377 -0
- package/dist/lib/i18n/languages/fr-fr.json +377 -0
- package/dist/lib/i18n/languages/hi-in.json +377 -0
- package/dist/lib/i18n/languages/ja-jp.json +377 -0
- package/dist/lib/i18n/languages/ko-kr.json +377 -0
- package/dist/lib/i18n/languages/pt-br.json +377 -0
- package/dist/lib/i18n/languages/ru-ru.json +377 -0
- package/dist/lib/i18n/languages/zh-cn.json +377 -0
- package/dist/lib/i18n/translations.mjs +140 -0
- package/dist/lib/modes/eager.mjs +75 -0
- package/dist/lib/modes/lazy.mjs +97 -0
- package/dist/lib/processors/flatten.mjs +453 -0
- package/dist/lib/processors/loader.mjs +355 -0
- package/dist/lib/processors/type-generator.mjs +291 -0
- package/dist/lib/processors/typescript.mjs +188 -0
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +80 -522
- package/dist/lib/runtime/runtime-livebindings.mjs +45 -390
- package/dist/lib/runtime/runtime.mjs +39 -159
- package/dist/slothlet.mjs +525 -744
- package/docs/API-RULES.md +338 -486
- package/index.cjs +4 -4
- package/index.mjs +82 -45
- package/package.json +143 -30
- package/types/dist/lib/builders/api-assignment.d.mts +97 -0
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -0
- package/types/dist/lib/builders/api_builder.d.mts +96 -0
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -0
- package/types/dist/lib/builders/builder.d.mts +60 -0
- package/types/dist/lib/builders/builder.d.mts.map +1 -0
- package/types/dist/lib/builders/modes-processor.d.mts +32 -0
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -0
- package/types/dist/lib/errors.d.mts +118 -0
- package/types/dist/lib/errors.d.mts.map +1 -0
- package/types/dist/lib/factories/component-base.d.mts +182 -0
- package/types/dist/lib/factories/component-base.d.mts.map +1 -0
- package/types/dist/lib/factories/context.d.mts +26 -0
- package/types/dist/lib/factories/context.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts +208 -0
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/api-manager.d.mts +392 -0
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-async.d.mts +66 -0
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -0
- package/types/dist/lib/handlers/context-live.d.mts +65 -0
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -0
- package/types/dist/lib/handlers/hook-manager.d.mts +199 -0
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts +49 -0
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -0
- package/types/dist/lib/handlers/lifecycle.d.mts +90 -0
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts +75 -0
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/metadata.d.mts +215 -0
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -0
- package/types/dist/lib/handlers/ownership.d.mts +170 -0
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts +250 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +54 -0
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -0
- package/types/dist/lib/helpers/config.d.mts +96 -0
- package/types/dist/lib/helpers/config.d.mts.map +1 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts +31 -0
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -0
- package/types/dist/lib/helpers/hint-detector.d.mts +20 -0
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -0
- package/types/dist/lib/helpers/modes-utils.d.mts +35 -0
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -0
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +29 -145
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +95 -94
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +53 -116
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +39 -0
- package/types/dist/lib/i18n/translations.d.mts.map +1 -0
- package/types/dist/lib/modes/eager.d.mts +36 -0
- package/types/dist/lib/modes/eager.d.mts.map +1 -0
- package/types/dist/lib/modes/lazy.d.mts +49 -0
- package/types/dist/lib/modes/lazy.d.mts.map +1 -0
- package/types/dist/lib/processors/flatten.d.mts +114 -0
- package/types/dist/lib/processors/flatten.d.mts.map +1 -0
- package/types/dist/lib/processors/loader.d.mts +47 -0
- package/types/dist/lib/processors/loader.d.mts.map +1 -0
- package/types/dist/lib/processors/type-generator.d.mts +19 -0
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -0
- package/types/dist/lib/processors/typescript.d.mts +55 -0
- package/types/dist/lib/processors/typescript.d.mts.map +1 -0
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +47 -42
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +34 -65
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +39 -9
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +184 -111
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +1 -3
- package/dist/lib/engine/README.md +0 -21
- package/dist/lib/engine/slothlet_child.mjs +0 -59
- package/dist/lib/engine/slothlet_engine.mjs +0 -372
- package/dist/lib/engine/slothlet_esm.mjs +0 -230
- package/dist/lib/engine/slothlet_helpers.mjs +0 -455
- package/dist/lib/engine/slothlet_worker.mjs +0 -149
- package/dist/lib/helpers/als-eventemitter.mjs +0 -256
- package/dist/lib/helpers/api_builder/add_api.mjs +0 -553
- package/dist/lib/helpers/api_builder/analysis.mjs +0 -532
- package/dist/lib/helpers/api_builder/construction.mjs +0 -495
- package/dist/lib/helpers/api_builder/decisions.mjs +0 -748
- package/dist/lib/helpers/api_builder/metadata.mjs +0 -248
- package/dist/lib/helpers/api_builder.mjs +0 -41
- package/dist/lib/helpers/auto-wrap.mjs +0 -62
- package/dist/lib/helpers/hooks.mjs +0 -389
- package/dist/lib/helpers/instance-manager.mjs +0 -111
- package/dist/lib/helpers/metadata-api.mjs +0 -201
- package/dist/lib/helpers/multidefault.mjs +0 -216
- package/dist/lib/modes/slothlet_eager.mjs +0 -154
- package/dist/lib/modes/slothlet_lazy.mjs +0 -594
- package/docs/API-RULES-CONDITIONS.md +0 -712
- package/types/dist/lib/engine/slothlet_child.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_child.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_engine.d.mts +0 -31
- package/types/dist/lib/engine/slothlet_engine.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_esm.d.mts +0 -19
- package/types/dist/lib/engine/slothlet_esm.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_helpers.d.mts +0 -25
- package/types/dist/lib/engine/slothlet_helpers.d.mts.map +0 -1
- package/types/dist/lib/engine/slothlet_worker.d.mts +0 -2
- package/types/dist/lib/engine/slothlet_worker.d.mts.map +0 -1
- package/types/dist/lib/helpers/als-eventemitter.d.mts +0 -56
- package/types/dist/lib/helpers/als-eventemitter.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/add_api.d.mts +0 -102
- package/types/dist/lib/helpers/api_builder/add_api.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/analysis.d.mts +0 -189
- package/types/dist/lib/helpers/api_builder/analysis.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/construction.d.mts +0 -107
- package/types/dist/lib/helpers/api_builder/construction.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/decisions.d.mts +0 -213
- package/types/dist/lib/helpers/api_builder/decisions.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder/metadata.d.mts +0 -99
- package/types/dist/lib/helpers/api_builder/metadata.d.mts.map +0 -1
- package/types/dist/lib/helpers/api_builder.d.mts +0 -6
- package/types/dist/lib/helpers/api_builder.d.mts.map +0 -1
- package/types/dist/lib/helpers/auto-wrap.d.mts +0 -49
- package/types/dist/lib/helpers/auto-wrap.d.mts.map +0 -1
- package/types/dist/lib/helpers/hooks.d.mts +0 -342
- package/types/dist/lib/helpers/hooks.d.mts.map +0 -1
- package/types/dist/lib/helpers/instance-manager.d.mts +0 -41
- package/types/dist/lib/helpers/instance-manager.d.mts.map +0 -1
- package/types/dist/lib/helpers/metadata-api.d.mts +0 -132
- package/types/dist/lib/helpers/metadata-api.d.mts.map +0 -1
- package/types/dist/lib/helpers/multidefault.d.mts +0 -90
- package/types/dist/lib/helpers/multidefault.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_eager.d.mts +0 -65
- package/types/dist/lib/modes/slothlet_eager.d.mts.map +0 -1
- package/types/dist/lib/modes/slothlet_lazy.d.mts +0 -31
- package/types/dist/lib/modes/slothlet_lazy.d.mts.map +0 -1
- package/types/index.d.mts.map +0 -1
|
@@ -1,748 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2026 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 "node:fs/promises";
|
|
22
|
-
import path from "node:path";
|
|
23
|
-
import { multidefault_analyzeModules } from "@cldmv/slothlet/helpers/multidefault";
|
|
24
|
-
import { analyzeModule, processModuleFromAnalysis } from "@cldmv/slothlet/helpers/api_builder/analysis";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export function getFlatteningDecision(options) {
|
|
32
|
-
const {
|
|
33
|
-
mod,
|
|
34
|
-
fileName,
|
|
35
|
-
apiPathKey,
|
|
36
|
-
hasMultipleDefaultExports,
|
|
37
|
-
isSelfReferential,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
moduleHasDefault = !!mod.default,
|
|
41
|
-
categoryName,
|
|
42
|
-
|
|
43
|
-
totalModules = 1
|
|
44
|
-
} = options;
|
|
45
|
-
|
|
46
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (isSelfReferential) {
|
|
50
|
-
return {
|
|
51
|
-
shouldFlatten: false,
|
|
52
|
-
flattenToRoot: false,
|
|
53
|
-
flattenToCategory: false,
|
|
54
|
-
preserveAsNamespace: true,
|
|
55
|
-
useAutoFlattening: false,
|
|
56
|
-
reason: "self-referential export"
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (hasMultipleDefaultExports) {
|
|
62
|
-
if (moduleHasDefault) {
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
shouldFlatten: false,
|
|
66
|
-
flattenToRoot: false,
|
|
67
|
-
flattenToCategory: false,
|
|
68
|
-
preserveAsNamespace: true,
|
|
69
|
-
useAutoFlattening: false,
|
|
70
|
-
reason: "multi-default context with default export"
|
|
71
|
-
};
|
|
72
|
-
} else {
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
shouldFlatten: true,
|
|
76
|
-
flattenToRoot: true,
|
|
77
|
-
flattenToCategory: true,
|
|
78
|
-
preserveAsNamespace: false,
|
|
79
|
-
useAutoFlattening: false,
|
|
80
|
-
reason: "multi-default context without default export"
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (moduleKeys.length === 1 && moduleKeys[0] === apiPathKey) {
|
|
87
|
-
return {
|
|
88
|
-
shouldFlatten: true,
|
|
89
|
-
flattenToRoot: false,
|
|
90
|
-
flattenToCategory: false,
|
|
91
|
-
preserveAsNamespace: false,
|
|
92
|
-
useAutoFlattening: true,
|
|
93
|
-
reason: "auto-flatten single named export matching filename"
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (categoryName && fileName === categoryName && !moduleHasDefault && moduleKeys.length > 0) {
|
|
99
|
-
return {
|
|
100
|
-
shouldFlatten: true,
|
|
101
|
-
flattenToRoot: false,
|
|
102
|
-
flattenToCategory: true,
|
|
103
|
-
preserveAsNamespace: false,
|
|
104
|
-
useAutoFlattening: false,
|
|
105
|
-
reason: "filename matches container, flatten to category"
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
shouldFlatten: false,
|
|
126
|
-
flattenToRoot: false,
|
|
127
|
-
flattenToCategory: false,
|
|
128
|
-
preserveAsNamespace: true,
|
|
129
|
-
useAutoFlattening: false,
|
|
130
|
-
reason: "traditional namespace preservation"
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
export function applyFunctionNamePreference(options) {
|
|
136
|
-
const { mod, fileName, apiPathKey, categoryModules, toapiPathKey, debug = false } = options;
|
|
137
|
-
|
|
138
|
-
let hasPreferredName = false;
|
|
139
|
-
let preferredKey = apiPathKey;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
for (const [, exportValue] of Object.entries(mod)) {
|
|
143
|
-
if (typeof exportValue === "function" && exportValue.name) {
|
|
144
|
-
const functionNameLower = exportValue.name.toLowerCase();
|
|
145
|
-
const filenameLower = fileName.toLowerCase();
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (functionNameLower === filenameLower && exportValue.name !== apiPathKey) {
|
|
149
|
-
|
|
150
|
-
preferredKey = exportValue.name;
|
|
151
|
-
hasPreferredName = true;
|
|
152
|
-
|
|
153
|
-
if (debug) {
|
|
154
|
-
console.log(`[DEBUG] Using function name preference: ${exportValue.name} instead of ${apiPathKey} for ${fileName}`);
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const sanitizedFunctionName = toapiPathKey(exportValue.name);
|
|
161
|
-
if (sanitizedFunctionName.toLowerCase() === apiPathKey.toLowerCase() && exportValue.name !== apiPathKey) {
|
|
162
|
-
preferredKey = exportValue.name;
|
|
163
|
-
hasPreferredName = true;
|
|
164
|
-
|
|
165
|
-
if (debug) {
|
|
166
|
-
console.log(`[DEBUG] Using function name preference: ${exportValue.name} instead of ${apiPathKey} for ${fileName}`);
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (hasPreferredName) {
|
|
174
|
-
|
|
175
|
-
categoryModules[preferredKey] = mod;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return { hasPreferredName, preferredKey };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
export function processModuleForAPI(options) {
|
|
187
|
-
const {
|
|
188
|
-
mod,
|
|
189
|
-
fileName,
|
|
190
|
-
apiPathKey,
|
|
191
|
-
hasMultipleDefaultExports,
|
|
192
|
-
isSelfReferential,
|
|
193
|
-
api,
|
|
194
|
-
getRootDefault,
|
|
195
|
-
setRootDefault,
|
|
196
|
-
context = {},
|
|
197
|
-
originalAnalysis = null
|
|
198
|
-
} = options;
|
|
199
|
-
|
|
200
|
-
const { debug = false, mode = "unknown", categoryName, totalModules = 1 } = context;
|
|
201
|
-
|
|
202
|
-
let processed = false;
|
|
203
|
-
let rootDefaultSet = false;
|
|
204
|
-
let flattened = false;
|
|
205
|
-
let namespaced = false;
|
|
206
|
-
const apiAssignments = {};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const hasDefaultFunction = (mod && typeof mod.default === "function") || (mod && typeof mod === "function" && !mod.default);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const defaultFunction = mod?.default || (typeof mod === "function" ? mod : null);
|
|
215
|
-
|
|
216
|
-
if (hasDefaultFunction) {
|
|
217
|
-
processed = true;
|
|
218
|
-
|
|
219
|
-
if (hasMultipleDefaultExports && !isSelfReferential) {
|
|
220
|
-
|
|
221
|
-
apiAssignments[apiPathKey] = mod;
|
|
222
|
-
namespaced = true;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (debug) {
|
|
228
|
-
console.log(
|
|
229
|
-
`[DEBUG] ${mode}: Multi-default function - using filename '${apiPathKey}' for default export, mod type: ${typeof mod}, function name: ${defaultFunction?.name}`
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
} else if (isSelfReferential) {
|
|
233
|
-
|
|
234
|
-
apiAssignments[apiPathKey] = mod;
|
|
235
|
-
namespaced = true;
|
|
236
|
-
|
|
237
|
-
if (debug) {
|
|
238
|
-
console.log(`[DEBUG] ${mode}: Self-referential function - preserving ${fileName} as namespace`);
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
|
|
242
|
-
if (debug) {
|
|
243
|
-
console.log(
|
|
244
|
-
`[DEBUG] ${mode}: Processing traditional default function: hasMultipleDefaultExports=${hasMultipleDefaultExports}, rootDefaultFunction=${!!(getRootDefault && getRootDefault())}`
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (mode === "root" && getRootDefault && setRootDefault && !hasMultipleDefaultExports && !getRootDefault()) {
|
|
250
|
-
setRootDefault(defaultFunction);
|
|
251
|
-
rootDefaultSet = true;
|
|
252
|
-
|
|
253
|
-
if (debug) {
|
|
254
|
-
console.log(`[DEBUG] ${mode}: Set rootDefaultFunction to:`, defaultFunction.name);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
} else {
|
|
260
|
-
|
|
261
|
-
apiAssignments[apiPathKey] = mod;
|
|
262
|
-
namespaced = true;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
} else {
|
|
269
|
-
|
|
270
|
-
processed = true;
|
|
271
|
-
|
|
272
|
-
if (debug) {
|
|
273
|
-
console.log(`[DEBUG] ${mode}: Processing non-function or named-only exports for ${fileName}`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const decision = getFlatteningDecision({
|
|
278
|
-
mod,
|
|
279
|
-
fileName,
|
|
280
|
-
apiPathKey,
|
|
281
|
-
hasMultipleDefaultExports,
|
|
282
|
-
isSelfReferential,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
moduleHasDefault: originalAnalysis ? originalAnalysis.hasDefault : !!mod.default,
|
|
287
|
-
categoryName,
|
|
288
|
-
totalModules,
|
|
289
|
-
debug
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
if (debug) {
|
|
293
|
-
console.log(`[DEBUG] ${mode}: Flattening decision for ${fileName}: ${decision.reason}`);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (decision.useAutoFlattening) {
|
|
297
|
-
|
|
298
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
299
|
-
apiAssignments[apiPathKey] = mod[moduleKeys[0]];
|
|
300
|
-
flattened = true;
|
|
301
|
-
} else if (decision.flattenToRoot || decision.flattenToCategory) {
|
|
302
|
-
|
|
303
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
304
|
-
for (const key of moduleKeys) {
|
|
305
|
-
apiAssignments[key] = mod[key];
|
|
306
|
-
if (debug) {
|
|
307
|
-
console.log(`[DEBUG] ${mode}: Flattened ${fileName}.${key} to ${decision.flattenToRoot ? "root" : "category"}.${key}`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
flattened = true;
|
|
311
|
-
} else if (isSelfReferential) {
|
|
312
|
-
|
|
313
|
-
apiAssignments[apiPathKey] = mod[apiPathKey] || mod;
|
|
314
|
-
namespaced = true;
|
|
315
|
-
} else {
|
|
316
|
-
|
|
317
|
-
apiAssignments[apiPathKey] = mod;
|
|
318
|
-
namespaced = true;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
for (const [key, value] of Object.entries(apiAssignments)) {
|
|
324
|
-
if (debug) {
|
|
325
|
-
console.log(`[DEBUG] ${mode}: About to assign key '${key}' - current api[${key}]:`, api[key] ? Object.keys(api[key]) : "undefined");
|
|
326
|
-
console.log(`[DEBUG] ${mode}: New value for key '${key}':`, typeof value === "object" && value ? Object.keys(value) : typeof value);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (api[key] && typeof api[key] === "object" && typeof value === "object" && !Array.isArray(api[key]) && !Array.isArray(value)) {
|
|
331
|
-
if (debug) {
|
|
332
|
-
console.log(`[DEBUG] ${mode}: Merging objects for key '${key}' - existing:`, Object.keys(api[key]), "new:", Object.keys(value));
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
Object.assign(api[key], value);
|
|
336
|
-
} else {
|
|
337
|
-
api[key] = value;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return {
|
|
342
|
-
processed,
|
|
343
|
-
rootDefaultSet,
|
|
344
|
-
flattened,
|
|
345
|
-
namespaced,
|
|
346
|
-
apiAssignments
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
export async function buildCategoryDecisions(categoryPath, options = {}) {
|
|
356
|
-
const { currentDepth = 0, maxDepth = Infinity, mode = "eager", subdirHandler, existingApi: _ } = options;
|
|
357
|
-
const { instance } = options;
|
|
358
|
-
|
|
359
|
-
if (!instance || typeof instance._toapiPathKey !== "function") {
|
|
360
|
-
throw new Error("buildCategoryDecisions requires instance parameter with _toapiPathKey method");
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const debug = instance.config?.debug || false;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (debug) {
|
|
367
|
-
console.log(`[DEBUG] buildCategoryDecisions called with path: ${categoryPath}, mode: ${mode}`);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const files = await fs.readdir(categoryPath, { withFileTypes: true });
|
|
371
|
-
const moduleFiles = files.filter((f) => instance._shouldIncludeFile(f));
|
|
372
|
-
const categoryName = instance._toapiPathKey(path.basename(categoryPath));
|
|
373
|
-
const subDirs = files.filter((e) => e.isDirectory() && !e.name.startsWith("."));
|
|
374
|
-
|
|
375
|
-
const decisions = {
|
|
376
|
-
type: null,
|
|
377
|
-
categoryName,
|
|
378
|
-
moduleFiles,
|
|
379
|
-
subDirs,
|
|
380
|
-
currentDepth,
|
|
381
|
-
maxDepth,
|
|
382
|
-
mode,
|
|
383
|
-
subdirHandler,
|
|
384
|
-
|
|
385
|
-
singleFile: null,
|
|
386
|
-
shouldFlatten: false,
|
|
387
|
-
flattenType: null,
|
|
388
|
-
preferredName: null,
|
|
389
|
-
|
|
390
|
-
multifileAnalysis: null,
|
|
391
|
-
processedModules: [],
|
|
392
|
-
categoryModules: {},
|
|
393
|
-
|
|
394
|
-
subdirectoryDecisions: []
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (moduleFiles.length === 1 && subDirs.length === 0) {
|
|
399
|
-
decisions.type = "single-file";
|
|
400
|
-
const moduleFile = moduleFiles[0];
|
|
401
|
-
const moduleExt = path.extname(moduleFile.name);
|
|
402
|
-
const moduleName = instance._toapiPathKey(path.basename(moduleFile.name, moduleExt));
|
|
403
|
-
|
|
404
|
-
decisions.singleFile = {
|
|
405
|
-
file: moduleFile,
|
|
406
|
-
moduleName,
|
|
407
|
-
moduleExt
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const analysis = await analyzeModule(path.join(categoryPath, moduleFile.name), {
|
|
412
|
-
debug,
|
|
413
|
-
instance
|
|
414
|
-
});
|
|
415
|
-
const mod = processModuleFromAnalysis(analysis, {
|
|
416
|
-
debug,
|
|
417
|
-
instance
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
decisions.singleFile.mod = mod;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const functionNameMatchesFolder = typeof mod === "function" && mod.name && mod.name.toLowerCase() === categoryName.toLowerCase();
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const functionNameMatchesFilename =
|
|
427
|
-
typeof mod === "function" &&
|
|
428
|
-
mod.name &&
|
|
429
|
-
instance._toapiPathKey(mod.name).toLowerCase() === instance._toapiPathKey(moduleName).toLowerCase() &&
|
|
430
|
-
mod.name !== instance._toapiPathKey(moduleName);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (moduleName === categoryName && typeof mod === "function" && currentDepth > 0) {
|
|
435
|
-
decisions.shouldFlatten = true;
|
|
436
|
-
decisions.flattenType = "function-folder-match";
|
|
437
|
-
decisions.preferredName = categoryName;
|
|
438
|
-
return decisions;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (analysis.hasDefault && analysis.defaultExportType === "object" && moduleName === categoryName && currentDepth > 0) {
|
|
444
|
-
if (debug) {
|
|
445
|
-
console.log(`[DEBUG] Default export flattening: ${categoryName}/${moduleFile.name} -> flatten default object contents`);
|
|
446
|
-
}
|
|
447
|
-
decisions.shouldFlatten = true;
|
|
448
|
-
decisions.flattenType = "default-export-flatten";
|
|
449
|
-
return decisions;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (moduleName === categoryName && mod && typeof mod === "object" && !Array.isArray(mod) && currentDepth > 0) {
|
|
455
|
-
|
|
456
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
457
|
-
if (debug) {
|
|
458
|
-
console.log(
|
|
459
|
-
`[DEBUG] Auto-flatten check: moduleName="${moduleName}" categoryName="${categoryName}" moduleKeys=[${moduleKeys}] match=${moduleKeys.length === 1 && moduleKeys[0] === moduleName}`
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
if (moduleKeys.length === 1 && moduleKeys[0] === moduleName) {
|
|
463
|
-
if (debug) {
|
|
464
|
-
console.log(`[DEBUG] Single-file auto-flattening: ${categoryName}/${moduleFile.name} -> flatten object contents`);
|
|
465
|
-
}
|
|
466
|
-
decisions.shouldFlatten = true;
|
|
467
|
-
decisions.flattenType = "object-auto-flatten";
|
|
468
|
-
decisions.preferredName = moduleKeys[0];
|
|
469
|
-
return decisions;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const fileBaseName = moduleFile.name.replace(/\.(mjs|cjs|js)$/, "");
|
|
475
|
-
if (fileBaseName === categoryName && moduleKeys.length > 0) {
|
|
476
|
-
if (debug) {
|
|
477
|
-
console.log(
|
|
478
|
-
`[DEBUG] Single-file filename-folder exact match flattening: ${categoryName}/${moduleFile.name} -> avoid double nesting`
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
decisions.shouldFlatten = true;
|
|
482
|
-
decisions.flattenType = "filename-folder-match-flatten";
|
|
483
|
-
return decisions;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if (moduleFiles.length === 1 && currentDepth > 0 && mod && typeof mod === "object" && !Array.isArray(mod)) {
|
|
492
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
493
|
-
const fileName = moduleFile.name.replace(/\.(mjs|cjs|js)$/, "");
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const isGenericFilename = ["singlefile", "index", "main", "default"].includes(fileName.toLowerCase());
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
if (moduleKeys.length === 1 && isGenericFilename) {
|
|
501
|
-
if (debug) {
|
|
502
|
-
console.log(`[DEBUG] Single-file parent-level auto-flattening: ${categoryName}/${moduleFile.name} -> flatten to parent level`);
|
|
503
|
-
}
|
|
504
|
-
decisions.shouldFlatten = true;
|
|
505
|
-
decisions.flattenType = "parent-level-flatten";
|
|
506
|
-
decisions.preferredName = moduleKeys[0];
|
|
507
|
-
return decisions;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (functionNameMatchesFolder && currentDepth > 0) {
|
|
514
|
-
decisions.shouldFlatten = true;
|
|
515
|
-
decisions.flattenType = "function-folder-match";
|
|
516
|
-
decisions.preferredName = mod.name;
|
|
517
|
-
return decisions;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (functionNameMatchesFilename) {
|
|
522
|
-
decisions.shouldFlatten = false;
|
|
523
|
-
decisions.preferredName = mod.name;
|
|
524
|
-
return decisions;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (
|
|
531
|
-
typeof mod === "function" &&
|
|
532
|
-
(!mod.name || mod.name === "default" || mod.__slothletDefault === true) &&
|
|
533
|
-
currentDepth > 0
|
|
534
|
-
) {
|
|
535
|
-
decisions.shouldFlatten = true;
|
|
536
|
-
decisions.flattenType = "default-function";
|
|
537
|
-
decisions.preferredName = categoryName;
|
|
538
|
-
return decisions;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
543
|
-
if (moduleKeys.length === 1 && moduleKeys[0] === moduleName) {
|
|
544
|
-
|
|
545
|
-
decisions.shouldFlatten = true;
|
|
546
|
-
decisions.flattenType = "object-auto-flatten";
|
|
547
|
-
decisions.preferredName = moduleName;
|
|
548
|
-
return decisions;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
decisions.shouldFlatten = false;
|
|
553
|
-
decisions.preferredName = moduleName;
|
|
554
|
-
return decisions;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
decisions.type = "multi-file";
|
|
559
|
-
if (debug) {
|
|
560
|
-
console.log(`[DEBUG] buildCategoryDecisions: Processing multi-file case for ${categoryPath}`);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const analysis = await multidefault_analyzeModules(moduleFiles, categoryPath, { debug, instance });
|
|
565
|
-
|
|
566
|
-
decisions.multifileAnalysis = analysis;
|
|
567
|
-
|
|
568
|
-
const { totalDefaultExports, hasMultipleDefaultExports, selfReferentialFiles, defaultExportFiles: analysisDefaults } = analysis;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
const defaultExportFiles = [];
|
|
572
|
-
for (const { fileName } of analysisDefaults) {
|
|
573
|
-
const file = moduleFiles.find((f) => path.basename(f.name, path.extname(f.name)) === fileName);
|
|
574
|
-
if (file) {
|
|
575
|
-
const analysis = await analyzeModule(path.join(categoryPath, file.name), {
|
|
576
|
-
debug,
|
|
577
|
-
instance
|
|
578
|
-
});
|
|
579
|
-
const processedMod = processModuleFromAnalysis(analysis, {
|
|
580
|
-
debug,
|
|
581
|
-
instance
|
|
582
|
-
});
|
|
583
|
-
defaultExportFiles.push({ file, moduleName: instance._toapiPathKey(fileName), mod: processedMod, analysis });
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
if (debug) {
|
|
588
|
-
console.log(`[DEBUG] buildCategoryDecisions: Using shared multidefault utility results`);
|
|
589
|
-
console.log(`[DEBUG] - totalDefaultExports: ${totalDefaultExports}`);
|
|
590
|
-
console.log(`[DEBUG] - hasMultipleDefaultExports: ${hasMultipleDefaultExports}`);
|
|
591
|
-
console.log(`[DEBUG] - selfReferentialFiles: ${Array.from(selfReferentialFiles)}`);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
for (const file of moduleFiles) {
|
|
596
|
-
const moduleExt = path.extname(file.name);
|
|
597
|
-
const moduleName = instance._toapiPathKey(path.basename(file.name, moduleExt));
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
let mod = null;
|
|
601
|
-
let analysis = null;
|
|
602
|
-
const existingDefault = defaultExportFiles.find((def) => def.moduleName === moduleName);
|
|
603
|
-
if (existingDefault) {
|
|
604
|
-
mod = existingDefault.mod;
|
|
605
|
-
|
|
606
|
-
analysis = existingDefault.analysis;
|
|
607
|
-
} else {
|
|
608
|
-
|
|
609
|
-
analysis = await analyzeModule(path.join(categoryPath, file.name), {
|
|
610
|
-
debug,
|
|
611
|
-
instance
|
|
612
|
-
});
|
|
613
|
-
mod = processModuleFromAnalysis(analysis, {
|
|
614
|
-
debug,
|
|
615
|
-
instance
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
const moduleDecision = {
|
|
620
|
-
file,
|
|
621
|
-
moduleName,
|
|
622
|
-
mod,
|
|
623
|
-
type: null,
|
|
624
|
-
apiPathKey: null,
|
|
625
|
-
shouldFlatten: false,
|
|
626
|
-
flattenType: null,
|
|
627
|
-
specialHandling: null
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
if (moduleName === categoryName && mod && typeof mod === "object") {
|
|
631
|
-
moduleDecision.type = "category-match-object";
|
|
632
|
-
moduleDecision.specialHandling = "category-merge";
|
|
633
|
-
} else if (typeof mod === "function") {
|
|
634
|
-
moduleDecision.type = "function";
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
const isSelfReferential = selfReferentialFiles.has(moduleName);
|
|
638
|
-
|
|
639
|
-
if (hasMultipleDefaultExports && mod.__slothletDefault === true && !isSelfReferential) {
|
|
640
|
-
|
|
641
|
-
moduleDecision.apiPathKey = moduleName;
|
|
642
|
-
moduleDecision.specialHandling = "multi-default-filename";
|
|
643
|
-
if (debug) {
|
|
644
|
-
console.log(
|
|
645
|
-
`[DEBUG] Multi-default function case: ${moduleName} => ${moduleDecision.apiPathKey} (hasMultiple=${hasMultipleDefaultExports}, __slothletDefault=${mod.__slothletDefault}, isSelfRef=${isSelfReferential})`
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
} else if (selfReferentialFiles.has(moduleName)) {
|
|
649
|
-
|
|
650
|
-
moduleDecision.type = "self-referential";
|
|
651
|
-
moduleDecision.specialHandling = "self-referential-namespace";
|
|
652
|
-
} else {
|
|
653
|
-
|
|
654
|
-
const fnName = mod.name && mod.name !== "default" ? mod.name : moduleName;
|
|
655
|
-
if (debug) {
|
|
656
|
-
console.log(
|
|
657
|
-
`[DEBUG] Standard function case: ${moduleName}, fnName=${fnName}, mod.__slothletDefault=${mod.__slothletDefault}, hasMultiple=${hasMultipleDefaultExports}`
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (fnName && fnName.toLowerCase() === moduleName.toLowerCase() && fnName !== moduleName) {
|
|
664
|
-
|
|
665
|
-
moduleDecision.apiPathKey = fnName;
|
|
666
|
-
moduleDecision.specialHandling = "prefer-function-name";
|
|
667
|
-
} else {
|
|
668
|
-
|
|
669
|
-
moduleDecision.apiPathKey = instance._toapiPathKey(fnName);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
} else {
|
|
673
|
-
moduleDecision.type = "object";
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
let hasPreferredName = false;
|
|
677
|
-
const modWithPreferredNames = {};
|
|
678
|
-
|
|
679
|
-
for (const [exportName, exportValue] of Object.entries(mod)) {
|
|
680
|
-
if (
|
|
681
|
-
typeof exportValue === "function" &&
|
|
682
|
-
exportValue.name &&
|
|
683
|
-
instance._toapiPathKey(exportValue.name).toLowerCase() === instance._toapiPathKey(moduleName).toLowerCase() &&
|
|
684
|
-
exportValue.name !== instance._toapiPathKey(moduleName)
|
|
685
|
-
) {
|
|
686
|
-
|
|
687
|
-
modWithPreferredNames[exportValue.name] = exportValue;
|
|
688
|
-
hasPreferredName = true;
|
|
689
|
-
} else {
|
|
690
|
-
modWithPreferredNames[instance._toapiPathKey(exportName)] = exportValue;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
if (hasPreferredName) {
|
|
695
|
-
moduleDecision.specialHandling = "preferred-export-names";
|
|
696
|
-
moduleDecision.processedExports = modWithPreferredNames;
|
|
697
|
-
} else if (selfReferentialFiles.has(moduleName)) {
|
|
698
|
-
|
|
699
|
-
moduleDecision.type = "self-referential";
|
|
700
|
-
moduleDecision.specialHandling = "self-referential-namespace";
|
|
701
|
-
} else {
|
|
702
|
-
|
|
703
|
-
const moduleKeys = Object.keys(mod).filter((k) => k !== "default");
|
|
704
|
-
const apiPathKey = instance._toapiPathKey(moduleName);
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
if (!hasMultipleDefaultExports && analysis.hasDefault && analysis.defaultExportType === "object") {
|
|
709
|
-
moduleDecision.shouldFlatten = true;
|
|
710
|
-
moduleDecision.flattenType = "single-default-object";
|
|
711
|
-
moduleDecision.apiPathKey = apiPathKey;
|
|
712
|
-
} else if (hasMultipleDefaultExports && !analysis.hasDefault && moduleKeys.length > 0) {
|
|
713
|
-
|
|
714
|
-
moduleDecision.shouldFlatten = true;
|
|
715
|
-
moduleDecision.flattenType = "multi-default-no-default";
|
|
716
|
-
} else if (moduleKeys.length === 1 && moduleKeys[0] === apiPathKey) {
|
|
717
|
-
|
|
718
|
-
moduleDecision.shouldFlatten = true;
|
|
719
|
-
moduleDecision.flattenType = "single-named-export-match";
|
|
720
|
-
moduleDecision.apiPathKey = apiPathKey;
|
|
721
|
-
} else if (!analysis.hasDefault && moduleKeys.length > 0 && moduleName === categoryName) {
|
|
722
|
-
|
|
723
|
-
moduleDecision.shouldFlatten = true;
|
|
724
|
-
moduleDecision.flattenType = "category-name-match-flatten";
|
|
725
|
-
} else {
|
|
726
|
-
|
|
727
|
-
moduleDecision.apiPathKey = apiPathKey;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
decisions.processedModules.push(moduleDecision);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
for (const subDir of subDirs) {
|
|
737
|
-
const subDirPath = path.join(categoryPath, subDir.name);
|
|
738
|
-
const subDirDecision = {
|
|
739
|
-
name: subDir.name,
|
|
740
|
-
path: subDirPath,
|
|
741
|
-
apiPathKey: instance._toapiPathKey(subDir.name),
|
|
742
|
-
shouldRecurse: currentDepth < maxDepth
|
|
743
|
-
};
|
|
744
|
-
decisions.subdirectoryDecisions.push(subDirDecision);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
return decisions;
|
|
748
|
-
}
|