@inspecto-dev/plugin 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/astro.cjs +2687 -0
- package/dist/astro.cjs.map +1 -0
- package/dist/astro.d.cts +17 -0
- package/dist/astro.d.ts +17 -0
- package/dist/astro.js +2656 -0
- package/dist/astro.js.map +1 -0
- package/dist/index.cjs +932 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +930 -87
- package/dist/index.js.map +1 -1
- package/dist/legacy/rspack/index.cjs +530 -89
- package/dist/legacy/rspack/index.cjs.map +1 -1
- package/dist/legacy/rspack/index.js +530 -89
- package/dist/legacy/rspack/index.js.map +1 -1
- package/dist/legacy/rspack/loader.cjs +407 -3
- package/dist/legacy/rspack/loader.cjs.map +1 -1
- package/dist/legacy/rspack/loader.js +403 -3
- package/dist/legacy/rspack/loader.js.map +1 -1
- package/dist/legacy/webpack4/index.cjs +519 -78
- package/dist/legacy/webpack4/index.cjs.map +1 -1
- package/dist/legacy/webpack4/index.js +519 -78
- package/dist/legacy/webpack4/index.js.map +1 -1
- package/dist/legacy/webpack4/loader.cjs +407 -3
- package/dist/legacy/webpack4/loader.cjs.map +1 -1
- package/dist/legacy/webpack4/loader.js +403 -3
- package/dist/legacy/webpack4/loader.js.map +1 -1
- package/dist/rollup.cjs +932 -87
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +930 -87
- package/dist/rollup.js.map +1 -1
- package/dist/rspack.cjs +932 -87
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +930 -87
- package/dist/rspack.js.map +1 -1
- package/dist/vite.cjs +932 -87
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +930 -87
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +932 -87
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +930 -87
- package/dist/webpack.js.map +1 -1
- package/package.json +13 -10
|
@@ -34,6 +34,10 @@ __export(loader_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(loader_exports);
|
|
36
36
|
|
|
37
|
+
// ../../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
|
|
38
|
+
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;
|
|
39
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
+
|
|
37
41
|
// src/transform/index.ts
|
|
38
42
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
39
43
|
|
|
@@ -115,14 +119,14 @@ function extractTransformFilePath(requestId) {
|
|
|
115
119
|
wrapped: filePath !== requestId
|
|
116
120
|
};
|
|
117
121
|
}
|
|
118
|
-
function shouldTransform(filePath,
|
|
122
|
+
function shouldTransform(filePath, _options) {
|
|
119
123
|
const resolvedFilePath = extractTransformFilePath(filePath).filePath;
|
|
120
124
|
if (process.env["NODE_ENV"] === "production") return false;
|
|
121
125
|
if (resolvedFilePath.includes("node_modules")) return false;
|
|
122
126
|
if (resolvedFilePath.startsWith("\0")) return false;
|
|
123
127
|
if (/[/\\](dist|build|\.next|\.nuxt)[/\\]/.test(resolvedFilePath)) return false;
|
|
124
128
|
const ext = resolvedFilePath.split(".").pop()?.toLowerCase();
|
|
125
|
-
if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue"].includes(ext)) {
|
|
129
|
+
if (ext && !["js", "jsx", "ts", "tsx", "mjs", "mts", "vue", "svelte", "astro"].includes(ext)) {
|
|
126
130
|
return false;
|
|
127
131
|
}
|
|
128
132
|
return true;
|
|
@@ -276,7 +280,7 @@ function transformVue(options) {
|
|
|
276
280
|
if (escapeTagsSet.has(tagName)) return;
|
|
277
281
|
if (tagName === "template" && node === ast.children[0]) return;
|
|
278
282
|
const alreadyHasAttr = node.props.some(
|
|
279
|
-
(
|
|
283
|
+
(p2) => p2.type === import_compiler_core.NodeTypes.ATTRIBUTE && p2.name === attributeName
|
|
280
284
|
);
|
|
281
285
|
if (alreadyHasAttr) return;
|
|
282
286
|
const loc = node.loc;
|
|
@@ -313,6 +317,387 @@ function walkElement(node, visitor) {
|
|
|
313
317
|
}
|
|
314
318
|
}
|
|
315
319
|
|
|
320
|
+
// src/transform/transform-svelte.ts
|
|
321
|
+
var import_magic_string3 = __toESM(require("magic-string"), 1);
|
|
322
|
+
var import_compiler = require("svelte/compiler");
|
|
323
|
+
function walk(node, visitor) {
|
|
324
|
+
if (!node || typeof node !== "object") return;
|
|
325
|
+
visitor.enter(node);
|
|
326
|
+
for (const key in node) {
|
|
327
|
+
if (key === "parent" || key === "prev" || key === "next") continue;
|
|
328
|
+
const value = node[key];
|
|
329
|
+
if (Array.isArray(value)) {
|
|
330
|
+
value.forEach((child) => {
|
|
331
|
+
if (child && typeof child === "object") walk(child, visitor);
|
|
332
|
+
});
|
|
333
|
+
} else if (value && typeof value === "object") {
|
|
334
|
+
walk(value, visitor);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function transformSvelte(options) {
|
|
339
|
+
const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
|
|
340
|
+
const escapeTagsSet = buildEscapeTagsSet(escapeTags);
|
|
341
|
+
let replacedContent = source;
|
|
342
|
+
const scriptRegex = /<script(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/script>/gi;
|
|
343
|
+
const styleRegex = /<style(?:\s+[a-zA-Z-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]*))?)?>[\s\S]*?<\/style>/gi;
|
|
344
|
+
const scriptMatches = source.match(scriptRegex) || [];
|
|
345
|
+
const styleMatches = source.match(styleRegex) || [];
|
|
346
|
+
[...scriptMatches, ...styleMatches].forEach((match) => {
|
|
347
|
+
replacedContent = replacedContent.replace(match, " ".repeat(match.length));
|
|
348
|
+
});
|
|
349
|
+
let ast;
|
|
350
|
+
try {
|
|
351
|
+
ast = (0, import_compiler.parse)(replacedContent);
|
|
352
|
+
} catch {
|
|
353
|
+
return { code: source, map: null, changed: false };
|
|
354
|
+
}
|
|
355
|
+
const s2 = new import_magic_string3.default(source);
|
|
356
|
+
let changed = false;
|
|
357
|
+
function countLines(text, position) {
|
|
358
|
+
let lines = 0;
|
|
359
|
+
for (let i2 = 0; i2 < position; i2++) {
|
|
360
|
+
if (text[i2] === "\n") lines++;
|
|
361
|
+
}
|
|
362
|
+
return lines;
|
|
363
|
+
}
|
|
364
|
+
const root = ast.html || ast.fragment || ast;
|
|
365
|
+
walk(root, {
|
|
366
|
+
enter(node) {
|
|
367
|
+
if (node.type === "Element" || node.type === "RegularElement" || node.type === "InlineComponent" || node.type === "Component") {
|
|
368
|
+
const tagName = node.name || "";
|
|
369
|
+
if (tagName && !escapeTagsSet.has(tagName.toLowerCase()) && !node.attributes?.some((attr) => attr.name === attributeName)) {
|
|
370
|
+
const insertPosition = node.start + tagName.length + 1;
|
|
371
|
+
const line = countLines(source, node.start) + 1;
|
|
372
|
+
const lastNewLine = source.lastIndexOf("\n", node.start - 1);
|
|
373
|
+
const column = lastNewLine === -1 ? node.start + 1 : node.start - lastNewLine;
|
|
374
|
+
const attrValue = formatAttrValue(filePath, line, column);
|
|
375
|
+
const addition = ` ${attributeName}="${attrValue}"`;
|
|
376
|
+
s2.appendLeft(insertPosition, addition);
|
|
377
|
+
changed = true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
code: s2.toString(),
|
|
384
|
+
map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
|
|
385
|
+
changed
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/transform/transform-astro.ts
|
|
390
|
+
var import_magic_string4 = __toESM(require("magic-string"), 1);
|
|
391
|
+
|
|
392
|
+
// ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
|
|
393
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
394
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
395
|
+
var import_util = require("util");
|
|
396
|
+
globalThis.fs || Object.defineProperty(globalThis, "fs", { value: import_fs.default });
|
|
397
|
+
globalThis.process || Object.defineProperties(globalThis, "process", { value: process });
|
|
398
|
+
globalThis.crypto || Object.defineProperty(globalThis, "crypto", { value: import_crypto.default.webcrypto ? import_crypto.default.webcrypto : { getRandomValues(m2) {
|
|
399
|
+
return import_crypto.default.randomFillSync(m2);
|
|
400
|
+
} } });
|
|
401
|
+
globalThis.performance || Object.defineProperty(globalThis, "performance", { value: { now() {
|
|
402
|
+
let [m2, o] = process.hrtime();
|
|
403
|
+
return m2 * 1e3 + o / 1e6;
|
|
404
|
+
} } });
|
|
405
|
+
var y = new import_util.TextEncoder("utf-8");
|
|
406
|
+
var w = new import_util.TextDecoder("utf-8");
|
|
407
|
+
var d = class {
|
|
408
|
+
constructor() {
|
|
409
|
+
this.argv = ["js"], this.env = {}, this.exit = (t) => {
|
|
410
|
+
t !== 0 && console.warn("exit code:", t);
|
|
411
|
+
}, this._exitPromise = new Promise((t) => {
|
|
412
|
+
this._resolveExitPromise = t;
|
|
413
|
+
}), this._pendingEvent = null, this._scheduledTimeouts = /* @__PURE__ */ new Map(), this._nextCallbackTimeoutID = 1;
|
|
414
|
+
let o = (t, e) => {
|
|
415
|
+
this.mem.setUint32(t + 0, e, true), this.mem.setUint32(t + 4, Math.floor(e / 4294967296), true);
|
|
416
|
+
}, n = (t) => {
|
|
417
|
+
let e = this.mem.getUint32(t + 0, true), s2 = this.mem.getInt32(t + 4, true);
|
|
418
|
+
return e + s2 * 4294967296;
|
|
419
|
+
}, r = (t) => {
|
|
420
|
+
let e = this.mem.getFloat64(t, true);
|
|
421
|
+
if (e === 0) return;
|
|
422
|
+
if (!isNaN(e)) return e;
|
|
423
|
+
let s2 = this.mem.getUint32(t, true);
|
|
424
|
+
return this._values[s2];
|
|
425
|
+
}, l = (t, e) => {
|
|
426
|
+
if (typeof e == "number" && e !== 0) {
|
|
427
|
+
if (isNaN(e)) {
|
|
428
|
+
this.mem.setUint32(t + 4, 2146959360, true), this.mem.setUint32(t, 0, true);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
this.mem.setFloat64(t, e, true);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (e === void 0) {
|
|
435
|
+
this.mem.setFloat64(t, 0, true);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
let i2 = this._ids.get(e);
|
|
439
|
+
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]++;
|
|
440
|
+
let a = 0;
|
|
441
|
+
switch (typeof e) {
|
|
442
|
+
case "object":
|
|
443
|
+
e !== null && (a = 1);
|
|
444
|
+
break;
|
|
445
|
+
case "string":
|
|
446
|
+
a = 2;
|
|
447
|
+
break;
|
|
448
|
+
case "symbol":
|
|
449
|
+
a = 3;
|
|
450
|
+
break;
|
|
451
|
+
case "function":
|
|
452
|
+
a = 4;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
this.mem.setUint32(t + 4, 2146959360 | a, true), this.mem.setUint32(t, i2, true);
|
|
456
|
+
}, c = (t) => {
|
|
457
|
+
let e = n(t + 0), s2 = n(t + 8);
|
|
458
|
+
return new Uint8Array(this._inst.exports.mem.buffer, e, s2);
|
|
459
|
+
}, f2 = (t) => {
|
|
460
|
+
let e = n(t + 0), s2 = n(t + 8), i2 = new Array(s2);
|
|
461
|
+
for (let a = 0; a < s2; a++) i2[a] = r(e + a * 8);
|
|
462
|
+
return i2;
|
|
463
|
+
}, u = (t) => {
|
|
464
|
+
let e = n(t + 0), s2 = n(t + 8);
|
|
465
|
+
return w.decode(new DataView(this._inst.exports.mem.buffer, e, s2));
|
|
466
|
+
}, h = Date.now() - performance.now();
|
|
467
|
+
this.importObject = { gojs: { "runtime.wasmExit": (t) => {
|
|
468
|
+
t >>>= 0;
|
|
469
|
+
let e = this.mem.getInt32(t + 8, true);
|
|
470
|
+
this.exited = true, delete this._inst, delete this._values, delete this._goRefCounts, delete this._ids, delete this._idPool, this.exit(e);
|
|
471
|
+
}, "runtime.wasmWrite": (t) => {
|
|
472
|
+
t >>>= 0;
|
|
473
|
+
let e = n(t + 8), s2 = n(t + 16), i2 = this.mem.getInt32(t + 24, true);
|
|
474
|
+
import_fs.default.writeSync(e, new Uint8Array(this._inst.exports.mem.buffer, s2, i2));
|
|
475
|
+
}, "runtime.resetMemoryDataView": (t) => {
|
|
476
|
+
t >>>= 0, this.mem = new DataView(this._inst.exports.mem.buffer);
|
|
477
|
+
}, "runtime.nanotime1": (t) => {
|
|
478
|
+
t >>>= 0, o(t + 8, (h + performance.now()) * 1e6);
|
|
479
|
+
}, "runtime.walltime": (t) => {
|
|
480
|
+
t >>>= 0;
|
|
481
|
+
let e = (/* @__PURE__ */ new Date()).getTime();
|
|
482
|
+
o(t + 8, e / 1e3), this.mem.setInt32(t + 16, e % 1e3 * 1e6, true);
|
|
483
|
+
}, "runtime.scheduleTimeoutEvent": (t) => {
|
|
484
|
+
t >>>= 0;
|
|
485
|
+
let e = this._nextCallbackTimeoutID;
|
|
486
|
+
this._nextCallbackTimeoutID++, this._scheduledTimeouts.set(e, setTimeout(() => {
|
|
487
|
+
for (this._resume(); this._scheduledTimeouts.has(e); ) console.warn("scheduleTimeoutEvent: missed timeout event"), this._resume();
|
|
488
|
+
}, n(t + 8) + 1)), this.mem.setInt32(t + 16, e, true);
|
|
489
|
+
}, "runtime.clearTimeoutEvent": (t) => {
|
|
490
|
+
t >>>= 0;
|
|
491
|
+
let e = this.mem.getInt32(t + 8, true);
|
|
492
|
+
clearTimeout(this._scheduledTimeouts.get(e)), this._scheduledTimeouts.delete(e);
|
|
493
|
+
}, "runtime.getRandomData": (t) => {
|
|
494
|
+
t >>>= 0, globalThis.crypto.getRandomValues(c(t + 8));
|
|
495
|
+
}, "syscall/js.finalizeRef": (t) => {
|
|
496
|
+
t >>>= 0;
|
|
497
|
+
let e = this.mem.getUint32(t + 8, true);
|
|
498
|
+
if (this._goRefCounts[e]--, this._goRefCounts[e] === 0) {
|
|
499
|
+
let s2 = this._values[e];
|
|
500
|
+
this._values[e] = null, this._ids.delete(s2), this._idPool.push(e);
|
|
501
|
+
}
|
|
502
|
+
}, "syscall/js.stringVal": (t) => {
|
|
503
|
+
t >>>= 0, l(t + 24, u(t + 8));
|
|
504
|
+
}, "syscall/js.valueGet": (t) => {
|
|
505
|
+
t >>>= 0;
|
|
506
|
+
let e = Reflect.get(r(t + 8), u(t + 16));
|
|
507
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 32, e);
|
|
508
|
+
}, "syscall/js.valueSet": (t) => {
|
|
509
|
+
t >>>= 0, Reflect.set(r(t + 8), u(t + 16), r(t + 32));
|
|
510
|
+
}, "syscall/js.valueDelete": (t) => {
|
|
511
|
+
t >>>= 0, Reflect.deleteProperty(r(t + 8), u(t + 16));
|
|
512
|
+
}, "syscall/js.valueIndex": (t) => {
|
|
513
|
+
t >>>= 0, l(t + 24, Reflect.get(r(t + 8), n(t + 16)));
|
|
514
|
+
}, "syscall/js.valueSetIndex": (t) => {
|
|
515
|
+
t >>>= 0, Reflect.set(r(t + 8), n(t + 16), r(t + 24));
|
|
516
|
+
}, "syscall/js.valueCall": (t) => {
|
|
517
|
+
t >>>= 0;
|
|
518
|
+
try {
|
|
519
|
+
let e = r(t + 8), s2 = Reflect.get(e, u(t + 16)), i2 = f2(t + 32), a = Reflect.apply(s2, e, i2);
|
|
520
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 56, a), this.mem.setUint8(t + 64, 1);
|
|
521
|
+
} catch (e) {
|
|
522
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 56, e), this.mem.setUint8(t + 64, 0);
|
|
523
|
+
}
|
|
524
|
+
}, "syscall/js.valueInvoke": (t) => {
|
|
525
|
+
t >>>= 0;
|
|
526
|
+
try {
|
|
527
|
+
let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.apply(e, void 0, s2);
|
|
528
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
|
|
529
|
+
} catch (e) {
|
|
530
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
|
|
531
|
+
}
|
|
532
|
+
}, "syscall/js.valueNew": (t) => {
|
|
533
|
+
t >>>= 0;
|
|
534
|
+
try {
|
|
535
|
+
let e = r(t + 8), s2 = f2(t + 16), i2 = Reflect.construct(e, s2);
|
|
536
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, i2), this.mem.setUint8(t + 48, 1);
|
|
537
|
+
} catch (e) {
|
|
538
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
|
|
539
|
+
}
|
|
540
|
+
}, "syscall/js.valueLength": (t) => {
|
|
541
|
+
t >>>= 0, o(t + 16, Number.parseInt(r(t + 8).length));
|
|
542
|
+
}, "syscall/js.valuePrepareString": (t) => {
|
|
543
|
+
t >>>= 0;
|
|
544
|
+
let e = y.encode(String(r(t + 8)));
|
|
545
|
+
l(t + 16, e), o(t + 24, e.length);
|
|
546
|
+
}, "syscall/js.valueLoadString": (t) => {
|
|
547
|
+
t >>>= 0;
|
|
548
|
+
let e = r(t + 8);
|
|
549
|
+
c(t + 16).set(e);
|
|
550
|
+
}, "syscall/js.valueInstanceOf": (t) => {
|
|
551
|
+
t >>>= 0, this.mem.setUint8(t + 24, r(t + 8) instanceof r(t + 16) ? 1 : 0);
|
|
552
|
+
}, "syscall/js.copyBytesToGo": (t) => {
|
|
553
|
+
t >>>= 0;
|
|
554
|
+
let e = c(t + 8), s2 = r(t + 32);
|
|
555
|
+
if (!(s2 instanceof Uint8Array || s2 instanceof Uint8ClampedArray)) {
|
|
556
|
+
this.mem.setUint8(t + 48, 0);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
let i2 = s2.subarray(0, e.length);
|
|
560
|
+
e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
|
|
561
|
+
}, "syscall/js.copyBytesToJS": (t) => {
|
|
562
|
+
t >>>= 0;
|
|
563
|
+
let e = r(t + 8), s2 = c(t + 16);
|
|
564
|
+
if (!(e instanceof Uint8Array || e instanceof Uint8ClampedArray)) {
|
|
565
|
+
this.mem.setUint8(t + 48, 0);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
let i2 = s2.subarray(0, e.length);
|
|
569
|
+
e.set(i2), o(t + 40, i2.length), this.mem.setUint8(t + 48, 1);
|
|
570
|
+
}, debug: (t) => {
|
|
571
|
+
console.log(t);
|
|
572
|
+
} } };
|
|
573
|
+
}
|
|
574
|
+
async run(o) {
|
|
575
|
+
if (!(o instanceof WebAssembly.Instance)) throw new Error("Go.run: WebAssembly.Instance expected");
|
|
576
|
+
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;
|
|
577
|
+
let n = 4096, r = (h) => {
|
|
578
|
+
let t = n, e = y.encode(`${h}\0`);
|
|
579
|
+
return new Uint8Array(this.mem.buffer, n, e.length).set(e), n += e.length, n % 8 !== 0 && (n += 8 - n % 8), t;
|
|
580
|
+
}, l = this.argv.length, c = [];
|
|
581
|
+
this.argv.forEach((h) => {
|
|
582
|
+
c.push(r(h));
|
|
583
|
+
}), c.push(0), Object.keys(this.env).sort().forEach((h) => {
|
|
584
|
+
c.push(r(`${h}=${this.env[h]}`));
|
|
585
|
+
}), c.push(0);
|
|
586
|
+
let u = n;
|
|
587
|
+
c.forEach((h) => {
|
|
588
|
+
this.mem.setUint32(n, h, true), this.mem.setUint32(n + 4, 0, true), n += 8;
|
|
589
|
+
}), this._inst.exports.run(l, u), this.exited && this._resolveExitPromise(), await this._exitPromise;
|
|
590
|
+
}
|
|
591
|
+
_resume() {
|
|
592
|
+
if (this.exited) throw new Error("Go program has already exited");
|
|
593
|
+
this._inst.exports.resume(), this.exited && this._resolveExitPromise();
|
|
594
|
+
}
|
|
595
|
+
_makeFuncWrapper(o) {
|
|
596
|
+
let n = this;
|
|
597
|
+
return function() {
|
|
598
|
+
let r = { id: o, this: this, args: arguments };
|
|
599
|
+
return n._pendingEvent = r, n._resume(), r.result;
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// ../../node_modules/.pnpm/@astrojs+compiler@3.0.1/node_modules/@astrojs/compiler/dist/node/sync.js
|
|
605
|
+
var import_fs2 = require("fs");
|
|
606
|
+
var import_url = require("url");
|
|
607
|
+
function i() {
|
|
608
|
+
return s || (s = f()), s;
|
|
609
|
+
}
|
|
610
|
+
var s;
|
|
611
|
+
var w2 = (e, t) => i().parse(e, t);
|
|
612
|
+
function f() {
|
|
613
|
+
let e = new d(), t = v2((0, import_url.fileURLToPath)(new URL("../astro.wasm", importMetaUrl)), e.importObject);
|
|
614
|
+
e.run(t);
|
|
615
|
+
let o = globalThis["@astrojs/compiler"];
|
|
616
|
+
return { transform: (n, a) => {
|
|
617
|
+
try {
|
|
618
|
+
return o.transform(n, a || {});
|
|
619
|
+
} catch (r) {
|
|
620
|
+
throw s = void 0, r;
|
|
621
|
+
}
|
|
622
|
+
}, parse: (n, a) => {
|
|
623
|
+
try {
|
|
624
|
+
let r = o.parse(n, a || {});
|
|
625
|
+
return { ...r, ast: JSON.parse(r.ast) };
|
|
626
|
+
} catch (r) {
|
|
627
|
+
throw s = void 0, r;
|
|
628
|
+
}
|
|
629
|
+
}, convertToTSX: (n, a) => {
|
|
630
|
+
try {
|
|
631
|
+
let r = o.convertToTSX(n, a || {});
|
|
632
|
+
return { ...r, map: JSON.parse(r.map) };
|
|
633
|
+
} catch (r) {
|
|
634
|
+
throw s = void 0, r;
|
|
635
|
+
}
|
|
636
|
+
} };
|
|
637
|
+
}
|
|
638
|
+
function v2(e, t) {
|
|
639
|
+
let o = (0, import_fs2.readFileSync)(e);
|
|
640
|
+
return new WebAssembly.Instance(new WebAssembly.Module(o), t);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// src/transform/transform-astro.ts
|
|
644
|
+
function walk2(node, visitor) {
|
|
645
|
+
if (!node || typeof node !== "object") return;
|
|
646
|
+
visitor.enter(node);
|
|
647
|
+
if (Array.isArray(node.children)) {
|
|
648
|
+
for (const child of node.children) {
|
|
649
|
+
walk2(child, visitor);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function transformAstro(options) {
|
|
654
|
+
const { filePath, source, escapeTags, attributeName = "data-inspecto" } = options;
|
|
655
|
+
const escapeTagsSet = buildEscapeTagsSet(escapeTags);
|
|
656
|
+
let ast;
|
|
657
|
+
try {
|
|
658
|
+
ast = w2(source, { position: true }).ast;
|
|
659
|
+
} catch (_err) {
|
|
660
|
+
return { code: source, map: null, changed: false };
|
|
661
|
+
}
|
|
662
|
+
const s2 = new import_magic_string4.default(source);
|
|
663
|
+
let changed = false;
|
|
664
|
+
walk2(ast, {
|
|
665
|
+
enter(node) {
|
|
666
|
+
if (node.type === "element" || node.type === "component") {
|
|
667
|
+
const tagName = node.name;
|
|
668
|
+
if (tagName && !escapeTagsSet.has(tagName) && !node.attributes?.some((attr) => attr.name === attributeName)) {
|
|
669
|
+
const startOffset = node.position?.start?.offset ?? -1;
|
|
670
|
+
if (startOffset === -1) return;
|
|
671
|
+
let tagStartIndex = startOffset;
|
|
672
|
+
while (tagStartIndex >= 0 && source[tagStartIndex] !== "<") {
|
|
673
|
+
tagStartIndex--;
|
|
674
|
+
}
|
|
675
|
+
if (tagStartIndex >= 0) {
|
|
676
|
+
const substringAfterTag = source.substring(tagStartIndex);
|
|
677
|
+
const escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
678
|
+
const strictRegex = new RegExp(`^<\\s*${escapedTagName}(?=\\s|/|>)`, "i");
|
|
679
|
+
const strictMatch = substringAfterTag.match(strictRegex);
|
|
680
|
+
if (strictMatch) {
|
|
681
|
+
const insertPosition = tagStartIndex + strictMatch[0].length;
|
|
682
|
+
const line = node.position.start.line;
|
|
683
|
+
const column = node.position.start.column;
|
|
684
|
+
const attrValue = formatAttrValue(filePath, line, column);
|
|
685
|
+
const addition = ` ${attributeName}="${attrValue}"`;
|
|
686
|
+
s2.appendLeft(insertPosition, addition);
|
|
687
|
+
changed = true;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
return {
|
|
695
|
+
code: s2.toString(),
|
|
696
|
+
map: changed ? s2.generateMap({ source: filePath, includeContent: true }) : null,
|
|
697
|
+
changed
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
316
701
|
// src/transform/index.ts
|
|
317
702
|
function transformRouter(options) {
|
|
318
703
|
const { filePath, source, projectRoot, pluginOptions } = options;
|
|
@@ -337,6 +722,25 @@ function transformRouter(options) {
|
|
|
337
722
|
attributeName: pluginOptions.attributeName
|
|
338
723
|
});
|
|
339
724
|
}
|
|
725
|
+
if (ext === ".svelte") {
|
|
726
|
+
return transformSvelte({
|
|
727
|
+
filePath,
|
|
728
|
+
source,
|
|
729
|
+
projectRoot,
|
|
730
|
+
escapeTags: pluginOptions.escapeTags,
|
|
731
|
+
pathType: pluginOptions.pathType,
|
|
732
|
+
attributeName: pluginOptions.attributeName
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
if (ext === ".astro") {
|
|
736
|
+
return transformAstro({
|
|
737
|
+
filePath,
|
|
738
|
+
source,
|
|
739
|
+
escapeTags: pluginOptions.escapeTags,
|
|
740
|
+
pathType: pluginOptions.pathType,
|
|
741
|
+
attributeName: pluginOptions.attributeName
|
|
742
|
+
});
|
|
743
|
+
}
|
|
340
744
|
return null;
|
|
341
745
|
}
|
|
342
746
|
|