@animus-ui/vite-plugin 0.1.0-next.8 → 0.1.0-next.v7

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.
@@ -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;AA6RD,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAw7BxE;AAED,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,eAAe,aAAa,CAAC"}
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;AA0RD,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAq5BxE;AAED,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,eAAe,aAAa,CAAC"}
package/dist/index.mjs CHANGED
@@ -65,11 +65,15 @@ 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") 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}`);
68
+ if (theme._tokens?.modes != null && typeof theme._tokens.modes === "object") {
69
+ const defaultMode = typeof theme.mode === "string" ? theme.mode : Object.keys(theme._tokens.modes)[0];
70
+ for (const [modeName, modeTokens] of Object.entries(theme._tokens.modes)) {
71
+ if (modeName === defaultMode) continue;
72
+ if (modeTokens == null || typeof modeTokens !== "object") continue;
73
+ const modeLines = [];
74
+ flattenModeTokens(modeLines, modeTokens, "");
75
+ if (modeLines.length > 0) parts.push(`[data-color-mode="${modeName}"] {\n${modeLines.join("\n")}\n}`);
76
+ }
73
77
  }
74
78
  return parts.join("\n\n");
75
79
  }
@@ -114,8 +118,6 @@ const VIRTUAL_COMPONENTS_ID = "virtual:animus/components.js";
114
118
  const RESOLVED_COMPONENTS_ID = "\0virtual:animus/components.js";
115
119
  const VIRTUAL_BRIDGE_ID = "virtual:animus/hmr-bridge.js";
116
120
  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";
119
121
  const DEFAULT_EXTENSIONS = new Set([
120
122
  ".ts",
121
123
  ".tsx",
@@ -224,7 +226,7 @@ const UNITLESS_PROPERTIES = new Set([
224
226
  * Numbers inside CSS function calls (cubic-bezier, rgb, calc, etc.) are skipped.
225
227
  */
226
228
  function applyUnitFallback(css) {
227
- return css.replace(/([a-z-]+)\s*:\s*([^;{}]+);/g, (match, prop, value) => {
229
+ return css.replace(/([a-z-]+)\s*:\s*([^;]+);/g, (match, prop, value) => {
228
230
  if (UNITLESS_PROPERTIES.has(prop)) return match;
229
231
  let depth = 0;
230
232
  let fixed = "";
@@ -330,7 +332,6 @@ function animusExtract(options = {}) {
330
332
  let storedManifestJson = "";
331
333
  let resolvedComponentCss = "";
332
334
  let storedSheets = null;
333
- let storedSystemPropMapJson = "{}";
334
335
  const fileCache = /* @__PURE__ */ new Map();
335
336
  let packageMap = {};
336
337
  let bridgeInjected = false;
@@ -423,7 +424,7 @@ function animusExtract(options = {}) {
423
424
  const ts = Date.now();
424
425
  const tmpScript = join(tmpdir(), `animus-system-${ts}.js`);
425
426
  const tmpOut = join(tmpdir(), `animus-system-${ts}.json`);
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`);
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: cfg.tokens,\n transformNames: Object.keys(cfg.transforms || {}),\n globalStyles: cfg.globalStyles || null\n}));\n`);
427
428
  execSync(`bun run "${tmpScript}"`, {
428
429
  cwd: rootDir,
429
430
  encoding: "utf-8"
@@ -441,7 +442,7 @@ function animusExtract(options = {}) {
441
442
  themeJson = result.scalesJson;
442
443
  variableMapJson = result.variableMapJson;
443
444
  variableCss = result.variableCss;
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`.");
445
+ }
445
446
  if (parsed.globalStyles) {
446
447
  const hasReset = parsed.globalStyles.reset && Object.keys(parsed.globalStyles.reset).length > 0;
447
448
  const hasGlobal = parsed.globalStyles.global && Object.keys(parsed.globalStyles.global).length > 0;
@@ -493,7 +494,6 @@ function animusExtract(options = {}) {
493
494
  const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd);
494
495
  storedManifest = JSON.parse(manifestJson);
495
496
  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,7 +643,6 @@ 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;
647
646
  return null;
648
647
  },
649
648
  load(id) {
@@ -695,7 +694,6 @@ if (import.meta.hot) {
695
694
  });
696
695
  }
697
696
  `;
698
- if (id === RESOLVED_SYSTEM_PROPS_ID) return `export const systemPropMap = ${storedSystemPropMapJson};\nexport const systemPropGroups = ${groupRegistryJson};`;
699
697
  return null;
700
698
  },
701
699
  transform(code, id) {
@@ -766,11 +764,6 @@ if (import.meta.hot) {
766
764
  hmrServer.moduleGraph.invalidateModule(compModule);
767
765
  geologicalModules.push(compModule);
768
766
  }
769
- const sysPropModule = hmrServer.moduleGraph.getModuleById(RESOLVED_SYSTEM_PROPS_ID);
770
- if (sysPropModule) {
771
- hmrServer.moduleGraph.invalidateModule(sysPropModule);
772
- geologicalModules.push(sysPropModule);
773
- }
774
767
  return geologicalModules;
775
768
  }
776
769
  let source;
@@ -801,11 +794,6 @@ if (import.meta.hot) {
801
794
  hmrServer.moduleGraph.invalidateModule(compModule);
802
795
  modulesToUpdate.push(compModule);
803
796
  }
804
- const sysPropModule = hmrServer.moduleGraph.getModuleById(RESOLVED_SYSTEM_PROPS_ID);
805
- if (sysPropModule) {
806
- hmrServer.moduleGraph.invalidateModule(sysPropModule);
807
- modulesToUpdate.push(sysPropModule);
808
- }
809
797
  if (storedManifest?.components) {
810
798
  const staleFiles = /* @__PURE__ */ new Set();
811
799
  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;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"}
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;AA6KD;;;;;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.8",
3
+ "version": "0.1.0-next.v7",
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.8",
29
- "@animus-ui/extract": "0.1.0-next.8"
28
+ "@animus-ui/core": "0.1.0-next.v7",
29
+ "@animus-ui/extract": "0.1.0-next.v7"
30
30
  }
31
31
  }