@vizejs/vite-plugin-musea 0.500.0 → 0.502.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/a11y/index.mjs +1 -1
- package/dist/{a11y-DuFu75hl.mjs → a11y-CYZszxM7.mjs} +23 -17
- package/dist/a11y-CYZszxM7.mjs.map +1 -0
- package/dist/{utils-ChmPv0qc.mjs → browser-launch-L43ulIaZ.mjs} +49 -2
- package/dist/browser-launch-L43ulIaZ.mjs.map +1 -0
- package/dist/cli/index.d.mts +2 -1
- package/dist/cli/index.d.mts.map +1 -1
- package/dist/cli/index.mjs +28 -7
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{index-DENP7L3t.d.mts → index-BXI8gTfW.d.mts} +7 -6
- package/dist/index-BXI8gTfW.d.mts.map +1 -0
- package/dist/{index-ZFHsOEPD.d.mts → index-CPq3wpG5.d.mts} +5 -1
- package/dist/index-CPq3wpG5.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +49 -14
- package/dist/index.mjs.map +1 -1
- package/dist/{options-B-sFFEcK.mjs → options-BRid4Hkx.mjs} +2 -2
- package/dist/{options-B-sFFEcK.mjs.map → options-BRid4Hkx.mjs.map} +1 -1
- package/dist/{vrt-nAWyjDmd.d.mts → vrt-CLASQfpd.d.mts} +2 -2
- package/dist/{vrt-nAWyjDmd.d.mts.map → vrt-CLASQfpd.d.mts.map} +1 -1
- package/dist/{vrt-dFU3k2J6.mjs → vrt-DdWm07iR.mjs} +11 -43
- package/dist/vrt-DdWm07iR.mjs.map +1 -0
- package/dist/vrt.d.mts +1 -1
- package/dist/vrt.mjs +2 -1
- package/package.json +4 -4
- package/dist/a11y-DuFu75hl.mjs.map +0 -1
- package/dist/index-DENP7L3t.d.mts.map +0 -1
- package/dist/index-ZFHsOEPD.d.mts.map +0 -1
- package/dist/utils-ChmPv0qc.mjs.map +0 -1
- 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-
|
|
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-CPq3wpG5.mjs";
|
|
2
|
+
import { c as VrtSummary, n as generateVrtReport, r as MuseaVrtRunner, s as VrtResult, t as generateVrtJsonReport } from "./vrt-CLASQfpd.mjs";
|
|
3
|
+
import { n as MuseaA11yRunner, t as A11ySummary } from "./index-BXI8gTfW.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":";;;;;;;iBA6CgB,KAAA,CAAM,OAAA,GAAS,YAAA,GAAoB,MAAM;;;AAAA;;;AAAA,iBCLzC,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;;;AFzB5B;;;AAAA,iBGNgB,kBAAA,CAAmB,UAA2B,EAAf,aAAa;;;;iBAgI5C,sBAAA,CAAuB,UAA2B,EAAf,aAAa;AH1HP;;;;AAAA,iBGkInC,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-
|
|
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-BRid4Hkx.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-
|
|
5
|
-
import { t as MuseaA11yRunner } from "./a11y-
|
|
4
|
+
import { i as MuseaVrtRunner, n as generateVrtJsonReport, r as generateVrtReport } from "./vrt-DdWm07iR.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";
|
|
@@ -859,6 +859,15 @@ function resolveGallerySourceDir() {
|
|
|
859
859
|
function toViteFsPath(filePath) {
|
|
860
860
|
return encodeURI(`/@fs${filePath.split(path.sep).join("/")}`);
|
|
861
861
|
}
|
|
862
|
+
function ignorePackedGalleryAssetTransforms(html, basePath) {
|
|
863
|
+
const assetPrefix = `${basePath.replace(/\/+$/, "")}/assets/`;
|
|
864
|
+
return html.replace(/<script\b[^>]*>/giu, (tag) => {
|
|
865
|
+
const type = /\btype\s*=\s*(["'])module\1/iu.exec(tag);
|
|
866
|
+
const src = /\bsrc\s*=\s*(["'])([^"']+)\1/iu.exec(tag);
|
|
867
|
+
if (!type || !src || !src[2].startsWith(assetPrefix) || /\bvite-ignore\b/iu.test(tag)) return tag;
|
|
868
|
+
return tag.replace(/^<script\b/iu, "<script vite-ignore");
|
|
869
|
+
});
|
|
870
|
+
}
|
|
862
871
|
async function tryLoadSourceGalleryHtml(devServer, url, basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar) {
|
|
863
872
|
const gallerySourceDir = resolveGallerySourceDir();
|
|
864
873
|
const indexHtmlPath = path.join(gallerySourceDir, "index.html");
|
|
@@ -908,7 +917,7 @@ function registerMiddleware(devServer, ctx) {
|
|
|
908
917
|
let html = rewriteGalleryBase(await fs.promises.readFile(indexHtmlPath, "utf-8"), basePath);
|
|
909
918
|
html = html.replace("</head>", `<script>${generateDevGlobalsScript(basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar)}<\/script></head>`);
|
|
910
919
|
res.setHeader("Content-Type", "text/html");
|
|
911
|
-
res.end(await devServer.transformIndexHtml(url, html));
|
|
920
|
+
res.end(await devServer.transformIndexHtml(url, ignorePackedGalleryAssetTransforms(html, basePath)));
|
|
912
921
|
return;
|
|
913
922
|
} catch {
|
|
914
923
|
const sourceHtml = await tryLoadSourceGalleryHtml(devServer, url, basePath, devSessionToken, themeConfig, tokenPreviewConfig, toolbar);
|
|
@@ -1925,6 +1934,18 @@ async function resolveMuseaSharedConfig(resolvedConfig, loadConfigFile = loadCon
|
|
|
1925
1934
|
}
|
|
1926
1935
|
//#endregion
|
|
1927
1936
|
//#region src/plugin/virtual-transform.ts
|
|
1937
|
+
const VIRTUAL_ART_PREFIX = "\0musea-art:";
|
|
1938
|
+
const VIRTUAL_INLINE_ART_PREFIX = "\0musea:";
|
|
1939
|
+
/**
|
|
1940
|
+
* Give Vite's TypeScript transformer a filename beside the authored art file.
|
|
1941
|
+
* OXC uses this filename to select a tsconfig, so a synthetic filename under
|
|
1942
|
+
* the Vite root can accidentally select an unrelated ancestor config.
|
|
1943
|
+
*/
|
|
1944
|
+
function museaVirtualTransformId(id) {
|
|
1945
|
+
const prefix = id.startsWith(VIRTUAL_ART_PREFIX) ? VIRTUAL_ART_PREFIX : id.startsWith(VIRTUAL_INLINE_ART_PREFIX) ? VIRTUAL_INLINE_ART_PREFIX : null;
|
|
1946
|
+
if (!prefix) return null;
|
|
1947
|
+
return `${id.slice(prefix.length).replace(/\?musea-virtual$/, "")}.ts`;
|
|
1948
|
+
}
|
|
1928
1949
|
function createMuseaVirtualTransformer(viteApi) {
|
|
1929
1950
|
return async (code, id, sourcemap) => {
|
|
1930
1951
|
if (typeof viteApi.transformWithOxc === "function") return viteApi.transformWithOxc(code, id, {
|
|
@@ -1998,6 +2019,22 @@ async function registerSourceGalleryDependencies(config) {
|
|
|
1998
2019
|
optimizer.entries = [...new Set([...typeof entries === "string" ? [entries] : entries, globPath(gallery)])];
|
|
1999
2020
|
}
|
|
2000
2021
|
//#endregion
|
|
2022
|
+
//#region src/plugin/gallery-url.ts
|
|
2023
|
+
function resolveMuseaGalleryUrls(resolvedUrls, fallback, basePath) {
|
|
2024
|
+
const origins = [...resolvedUrls?.local ?? [], ...resolvedUrls?.network ?? []];
|
|
2025
|
+
if (origins.length === 0) {
|
|
2026
|
+
const host = ["::", "0.0.0.0"].includes(fallback.address) ? "localhost" : fallback.address === "::1" ? "[::1]" : fallback.address;
|
|
2027
|
+
origins.push(`${fallback.protocol}://${host}:${fallback.port}/`);
|
|
2028
|
+
}
|
|
2029
|
+
return [...new Set(origins)].map((origin) => {
|
|
2030
|
+
const url = new URL(origin);
|
|
2031
|
+
url.pathname = basePath;
|
|
2032
|
+
url.search = "";
|
|
2033
|
+
url.hash = "";
|
|
2034
|
+
return url.href;
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
//#endregion
|
|
2001
2038
|
//#region src/plugin/index.ts
|
|
2002
2039
|
function musea(options = {}) {
|
|
2003
2040
|
let include = options.include ?? ["**/*.art.vue"];
|
|
@@ -2149,15 +2186,12 @@ function musea(options = {}) {
|
|
|
2149
2186
|
const address = devServer.httpServer?.address();
|
|
2150
2187
|
if (address && typeof address === "object") {
|
|
2151
2188
|
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
2189
|
console.log();
|
|
2160
|
-
|
|
2190
|
+
for (const url of resolveMuseaGalleryUrls(devServer.resolvedUrls, {
|
|
2191
|
+
protocol,
|
|
2192
|
+
address: address.address,
|
|
2193
|
+
port: address.port
|
|
2194
|
+
}, basePath)) console.log(` \x1b[36m➜\x1b[0m \x1b[1mMusea Gallery:\x1b[0m \x1b[36m${url}\x1b[0m`);
|
|
2161
2195
|
}
|
|
2162
2196
|
});
|
|
2163
2197
|
};
|
|
@@ -2197,8 +2231,9 @@ function musea(options = {}) {
|
|
|
2197
2231
|
async transform(code, id) {
|
|
2198
2232
|
if (!id.includes("?musea-virtual")) return null;
|
|
2199
2233
|
if (!id.includes("musea-art:") && !id.includes("\0musea:")) return null;
|
|
2200
|
-
const
|
|
2201
|
-
|
|
2234
|
+
const loaderId = museaVirtualTransformId(id);
|
|
2235
|
+
if (!loaderId) return null;
|
|
2236
|
+
return transformMuseaVirtualModule(code, loaderId, config.command === "serve");
|
|
2202
2237
|
},
|
|
2203
2238
|
handleHotUpdate: createHandleHotUpdate(virtualState)
|
|
2204
2239
|
};
|