@inspecto-dev/plugin 0.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/dist/index.cjs +1098 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +34 -0
  6. package/dist/index.d.ts +34 -0
  7. package/dist/index.js +1058 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/legacy/rspack/index.cjs +696 -0
  10. package/dist/legacy/rspack/index.cjs.map +1 -0
  11. package/dist/legacy/rspack/index.d.cts +10 -0
  12. package/dist/legacy/rspack/index.d.ts +10 -0
  13. package/dist/legacy/rspack/index.js +668 -0
  14. package/dist/legacy/rspack/index.js.map +1 -0
  15. package/dist/legacy/rspack/loader.cjs +310 -0
  16. package/dist/legacy/rspack/loader.cjs.map +1 -0
  17. package/dist/legacy/rspack/loader.d.cts +3 -0
  18. package/dist/legacy/rspack/loader.d.ts +3 -0
  19. package/dist/legacy/rspack/loader.js +277 -0
  20. package/dist/legacy/rspack/loader.js.map +1 -0
  21. package/dist/rollup.cjs +1098 -0
  22. package/dist/rollup.cjs.map +1 -0
  23. package/dist/rollup.d.cts +5 -0
  24. package/dist/rollup.d.ts +5 -0
  25. package/dist/rollup.js +1058 -0
  26. package/dist/rollup.js.map +1 -0
  27. package/dist/rspack.cjs +1098 -0
  28. package/dist/rspack.cjs.map +1 -0
  29. package/dist/rspack.d.cts +5 -0
  30. package/dist/rspack.d.ts +5 -0
  31. package/dist/rspack.js +1058 -0
  32. package/dist/rspack.js.map +1 -0
  33. package/dist/vite.cjs +1098 -0
  34. package/dist/vite.cjs.map +1 -0
  35. package/dist/vite.d.cts +5 -0
  36. package/dist/vite.d.ts +5 -0
  37. package/dist/vite.js +1058 -0
  38. package/dist/vite.js.map +1 -0
  39. package/dist/webpack.cjs +1098 -0
  40. package/dist/webpack.cjs.map +1 -0
  41. package/dist/webpack.d.cts +5 -0
  42. package/dist/webpack.d.ts +5 -0
  43. package/dist/webpack.js +1058 -0
  44. package/dist/webpack.js.map +1 -0
  45. package/legacy/rspack/index.cjs +1 -0
  46. package/legacy/rspack/index.d.ts +1 -0
  47. package/legacy/rspack/index.js +2 -0
  48. package/legacy/rspack/package.json +5 -0
  49. package/package.json +97 -0
