fortiplugin-bundle-adapter 0.0.13 → 0.0.15

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/index.cjs CHANGED
@@ -56,18 +56,6 @@ function shouldInject(id, opts) {
56
56
  for (const p of prefixes) if (id.startsWith(p)) return true;
57
57
  return false;
58
58
  }
59
- function programHasDefaultExport(p) {
60
- for (const stmt of p.body) {
61
- if (t.isExportDefaultDeclaration(stmt)) return true;
62
- if (t.isExportNamedDeclaration(stmt) && stmt.specifiers?.length) {
63
- for (const spec of stmt.specifiers) {
64
- const exported = t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value;
65
- if (exported === "default") return true;
66
- }
67
- }
68
- }
69
- return false;
70
- }
71
59
  function getImportedName(spec) {
72
60
  return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;
73
61
  }
@@ -76,17 +64,57 @@ function makeImportMapExpr(depsIdent, runtimeKey) {
76
64
  const isObj = t.logicalExpression(
77
65
  "&&",
78
66
  t.binaryExpression("!==", depsIdent, t.nullLiteral()),
79
- t.binaryExpression(
80
- "===",
81
- t.unaryExpression("typeof", depsIdent),
82
- t.stringLiteral("object")
83
- )
67
+ t.binaryExpression("===", t.unaryExpression("typeof", depsIdent), t.stringLiteral("object"))
84
68
  );
85
69
  const test = t.logicalExpression("&&", isObj, hasKey);
86
70
  const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));
87
71
  const fallback = t.logicalExpression("||", depsIdent, t.objectExpression([]));
88
72
  return t.conditionalExpression(test, depsKey, fallback);
89
73
  }
