@animus-ui/vite-plugin 0.1.0-next.60 → 0.1.0-next.62
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 +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +67 -14
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export interface AnimusExtractOptions {
|
|
|
13
13
|
exclude?: string[];
|
|
14
14
|
/** When true, extraction failures throw instead of warning. Use in CI to enforce full extraction. */
|
|
15
15
|
strict?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When true, run structural self-verification at the end of `buildStart`:
|
|
18
|
+
* component CSS non-empty, assembled layer ordering correct, `:root` block
|
|
19
|
+
* present in variable CSS, no unresolved `__TRANSFORM__` placeholders. Prefix
|
|
20
|
+
* output with `[animus:verify]`. Failures throw when `strict: true`,
|
|
21
|
+
* otherwise warn.
|
|
22
|
+
*/
|
|
23
|
+
verify?: boolean;
|
|
16
24
|
/** Enable verbose logging. Also activatable via ANIMUS_DEBUG=1 env var. */
|
|
17
25
|
verbose?: boolean;
|
|
18
26
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAE3C,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;;;;;;OAMG;IACH,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;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAylCnE;AAED,eAAe,aAAa,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
4
4
|
import { dirname, extname, join, relative, resolve } from "path";
|
|
5
|
-
import { applyUnitFallback, assembleStylesheet, extractSystemFilePackages, validateLayerOrder } from "@animus-ui/extract/pipeline";
|
|
5
|
+
import { applyUnitFallback, assembleStylesheet, extractSystemFilePackages, stripLeadingLayerDeclaration, validateLayerOrder } from "@animus-ui/extract/pipeline";
|
|
6
6
|
import browserslist from "browserslist";
|
|
7
7
|
import { browserslistToTargets, transform } from "lightningcss";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
@@ -146,11 +146,13 @@ function animusExtract(options) {
|
|
|
146
146
|
let variableCss = "";
|
|
147
147
|
let globalCss = "";
|
|
148
148
|
let globalStyleBlocksJson = null;
|
|
149
|
+
let keyframesBlocksJson = null;
|
|
149
150
|
let pathAliasesJson = null;
|
|
150
151
|
let storedManifest = null;
|
|
151
152
|
let storedManifestJson = "";
|
|
152
153
|
let resolvedComponentCss = "";
|
|
153
154
|
let storedSheets = null;
|
|
155
|
+
let layerDeclaration = "";
|
|
154
156
|
let fragmentCache = /* @__PURE__ */ new Map();
|
|
155
157
|
let reverseProvenance = {};
|
|
156
158
|
let storedSystemPropMapJson = "{}";
|
|
@@ -183,6 +185,7 @@ function animusExtract(options) {
|
|
|
183
185
|
variableCss = config.variableCss;
|
|
184
186
|
contextualVarsJson = config.contextualVarsJson;
|
|
185
187
|
globalStyleBlocksJson = config.globalStyleBlocks || null;
|
|
188
|
+
keyframesBlocksJson = config.keyframesBlocks || null;
|
|
186
189
|
} catch (e) {
|
|
187
190
|
if (options.strict) throw new Error(`[animus-extract] Failed to load system from ${resolvedSystemPath}: ${e}`);
|
|
188
191
|
console.warn(`[animus-extract] Failed to load system from ${resolvedSystemPath}:`, e);
|
|
@@ -202,7 +205,7 @@ function animusExtract(options) {
|
|
|
202
205
|
runtime_import: "@animus-ui/system",
|
|
203
206
|
css_module_id: "virtual:animus/styles.css"
|
|
204
207
|
});
|
|
205
|
-
const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, contextualVarsJson || null, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd, emitterConfig, selectorAliasesJson, selectorOrderJson, globalStyleBlocksJson, pathAliasesJson);
|
|
208
|
+
const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, contextualVarsJson || null, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd, emitterConfig, selectorAliasesJson, selectorOrderJson, globalStyleBlocksJson, pathAliasesJson, keyframesBlocksJson);
|
|
206
209
|
storedManifest = JSON.parse(manifestJson);
|
|
207
210
|
storedManifestJson = manifestJson;
|
|
208
211
|
storedSystemPropMapJson = JSON.stringify(storedManifest?.system_prop_map ?? {});
|
|
@@ -236,6 +239,30 @@ function animusExtract(options) {
|
|
|
236
239
|
console.warn("[animus-extract] analyzeProject failed:", e);
|
|
237
240
|
}
|
|
238
241
|
}
|
|
242
|
+
function runSelfVerify() {
|
|
243
|
+
const failures = [];
|
|
244
|
+
if (resolvedComponentCss.trim().length === 0) failures.push("No component CSS produced — check system file and include patterns");
|
|
245
|
+
if (!variableCss.includes(":root")) failures.push("No :root variable block found in variable CSS");
|
|
246
|
+
if (`${variableCss}\n${globalCss}\n${resolvedComponentCss}`.includes("__TRANSFORM__")) failures.push("Unresolved __TRANSFORM__ placeholders found in CSS output");
|
|
247
|
+
if (storedManifest && resolvedComponentCss.length > 0) {
|
|
248
|
+
const assembled = assembleStylesheet({
|
|
249
|
+
layers: options.layers,
|
|
250
|
+
variableCss,
|
|
251
|
+
globalCss,
|
|
252
|
+
componentCss: resolvedComponentCss
|
|
253
|
+
});
|
|
254
|
+
const baseIdx = assembled.search(/@layer\s+anm-base\s*\{/);
|
|
255
|
+
const variantsIdx = assembled.search(/@layer\s+anm-variants\s*\{/);
|
|
256
|
+
if (baseIdx !== -1 && variantsIdx !== -1 && baseIdx >= variantsIdx) failures.push(`CSS layer ordering violated — @layer anm-base (offset ${baseIdx}) must precede @layer anm-variants (offset ${variantsIdx})`);
|
|
257
|
+
}
|
|
258
|
+
for (const message of failures) {
|
|
259
|
+
const line = `[animus:verify] ${message}`;
|
|
260
|
+
if (options.strict) throw new Error(line);
|
|
261
|
+
if (logger) logger.warn(line, { timestamp: true });
|
|
262
|
+
else console.warn(line);
|
|
263
|
+
}
|
|
264
|
+
if (failures.length === 0) log("[animus:verify] structural self-check passed");
|
|
265
|
+
}
|
|
239
266
|
return {
|
|
240
267
|
name: "animus-extract",
|
|
241
268
|
enforce: "pre",
|
|
@@ -402,6 +429,14 @@ function animusExtract(options) {
|
|
|
402
429
|
log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
|
|
403
430
|
} else log("Delivery: single file mode (production)");
|
|
404
431
|
}
|
|
432
|
+
const { declaration } = assembleStylesheet({
|
|
433
|
+
layers: options.layers,
|
|
434
|
+
variableCss: "",
|
|
435
|
+
globalCss: "",
|
|
436
|
+
split: true
|
|
437
|
+
});
|
|
438
|
+
layerDeclaration = declaration;
|
|
439
|
+
if (options.verify) runSelfVerify();
|
|
405
440
|
},
|
|
406
441
|
resolveId(id) {
|
|
407
442
|
if (id === VIRTUAL_CSS_ID) return RESOLVED_CSS_ID;
|
|
@@ -419,22 +454,28 @@ function animusExtract(options) {
|
|
|
419
454
|
warnFn: warn
|
|
420
455
|
};
|
|
421
456
|
if (id === RESOLVED_CSS_ID) {
|
|
422
|
-
if (!isProd && storedSheets)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
457
|
+
if (!isProd && storedSheets) {
|
|
458
|
+
const { variables, body } = assembleStylesheet({
|
|
459
|
+
layers: options.layers,
|
|
460
|
+
variableCss,
|
|
461
|
+
globalCss,
|
|
462
|
+
split: true
|
|
463
|
+
});
|
|
464
|
+
return [variables, postProcessCss(body, {
|
|
465
|
+
...lcssOpts,
|
|
466
|
+
minify: false
|
|
467
|
+
})].filter(Boolean).join("\n");
|
|
468
|
+
}
|
|
469
|
+
const { variables, body } = assembleStylesheet({
|
|
431
470
|
layers: options.layers,
|
|
432
471
|
variableCss,
|
|
433
472
|
globalCss,
|
|
434
|
-
componentCss: resolvedComponentCss
|
|
435
|
-
|
|
473
|
+
componentCss: resolvedComponentCss,
|
|
474
|
+
split: true
|
|
475
|
+
});
|
|
476
|
+
return [variables, postProcessCss(body, lcssOpts)].filter(Boolean).join("\n");
|
|
436
477
|
}
|
|
437
|
-
if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss(resolvedComponentCss || "", {
|
|
478
|
+
if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss(stripLeadingLayerDeclaration(resolvedComponentCss || ""), {
|
|
438
479
|
...lcssOpts,
|
|
439
480
|
minify: false
|
|
440
481
|
}).replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;`;
|
|
@@ -541,6 +582,18 @@ if (import.meta.hot) {
|
|
|
541
582
|
return null;
|
|
542
583
|
}
|
|
543
584
|
},
|
|
585
|
+
transformIndexHtml: {
|
|
586
|
+
order: "pre",
|
|
587
|
+
handler() {
|
|
588
|
+
if (!layerDeclaration) return [];
|
|
589
|
+
return [{
|
|
590
|
+
tag: "style",
|
|
591
|
+
attrs: { "data-animus-layers": "" },
|
|
592
|
+
children: layerDeclaration,
|
|
593
|
+
injectTo: "head-prepend"
|
|
594
|
+
}];
|
|
595
|
+
}
|
|
596
|
+
},
|
|
544
597
|
handleHotUpdate({ file, server: hmrServer, modules }) {
|
|
545
598
|
if (isProd) return;
|
|
546
599
|
const ext = extname(file);
|
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.62",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"vite": ">=5.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
41
|
-
"@animus-ui/system": "0.1.0-next.
|
|
40
|
+
"@animus-ui/extract": "0.1.0-next.62",
|
|
41
|
+
"@animus-ui/system": "0.1.0-next.62",
|
|
42
42
|
"browserslist": "^4.24.0",
|
|
43
43
|
"lightningcss": "^1.29.0"
|
|
44
44
|
}
|