@vizejs/rspack-plugin 0.572.0 → 0.574.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.
@@ -1,4 +1,4 @@
1
- import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-ByWFOFCe.mjs";import*as o from"@vizejs/native";import{rewriteSfcTemplateAssetReferences as s}from"@vizejs/native";import c from"node:path";import{createHash as l}from"node:crypto";import{parseSync as u}from"oxc-parser";import{transformSync as d}from"oxc-transform";function f(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===3&&Array.isArray(t.sources)&&Array.isArray(t.names)&&typeof t.mappings==`string`}function p(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return f(t)?t:null}function m(e){let t=0;for(let n=e.indexOf(`
1
+ import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-D_f3YvFb.mjs";import*as o from"@vizejs/native";import{rewriteSfcTemplateAssetReferences as s}from"@vizejs/native";import c from"node:path";import{createHash as l}from"node:crypto";import{parseSync as u}from"oxc-parser";import{transformSync as d}from"oxc-transform";function f(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===3&&Array.isArray(t.sources)&&Array.isArray(t.names)&&typeof t.mappings==`string`}function p(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return f(t)?t:null}function m(e){let t=0;for(let n=e.indexOf(`
2
2
  `);n!==-1;n=e.indexOf(`
3
3
  `,n+1))t++;return t}function h(e,t,n){if(n<=0)return e;let r=e.mappings.split(`;`);if(t>=r.length)return e;let i=[...r.slice(0,t),...Array(n).fill(``),...r.slice(t)];return{...e,mappings:i.join(`;`)}}function g(e,t,n){let r=n+e;if(!n)return{code:r,map:t??null};let i=p(t);return!i||!n.endsWith(`
4
4
  `)?{code:r,map:null}:{code:r,map:JSON.stringify(h(i,0,m(n)))}}function _(e,t){return`{
@@ -8,16 +8,16 @@ import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-ByWFOFCe.mjs";impo
8
8
  if (!Object.prototype.hasOwnProperty.call(next, key)) delete current[key]
9
9
  })
10
10
  Object.assign(current, next)
11
- }`}function v(e,t,n=`null`){return`
11
+ }`}function v(e,t,n=`null`,r=`module.hot`,i=`_sfc_main`){return`
12
12
  /* hot reload */