74
+ function looksLikeRollupNamespaceWrapper(init) {
75
+ if (!init || !t.isCallExpression(init)) return false;
76
+ if (!t.isMemberExpression(init.callee)) return false;
77
+ if (!t.isIdentifier(init.callee.object, { name: "Object" })) return false;
78
+ if (!t.isIdentifier(init.callee.property, { name: "freeze" })) return false;
79
+ const arg0 = init.arguments[0];
80
+ if (!t.isCallExpression(arg0)) return false;
81
+ if (!t.isMemberExpression(arg0.callee)) return false;
82
+ if (!t.isIdentifier(arg0.callee.object, { name: "Object" })) return false;
83
+ if (!t.isIdentifier(arg0.callee.property, { name: "defineProperty" })) return false;
84
+ const objArg = arg0.arguments[0];
85
+ if (!t.isObjectExpression(objArg)) return false;
86
+ const hasDefault = objArg.properties.some((p) => {
87
+ if (!t.isObjectProperty(p)) return false;
88
+ if (t.isIdentifier(p.key)) return p.key.name === "default";
89
+ if (t.isStringLiteral(p.key)) return p.key.value === "default";
90
+ return false;
91
+ });
92
+ return hasDefault;
93
+ }
94
+ function inferDefaultFromSingleNamedExport(program) {
95
+ const exports2 = program.body.filter(
96
+ (s) => t.isExportNamedDeclaration(s)
97
+ );
98
+ for (const ex of exports2) {
99
+ if (!ex.specifiers || ex.specifiers.length !== 1) continue;
100
+ const spec = ex.specifiers[0];
101
+ if (!t.isExportSpecifier(spec)) continue;
102
+ if (!t.isIdentifier(spec.local)) continue;
103
+ const localName = spec.local.name;
104
+ let ok = false;
105
+ for (const stmt of program.body) {
106
+ if (!t.isVariableDeclaration(stmt)) continue;
107
+ for (const d of stmt.declarations) {
108
+ if (!t.isIdentifier(d.id, { name: localName })) continue;
109
+ if (looksLikeRollupNamespaceWrapper(d.init)) ok = true;
110
+ }
111
+ }
112
+ if (ok) {
113
+ return { local: localName, returnDefaultProperty: true };
114
+ }
115
+ }
116
+ return null;
117
+ }
90
118
  function fortiPrepTransform(_api, rawOpts = {}) {
91
119
  const opts = {
92
120
  ...rawOpts,
@@ -94,7 +122,8 @@ function fortiPrepTransform(_api, rawOpts = {}) {
94
122
  depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,
95
123
  onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault
96
124
  };
97
- let enabled = true;
125
+ const removedPaths = [];
126
+ const replacedExports = [];
98
127
  const keptImports = [];
99
128
  const keptNamedExports = [];
100
129
  const injectedImportsById = /* @__PURE__ */ new Map();
@@ -109,21 +138,28 @@ function fortiPrepTransform(_api, rawOpts = {}) {
109
138
  name: "fortiplugin-prep/transform",
110
139
  visitor: {
111
140
  Program: {
112
- enter(path2) {
113
- const hasDefault = programHasDefaultExport(path2.node);
114
- if (!hasDefault && (opts.onMissingDefault ?? DEFAULTS.onMissingDefault) === "skip") {
115
- enabled = false;
116
- }
117
- },
118
141
  exit(path2) {
119
- if (!enabled) return;
120
142
  const program = path2.node;
143
+ if (!defaultExportLocalName) {
144
+ const inferred = inferDefaultFromSingleNamedExport(program);
145
+ if (inferred) {
146
+ defaultExportLocalName = inferred.local;
147
+ returnDefaultProperty = inferred.returnDefaultProperty;
148
+ }
149
+ }
121
150
  if (!defaultExportLocalName) {
122
151
  const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;
123
- if (behavior === "throw") {
124
- throw path2.buildCodeFrameError(DEFAULT_EXPORT_ERROR);
152
+ if (behavior === "throw") throw path2.buildCodeFrameError(DEFAULT_EXPORT_ERROR);
153
+ if (behavior === "skip") {
154
+ return;
125
155
  }
126
- defaultExportLocalName = null;
156
+ }
157
+ for (const { path: exPath, replacement } of replacedExports) {
158
+ exPath.replaceWith(replacement);
159
+ }
160
+ for (const p of removedPaths) {
161
+ if (p.removed) continue;
162
+ p.remove();
127
163
  }
128
164
  const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);
129
165
  const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;
@@ -160,9 +196,7 @@ function fortiPrepTransform(_api, rawOpts = {}) {
160
196
  ]);
161
197
  const injectedStmts = [importsDecl, defaultHelperDecl];
162
198
  for (const [importId, specs] of injectedImportsById.entries()) {
163
- const modIdent = t.identifier(
164
- `__m_${importId.replace(/[^a-zA-Z0-9_$]/g, "_")}`
165
- );
199
+ const modIdent = t.identifier(`__m_${importId.replace(/[^a-zA-Z0-9_$]/g, "_")}`);
166
200
  injectedStmts.push(
167
201
  t.variableDeclaration("const", [
168
202
  t.variableDeclarator(
@@ -224,12 +258,11 @@ function fortiPrepTransform(_api, rawOpts = {}) {
224
258
  }
225
259
  },
226
260
  ImportDeclaration(path2) {
227
- if (!enabled) return;
228
261
  const node = path2.node;
229
262
  const importId = node.source.value;
230
263
  if (!shouldInject(importId, opts)) {
231
264
  keptImports.push(node);
232
- path2.remove();
265
+ removedPaths.push(path2);
233
266
  return;
234
267
  }
235
268
  for (const s of node.specifiers) {
@@ -245,14 +278,13 @@ function fortiPrepTransform(_api, rawOpts = {}) {
245
278
  });
246
279
  }
247
280
  }
248
- path2.remove();
281
+ removedPaths.push(path2);
249
282
  },
250
283
  ExportDefaultDeclaration(path2) {
251
- if (!enabled) return;
252
284
  const decl = path2.node.declaration;
253
285
  if (t.isIdentifier(decl)) {
254
286
  defaultExportLocalName = decl.name;
255
- path2.remove();
287
+ removedPaths.push(path2);
256
288
  return;
257
289
  }
258
290
  if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {
@@ -260,19 +292,17 @@ function fortiPrepTransform(_api, rawOpts = {}) {
260
292
  decl.id = path2.scope.generateUidIdentifier("defaultExport");
261
293
  }
262
294
  defaultExportLocalName = decl.id.name;
263
- path2.replaceWith(decl);
295
+ replacedExports.push({ path: path2, replacement: decl });
264
296
  return;
265
297
  }
266
298
  const id = path2.scope.generateUidIdentifier("defaultExport");
267
- path2.replaceWith(
268
- t.variableDeclaration("const", [
269
- t.variableDeclarator(id, decl)
270
- ])
271
- );
272
299
  defaultExportLocalName = id.name;
300
+ const replacement = t.variableDeclaration("const", [
301
+ t.variableDeclarator(id, decl)
302
+ ]);
303
+ replacedExports.push({ path: path2, replacement });
273
304
  },
274
305
  ExportNamedDeclaration(path2) {
275
- if (!enabled) return;
276
306
  const node = path2.node;
277
307
  if (node.specifiers?.length) {
278
308
  let foundExplicitDefault = false;
@@ -298,7 +328,7 @@ function fortiPrepTransform(_api, rawOpts = {}) {
298
328
  if (node.declaration || node.specifiers && node.specifiers.length > 0) {
299
329
  keptNamedExports.push(node);
300
330
  }
301
- path2.remove();
331
+ removedPaths.push(path2);
302
332
  }
303
333
  }
304
334
  };
@@ -502,9 +532,9 @@ function crawl(dirPath, baseDir, acc, sets, appEntryAbsPath) {
502
532
  }
503
533
  function generatePluginInputs(srcRoot = import_node_path2.default.resolve(process.cwd(), "ts"), options = {}) {
504
534
  const {
505
- writeAppEntry = true,
535
+ writeAppEntry = false,
506
536
  appEntryName = "app.tsx",
507
- includeAppEntryInInputs = true,
537
+ includeAppEntryInInputs = false,
508
538
  appEntryKey = "__app_entry",
509
539
  verbose = true
510
540
  } = options;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/vite/prep.ts","../src/babel/transform.ts","../src/utils/generate-plugin-inputs.ts"],"sourcesContent":["// src/index.ts\r\nexport {default} from \"./vite/prep\";\r\nexport type {FortiPrepOptions} from \"./vite/prep\";\r\nexport type {FortiPrepTransformOptions} from \"./babel/transform\";\r\n\r\n// ✅ add this:\r\nexport {default as fortiPrepTransform} from \"./babel/transform\";\r\nexport {generatePluginInputs as discoverEntrypoints} from './utils/generate-plugin-inputs'","import { transformSync } from \"@babel/core\";\r\nimport { readFileSync, writeFileSync } from \"node:fs\";\r\nimport { dirname, resolve as resolvePath } from \"node:path\";\r\nimport type {NormalizedOutputOptions, OutputBundle, OutputOptions} from \"rollup\";\r\nimport type { Plugin as VitePlugin } from \"vite\";\r\n\r\nimport fortiPrepTransform, {\r\n type FortiPrepTransformOptions,\r\n} from \"../babel/transform\";\r\n\r\nexport type FortiPrepOptions = FortiPrepTransformOptions & {\r\n /**\r\n * Which emitted entry file extensions should be rewritten.\r\n * Default: [\".js\", \".mjs\"]\r\n */\r\n entryExtensions?: string[];\r\n\r\n /**\r\n * Vite plugin name\r\n * Default: \"fortiplugin-prep\"\r\n */\r\n pluginName?: string;\r\n};\r\n\r\nconst DEFAULT_INJECTED_IDS = [\"react\", \"react/jsx-runtime\"] as const;\r\nconst DEFAULT_INJECTED_PREFIXES = [\"@inertiajs/\", \"@host/\"] as const;\r\n\r\nfunction resolveOutDir(outputOptions: OutputOptions): string | null {\r\n if (outputOptions.dir) return outputOptions.dir;\r\n if (outputOptions.file) return dirname(outputOptions.file);\r\n return null;\r\n}\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\n/**\r\n * FortiPlugin bundle adapter:\r\n * - marks injected imports as Rollup externals (so they survive into output)\r\n * - rewrites built entry chunks to remove those imports and load them from runtime deps\r\n */\r\nexport default function prep(options: FortiPrepOptions = {}): VitePlugin {\r\n const injectedIds = options.injectedIds ?? [...DEFAULT_INJECTED_IDS];\r\n const injectedPrefixes = options.injectedPrefixes ?? [...DEFAULT_INJECTED_PREFIXES];\r\n\r\n const runtimeKey = options.runtimeKey ?? \"imports\";\r\n const depsParam = options.depsParam ?? \"deps\";\r\n\r\n const entryExtensions = options.entryExtensions ?? [\".js\", \".mjs\"];\r\n const pluginName = options.pluginName ?? \"fortiplugin-prep\";\r\n\r\n const transformOptions: FortiPrepTransformOptions = {\r\n injectedIds,\r\n injectedPrefixes,\r\n runtimeKey,\r\n depsParam,\r\n };\r\n\r\n return {\r\n name: pluginName,\r\n apply: \"build\",\r\n\r\n config() {\r\n return {\r\n define: {\r\n \"process.env.NODE_ENV\": '\"production\"',\r\n },\r\n build: {\r\n rollupOptions: {\r\n // Ensure virtual imports don't need to resolve.\r\n external: (id: string) => shouldInject(id, transformOptions),\r\n },\r\n },\r\n };\r\n },\r\n\r\n writeBundle(outputOptions: NormalizedOutputOptions, bundle: OutputBundle) {\r\n const outDir = resolveOutDir(outputOptions);\r\n if (!outDir) return;\r\n\r\n for (const [fileName, item] of Object.entries(bundle)) {\r\n if (item.type !== \"chunk\") continue;\r\n if (!item.isEntry) continue;\r\n\r\n if (!entryExtensions.some((ext) => fileName.endsWith(ext))) continue;\r\n\r\n const absPath = resolvePath(outDir, fileName);\r\n const input = readFileSync(absPath, \"utf-8\");\r\n\r\n const result = transformSync(input, {\r\n filename: absPath,\r\n sourceType: \"module\",\r\n // Fresh plugin instance per file (Babel calls plugin factory per file when passed as [fn, opts])\r\n plugins: [[fortiPrepTransform as any, transformOptions]],\r\n generatorOpts: {\r\n compact: false,\r\n comments: true,\r\n retainLines: false,\r\n },\r\n });\r\n\r\n if (!result?.code) continue;\r\n writeFileSync(absPath, result.code, \"utf-8\");\r\n }\r\n },\r\n };\r\n}","// noinspection JSUnusedGlobalSymbols,GrazieInspection\r\n\r\nimport type {PluginObj} from \"@babel/core\";\r\nimport * as t from \"@babel/types\";\r\nimport type {NodePath} from \"@babel/traverse\";\r\n\r\nexport type FortiPrepTransformOptions = {\r\n /**\r\n * Exact import ids to inject (removed from bundle and loaded from runtime deps).\r\n * Example: [\"react\", \"react/jsx-runtime\", \"@host/ui\"]\r\n */\r\n injectedIds?: string[];\r\n\r\n /**\r\n * Prefix import ids to inject.\r\n * Example: [\"@host/\", \"@inertiajs/\"]\r\n */\r\n injectedPrefixes?: string[];\r\n\r\n /**\r\n * The key on the deps object used as the import map.\r\n * Wrapper supports passing deps.imports OR passing the import map directly.\r\n *\r\n * Default: \"imports\"\r\n */\r\n runtimeKey?: string;\r\n\r\n /**\r\n * Wrapper function parameter name.\r\n * Default: \"deps\"\r\n */\r\n depsParam?: string;\r\n\r\n /**\r\n * What to do if we can't determine a default export to return.\r\n *\r\n * - \"skip\": do nothing (leave file untouched) ✅ default\r\n * - \"return-null\": still wrap, but return null\r\n * - \"throw\": fail the build (old behavior)\r\n */\r\n onMissingDefault?: \"skip\" | \"return-null\" | \"throw\";\r\n};\r\n\r\nconst DEFAULTS: Required<\r\n Pick<FortiPrepTransformOptions, \"runtimeKey\" | \"depsParam\" | \"onMissingDefault\">\r\n> = {\r\n runtimeKey: \"imports\",\r\n depsParam: \"deps\",\r\n onMissingDefault: \"skip\",\r\n};\r\n\r\nconst DEFAULT_EXPORT_ERROR =\r\n \"PROBLEM!!, No known default function was found, your code either possesses NO named default export or this export format is currently not supported.\";\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\nfunction programHasDefaultExport(p: t.Program): boolean {\r\n for (const stmt of p.body) {\r\n if (t.isExportDefaultDeclaration(stmt)) return true;\r\n\r\n // Rollup-style: export { Foo as default }\r\n if (t.isExportNamedDeclaration(stmt) && stmt.specifiers?.length) {\r\n for (const spec of stmt.specifiers) {\r\n const exported = t.isIdentifier(spec.exported)\r\n ? spec.exported.name\r\n : spec.exported.value;\r\n if (exported === \"default\") return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\ntype CapturedImport =\r\n | { kind: \"default\"; local: string }\r\n | { kind: \"namespace\"; local: string }\r\n | { kind: \"named\"; imported: string; local: string };\r\n\r\nfunction getImportedName(spec: t.ImportSpecifier): string {\r\n return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;\r\n}\r\n\r\nfunction makeImportMapExpr(depsIdent: t.Identifier, runtimeKey: string): t.Expression {\r\n // Support both:\r\n // factory({ imports: { ... } })\r\n // and:\r\n // factory({ ... }) // direct import map\r\n //\r\n // const __imports =\r\n // deps && typeof deps === \"object\" && \"imports\" in deps\r\n // ? deps.imports\r\n // : (deps || {});\r\n const hasKey = t.binaryExpression(\"in\", t.stringLiteral(runtimeKey), depsIdent);\r\n\r\n const isObj = t.logicalExpression(\r\n \"&&\",\r\n t.binaryExpression(\"!==\", depsIdent, t.nullLiteral()),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", depsIdent),\r\n t.stringLiteral(\"object\")\r\n )\r\n );\r\n\r\n const test = t.logicalExpression(\"&&\", isObj, hasKey);\r\n\r\n const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));\r\n const fallback = t.logicalExpression(\"||\", depsIdent, t.objectExpression([]));\r\n\r\n return t.conditionalExpression(test, depsKey, fallback);\r\n}\r\n\r\n/**\r\n * Babel plugin factory (Babel calls this per-file when used as `[plugin, options]`).\r\n */\r\nexport default function fortiPrepTransform(\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n _api: unknown,\r\n rawOpts: FortiPrepTransformOptions = {}\r\n): PluginObj {\r\n const opts: FortiPrepTransformOptions = {\r\n ...rawOpts,\r\n runtimeKey: rawOpts.runtimeKey ?? DEFAULTS.runtimeKey,\r\n depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,\r\n onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault,\r\n };\r\n\r\n // If false, we do NOTHING to this file (silent ignore).\r\n let enabled = true;\r\n\r\n // per-file state (because Babel calls the plugin per file)\r\n const keptImports: t.ImportDeclaration[] = [];\r\n const keptNamedExports: t.ExportNamedDeclaration[] = [];\r\n\r\n const injectedImportsById = new Map<string, CapturedImport[]>();\r\n\r\n let defaultExportLocalName: string | null = null;\r\n let returnDefaultProperty = false;\r\n\r\n function captureImport(importId: string, entry: CapturedImport) {\r\n const list = injectedImportsById.get(importId) ?? [];\r\n list.push(entry);\r\n injectedImportsById.set(importId, list);\r\n }\r\n\r\n return {\r\n name: \"fortiplugin-prep/transform\",\r\n visitor: {\r\n Program: {\r\n enter(path: NodePath<t.Program>) {\r\n // If there's no default export and behavior is \"skip\", silently do nothing.\r\n const hasDefault = programHasDefaultExport(path.node);\r\n if (!hasDefault && (opts.onMissingDefault ?? DEFAULTS.onMissingDefault) === \"skip\") {\r\n enabled = false;\r\n }\r\n },\r\n\r\n exit(path: NodePath<t.Program>) {\r\n if (!enabled) return;\r\n\r\n const program = path.node;\r\n\r\n // If we still couldn't resolve the default export name, decide behavior.\r\n if (!defaultExportLocalName) {\r\n const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;\r\n\r\n if (behavior === \"throw\") {\r\n throw path.buildCodeFrameError(DEFAULT_EXPORT_ERROR);\r\n }\r\n\r\n // \"return-null\": wrap but return null.\r\n // (Note: \"skip\" mode should have disabled earlier, but this is a safe fallback.)\r\n defaultExportLocalName = null;\r\n }\r\n\r\n const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);\r\n const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;\r\n\r\n // const __imports = (deps has runtimeKey) ? deps[runtimeKey] : (deps || {});\r\n const importsIdent = t.identifier(\"__imports\");\r\n const importsInit = makeImportMapExpr(depsIdent, runtimeKey);\r\n const importsDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(importsIdent, importsInit),\r\n ]);\r\n\r\n // const __default = (m) => (m && typeof m === \"object\" && \"default\" in m ? m.default : m);\r\n const defaultHelperIdent = t.identifier(\"__default\");\r\n const defaultHelperDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n defaultHelperIdent,\r\n t.arrowFunctionExpression(\r\n [t.identifier(\"m\")],\r\n t.conditionalExpression(\r\n t.logicalExpression(\r\n \"&&\",\r\n t.logicalExpression(\r\n \"&&\",\r\n t.identifier(\"m\"),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", t.identifier(\"m\")),\r\n t.stringLiteral(\"object\")\r\n )\r\n ),\r\n t.binaryExpression(\"in\", t.stringLiteral(\"default\"), t.identifier(\"m\"))\r\n ),\r\n t.memberExpression(t.identifier(\"m\"), t.identifier(\"default\")),\r\n t.identifier(\"m\")\r\n )\r\n )\r\n ),\r\n ]);\r\n\r\n // Build injected module locals inside wrapper\r\n const injectedStmts: t.Statement[] = [importsDecl, defaultHelperDecl];\r\n\r\n for (const [importId, specs] of injectedImportsById.entries()) {\r\n const modIdent = t.identifier(\r\n `__m_${importId.replace(/[^a-zA-Z0-9_$]/g, \"_\")}`\r\n );\r\n\r\n // const __m_xxx = __imports[\"<importId>\"];\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n modIdent,\r\n t.memberExpression(importsIdent, t.stringLiteral(importId), true)\r\n ),\r\n ])\r\n );\r\n\r\n const named: Array<{ imported: string; local: string }> = [];\r\n\r\n for (const s of specs) {\r\n if (s.kind === \"default\") {\r\n // const Local = __default(__m_xxx);\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.identifier(s.local),\r\n t.callExpression(defaultHelperIdent, [modIdent])\r\n ),\r\n ])\r\n );\r\n } else if (s.kind === \"namespace\") {\r\n // const Local = __m_xxx;\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(t.identifier(s.local), modIdent),\r\n ])\r\n );\r\n } else {\r\n named.push({imported: s.imported, local: s.local});\r\n }\r\n }\r\n\r\n if (named.length) {\r\n // const { A, B: C } = (__m_xxx || {});\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.objectPattern(\r\n named.map(({imported, local}) =>\r\n t.objectProperty(\r\n t.identifier(imported),\r\n t.identifier(local),\r\n false,\r\n imported === local\r\n )\r\n )\r\n ),\r\n t.logicalExpression(\"||\", modIdent, t.objectExpression([]))\r\n ),\r\n ])\r\n );\r\n }\r\n }\r\n\r\n const returnExpr =\r\n defaultExportLocalName == null\r\n ? t.nullLiteral()\r\n : returnDefaultProperty\r\n ? t.memberExpression(t.identifier(defaultExportLocalName), t.identifier(\"default\"))\r\n : t.identifier(defaultExportLocalName);\r\n\r\n // Wrapper body:\r\n // injectedStmts...\r\n // <original body>\r\n // return <defaultExport>\r\n const wrapperBody: t.Statement[] = [];\r\n wrapperBody.push(...injectedStmts);\r\n wrapperBody.push(...program.body);\r\n wrapperBody.push(t.returnStatement(returnExpr));\r\n\r\n const wrapper = t.exportDefaultDeclaration(\r\n t.functionDeclaration(null, [depsIdent], t.blockStatement(wrapperBody))\r\n );\r\n\r\n // Final program:\r\n // kept imports at module scope\r\n // export default function(deps) { ... }\r\n // kept named exports (same as your old behavior)\r\n program.body = [...keptImports, wrapper, ...keptNamedExports] as any;\r\n },\r\n },\r\n\r\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const node = path.node;\r\n const importId = node.source.value;\r\n\r\n if (!shouldInject(importId, opts)) {\r\n keptImports.push(node);\r\n path.remove();\r\n return;\r\n }\r\n\r\n // Remove injected import and capture its specifiers to recreate inside wrapper.\r\n for (const s of node.specifiers) {\r\n if (t.isImportDefaultSpecifier(s)) {\r\n captureImport(importId, {kind: \"default\", local: s.local.name});\r\n } else if (t.isImportNamespaceSpecifier(s)) {\r\n captureImport(importId, {kind: \"namespace\", local: s.local.name});\r\n } else if (t.isImportSpecifier(s)) {\r\n captureImport(importId, {\r\n kind: \"named\",\r\n imported: getImportedName(s),\r\n local: s.local.name,\r\n });\r\n }\r\n }\r\n\r\n // side-effect-only injected imports (import \"@host/ui\") become no-ops at runtime\r\n path.remove();\r\n },\r\n\r\n ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const decl = path.node.declaration;\r\n\r\n // export default Foo;\r\n if (t.isIdentifier(decl)) {\r\n defaultExportLocalName = decl.name;\r\n path.remove();\r\n return;\r\n }\r\n\r\n // export default function (...) {}\r\n // export default class {...}\r\n // Keep as declaration (valid) and remember its id.\r\n if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {\r\n if (!decl.id) {\r\n decl.id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n }\r\n defaultExportLocalName = decl.id.name;\r\n path.replaceWith(decl);\r\n return;\r\n }\r\n\r\n // export default (expr/arrow/etc)\r\n const id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n path.replaceWith(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(id, decl as t.Expression),\r\n ])\r\n );\r\n defaultExportLocalName = id.name;\r\n },\r\n\r\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const node = path.node;\r\n\r\n // Detect Rollup-style: export { Foo as default }\r\n if (node.specifiers?.length) {\r\n let foundExplicitDefault = false;\r\n\r\n node.specifiers = node.specifiers.filter((spec) => {\r\n const exported = t.isIdentifier(spec.exported)\r\n ? spec.exported.name\r\n : spec.exported.value;\r\n\r\n if (exported === \"default\") {\r\n const local = (spec as any)?.local?.name as string | undefined;\r\n if (local) defaultExportLocalName = local;\r\n foundExplicitDefault = true;\r\n return false; // remove the default specifier\r\n }\r\n\r\n return true;\r\n });\r\n\r\n // Minified fallback behavior:\r\n // If no default specifier found and exactly one spec exists,\r\n // treat it as the container and return `<local>.default`.\r\n if (\r\n !foundExplicitDefault &&\r\n !defaultExportLocalName &&\r\n node.specifiers.length === 1\r\n ) {\r\n const only = node.specifiers[0] as any;\r\n if (only?.local?.name) {\r\n defaultExportLocalName = only.local.name;\r\n returnDefaultProperty = true;\r\n node.specifiers = [];\r\n }\r\n }\r\n }\r\n\r\n // Keep named exports after wrapper (same as prior behavior),\r\n // BUT do not keep empty export declarations.\r\n if (node.declaration || (node.specifiers && node.specifiers.length > 0)) {\r\n keptNamedExports.push(node);\r\n }\r\n\r\n path.remove();\r\n },\r\n },\r\n };\r\n}","// src/utils/generate-plugin-inputs.ts\r\nimport path from \"node:path\";\r\nimport * as fs from \"node:fs\";\r\n\r\nconst EXT_PATTERN = /\\.(tsx?|jsx?)$/i;\r\n\r\nexport type PluginInputs = Record<string, string>;\r\n\r\nexport type GeneratePluginInputsOptions = {\r\n /**\r\n * If true, also generates `app.tsx` that imports every discovered entry\r\n * (handy for dev/HMR).\r\n *\r\n * Default: true\r\n */\r\n writeAppEntry?: boolean;\r\n\r\n /**\r\n * Name of the generated app entry file (inside srcRoot).\r\n *\r\n * Default: \"app.tsx\"\r\n */\r\n appEntryName?: string;\r\n\r\n /**\r\n * Adds the generated app entry to the returned Rollup inputs map.\r\n *\r\n * Default: true\r\n */\r\n includeAppEntryInInputs?: boolean;\r\n\r\n /**\r\n * Key name used for the generated app entry in Rollup inputs.\r\n *\r\n * Default: \"__app_entry\"\r\n */\r\n appEntryKey?: string;\r\n\r\n /**\r\n * Extra directory names to ignore (case-insensitive).\r\n */\r\n ignoreDirs?: string[];\r\n\r\n /**\r\n * Extra “component-like” directory names to ignore (case-insensitive, exact match).\r\n */\r\n componentLikeDirs?: string[];\r\n\r\n /**\r\n * Whether to print discovered inputs to console.\r\n *\r\n * Default: true\r\n */\r\n verbose?: boolean;\r\n};\r\n\r\n// folders you typically never want as rollup inputs\r\nconst DEFAULT_IGNORE_DIRS = new Set<string>([\r\n \"node_modules\",\r\n \".git\",\r\n \".vite\",\r\n \".internal\",\r\n \"dist\",\r\n \"build\",\r\n \"public\",\r\n]);\r\n\r\n// “component-like” folders that should NOT produce entrypoints\r\n// Strict: exact folder-name matches only (case-insensitive)\r\nconst DEFAULT_COMPONENT_LIKE_DIRS = new Set<string>([\r\n \"component\",\r\n \"components\",\r\n \"ui\",\r\n \"uis\",\r\n \"widget\",\r\n \"widgets\",\r\n \"atom\",\r\n \"atoms\",\r\n \"molecule\",\r\n \"molecules\",\r\n \"organism\",\r\n \"organisms\",\r\n \"layout\",\r\n \"layouts\",\r\n \"partial\",\r\n \"partials\",\r\n]);\r\n\r\nfunction normalizeName(x: unknown): string {\r\n return String(x ?? \"\").toLowerCase();\r\n}\r\n\r\nfunction makeIgnoreSets(opts?: GeneratePluginInputsOptions): {\r\n ignoreDirs: Set<string>;\r\n componentLikeDirs: Set<string>;\r\n} {\r\n const ignoreDirs = new Set(DEFAULT_IGNORE_DIRS);\r\n const componentLikeDirs = new Set(DEFAULT_COMPONENT_LIKE_DIRS);\r\n\r\n for (const d of opts?.ignoreDirs ?? []) ignoreDirs.add(normalizeName(d));\r\n for (const d of opts?.componentLikeDirs ?? []) componentLikeDirs.add(normalizeName(d));\r\n\r\n return { ignoreDirs, componentLikeDirs };\r\n}\r\n\r\nfunction isIgnoredDir(\r\n dirName: string,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> }\r\n): boolean {\r\n const name = normalizeName(dirName);\r\n return sets.ignoreDirs.has(name) || sets.componentLikeDirs.has(name);\r\n}\r\n\r\n/**\r\n * Creates an app.tsx file that simply imports every discovered entry.\r\n * Helpful for HMR / dev mode.\r\n */\r\nfunction writeAppEntryFile(inputs: PluginInputs, srcRoot: string, appEntryName: string): void {\r\n const app = path.join(srcRoot, appEntryName);\r\n const lines: string[] = [\"// Auto-generated – do not edit\", \"\"];\r\n\r\n const entries = Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b));\r\n\r\n for (const [name, full] of entries) {\r\n const rel =\r\n \"./\" + path.relative(srcRoot, full).replace(/\\\\/g, \"/\").replace(EXT_PATTERN, \"\");\r\n\r\n const variable = name.replace(/[^a-zA-Z0-9_$]/g, \"_\").replace(/^(\\d)/, \"_$1\");\r\n\r\n lines.push(`import * as ${variable} from '${rel}';`);\r\n lines.push(`console.log('${name} loaded:', ${variable});`, \"\");\r\n }\r\n\r\n fs.writeFileSync(app, lines.join(\"\\n\"), \"utf8\");\r\n // eslint-disable-next-line no-console\r\n console.log(`✅ Generated ${appEntryName} in ${srcRoot}`);\r\n}\r\n\r\n/**\r\n * Convert a relative path like \"foo/bar/index.tsx\" to a dot key.\r\n * If `collapseIndex` is true, \"foo/bar/index\" becomes \"foo.bar\".\r\n * Otherwise it becomes \"foo.bar.index\".\r\n */\r\nfunction pathToKey(relNoExt: string, opts: { collapseIndex: boolean }): string {\r\n let normalized = relNoExt.replace(/\\\\/g, \"/\");\r\n\r\n if (opts.collapseIndex) {\r\n normalized = normalized.replace(/\\/index$/i, \"\");\r\n }\r\n\r\n let key = normalized.split(\"/\").filter(Boolean).join(\".\");\r\n if (!key) key = \"index\";\r\n return key;\r\n}\r\n\r\n/**\r\n * Recursively collect entry files under dirPath.\r\n *\r\n * Rule:\r\n * - Prefer collapsing \".../index.tsx\" => \"...\" for nicer keys\r\n * - BUT if that key would collide with another entry, fallback to explicit \"...index\"\r\n * (e.g. \"foo.index\") for the index file ONLY.\r\n */\r\nfunction crawl(\r\n dirPath: string,\r\n baseDir: string,\r\n acc: PluginInputs,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> },\r\n appEntryAbsPath: string\r\n): void {\r\n if (!fs.existsSync(dirPath)) return;\r\n\r\n for (const item of fs.readdirSync(dirPath)) {\r\n const full = path.join(dirPath, item);\r\n const stat = fs.statSync(full);\r\n\r\n if (stat.isDirectory()) {\r\n if (isIgnoredDir(item, sets)) continue;\r\n crawl(full, baseDir, acc, sets, appEntryAbsPath);\r\n continue;\r\n }\r\n\r\n if (!EXT_PATTERN.test(item)) continue;\r\n\r\n // Don't include the generated entry itself (prevents self-import)\r\n if (path.resolve(full) === path.resolve(appEntryAbsPath)) {\r\n continue;\r\n }\r\n\r\n const relNoExt = path.relative(baseDir, full).replace(EXT_PATTERN, \"\");\r\n const isIndexFile = /(^|[\\\\/])index$/i.test(relNoExt);\r\n\r\n // Preferred key: collapse \".../index\" => \"...\"\r\n const preferred = pathToKey(relNoExt, { collapseIndex: true });\r\n\r\n // Explicit key: keep \".../index\" => \"...index\"\r\n // Example: \"foo/index\" => \"foo.index\"\r\n const explicit = pathToKey(relNoExt, { collapseIndex: false });\r\n\r\n let name = preferred;\r\n\r\n // If preferred collides, ONLY the index file switches to explicit path key.\r\n const existing = acc[name];\r\n if (existing && path.resolve(existing) !== path.resolve(full)) {\r\n if (isIndexFile) {\r\n // Use foo.index (or deeper.path.index) instead of suffixing __2\r\n if (!acc[explicit]) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `⚠️ Key collision for \"${preferred}\" — using \"${explicit}\" for index file`,\r\n { existing: acc[preferred], incoming: full }\r\n );\r\n name = explicit;\r\n } else {\r\n // Extremely rare: even explicit collides (e.g. duplicate paths via symlinks)\r\n let i = 2;\r\n let next = `${explicit}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${explicit}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Key collision for \"${explicit}\" — using \"${next}\"`, {\r\n existing: acc[explicit],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n } else {\r\n // Non-index collision: suffix like original behavior\r\n let i = 2;\r\n let next = `${name}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${name}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Input key collision \"${name}\" -> using \"${next}\"`, {\r\n existing: acc[name],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n }\r\n\r\n acc[name] = full;\r\n }\r\n}\r\n\r\n/**\r\n * Discover integration pages/components and return a Rollup input map.\r\n *\r\n * @param srcRoot absolute or relative path to the source folder (e.g. \"resources/embed/ts\")\r\n * @param options\r\n * @returns Rollup input map: { [key]: absolutePath }\r\n */\r\nexport function generatePluginInputs(\r\n srcRoot: string = path.resolve(process.cwd(), \"ts\"),\r\n options: GeneratePluginInputsOptions = {}\r\n): PluginInputs {\r\n const {\r\n writeAppEntry = true,\r\n appEntryName = \"app.tsx\",\r\n includeAppEntryInInputs = true,\r\n appEntryKey = \"__app_entry\",\r\n verbose = true,\r\n } = options;\r\n\r\n const absRoot = path.resolve(srcRoot);\r\n const inputs: PluginInputs = {};\r\n\r\n const sets = makeIgnoreSets(options);\r\n const appEntryAbsPath = path.join(absRoot, appEntryName);\r\n\r\n // Crawl everything under absRoot (no folder assumptions)\r\n crawl(absRoot, absRoot, inputs, sets, appEntryAbsPath);\r\n\r\n if (verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"✅ Integrations discovered:\", inputs);\r\n }\r\n\r\n if (writeAppEntry) {\r\n writeAppEntryFile(inputs, absRoot, appEntryName);\r\n }\r\n\r\n if (!includeAppEntryInInputs) return inputs;\r\n\r\n return { ...inputs, [appEntryKey]: appEntryAbsPath };\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;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AI;AAAA,EAChB;AACJ;AASO,SAAS,qBACZ,UAAkB,kBAAAA,QAAK,QAAQ,QAAQ,IAAI,GAAG,IAAI,GAClD,UAAuC,CAAC,GAC5B;AACZ,QAAM;AAAA,IACF,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,0BAA0B;AAAA,IAC1B,cAAc;AAAA,IACd,UAAU;AAAA,EACd,IAAI;AAEJ,QAAM,UAAU,kBAAAA,QAAK,QAAQ,OAAO;AACpC,QAAM,SAAuB,CAAC;AAE9B,QAAM,OAAO,eAAe,OAAO;AACnC,QAAM,kBAAkB,kBAAAA,QAAK,KAAK,SAAS,YAAY;AAGvD,QAAM,SAAS,SAAS,QAAQ,MAAM,eAAe;AAErD,MAAI,SAAS;AAET,YAAQ,IAAI,mCAA8B,MAAM;AAAA,EACpD;AAEA,MAAI,eAAe;AACf,sBAAkB,QAAQ,SAAS,YAAY;AAAA,EACnD;AAEA,MAAI,CAAC,wBAAyB,QAAO;AAErC,SAAO,EAAE,GAAG,QAAQ,CAAC,WAAW,GAAG,gBAAgB;AACvD;","names":["path","shouldInject","resolvePath","import_node_path","path"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/vite/prep.ts","../src/babel/transform.ts","../src/utils/generate-plugin-inputs.ts"],"sourcesContent":["// src/index.ts\r\nexport {default} from \"./vite/prep\";\r\nexport type {FortiPrepOptions} from \"./vite/prep\";\r\nexport type {FortiPrepTransformOptions} from \"./babel/transform\";\r\n\r\n// ✅ add this:\r\nexport {default as fortiPrepTransform} from \"./babel/transform\";\r\nexport {generatePluginInputs as discoverEntrypoints} from './utils/generate-plugin-inputs'","import { transformSync } from \"@babel/core\";\r\nimport { readFileSync, writeFileSync } from \"node:fs\";\r\nimport { dirname, resolve as resolvePath } from \"node:path\";\r\nimport type {NormalizedOutputOptions, OutputBundle, OutputOptions} from \"rollup\";\r\nimport type { Plugin as VitePlugin } from \"vite\";\r\n\r\nimport fortiPrepTransform, {\r\n type FortiPrepTransformOptions,\r\n} from \"../babel/transform\";\r\n\r\nexport type FortiPrepOptions = FortiPrepTransformOptions & {\r\n /**\r\n * Which emitted entry file extensions should be rewritten.\r\n * Default: [\".js\", \".mjs\"]\r\n */\r\n entryExtensions?: string[];\r\n\r\n /**\r\n * Vite plugin name\r\n * Default: \"fortiplugin-prep\"\r\n */\r\n pluginName?: string;\r\n};\r\n\r\nconst DEFAULT_INJECTED_IDS = [\"react\", \"react/jsx-runtime\"] as const;\r\nconst DEFAULT_INJECTED_PREFIXES = [\"@inertiajs/\", \"@host/\"] as const;\r\n\r\nfunction resolveOutDir(outputOptions: OutputOptions): string | null {\r\n if (outputOptions.dir) return outputOptions.dir;\r\n if (outputOptions.file) return dirname(outputOptions.file);\r\n return null;\r\n}\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\n/**\r\n * FortiPlugin bundle adapter:\r\n * - marks injected imports as Rollup externals (so they survive into output)\r\n * - rewrites built entry chunks to remove those imports and load them from runtime deps\r\n */\r\nexport default function prep(options: FortiPrepOptions = {}): VitePlugin {\r\n const injectedIds = options.injectedIds ?? [...DEFAULT_INJECTED_IDS];\r\n const injectedPrefixes = options.injectedPrefixes ?? [...DEFAULT_INJECTED_PREFIXES];\r\n\r\n const runtimeKey = options.runtimeKey ?? \"imports\";\r\n const depsParam = options.depsParam ?? \"deps\";\r\n\r\n const entryExtensions = options.entryExtensions ?? [\".js\", \".mjs\"];\r\n const pluginName = options.pluginName ?? \"fortiplugin-prep\";\r\n\r\n const transformOptions: FortiPrepTransformOptions = {\r\n injectedIds,\r\n injectedPrefixes,\r\n runtimeKey,\r\n depsParam,\r\n };\r\n\r\n return {\r\n name: pluginName,\r\n apply: \"build\",\r\n\r\n config() {\r\n return {\r\n define: {\r\n \"process.env.NODE_ENV\": '\"production\"',\r\n },\r\n build: {\r\n rollupOptions: {\r\n // Ensure virtual imports don't need to resolve.\r\n external: (id: string) => shouldInject(id, transformOptions),\r\n },\r\n },\r\n };\r\n },\r\n\r\n writeBundle(outputOptions: NormalizedOutputOptions, bundle: OutputBundle) {\r\n const outDir = resolveOutDir(outputOptions);\r\n if (!outDir) return;\r\n\r\n for (const [fileName, item] of Object.entries(bundle)) {\r\n if (item.type !== \"chunk\") continue;\r\n if (!item.isEntry) continue;\r\n\r\n if (!entryExtensions.some((ext) => fileName.endsWith(ext))) continue;\r\n\r\n const absPath = resolvePath(outDir, fileName);\r\n const input = readFileSync(absPath, \"utf-8\");\r\n\r\n const result = transformSync(input, {\r\n filename: absPath,\r\n sourceType: \"module\",\r\n // Fresh plugin instance per file (Babel calls plugin factory per file when passed as [fn, opts])\r\n plugins: [[fortiPrepTransform as any, transformOptions]],\r\n generatorOpts: {\r\n compact: false,\r\n comments: true,\r\n retainLines: false,\r\n },\r\n });\r\n\r\n if (!result?.code) continue;\r\n writeFileSync(absPath, result.code, \"utf-8\");\r\n }\r\n },\r\n };\r\n}","// noinspection JSUnusedGlobalSymbols,GrazieInspection\r\n\r\nimport type { PluginObj } from \"@babel/core\";\r\nimport * as t from \"@babel/types\";\r\nimport type { NodePath } from \"@babel/traverse\";\r\n\r\nexport type FortiPrepTransformOptions = {\r\n injectedIds?: string[];\r\n injectedPrefixes?: string[];\r\n runtimeKey?: string;\r\n depsParam?: string;\r\n onMissingDefault?: \"skip\" | \"return-null\" | \"throw\";\r\n};\r\n\r\nconst DEFAULTS: Required<Pick<FortiPrepTransformOptions, \"runtimeKey\" | \"depsParam\" | \"onMissingDefault\">> = {\r\n runtimeKey: \"imports\",\r\n depsParam: \"deps\",\r\n onMissingDefault: \"skip\",\r\n};\r\n\r\nconst DEFAULT_EXPORT_ERROR =\r\n \"PROBLEM!!, No known default function was found, your code either possesses NO named default export or this export format is currently not supported.\";\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\ntype CapturedImport =\r\n | { kind: \"default\"; local: string }\r\n | { kind: \"namespace\"; local: string }\r\n | { kind: \"named\"; imported: string; local: string };\r\n\r\nfunction getImportedName(spec: t.ImportSpecifier): string {\r\n return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;\r\n}\r\n\r\nfunction makeImportMapExpr(depsIdent: t.Identifier, runtimeKey: string): t.Expression {\r\n const hasKey = t.binaryExpression(\"in\", t.stringLiteral(runtimeKey), depsIdent);\r\n\r\n const isObj = t.logicalExpression(\r\n \"&&\",\r\n t.binaryExpression(\"!==\", depsIdent, t.nullLiteral()),\r\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", depsIdent), t.stringLiteral(\"object\"))\r\n );\r\n\r\n const test = t.logicalExpression(\"&&\", isObj, hasKey);\r\n const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));\r\n const fallback = t.logicalExpression(\"||\", depsIdent, t.objectExpression([]));\r\n\r\n return t.conditionalExpression(test, depsKey, fallback);\r\n}\r\n\r\n/**\r\n * Detects Rollup namespace wrapper variable:\r\n * const M = Object.freeze(Object.defineProperty({ __proto__: null, default: x }, Symbol.toStringTag, { value:\"Module\" }));\r\n */\r\nfunction looksLikeRollupNamespaceWrapper(init: t.Expression | null | undefined): boolean {\r\n if (!init || !t.isCallExpression(init)) return false;\r\n\r\n // Object.freeze(...)\r\n if (!t.isMemberExpression(init.callee)) return false;\r\n if (!t.isIdentifier(init.callee.object, { name: \"Object\" })) return false;\r\n if (!t.isIdentifier(init.callee.property, { name: \"freeze\" })) return false;\r\n\r\n const arg0 = init.arguments[0];\r\n if (!t.isCallExpression(arg0)) return false;\r\n\r\n // Object.defineProperty(...)\r\n if (!t.isMemberExpression(arg0.callee)) return false;\r\n if (!t.isIdentifier(arg0.callee.object, { name: \"Object\" })) return false;\r\n if (!t.isIdentifier(arg0.callee.property, { name: \"defineProperty\" })) return false;\r\n\r\n const objArg = arg0.arguments[0];\r\n if (!t.isObjectExpression(objArg)) return false;\r\n\r\n // must contain a \"default\" property\r\n const hasDefault = objArg.properties.some((p) => {\r\n if (!t.isObjectProperty(p)) return false;\r\n if (t.isIdentifier(p.key)) return p.key.name === \"default\";\r\n if (t.isStringLiteral(p.key)) return p.key.value === \"default\";\r\n return false;\r\n });\r\n\r\n return hasDefault;\r\n}\r\n\r\nfunction inferDefaultFromSingleNamedExport(program: t.Program): { local: string; returnDefaultProperty: boolean } | null {\r\n // If there's exactly one named export specifier, it's often the namespace container:\r\n // export { M as k };\r\n // Return M.default\r\n const exports: t.ExportNamedDeclaration[] = program.body.filter((s): s is t.ExportNamedDeclaration =>\r\n t.isExportNamedDeclaration(s)\r\n );\r\n\r\n for (const ex of exports) {\r\n if (!ex.specifiers || ex.specifiers.length !== 1) continue;\r\n\r\n const spec = ex.specifiers[0];\r\n if (!t.isExportSpecifier(spec)) continue;\r\n if (!t.isIdentifier(spec.local)) continue;\r\n\r\n const localName = spec.local.name;\r\n\r\n // Safety: only accept if we can find a matching variable declaration that looks like a Rollup namespace wrapper\r\n let ok = false;\r\n for (const stmt of program.body) {\r\n if (!t.isVariableDeclaration(stmt)) continue;\r\n for (const d of stmt.declarations) {\r\n if (!t.isIdentifier(d.id, { name: localName })) continue;\r\n if (looksLikeRollupNamespaceWrapper(d.init as any)) ok = true;\r\n }\r\n }\r\n\r\n if (ok) {\r\n return { local: localName, returnDefaultProperty: true };\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Babel plugin factory\r\n */\r\nexport default function fortiPrepTransform(_api: unknown, rawOpts: FortiPrepTransformOptions = {}): PluginObj {\r\n const opts: FortiPrepTransformOptions = {\r\n ...rawOpts,\r\n runtimeKey: rawOpts.runtimeKey ?? DEFAULTS.runtimeKey,\r\n depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,\r\n onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault,\r\n };\r\n\r\n // We defer all mutations until Program.exit\r\n const removedPaths: NodePath[] = [];\r\n const replacedExports: Array<{ path: NodePath<t.ExportDefaultDeclaration>; replacement: t.Statement }> = [];\r\n\r\n const keptImports: t.ImportDeclaration[] = [];\r\n const keptNamedExports: t.ExportNamedDeclaration[] = [];\r\n const injectedImportsById = new Map<string, CapturedImport[]>();\r\n\r\n let defaultExportLocalName: string | null = null;\r\n let returnDefaultProperty = false;\r\n\r\n function captureImport(importId: string, entry: CapturedImport) {\r\n const list = injectedImportsById.get(importId) ?? [];\r\n list.push(entry);\r\n injectedImportsById.set(importId, list);\r\n }\r\n\r\n return {\r\n name: \"fortiplugin-prep/transform\",\r\n visitor: {\r\n Program: {\r\n exit(path: NodePath<t.Program>) {\r\n const program = path.node;\r\n\r\n // Apply deferred replacements/removals so we can decide to skip cleanly.\r\n // But only AFTER we determine if we're wrapping.\r\n\r\n // 1) If we still don't have a default, try inference for rollup wrapper exports.\r\n if (!defaultExportLocalName) {\r\n const inferred = inferDefaultFromSingleNamedExport(program);\r\n if (inferred) {\r\n defaultExportLocalName = inferred.local;\r\n returnDefaultProperty = inferred.returnDefaultProperty;\r\n }\r\n }\r\n\r\n // 2) Decide behavior if still missing\r\n if (!defaultExportLocalName) {\r\n const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;\r\n if (behavior === \"throw\") throw path.buildCodeFrameError(DEFAULT_EXPORT_ERROR);\r\n if (behavior === \"skip\") {\r\n // Do nothing: leave the program untouched\r\n return;\r\n }\r\n // return-null => wrap but return null\r\n }\r\n\r\n // 3) Now that we WILL wrap, perform deferred mutations\r\n for (const { path: exPath, replacement } of replacedExports) {\r\n exPath.replaceWith(replacement as any);\r\n }\r\n for (const p of removedPaths) {\r\n if (p.removed) continue;\r\n p.remove();\r\n }\r\n\r\n const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);\r\n const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;\r\n\r\n const importsIdent = t.identifier(\"__imports\");\r\n const importsInit = makeImportMapExpr(depsIdent, runtimeKey);\r\n const importsDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(importsIdent, importsInit),\r\n ]);\r\n\r\n const defaultHelperIdent = t.identifier(\"__default\");\r\n const defaultHelperDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n defaultHelperIdent,\r\n t.arrowFunctionExpression(\r\n [t.identifier(\"m\")],\r\n t.conditionalExpression(\r\n t.logicalExpression(\r\n \"&&\",\r\n t.logicalExpression(\r\n \"&&\",\r\n t.identifier(\"m\"),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", t.identifier(\"m\")),\r\n t.stringLiteral(\"object\")\r\n )\r\n ),\r\n t.binaryExpression(\"in\", t.stringLiteral(\"default\"), t.identifier(\"m\"))\r\n ),\r\n t.memberExpression(t.identifier(\"m\"), t.identifier(\"default\")),\r\n t.identifier(\"m\")\r\n )\r\n )\r\n ),\r\n ]);\r\n\r\n const injectedStmts: t.Statement[] = [importsDecl, defaultHelperDecl];\r\n\r\n for (const [importId, specs] of injectedImportsById.entries()) {\r\n const modIdent = t.identifier(`__m_${importId.replace(/[^a-zA-Z0-9_$]/g, \"_\")}`);\r\n\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n modIdent,\r\n t.memberExpression(importsIdent, t.stringLiteral(importId), true)\r\n ),\r\n ])\r\n );\r\n\r\n const named: Array<{ imported: string; local: string }> = [];\r\n\r\n for (const s of specs) {\r\n if (s.kind === \"default\") {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.identifier(s.local),\r\n t.callExpression(defaultHelperIdent, [modIdent])\r\n ),\r\n ])\r\n );\r\n } else if (s.kind === \"namespace\") {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(t.identifier(s.local), modIdent),\r\n ])\r\n );\r\n } else {\r\n named.push({ imported: s.imported, local: s.local });\r\n }\r\n }\r\n\r\n if (named.length) {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.objectPattern(\r\n named.map(({ imported, local }) =>\r\n t.objectProperty(\r\n t.identifier(imported),\r\n t.identifier(local),\r\n false,\r\n imported === local\r\n )\r\n )\r\n ),\r\n t.logicalExpression(\"||\", modIdent, t.objectExpression([]))\r\n ),\r\n ])\r\n );\r\n }\r\n }\r\n\r\n const returnExpr =\r\n defaultExportLocalName == null\r\n ? t.nullLiteral()\r\n : returnDefaultProperty\r\n ? t.memberExpression(t.identifier(defaultExportLocalName), t.identifier(\"default\"))\r\n : t.identifier(defaultExportLocalName);\r\n\r\n const wrapperBody: t.Statement[] = [];\r\n wrapperBody.push(...injectedStmts);\r\n wrapperBody.push(...program.body);\r\n wrapperBody.push(t.returnStatement(returnExpr));\r\n\r\n const wrapper = t.exportDefaultDeclaration(\r\n t.functionDeclaration(null, [depsIdent], t.blockStatement(wrapperBody))\r\n );\r\n\r\n program.body = [...keptImports, wrapper, ...keptNamedExports] as any;\r\n },\r\n },\r\n\r\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\r\n const node = path.node;\r\n const importId = node.source.value;\r\n\r\n if (!shouldInject(importId, opts)) {\r\n keptImports.push(node);\r\n removedPaths.push(path);\r\n return;\r\n }\r\n\r\n for (const s of node.specifiers) {\r\n if (t.isImportDefaultSpecifier(s)) {\r\n captureImport(importId, { kind: \"default\", local: s.local.name });\r\n } else if (t.isImportNamespaceSpecifier(s)) {\r\n captureImport(importId, { kind: \"namespace\", local: s.local.name });\r\n } else if (t.isImportSpecifier(s)) {\r\n captureImport(importId, {\r\n kind: \"named\",\r\n imported: getImportedName(s),\r\n local: s.local.name,\r\n });\r\n }\r\n }\r\n\r\n removedPaths.push(path);\r\n },\r\n\r\n ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {\r\n const decl = path.node.declaration;\r\n\r\n if (t.isIdentifier(decl)) {\r\n defaultExportLocalName = decl.name;\r\n removedPaths.push(path);\r\n return;\r\n }\r\n\r\n if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {\r\n if (!decl.id) {\r\n decl.id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n }\r\n defaultExportLocalName = decl.id.name;\r\n // Replace export default decl with the decl itself (deferred)\r\n replacedExports.push({ path, replacement: decl as any });\r\n return;\r\n }\r\n\r\n // export default (expr/arrow/etc)\r\n const id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n defaultExportLocalName = id.name;\r\n\r\n const replacement = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(id, decl as t.Expression),\r\n ]);\r\n\r\n replacedExports.push({ path, replacement });\r\n },\r\n\r\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\r\n const node = path.node;\r\n\r\n if (node.specifiers?.length) {\r\n let foundExplicitDefault = false;\r\n\r\n node.specifiers = node.specifiers.filter((spec) => {\r\n const exported = t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value;\r\n\r\n if (exported === \"default\") {\r\n const local = (spec as any)?.local?.name as string | undefined;\r\n if (local) defaultExportLocalName = local;\r\n foundExplicitDefault = true;\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n\r\n if (!foundExplicitDefault && !defaultExportLocalName && node.specifiers.length === 1) {\r\n const only = node.specifiers[0] as any;\r\n if (only?.local?.name) {\r\n defaultExportLocalName = only.local.name;\r\n returnDefaultProperty = true;\r\n node.specifiers = [];\r\n }\r\n }\r\n }\r\n\r\n if (node.declaration || (node.specifiers && node.specifiers.length > 0)) {\r\n keptNamedExports.push(node);\r\n }\r\n\r\n removedPaths.push(path);\r\n },\r\n },\r\n };\r\n}","// src/utils/generate-plugin-inputs.ts\r\nimport path from \"node:path\";\r\nimport * as fs from \"node:fs\";\r\n\r\nconst EXT_PATTERN = /\\.(tsx?|jsx?)$/i;\r\n\r\nexport type PluginInputs = Record<string, string>;\r\n\r\nexport type GeneratePluginInputsOptions = {\r\n /**\r\n * If true, also generates `app.tsx` that imports every discovered entry\r\n * (handy for dev/HMR).\r\n *\r\n * Default: true\r\n */\r\n writeAppEntry?: boolean;\r\n\r\n /**\r\n * Name of the generated app entry file (inside srcRoot).\r\n *\r\n * Default: \"app.tsx\"\r\n */\r\n appEntryName?: string;\r\n\r\n /**\r\n * Adds the generated app entry to the returned Rollup inputs map.\r\n *\r\n * Default: true\r\n */\r\n includeAppEntryInInputs?: boolean;\r\n\r\n /**\r\n * Key name used for the generated app entry in Rollup inputs.\r\n *\r\n * Default: \"__app_entry\"\r\n */\r\n appEntryKey?: string;\r\n\r\n /**\r\n * Extra directory names to ignore (case-insensitive).\r\n */\r\n ignoreDirs?: string[];\r\n\r\n /**\r\n * Extra “component-like” directory names to ignore (case-insensitive, exact match).\r\n */\r\n componentLikeDirs?: string[];\r\n\r\n /**\r\n * Whether to print discovered inputs to console.\r\n *\r\n * Default: true\r\n */\r\n verbose?: boolean;\r\n};\r\n\r\n// folders you typically never want as rollup inputs\r\nconst DEFAULT_IGNORE_DIRS = new Set<string>([\r\n \"node_modules\",\r\n \".git\",\r\n \".vite\",\r\n \".internal\",\r\n \"dist\",\r\n \"build\",\r\n \"public\",\r\n]);\r\n\r\n// “component-like” folders that should NOT produce entrypoints\r\n// Strict: exact folder-name matches only (case-insensitive)\r\nconst DEFAULT_COMPONENT_LIKE_DIRS = new Set<string>([\r\n \"component\",\r\n \"components\",\r\n \"ui\",\r\n \"uis\",\r\n \"widget\",\r\n \"widgets\",\r\n \"atom\",\r\n \"atoms\",\r\n \"molecule\",\r\n \"molecules\",\r\n \"organism\",\r\n \"organisms\",\r\n \"layout\",\r\n \"layouts\",\r\n \"partial\",\r\n \"partials\",\r\n]);\r\n\r\nfunction normalizeName(x: unknown): string {\r\n return String(x ?? \"\").toLowerCase();\r\n}\r\n\r\nfunction makeIgnoreSets(opts?: GeneratePluginInputsOptions): {\r\n ignoreDirs: Set<string>;\r\n componentLikeDirs: Set<string>;\r\n} {\r\n const ignoreDirs = new Set(DEFAULT_IGNORE_DIRS);\r\n const componentLikeDirs = new Set(DEFAULT_COMPONENT_LIKE_DIRS);\r\n\r\n for (const d of opts?.ignoreDirs ?? []) ignoreDirs.add(normalizeName(d));\r\n for (const d of opts?.componentLikeDirs ?? []) componentLikeDirs.add(normalizeName(d));\r\n\r\n return { ignoreDirs, componentLikeDirs };\r\n}\r\n\r\nfunction isIgnoredDir(\r\n dirName: string,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> }\r\n): boolean {\r\n const name = normalizeName(dirName);\r\n return sets.ignoreDirs.has(name) || sets.componentLikeDirs.has(name);\r\n}\r\n\r\n/**\r\n * Creates an app.tsx file that simply imports every discovered entry.\r\n * Helpful for HMR / dev mode.\r\n */\r\nfunction writeAppEntryFile(inputs: PluginInputs, srcRoot: string, appEntryName: string): void {\r\n const app = path.join(srcRoot, appEntryName);\r\n const lines: string[] = [\"// Auto-generated – do not edit\", \"\"];\r\n\r\n const entries = Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b));\r\n\r\n for (const [name, full] of entries) {\r\n const rel =\r\n \"./\" + path.relative(srcRoot, full).replace(/\\\\/g, \"/\").replace(EXT_PATTERN, \"\");\r\n\r\n const variable = name.replace(/[^a-zA-Z0-9_$]/g, \"_\").replace(/^(\\d)/, \"_$1\");\r\n\r\n lines.push(`import * as ${variable} from '${rel}';`);\r\n lines.push(`console.log('${name} loaded:', ${variable});`, \"\");\r\n }\r\n\r\n fs.writeFileSync(app, lines.join(\"\\n\"), \"utf8\");\r\n // eslint-disable-next-line no-console\r\n console.log(`✅ Generated ${appEntryName} in ${srcRoot}`);\r\n}\r\n\r\n/**\r\n * Convert a relative path like \"foo/bar/index.tsx\" to a dot key.\r\n * If `collapseIndex` is true, \"foo/bar/index\" becomes \"foo.bar\".\r\n * Otherwise it becomes \"foo.bar.index\".\r\n */\r\nfunction pathToKey(relNoExt: string, opts: { collapseIndex: boolean }): string {\r\n let normalized = relNoExt.replace(/\\\\/g, \"/\");\r\n\r\n if (opts.collapseIndex) {\r\n normalized = normalized.replace(/\\/index$/i, \"\");\r\n }\r\n\r\n let key = normalized.split(\"/\").filter(Boolean).join(\".\");\r\n if (!key) key = \"index\";\r\n return key;\r\n}\r\n\r\n/**\r\n * Recursively collect entry files under dirPath.\r\n *\r\n * Rule:\r\n * - Prefer collapsing \".../index.tsx\" => \"...\" for nicer keys\r\n * - BUT if that key would collide with another entry, fallback to explicit \"...index\"\r\n * (e.g. \"foo.index\") for the index file ONLY.\r\n */\r\nfunction crawl(\r\n dirPath: string,\r\n baseDir: string,\r\n acc: PluginInputs,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> },\r\n appEntryAbsPath: string\r\n): void {\r\n if (!fs.existsSync(dirPath)) return;\r\n\r\n for (const item of fs.readdirSync(dirPath)) {\r\n const full = path.join(dirPath, item);\r\n const stat = fs.statSync(full);\r\n\r\n if (stat.isDirectory()) {\r\n if (isIgnoredDir(item, sets)) continue;\r\n crawl(full, baseDir, acc, sets, appEntryAbsPath);\r\n continue;\r\n }\r\n\r\n if (!EXT_PATTERN.test(item)) continue;\r\n\r\n // Don't include the generated entry itself (prevents self-import)\r\n if (path.resolve(full) === path.resolve(appEntryAbsPath)) {\r\n continue;\r\n }\r\n\r\n const relNoExt = path.relative(baseDir, full).replace(EXT_PATTERN, \"\");\r\n const isIndexFile = /(^|[\\\\/])index$/i.test(relNoExt);\r\n\r\n // Preferred key: collapse \".../index\" => \"...\"\r\n const preferred = pathToKey(relNoExt, { collapseIndex: true });\r\n\r\n // Explicit key: keep \".../index\" => \"...index\"\r\n // Example: \"foo/index\" => \"foo.index\"\r\n const explicit = pathToKey(relNoExt, { collapseIndex: false });\r\n\r\n let name = preferred;\r\n\r\n // If preferred collides, ONLY the index file switches to explicit path key.\r\n const existing = acc[name];\r\n if (existing && path.resolve(existing) !== path.resolve(full)) {\r\n if (isIndexFile) {\r\n // Use foo.index (or deeper.path.index) instead of suffixing __2\r\n if (!acc[explicit]) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `⚠️ Key collision for \"${preferred}\" — using \"${explicit}\" for index file`,\r\n { existing: acc[preferred], incoming: full }\r\n );\r\n name = explicit;\r\n } else {\r\n // Extremely rare: even explicit collides (e.g. duplicate paths via symlinks)\r\n let i = 2;\r\n let next = `${explicit}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${explicit}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Key collision for \"${explicit}\" — using \"${next}\"`, {\r\n existing: acc[explicit],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n } else {\r\n // Non-index collision: suffix like original behavior\r\n let i = 2;\r\n let next = `${name}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${name}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Input key collision \"${name}\" -> using \"${next}\"`, {\r\n existing: acc[name],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n }\r\n\r\n acc[name] = full;\r\n }\r\n}\r\n\r\n/**\r\n * Discover integration pages/components and return a Rollup input map.\r\n *\r\n * @param srcRoot absolute or relative path to the source folder (e.g. \"resources/embed/ts\")\r\n * @param options\r\n * @returns Rollup input map: { [key]: absolutePath }\r\n */\r\nexport function generatePluginInputs(\r\n srcRoot: string = path.resolve(process.cwd(), \"ts\"),\r\n options: GeneratePluginInputsOptions = {}\r\n): PluginInputs {\r\n const {\r\n writeAppEntry = false,\r\n appEntryName = \"app.tsx\",\r\n includeAppEntryInInputs = false,\r\n appEntryKey = \"__app_entry\",\r\n verbose = true,\r\n } = options;\r\n\r\n const absRoot = path.resolve(srcRoot);\r\n const inputs: PluginInputs = {};\r\n\r\n const sets = makeIgnoreSets(options);\r\n const appEntryAbsPath = path.join(absRoot, appEntryName);\r\n\r\n // Crawl everything under absRoot (no folder assumptions)\r\n crawl(absRoot, absRoot, inputs, sets, appEntryAbsPath);\r\n\r\n if (verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"✅ Integrations discovered:\", inputs);\r\n }\r\n\r\n if (writeAppEntry) {\r\n writeAppEntryFile(inputs, absRoot, appEntryName);\r\n }\r\n\r\n if (!includeAppEntryInInputs) return inputs;\r\n\r\n return { ...inputs, [appEntryKey]: appEntryAbsPath };\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA8B;AAC9B,qBAA4C;AAC5C,uBAAgD;;;ACChD,QAAmB;AAWnB,IAAM,WAAuG;AAAA,EACzG,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,kBAAkB;AACtB;AAEA,IAAM,uBACF;AAEJ,SAAS,aAAa,IAAY,MAA0C;AACxE,QAAM,MAAM,KAAK,eAAe,CAAC;AACjC,QAAM,WAAW,KAAK,oBAAoB,CAAC;AAC3C,MAAI,IAAI,SAAS,EAAE,EAAG,QAAO;AAC7B,aAAW,KAAK,SAAU,KAAI,GAAG,WAAW,CAAC,EAAG,QAAO;AACvD,SAAO;AACX;AAOA,SAAS,gBAAgB,MAAiC;AACtD,SAAS,eAAa,KAAK,QAAQ,IAAI,KAAK,SAAS,OAAO,KAAK,SAAS;AAC9E;AAEA,SAAS,kBAAkB,WAAyB,YAAkC;AAClF,QAAM,SAAW,mBAAiB,MAAQ,gBAAc,UAAU,GAAG,SAAS;AAE9E,QAAM,QAAU;AAAA,IACZ;AAAA,IACE,mBAAiB,OAAO,WAAa,cAAY,CAAC;AAAA,IAClD,mBAAiB,OAAS,kBAAgB,UAAU,SAAS,GAAK,gBAAc,QAAQ,CAAC;AAAA,EAC/F;AAEA,QAAM,OAAS,oBAAkB,MAAM,OAAO,MAAM;AACpD,QAAM,UAAY,mBAAiB,W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names":["exports","path","shouldInject","resolvePath","import_node_path","path"]}
package/dist/index.d.mts CHANGED
@@ -2,39 +2,14 @@ import { Plugin } from 'vite';
2
2
  import { PluginObj } from '@babel/core';
3
3
 
4
4
  type FortiPrepTransformOptions = {
5
- /**
6
- * Exact import ids to inject (removed from bundle and loaded from runtime deps).
7
- * Example: ["react", "react/jsx-runtime", "@host/ui"]
8
- */
9
5
  injectedIds?: string[];
10
- /**
11
- * Prefix import ids to inject.
12
- * Example: ["@host/", "@inertiajs/"]
13
- */
14
6
  injectedPrefixes?: string[];
15
- /**
16
- * The key on the deps object used as the import map.
17
- * Wrapper supports passing deps.imports OR passing the import map directly.
18
- *
19
- * Default: "imports"
20
- */
21
7
  runtimeKey?: string;
22
- /**
23
- * Wrapper function parameter name.
24
- * Default: "deps"
25
- */
26
8
  depsParam?: string;
27
- /**
28
- * What to do if we can't determine a default export to return.
29
- *
30
- * - "skip": do nothing (leave file untouched) ✅ default
31
- * - "return-null": still wrap, but return null
32
- * - "throw": fail the build (old behavior)
33
- */
34
9
  onMissingDefault?: "skip" | "return-null" | "throw";
35
10
  };
36
11
  /**
37
- * Babel plugin factory (Babel calls this per-file when used as `[plugin, options]`).
12
+ * Babel plugin factory
38
13
  */
39
14
  declare function fortiPrepTransform(_api: unknown, rawOpts?: FortiPrepTransformOptions): PluginObj;
40
15
 
package/dist/index.d.ts CHANGED
@@ -2,39 +2,14 @@ import { Plugin } from 'vite';
2
2
  import { PluginObj } from '@babel/core';
3
3
 
4
4
  type FortiPrepTransformOptions = {
5
- /**
6
- * Exact import ids to inject (removed from bundle and loaded from runtime deps).
7
- * Example: ["react", "react/jsx-runtime", "@host/ui"]
8
- */
9
5
  injectedIds?: string[];
10
- /**
11
- * Prefix import ids to inject.
12
- * Example: ["@host/", "@inertiajs/"]
13
- */
14
6
  injectedPrefixes?: string[];
15
- /**
16
- * The key on the deps object used as the import map.
17
- * Wrapper supports passing deps.imports OR passing the import map directly.
18
- *
19
- * Default: "imports"
20
- */
21
7
  runtimeKey?: string;
22
- /**
23
- * Wrapper function parameter name.
24
- * Default: "deps"
25
- */
26
8
  depsParam?: string;
27
- /**
28
- * What to do if we can't determine a default export to return.
29
- *
30
- * - "skip": do nothing (leave file untouched) ✅ default
31
- * - "return-null": still wrap, but return null
32
- * - "throw": fail the build (old behavior)
33
- */
34
9
  onMissingDefault?: "skip" | "return-null" | "throw";
35
10
  };
36
11
  /**
37
- * Babel plugin factory (Babel calls this per-file when used as `[plugin, options]`).
12
+ * Babel plugin factory
38
13
  */
39
14
  declare function fortiPrepTransform(_api: unknown, rawOpts?: FortiPrepTransformOptions): PluginObj;
40
15
 
package/dist/index.mjs CHANGED
@@ -18,18 +18,6 @@ function shouldInject(id, opts) {
18
18
  for (const p of prefixes) if (id.startsWith(p)) return true;
19
19
  return false;
20
20
  }
21
- function programHasDefaultExport(p) {
22
- for (const stmt of p.body) {
23
- if (t.isExportDefaultDeclaration(stmt)) return true;
24
- if (t.isExportNamedDeclaration(stmt) && stmt.specifiers?.length) {
25
- for (const spec of stmt.specifiers) {
26
- const exported = t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value;
27
- if (exported === "default") return true;
28
- }
29
- }
30
- }
31
- return false;
32
- }
33
21
  function getImportedName(spec) {
34
22
  return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;
35
23
  }
@@ -38,17 +26,57 @@ function makeImportMapExpr(depsIdent, runtimeKey) {
38
26
  const isObj = t.logicalExpression(
39
27
  "&&",
40
28
  t.binaryExpression("!==", depsIdent, t.nullLiteral()),
41
- t.binaryExpression(
42
- "===",
43
- t.unaryExpression("typeof", depsIdent),
44
- t.stringLiteral("object")
45
- )
29
+ t.binaryExpression("===", t.unaryExpression("typeof", depsIdent), t.stringLiteral("object"))
46
30
  );
47
31
  const test = t.logicalExpression("&&", isObj, hasKey);
48
32
  const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));
49
33
  const fallback = t.logicalExpression("||", depsIdent, t.objectExpression([]));
50
34
  return t.conditionalExpression(test, depsKey, fallback);
51
35
  }
36
+ function looksLikeRollupNamespaceWrapper(init) {
37
+ if (!init || !t.isCallExpression(init)) return false;
38
+ if (!t.isMemberExpression(init.callee)) return false;
39
+ if (!t.isIdentifier(init.callee.object, { name: "Object" })) return false;
40
+ if (!t.isIdentifier(init.callee.property, { name: "freeze" })) return false;
41
+ const arg0 = init.arguments[0];
42
+ if (!t.isCallExpression(arg0)) return false;
43
+ if (!t.isMemberExpression(arg0.callee)) return false;
44
+ if (!t.isIdentifier(arg0.callee.object, { name: "Object" })) return false;
45
+ if (!t.isIdentifier(arg0.callee.property, { name: "defineProperty" })) return false;
46
+ const objArg = arg0.arguments[0];
47
+ if (!t.isObjectExpression(objArg)) return false;
48
+ const hasDefault = objArg.properties.some((p) => {
49
+ if (!t.isObjectProperty(p)) return false;
50
+ if (t.isIdentifier(p.key)) return p.key.name === "default";
51
+ if (t.isStringLiteral(p.key)) return p.key.value === "default";
52
+ return false;
53
+ });
54
+ return hasDefault;
55
+ }
56
+ function inferDefaultFromSingleNamedExport(program) {
57
+ const exports = program.body.filter(
58
+ (s) => t.isExportNamedDeclaration(s)
59
+ );
60
+ for (const ex of exports) {
61
+ if (!ex.specifiers || ex.specifiers.length !== 1) continue;
62
+ const spec = ex.specifiers[0];
63
+ if (!t.isExportSpecifier(spec)) continue;
64
+ if (!t.isIdentifier(spec.local)) continue;
65
+ const localName = spec.local.name;
66
+ let ok = false;
67
+ for (const stmt of program.body) {
68
+ if (!t.isVariableDeclaration(stmt)) continue;
69
+ for (const d of stmt.declarations) {
70
+ if (!t.isIdentifier(d.id, { name: localName })) continue;
71
+ if (looksLikeRollupNamespaceWrapper(d.init)) ok = true;
72
+ }
73
+ }
74
+ if (ok) {
75
+ return { local: localName, returnDefaultProperty: true };
76
+ }
77
+ }
78
+ return null;
79
+ }
52
80
  function fortiPrepTransform(_api, rawOpts = {}) {
53
81
  const opts = {
54
82
  ...rawOpts,
@@ -56,7 +84,8 @@ function fortiPrepTransform(_api, rawOpts = {}) {
56
84
  depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,
57
85
  onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault
58
86
  };
59
- let enabled = true;
87
+ const removedPaths = [];
88
+ const replacedExports = [];
60
89
  const keptImports = [];
61
90
  const keptNamedExports = [];
62
91
  const injectedImportsById = /* @__PURE__ */ new Map();
@@ -71,21 +100,28 @@ function fortiPrepTransform(_api, rawOpts = {}) {
71
100
  name: "fortiplugin-prep/transform",
72
101
  visitor: {
73
102
  Program: {
74
- enter(path2) {
75
- const hasDefault = programHasDefaultExport(path2.node);
76
- if (!hasDefault && (opts.onMissingDefault ?? DEFAULTS.onMissingDefault) === "skip") {
77
- enabled = false;
78
- }
79
- },
80
103
  exit(path2) {
81
- if (!enabled) return;
82
104
  const program = path2.node;
105
+ if (!defaultExportLocalName) {
106
+ const inferred = inferDefaultFromSingleNamedExport(program);
107
+ if (inferred) {
108
+ defaultExportLocalName = inferred.local;
109
+ returnDefaultProperty = inferred.returnDefaultProperty;
110
+ }
111
+ }
83
112
  if (!defaultExportLocalName) {
84
113
  const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;
85
- if (behavior === "throw") {
86
- throw path2.buildCodeFrameError(DEFAULT_EXPORT_ERROR);
114
+ if (behavior === "throw") throw path2.buildCodeFrameError(DEFAULT_EXPORT_ERROR);
115
+ if (behavior === "skip") {
116
+ return;
87
117
  }
88
- defaultExportLocalName = null;
118
+ }
119
+ for (const { path: exPath, replacement } of replacedExports) {
120
+ exPath.replaceWith(replacement);
121
+ }
122
+ for (const p of removedPaths) {
123
+ if (p.removed) continue;
124
+ p.remove();
89
125
  }
90
126
  const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);
91
127
  const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;
@@ -122,9 +158,7 @@ function fortiPrepTransform(_api, rawOpts = {}) {
122
158
  ]);
123
159
  const injectedStmts = [importsDecl, defaultHelperDecl];
124
160
  for (const [importId, specs] of injectedImportsById.entries()) {
125
- const modIdent = t.identifier(
126
- `__m_${importId.replace(/[^a-zA-Z0-9_$]/g, "_")}`
127
- );
161
+ const modIdent = t.identifier(`__m_${importId.replace(/[^a-zA-Z0-9_$]/g, "_")}`);
128
162
  injectedStmts.push(
129
163
  t.variableDeclaration("const", [
130
164
  t.variableDeclarator(
@@ -186,12 +220,11 @@ function fortiPrepTransform(_api, rawOpts = {}) {
186
220
  }
187
221
  },
188
222
  ImportDeclaration(path2) {
189
- if (!enabled) return;
190
223
  const node = path2.node;
191
224
  const importId = node.source.value;
192
225
  if (!shouldInject(importId, opts)) {
193
226
  keptImports.push(node);
194
- path2.remove();
227
+ removedPaths.push(path2);
195
228
  return;
196
229
  }
197
230
  for (const s of node.specifiers) {
@@ -207,14 +240,13 @@ function fortiPrepTransform(_api, rawOpts = {}) {
207
240
  });
208
241
  }
209
242
  }
210
- path2.remove();
243
+ removedPaths.push(path2);
211
244
  },
212
245
  ExportDefaultDeclaration(path2) {
213
- if (!enabled) return;
214
246
  const decl = path2.node.declaration;
215
247
  if (t.isIdentifier(decl)) {
216
248
  defaultExportLocalName = decl.name;
217
- path2.remove();
249
+ removedPaths.push(path2);
218
250
  return;
219
251
  }
220
252
  if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {
@@ -222,19 +254,17 @@ function fortiPrepTransform(_api, rawOpts = {}) {
222
254
  decl.id = path2.scope.generateUidIdentifier("defaultExport");
223
255
  }
224
256
  defaultExportLocalName = decl.id.name;
225
- path2.replaceWith(decl);
257
+ replacedExports.push({ path: path2, replacement: decl });
226
258
  return;
227
259
  }
228
260
  const id = path2.scope.generateUidIdentifier("defaultExport");
229
- path2.replaceWith(
230
- t.variableDeclaration("const", [
231
- t.variableDeclarator(id, decl)
232
- ])
233
- );
234
261
  defaultExportLocalName = id.name;
262
+ const replacement = t.variableDeclaration("const", [
263
+ t.variableDeclarator(id, decl)
264
+ ]);
265
+ replacedExports.push({ path: path2, replacement });
235
266
  },
236
267
  ExportNamedDeclaration(path2) {
237
- if (!enabled) return;
238
268
  const node = path2.node;
239
269
  if (node.specifiers?.length) {
240
270
  let foundExplicitDefault = false;
@@ -260,7 +290,7 @@ function fortiPrepTransform(_api, rawOpts = {}) {
260
290
  if (node.declaration || node.specifiers && node.specifiers.length > 0) {
261
291
  keptNamedExports.push(node);
262
292
  }
263
- path2.remove();
293
+ removedPaths.push(path2);
264
294
  }
265
295
  }
266
296
  };
@@ -464,9 +494,9 @@ function crawl(dirPath, baseDir, acc, sets, appEntryAbsPath) {
464
494
  }
465
495
  function generatePluginInputs(srcRoot = path.resolve(process.cwd(), "ts"), options = {}) {
466
496
  const {
467
- writeAppEntry = true,
497
+ writeAppEntry = false,
468
498
  appEntryName = "app.tsx",
469
- includeAppEntryInInputs = true,
499
+ includeAppEntryInInputs = false,
470
500
  appEntryKey = "__app_entry",
471
501
  verbose = true
472
502
  } = options;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite/prep.ts","../src/babel/transform.ts","../src/utils/generate-plugin-inputs.ts"],"sourcesContent":["import { transformSync } from \"@babel/core\";\r\nimport { readFileSync, writeFileSync } from \"node:fs\";\r\nimport { dirname, resolve as resolvePath } from \"node:path\";\r\nimport type {NormalizedOutputOptions, OutputBundle, OutputOptions} from \"rollup\";\r\nimport type { Plugin as VitePlugin } from \"vite\";\r\n\r\nimport fortiPrepTransform, {\r\n type FortiPrepTransformOptions,\r\n} from \"../babel/transform\";\r\n\r\nexport type FortiPrepOptions = FortiPrepTransformOptions & {\r\n /**\r\n * Which emitted entry file extensions should be rewritten.\r\n * Default: [\".js\", \".mjs\"]\r\n */\r\n entryExtensions?: string[];\r\n\r\n /**\r\n * Vite plugin name\r\n * Default: \"fortiplugin-prep\"\r\n */\r\n pluginName?: string;\r\n};\r\n\r\nconst DEFAULT_INJECTED_IDS = [\"react\", \"react/jsx-runtime\"] as const;\r\nconst DEFAULT_INJECTED_PREFIXES = [\"@inertiajs/\", \"@host/\"] as const;\r\n\r\nfunction resolveOutDir(outputOptions: OutputOptions): string | null {\r\n if (outputOptions.dir) return outputOptions.dir;\r\n if (outputOptions.file) return dirname(outputOptions.file);\r\n return null;\r\n}\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\n/**\r\n * FortiPlugin bundle adapter:\r\n * - marks injected imports as Rollup externals (so they survive into output)\r\n * - rewrites built entry chunks to remove those imports and load them from runtime deps\r\n */\r\nexport default function prep(options: FortiPrepOptions = {}): VitePlugin {\r\n const injectedIds = options.injectedIds ?? [...DEFAULT_INJECTED_IDS];\r\n const injectedPrefixes = options.injectedPrefixes ?? [...DEFAULT_INJECTED_PREFIXES];\r\n\r\n const runtimeKey = options.runtimeKey ?? \"imports\";\r\n const depsParam = options.depsParam ?? \"deps\";\r\n\r\n const entryExtensions = options.entryExtensions ?? [\".js\", \".mjs\"];\r\n const pluginName = options.pluginName ?? \"fortiplugin-prep\";\r\n\r\n const transformOptions: FortiPrepTransformOptions = {\r\n injectedIds,\r\n injectedPrefixes,\r\n runtimeKey,\r\n depsParam,\r\n };\r\n\r\n return {\r\n name: pluginName,\r\n apply: \"build\",\r\n\r\n config() {\r\n return {\r\n define: {\r\n \"process.env.NODE_ENV\": '\"production\"',\r\n },\r\n build: {\r\n rollupOptions: {\r\n // Ensure virtual imports don't need to resolve.\r\n external: (id: string) => shouldInject(id, transformOptions),\r\n },\r\n },\r\n };\r\n },\r\n\r\n writeBundle(outputOptions: NormalizedOutputOptions, bundle: OutputBundle) {\r\n const outDir = resolveOutDir(outputOptions);\r\n if (!outDir) return;\r\n\r\n for (const [fileName, item] of Object.entries(bundle)) {\r\n if (item.type !== \"chunk\") continue;\r\n if (!item.isEntry) continue;\r\n\r\n if (!entryExtensions.some((ext) => fileName.endsWith(ext))) continue;\r\n\r\n const absPath = resolvePath(outDir, fileName);\r\n const input = readFileSync(absPath, \"utf-8\");\r\n\r\n const result = transformSync(input, {\r\n filename: absPath,\r\n sourceType: \"module\",\r\n // Fresh plugin instance per file (Babel calls plugin factory per file when passed as [fn, opts])\r\n plugins: [[fortiPrepTransform as any, transformOptions]],\r\n generatorOpts: {\r\n compact: false,\r\n comments: true,\r\n retainLines: false,\r\n },\r\n });\r\n\r\n if (!result?.code) continue;\r\n writeFileSync(absPath, result.code, \"utf-8\");\r\n }\r\n },\r\n };\r\n}","// noinspection JSUnusedGlobalSymbols,GrazieInspection\r\n\r\nimport type {PluginObj} from \"@babel/core\";\r\nimport * as t from \"@babel/types\";\r\nimport type {NodePath} from \"@babel/traverse\";\r\n\r\nexport type FortiPrepTransformOptions = {\r\n /**\r\n * Exact import ids to inject (removed from bundle and loaded from runtime deps).\r\n * Example: [\"react\", \"react/jsx-runtime\", \"@host/ui\"]\r\n */\r\n injectedIds?: string[];\r\n\r\n /**\r\n * Prefix import ids to inject.\r\n * Example: [\"@host/\", \"@inertiajs/\"]\r\n */\r\n injectedPrefixes?: string[];\r\n\r\n /**\r\n * The key on the deps object used as the import map.\r\n * Wrapper supports passing deps.imports OR passing the import map directly.\r\n *\r\n * Default: \"imports\"\r\n */\r\n runtimeKey?: string;\r\n\r\n /**\r\n * Wrapper function parameter name.\r\n * Default: \"deps\"\r\n */\r\n depsParam?: string;\r\n\r\n /**\r\n * What to do if we can't determine a default export to return.\r\n *\r\n * - \"skip\": do nothing (leave file untouched) ✅ default\r\n * - \"return-null\": still wrap, but return null\r\n * - \"throw\": fail the build (old behavior)\r\n */\r\n onMissingDefault?: \"skip\" | \"return-null\" | \"throw\";\r\n};\r\n\r\nconst DEFAULTS: Required<\r\n Pick<FortiPrepTransformOptions, \"runtimeKey\" | \"depsParam\" | \"onMissingDefault\">\r\n> = {\r\n runtimeKey: \"imports\",\r\n depsParam: \"deps\",\r\n onMissingDefault: \"skip\",\r\n};\r\n\r\nconst DEFAULT_EXPORT_ERROR =\r\n \"PROBLEM!!, No known default function was found, your code either possesses NO named default export or this export format is currently not supported.\";\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\nfunction programHasDefaultExport(p: t.Program): boolean {\r\n for (const stmt of p.body) {\r\n if (t.isExportDefaultDeclaration(stmt)) return true;\r\n\r\n // Rollup-style: export { Foo as default }\r\n if (t.isExportNamedDeclaration(stmt) && stmt.specifiers?.length) {\r\n for (const spec of stmt.specifiers) {\r\n const exported = t.isIdentifier(spec.exported)\r\n ? spec.exported.name\r\n : spec.exported.value;\r\n if (exported === \"default\") return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\ntype CapturedImport =\r\n | { kind: \"default\"; local: string }\r\n | { kind: \"namespace\"; local: string }\r\n | { kind: \"named\"; imported: string; local: string };\r\n\r\nfunction getImportedName(spec: t.ImportSpecifier): string {\r\n return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;\r\n}\r\n\r\nfunction makeImportMapExpr(depsIdent: t.Identifier, runtimeKey: string): t.Expression {\r\n // Support both:\r\n // factory({ imports: { ... } })\r\n // and:\r\n // factory({ ... }) // direct import map\r\n //\r\n // const __imports =\r\n // deps && typeof deps === \"object\" && \"imports\" in deps\r\n // ? deps.imports\r\n // : (deps || {});\r\n const hasKey = t.binaryExpression(\"in\", t.stringLiteral(runtimeKey), depsIdent);\r\n\r\n const isObj = t.logicalExpression(\r\n \"&&\",\r\n t.binaryExpression(\"!==\", depsIdent, t.nullLiteral()),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", depsIdent),\r\n t.stringLiteral(\"object\")\r\n )\r\n );\r\n\r\n const test = t.logicalExpression(\"&&\", isObj, hasKey);\r\n\r\n const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));\r\n const fallback = t.logicalExpression(\"||\", depsIdent, t.objectExpression([]));\r\n\r\n return t.conditionalExpression(test, depsKey, fallback);\r\n}\r\n\r\n/**\r\n * Babel plugin factory (Babel calls this per-file when used as `[plugin, options]`).\r\n */\r\nexport default function fortiPrepTransform(\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n _api: unknown,\r\n rawOpts: FortiPrepTransformOptions = {}\r\n): PluginObj {\r\n const opts: FortiPrepTransformOptions = {\r\n ...rawOpts,\r\n runtimeKey: rawOpts.runtimeKey ?? DEFAULTS.runtimeKey,\r\n depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,\r\n onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault,\r\n };\r\n\r\n // If false, we do NOTHING to this file (silent ignore).\r\n let enabled = true;\r\n\r\n // per-file state (because Babel calls the plugin per file)\r\n const keptImports: t.ImportDeclaration[] = [];\r\n const keptNamedExports: t.ExportNamedDeclaration[] = [];\r\n\r\n const injectedImportsById = new Map<string, CapturedImport[]>();\r\n\r\n let defaultExportLocalName: string | null = null;\r\n let returnDefaultProperty = false;\r\n\r\n function captureImport(importId: string, entry: CapturedImport) {\r\n const list = injectedImportsById.get(importId) ?? [];\r\n list.push(entry);\r\n injectedImportsById.set(importId, list);\r\n }\r\n\r\n return {\r\n name: \"fortiplugin-prep/transform\",\r\n visitor: {\r\n Program: {\r\n enter(path: NodePath<t.Program>) {\r\n // If there's no default export and behavior is \"skip\", silently do nothing.\r\n const hasDefault = programHasDefaultExport(path.node);\r\n if (!hasDefault && (opts.onMissingDefault ?? DEFAULTS.onMissingDefault) === \"skip\") {\r\n enabled = false;\r\n }\r\n },\r\n\r\n exit(path: NodePath<t.Program>) {\r\n if (!enabled) return;\r\n\r\n const program = path.node;\r\n\r\n // If we still couldn't resolve the default export name, decide behavior.\r\n if (!defaultExportLocalName) {\r\n const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;\r\n\r\n if (behavior === \"throw\") {\r\n throw path.buildCodeFrameError(DEFAULT_EXPORT_ERROR);\r\n }\r\n\r\n // \"return-null\": wrap but return null.\r\n // (Note: \"skip\" mode should have disabled earlier, but this is a safe fallback.)\r\n defaultExportLocalName = null;\r\n }\r\n\r\n const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);\r\n const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;\r\n\r\n // const __imports = (deps has runtimeKey) ? deps[runtimeKey] : (deps || {});\r\n const importsIdent = t.identifier(\"__imports\");\r\n const importsInit = makeImportMapExpr(depsIdent, runtimeKey);\r\n const importsDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(importsIdent, importsInit),\r\n ]);\r\n\r\n // const __default = (m) => (m && typeof m === \"object\" && \"default\" in m ? m.default : m);\r\n const defaultHelperIdent = t.identifier(\"__default\");\r\n const defaultHelperDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n defaultHelperIdent,\r\n t.arrowFunctionExpression(\r\n [t.identifier(\"m\")],\r\n t.conditionalExpression(\r\n t.logicalExpression(\r\n \"&&\",\r\n t.logicalExpression(\r\n \"&&\",\r\n t.identifier(\"m\"),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", t.identifier(\"m\")),\r\n t.stringLiteral(\"object\")\r\n )\r\n ),\r\n t.binaryExpression(\"in\", t.stringLiteral(\"default\"), t.identifier(\"m\"))\r\n ),\r\n t.memberExpression(t.identifier(\"m\"), t.identifier(\"default\")),\r\n t.identifier(\"m\")\r\n )\r\n )\r\n ),\r\n ]);\r\n\r\n // Build injected module locals inside wrapper\r\n const injectedStmts: t.Statement[] = [importsDecl, defaultHelperDecl];\r\n\r\n for (const [importId, specs] of injectedImportsById.entries()) {\r\n const modIdent = t.identifier(\r\n `__m_${importId.replace(/[^a-zA-Z0-9_$]/g, \"_\")}`\r\n );\r\n\r\n // const __m_xxx = __imports[\"<importId>\"];\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n modIdent,\r\n t.memberExpression(importsIdent, t.stringLiteral(importId), true)\r\n ),\r\n ])\r\n );\r\n\r\n const named: Array<{ imported: string; local: string }> = [];\r\n\r\n for (const s of specs) {\r\n if (s.kind === \"default\") {\r\n // const Local = __default(__m_xxx);\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.identifier(s.local),\r\n t.callExpression(defaultHelperIdent, [modIdent])\r\n ),\r\n ])\r\n );\r\n } else if (s.kind === \"namespace\") {\r\n // const Local = __m_xxx;\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(t.identifier(s.local), modIdent),\r\n ])\r\n );\r\n } else {\r\n named.push({imported: s.imported, local: s.local});\r\n }\r\n }\r\n\r\n if (named.length) {\r\n // const { A, B: C } = (__m_xxx || {});\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.objectPattern(\r\n named.map(({imported, local}) =>\r\n t.objectProperty(\r\n t.identifier(imported),\r\n t.identifier(local),\r\n false,\r\n imported === local\r\n )\r\n )\r\n ),\r\n t.logicalExpression(\"||\", modIdent, t.objectExpression([]))\r\n ),\r\n ])\r\n );\r\n }\r\n }\r\n\r\n const returnExpr =\r\n defaultExportLocalName == null\r\n ? t.nullLiteral()\r\n : returnDefaultProperty\r\n ? t.memberExpression(t.identifier(defaultExportLocalName), t.identifier(\"default\"))\r\n : t.identifier(defaultExportLocalName);\r\n\r\n // Wrapper body:\r\n // injectedStmts...\r\n // <original body>\r\n // return <defaultExport>\r\n const wrapperBody: t.Statement[] = [];\r\n wrapperBody.push(...injectedStmts);\r\n wrapperBody.push(...program.body);\r\n wrapperBody.push(t.returnStatement(returnExpr));\r\n\r\n const wrapper = t.exportDefaultDeclaration(\r\n t.functionDeclaration(null, [depsIdent], t.blockStatement(wrapperBody))\r\n );\r\n\r\n // Final program:\r\n // kept imports at module scope\r\n // export default function(deps) { ... }\r\n // kept named exports (same as your old behavior)\r\n program.body = [...keptImports, wrapper, ...keptNamedExports] as any;\r\n },\r\n },\r\n\r\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const node = path.node;\r\n const importId = node.source.value;\r\n\r\n if (!shouldInject(importId, opts)) {\r\n keptImports.push(node);\r\n path.remove();\r\n return;\r\n }\r\n\r\n // Remove injected import and capture its specifiers to recreate inside wrapper.\r\n for (const s of node.specifiers) {\r\n if (t.isImportDefaultSpecifier(s)) {\r\n captureImport(importId, {kind: \"default\", local: s.local.name});\r\n } else if (t.isImportNamespaceSpecifier(s)) {\r\n captureImport(importId, {kind: \"namespace\", local: s.local.name});\r\n } else if (t.isImportSpecifier(s)) {\r\n captureImport(importId, {\r\n kind: \"named\",\r\n imported: getImportedName(s),\r\n local: s.local.name,\r\n });\r\n }\r\n }\r\n\r\n // side-effect-only injected imports (import \"@host/ui\") become no-ops at runtime\r\n path.remove();\r\n },\r\n\r\n ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const decl = path.node.declaration;\r\n\r\n // export default Foo;\r\n if (t.isIdentifier(decl)) {\r\n defaultExportLocalName = decl.name;\r\n path.remove();\r\n return;\r\n }\r\n\r\n // export default function (...) {}\r\n // export default class {...}\r\n // Keep as declaration (valid) and remember its id.\r\n if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {\r\n if (!decl.id) {\r\n decl.id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n }\r\n defaultExportLocalName = decl.id.name;\r\n path.replaceWith(decl);\r\n return;\r\n }\r\n\r\n // export default (expr/arrow/etc)\r\n const id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n path.replaceWith(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(id, decl as t.Expression),\r\n ])\r\n );\r\n defaultExportLocalName = id.name;\r\n },\r\n\r\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\r\n if (!enabled) return;\r\n\r\n const node = path.node;\r\n\r\n // Detect Rollup-style: export { Foo as default }\r\n if (node.specifiers?.length) {\r\n let foundExplicitDefault = false;\r\n\r\n node.specifiers = node.specifiers.filter((spec) => {\r\n const exported = t.isIdentifier(spec.exported)\r\n ? spec.exported.name\r\n : spec.exported.value;\r\n\r\n if (exported === \"default\") {\r\n const local = (spec as any)?.local?.name as string | undefined;\r\n if (local) defaultExportLocalName = local;\r\n foundExplicitDefault = true;\r\n return false; // remove the default specifier\r\n }\r\n\r\n return true;\r\n });\r\n\r\n // Minified fallback behavior:\r\n // If no default specifier found and exactly one spec exists,\r\n // treat it as the container and return `<local>.default`.\r\n if (\r\n !foundExplicitDefault &&\r\n !defaultExportLocalName &&\r\n node.specifiers.length === 1\r\n ) {\r\n const only = node.specifiers[0] as any;\r\n if (only?.local?.name) {\r\n defaultExportLocalName = only.local.name;\r\n returnDefaultProperty = true;\r\n node.specifiers = [];\r\n }\r\n }\r\n }\r\n\r\n // Keep named exports after wrapper (same as prior behavior),\r\n // BUT do not keep empty export declarations.\r\n if (node.declaration || (node.specifiers && node.specifiers.length > 0)) {\r\n keptNamedExports.push(node);\r\n }\r\n\r\n path.remove();\r\n },\r\n },\r\n };\r\n}","// src/utils/generate-plugin-inputs.ts\r\nimport path from \"node:path\";\r\nimport * as fs from \"node:fs\";\r\n\r\nconst EXT_PATTERN = /\\.(tsx?|jsx?)$/i;\r\n\r\nexport type PluginInputs = Record<string, string>;\r\n\r\nexport type GeneratePluginInputsOptions = {\r\n /**\r\n * If true, also generates `app.tsx` that imports every discovered entry\r\n * (handy for dev/HMR).\r\n *\r\n * Default: true\r\n */\r\n writeAppEntry?: boolean;\r\n\r\n /**\r\n * Name of the generated app entry file (inside srcRoot).\r\n *\r\n * Default: \"app.tsx\"\r\n */\r\n appEntryName?: string;\r\n\r\n /**\r\n * Adds the generated app entry to the returned Rollup inputs map.\r\n *\r\n * Default: true\r\n */\r\n includeAppEntryInInputs?: boolean;\r\n\r\n /**\r\n * Key name used for the generated app entry in Rollup inputs.\r\n *\r\n * Default: \"__app_entry\"\r\n */\r\n appEntryKey?: string;\r\n\r\n /**\r\n * Extra directory names to ignore (case-insensitive).\r\n */\r\n ignoreDirs?: string[];\r\n\r\n /**\r\n * Extra “component-like” directory names to ignore (case-insensitive, exact match).\r\n */\r\n componentLikeDirs?: string[];\r\n\r\n /**\r\n * Whether to print discovered inputs to console.\r\n *\r\n * Default: true\r\n */\r\n verbose?: boolean;\r\n};\r\n\r\n// folders you typically never want as rollup inputs\r\nconst DEFAULT_IGNORE_DIRS = new Set<string>([\r\n \"node_modules\",\r\n \".git\",\r\n \".vite\",\r\n \".internal\",\r\n \"dist\",\r\n \"build\",\r\n \"public\",\r\n]);\r\n\r\n// “component-like” folders that should NOT produce entrypoints\r\n// Strict: exact folder-name matches only (case-insensitive)\r\nconst DEFAULT_COMPONENT_LIKE_DIRS = new Set<string>([\r\n \"component\",\r\n \"components\",\r\n \"ui\",\r\n \"uis\",\r\n \"widget\",\r\n \"widgets\",\r\n \"atom\",\r\n \"atoms\",\r\n \"molecule\",\r\n \"molecules\",\r\n \"organism\",\r\n \"organisms\",\r\n \"layout\",\r\n \"layouts\",\r\n \"partial\",\r\n \"partials\",\r\n]);\r\n\r\nfunction normalizeName(x: unknown): string {\r\n return String(x ?? \"\").toLowerCase();\r\n}\r\n\r\nfunction makeIgnoreSets(opts?: GeneratePluginInputsOptions): {\r\n ignoreDirs: Set<string>;\r\n componentLikeDirs: Set<string>;\r\n} {\r\n const ignoreDirs = new Set(DEFAULT_IGNORE_DIRS);\r\n const componentLikeDirs = new Set(DEFAULT_COMPONENT_LIKE_DIRS);\r\n\r\n for (const d of opts?.ignoreDirs ?? []) ignoreDirs.add(normalizeName(d));\r\n for (const d of opts?.componentLikeDirs ?? []) componentLikeDirs.add(normalizeName(d));\r\n\r\n return { ignoreDirs, componentLikeDirs };\r\n}\r\n\r\nfunction isIgnoredDir(\r\n dirName: string,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> }\r\n): boolean {\r\n const name = normalizeName(dirName);\r\n return sets.ignoreDirs.has(name) || sets.componentLikeDirs.has(name);\r\n}\r\n\r\n/**\r\n * Creates an app.tsx file that simply imports every discovered entry.\r\n * Helpful for HMR / dev mode.\r\n */\r\nfunction writeAppEntryFile(inputs: PluginInputs, srcRoot: string, appEntryName: string): void {\r\n const app = path.join(srcRoot, appEntryName);\r\n const lines: string[] = [\"// Auto-generated – do not edit\", \"\"];\r\n\r\n const entries = Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b));\r\n\r\n for (const [name, full] of entries) {\r\n const rel =\r\n \"./\" + path.relative(srcRoot, full).replace(/\\\\/g, \"/\").replace(EXT_PATTERN, \"\");\r\n\r\n const variable = name.replace(/[^a-zA-Z0-9_$]/g, \"_\").replace(/^(\\d)/, \"_$1\");\r\n\r\n lines.push(`import * as ${variable} from '${rel}';`);\r\n lines.push(`console.log('${name} loaded:', ${variable});`, \"\");\r\n }\r\n\r\n fs.writeFileSync(app, lines.join(\"\\n\"), \"utf8\");\r\n // eslint-disable-next-line no-console\r\n console.log(`✅ Generated ${appEntryName} in ${srcRoot}`);\r\n}\r\n\r\n/**\r\n * Convert a relative path like \"foo/bar/index.tsx\" to a dot key.\r\n * If `collapseIndex` is true, \"foo/bar/index\" becomes \"foo.bar\".\r\n * Otherwise it becomes \"foo.bar.index\".\r\n */\r\nfunction pathToKey(relNoExt: string, opts: { collapseIndex: boolean }): string {\r\n let normalized = relNoExt.replace(/\\\\/g, \"/\");\r\n\r\n if (opts.collapseIndex) {\r\n normalized = normalized.replace(/\\/index$/i, \"\");\r\n }\r\n\r\n let key = normalized.split(\"/\").filter(Boolean).join(\".\");\r\n if (!key) key = \"index\";\r\n return key;\r\n}\r\n\r\n/**\r\n * Recursively collect entry files under dirPath.\r\n *\r\n * Rule:\r\n * - Prefer collapsing \".../index.tsx\" => \"...\" for nicer keys\r\n * - BUT if that key would collide with another entry, fallback to explicit \"...index\"\r\n * (e.g. \"foo.index\") for the index file ONLY.\r\n */\r\nfunction crawl(\r\n dirPath: string,\r\n baseDir: string,\r\n acc: PluginInputs,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> },\r\n appEntryAbsPath: string\r\n): void {\r\n if (!fs.existsSync(dirPath)) return;\r\n\r\n for (const item of fs.readdirSync(dirPath)) {\r\n const full = path.join(dirPath, item);\r\n const stat = fs.statSync(full);\r\n\r\n if (stat.isDirectory()) {\r\n if (isIgnoredDir(item, sets)) continue;\r\n crawl(full, baseDir, acc, sets, appEntryAbsPath);\r\n continue;\r\n }\r\n\r\n if (!EXT_PATTERN.test(item)) continue;\r\n\r\n // Don't include the generated entry itself (prevents self-import)\r\n if (path.resolve(full) === path.resolve(appEntryAbsPath)) {\r\n continue;\r\n }\r\n\r\n const relNoExt = path.relative(baseDir, full).replace(EXT_PATTERN, \"\");\r\n const isIndexFile = /(^|[\\\\/])index$/i.test(relNoExt);\r\n\r\n // Preferred key: collapse \".../index\" => \"...\"\r\n const preferred = pathToKey(relNoExt, { collapseIndex: true });\r\n\r\n // Explicit key: keep \".../index\" => \"...index\"\r\n // Example: \"foo/index\" => \"foo.index\"\r\n const explicit = pathToKey(relNoExt, { collapseIndex: false });\r\n\r\n let name = preferred;\r\n\r\n // If preferred collides, ONLY the index file switches to explicit path key.\r\n const existing = acc[name];\r\n if (existing && path.resolve(existing) !== path.resolve(full)) {\r\n if (isIndexFile) {\r\n // Use foo.index (or deeper.path.index) instead of suffixing __2\r\n if (!acc[explicit]) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `⚠️ Key collision for \"${preferred}\" — using \"${explicit}\" for index file`,\r\n { existing: acc[preferred], incoming: full }\r\n );\r\n name = explicit;\r\n } else {\r\n // Extremely rare: even explicit collides (e.g. duplicate paths via symlinks)\r\n let i = 2;\r\n let next = `${explicit}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${explicit}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Key collision for \"${explicit}\" — using \"${next}\"`, {\r\n existing: acc[explicit],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n } else {\r\n // Non-index collision: suffix like original behavior\r\n let i = 2;\r\n let next = `${name}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${name}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Input key collision \"${name}\" -> using \"${next}\"`, {\r\n existing: acc[name],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n }\r\n\r\n acc[name] = full;\r\n }\r\n}\r\n\r\n/**\r\n * Discover integration pages/components and return a Rollup input map.\r\n *\r\n * @param srcRoot absolute or relative path to the source folder (e.g. \"resources/embed/ts\")\r\n * @param options\r\n * @returns Rollup input map: { [key]: absolutePath }\r\n */\r\nexport function generatePluginInputs(\r\n srcRoot: string = path.resolve(process.cwd(), \"ts\"),\r\n options: GeneratePluginInputsOptions = {}\r\n): PluginInputs {\r\n const {\r\n writeAppEntry = true,\r\n appEntryName = \"app.tsx\",\r\n includeAppEntryInInputs = true,\r\n appEntryKey = \"__app_entry\",\r\n verbose = true,\r\n } = options;\r\n\r\n const absRoot = path.resolve(srcRoot);\r\n const inputs: PluginInputs = {};\r\n\r\n const sets = makeIgnoreSets(options);\r\n const appEntryAbsPath = path.join(absRoot, appEntryName);\r\n\r\n // Crawl everything under absRoot (no folder assumptions)\r\n crawl(absRoot, absRoot, inputs, sets, appEntryAbsPath);\r\n\r\n if (verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"✅ Integrations discovered:\", inputs);\r\n }\r\n\r\n if (writeAppEntry) {\r\n writeAppEntryFile(inputs, absRoot, appEntryName);\r\n }\r\n\r\n if (!includeAppEntryInInputs) return inputs;\r\n\r\n return { ...inputs, [appEntryKey]: appE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AI,GAAG,IAAI,GAClD,UAAuC,CAAC,GAC5B;AACZ,QAAM;AAAA,IACF,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,0BAA0B;AAAA,IAC1B,cAAc;AAAA,IACd,UAAU;AAAA,EACd,IAAI;AAEJ,QAAM,UAAU,KAAK,QAAQ,OAAO;AACpC,QAAM,SAAuB,CAAC;AAE9B,QAAM,OAAO,eAAe,OAAO;AACnC,QAAM,kBAAkB,KAAK,KAAK,SAAS,YAAY;AAGvD,QAAM,SAAS,SAAS,QAAQ,MAAM,eAAe;AAErD,MAAI,SAAS;AAET,YAAQ,IAAI,mCAA8B,MAAM;AAAA,EACpD;AAEA,MAAI,eAAe;AACf,sBAAkB,QAAQ,SAAS,YAAY;AAAA,EACnD;AAEA,MAAI,CAAC,wBAAyB,QAAO;AAErC,SAAO,EAAE,GAAG,QAAQ,CAAC,WAAW,GAAG,gBAAgB;AACvD;","names":["path","shouldInject"]}
1
+ {"version":3,"sources":["../src/vite/prep.ts","../src/babel/transform.ts","../src/utils/generate-plugin-inputs.ts"],"sourcesContent":["import { transformSync } from \"@babel/core\";\r\nimport { readFileSync, writeFileSync } from \"node:fs\";\r\nimport { dirname, resolve as resolvePath } from \"node:path\";\r\nimport type {NormalizedOutputOptions, OutputBundle, OutputOptions} from \"rollup\";\r\nimport type { Plugin as VitePlugin } from \"vite\";\r\n\r\nimport fortiPrepTransform, {\r\n type FortiPrepTransformOptions,\r\n} from \"../babel/transform\";\r\n\r\nexport type FortiPrepOptions = FortiPrepTransformOptions & {\r\n /**\r\n * Which emitted entry file extensions should be rewritten.\r\n * Default: [\".js\", \".mjs\"]\r\n */\r\n entryExtensions?: string[];\r\n\r\n /**\r\n * Vite plugin name\r\n * Default: \"fortiplugin-prep\"\r\n */\r\n pluginName?: string;\r\n};\r\n\r\nconst DEFAULT_INJECTED_IDS = [\"react\", \"react/jsx-runtime\"] as const;\r\nconst DEFAULT_INJECTED_PREFIXES = [\"@inertiajs/\", \"@host/\"] as const;\r\n\r\nfunction resolveOutDir(outputOptions: OutputOptions): string | null {\r\n if (outputOptions.dir) return outputOptions.dir;\r\n if (outputOptions.file) return dirname(outputOptions.file);\r\n return null;\r\n}\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\n/**\r\n * FortiPlugin bundle adapter:\r\n * - marks injected imports as Rollup externals (so they survive into output)\r\n * - rewrites built entry chunks to remove those imports and load them from runtime deps\r\n */\r\nexport default function prep(options: FortiPrepOptions = {}): VitePlugin {\r\n const injectedIds = options.injectedIds ?? [...DEFAULT_INJECTED_IDS];\r\n const injectedPrefixes = options.injectedPrefixes ?? [...DEFAULT_INJECTED_PREFIXES];\r\n\r\n const runtimeKey = options.runtimeKey ?? \"imports\";\r\n const depsParam = options.depsParam ?? \"deps\";\r\n\r\n const entryExtensions = options.entryExtensions ?? [\".js\", \".mjs\"];\r\n const pluginName = options.pluginName ?? \"fortiplugin-prep\";\r\n\r\n const transformOptions: FortiPrepTransformOptions = {\r\n injectedIds,\r\n injectedPrefixes,\r\n runtimeKey,\r\n depsParam,\r\n };\r\n\r\n return {\r\n name: pluginName,\r\n apply: \"build\",\r\n\r\n config() {\r\n return {\r\n define: {\r\n \"process.env.NODE_ENV\": '\"production\"',\r\n },\r\n build: {\r\n rollupOptions: {\r\n // Ensure virtual imports don't need to resolve.\r\n external: (id: string) => shouldInject(id, transformOptions),\r\n },\r\n },\r\n };\r\n },\r\n\r\n writeBundle(outputOptions: NormalizedOutputOptions, bundle: OutputBundle) {\r\n const outDir = resolveOutDir(outputOptions);\r\n if (!outDir) return;\r\n\r\n for (const [fileName, item] of Object.entries(bundle)) {\r\n if (item.type !== \"chunk\") continue;\r\n if (!item.isEntry) continue;\r\n\r\n if (!entryExtensions.some((ext) => fileName.endsWith(ext))) continue;\r\n\r\n const absPath = resolvePath(outDir, fileName);\r\n const input = readFileSync(absPath, \"utf-8\");\r\n\r\n const result = transformSync(input, {\r\n filename: absPath,\r\n sourceType: \"module\",\r\n // Fresh plugin instance per file (Babel calls plugin factory per file when passed as [fn, opts])\r\n plugins: [[fortiPrepTransform as any, transformOptions]],\r\n generatorOpts: {\r\n compact: false,\r\n comments: true,\r\n retainLines: false,\r\n },\r\n });\r\n\r\n if (!result?.code) continue;\r\n writeFileSync(absPath, result.code, \"utf-8\");\r\n }\r\n },\r\n };\r\n}","// noinspection JSUnusedGlobalSymbols,GrazieInspection\r\n\r\nimport type { PluginObj } from \"@babel/core\";\r\nimport * as t from \"@babel/types\";\r\nimport type { NodePath } from \"@babel/traverse\";\r\n\r\nexport type FortiPrepTransformOptions = {\r\n injectedIds?: string[];\r\n injectedPrefixes?: string[];\r\n runtimeKey?: string;\r\n depsParam?: string;\r\n onMissingDefault?: \"skip\" | \"return-null\" | \"throw\";\r\n};\r\n\r\nconst DEFAULTS: Required<Pick<FortiPrepTransformOptions, \"runtimeKey\" | \"depsParam\" | \"onMissingDefault\">> = {\r\n runtimeKey: \"imports\",\r\n depsParam: \"deps\",\r\n onMissingDefault: \"skip\",\r\n};\r\n\r\nconst DEFAULT_EXPORT_ERROR =\r\n \"PROBLEM!!, No known default function was found, your code either possesses NO named default export or this export format is currently not supported.\";\r\n\r\nfunction shouldInject(id: string, opts: FortiPrepTransformOptions): boolean {\r\n const ids = opts.injectedIds ?? [];\r\n const prefixes = opts.injectedPrefixes ?? [];\r\n if (ids.includes(id)) return true;\r\n for (const p of prefixes) if (id.startsWith(p)) return true;\r\n return false;\r\n}\r\n\r\ntype CapturedImport =\r\n | { kind: \"default\"; local: string }\r\n | { kind: \"namespace\"; local: string }\r\n | { kind: \"named\"; imported: string; local: string };\r\n\r\nfunction getImportedName(spec: t.ImportSpecifier): string {\r\n return t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;\r\n}\r\n\r\nfunction makeImportMapExpr(depsIdent: t.Identifier, runtimeKey: string): t.Expression {\r\n const hasKey = t.binaryExpression(\"in\", t.stringLiteral(runtimeKey), depsIdent);\r\n\r\n const isObj = t.logicalExpression(\r\n \"&&\",\r\n t.binaryExpression(\"!==\", depsIdent, t.nullLiteral()),\r\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", depsIdent), t.stringLiteral(\"object\"))\r\n );\r\n\r\n const test = t.logicalExpression(\"&&\", isObj, hasKey);\r\n const depsKey = t.memberExpression(depsIdent, t.identifier(runtimeKey));\r\n const fallback = t.logicalExpression(\"||\", depsIdent, t.objectExpression([]));\r\n\r\n return t.conditionalExpression(test, depsKey, fallback);\r\n}\r\n\r\n/**\r\n * Detects Rollup namespace wrapper variable:\r\n * const M = Object.freeze(Object.defineProperty({ __proto__: null, default: x }, Symbol.toStringTag, { value:\"Module\" }));\r\n */\r\nfunction looksLikeRollupNamespaceWrapper(init: t.Expression | null | undefined): boolean {\r\n if (!init || !t.isCallExpression(init)) return false;\r\n\r\n // Object.freeze(...)\r\n if (!t.isMemberExpression(init.callee)) return false;\r\n if (!t.isIdentifier(init.callee.object, { name: \"Object\" })) return false;\r\n if (!t.isIdentifier(init.callee.property, { name: \"freeze\" })) return false;\r\n\r\n const arg0 = init.arguments[0];\r\n if (!t.isCallExpression(arg0)) return false;\r\n\r\n // Object.defineProperty(...)\r\n if (!t.isMemberExpression(arg0.callee)) return false;\r\n if (!t.isIdentifier(arg0.callee.object, { name: \"Object\" })) return false;\r\n if (!t.isIdentifier(arg0.callee.property, { name: \"defineProperty\" })) return false;\r\n\r\n const objArg = arg0.arguments[0];\r\n if (!t.isObjectExpression(objArg)) return false;\r\n\r\n // must contain a \"default\" property\r\n const hasDefault = objArg.properties.some((p) => {\r\n if (!t.isObjectProperty(p)) return false;\r\n if (t.isIdentifier(p.key)) return p.key.name === \"default\";\r\n if (t.isStringLiteral(p.key)) return p.key.value === \"default\";\r\n return false;\r\n });\r\n\r\n return hasDefault;\r\n}\r\n\r\nfunction inferDefaultFromSingleNamedExport(program: t.Program): { local: string; returnDefaultProperty: boolean } | null {\r\n // If there's exactly one named export specifier, it's often the namespace container:\r\n // export { M as k };\r\n // Return M.default\r\n const exports: t.ExportNamedDeclaration[] = program.body.filter((s): s is t.ExportNamedDeclaration =>\r\n t.isExportNamedDeclaration(s)\r\n );\r\n\r\n for (const ex of exports) {\r\n if (!ex.specifiers || ex.specifiers.length !== 1) continue;\r\n\r\n const spec = ex.specifiers[0];\r\n if (!t.isExportSpecifier(spec)) continue;\r\n if (!t.isIdentifier(spec.local)) continue;\r\n\r\n const localName = spec.local.name;\r\n\r\n // Safety: only accept if we can find a matching variable declaration that looks like a Rollup namespace wrapper\r\n let ok = false;\r\n for (const stmt of program.body) {\r\n if (!t.isVariableDeclaration(stmt)) continue;\r\n for (const d of stmt.declarations) {\r\n if (!t.isIdentifier(d.id, { name: localName })) continue;\r\n if (looksLikeRollupNamespaceWrapper(d.init as any)) ok = true;\r\n }\r\n }\r\n\r\n if (ok) {\r\n return { local: localName, returnDefaultProperty: true };\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Babel plugin factory\r\n */\r\nexport default function fortiPrepTransform(_api: unknown, rawOpts: FortiPrepTransformOptions = {}): PluginObj {\r\n const opts: FortiPrepTransformOptions = {\r\n ...rawOpts,\r\n runtimeKey: rawOpts.runtimeKey ?? DEFAULTS.runtimeKey,\r\n depsParam: rawOpts.depsParam ?? DEFAULTS.depsParam,\r\n onMissingDefault: rawOpts.onMissingDefault ?? DEFAULTS.onMissingDefault,\r\n };\r\n\r\n // We defer all mutations until Program.exit\r\n const removedPaths: NodePath[] = [];\r\n const replacedExports: Array<{ path: NodePath<t.ExportDefaultDeclaration>; replacement: t.Statement }> = [];\r\n\r\n const keptImports: t.ImportDeclaration[] = [];\r\n const keptNamedExports: t.ExportNamedDeclaration[] = [];\r\n const injectedImportsById = new Map<string, CapturedImport[]>();\r\n\r\n let defaultExportLocalName: string | null = null;\r\n let returnDefaultProperty = false;\r\n\r\n function captureImport(importId: string, entry: CapturedImport) {\r\n const list = injectedImportsById.get(importId) ?? [];\r\n list.push(entry);\r\n injectedImportsById.set(importId, list);\r\n }\r\n\r\n return {\r\n name: \"fortiplugin-prep/transform\",\r\n visitor: {\r\n Program: {\r\n exit(path: NodePath<t.Program>) {\r\n const program = path.node;\r\n\r\n // Apply deferred replacements/removals so we can decide to skip cleanly.\r\n // But only AFTER we determine if we're wrapping.\r\n\r\n // 1) If we still don't have a default, try inference for rollup wrapper exports.\r\n if (!defaultExportLocalName) {\r\n const inferred = inferDefaultFromSingleNamedExport(program);\r\n if (inferred) {\r\n defaultExportLocalName = inferred.local;\r\n returnDefaultProperty = inferred.returnDefaultProperty;\r\n }\r\n }\r\n\r\n // 2) Decide behavior if still missing\r\n if (!defaultExportLocalName) {\r\n const behavior = opts.onMissingDefault ?? DEFAULTS.onMissingDefault;\r\n if (behavior === \"throw\") throw path.buildCodeFrameError(DEFAULT_EXPORT_ERROR);\r\n if (behavior === \"skip\") {\r\n // Do nothing: leave the program untouched\r\n return;\r\n }\r\n // return-null => wrap but return null\r\n }\r\n\r\n // 3) Now that we WILL wrap, perform deferred mutations\r\n for (const { path: exPath, replacement } of replacedExports) {\r\n exPath.replaceWith(replacement as any);\r\n }\r\n for (const p of removedPaths) {\r\n if (p.removed) continue;\r\n p.remove();\r\n }\r\n\r\n const depsIdent = t.identifier(opts.depsParam ?? DEFAULTS.depsParam);\r\n const runtimeKey = opts.runtimeKey ?? DEFAULTS.runtimeKey;\r\n\r\n const importsIdent = t.identifier(\"__imports\");\r\n const importsInit = makeImportMapExpr(depsIdent, runtimeKey);\r\n const importsDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(importsIdent, importsInit),\r\n ]);\r\n\r\n const defaultHelperIdent = t.identifier(\"__default\");\r\n const defaultHelperDecl = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n defaultHelperIdent,\r\n t.arrowFunctionExpression(\r\n [t.identifier(\"m\")],\r\n t.conditionalExpression(\r\n t.logicalExpression(\r\n \"&&\",\r\n t.logicalExpression(\r\n \"&&\",\r\n t.identifier(\"m\"),\r\n t.binaryExpression(\r\n \"===\",\r\n t.unaryExpression(\"typeof\", t.identifier(\"m\")),\r\n t.stringLiteral(\"object\")\r\n )\r\n ),\r\n t.binaryExpression(\"in\", t.stringLiteral(\"default\"), t.identifier(\"m\"))\r\n ),\r\n t.memberExpression(t.identifier(\"m\"), t.identifier(\"default\")),\r\n t.identifier(\"m\")\r\n )\r\n )\r\n ),\r\n ]);\r\n\r\n const injectedStmts: t.Statement[] = [importsDecl, defaultHelperDecl];\r\n\r\n for (const [importId, specs] of injectedImportsById.entries()) {\r\n const modIdent = t.identifier(`__m_${importId.replace(/[^a-zA-Z0-9_$]/g, \"_\")}`);\r\n\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n modIdent,\r\n t.memberExpression(importsIdent, t.stringLiteral(importId), true)\r\n ),\r\n ])\r\n );\r\n\r\n const named: Array<{ imported: string; local: string }> = [];\r\n\r\n for (const s of specs) {\r\n if (s.kind === \"default\") {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.identifier(s.local),\r\n t.callExpression(defaultHelperIdent, [modIdent])\r\n ),\r\n ])\r\n );\r\n } else if (s.kind === \"namespace\") {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(t.identifier(s.local), modIdent),\r\n ])\r\n );\r\n } else {\r\n named.push({ imported: s.imported, local: s.local });\r\n }\r\n }\r\n\r\n if (named.length) {\r\n injectedStmts.push(\r\n t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(\r\n t.objectPattern(\r\n named.map(({ imported, local }) =>\r\n t.objectProperty(\r\n t.identifier(imported),\r\n t.identifier(local),\r\n false,\r\n imported === local\r\n )\r\n )\r\n ),\r\n t.logicalExpression(\"||\", modIdent, t.objectExpression([]))\r\n ),\r\n ])\r\n );\r\n }\r\n }\r\n\r\n const returnExpr =\r\n defaultExportLocalName == null\r\n ? t.nullLiteral()\r\n : returnDefaultProperty\r\n ? t.memberExpression(t.identifier(defaultExportLocalName), t.identifier(\"default\"))\r\n : t.identifier(defaultExportLocalName);\r\n\r\n const wrapperBody: t.Statement[] = [];\r\n wrapperBody.push(...injectedStmts);\r\n wrapperBody.push(...program.body);\r\n wrapperBody.push(t.returnStatement(returnExpr));\r\n\r\n const wrapper = t.exportDefaultDeclaration(\r\n t.functionDeclaration(null, [depsIdent], t.blockStatement(wrapperBody))\r\n );\r\n\r\n program.body = [...keptImports, wrapper, ...keptNamedExports] as any;\r\n },\r\n },\r\n\r\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\r\n const node = path.node;\r\n const importId = node.source.value;\r\n\r\n if (!shouldInject(importId, opts)) {\r\n keptImports.push(node);\r\n removedPaths.push(path);\r\n return;\r\n }\r\n\r\n for (const s of node.specifiers) {\r\n if (t.isImportDefaultSpecifier(s)) {\r\n captureImport(importId, { kind: \"default\", local: s.local.name });\r\n } else if (t.isImportNamespaceSpecifier(s)) {\r\n captureImport(importId, { kind: \"namespace\", local: s.local.name });\r\n } else if (t.isImportSpecifier(s)) {\r\n captureImport(importId, {\r\n kind: \"named\",\r\n imported: getImportedName(s),\r\n local: s.local.name,\r\n });\r\n }\r\n }\r\n\r\n removedPaths.push(path);\r\n },\r\n\r\n ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {\r\n const decl = path.node.declaration;\r\n\r\n if (t.isIdentifier(decl)) {\r\n defaultExportLocalName = decl.name;\r\n removedPaths.push(path);\r\n return;\r\n }\r\n\r\n if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {\r\n if (!decl.id) {\r\n decl.id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n }\r\n defaultExportLocalName = decl.id.name;\r\n // Replace export default decl with the decl itself (deferred)\r\n replacedExports.push({ path, replacement: decl as any });\r\n return;\r\n }\r\n\r\n // export default (expr/arrow/etc)\r\n const id = path.scope.generateUidIdentifier(\"defaultExport\");\r\n defaultExportLocalName = id.name;\r\n\r\n const replacement = t.variableDeclaration(\"const\", [\r\n t.variableDeclarator(id, decl as t.Expression),\r\n ]);\r\n\r\n replacedExports.push({ path, replacement });\r\n },\r\n\r\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\r\n const node = path.node;\r\n\r\n if (node.specifiers?.length) {\r\n let foundExplicitDefault = false;\r\n\r\n node.specifiers = node.specifiers.filter((spec) => {\r\n const exported = t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value;\r\n\r\n if (exported === \"default\") {\r\n const local = (spec as any)?.local?.name as string | undefined;\r\n if (local) defaultExportLocalName = local;\r\n foundExplicitDefault = true;\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n\r\n if (!foundExplicitDefault && !defaultExportLocalName && node.specifiers.length === 1) {\r\n const only = node.specifiers[0] as any;\r\n if (only?.local?.name) {\r\n defaultExportLocalName = only.local.name;\r\n returnDefaultProperty = true;\r\n node.specifiers = [];\r\n }\r\n }\r\n }\r\n\r\n if (node.declaration || (node.specifiers && node.specifiers.length > 0)) {\r\n keptNamedExports.push(node);\r\n }\r\n\r\n removedPaths.push(path);\r\n },\r\n },\r\n };\r\n}","// src/utils/generate-plugin-inputs.ts\r\nimport path from \"node:path\";\r\nimport * as fs from \"node:fs\";\r\n\r\nconst EXT_PATTERN = /\\.(tsx?|jsx?)$/i;\r\n\r\nexport type PluginInputs = Record<string, string>;\r\n\r\nexport type GeneratePluginInputsOptions = {\r\n /**\r\n * If true, also generates `app.tsx` that imports every discovered entry\r\n * (handy for dev/HMR).\r\n *\r\n * Default: true\r\n */\r\n writeAppEntry?: boolean;\r\n\r\n /**\r\n * Name of the generated app entry file (inside srcRoot).\r\n *\r\n * Default: \"app.tsx\"\r\n */\r\n appEntryName?: string;\r\n\r\n /**\r\n * Adds the generated app entry to the returned Rollup inputs map.\r\n *\r\n * Default: true\r\n */\r\n includeAppEntryInInputs?: boolean;\r\n\r\n /**\r\n * Key name used for the generated app entry in Rollup inputs.\r\n *\r\n * Default: \"__app_entry\"\r\n */\r\n appEntryKey?: string;\r\n\r\n /**\r\n * Extra directory names to ignore (case-insensitive).\r\n */\r\n ignoreDirs?: string[];\r\n\r\n /**\r\n * Extra “component-like” directory names to ignore (case-insensitive, exact match).\r\n */\r\n componentLikeDirs?: string[];\r\n\r\n /**\r\n * Whether to print discovered inputs to console.\r\n *\r\n * Default: true\r\n */\r\n verbose?: boolean;\r\n};\r\n\r\n// folders you typically never want as rollup inputs\r\nconst DEFAULT_IGNORE_DIRS = new Set<string>([\r\n \"node_modules\",\r\n \".git\",\r\n \".vite\",\r\n \".internal\",\r\n \"dist\",\r\n \"build\",\r\n \"public\",\r\n]);\r\n\r\n// “component-like” folders that should NOT produce entrypoints\r\n// Strict: exact folder-name matches only (case-insensitive)\r\nconst DEFAULT_COMPONENT_LIKE_DIRS = new Set<string>([\r\n \"component\",\r\n \"components\",\r\n \"ui\",\r\n \"uis\",\r\n \"widget\",\r\n \"widgets\",\r\n \"atom\",\r\n \"atoms\",\r\n \"molecule\",\r\n \"molecules\",\r\n \"organism\",\r\n \"organisms\",\r\n \"layout\",\r\n \"layouts\",\r\n \"partial\",\r\n \"partials\",\r\n]);\r\n\r\nfunction normalizeName(x: unknown): string {\r\n return String(x ?? \"\").toLowerCase();\r\n}\r\n\r\nfunction makeIgnoreSets(opts?: GeneratePluginInputsOptions): {\r\n ignoreDirs: Set<string>;\r\n componentLikeDirs: Set<string>;\r\n} {\r\n const ignoreDirs = new Set(DEFAULT_IGNORE_DIRS);\r\n const componentLikeDirs = new Set(DEFAULT_COMPONENT_LIKE_DIRS);\r\n\r\n for (const d of opts?.ignoreDirs ?? []) ignoreDirs.add(normalizeName(d));\r\n for (const d of opts?.componentLikeDirs ?? []) componentLikeDirs.add(normalizeName(d));\r\n\r\n return { ignoreDirs, componentLikeDirs };\r\n}\r\n\r\nfunction isIgnoredDir(\r\n dirName: string,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> }\r\n): boolean {\r\n const name = normalizeName(dirName);\r\n return sets.ignoreDirs.has(name) || sets.componentLikeDirs.has(name);\r\n}\r\n\r\n/**\r\n * Creates an app.tsx file that simply imports every discovered entry.\r\n * Helpful for HMR / dev mode.\r\n */\r\nfunction writeAppEntryFile(inputs: PluginInputs, srcRoot: string, appEntryName: string): void {\r\n const app = path.join(srcRoot, appEntryName);\r\n const lines: string[] = [\"// Auto-generated – do not edit\", \"\"];\r\n\r\n const entries = Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b));\r\n\r\n for (const [name, full] of entries) {\r\n const rel =\r\n \"./\" + path.relative(srcRoot, full).replace(/\\\\/g, \"/\").replace(EXT_PATTERN, \"\");\r\n\r\n const variable = name.replace(/[^a-zA-Z0-9_$]/g, \"_\").replace(/^(\\d)/, \"_$1\");\r\n\r\n lines.push(`import * as ${variable} from '${rel}';`);\r\n lines.push(`console.log('${name} loaded:', ${variable});`, \"\");\r\n }\r\n\r\n fs.writeFileSync(app, lines.join(\"\\n\"), \"utf8\");\r\n // eslint-disable-next-line no-console\r\n console.log(`✅ Generated ${appEntryName} in ${srcRoot}`);\r\n}\r\n\r\n/**\r\n * Convert a relative path like \"foo/bar/index.tsx\" to a dot key.\r\n * If `collapseIndex` is true, \"foo/bar/index\" becomes \"foo.bar\".\r\n * Otherwise it becomes \"foo.bar.index\".\r\n */\r\nfunction pathToKey(relNoExt: string, opts: { collapseIndex: boolean }): string {\r\n let normalized = relNoExt.replace(/\\\\/g, \"/\");\r\n\r\n if (opts.collapseIndex) {\r\n normalized = normalized.replace(/\\/index$/i, \"\");\r\n }\r\n\r\n let key = normalized.split(\"/\").filter(Boolean).join(\".\");\r\n if (!key) key = \"index\";\r\n return key;\r\n}\r\n\r\n/**\r\n * Recursively collect entry files under dirPath.\r\n *\r\n * Rule:\r\n * - Prefer collapsing \".../index.tsx\" => \"...\" for nicer keys\r\n * - BUT if that key would collide with another entry, fallback to explicit \"...index\"\r\n * (e.g. \"foo.index\") for the index file ONLY.\r\n */\r\nfunction crawl(\r\n dirPath: string,\r\n baseDir: string,\r\n acc: PluginInputs,\r\n sets: { ignoreDirs: Set<string>; componentLikeDirs: Set<string> },\r\n appEntryAbsPath: string\r\n): void {\r\n if (!fs.existsSync(dirPath)) return;\r\n\r\n for (const item of fs.readdirSync(dirPath)) {\r\n const full = path.join(dirPath, item);\r\n const stat = fs.statSync(full);\r\n\r\n if (stat.isDirectory()) {\r\n if (isIgnoredDir(item, sets)) continue;\r\n crawl(full, baseDir, acc, sets, appEntryAbsPath);\r\n continue;\r\n }\r\n\r\n if (!EXT_PATTERN.test(item)) continue;\r\n\r\n // Don't include the generated entry itself (prevents self-import)\r\n if (path.resolve(full) === path.resolve(appEntryAbsPath)) {\r\n continue;\r\n }\r\n\r\n const relNoExt = path.relative(baseDir, full).replace(EXT_PATTERN, \"\");\r\n const isIndexFile = /(^|[\\\\/])index$/i.test(relNoExt);\r\n\r\n // Preferred key: collapse \".../index\" => \"...\"\r\n const preferred = pathToKey(relNoExt, { collapseIndex: true });\r\n\r\n // Explicit key: keep \".../index\" => \"...index\"\r\n // Example: \"foo/index\" => \"foo.index\"\r\n const explicit = pathToKey(relNoExt, { collapseIndex: false });\r\n\r\n let name = preferred;\r\n\r\n // If preferred collides, ONLY the index file switches to explicit path key.\r\n const existing = acc[name];\r\n if (existing && path.resolve(existing) !== path.resolve(full)) {\r\n if (isIndexFile) {\r\n // Use foo.index (or deeper.path.index) instead of suffixing __2\r\n if (!acc[explicit]) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `⚠️ Key collision for \"${preferred}\" — using \"${explicit}\" for index file`,\r\n { existing: acc[preferred], incoming: full }\r\n );\r\n name = explicit;\r\n } else {\r\n // Extremely rare: even explicit collides (e.g. duplicate paths via symlinks)\r\n let i = 2;\r\n let next = `${explicit}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${explicit}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Key collision for \"${explicit}\" — using \"${next}\"`, {\r\n existing: acc[explicit],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n } else {\r\n // Non-index collision: suffix like original behavior\r\n let i = 2;\r\n let next = `${name}__${i}`;\r\n while (acc[next]) {\r\n i += 1;\r\n next = `${name}__${i}`;\r\n }\r\n // eslint-disable-next-line no-console\r\n console.warn(`⚠️ Input key collision \"${name}\" -> using \"${next}\"`, {\r\n existing: acc[name],\r\n incoming: full,\r\n });\r\n name = next;\r\n }\r\n }\r\n\r\n acc[name] = full;\r\n }\r\n}\r\n\r\n/**\r\n * Discover integration pages/components and return a Rollup input map.\r\n *\r\n * @param srcRoot absolute or relative path to the source folder (e.g. \"resources/embed/ts\")\r\n * @param options\r\n * @returns Rollup input map: { [key]: absolutePath }\r\n */\r\nexport function generatePluginInputs(\r\n srcRoot: string = path.resolve(process.cwd(), \"ts\"),\r\n options: GeneratePluginInputsOptions = {}\r\n): PluginInputs {\r\n const {\r\n writeAppEntry = false,\r\n appEntryName = \"app.tsx\",\r\n includeAppEntryInInputs = false,\r\n appEntryKey = \"__app_entry\",\r\n verbose = true,\r\n } = options;\r\n\r\n const absRoot = path.resolve(srcRoot);\r\n const inputs: PluginInputs = {};\r\n\r\n const sets = makeIgnoreSets(options);\r\n const appEntryAbsPath = path.join(absRoot, appEntryName);\r\n\r\n // Crawl everything under absRoot (no folder assumptions)\r\n crawl(absRoot, absRoot, inputs, sets, appEntryAbsPath);\r\n\r\n if (verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"✅ Integrations discovered:\", inputs);\r\n }\r\n\r\n if (writeAppEntry) {\r\n writeAppEntryFile(inputs, absRoot, appEntryName);\r\n }\r\n\r\n if (!includeAppEntryInInputs) return inputs;\r\n\r\n return { ...inputs, [appEntryKey]: appEntryAbsPath };\r\n}"],"mappings":";A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,UAChE,UAAU,IAAI,IAAI;AAAA,UAClB,UAAU;AAAA,QACd,CAAC;AACD,eAAO;AAAA,MACX;AAAA,IACJ;AAEA,QAAI,IAAI,IAAI;AAAA,EAChB;AACJ;AASO,SAAS,qBACZ,UAAkB,KAAK,QAAQ,QAAQ,IAAI,GAAG,IAAI,GAClD,UAAuC,CAAC,GAC5B;AACZ,QAAM;AAAA,IACF,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,0BAA0B;AAAA,IAC1B,cAAc;AAAA,IACd,UAAU;AAAA,EACd,IAAI;AAEJ,QAAM,UAAU,KAAK,QAAQ,OAAO;AACpC,QAAM,SAAuB,CAAC;AAE9B,QAAM,OAAO,eAAe,OAAO;AACnC,QAAM,kBAAkB,KAAK,KAAK,SAAS,YAAY;AAGvD,QAAM,SAAS,SAAS,QAAQ,MAAM,eAAe;AAErD,MAAI,SAAS;AAET,YAAQ,IAAI,mCAA8B,MAAM;AAAA,EACpD;AAEA,MAAI,eAAe;AACf,sBAAkB,QAAQ,SAAS,YAAY;AAAA,EACnD;AAEA,MAAI,CAAC,wBAAyB,QAAO;AAErC,SAAO,EAAE,GAAG,QAAQ,CAAC,WAAW,GAAG,gBAAgB;AACvD;","names":["path","shouldInject"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fortiplugin-bundle-adapter",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"
@@ -41,7 +41,7 @@
41
41
  "peerDependencies": {
42
42
  "react": "^18.0.0 || ^19.0.0",
43
43
  "rollup": "^4.0.0",
44
- "vite": "^5.0.0 || ^6.0.0"
44
+ "vite": "^5.0.0 || ^7"
45
45
  },
46
46
  "peerDependenciesMeta": {
47
47
  "vite": {