@inspecto-dev/plugin 0.3.7 → 0.3.8

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 (54) hide show
  1. package/README.md +2 -1
  2. package/dist/astro.cjs +2243 -0
  3. package/dist/astro.cjs.map +1 -0
  4. package/dist/astro.d.cts +17 -0
  5. package/dist/astro.d.ts +17 -0
  6. package/dist/astro.js +2212 -0
  7. package/dist/astro.js.map +1 -0
  8. package/dist/index.cjs +415 -14
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +21 -1
  11. package/dist/index.d.ts +21 -1
  12. package/dist/index.js +413 -14
  13. package/dist/index.js.map +1 -1
  14. package/dist/legacy/rspack/index.cjs +18 -18
  15. package/dist/legacy/rspack/index.cjs.map +1 -1
  16. package/dist/legacy/rspack/index.js +18 -18
  17. package/dist/legacy/rspack/index.js.map +1 -1
  18. package/dist/legacy/rspack/loader.cjs +404 -3
  19. package/dist/legacy/rspack/loader.cjs.map +1 -1
  20. package/dist/legacy/rspack/loader.js +400 -3
  21. package/dist/legacy/rspack/loader.js.map +1 -1
  22. package/dist/legacy/webpack4/index.cjs +7 -7
  23. package/dist/legacy/webpack4/index.cjs.map +1 -1
  24. package/dist/legacy/webpack4/index.js +7 -7
  25. package/dist/legacy/webpack4/index.js.map +1 -1
  26. package/dist/legacy/webpack4/loader.cjs +404 -3
  27. package/dist/legacy/webpack4/loader.cjs.map +1 -1
  28. package/dist/legacy/webpack4/loader.js +400 -3
  29. package/dist/legacy/webpack4/loader.js.map +1 -1
  30. package/dist/rollup.cjs +415 -14
  31. package/dist/rollup.cjs.map +1 -1
  32. package/dist/rollup.d.cts +1 -1
  33. package/dist/rollup.d.ts +1 -1
  34. package/dist/rollup.js +413 -14
  35. package/dist/rollup.js.map +1 -1
  36. package/dist/rspack.cjs +415 -14
  37. package/dist/rspack.cjs.map +1 -1
  38. package/dist/rspack.d.cts +1 -1
  39. package/dist/rspack.d.ts +1 -1
  40. package/dist/rspack.js +413 -14
  41. package/dist/rspack.js.map +1 -1
  42. package/dist/vite.cjs +415 -14
  43. package/dist/vite.cjs.map +1 -1
  44. package/dist/vite.d.cts +1 -1
  45. package/dist/vite.d.ts +1 -1
  46. package/dist/vite.js +413 -14
  47. package/dist/vite.js.map +1 -1
  48. package/dist/webpack.cjs +415 -14
  49. package/dist/webpack.cjs.map +1 -1
  50. package/dist/webpack.d.cts +1 -1
  51. package/dist/webpack.d.ts +1 -1
  52. package/dist/webpack.js +413 -14
  53. package/dist/webpack.js.map +1 -1
  54. package/package.json +9 -2
