@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/vite.cjs CHANGED
@@ -34,14 +34,16 @@ __export(src_exports, {
34
34
  esbuildPlugin: () => esbuildPlugin,
35
35
  rollupPlugin: () => rollupPlugin,
36
36
  rspackPlugin: () => rspackPlugin,
37
+ transformAstro: () => transformAstro,
37
38
  transformJsx: () => transformJsx,
39
+ transformRouter: () => transformRouter,
38
40
  unplugin: () => unplugin,
39
41
  vitePlugin: () => vitePlugin,
40
42
  webpackPlugin: () => webpackPlugin
41
43
  });
42
44
  module.exports = __toCommonJS(src_exports);
43
45
 
44
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.9_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/cjs_shims.js
46
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.10_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/cjs_shims.js
45
47
  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
48
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
47
49
 
@@ -120,14 +122,14 @@ function extractTransformFilePath(requestId) {
120
122
  wrapped: filePath !== requestId
121
123
  };
122
124
  }
123
- function shouldTransform(filePath, options) {
125
+ function shouldTransform(filePath, _options) {
124
126
  const resolvedFilePath = extractTransformFilePath(filePath).filePath;
125
127
  if (process.env["NODE_ENV"] === "production") return false;
126
128
  if (resolvedFilePath.includes("node_modules")) return false;
127
129
  if (resolvedFilePath.startsWith("\0")) return false;
128
130
  if (/[/\\](dist|build|\.next|\.nuxt)[/\\]/.test(resolvedFilePath)) return false;
129
131
  const ext = resolvedFilePath.split(".").pop()?.toLowerCase();
130
- if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue"].includes(ext)) {
132
+ if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue", "svelte", "astro"].includes(ext)) {
131
133
  return false;
132
134
  }
133
135
  return true;
@@ -288,7 +290,7 @@ function transformVue(options) {
288
290
  if (escapeTagsSet.has(tagName)) return;
289
291
  if (tagName === "template" && node === ast.children[0]) return;
290
292
  const alreadyHasAttr = node.props.some(
291
- (p) => p.type === import_compiler_core.NodeTypes.ATTRIBUTE && p.name === attributeName
293
+ (p2) => p2.type === import_compiler_core.NodeTypes.ATTRIBUTE && p2.name === attributeName
292
294
  );
293
295
  if (alreadyHasAttr) return;
294
296
  const loc = node.loc;
@@ -325,6 +327,387 @@ function walkElement(node, visitor) {
325
327
  }
326
328
  }
327
329
 
330
+ // src/transform/transform-svelte.ts
331
+ var import_magic_string3 = __toESM(require("magic-string"), 1);
332
+ var import_compiler = require("svelte/compiler");
333
+ function walk(node, visitor) {
334
+ if (!node || typeof node !== "object") return;
335
+ visitor.enter(node);
336
+ for (const key in node) {
337
+ if (key === "parent" || key === "prev" || key === "next") continue;
338
+ const value = node[key];
339
+ if (Array.isArray(value)) {
340
+ value.forEach((child) => {
341
+ if (child && typeof child === "object") walk(child, visitor);
342
+ });
343
+ } else if (value && typeof value === "object") {
344
+ walk(value, visitor);
345
+ }
346
+ }
347
+ }
348
+ function transformSvelte(options) {
349
+ const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
350
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
351
+ let replacedContent = source;
352
+ const scriptRegex = /<script(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/script>/gi;
353
+ const styleRegex = /<style(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/style>/gi;
354
+ const scriptMatches = source.match(scriptRegex) || [];
355
+ const styleMatches = source.match(styleRegex) || [];
356
+ [...scriptMatches, ...styleMatches].forEach((match) => {
357
+ replacedContent = replacedContent.replace(match, " ".repeat(match.length));
358
+ });
359
+ let ast;
360
+ try {
361
+ ast = (0, import_compiler.parse)(replacedContent);
362
+ } catch {
363
+ return { code: source, map: null, changed: false };
364
+ }
365
+ const s2 = new import_magic_string3.default(source);
366
+ let changed = false;
367
+ function countLines(text, position) {
368
+ let lines = 0;
369
+ for (let i2 = 0; i2 < position; i2++) {
370
+ if (text[i2] === "\n") lines++;
371
+ }
372
+ return lines;
373
+ }
374
+ const root = ast.html || ast.fragment || ast;
375
+ walk(root, {
376
+ enter(node) {
377
+ if (node.type === "Element" || node.type === "RegularElement" || node.type === "InlineComponent" || node.type === "Component") {
378
+ const tagName = node.name || "";
379
+ if (tagName && !escapeTagsSet.has(tagName.toLowerCase()) && !node.attributes?.some((attr) => attr.name === attributeName)) {
380
+ const insertPosition = node.start + tagName.length + 1;
381
+ const line = countLines(source, node.start) + 1;
382
+ const lastNewLine = source.lastIndexOf("\n", node.start - 1);
383
+ const column = lastNewLine === -1 ? node.start + 1 : node.start - lastNewLine;
384
+ const attrValue = formatAttrValue(filePath, line, column);
385
+ const addition = ` ${attributeName}="${attrValue}"`;
386
+ s2.appendLeft(insertPosition, addition);
387
+ changed = true;
388
+ }
389
+ }
390
+ }
391
+ });
392
+ return {
393
+ code: s2.toString(),
394
+ map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
395
+ changed
396
+ };
397
+ }
398
+
399
+ // src/transform/transform-astro.ts
400
+ var import_magic_string4 = __toESM(require("magic-string"), 1);
401
+
402
+ // ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
403
+ var import_crypto = __toESM(require("crypto"), 1);
404
+ var import_fs = __toESM(require("fs"), 1);
405
+ var import_util = require("util");
406
+ globalThis.fs || Object.defineProperty(globalThis, "fs", { value: import_fs.default });
407
+ globalThis.process || Object.defineProperties(globalThis, "process", { value: process });
408
+ globalThis.crypto || Object.defineProperty(globalThis, "crypto", { value: import_crypto.default.webcrypto ? import_crypto.default.webcrypto : { getRandomValues(m2) {
409
+ return import_crypto.default.randomFillSync(m2);
410
+ } } });
411
+ globalThis.performance || Object.defineProperty(globalThis, "performance", { value: { now() {
412
+ let [m2, o] = process.hrtime();
413
+ return m2 * 1e3 + o / 1e6;
414
+ } } });
415
+ var y = new import_util.TextEncoder("utf-8");
416
+ var w = new import_util.TextDecoder("utf-8");
417
+ var d = class {
418
+ constructor() {
419
+ this.argv = ["js"], this.env = {}, this.exit = (t) => {
420
+ t !== 0 && console.warn("exit code:", t);
421
+ }, this._exitPromise = new Promise((t) => {
422
+ this._resolveExitPromise = t;
423
+ }), this._pendingEvent = null, this._scheduledTimeouts = /* @__PURE__ */ new Map(), this._nextCallbackTimeoutID = 1;
424
+ let o = (t, e) => {
425
+ this.mem.setUint32(t + 0, e, true), this.mem.setUint32(t + 4, Math.floor(e / 4294967296), true);
426
+ }, n = (t) => {
427
+ let e = this.mem.getUint32(t + 0, true), s2 = this.mem.getInt32(t + 4, true);
428
+ return e + s2 * 4294967296;
429
+ }, r = (t) => {
430
+ let e = this.mem.getFloat64(t, true);
431
+ if (e === 0) return;
432
+ if (!isNaN(e)) return e;
433
+ let s2 = this.mem.getUint32(t, true);
434
+ return this._values[s2];
435
+ }, l = (t, e) => {
436
+ if (typeof e == "number" && e !== 0) {
437
+ if (isNaN(e)) {
438
+ this.mem.setUint32(t + 4, 2146959360, true), this.mem.setUint32(t, 0, true);
439
+ return;
440
+ }
441
+ this.mem.setFloat64(t, e, true);
442
+ return;
443
+ }
444
+ if (e === void 0) {
445
+ this.mem.setFloat64(t, 0, true);
446
+ return;
447
+ }
448
+ let i2 = this._ids.get(e);
449
+ 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]++;
450
+ let a = 0;
451
+ switch (typeof e) {
452
+ case "object":
453
+ e !== null && (a = 1);
454
+ break;
455
+ case "string":
456
+ a = 2;
457
+ break;
458
+ case "symbol":
459
+ a = 3;
460
+ break;
461
+ case "function":
462
+ a = 4;
463
+ break;
464
+ }
465
+ this.mem.setUint32(t + 4, 2146959360 | a, true), this.mem.setUint32(t, i2, true);
466
+ }, c = (t) => {
467
+ let e = n(t + 0), s2 = n(t + 8);
468
+ return new Uint8Array(this._inst.exports.mem.buffer, e, s2);
469
+ }, f2 = (t) => {
470
+ let e = n(t + 0), s2 = n(t + 8), i2 = new Array(s2);
471
+ for (let a = 0; a < s2; a++) i2[a] = r(e + a * 8);
472
+ return i2;
473
+ }, u = (t) => {
474
+ let e = n(t + 0), s2 = n(t + 8);
475
+ return w.decode(new DataView(this._inst.exports.mem.buffer, e, s2));
476
+ }, h = Date.now() - performance.now();
477
+ this.importObject = { gojs: { "runtime.wasmExit": (t) => {
478
+ t >>>= 0;
479
+ let e = this.mem.getInt32(t + 8, true);
480
+ this.exited = true, delete this._inst, delete this._values, delete this._goRefCounts, delete this._ids, delete this._idPool, this.exit(e);
481
+ }, "runtime.wasmWrite": (t) => {
482
+ t >>>= 0;
483
+ let e = n(t + 8), s2 = n(t + 16), i2 = this.mem.getInt32(t + 24, true);
484
+ import_fs.default.writeSync(e, new Uint8Array(this._inst.exports.mem.buffer, s2, i2));
485
+ }, "runtime.resetMemoryDataView": (t) => {
486
+ t >>>= 0, this.mem = new DataView(this._inst.exports.mem.buffer);
487
+ }, "runtime.nanotime1": (t) => {
488
+ t >>>= 0, o(t + 8, (h + performance.now()) * 1e6);
489
+ }, "runtime.walltime": (t) => {
490
+ t >>>= 0;
491
+ let e = (/* @__PURE__ */ new Date()).getTime();
492
+ o(t + 8, e / 1e3), this.mem.setInt32(t + 16, e % 1e3 * 1e6, true);
493
+ }, "runtime.scheduleTimeoutEvent": (t) => {
494
+ t >>>= 0;
495
+ let e = this._nextCallbackTimeoutID;
496
+ this._nextCallbackTimeoutID++, this._scheduledTimeouts.set(e, setTimeout(() => {
497
+ for (this._resume(); this._scheduledTimeouts.has(e); ) console.warn("scheduleTimeoutEvent: missed timeout event"), this._resume();
498
+ }, n(t + 8) + 1)), this.mem.setInt32(t + 16, e, true);
499
+ }, "runtime.clearTimeoutEvent": (t) => {
500
+ t >>>= 0;
501
+ let e = this.mem.getInt32(t + 8, true);
502
+ clearTimeout(this._scheduledTimeouts.get(e)), this._scheduledTimeouts.delete(e);
503
+ }, "runtime.getRandomData": (t) => {
504
+ t >>>= 0, globalThis.crypto.getRandomValues(c(t + 8));
505
+ }, "syscall/js.finalizeRef": (t) => {
506
+ t >>>= 0;
507
+ let e = this.mem.getUint32(t + 8, true);
508
+ if (this._goRefCounts[e]--, this._goRefCounts[e] === 0) {
509
+ let s2 = this._values[e];
510
+ this._values[e] = null, this._ids.delete(s2), this._idPool.push(e);
511
+ }
512
+ }, "syscall/js.stringVal": (t) => {
513
+ t >>>= 0, l(t + 24, u(t + 8));
514
+ }, "syscall/js.valueGet": (t) => {
515
+ t >>>= 0;
516
+ let e = Reflect.get(r(t + 8), u(t + 16));
517
+ t = this._inst.exports.getsp() >>> 0, l(t + 32, e);
518
+ }, "syscall/js.valueSet": (t) => {
519
+ t >>>= 0, Reflect.set(r(t + 8), u(t + 16), r(t + 32));
520
+ }, "syscall/js.valueDelete": (t) => {
521
+ t >>>= 0, Reflect.deleteProperty(r(t + 8), u(t + 16));
522
+ }, "syscall/js.valueIndex": (t) => {
523
+ t >>>= 0, l(t + 24, Reflect.get(r(t + 8), n(t + 16)));
524
+ }, "syscall/js.valueSetIndex": (t) => {
525
+ t >>>= 0, Reflect.set(r(t + 8), n(t + 16), r(t + 24));
526
+ }, "syscall/js.valueCall": (t) => {
527
+ t >>>= 0;
528
+ try {
529
+ let e = r(t + 8), s2 = Reflect.get(e, u(t + 16)), i2 = f2(t + 32), a = Reflect.apply(s2, e, i2);
530
+ t = this._inst.exports.getsp() >>> 0, l(t + 56, a), this.mem.setUint8(t + 64, 1);
531
+ } catch (e) {
532
+ t = this._inst.exports.getsp() >>> 0, l(t + 56, e), this.mem.setUint8(t + 64, 0);
533
+ }
534
+ }, "syscall/js.valueInvoke": (t) => {
535
+ t >>>= 0;
536
+ try {
537
+ let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.apply(e, void 0, s2);
538
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
539
+ } catch (e) {
540
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
541
+ }
542
+ }, "syscall/js.valueNew": (t) => {
543
+ t >>>= 0;
544
+ try {
545
+ let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.construct(e, s2);
546
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
547
+ } catch (e) {
548
+ t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
549
+ }
550
+ }, "syscall/js.valueLength": (t) => {
551
+ t >>>= 0, o(t + 16, Number.parseInt(r(t + 8).length));
552
+ }, "syscall/js.valuePrepareString": (t) => {
553
+ t >>>= 0;
554
+ let e = y.encode(String(r(t + 8)));
555
+ l(t + 16, e), o(t + 24, e.length);
556
+ }, "syscall/js.valueLoadString": (t) => {
557
+ t >>>= 0;
558
+ let e = r(t + 8);
559
+ c(t + 16).set(e);
560
+ }, "syscall/js.valueInstanceOf": (t) => {
561
+ t >>>= 0, this.mem.setUint8(t + 24, r(t + 8) instanceof r(t + 16) ? 1 : 0);
562
+ }, "syscall/js.copyBytesToGo": (t) => {
563
+ t >>>= 0;
564
+ let e = c(t + 8), s2 = r(t + 32);
565
+ if (!(s2 instanceof Uint8Array || s2 instanceof Uint8ClampedArray)) {
566
+ this.mem.setUint8(t + 48, 0);
567
+ return;
568
+ }
569
+ let i2 = s2.subarray(0, e.length);
570
+ e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
571
+ }, "syscall/js.copyBytesToJS": (t) => {
572
+ t >>>= 0;
573
+ let e = r(t + 8), s2 = c(t + 16);
574
+ if (!(e instanceof Uint8Array || e instanceof Uint8ClampedArray)) {
575
+ this.mem.setUint8(t + 48, 0);
576
+ return;
577
+ }
578
+ let i2 = s2.subarray(0, e.length);
579
+ e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
580
+ }, debug: (t) => {
581
+ console.log(t);
582
+ } } };
583
+ }
584
+ async run(o) {
585
+ if (!(o instanceof WebAssembly.Instance)) throw new Error("Go.run: WebAssembly.Instance expected");
586
+ 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;
587
+ let n = 4096, r = (h) => {
588
+ let t = n, e = y.encode(`${h}\0`);
589
+ return new Uint8Array(this.mem.buffer, n, e.length).set(e), n += e.length, n % 8 !== 0 && (n += 8 - n % 8), t;
590
+ }, l = this.argv.length, c = [];
591
+ this.argv.forEach((h) => {
592
+ c.push(r(h));
593
+ }), c.push(0), Object.keys(this.env).sort().forEach((h) => {
594
+ c.push(r(`${h}=${this.env[h]}`));
595
+ }), c.push(0);
596
+ let u = n;
597
+ c.forEach((h) => {
598
+ this.mem.setUint32(n, h, true), this.mem.setUint32(n + 4, 0, true), n += 8;
599
+ }), this._inst.exports.run(l, u), this.exited && this._resolveExitPromise(), await this._exitPromise;
600
+ }
601
+ _resume() {
602
+ if (this.exited) throw new Error("Go program has already exited");
603
+ this._inst.exports.resume(), this.exited && this._resolveExitPromise();
604
+ }
605
+ _makeFuncWrapper(o) {
606
+ let n = this;
607
+ return function() {
608
+ let r = { id: o, this: this, args: arguments };
609
+ return n._pendingEvent = r, n._resume(), r.result;
610
+ };
611
+ }
612
+ };
613
+
614
+ // ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/node/sync.js
615
+ var import_fs2 = require("fs");
616
+ var import_url = require("url");
617
+ function i() {
618
+ return s || (s = f()), s;
619
+ }
620
+ var s;
621
+ var w2 = (e, t) => i().parse(e, t);
622
+ function f() {
623
+ let e = new d(), t = v2((0, import_url.fileURLToPath)(new URL("../astro.wasm", importMetaUrl)), e.importObject);
624
+ e.run(t);
625
+ let o = globalThis["@astrojs/compiler"];
626
+ return { transform: (n, a) => {
627
+ try {
628
+ return o.transform(n, a || {});
629
+ } catch (r) {
630
+ throw s = void 0, r;
631
+ }
632
+ }, parse: (n, a) => {
633
+ try {
634
+ let r = o.parse(n, a || {});
635
+ return { ...r, ast: JSON.parse(r.ast) };
636
+ } catch (r) {
637
+ throw s = void 0, r;
638
+ }
639
+ }, convertToTSX: (n, a) => {
640
+ try {
641
+ let r = o.convertToTSX(n, a || {});
642
+ return { ...r, map: JSON.parse(r.map) };
643
+ } catch (r) {
644
+ throw s = void 0, r;
645
+ }
646
+ } };
647
+ }
648
+ function v2(e, t) {
649
+ let o = (0, import_fs2.readFileSync)(e);
650
+ return new WebAssembly.Instance(new WebAssembly.Module(o), t);
651
+ }
652
+
653
+ // src/transform/transform-astro.ts
654
+ function walk2(node, visitor) {
655
+ if (!node || typeof node !== "object") return;
656
+ visitor.enter(node);
657
+ if (Array.isArray(node.children)) {
658
+ for (const child of node.children) {
659
+ walk2(child, visitor);
660
+ }
661
+ }
662
+ }
663
+ function transformAstro(options) {
664
+ const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
665
+ const escapeTagsSet = buildEscapeTagsSet(escapeTags);
666
+ let ast;
667
+ try {
668
+ ast = w2(source, { position: true }).ast;
669
+ } catch (_err) {
670
+ return { code: source, map: null, changed: false };
671
+ }
672
+ const s2 = new import_magic_string4.default(source);
673
+ let changed = false;
674
+ walk2(ast, {
675
+ enter(node) {
676
+ if (node.type === "element" || node.type === "component") {
677
+ const tagName = node.name;
678
+ if (tagName && !escapeTagsSet.has(tagName) && !node.attributes?.some((attr) => attr.name === attributeName)) {
679
+ const startOffset = node.position?.start?.offset ?? -1;
680
+ if (startOffset === -1) return;
681
+ let tagStartIndex = startOffset;
682
+ while (tagStartIndex >= 0 && source[tagStartIndex] !== "<") {
683
+ tagStartIndex--;
684
+ }
685
+ if (tagStartIndex >= 0) {
686
+ const substringAfterTag = source.substring(tagStartIndex);
687
+ const escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
688
+ const strictRegex = new RegExp(`^<\\s*${escapedTagName}(?=\\s|/|>)`, "i");
689
+ const strictMatch = substringAfterTag.match(strictRegex);
690
+ if (strictMatch) {
691
+ const insertPosition = tagStartIndex + strictMatch[0].length;
692
+ const line = node.position.start.line;
693
+ const column = node.position.start.column;
694
+ const attrValue = formatAttrValue(filePath, line, column);
695
+ const addition = ` ${attributeName}="${attrValue}"`;
696
+ s2.appendLeft(insertPosition, addition);
697
+ changed = true;
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+ });
704
+ return {
705
+ code: s2.toString(),
706
+ map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
707
+ changed
708
+ };
709
+ }
710
+
328
711
  // src/transform/index.ts
329
712
  function transformRouter(options) {
330
713
  const { filePath, source, projectRoot, pluginOptions } = options;
@@ -349,6 +732,22 @@ function transformRouter(options) {
349
732
  attributeName: pluginOptions.attributeName
350
733
  });
351
734
  }
735
+ if (ext === ".svelte") {
736
+ return transformSvelte({
737
+ filePath,
738
+ source,
739
+ escapeTags: pluginOptions.escapeTags,
740
+ attributeName: pluginOptions.attributeName
741
+ });
742
+ }
743
+ if (ext === ".astro") {
744
+ return transformAstro({
745
+ filePath,
746
+ source,
747
+ escapeTags: pluginOptions.escapeTags,
748
+ attributeName: pluginOptions.attributeName
749
+ });
750
+ }
352
751
  return null;
353
752
  }
354
753
 
@@ -487,7 +886,7 @@ function isDebugEnabled(namespace) {
487
886
  if (typeof process === "undefined" || !process.env) return false;
488
887
  const debugEnv = process.env.DEBUG;
489
888
  if (!debugEnv) return false;
490
- const namespaces = debugEnv.split(",").map((s) => s.trim());
889
+ const namespaces = debugEnv.split(",").map((s2) => s2.trim());
491
890
  for (const ns of namespaces) {
492
891
  if (ns === "*") return true;
493
892
  if (ns.endsWith("*")) {
@@ -643,7 +1042,7 @@ function readJsonSafely(filePath) {
643
1042
  }
644
1043
  return null;
645
1044
  }
646
- function resolveTargetTool(config, ide = "vscode") {
1045
+ function resolveTargetTool(config, _ide = "vscode") {
647
1046
  const defaultProvider = config["provider.default"];
648
1047
  if (defaultProvider) {
649
1048
  const tool = defaultProvider.split(".")[0];
@@ -751,7 +1150,7 @@ function resolveIntents(serverPrompts) {
751
1150
  configLogger.warn(`Intent "${item.id}" is missing required "aiIntent".`);
752
1151
  continue;
753
1152
  }
754
- const existingIdx = merged.findIndex((i) => i.id === item.id);
1153
+ const existingIdx = merged.findIndex((i2) => i2.id === item.id);
755
1154
  if (existingIdx !== -1) {
756
1155
  if (item.enabled === false) {
757
1156
  merged.splice(existingIdx, 1);
@@ -795,7 +1194,7 @@ function watchConfig(onReload, cwd = process.cwd(), gitRoot) {
795
1194
  });
796
1195
  watcher.unref();
797
1196
  watchers.push(watcher);
798
- } catch (e) {
1197
+ } catch (_e) {
799
1198
  }
800
1199
  }
801
1200
  }
@@ -1354,14 +1753,14 @@ async function startServer() {
1354
1753
  if (import_node_fs4.default.existsSync(portFile)) {
1355
1754
  try {
1356
1755
  portData = JSON.parse(import_node_fs4.default.readFileSync(portFile, "utf-8"));
1357
- } catch (e) {
1756
+ } catch (_e) {
1358
1757
  }
1359
1758
  }
1360
1759
  const rootHash = import_node_crypto2.default.createHash("md5").update(serverState.projectRoot).digest("hex");
1361
1760
  portData[rootHash] = port;
1362
1761
  import_node_fs4.default.writeFileSync(portFile, JSON.stringify(portData, null, 2), "utf-8");
1363
- } catch (e) {
1364
- serverLogger4.warn("Failed to write port file:", e);
1762
+ } catch (_e) {
1763
+ serverLogger4.warn("Failed to write port file:", _e);
1365
1764
  }
1366
1765
  process.once("exit", () => {
1367
1766
  try {
@@ -1434,7 +1833,7 @@ async function handleRequest(url, req, res) {
1434
1833
  let body;
1435
1834
  try {
1436
1835
  body = JSON.parse(await readBody(req));
1437
- } catch (e) {
1836
+ } catch (_e) {
1438
1837
  res.writeHead(400, { "Content-Type": "application/json" });
1439
1838
  res.end(JSON.stringify({ error: "Invalid JSON body" }));
1440
1839
  return;
@@ -1617,7 +2016,7 @@ function injectWebpack(compiler, serverPortFn, resolveClientModule2) {
1617
2016
  }
1618
2017
  compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
1619
2018
  const HtmlWebpackPlugin = compiler.options.plugins.find(
1620
- (p) => p && p.constructor && p.constructor.name === "HtmlWebpackPlugin"
2019
+ (p2) => p2 && p2.constructor && p2.constructor.name === "HtmlWebpackPlugin"
1621
2020
  );
1622
2021
  if (HtmlWebpackPlugin) {
1623
2022
  const hooks = HtmlWebpackPlugin.constructor.getHooks(compilation);
@@ -1661,7 +2060,7 @@ function injectRspack(compiler, serverPortFn, resolveClientModule2) {
1661
2060
  new compiler.webpack.EntryPlugin(compiler.context, inspectoClientPath, {}).apply(compiler);
1662
2061
  compiler.hooks.compilation.tap("inspecto-overlay", (compilation) => {
1663
2062
  const HtmlRspackPlugin = compiler.options.plugins.find(
1664
- (p) => p && p.constructor && p.constructor.name === "HtmlRspackPlugin"
2063
+ (p2) => p2 && p2.constructor && p2.constructor.name === "HtmlRspackPlugin"
1665
2064
  );
1666
2065
  if (HtmlRspackPlugin) {
1667
2066
  const hooks = HtmlRspackPlugin.constructor.getHooks(compilation);
@@ -1819,7 +2218,9 @@ var src_default = InspectoPlugin;
1819
2218
  esbuildPlugin,
1820
2219
  rollupPlugin,
1821
2220
  rspackPlugin,
2221
+ transformAstro,
1822
2222
  transformJsx,
2223
+ transformRouter,
1823
2224
  unplugin,
1824
2225
  vitePlugin,
1825
2226
  webpackPlugin