@vizejs/vite-plugin-musea 0.442.0 → 0.454.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 (62) hide show
  1. package/README.md +4 -0
  2. package/dist/a11y/index.d.mts +1 -1
  3. package/dist/a11y/index.mjs +1 -1
  4. package/dist/{a11y-BU5kFNk-.mjs → a11y-DuFu75hl.mjs} +2 -2
  5. package/dist/{a11y-BU5kFNk-.mjs.map → a11y-DuFu75hl.mjs.map} +1 -1
  6. package/dist/cli/index.d.mts +3 -2
  7. package/dist/cli/index.d.mts.map +1 -1
  8. package/dist/cli/index.mjs +342 -62
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/gallery/assets/{MonacoEditor-DpMHG8uG.js → MonacoEditor-CwTBvTDB.js} +2 -2
  11. package/dist/gallery/assets/{cssMode-BhNXI_iH.js → cssMode-CelCYNbn.js} +1 -1
  12. package/dist/gallery/assets/{editor.api-pyN3BEOj.js → editor.api-a6jnMk-M.js} +1 -1
  13. package/dist/gallery/assets/{freemarker2-DDdeAW1l.js → freemarker2-DPAvE--z.js} +1 -1
  14. package/dist/gallery/assets/{handlebars-d_XLJufS.js → handlebars-BM0wnfAw.js} +1 -1
  15. package/dist/gallery/assets/{html-pNQuOCmG.js → html-BVxuhUk3.js} +1 -1
  16. package/dist/gallery/assets/{htmlMode-C9_7c2MZ.js → htmlMode-BMPJCjfA.js} +1 -1
  17. package/dist/gallery/assets/index-B0odPzN2.css +1 -0
  18. package/dist/gallery/assets/index-Dc3b2Q04.js +73 -0
  19. package/dist/gallery/assets/{javascript-V9iW4BoD.js → javascript-DNIAc6FS.js} +1 -1
  20. package/dist/gallery/assets/{jsonMode-B_jKD9Gd.js → jsonMode-DoEfywTC.js} +1 -1
  21. package/dist/gallery/assets/{liquid-B5bf9QtA.js → liquid-Bda2NkY3.js} +1 -1
  22. package/dist/gallery/assets/{lspLanguageFeatures-DF8jpKLy.js → lspLanguageFeatures-Bss0uLYW.js} +1 -1
  23. package/dist/gallery/assets/{mdx-B6b4WvnG.js → mdx-Cz_EcYUc.js} +1 -1
  24. package/dist/gallery/assets/{python-C_8hKql2.js → python-DumZpK8Y.js} +1 -1
  25. package/dist/gallery/assets/{razor-BK6Cp9pQ.js → razor-B35B929n.js} +1 -1
  26. package/dist/gallery/assets/{register-BcnlSPEw.js → register-CQcuOoyc.js} +2 -2
  27. package/dist/gallery/assets/{toggleHighContrast-D_Ox9lw9.js → toggleHighContrast-MeFDOtI7.js} +1 -1
  28. package/dist/gallery/assets/{tsMode-BODHbLZw.js → tsMode-DJXGbiLp.js} +1 -1
  29. package/dist/gallery/assets/{typescript-CdaOwWaG.js → typescript-CkqSzVk4.js} +1 -1
  30. package/dist/gallery/assets/{vs-mnsDk7Q8.js → vs-BnuldxuJ.js} +3 -3
  31. package/dist/gallery/assets/{workers-DYnbCsrm.js → workers-tF2102zJ.js} +1 -1
  32. package/dist/gallery/assets/{xml-ClcAB6Hf.js → xml-ntbvGSvU.js} +1 -1
  33. package/dist/gallery/assets/{yaml-mW5XIYQE.js → yaml-s2GvmKpO.js} +1 -1
  34. package/dist/gallery/index.html +2 -2
  35. package/dist/{gallery-CLe_4-XW.mjs → gallery-LgVvVp28.mjs} +2 -2
  36. package/dist/{gallery-CLe_4-XW.mjs.map → gallery-LgVvVp28.mjs.map} +1 -1
  37. package/dist/{index-BU4-FGUC.d.mts → index-DENP7L3t.d.mts} +2 -2
  38. package/dist/{index-BU4-FGUC.d.mts.map → index-DENP7L3t.d.mts.map} +1 -1
  39. package/dist/index.d.mts +2 -2
  40. package/dist/index.d.mts.map +1 -1
  41. package/dist/index.mjs +112 -435
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/{options-DCuB_Fpu.mjs → options-DNFbTB_5.mjs} +435 -37
  44. package/dist/options-DNFbTB_5.mjs.map +1 -0
  45. package/dist/{template-BgBSA10_.mjs → template-CpNUvZPp.mjs} +5 -3
  46. package/dist/template-CpNUvZPp.mjs.map +1 -0
  47. package/dist/{utils-DeMLVlNS.mjs → utils-BloA9YP9.mjs} +35 -29
  48. package/dist/utils-BloA9YP9.mjs.map +1 -0
  49. package/dist/{vrt-PuxpRuHa.mjs → vrt-dFU3k2J6.mjs} +49 -6
  50. package/dist/vrt-dFU3k2J6.mjs.map +1 -0
  51. package/dist/{vrt-DtcnqPhF.d.mts → vrt-nAWyjDmd.d.mts} +8 -5
  52. package/dist/vrt-nAWyjDmd.d.mts.map +1 -0
  53. package/dist/vrt.d.mts +1 -1
  54. package/dist/vrt.mjs +1 -1
  55. package/package.json +5 -5
  56. package/dist/gallery/assets/index-DpZpi0O6.css +0 -1
  57. package/dist/gallery/assets/index-qkpGvqJF.js +0 -73
  58. package/dist/options-DCuB_Fpu.mjs.map +0 -1
  59. package/dist/template-BgBSA10_.mjs.map +0 -1
  60. package/dist/utils-DeMLVlNS.mjs.map +0 -1
  61. package/dist/vrt-DtcnqPhF.d.mts.map +0 -1
  62. package/dist/vrt-PuxpRuHa.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