package/dist/index.d.cts CHANGED
@@ -23,6 +23,26 @@ interface TransformJsxOptions {
23
23
  */
24
24
  declare function transformJsx(options: TransformJsxOptions): TransformResult;
25
25
 
26
+ interface TransformAstroOptions {
27
+ filePath: string;
28
+ source: string;
29
+ escapeTags?: string[];
30
+ attributeName?: string;
31
+ }
32
+ declare function transformAstro(options: TransformAstroOptions): TransformResult;
33
+
34
+ interface RouterOptions {
35
+ filePath: string;
36
+ source: string;
37
+ projectRoot: string;
38
+ pluginOptions: Required<UnpluginOptions>;
39
+ }
40
+ /**
41
+ * Route a file to the appropriate transform based on extension.
42
+ * Returns null if no transform applies.
43
+ */
44
+ declare function transformRouter(options: RouterOptions): TransformResult | null;
45
+
26
46
  declare const InspectoPlugin: _unplugin.UnpluginInstance<UnpluginOptions | undefined, boolean>;
27
47
  declare const unplugin: _unplugin.UnpluginInstance<UnpluginOptions | undefined, boolean>;
28
48
  declare const vitePlugin: (options?: UnpluginOptions | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
@@ -31,4 +51,4 @@ declare const rspackPlugin: (options?: UnpluginOptions | undefined) => _unplugin
31
51
  declare const rollupPlugin: (options?: UnpluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
32
52
  declare const esbuildPlugin: (options?: UnpluginOptions | undefined) => _unplugin.EsbuildPlugin;
33
53
 
34
- export { InspectoPlugin as default, esbuildPlugin, rollupPlugin, rspackPlugin, transformJsx, unplugin, vitePlugin, webpackPlugin };
54
+ export { InspectoPlugin as default, esbuildPlugin, rollupPlugin, rspackPlugin, transformAstro, transformJsx, transformRouter, unplugin, vitePlugin, webpackPlugin };
package/dist/index.d.ts CHANGED
@@ -23,6 +23,26 @@ interface TransformJsxOptions {
23
23
  */
24
24
  declare function transformJsx(options: TransformJsxOptions): TransformResult;
25
25
 
26
+ interface TransformAstroOptions {
27
+ filePath: string;
28
+ source: string;
29
+ escapeTags?: string[];
30
+ attributeName?: string;
31
+ }
32
+ declare function transformAstro(options: TransformAstroOptions): TransformResult;
33
+
34
+ interface RouterOptions {
35
+ filePath: string;
36
+ source: string;
37
+ projectRoot: string;
38
+ pluginOptions: Required<UnpluginOptions>;
39
+ }
40
+ /**
41
+ * Route a file to the appropriate transform based on extension.
42
+ * Returns null if no transform applies.
43
+ */
44
+ declare function transformRouter(options: RouterOptions): TransformResult | null;
45
+
26
46
  declare const InspectoPlugin: _unplugin.UnpluginInstance<UnpluginOptions | undefined, boolean>;
27
47
  declare const unplugin: _unplugin.UnpluginInstance<UnpluginOptions | undefined, boolean>;
28
48
  declare const vitePlugin: (options?: UnpluginOptions | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
@@ -31,4 +51,4 @@ declare const rspackPlugin: (options?: UnpluginOptions | undefined) => _unplugin
31
51
  declare const rollupPlugin: (options?: UnpluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
32
52
  declare const esbuildPlugin: (options?: UnpluginOptions | undefined) => _unplugin.EsbuildPlugin;
33
53
 
34
- export { InspectoPlugin as default, esbuildPlugin, rollupPlugin, rspackPlugin, transformJsx, unplugin, vitePlugin, webpackPlugin };
54
+ export { InspectoPlugin as default, esbuildPlugin, rollupPlugin, rspackPlugin, transformAstro, transformJsx, transformRouter, unplugin, vitePlugin, webpackPlugin };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
2
+ get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
3
3
  }) : x)(function(x) {
4
4
  if (typeof require !== "undefined") return require.apply(this, arguments);
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
@@ -80,14 +80,14 @@ function extractTransformFilePath(requestId) {
80
80
  wrapped: filePath !== requestId
81
81
  };
82
82
  }
83
- function shouldTransform(filePath, options) {
83
+ function shouldTransform(filePath, _options) {
84
84
  const resolvedFilePath = extractTransformFilePath(filePath).filePath;
85
85
  if (process.env["NODE_ENV"] === "production") return false;
86
86
  if (resolvedFilePath.includes("node_modules")) return false;
87
87
  if (resolvedFilePath.startsWith("\0")) return false;
88
88
  if (/[/\\](dist|build|\.next|\.nuxt)[/\\]/.test(resolvedFilePath)) return false;
89
89
  const ext = resolvedFilePath.split(".").pop()?.toLowerCase();
90
- if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue"].includes(ext)) {
90
+ if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue", "svelte", "astro"].includes(ext)) {
91
91
  return false;
92
92
  }
93
93
  return true;
@@ -248,7 +248,7 @@ function transformVue(options) {
248
248
  if (escapeTagsSet.has(tagName)) return;
249
249
  if (tagName === "template" && node === ast.children[0]) return;
250
250
  const alreadyHasAttr = node.props.some(
251
- (p) => p.type === NodeTypes.ATTRIBUTE && p.name === attributeName
251
+ (p2) => p2.type === NodeTypes.ATTRIBUTE && p2.name === attributeName
252
252
  );
253
253
  if (alreadyHasAttr) return;
254
254
  const loc = node.loc;
@@ -285,6 +285,387 @@ function walkElement(node, visitor) {
285
285
  }
286
286
  }
287
287
 
288
+ // src/transform/transform-svelte.ts
289
+ import MagicString3 from "magic-string";
290
+ import { parse as parseSvelte } from "svelte/compiler";
291
+ function walk(node, visitor) {
292
+ if (!node || typeof node !== "object") return;
293
+ visitor.enter(node);
294
+ for (const key in node) {
295
+ if (key === "parent" || key === "prev" || key === "next") continue;
296
+ const value = node[key];
297
+ if (Array.isArray(value)) {
298
+ value.forEach((child) => {
299
+ if (child && typeof child === "object") walk(child, visitor);
300
+ });
301
+ } else if (value && typeof value === "object") {
302
+ walk(value, visitor);
303
+ }
304
+ }
305
+ }
306
+ function transformSvelte(options) {
307
+ const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
308
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
309
+ let replacedContent = source;
310
+ const scriptRegex = /<script(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/script>/gi;
311
+ const styleRegex = /<style(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/style>/gi;
312
+ const scriptMatches = source.match(scriptRegex) || [];
313
+ const styleMatches = source.match(styleRegex) || [];
314
+ [...scriptMatches, ...styleMatches].forEach((match) => {
315
+ replacedContent = replacedContent.replace(match, " ".repeat(match.length));
316
+ });
317
+ let ast;
318
+ try {
319
+ ast = parseSvelte(replacedContent);
320
+ } catch {
321
+ return { code: source, map: null, changed: false };
322
+ }
323
+ const s2 = new MagicString3(source);
324
+ let changed = false;
325
+ function countLines(text, position) {
326
+ let lines = 0;
327
+ for (let i2 = 0; i2 < position; i2++) {
328
+ if (text[i2] === "\n") lines++;
329
+ }
330
+ return lines;
331
+ }
332
+ const root = ast.html || ast.fragment || ast;
333
+ walk(root, {
334
+ enter(node) {
335
+ if (node.type === "Element" || node.type === "RegularElement" || node.type === "InlineComponent" || node.type === "Component") {
336
+ const tagName = node.name || "";
337
+ if (tagName && !escapeTagsSet.has(tagName.toLowerCase()) && !node.attributes?.some((attr) => attr.name === attributeName)) {
338
+ const insertPosition = node.start + tagName.length + 1;
339
+ const line = countLines(source, node.start) + 1;
340
+ const lastNewLine = source.lastIndexOf("\n", node.start - 1);
341
+ const column = lastNewLine === -1 ? node.start + 1 : node.start - lastNewLine;
342
+ const attrValue = formatAttrValue(filePath, line, column);
343
+ const addition = ` ${attributeName}="${attrValue}"`;
344
+ s2.appendLeft(insertPosition, addition);
345
+ changed = true;
346
+ }
347
+ }
348
+ }
349
+ });
350
+ return {
351
+ code: s2.toString(),
352
+ map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
353
+ changed
354
+ };
355
+ }
356
+
357
+ // src/transform/transform-astro.ts
358
+ import MagicString4 from "magic-string";
359
+
360
+ // ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
361
+ import g from "crypto";
362
+ import _ from "fs";
363
+ import { TextDecoder as b, TextEncoder as v } from "util";
364
+ globalThis.fs || Object.defineProperty(globalThis, "fs", { value: _ });
365
+ globalThis.process || Object.defineProperties(globalThis, "process", { value: process });
366
+ globalThis.crypto || Object.defineProperty(globalThis, "crypto", { value: g.webcrypto ? g.webcrypto : { getRandomValues(m2) {
367
+ return g.randomFillSync(m2);
368
+ } } });
369
+ globalThis.performance || Object.defineProperty(globalThis, "performance", { value: { now() {
370
+ let [m2, o] = process.hrtime();
371
+ return m2 * 1e3 + o / 1e6;
372
+ } } });
373
+ var y = new v("utf-8");
374
+ var w = new b("utf-8");
375
+ var d = class {
376
+ constructor() {
377
+ this.argv = ["js"], this.env = {}, this.exit = (t) => {
378
+ t !== 0 && console.warn("exit code:", t);
379
+ }, this._exitPromise = new Promise((t) => {
380
+ this._resolveExitPromise = t;
381
+ }), this._pendingEvent = null, this._scheduledTimeouts = /* @__PURE__ */ new Map(), this._nextCallbackTimeoutID = 1;
382
+ let o = (t, e) => {
383
+ this.mem.setUint32(t + 0, e, true), this.mem.setUint32(t + 4, Math.floor(e / 4294967296), true);
384
+ }, n = (t) => {
385
+ let e = this.mem.getUint32(t + 0, true), s2 = this.mem.getInt32(t + 4, true);
386
+ return e + s2 * 4294967296;
387
+ }, r = (t) => {
388
+ let e = this.mem.getFloat64(t, true);
389
+ if (e === 0) return;
390
+ if (!isNaN(e)) return e;
391
+ let s2 = this.mem.getUint32(t, true);
392
+ return this._values[s2];
393
+ }, l = (t, e) => {
394
+ if (typeof e == "number" && e !== 0) {
395
+ if (isNaN(e)) {
396
+ this.mem.setUint32(t + 4, 2146959360, true), this.mem.setUint32(t, 0, true);
397
+ return;
398
+ }
399
+ this.mem.setFloat64(t, e, true);
400
+ return;
401
+ }
402
+ if (e === void 0) {
403
+ this.mem.setFloat64(t, 0, true);
404
+ return;
405
+ }
406
+ let i2 = this._ids.get(e);
407
+ i2 === void 0 && (i2 = this._idPool.pop(), i2 === void 0 && (i2 = this._values.length), this._values[i2] = e, this._goRefCounts[i2] = 0, this._ids.set(e, i2)), this._goRefCounts[i2]++;
408
+ let a = 0;
409
+ switch (typeof e) {
410
+ case "object":
411
+ e !== null && (a = 1);
412
+ break;
413
+ case "string":
414
+ a = 2;
415
+ break;
416
+ case "symbol":
417
+ a = 3;
418
+ break;
419
+ case "function":
420
+ a = 4;
421
+ break;
422
+ }
423
+ this.mem.setUint32(t + 4, 2146959360 | a, true), this.mem.setUint32(t, i2, true);
424
+ }, c = (t) => {
425
+ let e = n(t + 0), s2 = n(t + 8);
426
+ return new Uint8Array(this._inst.exports.mem.buffer, e, s2);
427
+ }, f2 = (t) => {
428
+ let e = n(t + 0), s2 = n(t + 8), i2 = new Array(s2);
429
+ for (let a = 0; a < s2; a++) i2[a] = r(e + a * 8);
430
+ return i2;
431
+ }, u = (t) => {
432
+ let e = n(t + 0), s2 = n(t + 8);
433
+ return w.decode(new DataView(this._inst.exports.mem.buffer, e, s2));
434
+ }, h = Date.now() - performance.now();
435
+ this.importObject = { gojs: { "runtime.wasmExit": (t) => {
436
+ t >>>= 0;
437
+ let e = this.mem.getInt32(t + 8, true);
438
+ this.exited = true, delete this._inst, delete this._values, delete this._goRefCounts, delete this._ids, delete this._idPool, this.exit(e);
439
+ }, "runtime.wasmWrite": (t) => {
440
+ t >>>= 0;
441
+ let e = n(t + 8), s2 = n(t + 16), i2 = this.mem.getInt32(t + 24, true);
442
+ _.writeSync(e, new Uint8Array(this._inst.exports.mem.buffer, s2, i2));
443
+ }, "runtime.resetMemoryDataView": (t) => {
444
+ t >>>= 0, this.mem = new DataView(this._inst.exports.mem.buffer);
445
+ }, "runtime.nanotime1": (t) => {
446
+ t >>>= 0, o(t + 8, (h + performance.now()) * 1e6);
447
+ }, "runtime.walltime": (t) => {
448
+ t >>>= 0;
449
+ let e = (/* @__PURE__ */ new Date()).getTime();
450
+ o(t + 8, e / 1e3), this.mem.setInt32(t + 16, e % 1e3 * 1e6, true);
451
+ }, "runtime.scheduleTimeoutEvent": (t) => {
452
+ t >>>= 0;
453
+ let e = this._nextCallbackTimeoutID;
454
+ this._nextCallbackTimeoutID++, this._scheduledTimeouts.set(e, setTimeout(() => {
455
+ for (this._resume(); this._scheduledTimeouts.has(e); ) console.warn("scheduleTimeoutEvent: missed timeout event"), this._resume();
456
+ }, n(t + 8) + 1)), this.mem.setInt32(t + 16, e, true);
457
+ }, "runtime.clearTimeoutEvent": (t) => {
458
+ t >>>= 0;
459
+ let e = this.mem.getInt32(t + 8, true);
460
+ clearTimeout(this._scheduledTimeouts.get(e)), this._scheduledTimeouts.delete(e);
461
+ }, "runtime.getRandomData": (t) => {
462
+ t >>>= 0, globalThis.crypto.getRandomValues(c(t + 8));
463
+ }, "syscall/js.finalizeRef": (t) => {
464
+ t >>>= 0;
465
+ let e = this.mem.getUint32(t + 8, true);
466
+ if (this._goRefCounts[e]--, this._goRefCounts[e] === 0) {
467
+ let s2 = this._values[e];
468
+ this._values[e] = null, this._ids.delete(s2), this._idPool.push(e);
469
+ }
470
+ }, "syscall/js.stringVal": (t) => {
471
+ t >>>= 0, l(t + 24, u(t + 8));
472
+ }, "syscall/js.valueGet": (t) => {
473
+ t >>>= 0;
474
+ let e = Reflect.get(r(t + 8), u(t + 16));
475
+ t = this._inst.exports.getsp() >>> 0, l(t + 32, e);
476
+ }, "syscall/js.valueSet": (t) => {
477
+ t >>>= 0, Reflect.set(r(t + 8), u(t + 16), r(t + 32));
478
+ }, "syscall/js.valueDelete": (t) => {
479
+ t >>>= 0, Reflect.deleteProperty(r(t + 8), u(t + 16));
480
+ }, "syscall/js.valueIndex": (t) => {
481
+ t >>>= 0, l(t + 24, Reflect.get(r(t + 8), n(t + 16)));
482
+ }, "syscall/js.valueSetIndex": (t) => {
483
+ t >>>= 0, Reflect.set(r(t + 8), n(t + 16), r(t + 24));
484
+ }, "syscall/js.valueCall": (t) => {
485
+ t >>>= 0;
486
+ try {
487
+ let e = r(t + 8), s2 = Reflect.get(e, u(t + 16)), i2 = f2(t + 32), a = Reflect.apply(s2, e, i2);
488
+ t = this._inst.exports.getsp() >>> 0, l(t + 56, a), this.mem.setUint8(t + 64, 1);
489
+ } catch (e) {
490
+ t = this._inst.exports.getsp() >>> 0, l(t + 56, e), this.mem.setUint8(t + 64, 0);
491
+ }
492
+ }, "syscall/js.valueInvoke": (t) => {
493
+ t >>>= 0;
494
+ try {
495
+ let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.apply(e, void 0, s2);
496
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
497
+ } catch (e) {
498
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
499
+ }
500
+ }, "syscall/js.valueNew": (t) => {
501
+ t >>>= 0;
502
+ try {
503
+ let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.construct(e, s2);
504
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
505
+ } catch (e) {
506
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
507
+ }
508
+ }, "syscall/js.valueLength": (t) => {
509
+ t >>>= 0, o(t + 16, Number.parseInt(r(t + 8).length));
510
+ }, "syscall/js.valuePrepareString": (t) => {
511
+ t >>>= 0;
512
+ let e = y.encode(String(r(t + 8)));
513
+ l(t + 16, e), o(t + 24, e.length);
514
+ }, "syscall/js.valueLoadString": (t) => {
515
+ t >>>= 0;
516
+ let e = r(t + 8);
517
+ c(t + 16).set(e);
518
+ }, "syscall/js.valueInstanceOf": (t) => {
519
+ t >>>= 0, this.mem.setUint8(t + 24, r(t + 8) instanceof r(t + 16) ? 1 : 0);
520
+ }, "syscall/js.copyBytesToGo": (t) => {
521
+ t >>>= 0;
522
+ let e = c(t + 8), s2 = r(t + 32);
523
+ if (!(s2 instanceof Uint8Array || s2 instanceof Uint8ClampedArray)) {
524
+ this.mem.setUint8(t + 48, 0);
525
+ return;
526
+ }
527
+ let i2 = s2.subarray(0, e.length);
528
+ e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
529
+ }, "syscall/js.copyBytesToJS": (t) => {
530
+ t >>>= 0;
531
+ let e = r(t + 8), s2 = c(t + 16);
532
+ if (!(e instanceof Uint8Array || e instanceof Uint8ClampedArray)) {
533
+ this.mem.setUint8(t + 48, 0);
534
+ return;
535
+ }
536
+ let i2 = s2.subarray(0, e.length);
537
+ e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
538
+ }, debug: (t) => {
539
+ console.log(t);
540
+ } } };
541
+ }
542
+ async run(o) {
543
+ if (!(o instanceof WebAssembly.Instance)) throw new Error("Go.run: WebAssembly.Instance expected");
544
+ this._inst = o, this.mem = new DataView(this._inst.exports.mem.buffer), this._values = [Number.NaN, 0, null, true, false, globalThis, this], this._goRefCounts = new Array(this._values.length).fill(Number.POSITIVE_INFINITY), this._ids = /* @__PURE__ */ new Map([[0, 1], [null, 2], [true, 3], [false, 4], [globalThis, 5], [this, 6]]), this._idPool = [], this.exited = false;
545
+ let n = 4096, r = (h) => {
546
+ let t = n, e = y.encode(`${h}\0`);
547
+ return new Uint8Array(this.mem.buffer, n, e.length).set(e), n += e.length, n % 8 !== 0 && (n += 8 - n % 8), t;
548
+ }, l = this.argv.length, c = [];
549
+ this.argv.forEach((h) => {
550
+ c.push(r(h));
551
+ }), c.push(0), Object.keys(this.env).sort().forEach((h) => {
552
+ c.push(r(`${h}=${this.env[h]}`));
553
+ }), c.push(0);
554
+ let u = n;
555
+ c.forEach((h) => {
556
+ this.mem.setUint32(n, h, true), this.mem.setUint32(n + 4, 0, true), n += 8;
557
+ }), this._inst.exports.run(l, u), this.exited && this._resolveExitPromise(), await this._exitPromise;
558
+ }
559
+ _resume() {
560
+ if (this.exited) throw new Error("Go program has already exited");
561
+ this._inst.exports.resume(), this.exited && this._resolveExitPromise();
562
+ }
563
+ _makeFuncWrapper(o) {
564
+ let n = this;
565
+ return function() {
566
+ let r = { id: o, this: this, args: arguments };
567
+ return n._pendingEvent = r, n._resume(), r.result;
568
+ };
569
+ }
570
+ };
571
+
572
+ // ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/node/sync.js
573
+ import { readFileSync as p } from "fs";
574
+ import { fileURLToPath as m } from "url";
575
+ function i() {
576
+ return s || (s = f()), s;
577
+ }
578
+ var s;
579
+ var w2 = (e, t) => i().parse(e, t);
580
+ function f() {
581
+ let e = new d(), t = v2(m(new URL("../astro.wasm", import.meta.url)), e.importObject);
582
+ e.run(t);
583
+ let o = globalThis["@astrojs/compiler"];
584
+ return { transform: (n, a) => {
585
+ try {
586
+ return o.transform(n, a || {});
587
+ } catch (r) {
588
+ throw s = void 0, r;
589
+ }
590
+ }, parse: (n, a) => {
591
+ try {
592
+ let r = o.parse(n, a || {});
593
+ return { ...r, ast: JSON.parse(r.ast) };
594
+ } catch (r) {
595
+ throw s = void 0, r;
596
+ }
597
+ }, convertToTSX: (n, a) => {
598
+ try {
599
+ let r = o.convertToTSX(n, a || {});
600
+ return { ...r, map: JSON.parse(r.map) };
601
+ } catch (r) {
602
+ throw s = void 0, r;
603
+ }
604
+ } };
605
+ }
606
+ function v2(e, t) {
607
+ let o = p(e);
608
+ return new WebAssembly.Instance(new WebAssembly.Module(o), t);
609
+ }
610
+
611
+ // src/transform/transform-astro.ts
612
+ function walk2(node, visitor) {
613
+ if (!node || typeof node !== "object") return;
614
+ visitor.enter(node);
615
+ if (Array.isArray(node.children)) {
616
+ for (const child of node.children) {
617
+ walk2(child, visitor);
618
+ }
619
+ }
620
+ }
621
+ function transformAstro(options) {
622
+ const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
623
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
624
+ let ast;
625
+ try {
626
+ ast = w2(source, { position: true }).ast;
627
+ } catch (_err) {
628
+ return { code: source, map: null, changed: false };
629
+ }
630
+ const s2 = new MagicString4(source);
631
+ let changed = false;
632
+ walk2(ast, {
633
+ enter(node) {
634
+ if (node.type === "element" || node.type === "component") {
635
+ const tagName = node.name;
636
+ if (tagName && !escapeTagsSet.has(tagName) && !node.attributes?.some((attr) => attr.name === attributeName)) {
637
+ const startOffset = node.position?.start?.offset ?? -1;
638
+ if (startOffset === -1) return;
639
+ let tagStartIndex = startOffset;
640
+ while (tagStartIndex >= 0 && source[tagStartIndex] !== "<") {
641
+ tagStartIndex--;
642
+ }
643
+ if (tagStartIndex >= 0) {
644
+ const substringAfterTag = source.substring(tagStartIndex);
645
+ const escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
646
+ const strictRegex = new RegExp(`^<\\s*${escapedTagName}(?=\\s|/|>)`, "i");
647
+ const strictMatch = substringAfterTag.match(strictRegex);
648
+ if (strictMatch) {
649
+ const insertPosition = tagStartIndex + strictMatch[0].length;
650
+ const line = node.position.start.line;
651
+ const column = node.position.start.column;
652
+ const attrValue = formatAttrValue(filePath, line, column);
653
+ const addition = ` ${attributeName}="${attrValue}"`;
654
+ s2.appendLeft(insertPosition, addition);
655
+ changed = true;
656
+ }
657
+ }
658
+ }
659
+ }
660
+ }
661
+ });
662
+ return {
663
+ code: s2.toString(),
664
+ map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
665
+ changed
666
+ };
667
+ }
668
+
288
669
  // src/transform/index.ts
289
670
  function transformRouter(options) {
290
671
  const { filePath, source, projectRoot, pluginOptions } = options;
@@ -309,6 +690,22 @@ function transformRouter(options) {
309
690
  attributeName: pluginOptions.attributeName
310
691
  });
311
692
  }
693
+ if (ext === ".svelte") {
694
+ return transformSvelte({
695
+ filePath,
696
+ source,
697
+ escapeTags: pluginOptions.escapeTags,
698
+ attributeName: pluginOptions.attributeName
699
+ });
700
+ }
701
+ if (ext === ".astro") {
702
+ return transformAstro({
703
+ filePath,
704
+ source,
705
+ escapeTags: pluginOptions.escapeTags,
706
+ attributeName: pluginOptions.attributeName
707
+ });
708
+ }
312
709
  return null;
313
710
  }
314
711
 
@@ -451,7 +848,7 @@ function isDebugEnabled(namespace) {
451
848
  if (typeof process === "undefined" || !process.env) return false;
452
849
  const debugEnv = process.env.DEBUG;
453
850
  if (!debugEnv) return false;
454
- const namespaces = debugEnv.split(",").map((s) => s.trim());
851
+ const namespaces = debugEnv.split(",").map((s2) => s2.trim());
455
852
  for (const ns of namespaces) {
456
853
  if (ns === "*") return true;
457
854
  if (ns.endsWith("*")) {
@@ -607,7 +1004,7 @@ function readJsonSafely(filePath) {
607
1004
  }
608
1005
  return null;
609
1006
  }
610
- function resolveTargetTool(config, ide = "vscode") {
1007
+ function resolveTargetTool(config, _ide = "vscode") {
611
1008
  const defaultProvider = config["provider.default"];
612
1009
  if (defaultProvider) {
613
1010
  const tool = defaultProvider.split(".")[0];
@@ -715,7 +1112,7 @@ function resolveIntents(serverPrompts) {
715
1112
  configLogger.warn(`Intent "${item.id}" is missing required "aiIntent".`);
716
1113
  continue;
717
1114
  }
718
- const existingIdx = merged.findIndex((i) => i.id === item.id);
1115
+ const existingIdx = merged.findIndex((i2) => i2.id === item.id);
719
1116
  if (existingIdx !== -1) {
720
1117
  if (item.enabled === false) {
721
1118
  merged.splice(existingIdx, 1);
@@ -759,7 +1156,7 @@ function watchConfig(onReload, cwd = process.cwd(), gitRoot) {
759
1156
  });
760
1157
  watcher.unref();
761
1158
  watchers.push(watcher);
762
- } catch (e) {
1159
+ } catch (_e) {
763
1160
  }
764
1161
  }
765
1162
  }
@@ -1318,14 +1715,14 @@ async function startServer() {
1318
1715
  if (fs5.existsSync(portFile)) {
1319
1716
  try {
1320
1717
  portData = JSON.parse(fs5.readFileSync(portFile, "utf-8"));
1321
- } catch (e) {
1718
+ } catch (_e) {
1322
1719
  }
1323
1720
  }
1324
1721
  const rootHash = crypto2.createHash("md5").update(serverState.projectRoot).digest("hex");
1325
1722
  portData[rootHash] = port;
1326
1723
  fs5.writeFileSync(portFile, JSON.stringify(portData, null, 2), "utf-8");
1327
- } catch (e) {
1328
- serverLogger4.warn("Failed to write port file:", e);
1724
+ } catch (_e) {
1725
+ serverLogger4.warn("Failed to write port file:", _e);
1329
1726
  }
1330
1727
  process.once("exit", () => {
1331
1728
  try {
@@ -1398,7 +1795,7 @@ async function handleRequest(url, req, res) {
1398
1795
  let body;
1399
1796
  try {
1400
1797
  body = JSON.parse(await readBody(req));
1401
- } catch (e) {
1798
+ } catch (_e) {
1402
1799
  res.writeHead(400, { "Content-Type": "application/json" });
1403
1800
  res.end(JSON.stringify({ error: "Invalid JSON body" }));
1404
1801
  return;
@@ -1581,7 +1978,7 @@ function injectWebpack(compiler, serverPortFn, resolveClientModule2) {
1581
1978
  }
1582
1979
  compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
1583
1980
  const HtmlWebpackPlugin = compiler.options.plugins.find(
1584
- (p) => p && p.constructor && p.constructor.name === "HtmlWebpackPlugin"
1981
+ (p2) => p2 && p2.constructor && p2.constructor.name === "HtmlWebpackPlugin"
1585
1982
  );
1586
1983
  if (HtmlWebpackPlugin) {
1587
1984
  const hooks = HtmlWebpackPlugin.constructor.getHooks(compilation);
@@ -1625,7 +2022,7 @@ function injectRspack(compiler, serverPortFn, resolveClientModule2) {
1625
2022
  new compiler.webpack.EntryPlugin(compiler.context, inspectoClientPath, {}).apply(compiler);
1626
2023
  compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
1627
2024
  const HtmlRspackPlugin = compiler.options.plugins.find(
1628
- (p) => p && p.constructor && p.constructor.name === "HtmlRspackPlugin"
2025
+ (p2) => p2 && p2.constructor && p2.constructor.name === "HtmlRspackPlugin"
1629
2026
  );
1630
2027
  if (HtmlRspackPlugin) {
1631
2028
  const hooks = HtmlRspackPlugin.constructor.getHooks(compilation);
@@ -1783,7 +2180,9 @@ export {
1783
2180
  esbuildPlugin,
1784
2181
  rollupPlugin,
1785
2182
  rspackPlugin,
2183
+ transformAstro,
1786
2184
  transformJsx,
2185
+ transformRouter,
1787
2186
  unplugin,
1788
2187
  vitePlugin,
1789
2188
  webpackPlugin