@vizejs/vite-plugin-musea 0.501.0 → 0.503.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.
Files changed (33) hide show
  1. package/dist/a11y/index.d.mts +1 -1
  2. package/dist/a11y/index.mjs +1 -1
  3. package/dist/{a11y-DuFu75hl.mjs → a11y-CYZszxM7.mjs} +23 -17
  4. package/dist/a11y-CYZszxM7.mjs.map +1 -0
  5. package/dist/{utils-ChmPv0qc.mjs → browser-launch-L43ulIaZ.mjs} +49 -2
  6. package/dist/browser-launch-L43ulIaZ.mjs.map +1 -0
  7. package/dist/cli/index.d.mts +4 -1
  8. package/dist/cli/index.d.mts.map +1 -1
  9. package/dist/cli/index.mjs +45 -7
  10. package/dist/cli/index.mjs.map +1 -1
  11. package/dist/{index-DENP7L3t.d.mts → index-CYEDgY-M.d.mts} +7 -6
  12. package/dist/index-CYEDgY-M.d.mts.map +1 -0
  13. package/dist/{index-ZFHsOEPD.d.mts → index-CbChC9Bf.d.mts} +20 -2
  14. package/dist/index-CbChC9Bf.d.mts.map +1 -0
  15. package/dist/index.d.mts +3 -3
  16. package/dist/index.d.mts.map +1 -1
  17. package/dist/index.mjs +72 -63
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{options-B-sFFEcK.mjs → options-BwF3nGEB.mjs} +241 -121
  20. package/dist/options-BwF3nGEB.mjs.map +1 -0
  21. package/dist/{vrt-dFU3k2J6.mjs → vrt-C7wgh92N.mjs} +15 -45
  22. package/dist/vrt-C7wgh92N.mjs.map +1 -0
  23. package/dist/{vrt-nAWyjDmd.d.mts → vrt-DNoUalLH.d.mts} +2 -2
  24. package/dist/{vrt-nAWyjDmd.d.mts.map → vrt-DNoUalLH.d.mts.map} +1 -1
  25. package/dist/vrt.d.mts +1 -1
  26. package/dist/vrt.mjs +2 -1
  27. package/package.json +4 -4
  28. package/dist/a11y-DuFu75hl.mjs.map +0 -1
  29. package/dist/index-DENP7L3t.d.mts.map +0 -1
  30. package/dist/index-ZFHsOEPD.d.mts.map +0 -1
  31. package/dist/options-B-sFFEcK.mjs.map +0 -1
  32. package/dist/utils-ChmPv0qc.mjs.map +0 -1
  33. package/dist/vrt-dFU3k2J6.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as MuseaGlobals, C as PaletteApiResponse, D as ViewportConfig, E as ComparisonConfig, M as MuseaToolbarOption, O as VrtOptions, S as AnalysisApiResponse, T as CiConfig, _ as StyleDictionaryOutput, a as MuseaOptions, b as A11yOptions, c as MuseaThemeColors, d as MuseaTokenPreviewKind, f as MuseaTokenPreviewRule, g as StyleDictionaryConfig, h as DesignToken, i as CsfOutput, j as MuseaToolbarControl, k as MuseaGlobalValue, l as MuseaVrtOptions, m as resolveTokenPreview, n as ArtMetadata, o as MuseaPreviewContext, p as ResolvedTokenPreview, r as ArtVariant, s as MuseaTheme, t as ArtFileInfo, u as MuseaTokenPreviewConfig, v as TokenCategory, w as CaptureConfig, x as A11yResult, y as parseTokens } from "./index-ZFHsOEPD.mjs";
