@vizejs/vite-plugin-musea 0.243.0 → 0.263.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/autogen/index.d.mts.map +1 -1
- package/dist/autogen/index.mjs +1 -1
- package/dist/{autogen-Blm3Qy_O.mjs → autogen-B7_TO0n5.mjs} +63 -20
- package/dist/autogen-B7_TO0n5.mjs.map +1 -0
- package/dist/cli/index.mjs +7 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +11 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +610 -448
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/autogen-Blm3Qy_O.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/autogen/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/autogen/index.ts"],"mappings":";;AA6BA;;;;;;;;;UAAiB,cAAA;EAYI;EAVnB,WAAA;EAgBe;EAdf,cAAA;;EAEA,qBAAA;EAaA;EAXA,mBAAA;EAaA;EAXA,qBAAA;EAYY;EAVZ,mBAAA;AAAA;;;;UAMe,cAAA;EACf,IAAA;EACA,QAAA;EACA,QAAA;EACA,YAAA;AAAA;;AAgBF;;UAViB,gBAAA;EACf,IAAA;EACA,SAAA;EACA,KAAA,EAAO,MAAA;EACP,WAAA;AAAA;;;AAwDF;UAlDiB,aAAA;EACf,QAAA,EAAU,gBAAA;EACV,cAAA;EACA,aAAA;AAAA;;;;;;;;iBA+CoB,eAAA,CACpB,aAAA,UACA,OAAA,GAAS,cAAA,GACR,OAAA,CAAQ,aAAA;;AAmDX;;iBAAsB,YAAA,CACpB,aAAA,UACA,OAAA,GAAS,cAAA,EACT,UAAA,YACC,OAAA"}
|
package/dist/autogen/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as writeArtFile, t as generateArtFile } from "../autogen-
|
|
1
|
+
import { n as writeArtFile, t as generateArtFile } from "../autogen-B7_TO0n5.mjs";
|
|
2
2
|
export { generateArtFile, writeArtFile };
|
|
@@ -59,7 +59,7 @@ function generateArtFileJs(componentPath, props, options) {
|
|
|
59
59
|
variants.push({
|
|
60
60
|
name: "Default",
|
|
61
61
|
isDefault: true,
|
|
62
|
-
props: defaultProps,
|
|
62
|
+
props: withRequiredPlaceholders(defaultProps, props),
|
|
63
63
|
description: `${componentName} with default props`
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -71,7 +71,7 @@ function generateArtFileJs(componentPath, props, options) {
|
|
|
71
71
|
variants.push({
|
|
72
72
|
name,
|
|
73
73
|
isDefault: false,
|
|
74
|
-
props: { [prop.name]: val },
|
|
74
|
+
props: withRequiredPlaceholders({ [prop.name]: val }, props),
|
|
75
75
|
description: `${prop.name} = ${JSON.stringify(val)}`
|
|
76
76
|
});
|
|
77
77
|
}
|
|
@@ -83,31 +83,71 @@ function generateArtFileJs(componentPath, props, options) {
|
|
|
83
83
|
variants.push({
|
|
84
84
|
name: nonDefault ? toPascalCase(prop.name) : `No${toPascalCase(prop.name)}`,
|
|
85
85
|
isDefault: false,
|
|
86
|
-
props: { [prop.name]: nonDefault },
|
|
86
|
+
props: withRequiredPlaceholders({ [prop.name]: nonDefault }, props),
|
|
87
87
|
description: `${prop.name} = ${nonDefault}`
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
let content = `<script setup lang="ts">\ndefineArt(${JSON.stringify(relPath)}, {\n title: ${JSON.stringify(componentName)},\n});\n<\/script>\n\n<art>\n`;
|
|
92
|
-
for (const variant of variants) {
|
|
93
|
-
const attrs = variant.isDefault ? `name="${variant.name}" default` : `name="${variant.name}"`;
|
|
94
|
-
content += ` <variant ${attrs}>\n`;
|
|
95
|
-
const propsStr = Object.entries(variant.props).map(([k, v]) => {
|
|
96
|
-
if (typeof v === "string") return `${k}="${v}"`;
|
|
97
|
-
if (typeof v === "boolean" && v) return k;
|
|
98
|
-
if (typeof v === "boolean" && !v) return `:${k}="false"`;
|
|
99
|
-
return `:${k}="${JSON.stringify(v)}"`;
|
|
100
|
-
}).join(" ");
|
|
101
|
-
content += ` <${componentName}${propsStr ? " " + propsStr : ""} />\n`;
|
|
102
|
-
content += ` </variant>\n\n`;
|
|
103
|
-
}
|
|
104
|
-
content += `</art>\n`;
|
|
105
91
|
return {
|
|
106
92
|
variants,
|
|
107
|
-
artFileContent:
|
|
93
|
+
artFileContent: generateArtFileContent(componentName, relPath, variants, props),
|
|
108
94
|
componentName
|
|
109
95
|
};
|
|
110
96
|
}
|
|
97
|
+
function finalizeArtOutput(output, componentPath, props) {
|
|
98
|
+
const variants = output.variants.map((variant) => ({
|
|
99
|
+
...variant,
|
|
100
|
+
props: withRequiredPlaceholders(variant.props, props)
|
|
101
|
+
}));
|
|
102
|
+
return {
|
|
103
|
+
...output,
|
|
104
|
+
variants,
|
|
105
|
+
artFileContent: generateArtFileContent(output.componentName, componentPath, variants, props)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function generateArtFileContent(componentName, componentPath, variants, props) {
|
|
109
|
+
const fixtures = /* @__PURE__ */ new Map();
|
|
110
|
+
let variantsContent = "";
|
|
111
|
+
for (const variant of variants) {
|
|
112
|
+
const attrs = variant.isDefault ? `name="${variant.name}" default` : `name="${variant.name}"`;
|
|
113
|
+
variantsContent += ` <variant ${attrs}>\n`;
|
|
114
|
+
const propsStr = Object.entries(variant.props).map(([k, v]) => renderPropAttribute(k, v, props, fixtures)).join(" ");
|
|
115
|
+
variantsContent += ` <${componentName}${propsStr ? " " + propsStr : ""} />\n`;
|
|
116
|
+
variantsContent += ` </variant>\n\n`;
|
|
117
|
+
}
|
|
118
|
+
const fixtureLines = [...fixtures.entries()].map(([propName, fixture]) => `const ${fixture} = {} as never; // TODO: replace generated fixture for required prop ${JSON.stringify(propName)}`);
|
|
119
|
+
return `<script setup lang="ts">
|
|
120
|
+
${fixtureLines.length > 0 ? `${fixtureLines.join("\n")}\n\n` : ""}defineArt(${JSON.stringify(componentPath)}, {
|
|
121
|
+
title: ${JSON.stringify(componentName)},
|
|
122
|
+
});
|
|
123
|
+
<\/script>
|
|
124
|
+
|
|
125
|
+
<art>
|
|
126
|
+
${variantsContent}</art>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
function withRequiredPlaceholders(values, props) {
|
|
130
|
+
const next = { ...values };
|
|
131
|
+
for (const prop of props) if (prop.required && prop.defaultValue === void 0 && !(prop.name in next)) next[prop.name] = null;
|
|
132
|
+
return next;
|
|
133
|
+
}
|
|
134
|
+
function renderPropAttribute(name, value, props, fixtures) {
|
|
135
|
+
const attrName = toKebabCase(name);
|
|
136
|
+
const prop = props.find((candidate) => candidate.name === name);
|
|
137
|
+
if (prop?.required && prop.defaultValue === void 0 && value == null) {
|
|
138
|
+
const fixture = fixtureIdentifier(name);
|
|
139
|
+
fixtures.set(name, fixture);
|
|
140
|
+
return `:${attrName}="${fixture}"`;
|
|
141
|
+
}
|
|
142
|
+
if (typeof value === "string") return `${attrName}="${value}"`;
|
|
143
|
+
if (typeof value === "boolean" && value) return attrName;
|
|
144
|
+
if (typeof value === "boolean" && !value) return `:${attrName}="false"`;
|
|
145
|
+
return `:${attrName}="${JSON.stringify(value)}"`;
|
|
146
|
+
}
|
|
147
|
+
function fixtureIdentifier(propName) {
|
|
148
|
+
const base = propName.replace(/[^\w$]/g, "_");
|
|
149
|
+
return /^[A-Za-z_$]/.test(base) ? `${base}Fixture` : `prop${toPascalCase(base)}Fixture`;
|
|
150
|
+
}
|
|
111
151
|
function parseUnionType(typeStr) {
|
|
112
152
|
const trimmed = typeStr.trim();
|
|
113
153
|
if (!trimmed.includes("|")) return [];
|
|
@@ -119,6 +159,9 @@ function parseUnionType(typeStr) {
|
|
|
119
159
|
function toPascalCase(str) {
|
|
120
160
|
return str.split(/[\s\-_]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
121
161
|
}
|
|
162
|
+
function toKebabCase(str) {
|
|
163
|
+
return str.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
164
|
+
}
|
|
122
165
|
//#endregion
|
|
123
166
|
//#region src/autogen/native-shape.ts
|
|
124
167
|
function toNativePropDefinitions(props) {
|
|
@@ -204,7 +247,7 @@ async function generateArtFile(componentPath, options = {}) {
|
|
|
204
247
|
}
|
|
205
248
|
if (binding.generateVariants) {
|
|
206
249
|
const relPath = `./${path.basename(componentPath)}`;
|
|
207
|
-
return fromNativeOutput(binding.generateVariants(relPath, toNativePropDefinitions(props), toNativeAutogenConfig(options)));
|
|
250
|
+
return finalizeArtOutput(fromNativeOutput(binding.generateVariants(relPath, toNativePropDefinitions(props), toNativeAutogenConfig(options))), relPath, props);
|
|
208
251
|
}
|
|
209
252
|
return generateArtFileJs(componentPath, props, options);
|
|
210
253
|
}
|
|
@@ -221,4 +264,4 @@ async function writeArtFile(componentPath, options = {}, outputPath) {
|
|
|
221
264
|
//#endregion
|
|
222
265
|
export { writeArtFile as n, generateArtFile as t };
|
|
223
266
|
|
|
224
|
-
//# sourceMappingURL=autogen-
|
|
267
|
+
//# sourceMappingURL=autogen-B7_TO0n5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autogen-B7_TO0n5.mjs","names":[],"sources":["../src/autogen/fallback.ts","../src/autogen/native-shape.ts","../src/autogen/index.ts"],"sourcesContent":["/**\n * JS-based fallback for variant auto-generation.\n *\n * Used when the native Rust binding is not available. Provides simple\n * regex-based prop extraction, minimal art file generation, and a pure\n * JS variant generator.\n */\n\nimport path from \"node:path\";\n\nimport type { AutogenOptions, AutogenOutput, GeneratedVariant, PropDefinition } from \"./index.js\";\n\n/**\n * Simple prop extraction fallback (when native binding not available).\n */\nexport function extractPropsSimple(source: string): PropDefinition[] {\n const props: PropDefinition[] = [];\n\n // Match defineProps<{ ... }>() or defineProps({ ... })\n const propsMatch = source.match(/defineProps\\s*<\\s*\\{([^}]*)\\}\\s*>/s);\n\n if (propsMatch) {\n const propsBlock = propsMatch[1];\n const propLines = propsBlock.split(\"\\n\");\n\n for (const line of propLines) {\n const propMatch = line.trim().match(/^(\\w+)(\\?)?:\\s*(.+?)\\s*;?\\s*$/);\n if (propMatch) {\n props.push({\n name: propMatch[1],\n propType: propMatch[3].replace(/,\\s*$/, \"\"),\n required: !propMatch[2],\n });\n }\n }\n }\n\n return props;\n}\n\n/**\n * Minimal art file for components with no props.\n */\nexport function generateMinimalArt(componentName: string, componentPath: string): string {\n return `<script setup lang=\"ts\">\ndefineArt(${JSON.stringify(componentPath)}, {\n title: ${JSON.stringify(componentName)},\n});\n</script>\n\n<art>\n <variant name=\"Default\" default>\n <${componentName} />\n </variant>\n</art>\n`;\n}\n\n/**\n * JS-based variant generation fallback.\n */\nexport function generateArtFileJs(\n componentPath: string,\n props: PropDefinition[],\n options: AutogenOptions,\n): AutogenOutput {\n const componentName = path.basename(componentPath, \".vue\");\n const relPath = `./${path.basename(componentPath)}`;\n const maxVariants = options.maxVariants ?? 20;\n const variants: GeneratedVariant[] = [];\n\n // Default variant\n if (options.includeDefault !== false) {\n const defaultProps: Record<string, unknown> = {};\n for (const prop of props) {\n if (prop.defaultValue !== undefined) {\n defaultProps[prop.name] = prop.defaultValue;\n }\n }\n variants.push({\n name: \"Default\",\n isDefault: true,\n props: withRequiredPlaceholders(defaultProps, props),\n description: `${componentName} with default props`,\n });\n }\n\n // Enum variants\n if (options.includeEnumVariants !== false) {\n for (const prop of props) {\n const unionValues = parseUnionType(prop.propType);\n for (const val of unionValues) {\n if (variants.length >= maxVariants) break;\n const name =\n typeof val === \"string\" ? toPascalCase(val) : `${toPascalCase(prop.name)}_${String(val)}`;\n variants.push({\n name,\n isDefault: false,\n props: withRequiredPlaceholders({ [prop.name]: val }, props),\n description: `${prop.name} = ${JSON.stringify(val)}`,\n });\n }\n }\n }\n\n // Boolean toggle variants\n if (options.includeBooleanToggles !== false) {\n for (const prop of props) {\n if (variants.length >= maxVariants) break;\n if (prop.propType.toLowerCase() === \"boolean\") {\n const nonDefault = prop.defaultValue === true ? false : true;\n variants.push({\n name: nonDefault ? toPascalCase(prop.name) : `No${toPascalCase(prop.name)}`,\n isDefault: false,\n props: withRequiredPlaceholders({ [prop.name]: nonDefault }, props),\n description: `${prop.name} = ${nonDefault}`,\n });\n }\n }\n }\n\n return {\n variants,\n artFileContent: generateArtFileContent(componentName, relPath, variants, props),\n componentName,\n };\n}\n\nexport function finalizeArtOutput(\n output: AutogenOutput,\n componentPath: string,\n props: PropDefinition[],\n): AutogenOutput {\n const variants = output.variants.map((variant) => ({\n ...variant,\n props: withRequiredPlaceholders(variant.props, props),\n }));\n return {\n ...output,\n variants,\n artFileContent: generateArtFileContent(output.componentName, componentPath, variants, props),\n };\n}\n\nfunction generateArtFileContent(\n componentName: string,\n componentPath: string,\n variants: GeneratedVariant[],\n props: PropDefinition[],\n): string {\n const fixtures = new Map<string, string>();\n let variantsContent = \"\";\n\n for (const variant of variants) {\n const attrs = variant.isDefault ? `name=\"${variant.name}\" default` : `name=\"${variant.name}\"`;\n variantsContent += ` <variant ${attrs}>\\n`;\n\n const propsStr = Object.entries(variant.props)\n .map(([k, v]) => renderPropAttribute(k, v, props, fixtures))\n .join(\" \");\n\n variantsContent += ` <${componentName}${propsStr ? \" \" + propsStr : \"\"} />\\n`;\n variantsContent += ` </variant>\\n\\n`;\n }\n\n const fixtureLines = [...fixtures.entries()].map(\n ([propName, fixture]) =>\n `const ${fixture} = {} as never; // TODO: replace generated fixture for required prop ${JSON.stringify(propName)}`,\n );\n const fixtureBlock = fixtureLines.length > 0 ? `${fixtureLines.join(\"\\n\")}\\n\\n` : \"\";\n\n return `<script setup lang=\"ts\">\n${fixtureBlock}defineArt(${JSON.stringify(componentPath)}, {\n title: ${JSON.stringify(componentName)},\n});\n</script>\n\n<art>\n${variantsContent}</art>\n`;\n}\n\nfunction withRequiredPlaceholders(\n values: Record<string, unknown>,\n props: PropDefinition[],\n): Record<string, unknown> {\n const next = { ...values };\n for (const prop of props) {\n if (prop.required && prop.defaultValue === undefined && !(prop.name in next)) {\n next[prop.name] = null;\n }\n }\n return next;\n}\n\nfunction renderPropAttribute(\n name: string,\n value: unknown,\n props: PropDefinition[],\n fixtures: Map<string, string>,\n): string {\n const attrName = toKebabCase(name);\n const prop = props.find((candidate) => candidate.name === name);\n if (prop?.required && prop.defaultValue === undefined && value == null) {\n const fixture = fixtureIdentifier(name);\n fixtures.set(name, fixture);\n return `:${attrName}=\"${fixture}\"`;\n }\n if (typeof value === \"string\") return `${attrName}=\"${value}\"`;\n if (typeof value === \"boolean\" && value) return attrName;\n if (typeof value === \"boolean\" && !value) return `:${attrName}=\"false\"`;\n return `:${attrName}=\"${JSON.stringify(value)}\"`;\n}\n\nfunction fixtureIdentifier(propName: string): string {\n const base = propName.replace(/[^\\w$]/g, \"_\");\n return /^[A-Za-z_$]/.test(base) ? `${base}Fixture` : `prop${toPascalCase(base)}Fixture`;\n}\n\nexport function parseUnionType(typeStr: string): unknown[] {\n const trimmed = typeStr.trim();\n if (!trimmed.includes(\"|\")) return [];\n\n if (trimmed.includes(\"'\") || trimmed.includes('\"')) {\n return trimmed\n .split(\"|\")\n .map((s) => s.trim().replace(/^['\"]|['\"]$/g, \"\"))\n .filter((s) => s.length > 0);\n }\n\n const parts = trimmed.split(\"|\").map((s) => s.trim());\n if (parts.every((p) => !isNaN(Number(p)))) {\n return parts.map(Number);\n }\n\n return [];\n}\n\nexport function toPascalCase(str: string): string {\n return str\n .split(/[\\s\\-_]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\nfunction toKebabCase(str: string): string {\n return str.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n","import type { AutogenOptions, AutogenOutput, PropDefinition } from \"./index.js\";\n\nexport interface NativePropDefinition {\n name: string;\n propType: string;\n required: boolean;\n defaultValue?: unknown;\n}\n\nexport interface NativeAutogenConfig {\n maxVariants?: number;\n includeDefault?: boolean;\n includeBooleanToggles?: boolean;\n includeEnumVariants?: boolean;\n includeBoundaryValues?: boolean;\n includeEmptyStrings?: boolean;\n}\n\nexport interface NativeGeneratedVariant {\n name: string;\n isDefault: boolean;\n props: Record<string, unknown>;\n description?: string;\n}\n\nexport interface NativeAutogenOutput {\n variants: NativeGeneratedVariant[];\n artFileContent: string;\n componentName: string;\n}\n\nexport function toNativePropDefinitions(props: PropDefinition[]): NativePropDefinition[] {\n return props.map((prop) => ({\n name: prop.name,\n propType: prop.propType,\n required: prop.required,\n defaultValue: prop.defaultValue,\n }));\n}\n\nexport function toNativeAutogenConfig(options: AutogenOptions): NativeAutogenConfig {\n return {\n maxVariants: options.maxVariants,\n includeDefault: options.includeDefault,\n includeBooleanToggles: options.includeBooleanToggles,\n includeEnumVariants: options.includeEnumVariants,\n includeBoundaryValues: options.includeBoundaryValues,\n includeEmptyStrings: options.includeEmptyStrings,\n };\n}\n\nexport function fromNativeOutput(output: NativeAutogenOutput): AutogenOutput {\n return {\n variants: output.variants.map((variant) => ({\n name: variant.name,\n isDefault: variant.isDefault,\n props: variant.props,\n description: variant.description,\n })),\n artFileContent: output.artFileContent,\n componentName: output.componentName,\n };\n}\n","/**\n * Variant auto-generation module.\n * Generates .art.vue files from component prop analysis.\n *\n * JS-based fallback logic (extractPropsSimple, generateMinimalArt,\n * generateArtFileJs, and helpers) is extracted into `fallback.ts`.\n */\n\nimport { createRequire } from \"node:module\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n extractPropsSimple,\n finalizeArtOutput,\n generateMinimalArt,\n generateArtFileJs,\n} from \"./fallback.js\";\nimport {\n fromNativeOutput,\n toNativeAutogenConfig,\n toNativePropDefinitions,\n type NativeAutogenOutput,\n type NativePropDefinition,\n} from \"./native-shape.js\";\n\n/**\n * Autogen configuration options.\n */\nexport interface AutogenOptions {\n /** Maximum number of variants to generate (default: 20) */\n maxVariants?: number;\n /** Include a \"Default\" variant with all default values (default: true) */\n includeDefault?: boolean;\n /** Include boolean toggle variants (default: true) */\n includeBooleanToggles?: boolean;\n /** Include enum/union variants (default: true) */\n includeEnumVariants?: boolean;\n /** Include boundary value variants for numbers (default: false) */\n includeBoundaryValues?: boolean;\n /** Include empty string variants for optional strings (default: false) */\n includeEmptyStrings?: boolean;\n}\n\n/**\n * Prop definition for variant generation.\n */\nexport interface PropDefinition {\n name: string;\n propType: string;\n required: boolean;\n defaultValue?: unknown;\n}\n\n/**\n * Generated variant.\n */\nexport interface GeneratedVariant {\n name: string;\n isDefault: boolean;\n props: Record<string, unknown>;\n description?: string;\n}\n\n/**\n * Autogen output.\n */\nexport interface AutogenOutput {\n variants: GeneratedVariant[];\n artFileContent: string;\n componentName: string;\n}\n\n// Native binding types\ninterface NativeAutogen {\n generateVariants?: (\n componentPath: string,\n props: NativePropDefinition[],\n config?: ReturnType<typeof toNativeAutogenConfig>,\n ) => NativeAutogenOutput;\n analyzeSfc?: (\n source: string,\n options?: { filename?: string },\n ) => {\n props: Array<{\n name: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n default_value?: unknown;\n }>;\n emits: string[];\n };\n}\n\nlet native: NativeAutogen | null = null;\n\nfunction loadNative(): NativeAutogen {\n if (native) return native;\n const require = createRequire(import.meta.url);\n try {\n native = require(\"@vizejs/native\") as NativeAutogen;\n return native;\n } catch (e) {\n throw new Error(\n `Failed to load @vizejs/native. Make sure it's installed and built:\\n${String(e)}`,\n );\n }\n}\n\n/**\n * Generate .art.vue file for a component.\n *\n * @param componentPath - Path to the Vue component file\n * @param options - Auto-generation options\n * @returns Generated .art.vue content and metadata\n */\nexport async function generateArtFile(\n componentPath: string,\n options: AutogenOptions = {},\n): Promise<AutogenOutput> {\n const absolutePath = path.resolve(componentPath);\n const source = await fs.promises.readFile(absolutePath, \"utf-8\");\n\n const binding = loadNative();\n\n // Analyze component to extract props\n let props: PropDefinition[];\n if (binding.analyzeSfc) {\n const analysis = binding.analyzeSfc(source, { filename: absolutePath });\n props = analysis.props.map((p) => ({\n name: p.name,\n propType: p.type,\n required: p.required,\n defaultValue: p.defaultValue ?? p.default_value,\n }));\n } else {\n // Fallback: simple regex-based prop extraction\n props = extractPropsSimple(source);\n }\n\n if (props.length === 0) {\n // No props found: generate minimal art file\n const componentName = path.basename(componentPath, \".vue\");\n const relPath = `./${path.basename(componentPath)}`;\n return {\n variants: [{ name: \"Default\", isDefault: true, props: {} }],\n artFileContent: generateMinimalArt(componentName, relPath),\n componentName,\n };\n }\n\n // Use native variant generation if available\n if (binding.generateVariants) {\n const relPath = `./${path.basename(componentPath)}`;\n const result = binding.generateVariants(\n relPath,\n toNativePropDefinitions(props),\n toNativeAutogenConfig(options),\n );\n\n return finalizeArtOutput(fromNativeOutput(result), relPath, props);\n }\n\n // Fallback: JS-based generation\n return generateArtFileJs(componentPath, props, options);\n}\n\n/**\n * Write generated .art.vue file to disk.\n */\nexport async function writeArtFile(\n componentPath: string,\n options: AutogenOptions = {},\n outputPath?: string,\n): Promise<string> {\n const output = await generateArtFile(componentPath, options);\n\n const targetPath = outputPath ?? componentPath.replace(/\\.vue$/, \".art.vue\");\n\n await fs.promises.mkdir(path.dirname(targetPath), { recursive: true });\n await fs.promises.writeFile(targetPath, output.artFileContent, \"utf-8\");\n\n return targetPath;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,mBAAmB,QAAkC;CACnE,MAAM,QAA0B,EAAE;CAGlC,MAAM,aAAa,OAAO,MAAM,qCAAqC;CAErE,IAAI,YAAY;EAEd,MAAM,YADa,WAAW,GACD,MAAM,KAAK;EAExC,KAAK,MAAM,QAAQ,WAAW;GAC5B,MAAM,YAAY,KAAK,MAAM,CAAC,MAAM,gCAAgC;GACpE,IAAI,WACF,MAAM,KAAK;IACT,MAAM,UAAU;IAChB,UAAU,UAAU,GAAG,QAAQ,SAAS,GAAG;IAC3C,UAAU,CAAC,UAAU;IACtB,CAAC;;;CAKR,OAAO;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AAc,QAAQ;CAEhE,MAAM,UAAU,YAAY;CAG5B,IAAI;CACJ,IAAI,QAAQ,YAEV,QADiB,QAAQ,WAAW,QAAQ,EAAE,UAAU,cAAc,CACtD,CAAC,MAAM,KAAK,OAAO;EACjC,MAAM,EAAE;EACR,UAAU,EAAE;EACZ,UAAU,EAAE;EACZ,cAAc,EAAE,gBAAgB,EAAE;EACnC,EAAE;MAGH,QAAQ,mBAAmB,OAAO;CAGpC,IAAI,MAAM,WAAW,GAAG;EAEtB,MAAM,gBAAgB,KAAK,SAAS,eAAe,OAAO;EAE1D,OAAO;GACL,UAAU,CAAC;IAAE,MAAM;IAAW,WAAW;IAAM,OAAO,EAAE;IAAE,CAAC;GAC3D,gBAAgB,mBAAmB,eAAe,KAH/B,KAAK,SAAS,cAAc,GAGW;GAC1D;GACD;;CAIH,IAAI,QAAQ,kBAAkB;EAC5B,MAAM,UAAU,KAAK,KAAK,SAAS,cAAc;EAOjD,OAAO,kBAAkB,iBANV,QAAQ,iBACrB,SACA,wBAAwB,MAAM,EAC9B,sBAAsB,QAAQ,CAGgB,CAAC,EAAE,SAAS,MAAM;;CAIpE,OAAO,kBAAkB,eAAe,OAAO,QAAQ;;;;;AAMzD,eAAsB,aACpB,eACA,UAA0B,EAAE,EAC5B,YACiB;CACjB,MAAM,SAAS,MAAM,gBAAgB,eAAe,QAAQ;CAE5D,MAAM,aAAa,cAAc,cAAc,QAAQ,UAAU,WAAW;CAE5E,MAAM,GAAG,SAAS,MAAM,KAAK,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;CACtE,MAAM,GAAG,SAAS,UAAU,YAAY,OAAO,gBAAgB,QAAQ;CAEvE,OAAO"}
|
package/dist/cli/index.mjs
CHANGED
|
@@ -12,7 +12,13 @@ import path from "node:path";
|
|
|
12
12
|
async function scanArtFiles(root) {
|
|
13
13
|
const files = [];
|
|
14
14
|
async function scan(dir) {
|
|
15
|
-
|
|
15
|
+
let entries;
|
|
16
|
+
try {
|
|
17
|
+
entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error.code === "EACCES") return;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
16
22
|
for (const entry of entries) {
|
|
17
23
|
const fullPath = path.join(dir, entry.name);
|
|
18
24
|
if (entry.name === "node_modules" || entry.name === "dist") continue;
|
package/dist/cli/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/cli/utils.ts","../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["/**\n * CLI utility functions for art file scanning and parsing.\n *\n * Extracted from cli.ts to keep file sizes manageable.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { ArtFileInfo } from \"../types/index.js\";\n\n/** Recursively scan a directory for .art.vue files. */\nexport async function scanArtFiles(root: string): Promise<string[]> {\n const files: string[] = [];\n\n async function scan(dir: string): Promise<void> {\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n // Skip node_modules and dist\n if (entry.name === \"node_modules\" || entry.name === \"dist\") {\n continue;\n }\n\n if (entry.isDirectory()) {\n await scan(fullPath);\n } else if (entry.isFile() && entry.name.endsWith(\".art.vue\")) {\n files.push(fullPath);\n }\n }\n }\n\n await scan(root);\n return files;\n}\n\n/** Parse a single .art.vue file into an ArtFileInfo structure. */\nexport async function parseArtFile(filePath: string): Promise<ArtFileInfo | null> {\n try {\n const source = await fs.promises.readFile(filePath, \"utf-8\");\n\n // Simple parsing - in production, use @vizejs/native\n const titleMatch = source.match(/<art[^>]*\\stitle=[\"']([^\"']+)[\"']/);\n const componentMatch = source.match(/<art[^>]*\\scomponent=[\"']([^\"']+)[\"']/);\n const categoryMatch = source.match(/<art[^>]*\\scategory=[\"']([^\"']+)[\"']/);\n\n const variants: ArtFileInfo[\"variants\"] = [];\n const variantRegex = /<variant\\s+([^>]*)>([\\s\\S]*?)<\\/variant>/g;\n let match;\n\n while ((match = variantRegex.exec(source)) !== null) {\n const attrs = match[1];\n const template = match[2].trim();\n\n const nameMatch = attrs.match(/name=[\"']([^\"']+)[\"']/);\n const isDefault = /\\bdefault\\b/.test(attrs);\n const skipVrt = /\\bskip-vrt\\b/.test(attrs);\n\n if (nameMatch) {\n variants.push({\n name: nameMatch[1],\n template,\n isDefault,\n skipVrt,\n });\n }\n }\n\n return {\n path: filePath,\n metadata: {\n title: titleMatch?.[1] || path.basename(filePath, \".art.vue\"),\n component: componentMatch?.[1],\n category: categoryMatch?.[1],\n tags: [],\n status: \"ready\",\n },\n variants,\n hasScriptSetup: /<script\\s+setup/.test(source),\n hasScript: /<script(?!\\s+setup)/.test(source),\n styleCount: (source.match(/<style/g) || []).length,\n };\n } catch (error) {\n console.error(`Failed to parse ${filePath}:`, error);\n return null;\n }\n}\n","/**\n * CLI command handlers for the Musea VRT tool.\n *\n * Extracted from cli.ts to keep file sizes manageable.\n * Contains the runVrt, runApprove, runClean, and runGenerate command implementations.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { MuseaVrtRunner, generateVrtReport, generateVrtJsonReport } from \"../vrt.js\";\nimport type { VrtSummary } from \"../vrt.js\";\nimport type { ArtFileInfo, VrtOptions } from \"../types/index.js\";\n\nimport type { CliOptions } from \"./index.js\";\n\nexport function hasCiBlockingVrtResult(summary: VrtSummary): boolean {\n return summary.failed > 0 || summary.skipped > 0;\n}\n\nexport async function runVrt(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const totalVariants = artFiles.reduce(\n (sum, art) => sum + art.variants.filter((v) => !v.skipVrt).length,\n 0,\n );\n\n console.log(` Testing ${totalVariants} variant(s) across ${artFiles.length} art file(s)\\n`);\n\n // Initialize VRT runner\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner({\n ...vrtOptions,\n ci: options.ci ? { failOnDiff: true, jsonReport: options.json } : undefined,\n });\n\n try {\n console.log(\" Launching browser...\");\n await runner.init();\n\n console.log(\" Running visual regression tests...\\n\");\n\n // Run tests\n const results = await runner.runAllTests(artFiles, options.baseUrl);\n const summary = runner.getSummary(results);\n\n // Print results\n console.log(\" Results:\");\n console.log(\" ---------\");\n console.log(` Passed: ${summary.passed}`);\n console.log(` Failed: ${summary.failed}`);\n console.log(` New: ${summary.new}`);\n console.log(` Skipped: ${summary.skipped}`);\n console.log(` Total: ${summary.total}`);\n console.log(` Duration: ${(summary.duration / 1000).toFixed(2)}s\\n`);\n\n // Run a11y audits if requested\n if (options.a11y) {\n console.log(\" Running accessibility audits...\\n\");\n try {\n const { MuseaA11yRunner } = await import(\"../a11y/index.js\");\n const a11yRunner = new MuseaA11yRunner();\n const a11yResults = await a11yRunner.runAudits(artFiles, options.baseUrl, runner);\n const a11ySummary = a11yRunner.getSummary(a11yResults);\n\n console.log(\" A11y Results:\");\n console.log(\" -------------\");\n console.log(` Components: ${a11ySummary.totalComponents}`);\n console.log(` Variants: ${a11ySummary.totalVariants}`);\n console.log(` Violations: ${a11ySummary.totalViolations}`);\n console.log(` Critical: ${a11ySummary.criticalCount}`);\n console.log(` Serious: ${a11ySummary.seriousCount}\\n`);\n\n // Generate a11y report\n const reportDir = options.output;\n await fs.promises.mkdir(reportDir, { recursive: true });\n\n if (options.json) {\n const a11yJson = a11yRunner.generateJsonReport(a11yResults);\n const a11yPath = path.join(reportDir, \"a11y-report.json\");\n await fs.promises.writeFile(a11yPath, a11yJson);\n console.log(` A11y JSON report: ${a11yPath}\\n`);\n } else {\n const a11yHtml = a11yRunner.generateHtmlReport(a11yResults);\n const a11yPath = path.join(reportDir, \"a11y-report.html\");\n await fs.promises.writeFile(a11yPath, a11yHtml);\n console.log(` A11y HTML report: ${a11yPath}\\n`);\n }\n\n // CI mode - exit with error on critical/serious violations\n if (options.ci && (a11ySummary.criticalCount > 0 || a11ySummary.seriousCount > 0)) {\n console.log(\" CI mode: Accessibility violations found\\n\");\n process.exit(1);\n }\n } catch (e) {\n console.warn(\" A11y audits skipped:\", e instanceof Error ? e.message : String(e));\n console.warn(\" Make sure axe-core is installed: npm install axe-core\\n\");\n }\n }\n\n // Update baselines if requested\n if (options.update) {\n console.log(\" Updating baselines...\");\n const updated = await runner.updateBaselines(results);\n console.log(` Updated ${updated} baseline(s)\\n`);\n }\n\n // Generate VRT report\n const reportDir = options.output;\n await fs.promises.mkdir(reportDir, { recursive: true });\n\n if (options.json) {\n const jsonReport = generateVrtJsonReport(results, summary);\n const jsonPath = path.join(reportDir, \"vrt-report.json\");\n await fs.promises.writeFile(jsonPath, jsonReport);\n console.log(` JSON report: ${jsonPath}\\n`);\n } else {\n const htmlReport = generateVrtReport(results, summary);\n const htmlPath = path.join(reportDir, \"vrt-report.html\");\n await fs.promises.writeFile(htmlPath, htmlReport);\n console.log(` HTML report: ${htmlPath}\\n`);\n }\n\n // CI mode - exit with error if visual diffs or capture/runtime errors occurred.\n if (options.ci && hasCiBlockingVrtResult(summary)) {\n console.log(\" CI mode: Exiting with error due to failures\\n\");\n process.exit(1);\n }\n } finally {\n await runner.close();\n }\n}\n\nexport async function runApprove(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner(vrtOptions);\n\n try {\n console.log(\" Launching browser...\");\n await runner.init();\n\n console.log(\" Running tests to find diffs...\\n\");\n\n const results = await runner.runAllTests(artFiles, options.baseUrl);\n const failed = results.filter((r) => !r.passed && !r.error);\n\n if (failed.length === 0) {\n console.log(\" No failed tests to approve.\\n\");\n return;\n }\n\n const pattern = options.pattern;\n if (pattern) {\n console.log(` Approving snapshots matching: ${pattern}\\n`);\n } else {\n console.log(` Approving all ${failed.length} failed snapshot(s)...\\n`);\n }\n\n const approved = await runner.approveResults(results, pattern);\n console.log(` Approved ${approved} snapshot(s)\\n`);\n } finally {\n await runner.close();\n }\n}\n\nexport async function runClean(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner(vrtOptions);\n\n console.log(\" Scanning for orphaned snapshots...\\n\");\n\n const cleaned = await runner.cleanOrphans(artFiles);\n\n if (cleaned === 0) {\n console.log(\" No orphaned snapshots found.\\n\");\n } else {\n console.log(`\\n Cleaned ${cleaned} orphaned snapshot(s)\\n`);\n }\n}\n\nexport async function runGenerate(options: CliOptions): Promise<void> {\n if (!options.componentPath) {\n console.error(\" Error: Missing component path.\");\n console.error(\" Usage: musea-vrt generate <component.vue>\\n\");\n process.exit(1);\n }\n\n const componentPath = path.resolve(options.componentPath);\n\n // Check file exists\n try {\n await fs.promises.access(componentPath);\n } catch {\n console.error(` Error: File not found: ${componentPath}\\n`);\n process.exit(1);\n }\n\n console.log(` Generating art file for: ${path.relative(process.cwd(), componentPath)}\\n`);\n\n try {\n const { writeArtFile } = await import(\"../autogen/index.js\");\n const outputPath = await writeArtFile(componentPath);\n const relOutput = path.relative(process.cwd(), outputPath);\n\n console.log(` Generated: ${relOutput}\\n`);\n } catch (e) {\n console.error(\" Generation failed:\", e instanceof Error ? e.message : String(e));\n process.exit(1);\n }\n}\n","#!/usr/bin/env node\n/**\n * Musea CLI\n *\n * Usage:\n * musea-vrt [command] [options]\n *\n * Commands:\n * (default) Run VRT tests\n * approve [pat] Approve failed snapshots (optionally filtered by pattern)\n * clean Remove orphaned snapshots\n *\n * Options:\n * -u, --update Update baseline snapshots\n * -c, --config Path to vite config (default: vite.config.ts)\n * -o, --output Output directory for reports (default: .vize)\n * -t, --threshold Diff threshold percentage (default: 0.1)\n * --json Output JSON report instead of HTML\n * --ci CI mode - exit with non-zero code on failures\n * --a11y Run accessibility audits alongside VRT\n * -h, --help Show help\n */\n\nimport type { ArtFileInfo } from \"../types/index.js\";\nimport { scanArtFiles, parseArtFile } from \"./utils.js\";\nimport { runVrt, runApprove, runClean, runGenerate } from \"./commands.js\";\n\ntype Command = \"run\" | \"approve\" | \"clean\" | \"generate\";\n\nexport interface CliOptions {\n command: Command;\n update: boolean;\n config: string;\n output: string;\n threshold: number;\n json: boolean;\n ci: boolean;\n a11y: boolean;\n help: boolean;\n baseUrl: string;\n pattern?: string;\n componentPath?: string;\n}\n\nfunction parseArgs(args: string[]): CliOptions {\n const options: CliOptions = {\n command: \"run\",\n update: false,\n config: \"vite.config.ts\",\n output: \".vize\",\n threshold: 0.1,\n json: false,\n ci: false,\n a11y: false,\n help: false,\n baseUrl: \"http://localhost:5173\",\n };\n\n let i = 0;\n\n // Check for subcommand as first arg\n if (args.length > 0 && !args[0].startsWith(\"-\")) {\n const sub = args[0];\n if (sub === \"approve\") {\n options.command = \"approve\";\n i = 1;\n // Optional pattern argument after approve\n if (args.length > 1 && !args[1].startsWith(\"-\")) {\n options.pattern = args[1];\n i = 2;\n }\n } else if (sub === \"clean\") {\n options.command = \"clean\";\n i = 1;\n } else if (sub === \"generate\") {\n options.command = \"generate\";\n i = 1;\n // Required component path argument\n if (args.length > 1 && !args[1].startsWith(\"-\")) {\n options.componentPath = args[1];\n i = 2;\n }\n }\n }\n\n for (; i < args.length; i++) {\n const arg = args[i];\n switch (arg) {\n case \"-u\":\n case \"--update\":\n options.update = true;\n break;\n case \"-c\":\n case \"--config\":\n options.config = args[++i] || \"vite.config.ts\";\n break;\n case \"-o\":\n case \"--output\":\n options.output = args[++i] || \".vize\";\n break;\n case \"-t\":\n case \"--threshold\":\n options.threshold = parseFloat(args[++i]) || 0.1;\n break;\n case \"--json\":\n options.json = true;\n break;\n case \"--ci\":\n options.ci = true;\n break;\n case \"--a11y\":\n options.a11y = true;\n break;\n case \"-b\":\n case \"--base-url\":\n options.baseUrl = args[++i] || \"http://localhost:5173\";\n break;\n case \"-h\":\n case \"--help\":\n options.help = true;\n break;\n }\n }\n\n return options;\n}\n\nfunction printHelp(): void {\n console.log(`\nMusea VRT - Visual Regression Testing for Component Gallery\n\nUsage:\n musea-vrt [command] [options]\n\nCommands:\n (default) Run VRT tests\n approve [pattern] Approve failed snapshots and update baselines\n Optional pattern filters which snapshots to approve\n clean Remove orphaned snapshots (no matching art/variant)\n generate <component> Auto-generate .art.vue from a Vue component\n\nOptions:\n -u, --update Update baseline snapshots with current screenshots\n -c, --config <path> Path to vite config file (default: vite.config.ts)\n -o, --output <dir> Output directory for reports (default: .vize)\n -t, --threshold <n> Diff threshold percentage (default: 0.1)\n -b, --base-url <url> Base URL for dev server (default: http://localhost:5173)\n --json Output JSON report instead of HTML\n --ci CI mode - exit with non-zero code on failures\n --a11y Run accessibility audits alongside VRT\n -h, --help Show this help message\n\nExamples:\n # Run VRT tests\n musea-vrt\n\n # Update baseline snapshots\n musea-vrt -u\n\n # Run with custom threshold\n musea-vrt -t 0.5\n\n # CI mode with JSON output\n musea-vrt --ci --json\n\n # Run with accessibility audits\n musea-vrt --a11y\n\n # Approve all failed snapshots\n musea-vrt approve\n\n # Approve specific snapshots by pattern\n musea-vrt approve \"Button/*\"\n\n # Clean orphaned snapshots\n musea-vrt clean\n\n # Auto-generate .art.vue from component\n musea-vrt generate src/components/Button.vue\n\n # Custom base URL\n musea-vrt -b http://localhost:3000\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const options = parseArgs(args);\n\n if (options.help) {\n printHelp();\n process.exit(0);\n }\n\n const cwd = process.cwd();\n\n console.log(\"\\n Musea VRT\");\n console.log(\" =========\\n\");\n\n // Handle generate command early (doesn't need art file scanning)\n if (options.command === \"generate\") {\n try {\n await runGenerate(options);\n } catch (error) {\n console.error(\"\\n Error:\", error);\n process.exit(1);\n }\n return;\n }\n\n // Scan for art files\n console.log(\" Scanning for art files...\");\n const artFilePaths = await scanArtFiles(cwd);\n\n if (artFilePaths.length === 0) {\n console.log(\" No art files found.\\n\");\n process.exit(0);\n }\n\n console.log(` Found ${artFilePaths.length} art file(s)\\n`);\n\n // Parse art files\n const artFiles: ArtFileInfo[] = [];\n for (const filePath of artFilePaths) {\n const art = await parseArtFile(filePath);\n if (art) {\n artFiles.push(art);\n }\n }\n\n try {\n switch (options.command) {\n case \"run\":\n await runVrt(options, artFiles);\n break;\n case \"approve\":\n await runApprove(options, artFiles);\n break;\n case \"clean\":\n await runClean(options, artFiles);\n break;\n case \"generate\":\n // Handled above before art file scanning\n break;\n }\n } catch (error) {\n console.error(\"\\n Error:\", error);\n process.exit(1);\n }\n}\n\nmain().catch((error) => {\n console.error(\"Fatal error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAYA,eAAsB,aAAa,MAAiC;CAClE,MAAM,QAAkB,EAAE;CAE1B,eAAe,KAAK,KAA4B;EAC9C,MAAM,UAAU,MAAM,GAAG,SAAS,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;EAEvE,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK;GAG3C,IAAI,MAAM,SAAS,kBAAkB,MAAM,SAAS,QAClD;GAGF,IAAI,MAAM,aAAa,EACrB,MAAM,KAAK,SAAS;QACf,IAAI,MAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,WAAW,EAC1D,MAAM,KAAK,SAAS;;;CAK1B,MAAM,KAAK,KAAK;CAChB,OAAO;;;AAIT,eAAsB,aAAa,UAA+C;CAChF,IAAI;EACF,MAAM,SAAS,MAAM,GAAG,SAAS,SAAS,UAAU,QAAQ;EAG5D,MAAM,aAAa,OAAO,MAAM,oCAAoC;EACpE,MAAM,iBAAiB,OAAO,MAAM,wCAAwC;EAC5E,MAAM,gBAAgB,OAAO,MAAM,uCAAuC;EAE1E,MAAM,WAAoC,EAAE;EAC5C,MAAM,eAAe;EACrB,IAAI;EAEJ,QAAQ,QAAQ,aAAa,KAAK,OAAO,MAAM,MAAM;GACnD,MAAM,QAAQ,MAAM;GACpB,MAAM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,OAAO;EACd,QAAQ,MAAM,cAAc,MAAM;EAClC,QAAQ,KAAK,EAAE;;;AAInB,MAAM,CAAC,OAAO,UAAU;CACtB,QAAQ,MAAM,gBAAgB,MAAM;CACpC,QAAQ,KAAK,EAAE;EACf"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/cli/utils.ts","../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["/**\n * CLI utility functions for art file scanning and parsing.\n *\n * Extracted from cli.ts to keep file sizes manageable.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { ArtFileInfo } from \"../types/index.js\";\n\n/** Recursively scan a directory for .art.vue files. */\nexport async function scanArtFiles(root: string): Promise<string[]> {\n const files: string[] = [];\n\n async function scan(dir: string): Promise<void> {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(dir, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"EACCES\") {\n return;\n }\n throw error;\n }\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n // Skip node_modules and dist\n if (entry.name === \"node_modules\" || entry.name === \"dist\") {\n continue;\n }\n\n if (entry.isDirectory()) {\n await scan(fullPath);\n } else if (entry.isFile() && entry.name.endsWith(\".art.vue\")) {\n files.push(fullPath);\n }\n }\n }\n\n await scan(root);\n return files;\n}\n\n/** Parse a single .art.vue file into an ArtFileInfo structure. */\nexport async function parseArtFile(filePath: string): Promise<ArtFileInfo | null> {\n try {\n const source = await fs.promises.readFile(filePath, \"utf-8\");\n\n // Simple parsing - in production, use @vizejs/native\n const titleMatch = source.match(/<art[^>]*\\stitle=[\"']([^\"']+)[\"']/);\n const componentMatch = source.match(/<art[^>]*\\scomponent=[\"']([^\"']+)[\"']/);\n const categoryMatch = source.match(/<art[^>]*\\scategory=[\"']([^\"']+)[\"']/);\n\n const variants: ArtFileInfo[\"variants\"] = [];\n const variantRegex = /<variant\\s+([^>]*)>([\\s\\S]*?)<\\/variant>/g;\n let match;\n\n while ((match = variantRegex.exec(source)) !== null) {\n const attrs = match[1];\n const template = match[2].trim();\n\n const nameMatch = attrs.match(/name=[\"']([^\"']+)[\"']/);\n const isDefault = /\\bdefault\\b/.test(attrs);\n const skipVrt = /\\bskip-vrt\\b/.test(attrs);\n\n if (nameMatch) {\n variants.push({\n name: nameMatch[1],\n template,\n isDefault,\n skipVrt,\n });\n }\n }\n\n return {\n path: filePath,\n metadata: {\n title: titleMatch?.[1] || path.basename(filePath, \".art.vue\"),\n component: componentMatch?.[1],\n category: categoryMatch?.[1],\n tags: [],\n status: \"ready\",\n },\n variants,\n hasScriptSetup: /<script\\s+setup/.test(source),\n hasScript: /<script(?!\\s+setup)/.test(source),\n styleCount: (source.match(/<style/g) || []).length,\n };\n } catch (error) {\n console.error(`Failed to parse ${filePath}:`, error);\n return null;\n }\n}\n","/**\n * CLI command handlers for the Musea VRT tool.\n *\n * Extracted from cli.ts to keep file sizes manageable.\n * Contains the runVrt, runApprove, runClean, and runGenerate command implementations.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { MuseaVrtRunner, generateVrtReport, generateVrtJsonReport } from \"../vrt.js\";\nimport type { VrtSummary } from \"../vrt.js\";\nimport type { ArtFileInfo, VrtOptions } from \"../types/index.js\";\n\nimport type { CliOptions } from \"./index.js\";\n\nexport function hasCiBlockingVrtResult(summary: VrtSummary): boolean {\n return summary.failed > 0 || summary.skipped > 0;\n}\n\nexport async function runVrt(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const totalVariants = artFiles.reduce(\n (sum, art) => sum + art.variants.filter((v) => !v.skipVrt).length,\n 0,\n );\n\n console.log(` Testing ${totalVariants} variant(s) across ${artFiles.length} art file(s)\\n`);\n\n // Initialize VRT runner\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner({\n ...vrtOptions,\n ci: options.ci ? { failOnDiff: true, jsonReport: options.json } : undefined,\n });\n\n try {\n console.log(\" Launching browser...\");\n await runner.init();\n\n console.log(\" Running visual regression tests...\\n\");\n\n // Run tests\n const results = await runner.runAllTests(artFiles, options.baseUrl);\n const summary = runner.getSummary(results);\n\n // Print results\n console.log(\" Results:\");\n console.log(\" ---------\");\n console.log(` Passed: ${summary.passed}`);\n console.log(` Failed: ${summary.failed}`);\n console.log(` New: ${summary.new}`);\n console.log(` Skipped: ${summary.skipped}`);\n console.log(` Total: ${summary.total}`);\n console.log(` Duration: ${(summary.duration / 1000).toFixed(2)}s\\n`);\n\n // Run a11y audits if requested\n if (options.a11y) {\n console.log(\" Running accessibility audits...\\n\");\n try {\n const { MuseaA11yRunner } = await import(\"../a11y/index.js\");\n const a11yRunner = new MuseaA11yRunner();\n const a11yResults = await a11yRunner.runAudits(artFiles, options.baseUrl, runner);\n const a11ySummary = a11yRunner.getSummary(a11yResults);\n\n console.log(\" A11y Results:\");\n console.log(\" -------------\");\n console.log(` Components: ${a11ySummary.totalComponents}`);\n console.log(` Variants: ${a11ySummary.totalVariants}`);\n console.log(` Violations: ${a11ySummary.totalViolations}`);\n console.log(` Critical: ${a11ySummary.criticalCount}`);\n console.log(` Serious: ${a11ySummary.seriousCount}\\n`);\n\n // Generate a11y report\n const reportDir = options.output;\n await fs.promises.mkdir(reportDir, { recursive: true });\n\n if (options.json) {\n const a11yJson = a11yRunner.generateJsonReport(a11yResults);\n const a11yPath = path.join(reportDir, \"a11y-report.json\");\n await fs.promises.writeFile(a11yPath, a11yJson);\n console.log(` A11y JSON report: ${a11yPath}\\n`);\n } else {\n const a11yHtml = a11yRunner.generateHtmlReport(a11yResults);\n const a11yPath = path.join(reportDir, \"a11y-report.html\");\n await fs.promises.writeFile(a11yPath, a11yHtml);\n console.log(` A11y HTML report: ${a11yPath}\\n`);\n }\n\n // CI mode - exit with error on critical/serious violations\n if (options.ci && (a11ySummary.criticalCount > 0 || a11ySummary.seriousCount > 0)) {\n console.log(\" CI mode: Accessibility violations found\\n\");\n process.exit(1);\n }\n } catch (e) {\n console.warn(\" A11y audits skipped:\", e instanceof Error ? e.message : String(e));\n console.warn(\" Make sure axe-core is installed: npm install axe-core\\n\");\n }\n }\n\n // Update baselines if requested\n if (options.update) {\n console.log(\" Updating baselines...\");\n const updated = await runner.updateBaselines(results);\n console.log(` Updated ${updated} baseline(s)\\n`);\n }\n\n // Generate VRT report\n const reportDir = options.output;\n await fs.promises.mkdir(reportDir, { recursive: true });\n\n if (options.json) {\n const jsonReport = generateVrtJsonReport(results, summary);\n const jsonPath = path.join(reportDir, \"vrt-report.json\");\n await fs.promises.writeFile(jsonPath, jsonReport);\n console.log(` JSON report: ${jsonPath}\\n`);\n } else {\n const htmlReport = generateVrtReport(results, summary);\n const htmlPath = path.join(reportDir, \"vrt-report.html\");\n await fs.promises.writeFile(htmlPath, htmlReport);\n console.log(` HTML report: ${htmlPath}\\n`);\n }\n\n // CI mode - exit with error if visual diffs or capture/runtime errors occurred.\n if (options.ci && hasCiBlockingVrtResult(summary)) {\n console.log(\" CI mode: Exiting with error due to failures\\n\");\n process.exit(1);\n }\n } finally {\n await runner.close();\n }\n}\n\nexport async function runApprove(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner(vrtOptions);\n\n try {\n console.log(\" Launching browser...\");\n await runner.init();\n\n console.log(\" Running tests to find diffs...\\n\");\n\n const results = await runner.runAllTests(artFiles, options.baseUrl);\n const failed = results.filter((r) => !r.passed && !r.error);\n\n if (failed.length === 0) {\n console.log(\" No failed tests to approve.\\n\");\n return;\n }\n\n const pattern = options.pattern;\n if (pattern) {\n console.log(` Approving snapshots matching: ${pattern}\\n`);\n } else {\n console.log(` Approving all ${failed.length} failed snapshot(s)...\\n`);\n }\n\n const approved = await runner.approveResults(results, pattern);\n console.log(` Approved ${approved} snapshot(s)\\n`);\n } finally {\n await runner.close();\n }\n}\n\nexport async function runClean(options: CliOptions, artFiles: ArtFileInfo[]): Promise<void> {\n const vrtOptions: VrtOptions = {\n snapshotDir: path.join(options.output, \"snapshots\"),\n threshold: options.threshold,\n };\n\n const runner = new MuseaVrtRunner(vrtOptions);\n\n console.log(\" Scanning for orphaned snapshots...\\n\");\n\n const cleaned = await runner.cleanOrphans(artFiles);\n\n if (cleaned === 0) {\n console.log(\" No orphaned snapshots found.\\n\");\n } else {\n console.log(`\\n Cleaned ${cleaned} orphaned snapshot(s)\\n`);\n }\n}\n\nexport async function runGenerate(options: CliOptions): Promise<void> {\n if (!options.componentPath) {\n console.error(\" Error: Missing component path.\");\n console.error(\" Usage: musea-vrt generate <component.vue>\\n\");\n process.exit(1);\n }\n\n const componentPath = path.resolve(options.componentPath);\n\n // Check file exists\n try {\n await fs.promises.access(componentPath);\n } catch {\n console.error(` Error: File not found: ${componentPath}\\n`);\n process.exit(1);\n }\n\n console.log(` Generating art file for: ${path.relative(process.cwd(), componentPath)}\\n`);\n\n try {\n const { writeArtFile } = await import(\"../autogen/index.js\");\n const outputPath = await writeArtFile(componentPath);\n const relOutput = path.relative(process.cwd(), outputPath);\n\n console.log(` Generated: ${relOutput}\\n`);\n } catch (e) {\n console.error(\" Generation failed:\", e instanceof Error ? e.message : String(e));\n process.exit(1);\n }\n}\n","#!/usr/bin/env node\n/**\n * Musea CLI\n *\n * Usage:\n * musea-vrt [command] [options]\n *\n * Commands:\n * (default) Run VRT tests\n * approve [pat] Approve failed snapshots (optionally filtered by pattern)\n * clean Remove orphaned snapshots\n *\n * Options:\n * -u, --update Update baseline snapshots\n * -c, --config Path to vite config (default: vite.config.ts)\n * -o, --output Output directory for reports (default: .vize)\n * -t, --threshold Diff threshold percentage (default: 0.1)\n * --json Output JSON report instead of HTML\n * --ci CI mode - exit with non-zero code on failures\n * --a11y Run accessibility audits alongside VRT\n * -h, --help Show help\n */\n\nimport type { ArtFileInfo } from \"../types/index.js\";\nimport { scanArtFiles, parseArtFile } from \"./utils.js\";\nimport { runVrt, runApprove, runClean, runGenerate } from \"./commands.js\";\n\ntype Command = \"run\" | \"approve\" | \"clean\" | \"generate\";\n\nexport interface CliOptions {\n command: Command;\n update: boolean;\n config: string;\n output: string;\n threshold: number;\n json: boolean;\n ci: boolean;\n a11y: boolean;\n help: boolean;\n baseUrl: string;\n pattern?: string;\n componentPath?: string;\n}\n\nfunction parseArgs(args: string[]): CliOptions {\n const options: CliOptions = {\n command: \"run\",\n update: false,\n config: \"vite.config.ts\",\n output: \".vize\",\n threshold: 0.1,\n json: false,\n ci: false,\n a11y: false,\n help: false,\n baseUrl: \"http://localhost:5173\",\n };\n\n let i = 0;\n\n // Check for subcommand as first arg\n if (args.length > 0 && !args[0].startsWith(\"-\")) {\n const sub = args[0];\n if (sub === \"approve\") {\n options.command = \"approve\";\n i = 1;\n // Optional pattern argument after approve\n if (args.length > 1 && !args[1].startsWith(\"-\")) {\n options.pattern = args[1];\n i = 2;\n }\n } else if (sub === \"clean\") {\n options.command = \"clean\";\n i = 1;\n } else if (sub === \"generate\") {\n options.command = \"generate\";\n i = 1;\n // Required component path argument\n if (args.length > 1 && !args[1].startsWith(\"-\")) {\n options.componentPath = args[1];\n i = 2;\n }\n }\n }\n\n for (; i < args.length; i++) {\n const arg = args[i];\n switch (arg) {\n case \"-u\":\n case \"--update\":\n options.update = true;\n break;\n case \"-c\":\n case \"--config\":\n options.config = args[++i] || \"vite.config.ts\";\n break;\n case \"-o\":\n case \"--output\":\n options.output = args[++i] || \".vize\";\n break;\n case \"-t\":\n case \"--threshold\":\n options.threshold = parseFloat(args[++i]) || 0.1;\n break;\n case \"--json\":\n options.json = true;\n break;\n case \"--ci\":\n options.ci = true;\n break;\n case \"--a11y\":\n options.a11y = true;\n break;\n case \"-b\":\n case \"--base-url\":\n options.baseUrl = args[++i] || \"http://localhost:5173\";\n break;\n case \"-h\":\n case \"--help\":\n options.help = true;\n break;\n }\n }\n\n return options;\n}\n\nfunction printHelp(): void {\n console.log(`\nMusea VRT - Visual Regression Testing for Component Gallery\n\nUsage:\n musea-vrt [command] [options]\n\nCommands:\n (default) Run VRT tests\n approve [pattern] Approve failed snapshots and update baselines\n Optional pattern filters which snapshots to approve\n clean Remove orphaned snapshots (no matching art/variant)\n generate <component> Auto-generate .art.vue from a Vue component\n\nOptions:\n -u, --update Update baseline snapshots with current screenshots\n -c, --config <path> Path to vite config file (default: vite.config.ts)\n -o, --output <dir> Output directory for reports (default: .vize)\n -t, --threshold <n> Diff threshold percentage (default: 0.1)\n -b, --base-url <url> Base URL for dev server (default: http://localhost:5173)\n --json Output JSON report instead of HTML\n --ci CI mode - exit with non-zero code on failures\n --a11y Run accessibility audits alongside VRT\n -h, --help Show this help message\n\nExamples:\n # Run VRT tests\n musea-vrt\n\n # Update baseline snapshots\n musea-vrt -u\n\n # Run with custom threshold\n musea-vrt -t 0.5\n\n # CI mode with JSON output\n musea-vrt --ci --json\n\n # Run with accessibility audits\n musea-vrt --a11y\n\n # Approve all failed snapshots\n musea-vrt approve\n\n # Approve specific snapshots by pattern\n musea-vrt approve \"Button/*\"\n\n # Clean orphaned snapshots\n musea-vrt clean\n\n # Auto-generate .art.vue from component\n musea-vrt generate src/components/Button.vue\n\n # Custom base URL\n musea-vrt -b http://localhost:3000\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const options = parseArgs(args);\n\n if (options.help) {\n printHelp();\n process.exit(0);\n }\n\n const cwd = process.cwd();\n\n console.log(\"\\n Musea VRT\");\n console.log(\" =========\\n\");\n\n // Handle generate command early (doesn't need art file scanning)\n if (options.command === \"generate\") {\n try {\n await runGenerate(options);\n } catch (error) {\n console.error(\"\\n Error:\", error);\n process.exit(1);\n }\n return;\n }\n\n // Scan for art files\n console.log(\" Scanning for art files...\");\n const artFilePaths = await scanArtFiles(cwd);\n\n if (artFilePaths.length === 0) {\n console.log(\" No art files found.\\n\");\n process.exit(0);\n }\n\n console.log(` Found ${artFilePaths.length} art file(s)\\n`);\n\n // Parse art files\n const artFiles: ArtFileInfo[] = [];\n for (const filePath of artFilePaths) {\n const art = await parseArtFile(filePath);\n if (art) {\n artFiles.push(art);\n }\n }\n\n try {\n switch (options.command) {\n case \"run\":\n await runVrt(options, artFiles);\n break;\n case \"approve\":\n await runApprove(options, artFiles);\n break;\n case \"clean\":\n await runClean(options, artFiles);\n break;\n case \"generate\":\n // Handled above before art file scanning\n break;\n }\n } catch (error) {\n console.error(\"\\n Error:\", error);\n process.exit(1);\n }\n}\n\nmain().catch((error) => {\n console.error(\"Fatal error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAYA,eAAsB,aAAa,MAAiC;CAClE,MAAM,QAAkB,EAAE;CAE1B,eAAe,KAAK,KAA4B;EAC9C,IAAI;EACJ,IAAI;GACF,UAAU,MAAM,GAAG,SAAS,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;WAC1D,OAAO;GACd,IAAK,MAAgC,SAAS,UAC5C;GAEF,MAAM;;EAGR,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK;GAG3C,IAAI,MAAM,SAAS,kBAAkB,MAAM,SAAS,QAClD;GAGF,IAAI,MAAM,aAAa,EACrB,MAAM,KAAK,SAAS;QACf,IAAI,MAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,WAAW,EAC1D,MAAM,KAAK,SAAS;;;CAK1B,MAAM,KAAK,KAAK;CAChB,OAAO;;;AAIT,eAAsB,aAAa,UAA+C;CAChF,IAAI;EACF,MAAM,SAAS,MAAM,GAAG,SAAS,SAAS,UAAU,QAAQ;EAG5D,MAAM,aAAa,OAAO,MAAM,oCAAoC;EACpE,MAAM,iBAAiB,OAAO,MAAM,wCAAwC;EAC5E,MAAM,gBAAgB,OAAO,MAAM,uCAAuC;EAE1E,MAAM,WAAoC,EAAE;EAC5C,MAAM,eAAe;EACrB,IAAI;EAEJ,QAAQ,QAAQ,aAAa,KAAK,OAAO,M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SAAS,SAAS,SAAS;IACjC;GACF,KAAK,YAEH;;UAEG,OAAO;EACd,QAAQ,MAAM,cAAc,MAAM;EAClC,QAAQ,KAAK,EAAE;;;AAInB,MAAM,CAAC,OAAO,UAAU;CACtB,QAAQ,MAAM,gBAAgB,MAAM;CACpC,QAAQ,KAAK,EAAE;EACf"}
|
package/dist/index.d.mts
CHANGED
|
@@ -85,6 +85,17 @@ interface MuseaOptions {
|
|
|
85
85
|
* @example 'src/tokens.json', 'src/tokens/', or 'src/styles/main.css'
|
|
86
86
|
*/
|
|
87
87
|
tokensPath?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Project root that should be treated as the outer boundary for path resolution
|
|
90
|
+
* (notably `tokensPath`). When set, sibling directories of the Vite root that
|
|
91
|
+
* live under this project root are allowed.
|
|
92
|
+
*
|
|
93
|
+
* Frameworks like Nuxt set this to their project root so a Vite app rooted at
|
|
94
|
+
* `app/` can still load tokens from `<project>/design/tokens`.
|
|
95
|
+
*
|
|
96
|
+
* Defaults to the Vite root when unset.
|
|
97
|
+
*/
|
|
98
|
+
projectRoot?: string;
|
|
88
99
|
/**
|
|
89
100
|
* Gallery theme configuration.
|
|
90
101
|
*
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/plugin.ts","../src/plugin/index.ts","../src/tokens/parser.ts","../src/tokens/usage.ts","../src/tokens/resolver.ts","../src/tokens/generator.ts"],"mappings":";;;;;;;;;;UAMiB,gBAAA;EACf,SAAA;EACA,WAAA;EACA,UAAA;EACA,UAAA;EACA,MAAA;EACA,WAAA;EACA,cAAA;EACA,YAAA;EACA,IAAA;EACA,aAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;EACA,OAAA;EACA,KAAA;EACA,IAAA;EACA,OAAA;EACA,MAAA;AAAA;;;;UAMe,UAAA;EANT;EAQN,IAAA;EAFyB;EAIzB,IAAA;EAEwB;EAAxB,MAAA,EAAQ,gBAAA;AAAA;;;;UAMO,YAAA;EAAA;;;;EAKf,OAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/plugin.ts","../src/plugin/index.ts","../src/tokens/parser.ts","../src/tokens/usage.ts","../src/tokens/resolver.ts","../src/tokens/generator.ts"],"mappings":";;;;;;;;;;UAMiB,gBAAA;EACf,SAAA;EACA,WAAA;EACA,UAAA;EACA,UAAA;EACA,MAAA;EACA,WAAA;EACA,cAAA;EACA,YAAA;EACA,IAAA;EACA,aAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;EACA,OAAA;EACA,KAAA;EACA,IAAA;EACA,OAAA;EACA,MAAA;AAAA;;;;UAMe,UAAA;EANT;EAQN,IAAA;EAFyB;EAIzB,IAAA;EAEwB;EAAxB,MAAA,EAAQ,gBAAA;AAAA;;;;UAMO,YAAA;EAAA;;;;EAKf,OAAA;EAkEmD;;;;EA5DnD,OAAA;EAMA;;;;EAAA,QAAA;EAyBM;;;;EAnBN,eAAA;EAgDmD;;;;EA1CnD,eAAA;;;;AChCF;;;EDwCE,SAAA;ECxC6B;;;ED6C7B,GAAA,GAAM,UAAA;EC7CiD;;;;AC3BzD;EF+EE,UAAA;;;;;;;;;;;EAYA,WAAA;EEpFc;AAMhB;;;;;;;EFwFE,KAAA,iCAAsC,UAAA,GAAa,UAAA;EEvFnD;;;;;;;;EFiGA,UAAA;EEzFoC;;;;;;;;;;EFqGpC,YAAA;AAAA;;;iBChGc,KAAA,CAAM,OAAA,GAAS,YAAA,GAAoB,MAAA;;;;;;;;;ADjCnD;;UEMiB,WAAA;EACf,KAAA;EACA,IAAA;EACA,WAAA;EACA,UAAA,GAAa,MAAA;EACb,KAAA;EACA,UAAA;EACA,cAAA;AAAA;;;;UAMe,aAAA;EACf,IAAA;EACA,MAAA,EAAQ,MAAA,SAAe,WAAA;EACvB,aAAA,GAAgB,aAAA;AAAA;;;;UAMD,qBAAA;EACf,UAAA,EAAY,aAAA;EACZ,QAAA;IACE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