@animus-ui/vite-plugin 0.1.0-next.32 → 0.1.0-next.34

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":"AA2BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6LD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAk+BnE;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA09BnE;AAED,eAAe,aAAa,CAAC"}
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { existsSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileS
5
5
  import { tmpdir } from "os";
6
6
  import { dirname, extname, join, relative, resolve } from "path";
7
7
  import { fileURLToPath } from "url";
8
- import { applyPrefix, applyUnitFallback, detectRuntime, execSubprocess, extractSystemFilePackages } from "@animus-ui/extract/pipeline";
8
+ import { applyPrefix, applyUnitFallback, assembleStylesheet, detectRuntime, execSubprocess, extractSystemFilePackages, validateLayerOrder } from "@animus-ui/extract/pipeline";
9
9
  import browserslist from "browserslist";
10
10
  import { browserslistToTargets, transform } from "lightningcss";
11
11
  //#region \0rolldown/runtime.js
@@ -107,38 +107,6 @@ function buildFileEntriesFromCache(cache, changedPath) {
107
107
  });
108
108
  return entries;
109
109
  }
110
- /**
111
- * The 7 Animus cascade layers in required order.
112
- * Consumer-provided `layers` must contain these as a subsequence.
113
- */
114
- const ANIMUS_LAYERS = [
115
- "global",
116
- "base",
117
- "variants",
118
- "compounds",
119
- "states",
120
- "system",
121
- "custom"
122
- ];
123
- /**
124
- * Validate that a consumer `layers` array contains all 7 Animus layers
125
- * in the correct relative order. Consumer layers may be interleaved.
126
- *
127
- * @throws Error with descriptive message on violation
128
- */
129
- function validateLayerOrder(layers) {
130
- let cursor = 0;
131
- for (const layer of layers) if (cursor < ANIMUS_LAYERS.length && layer === ANIMUS_LAYERS[cursor]) cursor++;
132
- if (cursor < ANIMUS_LAYERS.length) {
133
- const missing = ANIMUS_LAYERS.slice(cursor);
134
- const found = ANIMUS_LAYERS.slice(0, cursor);
135
- if (!ANIMUS_LAYERS.every((l) => layers.includes(l))) {
136
- const absent = ANIMUS_LAYERS.filter((l) => !layers.includes(l));
137
- throw new Error(`[animus] Invalid layers config: missing required layers: ${absent.join(", ")}. All 7 Animus layers must be present: ${ANIMUS_LAYERS.join(", ")}`);
138
- }
139
- throw new Error(`[animus] Invalid layers config: Animus layers must appear in order (${ANIMUS_LAYERS.join(" < ")}). Found ${found.join(", ")} in order, but ${missing.join(", ")} appeared out of sequence. Received: [${layers.join(", ")}]`);
140
- }
141
- }
142
110
  function animusExtract(options) {
143
111
  let themeJson = "{}";
144
112
  let variableMapJson = "{}";
@@ -166,7 +134,6 @@ function animusExtract(options) {
166
134
  let storedSystemPropMapJson = "{}";
167
135
  let storedDynamicPropsJson = "{}";
168
136
  let storedTransformsSource = "{}";
169
- let layerDeclaration = "";
170
137
  const fileCache = /* @__PURE__ */ new Map();
171
138
  let packageMap = {};
172
139
  let externalPackageDirs = [];
@@ -197,9 +164,10 @@ function animusExtract(options) {
197
164
  variableCss = parsed.serialized.variableCss;
198
165
  contextualVarsJson = parsed.serialized.contextualVarsJson;
199
166
  if (options.prefix) {
200
- const prefixed = applyPrefix(options.prefix, variableMapJson, variableCss);
167
+ const prefixed = applyPrefix(options.prefix, variableMapJson, variableCss, themeJson);
201
168
  variableMapJson = prefixed.variableMapJson;
202
169
  variableCss = prefixed.variableCss;
170
+ if (prefixed.themeJson) themeJson = prefixed.themeJson;
203
171
  }
204
172
  } else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
205
173
  if (parsed.globalStyleBlocks) {
@@ -427,11 +395,12 @@ function animusExtract(options) {
427
395
  for (const d of diagnostics) if (d.kind === "bail") warn(`⚠ ${d.component} not extracted: ${d.message}`);
428
396
  else if (d.kind === "skip") warn(`⚠ ${d.component}: skipped ${d.message}`);
429
397
  log(`CSS: ${resolvedComponentCss.length} bytes (${Object.keys(storedManifest.components || {}).length} components)`);
430
- if (options.layers) layerDeclaration = `@layer ${options.layers.join(", ")};\n`;
431
- else if (storedSheets) layerDeclaration = storedSheets.declaration;
432
- else layerDeclaration = `@layer ${ANIMUS_LAYERS.join(", ")};\n`;
433
398
  if (!isProd && storedSheets) {
434
- const staticSize = (layerDeclaration + variableCss + globalCss).length;
399
+ const staticSize = assembleStylesheet({
400
+ layers: options.layers,
401
+ variableCss,
402
+ globalCss
403
+ }).length;
435
404
  const componentSize = resolvedComponentCss.length;
436
405
  log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
437
406
  } else log("Delivery: single file mode (production)");
@@ -453,20 +422,20 @@ function animusExtract(options) {
453
422
  warnFn: warn
454
423
  };
455
424
  if (id === RESOLVED_CSS_ID) {
456
- if (!isProd && storedSheets) return postProcessCss([
457
- layerDeclaration,
425
+ if (!isProd && storedSheets) return postProcessCss(assembleStylesheet({
426
+ layers: options.layers,
458
427
  variableCss,
459
428
  globalCss
460
- ].filter(Boolean).join("\n"), {
429
+ }), {
461
430
  ...lcssOpts,
462
431
  minify: false
463
432
  });
464
- return postProcessCss([
465
- layerDeclaration,
433
+ return postProcessCss(assembleStylesheet({
434
+ layers: options.layers,
466
435
  variableCss,
467
436
  globalCss,
468
- resolvedComponentCss
469
- ].filter(Boolean).join("\n"), lcssOpts);
437
+ componentCss: resolvedComponentCss
438
+ }), lcssOpts);
470
439
  }
471
440
  if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss(resolvedComponentCss || "", {
472
441
  ...lcssOpts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.0-next.32",
3
+ "version": "0.1.0-next.34",
4
4
  "description": "Animus static CSS extraction Vite plugin",
5
5
  "author": "codecaaron <airrobb@gmail.com>",
6
6
  "license": "MIT",
@@ -25,8 +25,8 @@
25
25
  "vite": ">=5.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@animus-ui/extract": "0.1.0-next.32",
29
- "@animus-ui/system": "0.1.0-next.32",
28
+ "@animus-ui/extract": "0.1.0-next.34",
29
+ "@animus-ui/system": "0.1.0-next.34",
30
30
  "browserslist": "^4.24.0",
31
31
  "lightningcss": "^1.29.0"
32
32
  }