@bleedingdev/modern-js-code-tools 3.9.3-ultramodern.1 → 3.9.3-ultramodern.11
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/cjs/microvertical-api-baseline.cjs +8 -2
- package/dist/cjs/microvertical-api-boundary.cjs +397 -32
- package/dist/cjs/module-graph.cjs +44 -2
- package/dist/cjs/strict-effect-runtime.cjs +59 -6
- package/dist/esm/microvertical-api-baseline.js +1 -1
- package/dist/esm/microvertical-api-boundary.js +399 -34
- package/dist/esm/module-graph.js +44 -2
- package/dist/esm/strict-effect-runtime.js +59 -6
- package/dist/esm-node/microvertical-api-baseline.js +1 -1
- package/dist/esm-node/microvertical-api-boundary.js +399 -34
- package/dist/esm-node/module-graph.js +44 -2
- package/dist/esm-node/strict-effect-runtime.js +59 -6
- package/dist/types/microvertical-api-baseline.d.ts +4 -0
- package/dist/types/microvertical-api-boundary.d.ts +3 -2
- package/dist/types/module-graph.d.ts +8 -0
- package/package.json +6 -6
package/dist/esm/module-graph.js
CHANGED
|
@@ -186,6 +186,7 @@ function parseModule(filePath, workspace) {
|
|
|
186
186
|
const file = parseSource(node_fs.readFileSync(filePath, 'utf8'), filePath);
|
|
187
187
|
let scope;
|
|
188
188
|
const references = new Map();
|
|
189
|
+
const declarations = new Map();
|
|
189
190
|
const returns = new Map();
|
|
190
191
|
const bareReturns = new Set();
|
|
191
192
|
const functionScopes = new Map();
|
|
@@ -296,6 +297,11 @@ function parseModule(filePath, workspace) {
|
|
|
296
297
|
ReferencedIdentifier (p) {
|
|
297
298
|
references.set(p.node, p.scope.getBinding(p.node.name));
|
|
298
299
|
},
|
|
300
|
+
BindingIdentifier (p) {
|
|
301
|
+
if (!__rspack_external__babel_types_6e8337dd.isIdentifier(p.node)) return;
|
|
302
|
+
const binding = p.scope.getBinding(p.node.name);
|
|
303
|
+
if (binding?.identifier === p.node) declarations.set(p.node, binding);
|
|
304
|
+
},
|
|
299
305
|
Function (p) {
|
|
300
306
|
functionScopes.set(p.node, p.scope);
|
|
301
307
|
},
|
|
@@ -361,6 +367,7 @@ function parseModule(filePath, workspace) {
|
|
|
361
367
|
scope,
|
|
362
368
|
workspace,
|
|
363
369
|
references,
|
|
370
|
+
declarations,
|
|
364
371
|
returns,
|
|
365
372
|
bareReturns,
|
|
366
373
|
functionScopes,
|
|
@@ -1096,7 +1103,7 @@ function createModuleGraph() {
|
|
|
1096
1103
|
}
|
|
1097
1104
|
};
|
|
1098
1105
|
const mutated = (module, binding)=>binding.constantViolations.length > 0 || factsOf(module).merged.has(binding.identifier.name) || (aliasesOf(binding, factsOf(module).writes)?.some((alias)=>factsOf(module).writes.has(alias.binding)) ?? true);
|
|
1099
|
-
const resolveBinding = (module, name, scope, chain, seen)=>{
|
|
1106
|
+
const resolveBinding = (module, name, scope, chain, seen, lexical)=>{
|
|
1100
1107
|
const key = `${scope}:${module.path}#${name}`;
|
|
1101
1108
|
if (seen.has(key) || seen.size >= MAX_LOOKUPS) return;
|
|
1102
1109
|
seen.add(key);
|
|
@@ -1119,7 +1126,7 @@ function createModuleGraph() {
|
|
|
1119
1126
|
return void 0 === next ? void 0 : resolveBinding(next, imported, 'export', hops, seen);
|
|
1120
1127
|
};
|
|
1121
1128
|
if ('local' === scope) {
|
|
1122
|
-
const binding = factsOf(module).scope.getBinding(name);
|
|
1129
|
+
const binding = lexical ?? factsOf(module).scope.getBinding(name);
|
|
1123
1130
|
if (!binding || mutated(module, binding)) return;
|
|
1124
1131
|
if ('module' === binding.kind) {
|
|
1125
1132
|
const imported = importOf(binding);
|
|
@@ -1148,6 +1155,39 @@ function createModuleGraph() {
|
|
|
1148
1155
|
if (void 0 !== resolved) return resolved;
|
|
1149
1156
|
}
|
|
1150
1157
|
};
|
|
1158
|
+
const resolveReference = (module, reference)=>{
|
|
1159
|
+
const node = unwrapExpression(reference, true);
|
|
1160
|
+
const moduleFacts = factsOf(module);
|
|
1161
|
+
const bindingAt = (identifier)=>moduleFacts.references.get(identifier) ?? moduleFacts.declarations.get(identifier);
|
|
1162
|
+
if (__rspack_external__babel_types_6e8337dd.isIdentifier(node)) {
|
|
1163
|
+
const binding = bindingAt(node);
|
|
1164
|
+
return binding ? resolveBinding(module, node.name, 'local', [], new Set(), binding) : void 0;
|
|
1165
|
+
}
|
|
1166
|
+
if (!__rspack_external__babel_types_6e8337dd.isMemberExpression(node) || node.computed || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.object) || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.property)) return;
|
|
1167
|
+
const binding = bindingAt(node.object);
|
|
1168
|
+
if (!binding || 'module' !== binding.kind || mutated(module, binding)) return;
|
|
1169
|
+
const imported = importOf(binding);
|
|
1170
|
+
if (imported?.name !== '*') return;
|
|
1171
|
+
const target = follow(module, imported.specifier);
|
|
1172
|
+
const chain = [
|
|
1173
|
+
{
|
|
1174
|
+
path: module.path,
|
|
1175
|
+
name: node.object.name
|
|
1176
|
+
}
|
|
1177
|
+
];
|
|
1178
|
+
if ('external' === target) return {
|
|
1179
|
+
kind: 'external',
|
|
1180
|
+
specifier: imported.specifier,
|
|
1181
|
+
name: node.property.name,
|
|
1182
|
+
chain
|
|
1183
|
+
};
|
|
1184
|
+
return void 0 === target ? void 0 : resolveBinding(target, node.property.name, 'export', chain, new Set());
|
|
1185
|
+
};
|
|
1186
|
+
const isUnboundReference = (module, reference)=>{
|
|
1187
|
+
const node = unwrapExpression(reference, true);
|
|
1188
|
+
const { references } = factsOf(module);
|
|
1189
|
+
return __rspack_external__babel_types_6e8337dd.isIdentifier(node) && references.has(node) && void 0 === references.get(node);
|
|
1190
|
+
};
|
|
1151
1191
|
const evaluation = (walking)=>{
|
|
1152
1192
|
const active = new Set();
|
|
1153
1193
|
let frames = 0;
|
|
@@ -1755,6 +1795,8 @@ function createModuleGraph() {
|
|
|
1755
1795
|
return {
|
|
1756
1796
|
module: (filePath)=>load(filePath),
|
|
1757
1797
|
resolve: (module, name, scope)=>resolveBinding(module, name, scope, [], new Set()),
|
|
1798
|
+
resolveReference,
|
|
1799
|
+
isUnboundReference,
|
|
1758
1800
|
evaluate: (module, expression)=>evaluation(false).values(module, expression, []),
|
|
1759
1801
|
reachable: (module, expression)=>evaluation(true).reachable(module, expression)
|
|
1760
1802
|
};
|
|
@@ -7,6 +7,19 @@ const nodeRuntime = '@modern-js/bff-effect/effect';
|
|
|
7
7
|
const assembly = '@modern-js/bff-effect/assembly';
|
|
8
8
|
const failure = 'Generated API entries must export defineEffectBff(...) or the native Effect BFF assembly helper with an explicitly composed handler Layer and an unshadowed executable root; entries must implement handlers through HttpApiBuilder.group.';
|
|
9
9
|
const MAX_API_SOURCE_MODULES = 256;
|
|
10
|
+
const httpRouteMethods = new Set([
|
|
11
|
+
'*',
|
|
12
|
+
'GET',
|
|
13
|
+
'POST',
|
|
14
|
+
'PUT',
|
|
15
|
+
'PATCH',
|
|
16
|
+
'DELETE',
|
|
17
|
+
'HEAD',
|
|
18
|
+
'OPTIONS',
|
|
19
|
+
'TRACE',
|
|
20
|
+
'CONNECT',
|
|
21
|
+
'QUERY'
|
|
22
|
+
]);
|
|
10
23
|
function createEffectApiImportResolver(filename) {
|
|
11
24
|
const directory = node_fs.realpathSync(node_path.dirname(filename));
|
|
12
25
|
const owner = node_fs.realpathSync(node_path.resolve(directory, '..'));
|
|
@@ -54,9 +67,12 @@ function strictEffectRuntimeTopologyViolation(source, resolveImport) {
|
|
|
54
67
|
})) {
|
|
55
68
|
let target = nodePath.isAssignmentExpression() ? nodePath.node.left : nodePath.node.argument;
|
|
56
69
|
while(__rspack_external__babel_types_6e8337dd.isMemberExpression(target))target = target.object;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
let binding = __rspack_external__babel_types_6e8337dd.isIdentifier(target) ? nodePath.scope.getBinding(target.name) : void 0;
|
|
71
|
+
while(binding && !mutated.has(binding)){
|
|
72
|
+
mutated.add(binding);
|
|
73
|
+
const declarator = binding.path.node;
|
|
74
|
+
const alias = 'const' === binding.kind && __rspack_external__babel_types_6e8337dd.isVariableDeclarator(declarator) && declarator.init ? unwrapExpression(declarator.init, true) : void 0;
|
|
75
|
+
binding = __rspack_external__babel_types_6e8337dd.isIdentifier(alias) ? binding.path.scope.getBinding(alias.name) : void 0;
|
|
60
76
|
}
|
|
61
77
|
}
|
|
62
78
|
if (nodePath.isTSModuleDeclaration() && __rspack_external__babel_types_6e8337dd.isIdentifier(nodePath.node.id)) {
|
|
@@ -231,11 +247,48 @@ function strictEffectRuntimeTopologyViolation(source, resolveImport) {
|
|
|
231
247
|
if (method(node.callee, 'Layer', 'mergeAll', layerSources)) return node.arguments.length > 0 && node.arguments.every((argument)=>handlers(argument, api));
|
|
232
248
|
return method(node.callee, 'HttpApiBuilder', 'group') && 3 === node.arguments.length && apiIdentity(node.arguments[0]) === api && handled(node.arguments[2]);
|
|
233
249
|
});
|
|
234
|
-
const
|
|
250
|
+
const effectSources = [
|
|
251
|
+
edge,
|
|
252
|
+
'effect',
|
|
253
|
+
'effect/Effect'
|
|
254
|
+
];
|
|
255
|
+
const routeHandler = (node)=>{
|
|
256
|
+
node = unwrap(node);
|
|
257
|
+
if (!__rspack_external__babel_types_6e8337dd.isCallExpression(node) || !method(node.callee, 'HttpRouter', 'add') || 3 !== node.arguments.length) return;
|
|
258
|
+
const [verb, route, handler] = node.arguments;
|
|
259
|
+
return __rspack_external__babel_types_6e8337dd.isStringLiteral(verb) && httpRouteMethods.has(verb.value) && __rspack_external__babel_types_6e8337dd.isStringLiteral(route) && (route.value.startsWith('/') || '*' === route.value) && (__rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(handler) || __rspack_external__babel_types_6e8337dd.isFunctionExpression(handler)) ? handler : void 0;
|
|
260
|
+
};
|
|
261
|
+
const effectReference = (node)=>guarded(node, (node)=>{
|
|
235
262
|
const init = initialized(node);
|
|
236
|
-
if (init) return
|
|
263
|
+
if (init) return __rspack_external__babel_types_6e8337dd.isIdentifier(unwrap(init)) && effectReference(init);
|
|
264
|
+
const value = imported(node);
|
|
265
|
+
return !!value && !value.namespace;
|
|
266
|
+
});
|
|
267
|
+
const capturedRouteFactory = (node)=>guarded(node, (node)=>{
|
|
268
|
+
const init = initialized(node) ?? externalValue(node);
|
|
269
|
+
if (init) return capturedRouteFactory(init);
|
|
270
|
+
if (!__rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(node) || node.async || 1 !== node.params.length || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.params[0]) || __rspack_external__babel_types_6e8337dd.isBlockStatement(node.body)) return false;
|
|
271
|
+
const handler = routeHandler(node.body);
|
|
272
|
+
const parameter = binding(node.params[0]);
|
|
273
|
+
return !!handler && !!parameter && parameter.referencePaths.some((reference)=>!!reference.findParent((path)=>path.node === handler));
|
|
274
|
+
});
|
|
275
|
+
const capturedTransport = (node)=>guarded(node, (node)=>{
|
|
276
|
+
const init = initialized(node);
|
|
277
|
+
if (init) return capturedTransport(init);
|
|
278
|
+
if (!__rspack_external__babel_types_6e8337dd.isCallExpression(node)) return false;
|
|
279
|
+
if (method(node.callee, 'Effect', 'map', effectSources)) return 2 === node.arguments.length && effectReference(node.arguments[0]) && capturedRouteFactory(node.arguments[1]);
|
|
280
|
+
if (!__rspack_external__babel_types_6e8337dd.isMemberExpression(node.callee) || node.callee.computed || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.callee.property, {
|
|
281
|
+
name: 'pipe'
|
|
282
|
+
}) || 1 !== node.arguments.length || !effectReference(node.callee.object)) return false;
|
|
283
|
+
const map = unwrap(node.arguments[0]);
|
|
284
|
+
return __rspack_external__babel_types_6e8337dd.isCallExpression(map) && method(map.callee, 'Effect', 'map', effectSources) && 1 === map.arguments.length && capturedRouteFactory(map.arguments[0]);
|
|
285
|
+
});
|
|
286
|
+
const transport = (node, provided = false)=>guarded(node, (node)=>{
|
|
287
|
+
const init = initialized(node) ?? externalValue(node);
|
|
288
|
+
if (init) return transport(init, provided);
|
|
237
289
|
if (!__rspack_external__babel_types_6e8337dd.isCallExpression(node)) return method(node, 'Layer', 'empty', layerSources);
|
|
238
|
-
|
|
290
|
+
const providedHere = provided || node.arguments.some((argument)=>__rspack_external__babel_types_6e8337dd.isCallExpression(argument) && method(argument.callee, 'Layer', 'provide', layerSources) && 1 === argument.arguments.length);
|
|
291
|
+
return pipe(node, (value)=>transport(value, providedHere)) || void 0 !== routeHandler(node) || provided && method(node.callee, 'Layer', 'unwrap', layerSources) && 1 === node.arguments.length && capturedTransport(node.arguments[0]) || method(node.callee, 'HttpRouter', 'cors') || method(node.callee, 'Layer', 'mergeAll', layerSources) && node.arguments.length > 0 && node.arguments.every((argument)=>transport(argument, provided));
|
|
239
292
|
});
|
|
240
293
|
const directLayer = (node, api)=>guarded(node, (node)=>{
|
|
241
294
|
const init = initialized(node);
|
|
@@ -471,4 +471,4 @@ const microVerticalApiBaselineViolation = (stem, filePath, expectation)=>{
|
|
|
471
471
|
throw error;
|
|
472
472
|
}
|
|
473
473
|
};
|
|
474
|
-
export { configuredMicroVerticalApiStem, microVerticalApiBaselineViolation };
|
|
474
|
+
export { camelCaseStem, configuredMicroVerticalApiStem, microVerticalApiBaselineViolation, pascalCaseStem };
|