2
- import { c as VrtSummary, n as generateVrtReport, r as MuseaVrtRunner, s as VrtResult, t as generateVrtJsonReport } from "./vrt-nAWyjDmd.mjs";
3
- import { n as MuseaA11yRunner, t as A11ySummary } from "./index-DENP7L3t.mjs";
1
+ import { A as MuseaGlobals, C as PaletteApiResponse, D as ViewportConfig, E as ComparisonConfig, M as MuseaToolbarOption, O as VrtOptions, S as AnalysisApiResponse, T as CiConfig, _ as StyleDictionaryOutput, a as MuseaOptions, b as A11yOptions, c as MuseaThemeColors, d as MuseaTokenPreviewKind, f as MuseaTokenPreviewRule, g as StyleDictionaryConfig, h as DesignToken, i as CsfOutput, j as MuseaToolbarControl, k as MuseaGlobalValue, l as MuseaVrtOptions, m as resolveTokenPreview, n as ArtMetadata, o as MuseaPreviewContext, p as ResolvedTokenPreview, r as ArtVariant, s as MuseaTheme, t as ArtFileInfo, u as MuseaTokenPreviewConfig, v as TokenCategory, w as CaptureConfig, x as A11yResult, y as parseTokens } from "./index-CbChC9Bf.mjs";
2
+ import { c as VrtSummary, n as generateVrtReport, r as MuseaVrtRunner, s as VrtResult, t as generateVrtJsonReport } from "./vrt-DNoUalLH.mjs";
3
+ import { n as MuseaA11yRunner, t as A11ySummary } from "./index-CYEDgY-M.mjs";
4
4
  import { AutogenOptions, AutogenOutput, GeneratedVariant, PropDefinition, generateArtFile, writeArtFile } from "./autogen/index.mjs";
5
5
  import { Plugin } from "vite";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin/index.ts","../src/tokens/usage.ts","../src/tokens/resolver.ts","../src/tokens/generator.ts"],"mappings":";;;;;;;iBA4CgB,KAAA,CAAM,OAAA,GAAS,YAAA,GAAoB,MAAM;;;AAAA;;;AAAA,iBCJzC,cAAA,CACd,QAAA,EAAU,GAAA;EAAc,IAAA;EAAc,QAAA;IAAY,KAAA;IAAe,QAAA;EAAA;AAAA,IACjE,QAAA,EAAU,MAAA,SAAe,WAAA,IACxB,aAAA;;;;;;UCtBc,eAAA;EACf,IAAA;EACA,WAAA;EACA,QAAA;AAAA;;;;UAMe,eAAA;EACf,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,EAAS,eAAe;AAAA;;;;KAMd,aAAA,GAAgB,MAAM,SAAS,eAAA;;;;iBAqB3B,aAAA,CAAc,UAAA,EAAY,aAAA,KAAkB,MAAA,SAAe,WAAA;;;;iBAO3D,iBAAA,CACd,UAAA,EAAY,aAAA,IACZ,SAAA,EAAW,MAAA,SAAe,WAAA;;;AF1B5B;;;AAAA,iBGLgB,kBAAA,CAAmB,UAA2B,EAAf,aAAa;;;;iBAgI5C,sBAAA,CAAuB,UAA2B,EAAf,aAAa;AH3HP;;;;AAAA,iBGmInC,sBAAA,CACpB,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,qBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin/index.ts","../src/tokens/usage.ts","../src/tokens/resolver.ts","../src/tokens/generator.ts"],"mappings":";;;;;;;iBA+CgB,KAAA,CAAM,OAAA,GAAS,YAAA,GAAoB,MAAM;;;AAAA;;;AAAA,iBCPzC,cAAA,CACd,QAAA,EAAU,GAAA;EAAc,IAAA;EAAc,QAAA;IAAY,KAAA;IAAe,QAAA;EAAA;AAAA,IACjE,QAAA,EAAU,MAAA,SAAe,WAAA,IACxB,aAAA;;;;;;UCtBc,eAAA;EACf,IAAA;EACA,WAAA;EACA,QAAA;AAAA;;;;UAMe,eAAA;EACf,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,EAAS,eAAe;AAAA;;;;KAMd,aAAA,GAAgB,MAAM,SAAS,eAAA;;;;iBAqB3B,aAAA,CAAc,UAAA,EAAY,aAAA,KAAkB,MAAA,SAAe,WAAA;;;;iBAO3D,iBAAA,CACd,UAAA,EAAY,aAAA,IACZ,SAAA,EAAW,MAAA,SAAe,WAAA;;;AFvB5B;;;AAAA,iBGRgB,kBAAA,CAAmB,UAA2B,EAAf,aAAa;;;;iBAgI5C,sBAAA,CAAuB,UAA2B,EAAf,aAAa;AHxHP;;;;AAAA,iBGgInC,sBAAA,CACpB,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,qBAAA"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { C as resolveUrlPathInside, E as loadNative, S as resolveTrustedSourcePath, _ as assertVueSourcePath, a as scanArtFiles, b as resolveInside, c as buildThemeConfig, d as createDevSessionToken, f as parseJsonBody, h as assertArtVueSourcePath, i as resolveScanRoots, m as validateDevApiRequest, n as generateStorybookFiles, o as shouldProcess, p as serializeScriptValue, r as matchGlob, t as escapeHtml, u as collectRequestBody, v as decodeUrlComponent, w as HttpError } from "./utils-BloA9YP9.mjs";
