@vizejs/unplugin 0.428.0 → 0.429.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.
package/dist/babel.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_unplugin = require("./unplugin-CVX51sBt.cjs");
1
+ const require_unplugin = require("./unplugin-BZZSLylM.cjs");
2
2
  //#region src/babel.ts
3
3
  function vizeBabelPlugin(_api, rawOptions = {}) {
4
4
  const options = require_unplugin.normalizeOptions(rawOptions);
package/dist/babel.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-CreP_VP8.mjs";
1
+ import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-LGSCePN4.mjs";
2
2
  //#region src/babel.ts
3
3
  function vizeBabelPlugin(_api, rawOptions = {}) {
4
4
  const options = normalizeOptions(rawOptions);
package/dist/esbuild.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/esbuild.ts
2
- var esbuild_default = require("./unplugin-CVX51sBt.cjs").vizeUnplugin.esbuild;
2
+ var esbuild_default = require("./unplugin-BZZSLylM.cjs").vizeUnplugin.esbuild;
3
3
  //#endregion
4
4
  module.exports = esbuild_default;
package/dist/esbuild.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-CreP_VP8.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-LGSCePN4.mjs";
2
2
  //#region src/esbuild.ts
3
3
  var esbuild_default = vizeUnplugin.esbuild;
4
4
  //#endregion
package/dist/index.cjs CHANGED
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_unplugin = require("./unplugin-CVX51sBt.cjs");
5
+ const require_unplugin = require("./unplugin-BZZSLylM.cjs");
6
6
  exports.default = require_unplugin.vizeUnplugin;
7
7
  exports.vizeUnplugin = require_unplugin.vizeUnplugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as vizeUnplugin } from "./unplugin-CreP_VP8.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-LGSCePN4.mjs";
2
2
  export { vizeUnplugin as default, vizeUnplugin };
package/dist/rolldown.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/rolldown.ts
2
- var rolldown_default = require("./unplugin-CVX51sBt.cjs").vizeUnplugin.rollup;
2
+ var rolldown_default = require("./unplugin-BZZSLylM.cjs").vizeUnplugin.rollup;
3
3
  //#endregion
4
4
  module.exports = rolldown_default;
package/dist/rolldown.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-CreP_VP8.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-LGSCePN4.mjs";
2
2
  //#region src/rolldown.ts
3
3
  var rolldown_default = vizeUnplugin.rollup;
4
4
  //#endregion
package/dist/rollup.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/rollup.ts
2
- var rollup_default = require("./unplugin-CVX51sBt.cjs").vizeUnplugin.rollup;
2
+ var rollup_default = require("./unplugin-BZZSLylM.cjs").vizeUnplugin.rollup;
3
3
  //#endregion
4
4
  module.exports = rollup_default;
package/dist/rollup.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-CreP_VP8.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-LGSCePN4.mjs";
2
2
  //#region src/rollup.ts
3
3
  var rollup_default = vizeUnplugin.rollup;
4
4
  //#endregion
@@ -46,6 +46,74 @@ function matchesPattern(pattern, id) {
46
46
  return matches;
47
47
  }
48
48
  //#endregion
49
+ //#region ../shared/source-map.ts
50
+ function isSourceMapV3(value) {
51
+ if (value === null || typeof value !== "object") return false;
52
+ const map = value;
53
+ return map.version === 3 && Array.isArray(map.sources) && Array.isArray(map.names) && typeof map.mappings === "string";
54
+ }
55
+ /**
56
+ * Parse a compiler-produced map, or `null` when there is nothing usable.
57
+ *
58
+ * A malformed map is worse than no map — Vite would chain garbage into the
59
+ * bundle's map — so anything that is not a v3 document is dropped.
60
+ */
61
+ function parseSourceMap(json) {
62
+ if (!json) return null;
63
+ let parsed;
64
+ try {
65
+ parsed = JSON.parse(json);
66
+ } catch {
67
+ return null;
68
+ }
69
+ return isSourceMapV3(parsed) ? parsed : null;
70
+ }
71
+ function countNewlines(text) {
72
+ let total = 0;
73
+ for (let index = text.indexOf("\n"); index !== -1; index = text.indexOf("\n", index + 1)) total++;
74
+ return total;
75
+ }
76
+ /**
77
+ * Insert `count` unmapped generated lines at generated line `atLine`.
78
+ *
79
+ * Returns the map unchanged when the insertion lands past the last mapped line,
80
+ * because nothing after it needs moving.
81
+ */
82
+ function shiftMappedLines(map, atLine, count) {
83
+ if (count <= 0) return map;
84
+ const groups = map.mappings.split(";");
85
+ if (atLine >= groups.length) return map;
86
+ const shifted = [
87
+ ...groups.slice(0, atLine),
88
+ ...Array(count).fill(""),
89
+ ...groups.slice(atLine)
90
+ ];
91
+ return {
92
+ ...map,
93
+ mappings: shifted.join(";")
94
+ };
95
+ }
96
+ /** Prefix a native JSX module with unmapped generated whole lines.
97
+ * The actual style injection supplies the prefix; authored UTF-16 columns are
98
+ * unchanged because the module resumes at column zero on a new generated line.
99
+ */
100
+ function prependMappedJsxCode(code, mapJson, prefix) {
101
+ const output = prefix + code;
102
+ if (!prefix) return {
103
+ code: output,
104
+ map: mapJson ?? null
105
+ };
106
+ const map = parseSourceMap(mapJson);
107
+ if (!map || !prefix.endsWith("\n")) return {
108
+ code: output,
109
+ map: null
110
+ };
111
+ return {
112
+ code: output,
113
+ map: JSON.stringify(shiftMappedLines(map, 0, countNewlines(prefix)))
114
+ };
115
+ }
116
+ //#endregion
49
117
  //#region src/style.ts
50
118
  const PREPROCESSOR_LANGS = new Set([
51
119
  "scss",
@@ -254,8 +322,7 @@ function compileJsxModule(filePath, source, options) {
254
322
  let map = result.map ?? null;
255
323
  if (css) {
256
324
  const styleKey = result.scopedStyles[0].scopeId.replace(/^data-v-/, "");
257
- code = prependInlineStyleInjection(code, css, styleKey);
258
- map = null;
325
+ ({code, map} = prependMappedJsxCode(code, map, prependInlineStyleInjection("", css, styleKey)));
259
326
  }
260
327
  return {
261
328
  code,
@@ -23,6 +23,74 @@ function matchesPattern(pattern, id) {
23
23
  return matches;
24
24
  }
25
25
  //#endregion
26
+ //#region ../shared/source-map.ts
27
+ function isSourceMapV3(value) {
28
+ if (value === null || typeof value !== "object") return false;
29
+ const map = value;
30
+ return map.version === 3 && Array.isArray(map.sources) && Array.isArray(map.names) && typeof map.mappings === "string";
31
+ }
32
+ /**
33
+ * Parse a compiler-produced map, or `null` when there is nothing usable.
34
+ *
35
+ * A malformed map is worse than no map — Vite would chain garbage into the
36
+ * bundle's map — so anything that is not a v3 document is dropped.
37
+ */
38
+ function parseSourceMap(json) {
39
+ if (!json) return null;
40
+ let parsed;
41
+ try {
42
+ parsed = JSON.parse(json);
43
+ } catch {
44
+ return null;
45
+ }
46
+ return isSourceMapV3(parsed) ? parsed : null;
47
+ }
48
+ function countNewlines(text) {
49
+ let total = 0;
50
+ for (let index = text.indexOf("\n"); index !== -1; index = text.indexOf("\n", index + 1)) total++;
51
+ return total;
52
+ }
53
+ /**
54
+ * Insert `count` unmapped generated lines at generated line `atLine`.
55
+ *
56
+ * Returns the map unchanged when the insertion lands past the last mapped line,
57
+ * because nothing after it needs moving.
58
+ */
59
+ function shiftMappedLines(map, atLine, count) {
60
+ if (count <= 0) return map;
61
+ const groups = map.mappings.split(";");
62
+ if (atLine >= groups.length) return map;
63
+ const shifted = [
64
+ ...groups.slice(0, atLine),
65
+ ...Array(count).fill(""),
66
+ ...groups.slice(atLine)
67
+ ];
68
+ return {
69
+ ...map,
70
+ mappings: shifted.join(";")
71
+ };
72
+ }
73
+ /** Prefix a native JSX module with unmapped generated whole lines.
74
+ * The actual style injection supplies the prefix; authored UTF-16 columns are
75
+ * unchanged because the module resumes at column zero on a new generated line.
76
+ */
77
+ function prependMappedJsxCode(code, mapJson, prefix) {
78
+ const output = prefix + code;
79
+ if (!prefix) return {
80
+ code: output,
81
+ map: mapJson ?? null
82
+ };
83
+ const map = parseSourceMap(mapJson);
84
+ if (!map || !prefix.endsWith("\n")) return {
85
+ code: output,
86
+ map: null
87
+ };
88
+ return {
89
+ code: output,
90
+ map: JSON.stringify(shiftMappedLines(map, 0, countNewlines(prefix)))
91
+ };
92
+ }
93
+ //#endregion
26
94
  //#region src/style.ts
27
95
  const PREPROCESSOR_LANGS = new Set([
28
96
  "scss",
@@ -231,8 +299,7 @@ function compileJsxModule(filePath, source, options) {
231
299
  let map = result.map ?? null;
232
300
  if (css) {
233
301
  const styleKey = result.scopedStyles[0].scopeId.replace(/^data-v-/, "");
234
- code = prependInlineStyleInjection(code, css, styleKey);
235
- map = null;
302
+ ({code, map} = prependMappedJsxCode(code, map, prependInlineStyleInjection("", css, styleKey)));
236
303
  }
237
304
  return {
238
305
  code,
package/dist/webpack.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/webpack.ts
2
- var webpack_default = require("./unplugin-CVX51sBt.cjs").vizeUnplugin.webpack;
2
+ var webpack_default = require("./unplugin-BZZSLylM.cjs").vizeUnplugin.webpack;
3
3
  //#endregion
4
4
  module.exports = webpack_default;
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-CreP_VP8.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-LGSCePN4.mjs";
2
2
  //#region src/webpack.ts
3
3
  var webpack_default = vizeUnplugin.webpack;
4
4
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/unplugin",
3
- "version": "0.428.0",
3
+ "version": "0.429.0",
4
4
  "description": "Experimental Vue SFC integrations for Rollup, Rolldown, Webpack, esbuild, and Babel powered by Vize",
5
5
  "keywords": [
6
6
  "babel",
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@vizejs/native": "0.428.0",
71
+ "@vizejs/native": "0.429.0",
72
72
  "oxc-transform": "0.144.0",
73
73
  "unplugin": "3.3.0"
74
74
  },