@animus-ui/vite-plugin 0.1.0-next.1 → 0.1.0-next.8
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/index.d.ts.map +1 -1
- package/dist/index.mjs +24 -12
- package/dist/theme-evaluator.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAM3C,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8FAA8F;IAC9F,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAM3C,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8FAA8F;IAC9F,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6RD,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAw7BxE;AAED,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,eAAe,aAAa,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -65,15 +65,11 @@ function buildVariableCss(theme) {
|
|
|
65
65
|
}
|
|
66
66
|
if (rootLines.length > 0) parts.push(`:root {\n${rootLines.join("\n")}\n}`);
|
|
67
67
|
}
|
|
68
|
-
if (theme._tokens?.modes != null && typeof theme._tokens.modes === "object") {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const modeLines = [];
|
|
74
|
-
flattenModeTokens(modeLines, modeTokens, "");
|
|
75
|
-
if (modeLines.length > 0) parts.push(`[data-color-mode="${modeName}"] {\n${modeLines.join("\n")}\n}`);
|
|
76
|
-
}
|
|
68
|
+
if (theme._tokens?.modes != null && typeof theme._tokens.modes === "object") for (const [modeName, modeTokens] of Object.entries(theme._tokens.modes)) {
|
|
69
|
+
if (modeTokens == null || typeof modeTokens !== "object") continue;
|
|
70
|
+
const modeLines = [];
|
|
71
|
+
flattenModeTokens(modeLines, modeTokens, "");
|
|
72
|
+
if (modeLines.length > 0) parts.push(`[data-color-mode="${modeName}"] {\n${modeLines.join("\n")}\n}`);
|
|
77
73
|
}
|
|
78
74
|
return parts.join("\n\n");
|
|
79
75
|
}
|
|
@@ -118,6 +114,8 @@ const VIRTUAL_COMPONENTS_ID = "virtual:animus/components.js";
|
|
|
118
114
|
const RESOLVED_COMPONENTS_ID = "\0virtual:animus/components.js";
|
|
119
115
|
const VIRTUAL_BRIDGE_ID = "virtual:animus/hmr-bridge.js";
|
|
120
116
|
const RESOLVED_BRIDGE_ID = "\0virtual:animus/hmr-bridge.js";
|
|
117
|
+
const VIRTUAL_SYSTEM_PROPS_ID = "virtual:animus/system-props";
|
|
118
|
+
const RESOLVED_SYSTEM_PROPS_ID = "\0virtual:animus/system-props";
|
|
121
119
|
const DEFAULT_EXTENSIONS = new Set([
|
|
122
120
|
".ts",
|
|
123
121
|
".tsx",
|
|
@@ -226,7 +224,7 @@ const UNITLESS_PROPERTIES = new Set([
|
|
|
226
224
|
* Numbers inside CSS function calls (cubic-bezier, rgb, calc, etc.) are skipped.
|
|
227
225
|
*/
|
|
228
226
|
function applyUnitFallback(css) {
|
|
229
|
-
return css.replace(/([a-z-]+)\s*:\s*([^;]+);/g, (match, prop, value) => {
|
|
227
|
+
return css.replace(/([a-z-]+)\s*:\s*([^;{}]+);/g, (match, prop, value) => {
|
|
230
228
|
if (UNITLESS_PROPERTIES.has(prop)) return match;
|
|
231
229
|
let depth = 0;
|
|
232
230
|
let fixed = "";
|
|
@@ -332,6 +330,7 @@ function animusExtract(options = {}) {
|
|
|
332
330
|
let storedManifestJson = "";
|
|
333
331
|
let resolvedComponentCss = "";
|
|
334
332
|
let storedSheets = null;
|
|
333
|
+
let storedSystemPropMapJson = "{}";
|
|
335
334
|
const fileCache = /* @__PURE__ */ new Map();
|
|
336
335
|
let packageMap = {};
|
|
337
336
|
let bridgeInjected = false;
|
|
@@ -424,7 +423,7 @@ function animusExtract(options = {}) {
|
|
|
424
423
|
const ts = Date.now();
|
|
425
424
|
const tmpScript = join(tmpdir(), `animus-system-${ts}.js`);
|
|
426
425
|
const tmpOut = join(tmpdir(), `animus-system-${ts}.json`);
|
|
427
|
-
writeFileSync(tmpScript, `const m = require(${JSON.stringify(resolvedSystemPath)});\nconst ds = m.ds || m.default || m.system;\nif (!ds || !ds.serialize) { throw new Error('Module does not export a SystemInstance with .serialize()'); }\nconst cfg = ds.serialize();\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify({\n propConfig: cfg.propConfig,\n groupRegistry: cfg.groupRegistry,\n tokens:
|
|
426
|
+
writeFileSync(tmpScript, `const m = require(${JSON.stringify(resolvedSystemPath)});\nconst ds = m.ds || m.default || m.system;\nif (!ds || !ds.serialize) { throw new Error('Module does not export a SystemInstance with .serialize()'); }\nconst cfg = ds.serialize();\nconst tokens = m.tokens || m.theme || null;\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify({\n propConfig: cfg.propConfig,\n groupRegistry: cfg.groupRegistry,\n tokens: tokens,\n transformNames: Object.keys(cfg.transforms || {}),\n globalStyles: cfg.globalStyles || null\n}));\n`);
|
|
428
427
|
execSync(`bun run "${tmpScript}"`, {
|
|
429
428
|
cwd: rootDir,
|
|
430
429
|
encoding: "utf-8"
|
|
@@ -442,7 +441,7 @@ function animusExtract(options = {}) {
|
|
|
442
441
|
themeJson = result.scalesJson;
|
|
443
442
|
variableMapJson = result.variableMapJson;
|
|
444
443
|
variableCss = result.variableCss;
|
|
445
|
-
}
|
|
444
|
+
} else if (logger) logger.warn("[animus] No tokens export found in system module — CSS variables will not be generated. Export your theme as `tokens` or `theme`.");
|
|
446
445
|
if (parsed.globalStyles) {
|
|
447
446
|
const hasReset = parsed.globalStyles.reset && Object.keys(parsed.globalStyles.reset).length > 0;
|
|
448
447
|
const hasGlobal = parsed.globalStyles.global && Object.keys(parsed.globalStyles.global).length > 0;
|
|
@@ -494,6 +493,7 @@ function animusExtract(options = {}) {
|
|
|
494
493
|
const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd);
|
|
495
494
|
storedManifest = JSON.parse(manifestJson);
|
|
496
495
|
storedManifestJson = manifestJson;
|
|
496
|
+
storedSystemPropMapJson = JSON.stringify(storedManifest?.system_prop_map ?? {});
|
|
497
497
|
bridgeInjected = false;
|
|
498
498
|
storedSheets = storedManifest?.sheets ?? null;
|
|
499
499
|
const rawCss = storedManifest?.css || "";
|
|
@@ -643,6 +643,7 @@ function animusExtract(options = {}) {
|
|
|
643
643
|
if (id === VIRTUAL_CSS_ID) return RESOLVED_CSS_ID;
|
|
644
644
|
if (id === VIRTUAL_COMPONENTS_ID) return RESOLVED_COMPONENTS_ID;
|
|
645
645
|
if (id === VIRTUAL_BRIDGE_ID) return RESOLVED_BRIDGE_ID;
|
|
646
|
+
if (id === VIRTUAL_SYSTEM_PROPS_ID) return RESOLVED_SYSTEM_PROPS_ID;
|
|
646
647
|
return null;
|
|
647
648
|
},
|
|
648
649
|
load(id) {
|
|
@@ -694,6 +695,7 @@ if (import.meta.hot) {
|
|
|
694
695
|
});
|
|
695
696
|
}
|
|
696
697
|
`;
|
|
698
|
+
if (id === RESOLVED_SYSTEM_PROPS_ID) return `export const systemPropMap = ${storedSystemPropMapJson};\nexport const systemPropGroups = ${groupRegistryJson};`;
|
|
697
699
|
return null;
|
|
698
700
|
},
|
|
699
701
|
transform(code, id) {
|
|
@@ -764,6 +766,11 @@ if (import.meta.hot) {
|
|
|
764
766
|
hmrServer.moduleGraph.invalidateModule(compModule);
|
|
765
767
|
geologicalModules.push(compModule);
|
|
766
768
|
}
|
|
769
|
+
const sysPropModule = hmrServer.moduleGraph.getModuleById(RESOLVED_SYSTEM_PROPS_ID);
|
|
770
|
+
if (sysPropModule) {
|
|
771
|
+
hmrServer.moduleGraph.invalidateModule(sysPropModule);
|
|
772
|
+
geologicalModules.push(sysPropModule);
|
|
773
|
+
}
|
|
767
774
|
return geologicalModules;
|
|
768
775
|
}
|
|
769
776
|
let source;
|
|
@@ -794,6 +801,11 @@ if (import.meta.hot) {
|
|
|
794
801
|
hmrServer.moduleGraph.invalidateModule(compModule);
|
|
795
802
|
modulesToUpdate.push(compModule);
|
|
796
803
|
}
|
|
804
|
+
const sysPropModule = hmrServer.moduleGraph.getModuleById(RESOLVED_SYSTEM_PROPS_ID);
|
|
805
|
+
if (sysPropModule) {
|
|
806
|
+
hmrServer.moduleGraph.invalidateModule(sysPropModule);
|
|
807
|
+
modulesToUpdate.push(sysPropModule);
|
|
808
|
+
}
|
|
797
809
|
if (storedManifest?.components) {
|
|
798
810
|
const staleFiles = /* @__PURE__ */ new Set();
|
|
799
811
|
for (const [id, desc] of Object.entries(storedManifest.components)) if ((desc.replacement ?? "") !== (prevReplacements.get(id) ?? "")) staleFiles.add(desc.file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-evaluator.d.ts","sourceRoot":"","sources":["../src/theme-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAuCA;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC5D,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAWD;
|
|
1
|
+
{"version":3,"file":"theme-evaluator.d.ts","sourceRoot":"","sources":["../src/theme-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAuCA;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC5D,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAWD;AAuKD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EACjD,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,GAC1C,MAAM,CAiCR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/vite-plugin",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.8",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"vite": ">=5.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@animus-ui/core": "0.1.0-next.
|
|
29
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
28
|
+
"@animus-ui/core": "0.1.0-next.8",
|
|
29
|
+
"@animus-ui/extract": "0.1.0-next.8"
|
|
30
30
|
}
|
|
31
31
|
}
|