13
- if (module.hot) {
14
- _sfc_main.__hmrId = "${e}"
13
+ if (${r}) {
14
+ ${i}.__hmrId = "${e}"
15
15
  const api = __VUE_HMR_RUNTIME__
16
- const previous = module.hot.data && module.hot.data.vize
16
+ const previous = ${r}.data && ${r}.data.vize
17
17
  // Own writable mappings; CSS module namespace exports may be read-only.
18
- if (_sfc_main.__cssModules) {
19
- Object.keys(_sfc_main.__cssModules).forEach(name => {
20
- _sfc_main.__cssModules[name] = Object.assign(Object.create(null), _sfc_main.__cssModules[name])
18
+ if (${i}.__cssModules) {
19
+ Object.keys(${i}.__cssModules).forEach(name => {
20
+ ${i}.__cssModules[name] = Object.assign(Object.create(null), ${i}.__cssModules[name])
21
21
  })
22
22
  }
23
23
  const current = {
@@ -27,12 +27,12 @@ if (module.hot) {
27
27
  // disables state preservation without changing module loading semantics.
28
28
  try { return ${n} } catch { return null }
29
29
  })(),
30
- component: _sfc_main,
31
- setup: _sfc_main.setup && _sfc_main.setup.toString()
30
+ component: ${i},
31
+ setup: ${i}.setup && ${i}.setup.toString()
32
32
  }
33
- module.hot.dispose(data => { data.vize = current })
34
- module.hot.accept()
35
- if (!api.createRecord('${e}', _sfc_main)) {
33
+ ${r}.dispose(data => { data.vize = current })
34
+ ${r}.accept()
35
+ if (!api.createRecord('${e}', ${i})) {
36
36
  const before = previous && previous.metadata
37
37
  const after = current.metadata
38
38
  const sameImports = previous && previous.imports && current.imports &&
@@ -45,24 +45,24 @@ if (module.hot) {
45
45
  if (canPreserve && (before.module === after.module ||
46
46
  (typeof before.script === 'string' && before.script === after.script &&
47
47
  typeof before.template === 'string' && typeof after.template === 'string' &&
48
- before.template !== after.template && typeof _sfc_main.render === 'function'))) {
48
+ before.template !== after.template && typeof ${i}.render === 'function'))) {
49
49
  // Retain both the module table and each mapping captured by setup.
50
- if (previous.component.__cssModules && _sfc_main.__cssModules) {
51
- Object.keys(_sfc_main.__cssModules).forEach(name => ${_(`previous.component.__cssModules[name]`,`_sfc_main.__cssModules[name]`)})
52
- _sfc_main.__cssModules = previous.component.__cssModules
50
+ if (previous.component.__cssModules && ${i}.__cssModules) {
51
+ Object.keys(${i}.__cssModules).forEach(name => ${_(`previous.component.__cssModules[name]`,`${i}.__cssModules[name]`)})
52
+ ${i}.__cssModules = previous.component.__cssModules
53
53
  }
54
- if (before.module !== after.module || _sfc_main.__cssModules) {
55
- api.rerender('${e}', _sfc_main.render)
54
+ if (before.module !== after.module || ${i}.__cssModules) {
55
+ api.rerender('${e}', ${i}.render)
56
56
  }
57
57
  } else {
58
- api.reload('${e}', _sfc_main)
58
+ api.reload('${e}', ${i})
59
59
  }
60
60
  }
61
- }`}function y(e,t,n,r){return`
62
- if (module.hot) {
63
- module.hot.accept(${t}, () => {
64
- ${_(`_sfc_main.__cssModules[${JSON.stringify(r)}]`,n)}
65
- __VUE_HMR_RUNTIME__.rerender("${e}", _sfc_main.render)
61
+ }`}function y(e,t,n,r,i=`module.hot`,a=`_sfc_main`){return`
62
+ if (${i}) {
63
+ ${i}.accept(${t}, () => {
64
+ ${_(`${a}.__cssModules[${JSON.stringify(r)}]`,n)}
65
+ __VUE_HMR_RUNTIME__.rerender("${e}", ${a}.render)
66
66
  })
67
67
  }`}const b=`vize-rspack-output.tsx`,x=`_sfc_main`;function S(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function C(e){return typeof e?.start==`number`?e.start:null}function w(e){return S(e)&&typeof e.name==`string`?e.name:null}function T(e){try{let t=u(b,e);if(typeof t==`object`&&t){let e=t.errors;if(Array.isArray(e)&&e.length>0)return null;let n=t.program;if(S(n))return n}return S(t)?t:null}catch{return null}}function E(e){return!e||!Array.isArray(e.body)?[]:e.body.filter(S)}function D(e,t){return w(e)===t}function O(e){return(Array.isArray(e.declarations)?e.declarations:[]).filter(S).map(e=>S(e.id)?w(e.id):null).filter(e=>e!=null)}function k(e){return E(e).find(e=>e.type===`ExportDefaultDeclaration`)??null}function A(e,t){let n=C(t);if(n==null)return null;let r=/^export\s+default\b/.exec(e.slice(n));return r?n+r[0].length:null}function j(e){let t=S(e.declaration)?e.declaration:null,n=[];if(t?.type===`FunctionDeclaration`||t?.type===`ClassDeclaration`){let e=S(t.id)?w(t.id):null;e&&n.push(e)}t?.type===`VariableDeclaration`&&n.push(...O(t));let r=Array.isArray(e.specifiers)?e.specifiers:[];for(let e of r.filter(S)){let t=w(S(e.exported)?e.exported:null)??w(S(e.local)?e.local:null);t&&n.push(t)}return n}function M(e){let t=T(e),n=E(t),r=k(t),i=n.filter(e=>e.type===`ExportNamedDeclaration`).flatMap(j);return{hasDefaultExport:r!=null,hasSfcMainDefined:n.some(e=>e.type===`VariableDeclaration`&&O(e).includes(x)),hasNamedRenderExport:i.includes(`render`),hasNamedSsrRenderExport:i.includes(`ssrRender`)}}function N(e){let t=d(b,e,{target:`esnext`,jsx:`preserve`});if(t.errors.length)return null;let n=T(t.code);if(!n)return null;let r=[];for(let e of E(n)){if(e.type!==`ImportDeclaration`)continue;let t=S(e.source)?e.source.value:null;if(typeof t!=`string`)return null;if(t===`vue`||t.includes(`?vue&type=style&`))continue;let n=Array.isArray(e.specifiers)?e.specifiers.filter(S):[];if(n.length===0)return null;for(let e of n){let n=S(e.local)?w(e.local):null;if(!n)return null;let i=JSON.stringify(`${t}:${n}`);r.push(e.type===`ImportNamespaceSpecifier`?`...Object.keys(${n}).sort().map(key => [${i} + ':' + key, ${n}[key]])`:`[${i}, ${n}]`)}}return`[${r.join(`, `)}]`}function P(e){let t=e.code,n=k(T(t)),r=C(n),i=n?A(t,n):null;r==null||i==null||e.replace(r,i,`const ${x} =`)}function F(e,t,n={}){let r=e.code,i=k(T(r)),a=S(i?.declaration)?i.declaration:null,o=C(i),s=typeof i?.end==`number`?i.end:null;!D(a,x)||o==null||(n.normalizeSemicolon&&s!=null&&r[s-1]!==`;`&&r[s]!==`;`&&e.replace(s,s,`;`),e.replace(o,o,`${t}\n`))}function I(e,t){return L(e,t).code}function L(e,r){let i=new t(e.code,n(e.map)),a=e.isCustomElement;e.templateAssetUrls.length>0&&i.edit(s(i.code,e.templateAssetUrls));let o=M(i.code),u=o.hasDefaultExport,d=o.hasSfcMainDefined;if(u&&!d)P(i),e.hasScoped&&e.scopeId&&i.append(`\n_sfc_main.__scopeId = "data-v-${e.scopeId}";`),i.append(`
68
68
  export default _sfc_main;`);else if(u&&d&&e.hasScoped&&e.scopeId)F(i,`_sfc_main.__scopeId = "data-v-${e.scopeId}";`);else if(!u&&!d){let t=o.hasNamedRenderExport?`render`:o.hasNamedSsrRenderExport?`ssrRender`:null;if(t){let n=e.hasScoped&&e.scopeId?`, __scopeId: "data-v-${e.scopeId}"`:``;i.append(`\nconst _sfc_main = { ${t}${n} };\nexport default _sfc_main;`)}}if(e.styles.length>0){if(a&&e.styles.some(e=>e.module))throw Error(`[vize] <style module> is not supported in custom elements mode.`);let t=e.styles.filter(e=>e.module===!0).length;if(t>1)throw Error(`[vize] Found ${t} unnamed <style module> blocks. Only one unnamed <style module> is allowed per SFC. Use named modules instead: <style module="name">`);let n=e.styles.filter(e=>e.src||/\S/.test(e.content)),o=[],s=n.map(t=>{let n=[`vue`,`type=style`,`index=${t.index}`,`lang=${t.lang||`css`}`,...t.scoped?[`scoped=${e.scopeId}`]:[],...t.module?[`module=${typeof t.module==`string`?t.module:`true`}`]:[],...a?[`inline`]:[]],i=`${r.requestPath}?${n.join(`&`)}`;if(a)return`import _style_${t.index} from ${JSON.stringify(i)};`;if(t.module){let e=typeof t.module==`string`?t.module:`$style`,n=`_cssModule_${t.index}`;return o.push({request:i,varName:n,bindingName:e}),`import * as ${n} from ${JSON.stringify(i)};`}return`import ${JSON.stringify(i)};`}).join(`
package/dist/index.d.mts CHANGED
@@ -3,7 +3,8 @@ import vizeLoader from "./loader/index.mjs";
3
3
  import vizeJsxLoader from "./loader/jsx-loader.mjs";
4
4
  import vizeStyleLoader from "./loader/style-loader.mjs";
5
5
  import vizeScopeLoader from "./loader/scope-loader.mjs";
6
- import { Compiler, RuleSetRule, sources } from "@rspack/core";
6
+ import sources from "webpack-sources";
7
+ import { Compiler, RuleSetRule } from "@rspack/core";
7
8
 
8
9
  //#region src/plugin/index.d.ts
9
10
  declare class VizePlugin {
@@ -44,7 +45,7 @@ declare function inlineSrcBlocks(source: string, scriptContent: string | null, t
44
45
  /** Match a file path against include/exclude patterns. Normalizes backslashes. */
45
46
  declare function matchesPattern(file: string, pattern: string | RegExp | (string | RegExp)[] | undefined, defaultValue: boolean): boolean;
46
47
  //#endregion
47
- //#region src/shared/hotReload.d.ts
48
+ //#region ../shared/hot-reload.d.ts
48
49
  /** HMR code generation for Vue SFCs using `module.hot` (Rspack/webpack CJS API). */
49
50
  interface HmrMetadata {
50
51
  source: string;
@@ -56,7 +57,7 @@ interface HmrMetadata {
56
57
  styles: string;
57
58
  }
58
59
  /** Generate `module.hot` HMR boilerplate for a Vue SFC. */
59
- declare function genHotReloadCode(id: string, metadata?: HmrMetadata, imports?: string): string;
60
+ declare function genHotReloadCode(id: string, metadata?: HmrMetadata, imports?: string, hot?: string, component?: string): string;
60
61
  //#endregion
61
62
  //#region src/shared/output.d.ts
62
63
  interface GenerateOutputOptions {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,o as r,r as i,s as a,t as o}from"./utils-ByWFOFCe.mjs";import{n as s,r as c,t as l}from"./loader-XrFRvGvu.mjs";import{a as u,i as d,n as f,r as p,s as m,t as h}from"./compiler-BE-cXcUW.mjs";import g from"./loader/jsx-loader.mjs";import _ from"./loader/style-loader.mjs";import v from"./loader/scope-loader.mjs";import{createRequire as y}from"node:module";import{parse as b}from"node:querystring";const x=`@vizejs/rspack-plugin/loader`;let S;try{S=y(import.meta.url).resolve(x).replaceAll(`\\`,`/`)}catch{}function C(e){let t=e.replaceAll(`\\`,`/`);return e===x||t===S||(t.includes(`@vizejs/rspack-plugin/`)||t.includes(`rspack-vize-plugin/`))&&/\/dist\/loader\/index\.[cm]?js$/.test(t)}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`string`?e.startsWith(`{`)&&e.endsWith(`}`)?JSON.parse(e):b(e):w(e)?e:{}}function E(e,t,n=!0){function r(e){if(typeof e.loader!=`string`||!C(e.loader))return;let r=T(e.options),i=w(r.css)?r.css:{};if(i.native!==void 0){if(!n)return;if(i.native!==t)throw Error(`[vize] Loader css.native conflicts with VizePlugin's automatic CSS mode. Configure a matching mode on VizePlugin, or set autoRules: false and provide matching style sub-request rules. See MIGRATION.md.`)}e.options={...r,css:{...i,native:t}}}function i(e){if(typeof e==`string`&&C(e)){let t={loader:e};return r(t),t}return w(e)&&r(e),e}function a(e){for(let t of e)w(t)&&(r(t),Array.isArray(t.use)?t.use=t.use.map(i):t.use!==void 0&&typeof t.use!=`function`&&(t.use=i(t.use)),Array.isArray(t.oneOf)&&a(t.oneOf),Array.isArray(t.rules)&&a(t.rules))}a(e)}const D=`@vizejs/rspack-plugin/style-loader`,O=`@vizejs/rspack-plugin/scope-loader`,k={"\\.css$":`css`,"\\.scss$":`scss`,"\\.sass$":`sass`,"\\.less$":`less`,"\\.styl(us)?$":`styl`};function A(e,t){let n=[],r=e.findIndex(e=>e!==`...`&&j(e));if(r===-1)return{applied:!1,clonedCount:0,warnings:n};let i=e[r];if(i.oneOf)return{applied:!1,clonedCount:0,warnings:n};let a=[];for(let t=0;t<e.length;t++){if(t===r)continue;let n=e[t];if(n===`...`)continue;let i=N(n);i&&a.push({index:t,rule:n,lang:i})}let o=[];for(let e of a)o.push(...P(e.rule,e.lang,t));o.some(e=>e.resourceQuery instanceof RegExp&&e.resourceQuery.test(`vue&type=style&index=0&lang=css`))||o.push(...F(t));let{test:s,include:c,exclude:l,resource:u,descriptionData:d,...f}=i,p={...f,loader:void 0,options:void 0,use:z(R(i))};E([p],t);for(let e of o)e.sideEffects=!0;e[r]={test:s,include:c,exclude:l,resource:u,descriptionData:d,oneOf:[...o,p]};for(let e of a)I(e.rule);return{applied:!0,clonedCount:o.length,warnings:n}}function j(e){return M(e.test)?R(e).some(e=>{let t=typeof e==`string`?e:e.loader;return t?C(t):!1}):!1}function M(e){return e?e instanceof RegExp?e.test(`App.vue`)||e.test(`foo.vue`):typeof e==`string`?e.includes(`.vue`):!1:!1}function N(e){let t=e.test;if(!t||!(t instanceof RegExp))return null;let n=t.source;for(let[e,t]of Object.entries(k))if(n.includes(e)||n===e)return t;return t.test(`foo.css`)&&!t.test(`foo.vue`)?`css`:t.test(`foo.scss`)&&!t.test(`foo.vue`)?`scss`:t.test(`foo.sass`)&&!t.test(`foo.vue`)?`sass`:t.test(`foo.less`)&&!t.test(`foo.vue`)?`less`:t.test(`foo.styl`)&&!t.test(`foo.vue`)?`styl`:null}function P(e,t,n){let r=R(e);if(r.length===0)return[];let i=z(r),a=n?-1:i.findIndex(e=>{let t=typeof e==`string`?e:e.loader;return/(?:^|[/\\])css-loader(?:[/\\?]|$)/.test(t??``)});i.splice(a+1,0,{loader:O}),i.push({loader:D});let o=(t,n)=>{let r={resourceQuery:t,use:z(i)};return n===`css/module`&&(!e.type||e.type===`css/auto`)?r.type=n:e.type?r.type=e.type:n&&(r.type=n),r};return n?[o(RegExp(`(?=.*type=style)(?=.*lang=${t})(?=.*module=)`),`css/module`),o(RegExp(`(?=.*type=style)(?=.*lang=${t})`),`css/auto`)]:[o(RegExp(`(?=.*type=style)(?=.*lang=${t})`))]}function F(e){return e?[{resourceQuery:/(?=.*type=style)(?=.*lang=css)(?=.*module=)/,type:`css/module`,use:[{loader:O},{loader:D}]},{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`css/auto`,use:[{loader:O},{loader:D}]}]:[{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`javascript/auto`,use:[{loader:O},{loader:D}]}]}function I(e){let t=e.resourceQuery;if(t)return typeof t==`object`&&!Array.isArray(t)&&!(t instanceof RegExp)&&`not`in t,void 0;e.resourceQuery={not:[/vue/]}}function L(e){return e?Array.isArray(e)?e:[e]:[]}function R(e){let t=L(e.use);if(t.length>0)return t;let n=e.loader;if(n){let t=e.options;return t?[{loader:n,options:t}]:[n]}return[]}function z(e){return e.map(e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t={...e};return`options`in e&&e.options&&typeof e.options==`object`&&(t.options={...e.options}),t}return e})}var B=class e{static name=`VizePlugin`;options;constructor(e={}){this.options=e}apply(t){let n=t.getInfrastructureLogger(e.name),r=this.options.isProduction??t.options.mode===`production`,i=[`include`,`exclude`,`isProduction`,`ssr`,`sourceMap`,`vapor`,`jsxMode`,`jsxCompat`,`root`,`compilerOptions`].filter(e=>this.options[e]!==void 0);i.length>0&&n.warn(`Deprecated VizePlugin options: ${i.join(`, `)}. Compilation options belong in loader options; file filters belong in module.rules. Legacy plugin behavior is unchanged: compilation options are not forwarded. See MIGRATION.md.`),this.options.debug&&this.options.vapor&&!r&&n.debug(`Legacy plugin vapor is set; configure vapor on the loader to select compilation mode.`);let a=s(t.options),o=t.webpack?.rspackVersion,l=c(this.options.css?.native,t.options,o);this.options.css?.native&&a===`disabled`&&n.warn("`css.native: true` is set but `experiments.css` is not enabled in rspack config.");let u=t.options.module?.rules,d=this.options.autoRules??!0;if(u&&E(u,l,d),d){let e=t.options.module?.rules;if(e){let t=A(e,l);t.applied&&this.options.debug&&n.debug(`Auto-injected ${t.clonedCount} style rule(s) for Vue SFC sub-requests.`);for(let e of t.warnings)n.warn(e)}}if(this.options.typescript??!0){let e=t.options.module?.rules;e&&(e.some(e=>{if(e===`...`||typeof e!=`object`||!e)return!1;let t=e;if(t.enforce!==`post`)return!1;let n=t.test;return n instanceof RegExp?n.test(`App.vue`):typeof n==`string`?n.includes(`.vue`):!1})||(e.push({test:/\.vue$/,resourceQuery:{not:[/type=/]},enforce:`post`,loader:`builtin:swc-loader`,options:{jsc:{parser:{syntax:`typescript`}}},type:`javascript/auto`}),this.options.debug&&n.debug(`Auto-injected TypeScript post-processing rule for .vue files.`)))}let{DefinePlugin:f}=t.webpack,p=new Set;for(let e of t.options.plugins??[]){let t=e?.definitions;if(t)for(let e of Object.keys(t))p.add(e)}let m={};p.has(`__VUE_OPTIONS_API__`)||(m.__VUE_OPTIONS_API__=JSON.stringify(!0)),p.has(`__VUE_PROD_DEVTOOLS__`)||(m.__VUE_PROD_DEVTOOLS__=JSON.stringify(!r)),p.has(`__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`)||(m.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=JSON.stringify(!r)),Object.keys(m).length>0&&new f(m).apply(t),this.options.debug&&!r&&t.hooks.watchRun.tap(e.name,e=>{let t=e.modifiedFiles,r=e.removedFiles;if(t)for(let e of t)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file changed: ${e}`);if(r)for(let e of r)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file removed: ${e}`)})}shouldHandleFile(e){return!(!t(e,this.options.include,!0)||t(e,this.options.exclude,!1))}};export{B as VizePlugin,o as addScopeToCssFallback,A as applyRuleCloning,h as clearCompilationCache,f as compileFile,p as compileJsxModule,i as extractCustomBlocks,n as extractSrcInfo,e as extractStyleBlocks,m as genHotReloadCode,u as generateOutput,r as generateScopeId,a as inlineSrcBlocks,d as isJsxFile,t as matchesPattern,g as vizeJsxLoader,l as vizeLoader,v as vizeScopeLoader,_ as vizeStyleLoader};
1
+ import{a as e,c as t,i as n,o as r,r as i,s as a,t as o}from"./utils-D_f3YvFb.mjs";import{n as s,r as c,t as l}from"./loader-BMbfY0xo.mjs";import{a as u,i as d,n as f,r as p,s as m,t as h}from"./compiler-D82EwDeR.mjs";import g from"./loader/jsx-loader.mjs";import _ from"./loader/style-loader.mjs";import v from"./loader/scope-loader.mjs";import{createRequire as y}from"node:module";import{parse as b}from"node:querystring";const x=`@vizejs/rspack-plugin/loader`;let S;try{S=y(import.meta.url).resolve(x).replaceAll(`\\`,`/`)}catch{}function C(e){let t=e.replaceAll(`\\`,`/`);return e===x||t===S||(t.includes(`@vizejs/rspack-plugin/`)||t.includes(`rspack-vize-plugin/`))&&/\/dist\/loader\/index\.[cm]?js$/.test(t)}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`string`?e.startsWith(`{`)&&e.endsWith(`}`)?JSON.parse(e):b(e):w(e)?e:{}}function E(e,t,n=!0){function r(e){if(typeof e.loader!=`string`||!C(e.loader))return;let r=T(e.options),i=w(r.css)?r.css:{};if(i.native!==void 0){if(!n)return;if(i.native!==t)throw Error(`[vize] Loader css.native conflicts with VizePlugin's automatic CSS mode. Configure a matching mode on VizePlugin, or set autoRules: false and provide matching style sub-request rules. See MIGRATION.md.`)}e.options={...r,css:{...i,native:t}}}function i(e){if(typeof e==`string`&&C(e)){let t={loader:e};return r(t),t}return w(e)&&r(e),e}function a(e){for(let t of e)w(t)&&(r(t),Array.isArray(t.use)?t.use=t.use.map(i):t.use!==void 0&&typeof t.use!=`function`&&(t.use=i(t.use)),Array.isArray(t.oneOf)&&a(t.oneOf),Array.isArray(t.rules)&&a(t.rules))}a(e)}const D=`@vizejs/rspack-plugin/style-loader`,O=`@vizejs/rspack-plugin/scope-loader`,k={"\\.css$":`css`,"\\.scss$":`scss`,"\\.sass$":`sass`,"\\.less$":`less`,"\\.styl(us)?$":`styl`};function A(e,t){let n=[],r=e.findIndex(e=>e!==`...`&&j(e));if(r===-1)return{applied:!1,clonedCount:0,warnings:n};let i=e[r];if(i.oneOf)return{applied:!1,clonedCount:0,warnings:n};let a=[];for(let t=0;t<e.length;t++){if(t===r)continue;let n=e[t];if(n===`...`)continue;let i=N(n);i&&a.push({index:t,rule:n,lang:i})}let o=[];for(let e of a)o.push(...P(e.rule,e.lang,t));o.some(e=>e.resourceQuery instanceof RegExp&&e.resourceQuery.test(`vue&type=style&index=0&lang=css`))||o.push(...F(t));let{test:s,include:c,exclude:l,resource:u,descriptionData:d,...f}=i,p={...f,loader:void 0,options:void 0,use:z(R(i))};E([p],t);for(let e of o)e.sideEffects=!0;e[r]={test:s,include:c,exclude:l,resource:u,descriptionData:d,oneOf:[...o,p]};for(let e of a)I(e.rule);return{applied:!0,clonedCount:o.length,warnings:n}}function j(e){return M(e.test)?R(e).some(e=>{let t=typeof e==`string`?e:e.loader;return t?C(t):!1}):!1}function M(e){return e?e instanceof RegExp?e.test(`App.vue`)||e.test(`foo.vue`):typeof e==`string`?e.includes(`.vue`):!1:!1}function N(e){let t=e.test;if(!t||!(t instanceof RegExp))return null;let n=t.source;for(let[e,t]of Object.entries(k))if(n.includes(e)||n===e)return t;return t.test(`foo.css`)&&!t.test(`foo.vue`)?`css`:t.test(`foo.scss`)&&!t.test(`foo.vue`)?`scss`:t.test(`foo.sass`)&&!t.test(`foo.vue`)?`sass`:t.test(`foo.less`)&&!t.test(`foo.vue`)?`less`:t.test(`foo.styl`)&&!t.test(`foo.vue`)?`styl`:null}function P(e,t,n){let r=R(e);if(r.length===0)return[];let i=z(r),a=n?-1:i.findIndex(e=>{let t=typeof e==`string`?e:e.loader;return/(?:^|[/\\])css-loader(?:[/\\?]|$)/.test(t??``)});i.splice(a+1,0,{loader:O}),i.push({loader:D});let o=(t,n)=>{let r={resourceQuery:t,use:z(i)};return n===`css/module`&&(!e.type||e.type===`css/auto`)?r.type=n:e.type?r.type=e.type:n&&(r.type=n),r};return n?[o(RegExp(`(?=.*type=style)(?=.*lang=${t})(?=.*module=)`),`css/module`),o(RegExp(`(?=.*type=style)(?=.*lang=${t})`),`css/auto`)]:[o(RegExp(`(?=.*type=style)(?=.*lang=${t})`))]}function F(e){return e?[{resourceQuery:/(?=.*type=style)(?=.*lang=css)(?=.*module=)/,type:`css/module`,use:[{loader:O},{loader:D}]},{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`css/auto`,use:[{loader:O},{loader:D}]}]:[{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`javascript/auto`,use:[{loader:O},{loader:D}]}]}function I(e){let t=e.resourceQuery;if(t)return typeof t==`object`&&!Array.isArray(t)&&!(t instanceof RegExp)&&`not`in t,void 0;e.resourceQuery={not:[/vue/]}}function L(e){return e?Array.isArray(e)?e:[e]:[]}function R(e){let t=L(e.use);if(t.length>0)return t;let n=e.loader;if(n){let t=e.options;return t?[{loader:n,options:t}]:[n]}return[]}function z(e){return e.map(e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t={...e};return`options`in e&&e.options&&typeof e.options==`object`&&(t.options={...e.options}),t}return e})}var B=class e{static name=`VizePlugin`;options;constructor(e={}){this.options=e}apply(t){let n=t.getInfrastructureLogger(e.name),r=this.options.isProduction??t.options.mode===`production`,i=[`include`,`exclude`,`isProduction`,`ssr`,`sourceMap`,`vapor`,`jsxMode`,`jsxCompat`,`root`,`compilerOptions`].filter(e=>this.options[e]!==void 0);i.length>0&&n.warn(`Deprecated VizePlugin options: ${i.join(`, `)}. Compilation options belong in loader options; file filters belong in module.rules. Legacy plugin behavior is unchanged: compilation options are not forwarded. See MIGRATION.md.`),this.options.debug&&this.options.vapor&&!r&&n.debug(`Legacy plugin vapor is set; configure vapor on the loader to select compilation mode.`);let a=s(t.options),o=t.webpack?.rspackVersion,l=c(this.options.css?.native,t.options,o);this.options.css?.native&&a===`disabled`&&n.warn("`css.native: true` is set but `experiments.css` is not enabled in rspack config.");let u=t.options.module?.rules,d=this.options.autoRules??!0;if(u&&E(u,l,d),d){let e=t.options.module?.rules;if(e){let t=A(e,l);t.applied&&this.options.debug&&n.debug(`Auto-injected ${t.clonedCount} style rule(s) for Vue SFC sub-requests.`);for(let e of t.warnings)n.warn(e)}}if(this.options.typescript??!0){let e=t.options.module?.rules;e&&(e.some(e=>{if(e===`...`||typeof e!=`object`||!e)return!1;let t=e;if(t.enforce!==`post`)return!1;let n=t.test;return n instanceof RegExp?n.test(`App.vue`):typeof n==`string`?n.includes(`.vue`):!1})||(e.push({test:/\.vue$/,resourceQuery:{not:[/type=/]},enforce:`post`,loader:`builtin:swc-loader`,options:{jsc:{parser:{syntax:`typescript`}}},type:`javascript/auto`}),this.options.debug&&n.debug(`Auto-injected TypeScript post-processing rule for .vue files.`)))}let{DefinePlugin:f}=t.webpack,p=new Set;for(let e of t.options.plugins??[]){let t=e?.definitions;if(t)for(let e of Object.keys(t))p.add(e)}let m={};p.has(`__VUE_OPTIONS_API__`)||(m.__VUE_OPTIONS_API__=JSON.stringify(!0)),p.has(`__VUE_PROD_DEVTOOLS__`)||(m.__VUE_PROD_DEVTOOLS__=JSON.stringify(!r)),p.has(`__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`)||(m.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=JSON.stringify(!r)),Object.keys(m).length>0&&new f(m).apply(t),this.options.debug&&!r&&t.hooks.watchRun.tap(e.name,e=>{let t=e.modifiedFiles,r=e.removedFiles;if(t)for(let e of t)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file changed: ${e}`);if(r)for(let e of r)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file removed: ${e}`)})}shouldHandleFile(e){return!(!t(e,this.options.include,!0)||t(e,this.options.exclude,!1))}};export{B as VizePlugin,o as addScopeToCssFallback,A as applyRuleCloning,h as clearCompilationCache,f as compileFile,p as compileJsxModule,i as extractCustomBlocks,n as extractSrcInfo,e as extractStyleBlocks,m as genHotReloadCode,u as generateOutput,r as generateScopeId,a as inlineSrcBlocks,d as isJsxFile,t as matchesPattern,g as vizeJsxLoader,l as vizeLoader,v as vizeScopeLoader,_ as vizeStyleLoader};
@@ -1 +1 @@
1
- import{t as e}from"../loader-XrFRvGvu.mjs";export{e as default};
1
+ import{t as e}from"../loader-BMbfY0xo.mjs";export{e as default};
@@ -1 +1 @@
1
- import{c as e,m as t}from"../utils-ByWFOFCe.mjs";import{r as n}from"../compiler-BE-cXcUW.mjs";function r(e){let r=this.async(),a=this.getOptions(),o=this.resourcePath;if(this.addDependency(o),!i(o,a)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${o}. Passing through source unchanged.`)),r(null,e);return}try{let i=this.mode===`production`||process.env.NODE_ENV===`production`,s=a.sourceMap??this.sourceMap??!i,{code:c,map:l,warnings:u}=n(o,e,{jsxMode:a.jsxMode,jsxCompat:a.jsxCompat,vapor:a.vapor??!1,sourceMap:s});for(let e of u)this.emitWarning(Error(`[vize] ${e}`));r(null,c,t(l)?l:void 0)}catch(e){r(e)}}function i(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}export{r as default};
1
+ import{c as e,m as t}from"../utils-D_f3YvFb.mjs";import{r as n}from"../compiler-D82EwDeR.mjs";function r(e){let r=this.async(),a=this.getOptions(),o=this.resourcePath;if(this.addDependency(o),!i(o,a)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${o}. Passing through source unchanged.`)),r(null,e);return}try{let i=this.mode===`production`||process.env.NODE_ENV===`production`,s=a.sourceMap??this.sourceMap??!i,{code:c,map:l,warnings:u}=n(o,e,{jsxMode:a.jsxMode,jsxCompat:a.jsxCompat,vapor:a.vapor??!1,sourceMap:s});for(let e of u)this.emitWarning(Error(`[vize] ${e}`));r(null,c,t(l)?l:void 0)}catch(e){r(e)}}function i(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}export{r as default};
@@ -1 +1 @@
1
- import{l as e}from"../utils-ByWFOFCe.mjs";import*as t from"@vizejs/native";const{compileCss:n}=t;function r(t){let r=this.async(),{resourceQuery:i,resourcePath:a}=this;if(!i){r(null,t);return}let o=new URLSearchParams(i.slice(1)).get(`scoped`);if(!o){r(null,t);return}let s=`data-v-${o}`,c=n(e(t),{filename:a,scoped:!0,scopeId:s});for(let e of c.errors)this.emitError(Error(`[vize] ${e}`));for(let e of c.warnings)this.emitWarning(Error(`[vize] ${e}`));r(null,c.code)}export{r as default};
1
+ import{l as e}from"../utils-D_f3YvFb.mjs";import*as t from"@vizejs/native";const{compileCss:n}=t;function r(t){let r=this.async(),{resourceQuery:i,resourcePath:a}=this;if(!i){r(null,t);return}let o=new URLSearchParams(i.slice(1)).get(`scoped`);if(!o){r(null,t);return}let s=`data-v-${o}`,c=n(e(t),{filename:a,scoped:!0,scopeId:s});for(let e of c.errors)this.emitError(Error(`[vize] ${e}`));for(let e of c.warnings)this.emitWarning(Error(`[vize] ${e}`));r(null,c.code)}export{r as default};
@@ -1 +1 @@
1
- import{a as e}from"../utils-ByWFOFCe.mjs";import t from"node:path";import n from"node:fs/promises";function r(r){let i=this.async(),{resourceQuery:a,resourcePath:o}=this;if(!a){i(null,r);return}let s=new URLSearchParams(a.slice(1));if(s.get(`type`)!==`style`){i(null,r);return}let c=parseInt(s.get(`index`)||`0`,10);this.addDependency(o);let l=e(r)[c];if(!l){this.hot||this.emitError(Error(`[vize] Style block at index ${c} not found in ${o}`)),i(null,``);return}if(l.src){let e=t.resolve(t.dirname(o),l.src);this.addDependency(e),n.readFile(e,`utf-8`).then(e=>{i(null,e)}).catch(()=>{this.emitWarning(Error(`[vize] <style src> target not found: ${l.src} (resolved: ${e}) in ${o}`)),i(null,``)});return}i(null,l.content)}export{r as default};
1
+ import{a as e}from"../utils-D_f3YvFb.mjs";import t from"node:path";import n from"node:fs/promises";function r(r){let i=this.async(),{resourceQuery:a,resourcePath:o}=this;if(!a){i(null,r);return}let s=new URLSearchParams(a.slice(1));if(s.get(`type`)!==`style`){i(null,r);return}let c=parseInt(s.get(`index`)||`0`,10);this.addDependency(o);let l=e(r)[c];if(!l){this.hot||this.emitError(Error(`[vize] Style block at index ${c} not found in ${o}`)),i(null,``);return}if(l.src){let e=t.resolve(t.dirname(o),l.src);this.addDependency(e),n.readFile(e,`utf-8`).then(e=>{i(null,e)}).catch(()=>{this.emitWarning(Error(`[vize] <style src> target not found: ${l.src} (resolved: ${e}) in ${o}`)),i(null,``)});return}i(null,l.content)}export{r as default};
@@ -1 +1 @@
1
- import{c as e,f as t,i as n,p as r,r as i}from"./utils-ByWFOFCe.mjs";import{n as a,o}from"./compiler-BE-cXcUW.mjs";import{sources as s}from"@rspack/core";import c from"node:fs";import l from"node:path";function u(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function d(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function f(e,t,n){if(e!=null)return e;let r=u(t);if(r!==`unavailable`)return r===`enabled`;let i=d(n);return i!=null&&i>=2}const p=/\.ce\.vue$/;function m(e){let u=this.async(),d=this.getOptions(),f=this.resourcePath,p=this.resourceQuery,m=v(this,f),y=d.isProduction??(this.mode===`production`||process.env.NODE_ENV===`production`),b=d.ssr??d.compilerOptions?.ssr??!1,x=!b&&!y&&d.hotReload!==!1,S=g(this,d),C=d.sourceMap??d.compilerOptions?.sourceMap??this.sourceMap??!y;if(this.addDependency(f),p?.includes(`type=style`)){u(Error(`[vize] Main loader received style sub-request: ${f}${p}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(p&&p.includes(`vue`)&&p.includes(`type=`)&&!p.includes(`type=style`)){let t=new URLSearchParams(p.slice(1)),n=t.get(`type`);if(n&&n!==`style`){let r=parseInt(t.get(`index`)||`0`,10),a=i(e)[r];if(a){if(a.src){let e=l.resolve(l.dirname(f),a.src);this.addDependency(e);try{u(null,c.readFileSync(e,`utf-8`))}catch{u(Error(`[vize] Custom block <${n} src="${a.src}"> not found (resolved: ${e}) in ${f}`))}return}u(null,a.content)}else u(null,``);return}}if(!h(f,d)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${f}. Passing through source unchanged.`)),u(null,e);return}try{let i=_(f,d.customElement),p=n(e),h=new t(e,C&&(p.scriptSrc||p.templateSrc)?new s.OriginalSource(e,f).map({columns:!0}):null);if(p.scriptSrc){let e=l.resolve(l.dirname(f),p.scriptSrc);this.addDependency(e);try{r(h,`script`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <script src="${p.scriptSrc}"> not found (resolved: ${e}) in ${f}`));return}}if(p.templateSrc){let e=l.resolve(l.dirname(f),p.templateSrc);this.addDependency(e);try{r(h,`template`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <template src="${p.templateSrc}"> not found (resolved: ${e}) in ${f}`));return}}let g=d.root?l.resolve(this.rootContext,d.root):this.rootContext,v=a(f,h.code,{sourceMap:C,ssr:b,vapor:d.vapor??d.compilerOptions?.vapor??!1,compilerOptions:d.compilerOptions,isCustomElement:i,rootContext:g,isProduction:y,transformAssetUrls:d.transformAssetUrls});for(let e of v.warnings)this.emitWarning(Error(`[vize] ${e}`));if(v.errors.length>0){for(let e of v.errors)this.emitError(Error(`[vize] ${e}`));let e=v.errors.join(`\\n`);u(Error(`[vize] Compilation failed for ${f}:\n${e}`));return}let w=o(v,{requestPath:m,hmr:x,filePath:f,isProduction:y,rootContext:g,nativeCss:S}),T=w.map&&h.map?new s.SourceMapSource(w.code,f,JSON.stringify(w.map),h.code,JSON.stringify(h.map),!0).map({columns:!0}):w.map;u(null,w.code,T?JSON.stringify(T):void 0)}catch(e){u(e)}}function h(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function g(e,t){let n=e._compiler;return f(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function _(e,t){return t===!0?!0:t===!1||t===void 0?p.test(e):t.test(e)}function v(e,t){return`./${l.basename(t)}`}export{u as n,f as r,m as t};
1
+ import{c as e,f as t,i as n,p as r,r as i}from"./utils-D_f3YvFb.mjs";import{n as a,o}from"./compiler-D82EwDeR.mjs";import{sources as s}from"@rspack/core";import c from"node:fs";import l from"node:path";function u(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function d(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function f(e,t,n){if(e!=null)return e;let r=u(t);if(r!==`unavailable`)return r===`enabled`;let i=d(n);return i!=null&&i>=2}const p=/\.ce\.vue$/;function m(e){let u=this.async(),d=this.getOptions(),f=this.resourcePath,p=this.resourceQuery,m=v(this,f),y=d.isProduction??(this.mode===`production`||process.env.NODE_ENV===`production`),b=d.ssr??d.compilerOptions?.ssr??!1,x=!b&&!y&&d.hotReload!==!1,S=g(this,d),C=d.sourceMap??d.compilerOptions?.sourceMap??this.sourceMap??!y;if(this.addDependency(f),p?.includes(`type=style`)){u(Error(`[vize] Main loader received style sub-request: ${f}${p}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(p&&p.includes(`vue`)&&p.includes(`type=`)&&!p.includes(`type=style`)){let t=new URLSearchParams(p.slice(1)),n=t.get(`type`);if(n&&n!==`style`){let r=parseInt(t.get(`index`)||`0`,10),a=i(e)[r];if(a){if(a.src){let e=l.resolve(l.dirname(f),a.src);this.addDependency(e);try{u(null,c.readFileSync(e,`utf-8`))}catch{u(Error(`[vize] Custom block <${n} src="${a.src}"> not found (resolved: ${e}) in ${f}`))}return}u(null,a.content)}else u(null,``);return}}if(!h(f,d)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${f}. Passing through source unchanged.`)),u(null,e);return}try{let i=_(f,d.customElement),p=n(e),h=new t(e,C&&(p.scriptSrc||p.templateSrc)?new s.OriginalSource(e,f).map({columns:!0}):null);if(p.scriptSrc){let e=l.resolve(l.dirname(f),p.scriptSrc);this.addDependency(e);try{r(h,`script`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <script src="${p.scriptSrc}"> not found (resolved: ${e}) in ${f}`));return}}if(p.templateSrc){let e=l.resolve(l.dirname(f),p.templateSrc);this.addDependency(e);try{r(h,`template`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <template src="${p.templateSrc}"> not found (resolved: ${e}) in ${f}`));return}}let g=d.root?l.resolve(this.rootContext,d.root):this.rootContext,v=a(f,h.code,{sourceMap:C,ssr:b,vapor:d.vapor??d.compilerOptions?.vapor??!1,compilerOptions:d.compilerOptions,isCustomElement:i,rootContext:g,isProduction:y,transformAssetUrls:d.transformAssetUrls});for(let e of v.warnings)this.emitWarning(Error(`[vize] ${e}`));if(v.errors.length>0){for(let e of v.errors)this.emitError(Error(`[vize] ${e}`));let e=v.errors.join(`\\n`);u(Error(`[vize] Compilation failed for ${f}:\n${e}`));return}let w=o(v,{requestPath:m,hmr:x,filePath:f,isProduction:y,rootContext:g,nativeCss:S}),T=w.map&&h.map?new s.SourceMapSource(w.code,f,JSON.stringify(w.map),h.code,JSON.stringify(h.map),!0).map({columns:!0}):w.map;u(null,w.code,T?JSON.stringify(T):void 0)}catch(e){u(e)}}function h(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function g(e,t){let n=e._compiler;return f(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function _(e,t){return t===!0?!0:t===!1||t===void 0?p.test(e):t.test(e)}function v(e,t){return`./${l.basename(t)}`}export{u as n,f as r,m as t};
@@ -0,0 +1 @@
1
+ import{collectSfcTemplateAssetUrls as e,extractSfcCustomBlocks as t,extractSfcSrcInfo as n,extractSfcStyleBlocks as r,generateSfcScopeId as i,scopeViteCssForPipeline as a,stripSfcScopedCssComments as o}from"@vizejs/native";import s from"webpack-sources";import{diffChars as c}from"diff";function l(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t==`object`&&t&&t.version===3&&Array.isArray(t.sources)&&t.sources.every(e=>typeof e==`string`)&&Array.isArray(t.names)&&t.names.every(e=>typeof e==`string`)&&(t.sourcesContent===void 0||Array.isArray(t.sourcesContent)&&t.sourcesContent.every(e=>e===null||typeof e==`string`))&&typeof t.mappings==`string`?t:null}catch{return null}}var u=class{code;map;constructor(e,t){this.code=e,this.map=t}edit(e){let t=this.code;if(this.code=e,this.map===null||e===t)return;let n=c(t,e,{maxEditLength:1e4,timeout:100});if(!n){this.map=null;return}let r=new s.SourceMapSource(t,this.map.file??`sfc.js`,JSON.stringify(this.map)),i=new s.ConcatSource,a=0;for(let e of n)e.added?i.add(e.value):(e.removed||i.add(f(r,t.length,a,a+e.value.length)),a+=e.value.length);this.map=i.map({columns:!0})}replace(e,t,n){let r=this.code,i=typeof n==`string`?n:n.source().toString();if(this.code=r.slice(0,e)+i+r.slice(t),this.map===null)return;let a=new s.SourceMapSource(r,this.map.file??`sfc.js`,JSON.stringify(this.map));this.map=new s.ConcatSource(f(a,r.length,0,e),n,f(a,r.length,t,r.length)).map({columns:!0})}prepend(e){this.replace(0,0,e)}append(e){this.replace(this.code.length,this.code.length,e)}};function d(e,t,n,r){let i=RegExp(`(<${t})([^>]*)\\bsrc=["'][^"']+["']([^>]*>)[\\s\\S]*?(<\\/${t}>)`,`i`).exec(e.code);if(!i)return;let[,a,o,c,l]=i,u=(o+c).replace(/\bsrc=["'][^"']+["']\s*/g,``);e.replace(i.index,i.index+i[0].length,new s.ConcatSource(`${a}${u}\n`,r?new s.OriginalSource(n,r):n,`\n${l}`))}function f(e,t,n,r){if(n===r)return new s.RawSource(``);let i=new s.ReplaceSource(e);return n>0&&i.replace(0,n-1,``),r<t&&i.replace(r,t-1,``),i}function p(e,t,n,r){return i(e,t,n,r)}function m(e){return r(e).map(w)}function h(e){return o(e)}function g(e,t){return a(e,t.startsWith(`data-v-`)?t:`data-v-${t}`)}function _(e){return t(e).map(T)}function v(e){let t=n(e);return{scriptSrc:t.scriptSrc??null,templateSrc:t.templateSrc??null}}function y(e,t,n){let r=new u(e,null);return t!==null&&d(r,`script`,t),n!==null&&d(r,`template`,n),r.code}function b(e,t,n){if(!t)return n;let r=e.replace(/\\/g,`/`);return(Array.isArray(t)?t:[t]).some(t=>typeof t==`string`?r.includes(t)||e.includes(t):x(t,r))}function x(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}Object.freeze({img:[`src`],video:[`src`,`poster`],source:[`src`],image:[`xlink:href`,`href`],use:[`xlink:href`,`href`]});function S(t,n){return n===!1?[]:e(t,C(n))}function C(e){if(!(e==null||e===!0))return Object.entries(e).map(([e,t])=>({tag:e,attrs:t}))}function w(e){return{content:e.content,src:e.src??null,lang:e.lang??null,scoped:e.scoped,module:e.module?e.moduleName??!0:!1,index:e.index}}function T(e){let t={};for(let n of e.attrs)t[n.name]=n.value??!0;return{type:e.blockType,content:e.content,src:e.src??null,attrs:t,index:e.index}}export{m as a,b as c,w as d,u as f,v as i,h as l,l as m,S as n,p as o,d as p,_ as r,y as s,g as t,T as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/rspack-plugin",
3
- "version": "0.572.0",
3
+ "version": "0.574.0",
4
4
  "description": "High-performance Rspack plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -59,16 +59,18 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@vizejs/native": "0.572.0",
62
+ "@vizejs/native": "0.574.0",
63
63
  "diff": "8.0.4",
64
64
  "oxc-parser": "0.144.0",
65
- "oxc-transform": "0.144.0"
65
+ "oxc-transform": "0.144.0",
66
+ "webpack-sources": "3.5.1"
66
67
  },
67
68
  "devDependencies": {
68
69
  "@jridgewell/trace-mapping": "0.3.31",
69
70
  "@rspack/core": "2.1.8",
70
71
  "@tsdown/css": "0.22.14",
71
72
  "@types/node": "25.9.2",
73
+ "@vizejs/builder-shared": "0.0.0",
72
74
  "css-loader": "7.1.2",
73
75
  "tsdown": "0.22.14",
74
76
  "typescript": "6.0.3",
@@ -1 +0,0 @@
1
- import{collectSfcTemplateAssetUrls as e,extractSfcCustomBlocks as t,extractSfcSrcInfo as n,extractSfcStyleBlocks as r,generateSfcScopeId as i,scopeViteCssForPipeline as a,stripSfcScopedCssComments as o}from"@vizejs/native";import{sources as s}from"@rspack/core";import{diffChars as c}from"diff";function l(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t==`object`&&t&&t.version===3&&Array.isArray(t.sources)&&t.sources.every(e=>typeof e==`string`)&&Array.isArray(t.names)&&t.names.every(e=>typeof e==`string`)&&(t.sourcesContent===void 0||Array.isArray(t.sourcesContent)&&t.sourcesContent.every(e=>e===null||typeof e==`string`))&&typeof t.mappings==`string`?t:null}catch{return null}}var u=class{code;map;constructor(e,t){this.code=e,this.map=t}edit(e){let t=this.code;if(this.code=e,this.map===null||e===t)return;let n=c(t,e,{maxEditLength:1e4,timeout:100});if(!n){this.map=null;return}let r=new s.SourceMapSource(t,this.map.file??`sfc.js`,JSON.stringify(this.map)),i=new s.ConcatSource,a=0;for(let e of n)e.added?i.add(e.value):(e.removed||i.add(f(r,t.length,a,a+e.value.length)),a+=e.value.length);this.map=i.map({columns:!0})}replace(e,t,n){let r=this.code,i=typeof n==`string`?n:n.source().toString();if(this.code=r.slice(0,e)+i+r.slice(t),this.map===null)return;let a=new s.SourceMapSource(r,this.map.file??`sfc.js`,JSON.stringify(this.map));this.map=new s.ConcatSource(f(a,r.length,0,e),n,f(a,r.length,t,r.length)).map({columns:!0})}prepend(e){this.replace(0,0,e)}append(e){this.replace(this.code.length,this.code.length,e)}};function d(e,t,n,r){let i=RegExp(`(<${t})([^>]*)\\bsrc=["'][^"']+["']([^>]*>)[\\s\\S]*?(<\\/${t}>)`,`i`).exec(e.code);if(!i)return;let[,a,o,c,l]=i,u=(o+c).replace(/\bsrc=["'][^"']+["']\s*/g,``);e.replace(i.index,i.index+i[0].length,new s.ConcatSource(`${a}${u}\n`,r?new s.OriginalSource(n,r):n,`\n${l}`))}function f(e,t,n,r){if(n===r)return new s.RawSource(``);let i=new s.ReplaceSource(e);return n>0&&i.replace(0,n-1,``),r<t&&i.replace(r,t-1,``),i}function p(e,t,n,r){return i(e,t,n,r)}function m(e){return r(e).map(w)}function h(e){return o(e)}function g(e,t){return a(e,t.startsWith(`data-v-`)?t:`data-v-${t}`)}function _(e){return t(e).map(T)}function v(e){let t=n(e);return{scriptSrc:t.scriptSrc??null,templateSrc:t.templateSrc??null}}function y(e,t,n){let r=new u(e,null);return t!==null&&d(r,`script`,t),n!==null&&d(r,`template`,n),r.code}function b(e,t,n){if(!t)return n;let r=e.replace(/\\/g,`/`);return(Array.isArray(t)?t:[t]).some(t=>typeof t==`string`?r.includes(t)||e.includes(t):x(t,r))}function x(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}Object.freeze({img:[`src`],video:[`src`,`poster`],source:[`src`],image:[`xlink:href`,`href`],use:[`xlink:href`,`href`]});function S(t,n){return n===!1?[]:e(t,C(n))}function C(e){if(!(e==null||e===!0))return Object.entries(e).map(([e,t])=>({tag:e,attrs:t}))}function w(e){return{content:e.content,src:e.src??null,lang:e.lang??null,scoped:e.scoped,module:e.module?e.moduleName??!0:!1,index:e.index}}function T(e){let t={};for(let n of e.attrs)t[n.name]=n.value??!0;return{type:e.blockType,content:e.content,src:e.src??null,attrs:t,index:e.index}}export{m as a,b as c,w as d,u as f,v as i,h as l,l as m,S as n,p as o,d as p,_ as r,y as s,g as t,T as u};