@bleedingdev/modern-js-code-tools 3.9.0-ultramodern.2 → 3.9.0-ultramodern.4

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.
@@ -121,22 +121,26 @@ const runOxlintRules = ({ cwd, targets, rules })=>{
121
121
  stdout: '',
122
122
  stderr: ''
123
123
  };
124
+ const pluginPath = resolvePluginPath();
124
125
  const tempDir = external_node_fs_default().mkdtempSync(external_node_path_default().join(external_node_os_default().tmpdir(), 'modern-code-tools-oxlint-'));
125
126
  const configPath = external_node_path_default().join(tempDir, 'oxlint.config.mjs');
126
- const pluginPath = resolvePluginPath();
127
- external_node_fs_default().writeFileSync(configPath, `export default {
128
- jsPlugins: [${JSON.stringify(pluginPath)}],
127
+ const adapterPath = external_node_path_default().join(tempDir, 'oxlint-plugin.mjs');
128
+ try {
129
+ external_node_fs_default().writeFileSync(adapterPath, `import plugin from ${JSON.stringify((0, external_node_url_namespaceObject.pathToFileURL)(pluginPath).href)};
130
+ export default plugin.rules ? plugin : plugin.default;
131
+ `, 'utf-8');
132
+ external_node_fs_default().writeFileSync(configPath, `export default {
133
+ jsPlugins: [${JSON.stringify(adapterPath)}],
129
134
  rules: ${JSON.stringify(rules, null, 2)}
130
135
  };
131
136
  `, 'utf-8');
132
- try {
133
137
  const result = (0, external_node_child_process_namespaceObject.spawnSync)(process.execPath, [
134
138
  resolveOxlintBin(),
135
139
  ...resolvedTargets,
136
140
  '--config',
137
141
  configPath,
138
142
  '--format',
139
- 'unix',
143
+ 'default',
140
144
  '--quiet'
141
145
  ], {
142
146
  cwd,
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  createStrictEffectApiBoundariesRule: ()=>createStrictEffectApiBoundariesRule
32
32
  });
33
+ const external_strict_effect_runtime_cjs_namespaceObject = require("../../strict-effect-runtime.cjs");
33
34
  const external_ast_cjs_namespaceObject = require("../ast.cjs");
34
35
  const createStrictEffectApiBoundariesRule = ()=>({
35
36
  meta: {
@@ -54,10 +55,11 @@ const createStrictEffectApiBoundariesRule = ()=>({
54
55
  (0, external_ast_cjs_namespaceObject.reportProgramPattern)(context, node, source, /(?:from|import)\s*['"][^'"]*(?:api\/effect|shared\/effect)[^'"]*['"]|shared-effect-api/u, 'Import API code from direct api/index.ts, shared/api.ts or src/api/* paths, not api/effect, shared/effect or shared Effect API packages.');
55
56
  (0, external_ast_cjs_namespaceObject.reportProgramPattern)(context, node, source, /\bstrictEffectApproach\s*(?::|=)\s*false\b/u, 'UltraModern API apps must keep strictEffectApproach enabled.');
56
57
  if ((0, external_ast_cjs_namespaceObject.isApiEntryFile)(filename)) {
57
- (0, external_ast_cjs_namespaceObject.reportMissingProgramPattern)(context, node, source, /\bdefineEffectBff\b/u, 'Generated API entries must export defineEffectBff(...).');
58
- (0, external_ast_cjs_namespaceObject.reportMissingProgramPattern)(context, node, source, /\bHttpApiBuilder\b/u, 'Generated API entries must implement handlers through HttpApiBuilder.');
59
- (0, external_ast_cjs_namespaceObject.reportMissingProgramPattern)(context, node, source, /\bLayer\b/u, 'Generated API entries must compose dependencies with Effect Layer.');
60
- (0, external_ast_cjs_namespaceObject.reportMissingProgramPattern)(context, node, source, /from\s+['"]\.\.\/shared\/api\.ts['"]/u, 'Generated API entries must import the contract from ../shared/api.ts.');
58
+ const violation = (0, external_strict_effect_runtime_cjs_namespaceObject.strictEffectRuntimeTopologyViolation)(source, (0, external_strict_effect_runtime_cjs_namespaceObject.createEffectApiImportResolver)(filename));
59
+ if (violation) context.report({
60
+ node,
61
+ message: violation
62
+ });
61
63
  }
62
64
  if ((0, external_ast_cjs_namespaceObject.isSharedApiContractFile)(filename)) {
63
65
  (0, external_ast_cjs_namespaceObject.reportMissingProgramPattern)(context, node, source, /\bHttpApi\.make\b/u, 'Generated shared API contracts must declare an HttpApi contract.');
@@ -0,0 +1,391 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ createEffectApiImportResolver: ()=>createEffectApiImportResolver,
41
+ strictEffectRuntimeTopologyViolation: ()=>strictEffectRuntimeTopologyViolation
42
+ });
43
+ const external_node_fs_namespaceObject = require("node:fs");
44
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
45
+ const external_node_path_namespaceObject = require("node:path");
46
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
47
+ const parser_namespaceObject = require("@babel/parser");
48
+ const traverse_namespaceObject = require("@babel/traverse");
49
+ var traverse_default = /*#__PURE__*/ __webpack_require__.n(traverse_namespaceObject);
50
+ const types_namespaceObject = require("@babel/types");
51
+ const edge = '@modern-js/plugin-bff/effect-edge';
52
+ const sharedRuntime = /^@[^/]+\/shared-contracts\/server\/effect-bff-runtime$/u;
53
+ const failure = 'Generated API entries must export defineEffectBff(...) or the server-only shared Effect BFF assembly helper with an explicitly composed handler Layer and an unshadowed executable root; entries must implement handlers through HttpApiBuilder.group.';
54
+ const invalidSources = new WeakSet();
55
+ function invalidSource(message) {
56
+ const error = new Error(message);
57
+ invalidSources.add(error);
58
+ return error;
59
+ }
60
+ class SourceValidationHub extends traverse_namespaceObject.Hub {
61
+ buildError(_node, message) {
62
+ return invalidSource(message);
63
+ }
64
+ }
65
+ function createEffectApiImportResolver(filename) {
66
+ const directory = external_node_fs_default().realpathSync(external_node_path_default().dirname(filename));
67
+ const owner = external_node_fs_default().realpathSync(external_node_path_default().resolve(directory, '..'));
68
+ const resolve = (from)=>(specifier)=>{
69
+ if (!specifier.startsWith('.')) return;
70
+ const target = external_node_path_default().resolve(external_node_path_default().dirname(from), specifier);
71
+ if (!target.startsWith(`${owner}${external_node_path_default().sep}`)) return;
72
+ for (const candidate of [
73
+ target,
74
+ `${target}.ts`,
75
+ `${target}.mts`
76
+ ])try {
77
+ const real = external_node_fs_default().realpathSync(candidate);
78
+ if (!real.startsWith(`${owner}${external_node_path_default().sep}`) || external_node_fs_default().statSync(real).size > 1000000) return;
79
+ return {
80
+ id: real,
81
+ source: external_node_fs_default().readFileSync(real, 'utf8'),
82
+ resolveImport: resolve(real)
83
+ };
84
+ } catch {}
85
+ };
86
+ return resolve(external_node_path_default().join(directory, external_node_path_default().basename(filename)));
87
+ }
88
+ function strictEffectRuntimeTopologyViolation(source, resolveImport) {
89
+ const modules = new Map();
90
+ const owners = new Map();
91
+ const paths = new Map();
92
+ const mutated = new Set();
93
+ const load = (input)=>{
94
+ const existing = modules.get(input.id);
95
+ if (existing) return existing;
96
+ if (modules.size >= 64 || input.source.length > 1000000) throw invalidSource('API source budget exceeded');
97
+ let file;
98
+ try {
99
+ file = (0, parser_namespaceObject.parse)(input.source, {
100
+ sourceType: 'module',
101
+ sourceFilename: input.id,
102
+ plugins: [
103
+ "typescript"
104
+ ]
105
+ });
106
+ } catch (cause) {
107
+ if ('object' == typeof cause && null !== cause && 'code' in cause && 'BABEL_PARSER_SYNTAX_ERROR' === cause.code && 'reasonCode' in cause && 'string' == typeof cause.reasonCode) throw invalidSource('Invalid API syntax');
108
+ throw cause;
109
+ }
110
+ const module = {
111
+ ...input,
112
+ file
113
+ };
114
+ modules.set(input.id, module);
115
+ const program = traverse_namespaceObject.NodePath.get({
116
+ hub: new SourceValidationHub(),
117
+ parentPath: void 0,
118
+ parent: file,
119
+ container: file,
120
+ key: 'program'
121
+ });
122
+ program.setContext();
123
+ traverse_default()(file, {
124
+ enter (nodePath) {
125
+ paths.set(nodePath.node, nodePath);
126
+ owners.set(nodePath.node, module);
127
+ if (nodePath.isAssignmentExpression() || nodePath.isUpdateExpression() || nodePath.isUnaryExpression({
128
+ operator: 'delete'
129
+ })) {
130
+ let target = nodePath.isAssignmentExpression() ? nodePath.node.left : nodePath.node.argument;
131
+ while(types_namespaceObject.isMemberExpression(target))target = target.object;
132
+ if (types_namespaceObject.isIdentifier(target)) {
133
+ const binding = nodePath.scope.getBinding(target.name);
134
+ if (binding) mutated.add(binding);
135
+ }
136
+ }
137
+ if (nodePath.isTSModuleDeclaration() && types_namespaceObject.isIdentifier(nodePath.node.id)) {
138
+ const binding = nodePath.scope.getBinding(nodePath.node.id.name);
139
+ if (binding) mutated.add(binding);
140
+ }
141
+ }
142
+ }, program.scope, void 0, program);
143
+ return module;
144
+ };
145
+ try {
146
+ const entry = load({
147
+ id: '/entry.ts',
148
+ source,
149
+ resolveImport
150
+ });
151
+ const unwrap = (node)=>{
152
+ while(types_namespaceObject.isParenthesizedExpression(node) || types_namespaceObject.isTSSatisfiesExpression(node) || types_namespaceObject.isTSAsExpression(node) || types_namespaceObject.isTSTypeAssertion(node) || types_namespaceObject.isTSNonNullExpression(node))node = node.expression;
153
+ return node;
154
+ };
155
+ const binding = (node)=>{
156
+ node = unwrap(node);
157
+ if (!types_namespaceObject.isIdentifier(node)) return;
158
+ const nodePath = paths.get(node);
159
+ if (!nodePath) throw new Error('Missing API lexical scope');
160
+ const value = nodePath.scope.getBinding(node.name);
161
+ return value?.constant && !mutated.has(value) ? value : void 0;
162
+ };
163
+ const declaration = (node)=>binding(node)?.path.node;
164
+ const imported = (node)=>{
165
+ const value = binding(node);
166
+ const decl = value?.path.node;
167
+ if (!decl || !types_namespaceObject.isImportSpecifier(decl) || 'type' === decl.importKind) return;
168
+ const statement = value.path.parent;
169
+ if (!types_namespaceObject.isImportDeclaration(statement) || 'type' === statement.importKind) return;
170
+ return {
171
+ name: types_namespaceObject.isIdentifier(decl.imported) ? decl.imported.name : decl.imported.value,
172
+ specifier: statement.source.value
173
+ };
174
+ };
175
+ const native = (node, name, sources = [
176
+ edge
177
+ ])=>{
178
+ const value = imported(node);
179
+ return value?.name === name && sources.includes(value.specifier);
180
+ };
181
+ const method = (node, namespace, member, sources = [
182
+ edge
183
+ ])=>{
184
+ node = unwrap(node);
185
+ return types_namespaceObject.isMemberExpression(node) && !node.computed && types_namespaceObject.isIdentifier(node.property, {
186
+ name: member
187
+ }) && native(node.object, namespace, sources);
188
+ };
189
+ const initialized = (node)=>{
190
+ const value = binding(node);
191
+ return value?.kind === 'const' && types_namespaceObject.isVariableDeclarator(value.path.node) ? value.path.node.init ?? void 0 : void 0;
192
+ };
193
+ const moduleFor = (node)=>{
194
+ const value = imported(node);
195
+ if (!value) return;
196
+ const input = owners.get(node)?.resolveImport?.(value.specifier);
197
+ return input ? {
198
+ module: load(input),
199
+ name: value.name
200
+ } : void 0;
201
+ };
202
+ const exported = (module, name)=>{
203
+ for (const statement of module.file.program.body)if (types_namespaceObject.isExportNamedDeclaration(statement) && 'type' !== statement.exportKind) {
204
+ if (types_namespaceObject.isVariableDeclaration(statement.declaration)) {
205
+ for (const decl of statement.declaration.declarations)if (types_namespaceObject.isIdentifier(decl.id, {
206
+ name
207
+ })) return decl.id;
208
+ }
209
+ if (!statement.source) {
210
+ const specifier = statement.specifiers.find((element)=>types_namespaceObject.isExportSpecifier(element) && 'type' !== element.exportKind && (types_namespaceObject.isIdentifier(element.exported) ? element.exported.name : element.exported.value) === name);
211
+ if (types_namespaceObject.isExportSpecifier(specifier)) return specifier.local;
212
+ }
213
+ }
214
+ };
215
+ const externalValue = (node)=>{
216
+ const value = moduleFor(node);
217
+ return value ? exported(value.module, value.name) : void 0;
218
+ };
219
+ const apiIdentity = (node, seen = new Set())=>{
220
+ node = unwrap(node);
221
+ if (seen.has(node)) return;
222
+ seen.add(node);
223
+ const value = imported(node);
224
+ if (value) {
225
+ if (!value.specifier.startsWith('.')) return;
226
+ const module = moduleFor(node);
227
+ const exportedValue = module && exported(module.module, module.name);
228
+ if (exportedValue) return apiIdentity(exportedValue, seen);
229
+ if (module && /(?:^|\/)shared\/(?:api|rpc)\.ts$/u.test(value.specifier)) return `${module.module.id}:import:${value.name}`;
230
+ if (!owners.get(node)?.resolveImport && /(?:^|\/)shared\/(?:api|rpc)\.ts$/u.test(value.specifier)) return `${value.specifier}:${value.name}`;
231
+ return;
232
+ }
233
+ const init = initialized(node);
234
+ if (init && types_namespaceObject.isIdentifier(unwrap(init))) return apiIdentity(init, seen);
235
+ const valueBinding = binding(node);
236
+ return valueBinding ? `${owners.get(valueBinding.path.node)?.id}:${valueBinding.identifier.start}` : void 0;
237
+ };
238
+ const properties = (node)=>{
239
+ node = unwrap(node);
240
+ if (!types_namespaceObject.isObjectExpression(node)) return;
241
+ const result = new Map();
242
+ for (const prop of node.properties){
243
+ if (!types_namespaceObject.isObjectProperty(prop) || prop.computed || !types_namespaceObject.isIdentifier(prop.key) || result.has(prop.key.name)) return;
244
+ result.set(prop.key.name, prop.value);
245
+ }
246
+ return result;
247
+ };
248
+ const active = new Set();
249
+ const guarded = (node, check)=>{
250
+ node = unwrap(node);
251
+ if (active.has(node) || active.size > 128) return false;
252
+ active.add(node);
253
+ try {
254
+ return check(node);
255
+ } finally{
256
+ active.delete(node);
257
+ }
258
+ };
259
+ const layerSources = [
260
+ edge,
261
+ 'effect'
262
+ ];
263
+ const returned = (body)=>{
264
+ if (!types_namespaceObject.isBlockStatement(body)) return body;
265
+ const statements = body.body;
266
+ const last = statements.at(-1);
267
+ return statements.slice(0, -1).every((statement)=>types_namespaceObject.isVariableDeclaration(statement)) && types_namespaceObject.isReturnStatement(last) ? last.argument : void 0;
268
+ };
269
+ const pipe = (node, check)=>types_namespaceObject.isMemberExpression(node.callee) && !node.callee.computed && types_namespaceObject.isIdentifier(node.callee.property, {
270
+ name: 'pipe'
271
+ }) && check(node.callee.object) && node.arguments.every((argument)=>method(argument, 'Layer', 'orDie', layerSources) || types_namespaceObject.isCallExpression(argument) && method(argument.callee, 'Layer', 'provide', layerSources) && argument.arguments.length > 0);
272
+ const handled = (node)=>{
273
+ node = unwrap(node);
274
+ if (!types_namespaceObject.isArrowFunctionExpression(node) && !types_namespaceObject.isFunctionExpression(node)) return false;
275
+ const parameter = node.params[0];
276
+ if (!types_namespaceObject.isIdentifier(parameter)) return false;
277
+ const body = returned(node.body);
278
+ const chain = (value, count = 0)=>{
279
+ value = unwrap(value);
280
+ if (types_namespaceObject.isIdentifier(value)) return count > 0 && declaration(value) === parameter;
281
+ return types_namespaceObject.isCallExpression(value) && types_namespaceObject.isMemberExpression(value.callee) && !value.callee.computed && types_namespaceObject.isIdentifier(value.callee.property) && [
282
+ 'handle',
283
+ 'handleRaw'
284
+ ].includes(value.callee.property.name) && 2 === value.arguments.length && chain(value.callee.object, count + 1);
285
+ };
286
+ return !!body && chain(body);
287
+ };
288
+ const handlers = (node, api)=>guarded(node, (node)=>{
289
+ const init = initialized(node) ?? externalValue(node);
290
+ if (init) return handlers(init, api);
291
+ if (!types_namespaceObject.isCallExpression(node)) return false;
292
+ if (pipe(node, (value)=>handlers(value, api))) return true;
293
+ if (method(node.callee, 'Layer', 'mergeAll', layerSources)) return node.arguments.length > 0 && node.arguments.every((argument)=>handlers(argument, api));
294
+ return method(node.callee, 'HttpApiBuilder', 'group') && 3 === node.arguments.length && apiIdentity(node.arguments[0]) === api && handled(node.arguments[2]);
295
+ });
296
+ const transport = (node)=>guarded(node, (node)=>{
297
+ const init = initialized(node);
298
+ if (init) return transport(init);
299
+ if (!types_namespaceObject.isCallExpression(node)) return method(node, 'Layer', 'empty', layerSources);
300
+ return pipe(node, transport) || method(node.callee, 'HttpRouter', 'cors') || method(node.callee, 'Layer', 'mergeAll', layerSources) && node.arguments.length > 0 && node.arguments.every(transport);
301
+ });
302
+ const directLayer = (node, api)=>guarded(node, (node)=>{
303
+ const init = initialized(node);
304
+ if (init) return directLayer(init, api);
305
+ if (!types_namespaceObject.isCallExpression(node) || !types_namespaceObject.isMemberExpression(node.callee) || node.callee.computed || !types_namespaceObject.isIdentifier(node.callee.property, {
306
+ name: 'pipe'
307
+ })) return false;
308
+ const base = unwrap(node.callee.object);
309
+ return types_namespaceObject.isCallExpression(base) && method(base.callee, 'HttpApiBuilder', 'layer') && 1 === base.arguments.length && apiIdentity(base.arguments[0]) === api && node.arguments.length > 0 && node.arguments.every((argument)=>types_namespaceObject.isCallExpression(argument) && method(argument.callee, 'Layer', 'provide', layerSources) && 1 === argument.arguments.length && handlers(argument.arguments[0], api));
310
+ });
311
+ const rpc = (values)=>{
312
+ const api = values.get('api');
313
+ const apiLayer = values.get('layer');
314
+ const apiInit = api && (initialized(api) ?? unwrap(api));
315
+ if (!apiInit || !types_namespaceObject.isCallExpression(apiInit) || !method(apiInit.callee, 'HttpApi', 'make') || 1 !== apiInit.arguments.length || !apiLayer || !transport(apiLayer)) return false;
316
+ const config = values.get('rpc');
317
+ const fields = config && properties(config);
318
+ const route = fields?.get('path');
319
+ const serialization = fields?.get('serialization');
320
+ if (!types_namespaceObject.isStringLiteral(route, {
321
+ value: '/rpc'
322
+ }) || !types_namespaceObject.isStringLiteral(serialization, {
323
+ value: 'json'
324
+ })) return false;
325
+ const group = fields?.get('group');
326
+ const layer = fields?.get('layer');
327
+ const value = group && imported(group);
328
+ if (!group || !layer || value?.specifier !== '../shared/rpc.ts') return false;
329
+ const groupValue = externalValue(group);
330
+ const groupInit = groupValue && initialized(groupValue);
331
+ if (!groupInit || !types_namespaceObject.isCallExpression(groupInit) || !method(groupInit.callee, 'RpcGroup', 'make', [
332
+ 'effect/unstable/rpc',
333
+ '@modern-js/plugin-bff/effect-client'
334
+ ])) return false;
335
+ const layerInit = initialized(layer) ?? unwrap(layer);
336
+ if (!types_namespaceObject.isCallExpression(layerInit) || !types_namespaceObject.isMemberExpression(layerInit.callee) || layerInit.callee.computed || !types_namespaceObject.isIdentifier(layerInit.callee.property, {
337
+ name: 'toLayer'
338
+ }) || apiIdentity(layerInit.callee.object) !== apiIdentity(group) || 1 !== layerInit.arguments.length) return false;
339
+ const implementation = unwrap(layerInit.arguments[0]);
340
+ if (!types_namespaceObject.isCallExpression(implementation) || !types_namespaceObject.isMemberExpression(implementation.callee) || implementation.callee.computed || !types_namespaceObject.isIdentifier(implementation.callee.property, {
341
+ name: 'of'
342
+ }) || apiIdentity(implementation.callee.object) !== apiIdentity(group) || 1 !== implementation.arguments.length) return false;
343
+ const entries = properties(implementation.arguments[0]);
344
+ return !!entries?.size && [
345
+ ...entries.values()
346
+ ].every((value)=>types_namespaceObject.isArrowFunctionExpression(value) || types_namespaceObject.isFunctionExpression(value));
347
+ };
348
+ const runtime = (node)=>guarded(node, (node)=>{
349
+ const init = initialized(node);
350
+ if (init) return runtime(init);
351
+ if (!types_namespaceObject.isCallExpression(node)) return false;
352
+ const value = imported(node.callee);
353
+ if (value?.name === 'defineEffectBff' && value.specifier === edge || value?.name === 'assembleEffectBffRuntime' && sharedRuntime.test(value.specifier)) {
354
+ if (1 !== node.arguments.length) return false;
355
+ const values = properties(node.arguments[0]);
356
+ if (!values) return false;
357
+ if ('defineEffectBff' === value.name && values.has('rpc')) return rpc(values);
358
+ const api = values.get('api');
359
+ const apiBinding = api && imported(api);
360
+ if (!api || apiBinding?.specifier !== '../shared/api.ts') return false;
361
+ const identity = apiIdentity(api);
362
+ if (!identity) return false;
363
+ const layer = values.get('defineEffectBff' === value.name ? 'layer' : 'handlers');
364
+ const extra = values.get('transport');
365
+ return void 0 !== layer && ('defineEffectBff' === value.name ? directLayer(layer, identity) : handlers(layer, identity)) && (!extra || transport(extra));
366
+ }
367
+ const decl = declaration(node.callee);
368
+ const factory = decl && types_namespaceObject.isFunctionDeclaration(decl) ? decl : initialized(node.callee);
369
+ if (!factory || !types_namespaceObject.isFunctionDeclaration(factory) && !types_namespaceObject.isArrowFunctionExpression(factory) && !types_namespaceObject.isFunctionExpression(factory) || !factory.body) return false;
370
+ const result = returned(factory.body);
371
+ return !!result && runtime(result);
372
+ });
373
+ const root = entry.file.program.body.find((statement)=>types_namespaceObject.isExportDefaultDeclaration(statement));
374
+ return root && runtime(root.declaration) ? void 0 : failure;
375
+ } catch (cause) {
376
+ if ('object' == typeof cause && null !== cause && invalidSources.has(cause)) return failure;
377
+ const message = 'object' == typeof cause && null !== cause && 'message' in cause && 'string' == typeof cause.message ? cause.message : String(cause);
378
+ throw new Error(`Strict Effect API analysis failed: ${message}`, {
379
+ cause
380
+ });
381
+ }
382
+ }
383
+ exports.createEffectApiImportResolver = __webpack_exports__.createEffectApiImportResolver;
384
+ exports.strictEffectRuntimeTopologyViolation = __webpack_exports__.strictEffectRuntimeTopologyViolation;
385
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
386
+ "createEffectApiImportResolver",
387
+ "strictEffectRuntimeTopologyViolation"
388
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
389
+ Object.defineProperty(exports, '__esModule', {
390
+ value: true
391
+ });
@@ -3,7 +3,7 @@ import node_fs from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import node_os from "node:os";
5
5
  import node_path from "node:path";
6
- import { fileURLToPath } from "node:url";
6
+ import { fileURLToPath, pathToFileURL } from "node:url";
7
7
  const oxlint_require = createRequire(import.meta.url);
8
8
  const ignoredDirectories = new Set([
9
9
  '.modern',
@@ -73,22 +73,26 @@ const runOxlintRules = ({ cwd, targets, rules })=>{
73
73
  stdout: '',
74
74
  stderr: ''
75
75
  };
76
+ const pluginPath = resolvePluginPath();
76
77
  const tempDir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), 'modern-code-tools-oxlint-'));
77
78
  const configPath = node_path.join(tempDir, 'oxlint.config.mjs');
78
- const pluginPath = resolvePluginPath();
79
- node_fs.writeFileSync(configPath, `export default {
80
- jsPlugins: [${JSON.stringify(pluginPath)}],
79
+ const adapterPath = node_path.join(tempDir, 'oxlint-plugin.mjs');
80
+ try {
81
+ node_fs.writeFileSync(adapterPath, `import plugin from ${JSON.stringify(pathToFileURL(pluginPath).href)};
82
+ export default plugin.rules ? plugin : plugin.default;
83
+ `, 'utf-8');
84
+ node_fs.writeFileSync(configPath, `export default {
85
+ jsPlugins: [${JSON.stringify(adapterPath)}],
81
86
  rules: ${JSON.stringify(rules, null, 2)}
82
87
  };
83
88
  `, 'utf-8');
84
- try {
85
89
  const result = spawnSync(process.execPath, [
86
90
  resolveOxlintBin(),
87
91
  ...resolvedTargets,
88
92
  '--config',
89
93
  configPath,
90
94
  '--format',
91
- 'unix',
95
+ 'default',
92
96
  '--quiet'
93
97
  ], {
94
98
  cwd,
@@ -1,3 +1,4 @@
1
+ import { createEffectApiImportResolver, strictEffectRuntimeTopologyViolation } from "../../strict-effect-runtime.js";
1
2
  import { getSourceText, isApiEntryFile, isApiSourceFile, isForbiddenGeneratedEffectPath, isSharedApiContractFile, normalizeFilename, reportMissingProgramPattern, reportProgramPattern } from "../ast.js";
2
3
  const createStrictEffectApiBoundariesRule = ()=>({
3
4
  meta: {
@@ -22,10 +23,11 @@ const createStrictEffectApiBoundariesRule = ()=>({
22
23
  reportProgramPattern(context, node, source, /(?:from|import)\s*['"][^'"]*(?:api\/effect|shared\/effect)[^'"]*['"]|shared-effect-api/u, 'Import API code from direct api/index.ts, shared/api.ts or src/api/* paths, not api/effect, shared/effect or shared Effect API packages.');
23
24
  reportProgramPattern(context, node, source, /\bstrictEffectApproach\s*(?::|=)\s*false\b/u, 'UltraModern API apps must keep strictEffectApproach enabled.');
24
25
  if (isApiEntryFile(filename)) {
25
- reportMissingProgramPattern(context, node, source, /\bdefineEffectBff\b/u, 'Generated API entries must export defineEffectBff(...).');
26
- reportMissingProgramPattern(context, node, source, /\bHttpApiBuilder\b/u, 'Generated API entries must implement handlers through HttpApiBuilder.');
27
- reportMissingProgramPattern(context, node, source, /\bLayer\b/u, 'Generated API entries must compose dependencies with Effect Layer.');
28
- reportMissingProgramPattern(context, node, source, /from\s+['"]\.\.\/shared\/api\.ts['"]/u, 'Generated API entries must import the contract from ../shared/api.ts.');
26
+ const violation = strictEffectRuntimeTopologyViolation(source, createEffectApiImportResolver(filename));
27
+ if (violation) context.report({
28
+ node,
29
+ message: violation
30
+ });
29
31
  }
30
32
  if (isSharedApiContractFile(filename)) {
31
33
  reportMissingProgramPattern(context, node, source, /\bHttpApi\.make\b/u, 'Generated shared API contracts must declare an HttpApi contract.');