- import { E as loadNative, S as resolveTrustedSourcePath, T as analyzeSfcFallback, f as parseJsonBody, g as assertComponentSourcePath, s as toPascalCase, t as escapeHtml, v as decodeUrlComponent, w as HttpError, x as resolveInsideAny, y as isVueSourcePath } from "./utils-DeMLVlNS.mjs";
2
- import { s as resolveSnapshotIdentity } from "./vrt-PuxpRuHa.mjs";
1
+ import { E as loadNative, S as resolveTrustedSourcePath, T as analyzeSfcFallback, f as parseJsonBody, g as assertComponentSourcePath, s as toPascalCase, t as escapeHtml, v as decodeUrlComponent, w as HttpError, x as resolveInsideAny, y as isVueSourcePath } from "./utils-BloA9YP9.mjs";
2
+ import { s as resolveSnapshotIdentity } from "./vrt-dFU3k2J6.mjs";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
- import crypto, { createHash } from "node:crypto";
6
5
  import ts from "typescript";
6
+ import crypto, { createHash } from "node:crypto";
7
+ import { lstat, readFile, readdir } from "node:fs/promises";
7
8
  //#region src/component-source.ts
8
9
  function allowedSourceRoots(root, scanRoots = []) {
9
10
  return [...new Set([root, ...scanRoots].map((sourceRoot) => path.resolve(sourceRoot)))];
@@ -20,6 +21,24 @@ function resolveComponentSourcePath(art, artPath, sourceRoots) {
20
21
  return resolved;
21
22
  }
22
23
  //#endregion
24
+ //#region src/variant-bindings.ts
25
+ /** Preserve ordinary bindings and disambiguate every normalized collision. */
26
+ function variantComponentNames(variants) {
27
+ const names = /* @__PURE__ */ new Map();
28
+ const counts = /* @__PURE__ */ new Map();
29
+ for (const { name } of variants) {
30
+ if (names.has(name)) throw new Error(`Duplicate Musea variant name: ${JSON.stringify(name)}`);
31
+ const binding = toPascalCase(name);
32
+ names.set(name, binding);
33
+ counts.set(binding, (counts.get(binding) ?? 0) + 1);
34
+ }
35
+ for (const [name, binding] of names) if (counts.get(binding) > 1) {
36
+ const hash = createHash("sha256").update(JSON.stringify(name)).digest("hex");
37
+ names.set(name, `__MuseaVariant_${hash}`);
38
+ }
39
+ return names;
40
+ }
41
+ //#endregion
23
42
  //#region src/art-module-vue2.ts
24
43
  /**
25
44
  * Legacy Vue 2 variant emission.
@@ -79,7 +98,7 @@ ${components} template: \`${fullTemplate}\`,
79
98
  * The parsed `<script setup>` is passed in rather than parsed here, so this
80
99
  * module does not have to import back from `art-module.ts`.
81
100
  */
82
- function componentNameFromSource$1(source) {
101
+ function componentNameFromSource(source) {
83
102
  const withoutQuery = source.split(/[?#]/, 1)[0] || source;
84
103
  const filename = path.basename(withoutQuery);
85
104
  const extension = path.extname(filename);
@@ -108,7 +127,7 @@ function resolveArtComponent(art, filePath, scriptSetup, options = {}) {
108
127
  };
109
128
  componentImportPath = options.root ? resolveComponentSourcePath(sourceArt, filePath, allowedSourceRoots(options.root, options.scanRoots ?? [])) ?? void 0 : path.isAbsolute(componentSource) ? componentSource : path.resolve(path.dirname(filePath), componentSource);
110
129
  }
111
- componentTagName = defineArtComponentName ?? (art.metadata.component ? componentNameFromSource$1(art.metadata.component) : "MuseaComponent");
130
+ componentTagName = defineArtComponentName ?? (art.metadata.component ? componentNameFromSource(art.metadata.component) : "MuseaComponent");
112
131
  componentBindingName = componentTagName;
113
132
  }
114
133
  return {
@@ -343,13 +362,6 @@ function extractDefineArtComponent(content) {
343
362
  };
344
363
  return { name: content.match(/\bdefineArt\s*\(\s*([A-Za-z_$][\w$]*)/)?.[1] };
345
364
  }
346
- function componentNameFromSource(source) {
347
- const withoutQuery = source.split(/[?#]/, 1)[0] || source;
348
- const filename = path.basename(withoutQuery);
349
- const extension = path.extname(filename);
350
- const name = toPascalCase(extension ? filename.slice(0, -extension.length) : filename);
351
- return name === "Variant" ? "MuseaComponent" : name;
352
- }
353
365
  function isDefineArtLine(trimmed) {
354
366
  return /\bdefineArt\s*\(/.test(trimmed);
355
367
  }
@@ -408,8 +420,9 @@ ${scriptSetup.setupBody.join("\n")}
408
420
  return ${setupReturn};
409
421
  })();
410
422
  `;
423
+ const bindings = variantComponentNames(art.variants);
411
424
  for (const variant of art.variants) {
412
- const variantComponentName = toPascalCase(variant.name);
425
+ const variantComponentName = bindings.get(variant.name);
413
426
  const template = expandSelfTag(variant.template, componentTagName);
414
427
  if (options.vueVersion === 2) {
415
428
  code += emitLegacyVariant({
@@ -434,29 +447,11 @@ export { ${variantComponentName} };
434
447
  }
435
448
  const defaultVariant = art.variants.find((v) => v.isDefault) || art.variants[0];
436
449
  if (defaultVariant) code += `
437
- export default ${toPascalCase(defaultVariant.name)};
450
+ export default ${bindings.get(defaultVariant.name)};
438
451
  `;
439
452
  return code;
440
453
  }
441
454
  //#endregion
442
- //#region src/art-order.ts
443
- function sortedArts(arts) {
444
- return [...arts].sort(compareArtFiles);
445
- }
446
- function compareArtFiles(a, b) {
447
- const order = compareOrder(a.metadata.order, b.metadata.order);
448
- if (order !== 0) return order;
449
- const title = a.metadata.title.localeCompare(b.metadata.title, void 0, { numeric: true });
450
- if (title !== 0) return title;
451
- return a.path.localeCompare(b.path, void 0, { numeric: true });
452
- }
453
- function compareOrder(a, b) {
454
- if (a === void 0 && b === void 0) return 0;
455
- if (a === void 0) return 1;
456
- if (b === void 0) return -1;
457
- return a - b;
458
- }
459
- //#endregion
460
455
  //#region src/tokens/native.ts
461
456
  function tokenNative() {
462
457
  const native = loadNative();
@@ -996,6 +991,308 @@ function findDependentTokens(tokenMap, targetPath) {
996
991
  return tokenNative().findDependentDesignTokens(tokenMap, targetPath);
997
992
  }
998
993
  //#endregion
994
+ //#region src/tokens/generator.ts
995
+ /**
996
+ * Token documentation generators for Style Dictionary integration.
997
+ *
998
+ * Generates HTML, Markdown, and JSON documentation from parsed token categories,
999
+ * and provides the main processStyleDictionary orchestrator function.
1000
+ */
1001
+ const SAFE_CSS_COLOR_PATTERN = /^(?:#[0-9a-fA-F]{3,8}|(?:rgb|hsl)a?\(\s*[-+.\d,%\s/]+\)|(?:oklch|oklab|lab|lch)\(\s*[-+.\d,%\s/]+\))$/;
1002
+ const DANGEROUS_PROTOCOL_PATTERN = /\b(javascript|vbscript):/gi;
1003
+ function escapeTokenText(value) {
1004
+ return escapeHtml(value).replace(DANGEROUS_PROTOCOL_PATTERN, "$1&#58;");
1005
+ }
1006
+ function safeCssColor(value, type) {
1007
+ if (typeof value !== "string") return null;
1008
+ const trimmed = value.trim();
1009
+ return (type === "color" || trimmed.startsWith("#") || trimmed.startsWith("rgb") || trimmed.startsWith("hsl")) && SAFE_CSS_COLOR_PATTERN.test(trimmed) ? trimmed : null;
1010
+ }
1011
+ /**
1012
+ * Generate HTML documentation for tokens.
1013
+ */
1014
+ function generateTokensHtml(categories) {
1015
+ const renderToken = (name, token) => {
1016
+ const color = safeCssColor(token.value, token.type);
1017
+ return `
1018
+ <div class="token">
1019
+ <div class="token-preview">
1020
+ ${color ? `<div class="color-swatch" style="background: ${color}"></div>` : ""}
1021
+ </div>
1022
+ <div class="token-info">
1023
+ <div class="token-name">${escapeTokenText(name)}</div>
1024
+ <div class="token-value">${escapeTokenText(String(token.value))}</div>
1025
+ ${token.description ? `<div class="token-description">${escapeTokenText(token.description)}</div>` : ""}
1026
+ </div>
1027
+ </div>
1028
+ `;
1029
+ };
1030
+ const renderCategory = (category, level = 2) => {
1031
+ const heading = `h${Math.min(level, 6)}`;
1032
+ let html = `<${heading}>${escapeTokenText(category.name)}</${heading}>`;
1033
+ html += "<div class=\"tokens-grid\">";
1034
+ for (const [name, token] of Object.entries(category.tokens)) html += renderToken(name, token);
1035
+ html += "</div>";
1036
+ if (category.subcategories) for (const sub of category.subcategories) html += renderCategory(sub, level + 1);
1037
+ return html;
1038
+ };
1039
+ return `<!DOCTYPE html>
1040
+ <html lang="en">
1041
+ <head>
1042
+ <meta charset="UTF-8">
1043
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1044
+ <title>Design Tokens - Musea</title>
1045
+ <style>
1046
+ :root {
1047
+ --musea-bg: #0d0d0d;
1048
+ --musea-bg-secondary: #1a1815;
1049
+ --musea-text: #e6e9f0;
1050
+ --musea-text-muted: #7b8494;
1051
+ --musea-accent: #a34828;
1052
+ --musea-border: #3a3530;
1053
+ }
1054
+ * { box-sizing: border-box; margin: 0; padding: 0; }
1055
+ body {
1056
+ font-family: 'Inter', -apple-system, sans-serif;
1057
+ background: var(--musea-bg);
1058
+ color: var(--musea-text);
1059
+ line-height: 1.6;
1060
+ padding: 2rem;
1061
+ }
1062
+ h1 { margin-bottom: 2rem; color: var(--musea-accent); }
1063
+ h2 { margin: 2rem 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--musea-border); }
1064
+ h3, h4, h5, h6 { margin: 1.5rem 0 0.75rem; }
1065
+ .tokens-grid {
1066
+ display: grid;
1067
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
1068
+ gap: 1rem;
1069
+ margin-bottom: 1.5rem;
1070
+ }
1071
+ .token {
1072
+ background: var(--musea-bg-secondary);
1073
+ border: 1px solid var(--musea-border);
1074
+ border-radius: 8px;
1075
+ padding: 1rem;
1076
+ display: flex;
1077
+ gap: 1rem;
1078
+ align-items: center;
1079
+ }
1080
+ .token-preview {
1081
+ flex-shrink: 0;
1082
+ width: 48px;
1083
+ height: 48px;
1084
+ display: flex;
1085
+ align-items: center;
1086
+ justify-content: center;
1087
+ }
1088
+ .color-swatch {
1089
+ width: 48px;
1090
+ height: 48px;
1091
+ border-radius: 8px;
1092
+ border: 1px solid var(--musea-border);
1093
+ }
1094
+ .token-info {
1095
+ flex: 1;
1096
+ min-width: 0;
1097
+ }
1098
+ .token-name {
1099
+ font-weight: 600;
1100
+ font-family: 'JetBrains Mono', monospace;
1101
+ font-size: 0.875rem;
1102
+ }
1103
+ .token-value {
1104
+ color: var(--musea-text-muted);
1105
+ font-family: 'JetBrains Mono', monospace;
1106
+ font-size: 0.75rem;
1107
+ word-break: break-all;
1108
+ }
1109
+ .token-description {
1110
+ color: var(--musea-text-muted);
1111
+ font-size: 0.75rem;
1112
+ margin-top: 0.25rem;
1113
+ }
1114
+ </style>
1115
+ </head>
1116
+ <body>
1117
+ <h1>Design Tokens</h1>
1118
+ ${categories.map((cat) => renderCategory(cat)).join("")}
1119
+ </body>
1120
+ </html>`;
1121
+ }
1122
+ /**
1123
+ * Generate Markdown documentation for tokens.
1124
+ */
1125
+ function generateTokensMarkdown(categories) {
1126
+ return tokenNative().generateDesignTokensMarkdown(categories, (/* @__PURE__ */ new Date()).toISOString());
1127
+ }
1128
+ /**
1129
+ * Style Dictionary plugin for Musea.
1130
+ * Parses tokens and generates documentation in the specified format.
1131
+ */
1132
+ async function processStyleDictionary(config) {
1133
+ const categories = await parseTokens(config.tokensPath);
1134
+ const outputDir = config.outputDir ?? ".vize/tokens";
1135
+ const outputFormat = config.outputFormat ?? "html";
1136
+ await fs.promises.mkdir(outputDir, { recursive: true });
1137
+ let content;
1138
+ let filename;
1139
+ switch (outputFormat) {
1140
+ case "html":
1141
+ content = generateTokensHtml(categories);
1142
+ filename = "tokens.html";
1143
+ break;
1144
+ case "markdown":
1145
+ content = generateTokensMarkdown(categories);
1146
+ filename = "tokens.md";
1147
+ break;
1148
+ default:
1149
+ content = JSON.stringify({ categories }, null, 2);
1150
+ filename = "tokens.json";
1151
+ }
1152
+ const outputPath = path.join(outputDir, filename);
1153
+ await fs.promises.writeFile(outputPath, content, "utf-8");
1154
+ console.log(`[musea] Generated token documentation: ${outputPath}`);
1155
+ return {
1156
+ categories,
1157
+ metadata: {
1158
+ name: path.basename(config.tokensPath),
1159
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString()
1160
+ }
1161
+ };
1162
+ }
1163
+ //#endregion
1164
+ //#region src/tokens/preview.ts
1165
+ function resolveTokenPreview(input) {
1166
+ const reference = resolveReference(input.token, input.tokenMap);
1167
+ const value = input.token.$resolvedValue ?? reference?.value ?? input.token.value;
1168
+ const candidates = buildCandidates(input.tokenPath, input.token, reference);
1169
+ const kind = resolveCustomKind(candidates, reference?.path, input.config?.rules) ?? inferPreviewKind(candidates, value);
1170
+ return {
1171
+ kind: new Set(input.config?.disabledKinds ?? []).has(kind) ? "generic" : kind,
1172
+ value,
1173
+ tokenPath: input.tokenPath,
1174
+ reference
1175
+ };
1176
+ }
1177
+ function resolveReference(token, tokenMap) {
1178
+ if (!token.$reference) return void 0;
1179
+ const referencedToken = tokenMap?.[token.$reference];
1180
+ return {
1181
+ path: token.$reference,
1182
+ token: referencedToken,
1183
+ value: referencedToken ? referencedToken.$resolvedValue ?? referencedToken.value : void 0
1184
+ };
1185
+ }
1186
+ function buildCandidates(tokenPath, token, reference) {
1187
+ const candidates = [{
1188
+ tokenPath,
1189
+ name: pathName(tokenPath),
1190
+ token
1191
+ }];
1192
+ if (reference?.token) candidates.push({
1193
+ tokenPath: reference.path,
1194
+ name: pathName(reference.path),
1195
+ token: reference.token
1196
+ });
1197
+ return candidates;
1198
+ }
1199
+ function resolveCustomKind(candidates, referencePath, rules) {
1200
+ for (const rule of rules ?? []) if (matchesRule(rule, candidates, referencePath)) return rule.kind;
1201
+ }
1202
+ function matchesRule(rule, candidates, referencePath) {
1203
+ const checks = [];
1204
+ if (rule.type !== void 0) checks.push(candidates.some((candidate) => typeMatches(candidate, rule.type)));
1205
+ if (rule.pathIncludes !== void 0) checks.push(candidates.some((candidate) => includesAny(candidate.tokenPath, rule.pathIncludes)));
1206
+ if (rule.nameIncludes !== void 0) checks.push(candidates.some((candidate) => includesAny(candidate.name, rule.nameIncludes)));
1207
+ if (rule.referencePathIncludes !== void 0) checks.push(referencePath !== void 0 && includesAny(referencePath, rule.referencePathIncludes));
1208
+ return checks.length > 0 && checks.every(Boolean);
1209
+ }
1210
+ function inferPreviewKind(candidates, value) {
1211
+ if (hasType(candidates, ["color"]) || isColorValue(value)) return "color";
1212
+ if (hasType(candidates, ["shadow", "box-shadow"]) || hasSignal(candidates, ["shadow", "box-shadow"])) return "shadow";
1213
+ if (hasType(candidates, [
1214
+ "z-index",
1215
+ "zindex",
1216
+ "zIndex"
1217
+ ]) || hasSignal(candidates, [
1218
+ "z-index",
1219
+ "zindex",
1220
+ "stacking-order"
1221
+ ])) return "zIndex";
1222
+ if (hasType(candidates, ["opacity"]) || hasSignal(candidates, ["opacity", "alpha"])) return "opacity";
1223
+ if (hasType(candidates, [
1224
+ "border-radius",
1225
+ "borderradius",
1226
+ "radius"
1227
+ ]) || hasSignal(candidates, [
1228
+ "border-radius",
1229
+ "borderradius",
1230
+ "radius",
1231
+ "round",
1232
+ "rounded"
1233
+ ])) return "radius";
1234
+ if (hasType(candidates, ["letterspacing", "letter-spacing"]) || hasSignal(candidates, [
1235
+ "letter-spacing",
1236
+ "letterspacing",
1237
+ "tracking"
1238
+ ])) return "letterSpacing";
1239
+ if (hasType(candidates, ["spacing", "space"]) || hasSignal(candidates, [
1240
+ "spacing",
1241
+ "spasing",
1242
+ "space",
1243
+ "gap",
1244
+ "padding",
1245
+ "margin",
1246
+ "inset"
1247
+ ])) return "spacing";
1248
+ if (hasSignal(candidates, [
1249
+ "font-size",
1250
+ "fontsize",
1251
+ "text-size"
1252
+ ])) return "fontSize";
1253
+ if (hasType(candidates, ["fontweight", "font-weight"]) || hasSignal(candidates, [
1254
+ "font-weight",
1255
+ "fontweight",
1256
+ "weight"
1257
+ ])) return "fontWeight";
1258
+ if (hasType(candidates, ["lineheight", "line-height"]) || hasSignal(candidates, ["line-height", "lineheight"])) return "lineHeight";
1259
+ return "generic";
1260
+ }
1261
+ function hasType(candidates, terms) {
1262
+ return candidates.some((candidate) => typeMatches(candidate, terms));
1263
+ }
1264
+ function hasSignal(candidates, terms) {
1265
+ return candidates.some((candidate) => includesAny(candidate.tokenPath, terms) || includesAny(candidate.name, terms) || candidate.token.type !== void 0 && includesAny(candidate.token.type, terms));
1266
+ }
1267
+ function typeMatches(candidate, expected) {
1268
+ if (!candidate.token.type) return false;
1269
+ return toArray(expected).some((term) => normalize(candidate.token.type) === normalize(term));
1270
+ }
1271
+ function includesAny(value, expected) {
1272
+ const normalizedValue = normalize(value);
1273
+ const compactValue = compact(normalizedValue);
1274
+ return toArray(expected).some((term) => {
1275
+ const normalizedTerm = normalize(term);
1276
+ return normalizedValue.includes(normalizedTerm) || compactValue.includes(compact(normalizedTerm));
1277
+ });
1278
+ }
1279
+ function isColorValue(value) {
1280
+ if (typeof value !== "string") return false;
1281
+ return /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|oklab\(|lab\(|lch\(|color\()/i.test(value.trim());
1282
+ }
1283
+ function pathName(tokenPath) {
1284
+ return tokenPath.split(".").at(-1) ?? tokenPath;
1285
+ }
1286
+ function normalize(value) {
1287
+ return value.trim().toLowerCase().replace(/[_\s]+/g, "-");
1288
+ }
1289
+ function compact(value) {
1290
+ return value.replace(/[-.]/g, "");
1291
+ }
1292
+ function toArray(value) {
1293
+ return Array.isArray(value) ? value : [value];
1294
+ }
1295
+ //#endregion
999
1296
  //#region src/api-tokens.ts
1000
1297
  function resolveTokensPath(ctx) {
1001
1298
  const allowedRoots = [ctx.config.root, ...ctx.scanRoots];
@@ -1350,6 +1647,7 @@ async function handleArtPalette(ctx, match, sendJson, sendError) {
1350
1647
  const componentSource = await fs.promises.readFile(resolvedComponentPath, "utf-8");
1351
1648
  const analysis = isVueSourcePath(resolvedComponentPath) ? binding.analyzeSfc ? binding.analyzeSfc(componentSource, { filename: resolvedComponentPath }) : analyzeSfcFallback(componentSource, { filename: resolvedComponentPath }) : analyzeScriptComponent(componentSource, resolvedComponentPath);
1352
1649
  if (analysis.props.length > 0) mergeSfcPropsIntoPalette(palette, analysis.props);
1650
+ if (isVueSourcePath(resolvedComponentPath) && analysis.props.some((prop) => prop.name === "__proto__")) palette.unsupportedProps = ["__proto__"];
1353
1651
  } catch {}
1354
1652
  sendJson(palette);
1355
1653
  } catch (e) {
@@ -1448,7 +1746,9 @@ function normalizePropName(name) {
1448
1746
  return name.replace(/[-_]/g, "").toLowerCase();
1449
1747
  }
1450
1748
  function generateTypescript(palette) {
1451
- const fields = palette.controls.map((control) => ` ${control.name}${control.required ? "" : "?"}: ${controlTsType(control)};`).join("\n");
1749
+ const fields = palette.controls.map((control) => {
1750
+ return ` ${/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(control.name) ? control.name : JSON.stringify(control.name)}${control.required ? "" : "?"}: ${controlTsType(control)};`;
1751
+ }).join("\n");
1452
1752
  return `export interface ${pascalCase(palette.title)}Props {\n${fields}\n}\n`;
1453
1753
  }
1454
1754
  function controlTsType(control) {
@@ -1571,6 +1871,24 @@ async function handleArtDocs(ctx, match, sendJson, sendError) {
1571
1871
  }
1572
1872
  /** GET /api/arts/:path/variants/:name/a11y */
1573
1873
  //#endregion
1874
+ //#region src/art-order.ts
1875
+ function sortedArts(arts) {
1876
+ return [...arts].sort(compareArtFiles);
1877
+ }
1878
+ function compareArtFiles(a, b) {
1879
+ const order = compareOrder(a.metadata.order, b.metadata.order);
1880
+ if (order !== 0) return order;
1881
+ const title = a.metadata.title.localeCompare(b.metadata.title, void 0, { numeric: true });
1882
+ if (title !== 0) return title;
1883
+ return a.path.localeCompare(b.path, void 0, { numeric: true });
1884
+ }
1885
+ function compareOrder(a, b) {
1886
+ if (a === void 0 && b === void 0) return 0;
1887
+ if (a === void 0) return 1;
1888
+ if (b === void 0) return -1;
1889
+ return a - b;
1890
+ }
1891
+ //#endregion
1574
1892
  //#region src/static-data.ts
1575
1893
  function staticPreviewId(artPath, variantName) {
1576
1894
  return crypto.createHash("sha256").update(artPath).update("\0").update(variantName).digest("hex").slice(0, 20);
@@ -1581,12 +1899,12 @@ function joinUrlPath(basePath, ...segments) {
1581
1899
  async function createStaticGalleryPayload(ctx) {
1582
1900
  const apiCtx = createApiContext(ctx);
1583
1901
  const arts = sortedArts(ctx.artFiles.values());
1584
- const previews = {};
1902
+ const previews = Object.create(null);
1585
1903
  const details = {};
1586
1904
  const snapshotIdentities = Object.create(null);
1587
1905
  for (const art of arts) {
1588
1906
  snapshotIdentities[art.path] = resolveSnapshotIdentity(art.path, ctx.projectRoot ?? ctx.config.root);
1589
- previews[art.path] = {};
1907
+ previews[art.path] = Object.create(null);
1590
1908
  for (const variant of art.variants) {
1591
1909
  const id = staticPreviewId(art.path, variant.name);
1592
1910
  previews[art.path][variant.name] = joinUrlPath(ctx.basePath, "preview", `${id}.html`);
@@ -1694,10 +2012,90 @@ function rewriteGalleryTextAssetBase(source, relativePath, basePath) {
1694
2012
  if (!TEXT_GALLERY_ASSET_EXT.test(relativePath)) return source;
1695
2013
  return rewriteGalleryBase(Buffer.from(source).toString("utf-8"), basePath);
1696
2014
  }
2015
+ function rewriteDevGalleryAsset(source, relativePath, basePath) {
2016
+ return basePath === "/__musea__" ? source : rewriteGalleryTextAssetBase(source, relativePath, basePath);
2017
+ }
1697
2018
  function publicBasePathFromViteBase(viteBase, basePath) {
1698
2019
  return viteBase && viteBase !== "/" && viteBase !== "./" ? joinUrlPath(viteBase, basePath) : basePath;
1699
2020
  }
1700
2021
  //#endregion
2022
+ //#region src/vrt/report-identity.ts
2023
+ /** Reserve one qualified namespace and compare legacy names on case-insensitive filesystems. */
2024
+ function legacyName(identity) {
2025
+ const basename = path.posix.basename(identity, ".art.vue");
2026
+ return /^[a-z0-9._-]{1,200}$/i.test(basename) && !/^art-[0-9a-f]{64}$/i.test(basename) ? `vrt-${basename}` : void 0;
2027
+ }
2028
+ /** The complete discovered Art set decides collisions, even for a single-Art request. */
2029
+ function resolveArtReportTarget(artPath, artPaths, projectRoot, reportDir) {
2030
+ const identities = Array.from(artPaths, (item) => resolveSnapshotIdentity(item, projectRoot));
2031
+ const identity = resolveSnapshotIdentity(artPath, projectRoot);
2032
+ if (!identities.includes(identity)) throw new Error(`Report Art not found: ${artPath}`);
2033
+ const candidates = identities.map(legacyName);
2034
+ const counts = /* @__PURE__ */ new Map();
2035
+ for (const name of candidates) if (name) counts.set(name.toLowerCase(), (counts.get(name.toLowerCase()) ?? 0) + 1);
2036
+ const names = identities.map((item, index) => {
2037
+ const candidate = candidates[index];
2038
+ const colliding = candidate && counts.get(candidate.toLowerCase()) > 1;
2039
+ return candidate && !colliding ? candidate : `vrt-art-${createHash("sha256").update(JSON.stringify([1, item])).digest("hex")}`;
2040
+ });
2041
+ if (new Set(names.map((name) => name.toLowerCase())).size !== names.length) throw new Error("Ambiguous VRT report identities");
2042
+ const base = names[identities.indexOf(identity)];
2043
+ return {
2044
+ identity,
2045
+ jsonReportPath: path.join(reportDir, `${base}-report.json`),
2046
+ htmlReportPath: path.join(reportDir, `${base}-report.html`)
2047
+ };
2048
+ }
2049
+ async function existsRegularFile(file) {
2050
+ try {
2051
+ if (!(await lstat(file)).isFile()) throw new Error(`VRT report is not a regular file: ${file}`);
2052
+ return true;
2053
+ } catch (error) {
2054
+ if (error.code === "ENOENT") return false;
2055
+ throw error;
2056
+ }
2057
+ }
2058
+ /** Fail before capture or writes; legacy adoption requires every recorded result to have this owner. */
2059
+ async function assertArtReportOwnership(target, projectRoot) {
2060
+ const refusal = `Ambiguous VRT report ownership: ${target.jsonReportPath}. Archive or move the existing reports before retrying.`;
2061
+ const names = [path.basename(target.jsonReportPath), path.basename(target.htmlReportPath)];
2062
+ let existingNames;
2063
+ try {
2064
+ existingNames = await readdir(path.dirname(target.jsonReportPath));
2065
+ } catch (error) {
2066
+ if (error.code === "ENOENT") return;
2067
+ throw error;
2068
+ }
2069
+ if (existingNames.some((item) => names.some((name) => item !== name && item.toLowerCase() === name.toLowerCase()))) throw new Error(refusal);
2070
+ const jsonExists = await existsRegularFile(target.jsonReportPath);
2071
+ const htmlExists = await existsRegularFile(target.htmlReportPath);
2072
+ if (!jsonExists && !htmlExists) return;
2073
+ if (!jsonExists) throw new Error(refusal);
2074
+ try {
2075
+ const report = JSON.parse(await readFile(target.jsonReportPath, "utf8"));
2076
+ if (!report || typeof report !== "object" || Array.isArray(report)) throw new Error(refusal);
2077
+ if (Object.hasOwn(report, "reportOwner")) {
2078
+ const owner = report.reportOwner;
2079
+ if (!owner || typeof owner !== "object" || owner.version !== 1 || owner.artIdentity !== target.identity) throw new Error(refusal);
2080
+ } else {
2081
+ const results = report.results;
2082
+ if (!Array.isArray(results) || !results.length || results.some((item) => !item || typeof item !== "object" || typeof item.artPath !== "string" || resolveSnapshotIdentity(item.artPath, projectRoot) !== target.identity)) throw new Error(refusal);
2083
+ }
2084
+ } catch {
2085
+ throw new Error(refusal);
2086
+ }
2087
+ }
2088
+ /** Keep ownership portable when a report directory moves to another machine. */
2089
+ function attachArtReportOwner(json, target) {
2090
+ return JSON.stringify({
2091
+ ...JSON.parse(json),
2092
+ reportOwner: {
2093
+ version: 1,
2094
+ artIdentity: target.identity
2095
+ }
2096
+ }, null, 2);
2097
+ }
2098
+ //#endregion
1701
2099
  //#region src/art-style.ts
1702
2100
  function artScopeAttribute(filePath) {
1703
2101
  return `data-v-${createHash("sha256").update(filePath).digest("hex").slice(0, 8)}`;
@@ -1838,6 +2236,6 @@ function readMuseaOptions(plugin) {
1838
2236
  return plugin[MUSEA_OPTIONS_KEY];
1839
2237
  }
1840
2238
  //#endregion
1841
- export { tokenNative as C, rewriteRelativeImportStatement as D, parseScriptSetupForArt as E, expandSelfTag as O, parseTokens as S, generateArtModule as T, handleTokensUpdate as _, rewriteGalleryBase as a, resolveReferences as b, joinUrlPath as c, handleArtDocs as d, handleArtSource as f, handleTokensGet as g, handleTokensDelete as h, publicBasePathFromViteBase as i, resolveArtComponent as k, staticPreviewId as l, handleTokensCreate as m, readMuseaOptions as n, rewriteGalleryTextAssetBase as o, handleArtPalette as p, processMuseaArtFile as r, createStaticGalleryPayload as s, attachMuseaOptions as t, handleArtAnalysis as u, handleTokensUsage as v, sortedArts as w, scanTokenUsage as x, buildTokenMap as y };
2239
+ export { scanTokenUsage as A, handleTokensUsage as C, processStyleDictionary as D, generateTokensMarkdown as E, expandSelfTag as F, resolveArtComponent as I, variantComponentNames as L, generateArtModule as M, parseScriptSetupForArt as N, buildTokenMap as O, rewriteRelativeImportStatement as P, handleTokensUpdate as S, generateTokensHtml as T, handleArtSource as _, attachArtReportOwner as a, handleTokensDelete as b, rewriteDevGalleryAsset as c, createStaticGalleryPayload as d, joinUrlPath as f, handleArtDocs as g, handleArtAnalysis as h, assertArtReportOwnership as i, parseTokens as j, resolveReferences as k, rewriteGalleryBase as l, sortedArts as m, readMuseaOptions as n, resolveArtReportTarget as o, staticPreviewId as p, processMuseaArtFile as r, publicBasePathFromViteBase as s, attachMuseaOptions as t, rewriteGalleryTextAssetBase as u, handleArtPalette as v, resolveTokenPreview as w, handleTokensGet as x, handleTokensCreate as y };
1842
2240
 
1843
- //# sourceMappingURL=options-DCuB_Fpu.mjs.map
2241
+ //# sourceMappingURL=options-DNFbTB_5.mjs.map