2
- import { A as scanTokenUsage, C as handleTokensUsage, D as processStyleDictionary, E as generateTokensMarkdown, F as expandSelfTag, I as resolveArtComponent, L as variantComponentNames, M as generateArtModule, N as parseScriptSetupForArt, O as buildTokenMap, P as rewriteRelativeImportStatement, S as handleTokensUpdate, T as generateTokensHtml, _ as handleArtSource, a as attachArtReportOwner, b as handleTokensDelete, c as rewriteDevGalleryAsset, d as createStaticGalleryPayload, f as joinUrlPath, g as handleArtDocs, h as handleArtAnalysis, i as assertArtReportOwnership, j as parseTokens, k as resolveReferences, l as rewriteGalleryBase, m as sortedArts, o as resolveArtReportTarget, p as staticPreviewId, r as processMuseaArtFile, s as publicBasePathFromViteBase, t as attachMuseaOptions, u as rewriteGalleryTextAssetBase, v as handleArtPalette, w as resolveTokenPreview, x as handleTokensGet, y as handleTokensCreate } from "./options-B-sFFEcK.mjs";
2
+ import { A as buildTokenMap, B as expandSelfTag, C as handleTokensGet, D as generateTokensHtml, E as resolveTokenPreview, F as parseScriptSetupForArt, H as variantComponentNames, I as rewriteRelativeImportStatement, L as loadArtStyle, M as scanTokenUsage, N as parseTokens, O as generateTokensMarkdown, P as generateArtModule, R as parseArtStyleRequest, S as handleTokensDelete, T as handleTokensUsage, V as resolveArtComponent, _ as handleArtAnalysis, a as attachArtReportOwner, b as handleArtPalette, c as rewriteDevGalleryAsset, d as createStaticGalleryPayload, f as joinUrlPath, g as sortedArts, h as staticPreviewId, i as assertArtReportOwnership, j as resolveReferences, k as processStyleDictionary, l as rewriteGalleryBase, m as resolveStaticIdentityRoot, o as resolveArtReportTarget, p as resolveStaticArtIdentity, r as processMuseaArtFile, s as publicBasePathFromViteBase, t as attachMuseaOptions, u as rewriteGalleryTextAssetBase, v as handleArtDocs, w as handleTokensUpdate, x as handleTokensCreate, y as handleArtSource, z as transformPreprocessedArtStyle } from "./options-BwF3nGEB.mjs";
3
3
  import { a as generateGalleryGlobalsScript, i as generateDevGlobalsScript, n as generateGalleryScript, r as generateGalleryModule, t as generateGalleryBody } from "./template-CpNUvZPp.mjs";
4
- import { i as MuseaVrtRunner, n as generateVrtJsonReport, r as generateVrtReport } from "./vrt-dFU3k2J6.mjs";
5
- import { t as MuseaA11yRunner } from "./a11y-DuFu75hl.mjs";
4
+ import { i as MuseaVrtRunner, n as generateVrtJsonReport, r as generateVrtReport } from "./vrt-C7wgh92N.mjs";
5
+ import { t as MuseaA11yRunner } from "./a11y-CYZszxM7.mjs";
6
6
  import { n as writeArtFile, t as generateArtFile } from "./autogen-B-N0cJbZ.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import fs, { existsSync } from "node:fs";