@@ -0,0 +1,1098 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => src_default,
34
+ esbuildPlugin: () => esbuildPlugin,
35
+ rollupPlugin: () => rollupPlugin,
36
+ rspackPlugin: () => rspackPlugin,
37
+ transformJsx: () => transformJsx,
38
+ unplugin: () => unplugin,
39
+ vitePlugin: () => vitePlugin,
40
+ webpackPlugin: () => webpackPlugin
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+
44
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/cjs_shims.js
45
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
46
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
47
+
48
+ // src/index.ts
49
+ var import_unplugin = require("unplugin");
50
+
51
+ // src/transform/utils.ts
52
+ var DEFAULT_ESCAPE_TAGS = /* @__PURE__ */ new Set([
53
+ "template",
54
+ "script",
55
+ "style",
56
+ // React special elements
57
+ "Fragment",
58
+ "React.Fragment",
59
+ "StrictMode",
60
+ "React.StrictMode",
61
+ "Suspense",
62
+ "React.Suspense",
63
+ "Profiler",
64
+ "React.Profiler",
65
+ // React transitions
66
+ "Transition",
67
+ "TransitionGroup",
68
+ // Vue built-in components
69
+ "KeepAlive",
70
+ "Teleport",
71
+ "Suspense",
72
+ // Vue router built-ins
73
+ "RouterView",
74
+ "RouterLink",
75
+ "NuxtPage",
76
+ "NuxtLink"
77
+ ]);
78
+ var JSX_EXTENSIONS = /* @__PURE__ */ new Set([".jsx", ".tsx", ".js", ".ts", ".mjs", ".mts"]);
79
+ function shouldTransform(filePath, options) {
80
+ if (process.env["NODE_ENV"] === "production") return false;
81
+ if (filePath.includes("node_modules")) return false;
82
+ if (filePath.startsWith("\0")) return false;
83
+ if (/[/\\](dist|build|\.next|\.nuxt)[/\\]/.test(filePath)) return false;
84
+ return true;
85
+ }
86
+ function buildEscapeTagsSet(escapeTags) {
87
+ const merged = new Set(DEFAULT_ESCAPE_TAGS);
88
+ if (escapeTags) {
89
+ for (const tag of escapeTags) {
90
+ merged.add(tag);
91
+ }
92
+ }
93
+ return merged;
94
+ }
95
+ function formatAttrValue(file, line, column) {
96
+ return `${file}:${line}:${column}`;
97
+ }
98
+
99
+ // src/transform/index.ts
100
+ var import_node_path3 = __toESM(require("path"), 1);
101
+
102
+ // src/transform/transform-jsx.ts
103
+ var parser = __toESM(require("@babel/parser"), 1);
104
+ var import_traverse = __toESM(require("@babel/traverse"), 1);
105
+ var import_magic_string = __toESM(require("magic-string"), 1);
106
+ var import_node_path = __toESM(require("path"), 1);
107
+ var traverse = typeof import_traverse.default === "function" ? import_traverse.default : import_traverse.default.default || import_traverse.default;
108
+ function transformJsx(options) {
109
+ const {
110
+ filePath,
111
+ source,
112
+ projectRoot,
113
+ escapeTags,
114
+ pathType = "absolute",
115
+ attributeName = "data-inspecto"
116
+ } = options;
117
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
118
+ const resolvedPath = pathType === "absolute" ? import_node_path.default.resolve(filePath) : import_node_path.default.relative(projectRoot, import_node_path.default.resolve(filePath));
119
+ const normalizedPath = resolvedPath.replace(/\\/g, "/");
120
+ let ast;
121
+ try {
122
+ ast = parser.parse(source, {
123
+ sourceType: "module",
124
+ plugins: [
125
+ "jsx",
126
+ "typescript",
127
+ "decorators-legacy",
128
+ "classProperties",
129
+ "optionalChaining",
130
+ "nullishCoalescingOperator",
131
+ "importMeta"
132
+ ],
133
+ errorRecovery: true
134
+ });
135
+ } catch {
136
+ return { code: source, map: null, changed: false };
137
+ }
138
+ const ms = new import_magic_string.default(source);
139
+ let changed = false;
140
+ traverse(ast, {
141
+ JSXOpeningElement(nodePath) {
142
+ const node = nodePath.node;
143
+ const alreadyHasAttr = node.attributes.some(
144
+ (attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === attributeName
145
+ );
146
+ if (alreadyHasAttr) return;
147
+ const nameNode = node.name;
148
+ let tagName;
149
+ if (nameNode.type === "JSXIdentifier") {
150
+ tagName = nameNode.name;
151
+ } else if (nameNode.type === "JSXMemberExpression") {
152
+ const objName = nameNode.object.type === "JSXIdentifier" ? nameNode.object.name : "";
153
+ const propName = nameNode.property.type === "JSXIdentifier" ? nameNode.property.name : "";
154
+ tagName = objName && propName ? `${objName}.${propName}` : objName;
155
+ } else {
156
+ tagName = "";
157
+ }
158
+ if (escapeTagsSet.has(tagName)) return;
159
+ const loc = node.loc;
160
+ if (!loc) return;
161
+ const { line, column } = loc.start;
162
+ const attrValue = formatAttrValue(normalizedPath, line, column + 1);
163
+ let insertPos = null;
164
+ if (node.attributes && node.attributes.length > 0) {
165
+ const firstAttr = node.attributes[0];
166
+ if (firstAttr && firstAttr.start != null) {
167
+ insertPos = firstAttr.start;
168
+ }
169
+ }
170
+ if (insertPos == null) {
171
+ if (node.typeParameters && node.typeParameters.end != null) {
172
+ insertPos = node.typeParameters.end;
173
+ } else if (node.name.end != null) {
174
+ insertPos = node.name.end;
175
+ }
176
+ }
177
+ if (insertPos == null) return;
178
+ ms.appendLeft(
179
+ insertPos,
180
+ ` ${attributeName}="${attrValue}"${node.attributes && node.attributes.length > 0 ? "" : " "}`
181
+ );
182
+ changed = true;
183
+ }
184
+ });
185
+ if (!changed) {
186
+ return { code: source, map: null, changed: false };
187
+ }
188
+ return {
189
+ code: ms.toString(),
190
+ map: ms.generateMap({ hires: true, source: filePath }),
191
+ changed: true
192
+ };
193
+ }
194
+
195
+ // src/transform/transform-vue.ts
196
+ var vueCompiler = __toESM(require("@vue/compiler-dom"), 1);
197
+ var import_compiler_sfc = require("@vue/compiler-sfc");
198
+ var import_compiler_core = require("@vue/compiler-core");
199
+ var import_magic_string2 = __toESM(require("magic-string"), 1);
200
+ var import_node_path2 = __toESM(require("path"), 1);
201
+ function transformVue(options) {
202
+ const {
203
+ filePath,
204
+ source,
205
+ projectRoot,
206
+ escapeTags,
207
+ pathType = "absolute",
208
+ attributeName = "data-inspecto"
209
+ } = options;
210
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
211
+ const resolvedPath = pathType === "absolute" ? import_node_path2.default.resolve(filePath) : import_node_path2.default.relative(projectRoot, import_node_path2.default.resolve(filePath));
212
+ const normalizedPath = resolvedPath.replace(/\\/g, "/");
213
+ const { descriptor, errors } = (0, import_compiler_sfc.parse)(source, {
214
+ filename: filePath,
215
+ sourceMap: false,
216
+ ignoreEmpty: true
217
+ });
218
+ if (errors.length > 0 || !descriptor.template) {
219
+ return { code: source, map: null, changed: false };
220
+ }
221
+ const templateContent = descriptor.template.content;
222
+ const templateBlockStart = descriptor.template.loc.start.offset;
223
+ let ast;
224
+ try {
225
+ ast = vueCompiler.parse(templateContent, {
226
+ parseMode: "html",
227
+ // Preserve source locations relative to templateContent
228
+ onError: () => {
229
+ }
230
+ });
231
+ } catch {
232
+ return { code: source, map: null, changed: false };
233
+ }
234
+ const ms = new import_magic_string2.default(source);
235
+ let changed = false;
236
+ walkElement(ast, (node) => {
237
+ if (node.type !== import_compiler_core.NodeTypes.ELEMENT) return;
238
+ const tagName = node.tag;
239
+ if (escapeTagsSet.has(tagName)) return;
240
+ if (tagName === "template" && node === ast.children[0]) return;
241
+ const alreadyHasAttr = node.props.some(
242
+ (p) => p.type === import_compiler_core.NodeTypes.ATTRIBUTE && p.name === attributeName
243
+ );
244
+ if (alreadyHasAttr) return;
245
+ const loc = node.loc;
246
+ if (!loc) return;
247
+ const { line, column } = loc.start;
248
+ const attrValue = formatAttrValue(normalizedPath, line, column + 1);
249
+ const tagNameEnd = loc.start.offset + tagName.length + 1;
250
+ const absoluteOffset = templateBlockStart + tagNameEnd;
251
+ ms.appendLeft(absoluteOffset, ` ${attributeName}="${attrValue}"`);
252
+ changed = true;
253
+ });
254
+ if (!changed) {
255
+ return { code: source, map: null, changed: false };
256
+ }
257
+ return {
258
+ code: ms.toString(),
259
+ map: ms.generateMap({ hires: true, source: filePath }),
260
+ changed: true
261
+ };
262
+ }
263
+ function walkElement(node, visitor) {
264
+ if (node.type === import_compiler_core.NodeTypes.ELEMENT) {
265
+ visitor(node);
266
+ for (const child of node.children) {
267
+ walkElement(child, visitor);
268
+ }
269
+ } else if ("children" in node && Array.isArray(node.children)) {
270
+ for (const child of node.children) {
271
+ walkElement(child, visitor);
272
+ }
273
+ }
274
+ }
275
+
276
+ // src/transform/index.ts
277
+ function transformRouter(options) {
278
+ const { filePath, source, projectRoot, pluginOptions } = options;
279
+ const ext = import_node_path3.default.extname(filePath).toLowerCase();
280
+ if (JSX_EXTENSIONS.has(ext)) {
281
+ return transformJsx({
282
+ filePath,
283
+ source,
284
+ projectRoot,
285
+ escapeTags: pluginOptions.escapeTags,
286
+ pathType: pluginOptions.pathType,
287
+ attributeName: pluginOptions.attributeName
288
+ });
289
+ }
290
+ if (ext === ".vue") {
291
+ return transformVue({
292
+ filePath,
293
+ source,
294
+ projectRoot,
295
+ escapeTags: pluginOptions.escapeTags,
296
+ pathType: pluginOptions.pathType,
297
+ attributeName: pluginOptions.attributeName
298
+ });
299
+ }
300
+ return null;
301
+ }
302
+
303
+ // src/server/index.ts
304
+ var import_node_http = __toESM(require("http"), 1);
305
+ var import_node_fs2 = __toESM(require("fs"), 1);
306
+ var import_node_path5 = __toESM(require("path"), 1);
307
+ var import_node_os2 = __toESM(require("os"), 1);
308
+ var import_node_child_process = require("child_process");
309
+ var import_portfinder = __toESM(require("portfinder"), 1);
310
+ var import_launch_ide = require("launch-ide");
311
+
312
+ // src/server/snippet.ts
313
+ var fs = __toESM(require("fs"), 1);
314
+ var path4 = __toESM(require("path"), 1);
315
+ var parser2 = __toESM(require("@babel/parser"), 1);
316
+ var import_traverse2 = __toESM(require("@babel/traverse"), 1);
317
+ var traverse2 = typeof import_traverse2.default === "function" ? import_traverse2.default : import_traverse2.default.default || import_traverse2.default;
318
+ var snippetCache = /* @__PURE__ */ new Map();
319
+ var DEFAULT_MAX_LINES = 100;
320
+ var DEFAULT_CONTEXT_LINES_BEFORE = 5;
321
+ async function extractSnippet(req) {
322
+ const { file, line, column, maxLines = DEFAULT_MAX_LINES } = req;
323
+ const absolutePath = path4.resolve(file);
324
+ let stat;
325
+ try {
326
+ stat = await fs.promises.stat(absolutePath);
327
+ } catch {
328
+ throw new Error(`FILE_NOT_FOUND: ${absolutePath}`);
329
+ }
330
+ const mtime = stat.mtimeMs;
331
+ let lines;
332
+ const cached = snippetCache.get(absolutePath);
333
+ if (cached && cached.mtime === mtime) {
334
+ lines = cached.lines;
335
+ } else {
336
+ const source = await fs.promises.readFile(absolutePath, "utf-8");
337
+ lines = source.split("\n");
338
+ snippetCache.set(absolutePath, { mtime, lines });
339
+ }
340
+ let snippetLines;
341
+ let startLine;
342
+ let componentName;
343
+ try {
344
+ const result = extractComponentBoundary(lines.join("\n"), line, column, maxLines);
345
+ snippetLines = result.lines;
346
+ startLine = result.startLine;
347
+ componentName = result.name;
348
+ } catch {
349
+ const before = Math.max(0, line - 1 - DEFAULT_CONTEXT_LINES_BEFORE);
350
+ const after = Math.min(lines.length, before + maxLines);
351
+ snippetLines = lines.slice(before, after);
352
+ startLine = before + 1;
353
+ }
354
+ if (snippetLines.length > maxLines) {
355
+ snippetLines = snippetLines.slice(0, maxLines);
356
+ }
357
+ return {
358
+ snippet: snippetLines.join("\n"),
359
+ startLine,
360
+ file: absolutePath,
361
+ ...componentName ? { name: componentName } : {}
362
+ };
363
+ }
364
+ function extractComponentBoundary(source, targetLine, _targetColumn, maxLines) {
365
+ const ast = parser2.parse(source, {
366
+ sourceType: "module",
367
+ plugins: ["jsx", "typescript", "decorators-legacy", "classProperties"],
368
+ errorRecovery: true
369
+ });
370
+ const allLines = source.split("\n");
371
+ let bestStart = 0;
372
+ let bestEnd = allLines.length - 1;
373
+ let bestName;
374
+ traverse2(ast, {
375
+ "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ClassMethod"(nodePath) {
376
+ const node = nodePath.node;
377
+ if (!node.loc) return;
378
+ const nodeStart = node.loc.start.line;
379
+ const nodeEnd = node.loc.end.line;
380
+ if (targetLine < nodeStart || targetLine > nodeEnd) return;
381
+ if (nodeEnd - nodeStart < bestEnd - bestStart) {
382
+ bestStart = nodeStart - 1;
383
+ bestEnd = nodeEnd - 1;
384
+ bestName = extractFunctionName(nodePath);
385
+ }
386
+ }
387
+ });
388
+ let sliceStart = bestStart;
389
+ let sliceEnd = bestEnd + 1;
390
+ if (sliceEnd - sliceStart > maxLines) {
391
+ const targetIdx = targetLine - 1;
392
+ sliceStart = Math.max(bestStart, targetIdx - Math.floor(maxLines / 3));
393
+ sliceEnd = sliceStart + maxLines;
394
+ if (sliceEnd > bestEnd + 1) {
395
+ sliceEnd = bestEnd + 1;
396
+ sliceStart = Math.max(0, sliceEnd - maxLines);
397
+ }
398
+ }
399
+ return {
400
+ lines: allLines.slice(sliceStart, sliceEnd),
401
+ startLine: sliceStart + 1,
402
+ ...bestName ? { name: bestName } : {}
403
+ };
404
+ }
405
+ function extractFunctionName(nodePath) {
406
+ const node = nodePath.node;
407
+ if (node.type === "FunctionDeclaration" && node.id) {
408
+ return node.id.name;
409
+ }
410
+ const parent = nodePath.parent;
411
+ if ((node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && parent.type === "VariableDeclarator" && parent.id.type === "Identifier") {
412
+ return parent.id.name;
413
+ }
414
+ if (node.type === "ClassMethod" && node.key.type === "Identifier") {
415
+ return node.key.name;
416
+ }
417
+ return void 0;
418
+ }
419
+
420
+ // src/config.ts
421
+ var import_node_fs = __toESM(require("fs"), 1);
422
+ var import_node_path4 = __toESM(require("path"), 1);
423
+ var import_node_os = __toESM(require("os"), 1);
424
+ var import_defu = require("defu");
425
+ var import_types = require("@inspecto-dev/types");
426
+ var loadedConfig = null;
427
+ var loadedPrompts = null;
428
+ var isWatching = false;
429
+ var arrayReplaceMerge = (0, import_defu.createDefu)((obj, key, val) => {
430
+ if (Array.isArray(val)) {
431
+ obj[key] = val;
432
+ return true;
433
+ }
434
+ });
435
+ function resolveConfigRoots(cwd, gitRoot) {
436
+ const roots = [];
437
+ let current = cwd;
438
+ const isUnderOrEqual = current === gitRoot || current.startsWith(gitRoot + import_node_path4.default.sep);
439
+ if (!isUnderOrEqual) {
440
+ if (import_node_fs.default.existsSync(import_node_path4.default.join(cwd, ".inspecto"))) roots.push(cwd);
441
+ return roots;
442
+ }
443
+ while (true) {
444
+ if (import_node_fs.default.existsSync(import_node_path4.default.join(current, ".inspecto"))) {
445
+ roots.push(current);
446
+ }
447
+ if (current === gitRoot) break;
448
+ const parent = import_node_path4.default.dirname(current);
449
+ if (parent === current) break;
450
+ current = parent;
451
+ }
452
+ return roots;
453
+ }
454
+ function loadUserConfigSync(force = false, cwd = process.cwd(), gitRoot) {
455
+ if (loadedConfig && !force) return loadedConfig;
456
+ loadedConfig = null;
457
+ const layers = [];
458
+ const roots = resolveConfigRoots(cwd, gitRoot ?? cwd);
459
+ for (const root of roots) {
460
+ layers.push(readJsonSafely(import_node_path4.default.join(root, ".inspecto", "settings.local.json")));
461
+ layers.push(readJsonSafely(import_node_path4.default.join(root, ".inspecto", "settings.json")));
462
+ }
463
+ layers.push(readJsonSafely(import_node_path4.default.join(import_node_os.default.homedir(), ".inspecto", "settings.json")));
464
+ layers.push({ providers: {} });
465
+ const validLayers = layers.filter((l) => l !== null);
466
+ loadedConfig = arrayReplaceMerge(...validLayers);
467
+ return loadedConfig;
468
+ }
469
+ async function loadPromptsConfig(force = false, cwd = process.cwd(), gitRoot) {
470
+ if (loadedPrompts && !force) return loadedPrompts;
471
+ const layers = [];
472
+ const roots = resolveConfigRoots(cwd, gitRoot ?? cwd);
473
+ for (const root of roots) {
474
+ const localPath = import_node_path4.default.join(root, ".inspecto", "prompts.local.json");
475
+ const jsonPath = import_node_path4.default.join(root, ".inspecto", "prompts.json");
476
+ layers.push(readJsonSafely(localPath));
477
+ layers.push(readJsonSafely(jsonPath));
478
+ }
479
+ layers.push(readJsonSafely(import_node_path4.default.join(import_node_os.default.homedir(), ".inspecto", "prompts.json")));
480
+ let finalPrompts = [];
481
+ for (const layer of layers) {
482
+ if (Array.isArray(layer) && layer.length > 0) {
483
+ finalPrompts = layer;
484
+ break;
485
+ }
486
+ if (layer && typeof layer === "object" && layer.$replace === true && Array.isArray(layer.items)) {
487
+ finalPrompts = layer;
488
+ break;
489
+ }
490
+ }
491
+ loadedPrompts = finalPrompts;
492
+ return loadedPrompts;
493
+ }
494
+ function readJsonSafely(filePath) {
495
+ try {
496
+ if (import_node_fs.default.existsSync(filePath)) {
497
+ const content = import_node_fs.default.readFileSync(filePath, "utf-8").trim();
498
+ if (!content) return null;
499
+ const parsed = JSON.parse(content);
500
+ if (!Array.isArray(parsed) && parsed.prompts && Array.isArray(parsed.prompts)) {
501
+ return parsed.prompts;
502
+ }
503
+ return parsed;
504
+ }
505
+ } catch (e) {
506
+ if (e instanceof SyntaxError) {
507
+ console.warn(`[inspecto] Failed to parse config at ${filePath}: Invalid JSON`);
508
+ } else {
509
+ console.warn(`[inspecto] Failed to read config at ${filePath}:`, e);
510
+ }
511
+ }
512
+ return null;
513
+ }
514
+ function resolveTargetTool(config) {
515
+ if (config.prefer) {
516
+ return config.prefer;
517
+ }
518
+ if (config.providers && Object.keys(config.providers).length > 0) {
519
+ return Object.keys(config.providers)[0];
520
+ }
521
+ return "github-copilot";
522
+ }
523
+ function resolveToolMode(tool, ide, config) {
524
+ let requestedType = void 0;
525
+ if (config.providers && config.providers[tool] && config.providers[tool].type) {
526
+ const type = config.providers[tool].type;
527
+ if (type === "plugin" || type === "cli") {
528
+ requestedType = type;
529
+ }
530
+ }
531
+ requestedType = requestedType ?? import_types.DEFAULT_TOOL_MODE[tool];
532
+ const valid = import_types.VALID_MODES[tool] || [import_types.DEFAULT_TOOL_MODE[tool]];
533
+ return requestedType && valid.includes(requestedType) ? requestedType : valid[0];
534
+ }
535
+ function extractToolOverrides(ide, config) {
536
+ const result = {};
537
+ if (!config.providers) return result;
538
+ for (const [tool, cfg] of Object.entries(config.providers)) {
539
+ if (!cfg) continue;
540
+ const overrides = {
541
+ type: cfg.type || import_types.DEFAULT_TOOL_MODE[tool] || "plugin"
542
+ };
543
+ if (cfg.bin) overrides.binaryPath = cfg.bin;
544
+ if (cfg.args) overrides.args = cfg.args;
545
+ if (cfg.cwd) overrides.cwd = cfg.cwd;
546
+ if (cfg.autoSend !== void 0) overrides.autoSend = cfg.autoSend;
547
+ result[tool] = overrides;
548
+ }
549
+ return result;
550
+ }
551
+ var watchers = [];
552
+ function watchConfig(onReload, cwd = process.cwd(), gitRoot) {
553
+ if (isWatching) return;
554
+ isWatching = true;
555
+ const watchDirs = [import_node_path4.default.join(import_node_os.default.homedir(), ".inspecto")];
556
+ const roots = resolveConfigRoots(cwd, gitRoot ?? cwd);
557
+ for (const root of roots) {
558
+ watchDirs.push(import_node_path4.default.join(root, ".inspecto"));
559
+ }
560
+ const CONFIG_FILES = /* @__PURE__ */ new Set([
561
+ "settings.json",
562
+ "settings.local.json",
563
+ "prompts.json",
564
+ "prompts.local.json"
565
+ ]);
566
+ for (const dir of watchDirs) {
567
+ if (!import_node_fs.default.existsSync(dir)) continue;
568
+ try {
569
+ const watcher = import_node_fs.default.watch(dir, async (eventType, filename) => {
570
+ if (!filename || !CONFIG_FILES.has(filename)) return;
571
+ loadedConfig = null;
572
+ loadedPrompts = null;
573
+ loadUserConfigSync(true, cwd, gitRoot);
574
+ await loadPromptsConfig(true, cwd, gitRoot);
575
+ onReload();
576
+ });
577
+ watcher.unref();
578
+ watchers.push(watcher);
579
+ } catch (e) {
580
+ }
581
+ }
582
+ }
583
+
584
+ // src/server/index.ts
585
+ var serverState = {
586
+ port: null,
587
+ running: false,
588
+ projectRoot: "",
589
+ configRoot: "",
590
+ cwd: process.cwd()
591
+ };
592
+ var serverInstance = null;
593
+ function resolveProjectRoot() {
594
+ let gitRoot;
595
+ try {
596
+ gitRoot = (0, import_node_child_process.execSync)("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
597
+ } catch {
598
+ gitRoot = process.cwd();
599
+ }
600
+ let current = gitRoot;
601
+ while (true) {
602
+ if (import_node_fs2.default.existsSync(import_node_path5.default.join(current, ".inspecto"))) return current;
603
+ const parent = import_node_path5.default.dirname(current);
604
+ if (parent === current) break;
605
+ current = parent;
606
+ }
607
+ return gitRoot;
608
+ }
609
+ function launchURI(uri) {
610
+ try {
611
+ if (process.platform === "darwin") {
612
+ (0, import_node_child_process.execFileSync)("open", [uri]);
613
+ } else if (process.platform === "win32") {
614
+ (0, import_node_child_process.execFileSync)("cmd", ["/c", "start", '""', uri]);
615
+ } else {
616
+ (0, import_node_child_process.execFileSync)("xdg-open", [uri]);
617
+ }
618
+ } catch (e) {
619
+ console.error("[inspecto] Failed to launch URI via execFileSync, falling back to launchIDE:", e);
620
+ (0, import_launch_ide.launchIDE)({ file: uri });
621
+ }
622
+ }
623
+ async function startServer() {
624
+ if (serverState.running && serverState.port !== null) {
625
+ return serverState.port;
626
+ }
627
+ serverState.projectRoot = resolveProjectRoot();
628
+ serverState.configRoot = serverState.projectRoot;
629
+ serverState.cwd = process.cwd();
630
+ import_portfinder.default.basePort = 5678;
631
+ const port = await import_portfinder.default.getPortPromise();
632
+ watchConfig(
633
+ () => {
634
+ console.log("[inspecto] user config reloaded.");
635
+ },
636
+ serverState.cwd,
637
+ serverState.configRoot
638
+ );
639
+ serverInstance = import_node_http.default.createServer((req, res) => {
640
+ res.setHeader("Access-Control-Allow-Origin", "*");
641
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
642
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
643
+ if (req.method === "OPTIONS") {
644
+ res.writeHead(204);
645
+ res.end();
646
+ return;
647
+ }
648
+ const url = new URL(req.url ?? "/", `http://localhost:${port}`);
649
+ handleRequest(url, req, res).catch((err) => {
650
+ console.error("[inspecto] server error:", err);
651
+ res.writeHead(500, { "Content-Type": "application/json" });
652
+ res.end(JSON.stringify({ success: false, error: String(err) }));
653
+ });
654
+ });
655
+ await new Promise((resolve2, reject) => {
656
+ serverInstance.listen(port, "127.0.0.1", () => {
657
+ serverInstance.unref();
658
+ resolve2();
659
+ });
660
+ serverInstance.once("error", reject);
661
+ });
662
+ serverInstance.on("error", (err) => {
663
+ console.error("[inspecto] persistent server error:", err);
664
+ });
665
+ serverState.port = port;
666
+ serverState.running = true;
667
+ const portFile = import_node_path5.default.join(import_node_os2.default.tmpdir(), "inspecto.port");
668
+ try {
669
+ import_node_fs2.default.writeFileSync(portFile, String(port), "utf-8");
670
+ } catch {
671
+ }
672
+ process.once("exit", () => {
673
+ try {
674
+ import_node_fs2.default.unlinkSync(portFile);
675
+ } catch {
676
+ }
677
+ });
678
+ console.log(`[inspecto] server running at http://127.0.0.1:${port}`);
679
+ return port;
680
+ }
681
+ async function readBody(req) {
682
+ return new Promise((resolve2, reject) => {
683
+ const chunks = [];
684
+ req.on("data", (chunk) => chunks.push(chunk));
685
+ req.on("end", () => resolve2(Buffer.concat(chunks).toString("utf-8")));
686
+ req.on("error", reject);
687
+ });
688
+ }
689
+ async function handleRequest(url, req, res) {
690
+ const pathname = url.pathname;
691
+ if (pathname === "/health" && req.method === "GET") {
692
+ res.writeHead(200, { "Content-Type": "application/json" });
693
+ res.end(JSON.stringify({ ok: true, port: serverState.port }));
694
+ return;
695
+ }
696
+ if (pathname === "/config" && req.method === "GET") {
697
+ const userConfig = loadUserConfigSync(false, serverState.cwd, serverState.configRoot);
698
+ const promptsConfig = await loadPromptsConfig(false, serverState.cwd, serverState.configRoot);
699
+ const effectiveIde = userConfig.ide ?? "vscode";
700
+ let info;
701
+ if (!serverState.ideInfo) {
702
+ const fallbackTargets = userConfig.providers ? Object.keys(userConfig.providers) : ["claude-code", "gemini", "coco", "codex"];
703
+ info = {
704
+ ide: effectiveIde,
705
+ providers: fallbackTargets.reduce(
706
+ (acc, target) => {
707
+ acc[target] = {
708
+ mode: resolveToolMode(target, effectiveIde, userConfig),
709
+ installed: false
710
+ };
711
+ return acc;
712
+ },
713
+ {}
714
+ )
715
+ };
716
+ } else {
717
+ const { scheme: _scheme, ...rest } = serverState.ideInfo;
718
+ info = rest;
719
+ }
720
+ const resolvedProviders = { ...info.providers };
721
+ for (const tool in resolvedProviders) {
722
+ resolvedProviders[tool].mode = resolveToolMode(tool, info.ide, userConfig);
723
+ }
724
+ const config = {
725
+ ...info,
726
+ providers: resolvedProviders,
727
+ providerOverrides: extractToolOverrides(info.ide, userConfig),
728
+ prompts: promptsConfig,
729
+ hotKeys: userConfig.hotKeys,
730
+ includeSnippet: userConfig.includeSnippet
731
+ };
732
+ res.writeHead(200, { "Content-Type": "application/json" });
733
+ res.end(JSON.stringify(config));
734
+ return;
735
+ }
736
+ if (pathname === "/config" && req.method === "POST") {
737
+ try {
738
+ const body = JSON.parse(await readBody(req));
739
+ serverState.ideInfo = body;
740
+ console.log(`[inspecto] Received IDE info from extension:`, body);
741
+ res.writeHead(200, { "Content-Type": "application/json" });
742
+ res.end(JSON.stringify({ success: true }));
743
+ } catch (e) {
744
+ console.error("[inspecto] Error parsing /config POST request:", e);
745
+ res.writeHead(400, { "Content-Type": "application/json" });
746
+ res.end(JSON.stringify({ error: "Invalid JSON body" }));
747
+ }
748
+ return;
749
+ }
750
+ if (pathname === "/open" && req.method === "POST") {
751
+ let body;
752
+ try {
753
+ body = JSON.parse(await readBody(req));
754
+ } catch (e) {
755
+ res.writeHead(400, { "Content-Type": "application/json" });
756
+ res.end(JSON.stringify({ error: "Invalid JSON body" }));
757
+ return;
758
+ }
759
+ const absolutePath = import_node_path5.default.isAbsolute(body.file) ? body.file : import_node_path5.default.resolve(serverState.cwd, body.file);
760
+ const userConfig = loadUserConfigSync(false, serverState.cwd, serverState.configRoot);
761
+ const ide = userConfig.ide ?? "vscode";
762
+ const editorHint = "code";
763
+ (0, import_launch_ide.launchIDE)({
764
+ file: absolutePath,
765
+ line: body.line,
766
+ column: body.column,
767
+ editor: editorHint,
768
+ type: process.platform === "darwin" ? "open" : "exec"
769
+ });
770
+ res.writeHead(200, { "Content-Type": "application/json" });
771
+ res.end(JSON.stringify({ success: true }));
772
+ return;
773
+ }
774
+ if (pathname === "/snippet" && req.method === "GET") {
775
+ const file = url.searchParams.get("file") ?? "";
776
+ const line = parseInt(url.searchParams.get("line") ?? "1", 10);
777
+ const column = parseInt(url.searchParams.get("column") ?? "1", 10);
778
+ const maxLines = parseInt(url.searchParams.get("maxLines") ?? "100", 10);
779
+ try {
780
+ const absolutePath = import_node_path5.default.isAbsolute(file) ? file : import_node_path5.default.resolve(serverState.cwd, file);
781
+ const result = await extractSnippet({ file: absolutePath, line, column, maxLines });
782
+ res.writeHead(200, { "Content-Type": "application/json" });
783
+ res.end(JSON.stringify(result));
784
+ } catch (err) {
785
+ const message = String(err.message || err);
786
+ const errorCode = message.startsWith("FILE_NOT_FOUND") ? "FILE_NOT_FOUND" : "UNKNOWN";
787
+ res.writeHead(404, { "Content-Type": "application/json" });
788
+ res.end(JSON.stringify({ success: false, error: message, errorCode }));
789
+ }
790
+ return;
791
+ }
792
+ if (pathname === "/send-to-ai" && req.method === "POST") {
793
+ try {
794
+ const rawBody = await readBody(req);
795
+ const body = JSON.parse(rawBody);
796
+ const result = await dispatchToAi(body);
797
+ res.writeHead(result.success ? 200 : 500, { "Content-Type": "application/json" });
798
+ res.end(JSON.stringify(result));
799
+ } catch (e) {
800
+ console.error("[inspecto] Error parsing /send-to-ai request:", e);
801
+ res.writeHead(500, { "Content-Type": "application/json" });
802
+ res.end(JSON.stringify({ success: false, error: String(e), errorCode: "INTERNAL_ERROR" }));
803
+ }
804
+ return;
805
+ }
806
+ res.writeHead(404, { "Content-Type": "application/json" });
807
+ res.end(JSON.stringify({ error: "not found" }));
808
+ }
809
+ async function dispatchToAi(req) {
810
+ const { location, snippet, prompt } = req;
811
+ const userConfig = loadUserConfigSync(false, serverState.cwd, serverState.configRoot);
812
+ const ide = userConfig.ide ?? "vscode";
813
+ const resolvedTarget = resolveTargetTool(userConfig);
814
+ const formattedPrompt = prompt ?? `Please help me with this code from \`${location.file}\` (line ${location.line}):
815
+
816
+ \`\`\`
817
+ ${snippet}
818
+ \`\`\`
819
+ `;
820
+ const params = new URLSearchParams();
821
+ params.set("target", resolvedTarget);
822
+ const overrides = extractToolOverrides(ide, userConfig)[resolvedTarget];
823
+ if (overrides) {
824
+ params.set("overrides", JSON.stringify(overrides));
825
+ }
826
+ params.set("prompt", formattedPrompt);
827
+ params.set("file", location.file);
828
+ params.set("line", String(location.line));
829
+ params.set("col", String(location.column));
830
+ params.set("snippet", snippet);
831
+ const scheme = serverState.ideInfo?.scheme || "vscode";
832
+ const uri = `${scheme}://inspecto.inspecto/send?${params.toString()}`;
833
+ console.log(`[inspecto] dispatchToAi: Generated URI: ${uri}`);
834
+ launchURI(uri);
835
+ return { success: true };
836
+ }
837
+
838
+ // src/injectors/utils.ts
839
+ var import_node_module = require("module");
840
+ var resolveClientModule = () => {
841
+ try {
842
+ return (0, import_node_module.createRequire)(importMetaUrl).resolve("@inspecto-dev/core");
843
+ } catch {
844
+ try {
845
+ return require.resolve("@inspecto-dev/core");
846
+ } catch {
847
+ console.warn("[inspecto] Could not resolve @inspecto-dev/core \u2014 falling back to bare specifier");
848
+ return "@inspecto-dev/core";
849
+ }
850
+ }
851
+ };
852
+
853
+ // src/injectors/webpack.ts
854
+ function getWebpackHtmlScript(serverPort) {
855
+ return `
856
+ window.__AI_INSPECTOR_PORT__ = ${serverPort};
857
+ window.addEventListener('load', () => {
858
+ if (window.InspectoClient) {
859
+ window.InspectoClient.mountInspector({
860
+ serverUrl: 'http://127.0.0.1:' + window.__AI_INSPECTOR_PORT__,
861
+ });
862
+ }
863
+ });
864
+ `;
865
+ }
866
+ function getWebpackAssetScript(serverPort) {
867
+ return `
868
+ if (typeof window !== 'undefined') {
869
+ window.__AI_INSPECTOR_PORT__ = ${serverPort};
870
+ const _initInspecto = () => {
871
+ if (window.InspectoClient) {
872
+ window.InspectoClient.mountInspector({
873
+ serverUrl: 'http://127.0.0.1:' + window.__AI_INSPECTOR_PORT__,
874
+ });
875
+ } else {
876
+ setTimeout(_initInspecto, 100);
877
+ }
878
+ };
879
+ if (document.readyState === 'complete') {
880
+ _initInspecto();
881
+ } else {
882
+ window.addEventListener('load', _initInspecto);
883
+ }
884
+ }
885
+ `;
886
+ }
887
+ function injectWebpack(compiler, serverPortFn, resolveClientModule2) {
888
+ const inspectoClientPath = resolveClientModule2();
889
+ new compiler.webpack.EntryPlugin(compiler.context, inspectoClientPath, { name: void 0 }).apply(
890
+ compiler
891
+ );
892
+ compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
893
+ const HtmlWebpackPlugin = compiler.options.plugins.find(
894
+ (p) => p && p.constructor && p.constructor.name === "HtmlWebpackPlugin"
895
+ );
896
+ if (HtmlWebpackPlugin) {
897
+ const hooks = HtmlWebpackPlugin.constructor.getHooks(compilation);
898
+ hooks.alterAssetTagGroups.tapPromise("inspecto-overlay", async (data) => {
899
+ const port = await serverPortFn();
900
+ data.headTags.unshift({
901
+ tagName: "script",
902
+ voidTag: false,
903
+ meta: { plugin: "inspecto-overlay" },
904
+ innerHTML: getWebpackHtmlScript(port)
905
+ });
906
+ return data;
907
+ });
908
+ } else {
909
+ compilation.hooks.processAssets.tapPromise(
910
+ {
911
+ name: "inspecto-overlay",
912
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
913
+ },
914
+ async (assets) => {
915
+ const port = await serverPortFn();
916
+ const mainAssetKey = Object.keys(assets).find(
917
+ (key) => key.endsWith(".js") && (key.includes("main") || key.includes("app"))
918
+ );
919
+ if (!mainAssetKey) return;
920
+ const originalSource = assets[mainAssetKey].source();
921
+ assets[mainAssetKey] = new compiler.webpack.sources.RawSource(
922
+ getWebpackAssetScript(port) + "\n" + originalSource
923
+ );
924
+ }
925
+ );
926
+ }
927
+ });
928
+ }
929
+
930
+ // src/injectors/rspack.ts
931
+ function injectRspack(compiler, serverPortFn, resolveClientModule2) {
932
+ const inspectoClientPath = resolveClientModule2();
933
+ new compiler.webpack.EntryPlugin(compiler.context, inspectoClientPath, {}).apply(compiler);
934
+ compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
935
+ const HtmlRspackPlugin = compiler.options.plugins.find(
936
+ (p) => p && p.constructor && p.constructor.name === "HtmlRspackPlugin"
937
+ );
938
+ if (HtmlRspackPlugin) {
939
+ const hooks = HtmlRspackPlugin.constructor.getHooks(compilation);
940
+ hooks.alterAssetTagGroups.tapPromise("inspecto-overlay", async (data) => {
941
+ const port = await serverPortFn();
942
+ data.headTags.unshift({
943
+ tagName: "script",
944
+ voidTag: false,
945
+ meta: { plugin: "inspecto-overlay" },
946
+ innerHTML: getWebpackHtmlScript(port)
947
+ });
948
+ return data;
949
+ });
950
+ }
951
+ });
952
+ }
953
+
954
+ // src/injectors/vite.ts
955
+ function getViteVirtualModuleScript(serverPort) {
956
+ return `
957
+ import { mountInspector } from '@inspecto-dev/core';
958
+ window.__AI_INSPECTOR_PORT__ = ${serverPort};
959
+ mountInspector({
960
+ serverUrl: 'http://127.0.0.1:' + window.__AI_INSPECTOR_PORT__,
961
+ });
962
+ `;
963
+ }
964
+ var VITE_VIRTUAL_MODULE_ID = "\0virtual:inspecto-client";
965
+ var VITE_VIRTUAL_IMPORT_ID = "/@id/__x00__virtual:inspecto-client";
966
+
967
+ // src/index.ts
968
+ var DEFAULT_OPTIONS = {
969
+ include: [],
970
+ exclude: [],
971
+ escapeTags: [],
972
+ pathType: "absolute",
973
+ attributeName: "data-inspecto"
974
+ };
975
+ var DEFAULT_PORT = 5678;
976
+ var getCleanId = (id) => id.split("?")[0];
977
+ var InspectoPlugin = (0, import_unplugin.createUnplugin)((userOptions = {}) => {
978
+ const options = {
979
+ ...DEFAULT_OPTIONS,
980
+ ...userOptions
981
+ };
982
+ const isProduction = process.env["NODE_ENV"] === "production";
983
+ let projectRoot = process.cwd();
984
+ let serverPort = null;
985
+ const ensureServer = async () => {
986
+ if (serverPort === null) {
987
+ serverPort = await startServer();
988
+ }
989
+ return serverPort;
990
+ };
991
+ return {
992
+ name: "inspecto-overlay",
993
+ enforce: "pre",
994
+ buildStart() {
995
+ if (isProduction) return;
996
+ projectRoot = serverState.cwd || process.cwd();
997
+ ensureServer().catch(console.error);
998
+ },
999
+ buildEnd() {
1000
+ },
1001
+ webpack: (compiler) => {
1002
+ if (isProduction) return;
1003
+ injectWebpack(compiler, ensureServer, resolveClientModule);
1004
+ },
1005
+ rspack: (compiler) => {
1006
+ if (isProduction) return;
1007
+ injectRspack(compiler, ensureServer, resolveClientModule);
1008
+ },
1009
+ vite: {
1010
+ config(config) {
1011
+ if (isProduction) return config;
1012
+ return {
1013
+ ...config,
1014
+ define: {
1015
+ ...config.define,
1016
+ __AI_INSPECTOR_PORT__: JSON.stringify(DEFAULT_PORT)
1017
+ // Placeholder, rewritten in configureServer
1018
+ }
1019
+ };
1020
+ },
1021
+ resolveId(id) {
1022
+ if (id === "virtual:inspecto-client") {
1023
+ return VITE_VIRTUAL_MODULE_ID;
1024
+ }
1025
+ return null;
1026
+ },
1027
+ load(id) {
1028
+ if (id === VITE_VIRTUAL_MODULE_ID) {
1029
+ return getViteVirtualModuleScript(serverPort ?? DEFAULT_PORT);
1030
+ }
1031
+ return null;
1032
+ },
1033
+ async configureServer(server) {
1034
+ if (isProduction) return;
1035
+ const port = await ensureServer();
1036
+ if (!server.config.define) {
1037
+ ;
1038
+ server.config.define = {};
1039
+ }
1040
+ ;
1041
+ server.config.define["__AI_INSPECTOR_PORT__"] = JSON.stringify(port);
1042
+ const mod = server.moduleGraph.getModuleById(VITE_VIRTUAL_MODULE_ID);
1043
+ if (mod) server.moduleGraph.invalidateModule(mod);
1044
+ },
1045
+ transformIndexHtml(html) {
1046
+ if (isProduction || !serverPort) return html;
1047
+ return {
1048
+ html,
1049
+ tags: [
1050
+ {
1051
+ tag: "script",
1052
+ attrs: { type: "module" },
1053
+ children: `import '${VITE_VIRTUAL_IMPORT_ID}';`
1054
+ }
1055
+ ]
1056
+ };
1057
+ }
1058
+ },
1059
+ transformInclude(id) {
1060
+ if (isProduction || !id) return false;
1061
+ const cleanId = getCleanId(id);
1062
+ return shouldTransform(cleanId, options);
1063
+ },
1064
+ transform(code, id) {
1065
+ if (isProduction || !id) return null;
1066
+ const cleanId = getCleanId(id);
1067
+ const result = transformRouter({
1068
+ filePath: cleanId,
1069
+ source: code,
1070
+ projectRoot,
1071
+ pluginOptions: options
1072
+ });
1073
+ if (!result || !result.changed) return null;
1074
+ return {
1075
+ code: result.code,
1076
+ map: result.map
1077
+ };
1078
+ }
1079
+ };
1080
+ });
1081
+ var unplugin = InspectoPlugin;
1082
+ var vitePlugin = InspectoPlugin.vite;
1083
+ var webpackPlugin = InspectoPlugin.webpack;
1084
+ var rspackPlugin = InspectoPlugin.rspack;
1085
+ var rollupPlugin = InspectoPlugin.rollup;
1086
+ var esbuildPlugin = InspectoPlugin.esbuild;
1087
+ var src_default = InspectoPlugin;
1088
+ // Annotate the CommonJS export names for ESM import in node:
1089
+ 0 && (module.exports = {
1090
+ esbuildPlugin,
1091
+ rollupPlugin,
1092
+ rspackPlugin,
1093
+ transformJsx,
1094
+ unplugin,
1095
+ vitePlugin,
1096
+ webpackPlugin
1097
+ });
1098
+ //# sourceMappingURL=webpack.cjs.map