@vizejs/vite-plugin-musea 0.502.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.
- package/dist/a11y/index.d.mts +1 -1
- package/dist/cli/index.d.mts +3 -1
- package/dist/cli/index.d.mts.map +1 -1
- package/dist/cli/index.mjs +19 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{index-BXI8gTfW.d.mts → index-CYEDgY-M.d.mts} +3 -3
- package/dist/{index-BXI8gTfW.d.mts.map → index-CYEDgY-M.d.mts.map} +1 -1
- package/dist/{index-CPq3wpG5.d.mts → index-CbChC9Bf.d.mts} +16 -2
- package/dist/{index-CPq3wpG5.d.mts.map → index-CbChC9Bf.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +25 -51
- package/dist/index.mjs.map +1 -1
- package/dist/{options-BRid4Hkx.mjs → options-BwF3nGEB.mjs} +241 -121
- package/dist/options-BwF3nGEB.mjs.map +1 -0
- package/dist/{vrt-DdWm07iR.mjs → vrt-C7wgh92N.mjs} +5 -3
- package/dist/vrt-C7wgh92N.mjs.map +1 -0
- package/dist/{vrt-CLASQfpd.d.mts → vrt-DNoUalLH.d.mts} +2 -2
- package/dist/{vrt-CLASQfpd.d.mts.map → vrt-DNoUalLH.d.mts.map} +1 -1
- package/dist/vrt.d.mts +1 -1
- package/dist/vrt.mjs +1 -1
- package/package.json +4 -4
- package/dist/options-BRid4Hkx.mjs.map +0 -1
- package/dist/vrt-DdWm07iR.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-
|
|
2
|
-
import { c as VrtSummary, n as generateVrtReport, r as MuseaVrtRunner, s as VrtResult, t as generateVrtJsonReport } from "./vrt-
|
|
3
|
-
import { n as MuseaA11yRunner, t as A11ySummary } from "./index-
|
|
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
|
|
package/dist/index.d.mts.map
CHANGED
|
@@ -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":";;;;;;;
|
|
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,7 +1,7 @@
|
|
|
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
|
|
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-
|
|
4
|
+
import { i as MuseaVrtRunner, n as generateVrtJsonReport, r as generateVrtReport } from "./vrt-C7wgh92N.mjs";
|
|
5
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";
|
|
@@ -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';
|
|
@@ -1470,6 +1427,8 @@ function decodeVariantName(encoded) {
|
|
|
1470
1427
|
function createResolveId(state) {
|
|
1471
1428
|
return function resolveId(id) {
|
|
1472
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}`;
|
|
1473
1432
|
if (id === "\0musea-gallery") return VIRTUAL_GALLERY;
|
|
1474
1433
|
if (id === "\0musea-manifest") return VIRTUAL_MANIFEST;
|
|
1475
1434
|
if (id.startsWith("virtual:musea-preview:")) return "\0musea-preview:" + id.slice(22);
|
|
@@ -1492,6 +1451,8 @@ function createResolveId(state) {
|
|
|
1492
1451
|
}
|
|
1493
1452
|
function createLoad(state) {
|
|
1494
1453
|
return function load(id) {
|
|
1454
|
+
const styleRequest = parseArtStyleRequest(id);
|
|
1455
|
+
if (styleRequest) return loadArtStyle(state.artFiles.get(styleRequest.filePath), styleRequest);
|
|
1495
1456
|
if (id === "\0musea-gallery") return generateGalleryModule(state.basePath);
|
|
1496
1457
|
if (id === "\0musea-manifest") return generateManifestModule(state.artFiles);
|
|
1497
1458
|
if (id.startsWith("\0musea-preview:")) {
|
|
@@ -1583,7 +1544,11 @@ function artHotUpdateModules(state, file, sourceModules) {
|
|
|
1583
1544
|
`\0musea-art:${file}?musea-virtual`,
|
|
1584
1545
|
`\0musea-shared:${file}?musea-virtual`
|
|
1585
1546
|
]);
|
|
1586
|
-
const derivedPrefixes = [
|
|
1547
|
+
const derivedPrefixes = [
|
|
1548
|
+
`\0musea-variant:${file}:`,
|
|
1549
|
+
`\0musea-preview:${file}:`,
|
|
1550
|
+
`\0${file}.__musea_style_`
|
|
1551
|
+
];
|
|
1587
1552
|
for (const [id, module] of graph.idToModuleMap) if (exactIds.has(id) || derivedPrefixes.some((prefix) => id.startsWith(prefix))) modules.add(module);
|
|
1588
1553
|
return [...modules];
|
|
1589
1554
|
}
|
|
@@ -1786,11 +1751,11 @@ function museaStaticBuildConfig(input) {
|
|
|
1786
1751
|
function resolveStaticRuntimeId(id) {
|
|
1787
1752
|
return id === "virtual:musea-static-runtime" ? RESOLVED_STATIC_RUNTIME : null;
|
|
1788
1753
|
}
|
|
1789
|
-
function loadStaticRuntimeModule(id, artFiles) {
|
|
1754
|
+
function loadStaticRuntimeModule(id, artFiles, identityRoot) {
|
|
1790
1755
|
if (id !== RESOLVED_STATIC_RUNTIME) return null;
|
|
1791
1756
|
return `
|
|
1792
1757
|
const loaders = { ${Array.from(artFiles.values()).flatMap((art) => art.variants.map((variant) => {
|
|
1793
|
-
const key = staticPreviewId(art.path, variant.name);
|
|
1758
|
+
const key = staticPreviewId(identityRoot ? resolveStaticArtIdentity(art.path, identityRoot) : art.path, variant.name);
|
|
1794
1759
|
const moduleId = previewModuleId(art.path, variant.name);
|
|
1795
1760
|
return `${JSON.stringify(key)}: () => import(${JSON.stringify(moduleId)})`;
|
|
1796
1761
|
})).join(",\n")} };
|
|
@@ -1828,7 +1793,7 @@ async function emitStaticGallery(emitFile, bundle, ctx) {
|
|
|
1828
1793
|
source: JSON.stringify(publicPayload.arts, null, 2)
|
|
1829
1794
|
});
|
|
1830
1795
|
await emitAxeVendor(emitFile, staticRoot);
|
|
1831
|
-
emitPreviewHtml(emitFile, staticRoot, runtimeFileName, publicBasePath,
|
|
1796
|
+
emitPreviewHtml(emitFile, staticRoot, runtimeFileName, publicBasePath, new Map(publicPayload.arts.map((art) => [art.path, art])));
|
|
1832
1797
|
emitRootRedirect(emitFile, staticRoot, publicBasePath);
|
|
1833
1798
|
}
|
|
1834
1799
|
function findRuntimeFileName(bundle) {
|
|
@@ -2209,7 +2174,7 @@ function musea(options = {}) {
|
|
|
2209
2174
|
return resolveStaticRuntimeId(id) ?? virtualResolveId(id);
|
|
2210
2175
|
},
|
|
2211
2176
|
load(id) {
|
|
2212
|
-
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);
|
|
2213
2178
|
},
|
|
2214
2179
|
async generateBundle(_options, bundle) {
|
|
2215
2180
|
if (!staticBuildEnabled) return;
|
|
@@ -2249,7 +2214,16 @@ function musea(options = {}) {
|
|
|
2249
2214
|
});
|
|
2250
2215
|
if (info) artFiles.set(filePath, info);
|
|
2251
2216
|
}
|
|
2252
|
-
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
|
+
}];
|
|
2253
2227
|
}
|
|
2254
2228
|
function resolveProjectRoot(projectRoot, viteRoot) {
|
|
2255
2229
|
if (!projectRoot) return void 0;
|