@@ -539,8 +539,6 @@ function generatePreviewModule(art, variantComponentName, variantName, cssImport
539
539
  const globals = toolbar.length > 0;
540
540
  const setupCall = previewSetup ? `await __museaPreviewSetup(app${globals ? ", { globals: __museaGlobals }" : ""});` : "";
541
541
  const actionEvents = JSON.stringify(art.metadata.actionEvents ?? []);
542
- const artStyleId = `musea-art-styles-${art.path.replace(/[^\w-]+/g, "_")}`;
543
- const artStyleIdLiteral = JSON.stringify(artStyleId);
544
542
  const legacyVue = isLegacyVueVersion(vueVersion);
545
543
  const vueImport = legacyVue ? `import Vue, { reactive, shallowRef${globals ? ", ref as __museaCreateGlobalsRef" : ""} } from 'vue';` : `import { createApp, reactive, shallowRef, h${globals ? ", ref as __museaCreateGlobalsRef" : ""} } from 'vue';`;
546
544
  const destroyCurrentApp = legacyVue ? "currentApp.$destroy();" : "currentApp.unmount();";
@@ -563,24 +561,6 @@ let currentApp = null;
563
561
  const propsOverride = shallowRef({});
564
562
  const slotsOverride = reactive({ default: '' });
565
563
 
566
- function ensureArtStyles(styles) {
567
- const styleId = ${artStyleIdLiteral};
568
- const existing = document.getElementById(styleId);
569
-
570
- if (!Array.isArray(styles) || styles.length === 0) {
571
- existing?.remove();
572
- return;
573
- }
574
-
575
- const tag = existing ?? document.createElement('style');
576
- tag.id = styleId;
577
- tag.textContent = styles.join('\\n\\n');
578
-
579
- if (!existing) {
580
- document.head.appendChild(tag);
581
- }
582
- }
583
-
584
564
  function renderError(title, error) {
585
565
  container.textContent = '';
586
566
  const root = document.createElement('div');
@@ -630,7 +610,6 @@ async function mount() {
630
610
 
631
611
  // Create and mount the app
632
612
  ${mountInitialApp}
633
- ensureArtStyles(artModule.__styles__);
634
613
  ${setupCall}
635
614
  container.innerHTML = '';
636
615
  container.className = 'musea-variant';
@@ -663,7 +642,6 @@ async function remountWithProps(Component) {
663
642
  ${destroyCurrentApp}
664
643
  }
665
644
  ${remountApp}
666
- ensureArtStyles(artModule.__styles__);
667
645
  ${setupCall}
668
646
  container.innerHTML = '';
669
647
  ${mountCurrentApp}
@@ -723,8 +701,6 @@ function generatePreviewModuleWithProps(art, variantComponentName, variantName,
723
701
  const globals = toolbar.length > 0;
724
702
  const setupCall = previewSetup ? `await __museaPreviewSetup(app${globals ? ", { globals: __museaGlobals }" : ""});` : "";
725
703
  const actionEvents = JSON.stringify(art.metadata.actionEvents ?? []);
726
- const artStyleId = `musea-art-styles-${art.path.replace(/[^\w-]+/g, "_")}`;
727
- const artStyleIdLiteral = JSON.stringify(artStyleId);
728
704
  const legacyVue = isLegacyVueVersion(vueVersion);
729
705
  const vueImport = legacyVue ? `import Vue${globals ? ", { ref as __museaCreateGlobalsRef }" : ""} from 'vue';` : `import { createApp, h${globals ? ", ref as __museaCreateGlobalsRef" : ""} } from 'vue';`;
730
706
  const wrappedComponent = legacyVue ? `const WrappedComponent = {
@@ -749,24 +725,6 @@ const propsOverride = JSON.parse(${JSON.stringify(propsJson)});
749
725
 
750
726
  ${MUSEA_ADDONS_INIT_CODE}${generatePreviewGlobals(toolbar)}
751
727
 
752
- function ensureArtStyles(styles) {
753
- const styleId = ${artStyleIdLiteral};
754
- const existing = document.getElementById(styleId);
755
-
756
- if (!Array.isArray(styles) || styles.length === 0) {
757
- existing?.remove();
758
- return;
759
- }
760
-
761
- const tag = existing ?? document.createElement('style');
762
- tag.id = styleId;
763
- tag.textContent = styles.join('\\n\\n');
764
-
765
- if (!existing) {
766
- document.head.appendChild(tag);
767
- }
768
- }
769
-
770
728
  function renderError(title, error) {
771
729
  container.textContent = '';
772
730
  const root = document.createElement('div');
@@ -794,7 +752,6 @@ async function mount() {
794
752
  ${wrappedComponent}
795
753
 
796
754
  ${appCreate}
797
- ensureArtStyles(artModule.__styles__);
798
755
  ${setupCall}
799
756
  container.innerHTML = '';
800
757
  container.className = 'musea-variant';
@@ -859,6 +816,15 @@ function resolveGallerySourceDir() {
859
816
  function toViteFsPath(filePath) {
860
817
  return encodeURI(`/@fs${filePath.split(path.sep).join("/")}`);
861
818
  }
819
+ function ignorePackedGalleryAssetTransforms(html, basePath) {
820
+ const assetPrefix = `${basePath.replace(/\/+$/, "")}/assets/`;
821
+ return html.replace(/<script\b[^>]*>/giu, (tag) => {
822
+ const type = /\btype\s*=\s*(["'])module\1/iu.exec(tag);
823
+ const src = /\bsrc\s*=\s*(["'])([^"']+)\1/iu.exec(tag);
824
+ if (!type || !src || !src[2].startsWith(assetPrefix) || /\bvite-ignore\b/iu.test(tag)) return tag;
825
+ return tag.replace(/^<script\b/iu, "<script vite-ignore");
826
+ });
827
+ }
862
828
  async function tryLoadSourceGalleryHtml(devServer, url, basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar) {
863
829
  const gallerySourceDir = resolveGallerySourceDir();
864
830
  const indexHtmlPath = path.join(gallerySourceDir, "index.html");
@@ -908,7 +874,7 @@ function registerMiddleware(devServer, ctx) {
908
874
  let html = rewriteGalleryBase(await fs.promises.readFile(indexHtmlPath, "utf-8"), basePath);
909
875
  html = html.replace("</head>", `<script>${generateDevGlobalsScript(basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar)}<\/script></head>`);
910
876
  res.setHeader("Content-Type", "text/html");
911
- res.end(await devServer.transformIndexHtml(url, html));
877
+ res.end(await devServer.transformIndexHtml(url, ignorePackedGalleryAssetTransforms(html, basePath)));
912
878
  return;
913
879
  } catch {
914
880
  const sourceHtml = await tryLoadSourceGalleryHtml(devServer, url, basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar);
@@ -1461,6 +1427,8 @@ function decodeVariantName(encoded) {
1461
1427
  function createResolveId(state) {
1462
1428
  return function resolveId(id) {
1463
1429
  const root = state.getConfigRoot();
1430
+ const styleRequest = parseArtStyleRequest(id);
1431
+ if (styleRequest && state.artFiles.has(styleRequest.filePath)) return id.startsWith("\0") ? id : `\0${id}`;
1464
1432
  if (id === "\0musea-gallery") return VIRTUAL_GALLERY;
1465
1433
  if (id === "\0musea-manifest") return VIRTUAL_MANIFEST;
1466
1434
  if (id.startsWith("virtual:musea-preview:")) return "\0musea-preview:" + id.slice(22);
@@ -1483,6 +1451,8 @@ function createResolveId(state) {
1483
1451
  }
1484
1452
  function createLoad(state) {
1485
1453
  return function load(id) {
1454
+ const styleRequest = parseArtStyleRequest(id);
1455
+ if (styleRequest) return loadArtStyle(state.artFiles.get(styleRequest.filePath), styleRequest);
1486
1456
  if (id === "\0musea-gallery") return generateGalleryModule(state.basePath);
1487
1457
  if (id === "\0musea-manifest") return generateManifestModule(state.artFiles);
1488
1458
  if (id.startsWith("\0musea-preview:")) {
@@ -1574,7 +1544,11 @@ function artHotUpdateModules(state, file, sourceModules) {
1574
1544
  `\0musea-art:${file}?musea-virtual`,
1575
1545
  `\0musea-shared:${file}?musea-virtual`
1576
1546
  ]);
1577
- const derivedPrefixes = [`\0musea-variant:${file}:`, `\0musea-preview:${file}:`];
1547
+ const derivedPrefixes = [
1548
+ `\0musea-variant:${file}:`,
1549
+ `\0musea-preview:${file}:`,
1550
+ `\0${file}.__musea_style_`
1551
+ ];
1578
1552
  for (const [id, module] of graph.idToModuleMap) if (exactIds.has(id) || derivedPrefixes.some((prefix) => id.startsWith(prefix))) modules.add(module);
1579
1553
  return [...modules];
1580
1554
  }
@@ -1777,11 +1751,11 @@ function museaStaticBuildConfig(input) {
1777
1751
  function resolveStaticRuntimeId(id) {
1778
1752
  return id === "virtual:musea-static-runtime" ? RESOLVED_STATIC_RUNTIME : null;
1779
1753
  }
1780
- function loadStaticRuntimeModule(id, artFiles) {
1754
+ function loadStaticRuntimeModule(id, artFiles, identityRoot) {
1781
1755
  if (id !== RESOLVED_STATIC_RUNTIME) return null;
1782
1756
  return `
1783
1757
  const loaders = { ${Array.from(artFiles.values()).flatMap((art) => art.variants.map((variant) => {
1784
- const key = staticPreviewId(art.path, variant.name);
1758
+ const key = staticPreviewId(identityRoot ? resolveStaticArtIdentity(art.path, identityRoot) : art.path, variant.name);
1785
1759
  const moduleId = previewModuleId(art.path, variant.name);
1786
1760
  return `${JSON.stringify(key)}: () => import(${JSON.stringify(moduleId)})`;
1787
1761
  })).join(",\n")} };
@@ -1819,7 +1793,7 @@ async function emitStaticGallery(emitFile, bundle, ctx) {
1819
1793
  source: JSON.stringify(publicPayload.arts, null, 2)
1820
1794
  });
1821
1795
  await emitAxeVendor(emitFile, staticRoot);
1822
- emitPreviewHtml(emitFile, staticRoot, runtimeFileName, publicBasePath, ctx.artFiles);
1796
+ emitPreviewHtml(emitFile, staticRoot, runtimeFileName, publicBasePath, new Map(publicPayload.arts.map((art) => [art.path, art])));
1823
1797
  emitRootRedirect(emitFile, staticRoot, publicBasePath);
1824
1798
  }
1825
1799
  function findRuntimeFileName(bundle) {
@@ -1925,6 +1899,18 @@ async function resolveMuseaSharedConfig(resolvedConfig, loadConfigFile = loadCon
1925
1899
  }
1926
1900
  //#endregion
1927
1901
  //#region src/plugin/virtual-transform.ts
1902
+ const VIRTUAL_ART_PREFIX = "\0musea-art:";
1903
+ const VIRTUAL_INLINE_ART_PREFIX = "\0musea:";
1904
+ /**
1905
+ * Give Vite's TypeScript transformer a filename beside the authored art file.
1906
+ * OXC uses this filename to select a tsconfig, so a synthetic filename under
1907
+ * the Vite root can accidentally select an unrelated ancestor config.
1908
+ */
1909
+ function museaVirtualTransformId(id) {
1910
+ const prefix = id.startsWith(VIRTUAL_ART_PREFIX) ? VIRTUAL_ART_PREFIX : id.startsWith(VIRTUAL_INLINE_ART_PREFIX) ? VIRTUAL_INLINE_ART_PREFIX : null;
1911
+ if (!prefix) return null;
1912
+ return `${id.slice(prefix.length).replace(/\?musea-virtual$/, "")}.ts`;
1913
+ }
1928
1914
  function createMuseaVirtualTransformer(viteApi) {
1929
1915
  return async (code, id, sourcemap) => {
1930
1916
  if (typeof viteApi.transformWithOxc === "function") return viteApi.transformWithOxc(code, id, {
@@ -1998,6 +1984,22 @@ async function registerSourceGalleryDependencies(config) {
1998
1984
  optimizer.entries = [...new Set([...typeof entries === "string" ? [entries] : entries, globPath(gallery)])];
1999
1985
  }
2000
1986
  //#endregion
1987
+ //#region src/plugin/gallery-url.ts
1988
+ function resolveMuseaGalleryUrls(resolvedUrls, fallback, basePath) {
1989
+ const origins = [...resolvedUrls?.local ?? [], ...resolvedUrls?.network ?? []];
1990
+ if (origins.length === 0) {
1991
+ const host = ["::", "0.0.0.0"].includes(fallback.address) ? "localhost" : fallback.address === "::1" ? "[::1]" : fallback.address;
1992
+ origins.push(`${fallback.protocol}://${host}:${fallback.port}/`);
1993
+ }
1994
+ return [...new Set(origins)].map((origin) => {
1995
+ const url = new URL(origin);
1996
+ url.pathname = basePath;
1997
+ url.search = "";
1998
+ url.hash = "";
1999
+ return url.href;
2000
+ });
2001
+ }
2002
+ //#endregion
2001
2003
  //#region src/plugin/index.ts
2002
2004
  function musea(options = {}) {
2003
2005
  let include = options.include ?? ["**/*.art.vue"];
@@ -2149,15 +2151,12 @@ function musea(options = {}) {
2149
2151
  const address = devServer.httpServer?.address();
2150
2152
  if (address && typeof address === "object") {
2151
2153
  const protocol = devServer.config.server.https ? "https" : "http";
2152
- const rawHost = address.address;
2153
- const url = `${protocol}://${[
2154
- "::",
2155
- "::1",
2156
- "0.0.0.0",
2157
- "127.0.0.1"
2158
- ].includes(rawHost) ? "localhost" : rawHost}:${address.port}${basePath}`;
2159
2154
  console.log();
2160
- console.log(` \x1b[36m➜\x1b[0m \x1b[1mMusea Gallery:\x1b[0m \x1b[36m${url}\x1b[0m`);
2155
+ for (const url of resolveMuseaGalleryUrls(devServer.resolvedUrls, {
2156
+ protocol,
2157
+ address: address.address,
2158
+ port: address.port
2159
+ }, basePath)) console.log(` \x1b[36m➜\x1b[0m \x1b[1mMusea Gallery:\x1b[0m \x1b[36m${url}\x1b[0m`);
2161
2160
  }
2162
2161
  });
2163
2162
  };
@@ -2175,7 +2174,7 @@ function musea(options = {}) {
2175
2174
  return resolveStaticRuntimeId(id) ?? virtualResolveId(id);
2176
2175
  },
2177
2176
  load(id) {
2178
- return loadStaticRuntimeModule(id, artFiles) ?? virtualLoad(id);
2177
+ return loadStaticRuntimeModule(id, artFiles, staticBuildEnabled ? resolveStaticIdentityRoot(config.root, artFiles.keys(), resolveProjectRoot(projectRootOption, config.root)) : void 0) ?? virtualLoad(id);
2179
2178
  },
2180
2179
  async generateBundle(_options, bundle) {
2181
2180
  if (!staticBuildEnabled) return;
@@ -2197,8 +2196,9 @@ function musea(options = {}) {
2197
2196
  async transform(code, id) {
2198
2197
  if (!id.includes("?musea-virtual")) return null;
2199
2198
  if (!id.includes("musea-art:") && !id.includes("\0musea:")) return null;
2200
- const safeId = id.replaceAll("\0", "").replace(/[^\w./-]+/g, "_").replace(/_+/g, "_");
2201
- return transformMuseaVirtualModule(code, path.join(config.root, `.musea-${safeId}.ts`), config.command === "serve");
2199
+ const loaderId = museaVirtualTransformId(id);
2200
+ if (!loaderId) return null;
2201
+ return transformMuseaVirtualModule(code, loaderId, config.command === "serve");
2202
2202
  },
2203
2203
  handleHotUpdate: createHandleHotUpdate(virtualState)
2204
2204
  };
@@ -2214,7 +2214,16 @@ function musea(options = {}) {
2214
2214
  });
2215
2215
  if (info) artFiles.set(filePath, info);
2216
2216
  }
2217
- return [attachMuseaOptions(mainPlugin, options)];
2217
+ return [attachMuseaOptions(mainPlugin, options), {
2218
+ name: "vite-plugin-musea:style-post-transform",
2219
+ transform(code, id) {
2220
+ const transformed = transformPreprocessedArtStyle(code, id);
2221
+ return transformed === null ? null : {
2222
+ code: transformed,
2223
+ map: null
2224
+ };
2225
+ }
2226
+ }];
2218
2227
  }
2219
2228
  function resolveProjectRoot(projectRoot, viteRoot) {
2220
2229
  if (!projectRoot) return void 0;