@animus-ui/vite-plugin 0.1.0-next.32 → 0.1.0-next.36
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 +17 -47
- package/package.json +5 -4
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":"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,CAo+BnE;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 = [];
|
|
@@ -183,7 +150,7 @@ function animusExtract(options) {
|
|
|
183
150
|
try {
|
|
184
151
|
const ts = Date.now();
|
|
185
152
|
const tmpOut = join(tmpdir(), `animus-system-${ts}.json`);
|
|
186
|
-
execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst
|
|
153
|
+
execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst exportNames = Object.keys(m);\nconst candidates = exportNames.filter(k => m[k] && typeof m[k].toConfig === 'function');\nif (candidates.length === 0) {\n throw new Error('[animus-extract] No SystemInstance found. Exports: [' + exportNames.join(', ') + ']. None have a .toConfig() method. A SystemInstance is created by: export const ds = createSystem().build()');\n}\nif (candidates.length > 1) {\n throw new Error('[animus-extract] Multiple SystemInstance candidates found: [' + candidates.join(', ') + ']. Specify which one to use.');\n}\nconst ds = m[candidates[0]];\nconst cfg = ds.toConfig();\nconst tokens = m.tokens || m.theme || null;\nconst serialized = tokens && typeof tokens.serialize === 'function' ? tokens.serialize() : null;\nconst globalStyleBlocks = {};\nfor (const [key, val] of Object.entries(m)) {\n if (val && typeof val === 'object' && val.__brand === 'GlobalStyleBlock') {\n globalStyleBlocks[key] = val.styles;\n }\n}\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify({\n propConfig: cfg.propConfig,\n groupRegistry: cfg.groupRegistry,\n serialized: serialized,\n transformNames: Object.keys(cfg.transforms || {}),\n globalStyleBlocks: Object.keys(globalStyleBlocks).length > 0 ? globalStyleBlocks : null\n}));\n`, rootDir);
|
|
187
154
|
const result = readFileSync(tmpOut, "utf-8");
|
|
188
155
|
try {
|
|
189
156
|
unlinkSync(tmpOut);
|
|
@@ -197,9 +164,11 @@ 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, contextualVarsJson);
|
|
201
168
|
variableMapJson = prefixed.variableMapJson;
|
|
202
169
|
variableCss = prefixed.variableCss;
|
|
170
|
+
if (prefixed.themeJson) themeJson = prefixed.themeJson;
|
|
171
|
+
if (prefixed.contextualVarsJson) contextualVarsJson = prefixed.contextualVarsJson;
|
|
203
172
|
}
|
|
204
173
|
} else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
|
|
205
174
|
if (parsed.globalStyleBlocks) {
|
|
@@ -427,11 +396,12 @@ function animusExtract(options) {
|
|
|
427
396
|
for (const d of diagnostics) if (d.kind === "bail") warn(`⚠ ${d.component} not extracted: ${d.message}`);
|
|
428
397
|
else if (d.kind === "skip") warn(`⚠ ${d.component}: skipped ${d.message}`);
|
|
429
398
|
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
399
|
if (!isProd && storedSheets) {
|
|
434
|
-
const staticSize = (
|
|
400
|
+
const staticSize = assembleStylesheet({
|
|
401
|
+
layers: options.layers,
|
|
402
|
+
variableCss,
|
|
403
|
+
globalCss
|
|
404
|
+
}).length;
|
|
435
405
|
const componentSize = resolvedComponentCss.length;
|
|
436
406
|
log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
|
|
437
407
|
} else log("Delivery: single file mode (production)");
|
|
@@ -453,20 +423,20 @@ function animusExtract(options) {
|
|
|
453
423
|
warnFn: warn
|
|
454
424
|
};
|
|
455
425
|
if (id === RESOLVED_CSS_ID) {
|
|
456
|
-
if (!isProd && storedSheets) return postProcessCss(
|
|
457
|
-
|
|
426
|
+
if (!isProd && storedSheets) return postProcessCss(assembleStylesheet({
|
|
427
|
+
layers: options.layers,
|
|
458
428
|
variableCss,
|
|
459
429
|
globalCss
|
|
460
|
-
|
|
430
|
+
}), {
|
|
461
431
|
...lcssOpts,
|
|
462
432
|
minify: false
|
|
463
433
|
});
|
|
464
|
-
return postProcessCss(
|
|
465
|
-
|
|
434
|
+
return postProcessCss(assembleStylesheet({
|
|
435
|
+
layers: options.layers,
|
|
466
436
|
variableCss,
|
|
467
437
|
globalCss,
|
|
468
|
-
resolvedComponentCss
|
|
469
|
-
|
|
438
|
+
componentCss: resolvedComponentCss
|
|
439
|
+
}), lcssOpts);
|
|
470
440
|
}
|
|
471
441
|
if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss(resolvedComponentCss || "", {
|
|
472
442
|
...lcssOpts,
|
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.36",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,15 +18,16 @@
|
|
|
18
18
|
"url": "git+https://github.com/codecaaron/animus"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "
|
|
21
|
+
"build": "bun run build:ts",
|
|
22
|
+
"build:ts": "tsdown && tsc -p tsconfig.build.json",
|
|
22
23
|
"compile": "tsc --noEmit"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"vite": ">=5.0.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
29
|
-
"@animus-ui/system": "0.1.0-next.
|
|
29
|
+
"@animus-ui/extract": "0.1.0-next.36",
|
|
30
|
+
"@animus-ui/system": "0.1.0-next.36",
|
|
30
31
|
"browserslist": "^4.24.0",
|
|
31
32
|
"lightningcss": "^1.29.0"
|
|
32
33
|
}
|