@animus-ui/extract 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.
- package/dist/assemble-stylesheet.d.ts +34 -0
- package/dist/assemble-stylesheet.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +78 -6
- package/dist/prefix.d.ts +4 -2
- package/dist/prefix.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 7 Animus cascade layers in required order.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ANIMUS_LAYERS: readonly ["global", "base", "variants", "compounds", "states", "system", "custom"];
|
|
5
|
+
/**
|
|
6
|
+
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
7
|
+
* in the correct relative order. Consumer layers may be interleaved.
|
|
8
|
+
*
|
|
9
|
+
* @throws Error with descriptive message on violation
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateLayerOrder(layers: string[]): void;
|
|
12
|
+
export interface AssembleStylesheetOptions {
|
|
13
|
+
/** Custom layer order. Must contain all 7 Animus layers as a subsequence. */
|
|
14
|
+
layers?: string[];
|
|
15
|
+
/** Variable CSS: `:root { --color-*: ... }` + color mode selectors */
|
|
16
|
+
variableCss?: string;
|
|
17
|
+
/** Global CSS: `@layer global { reset + global styles }` */
|
|
18
|
+
globalCss?: string;
|
|
19
|
+
/** Component CSS from the Rust crate (may contain embedded @layer declaration) */
|
|
20
|
+
componentCss?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Assemble the final stylesheet in canonical order:
|
|
24
|
+
*
|
|
25
|
+
* 1. `@layer` declaration (cascade ordering)
|
|
26
|
+
* 2. Emitted variables (`:root`, color mode selectors)
|
|
27
|
+
* 3. `@layer global { ... }` (reset + global styles)
|
|
28
|
+
* 4. `@layer base/variants/compounds/states/system/custom { ... }` (components)
|
|
29
|
+
*
|
|
30
|
+
* This is the single source of truth for stylesheet assembly.
|
|
31
|
+
* Both Vite and Next.js plugins must use this function.
|
|
32
|
+
*/
|
|
33
|
+
export declare function assembleStylesheet(options: AssembleStylesheetOptions): string;
|
|
34
|
+
//# sourceMappingURL=assemble-stylesheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble-stylesheet.d.ts","sourceRoot":"","sources":["../pipeline/assemble-stylesheet.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,oFAQhB,CAAC;AAIX;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAyBzD;AAYD,MAAM,WAAW,yBAAyB;IACxC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAsB7E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { AssembleStylesheetOptions } from './assemble-stylesheet';
|
|
2
|
+
export { ANIMUS_LAYERS, assembleStylesheet, validateLayerOrder, } from './assemble-stylesheet';
|
|
1
3
|
export { extractSystemFilePackages } from './discover-packages';
|
|
2
4
|
export { applyPrefix } from './prefix';
|
|
3
5
|
export { resolveGlobalStyles, resolveTokenAliases, resolveValue, } from './resolve-global-styles';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../pipeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../pipeline/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,73 @@ import { execSync } from "child_process";
|
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
6
6
|
//#endregion
|
|
7
|
+
//#region pipeline/assemble-stylesheet.ts
|
|
8
|
+
/**
|
|
9
|
+
* The 7 Animus cascade layers in required order.
|
|
10
|
+
*/
|
|
11
|
+
const ANIMUS_LAYERS = [
|
|
12
|
+
"global",
|
|
13
|
+
"base",
|
|
14
|
+
"variants",
|
|
15
|
+
"compounds",
|
|
16
|
+
"states",
|
|
17
|
+
"system",
|
|
18
|
+
"custom"
|
|
19
|
+
];
|
|
20
|
+
const DEFAULT_LAYER_DECLARATION = `@layer ${ANIMUS_LAYERS.join(", ")};\n`;
|
|
21
|
+
/**
|
|
22
|
+
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
23
|
+
* in the correct relative order. Consumer layers may be interleaved.
|
|
24
|
+
*
|
|
25
|
+
* @throws Error with descriptive message on violation
|
|
26
|
+
*/
|
|
27
|
+
function validateLayerOrder(layers) {
|
|
28
|
+
let cursor = 0;
|
|
29
|
+
for (const layer of layers) if (cursor < ANIMUS_LAYERS.length && layer === ANIMUS_LAYERS[cursor]) cursor++;
|
|
30
|
+
if (cursor < ANIMUS_LAYERS.length) {
|
|
31
|
+
const missing = ANIMUS_LAYERS.slice(cursor);
|
|
32
|
+
const found = ANIMUS_LAYERS.slice(0, cursor);
|
|
33
|
+
if (!ANIMUS_LAYERS.every((l) => layers.includes(l))) {
|
|
34
|
+
const absent = ANIMUS_LAYERS.filter((l) => !layers.includes(l));
|
|
35
|
+
throw new Error(`[animus-extract] Custom layers missing required layers: ${absent.join(", ")}. All 7 Animus layers must be present: ${ANIMUS_LAYERS.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`[animus-extract] Custom layers have wrong order. Found ${found.join(", ")} but then expected ${missing[0]}. Required order: (${ANIMUS_LAYERS.join(" < ")}). You may interleave custom layers but must preserve this subsequence.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Strip a leading `@layer ...;` declaration line from CSS if present.
|
|
42
|
+
* The Rust crate embeds this in prod-mode output; we strip it so the
|
|
43
|
+
* shared assembler controls placement.
|
|
44
|
+
*/
|
|
45
|
+
function stripLeadingLayerDeclaration(css) {
|
|
46
|
+
return css.replace(/^@layer\s+[^;{]+;\s*\n?/, "");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Assemble the final stylesheet in canonical order:
|
|
50
|
+
*
|
|
51
|
+
* 1. `@layer` declaration (cascade ordering)
|
|
52
|
+
* 2. Emitted variables (`:root`, color mode selectors)
|
|
53
|
+
* 3. `@layer global { ... }` (reset + global styles)
|
|
54
|
+
* 4. `@layer base/variants/compounds/states/system/custom { ... }` (components)
|
|
55
|
+
*
|
|
56
|
+
* This is the single source of truth for stylesheet assembly.
|
|
57
|
+
* Both Vite and Next.js plugins must use this function.
|
|
58
|
+
*/
|
|
59
|
+
function assembleStylesheet(options) {
|
|
60
|
+
let layerDeclaration;
|
|
61
|
+
if (options.layers) {
|
|
62
|
+
validateLayerOrder(options.layers);
|
|
63
|
+
layerDeclaration = `@layer ${options.layers.join(", ")};\n`;
|
|
64
|
+
} else layerDeclaration = DEFAULT_LAYER_DECLARATION;
|
|
65
|
+
const componentCss = options.componentCss ? stripLeadingLayerDeclaration(options.componentCss) : "";
|
|
66
|
+
return [
|
|
67
|
+
layerDeclaration,
|
|
68
|
+
options.variableCss || "",
|
|
69
|
+
options.globalCss || "",
|
|
70
|
+
componentCss
|
|
71
|
+
].filter(Boolean).join("\n");
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
7
74
|
//#region pipeline/discover-packages.ts
|
|
8
75
|
/**
|
|
9
76
|
* Extract external DS package names from `.includes([...])` calls in the system file.
|
|
@@ -59,27 +126,32 @@ function extractSystemFilePackages(systemFilePath) {
|
|
|
59
126
|
//#endregion
|
|
60
127
|
//#region pipeline/prefix.ts
|
|
61
128
|
/**
|
|
62
|
-
* Apply namespace prefix to a variable map
|
|
129
|
+
* Apply namespace prefix to a variable map, CSS variable declarations, and theme JSON.
|
|
63
130
|
*
|
|
64
131
|
* Variable map: `{ "colors.ember": "--color-ember" }` -> `{ "colors.ember": "--prefix-color-ember" }`
|
|
65
132
|
* Variable CSS: `--color-ember: #FF2800` -> `--prefix-color-ember: #FF2800`
|
|
66
133
|
* `var(--color-ember)` -> `var(--prefix-color-ember)`
|
|
134
|
+
* Theme JSON: `{ "colors.ember": "var(--color-ember)" }` -> `{ "colors.ember": "var(--prefix-color-ember)" }`
|
|
67
135
|
*/
|
|
68
|
-
function applyPrefix(prefix, variableMapJson, variableCss) {
|
|
136
|
+
function applyPrefix(prefix, variableMapJson, variableCss, themeJson) {
|
|
69
137
|
if (!prefix) return {
|
|
70
138
|
variableMapJson,
|
|
71
|
-
variableCss
|
|
139
|
+
variableCss,
|
|
140
|
+
themeJson
|
|
72
141
|
};
|
|
142
|
+
const varRefRe = /var\(--([a-zA-Z][\w-]*)\)/g;
|
|
73
143
|
const map = JSON.parse(variableMapJson);
|
|
74
144
|
const prefixed = {};
|
|
75
145
|
for (const [key, varName] of Object.entries(map)) prefixed[key] = varName.startsWith("--") ? `--${prefix}-${varName.slice(2)}` : varName;
|
|
76
146
|
let css = variableCss;
|
|
77
147
|
css = css.replace(/--([a-zA-Z][\w-]*)\s*:/g, `--${prefix}-$1:`);
|
|
78
|
-
css = css.replace(
|
|
79
|
-
|
|
148
|
+
css = css.replace(varRefRe, `var(--${prefix}-$1)`);
|
|
149
|
+
const result = {
|
|
80
150
|
variableMapJson: JSON.stringify(prefixed),
|
|
81
151
|
variableCss: css
|
|
82
152
|
};
|
|
153
|
+
if (themeJson) result.themeJson = themeJson.replace(varRefRe, `var(--${prefix}-$1)`);
|
|
154
|
+
return result;
|
|
83
155
|
}
|
|
84
156
|
//#endregion
|
|
85
157
|
//#region pipeline/utils.ts
|
|
@@ -327,4 +399,4 @@ function applyUnitFallback(css) {
|
|
|
327
399
|
});
|
|
328
400
|
}
|
|
329
401
|
//#endregion
|
|
330
|
-
export { applyPrefix, applyUnitFallback, camelToKebab, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles, resolveTokenAliases, resolveTransformPlaceholders, resolveValue };
|
|
402
|
+
export { ANIMUS_LAYERS, applyPrefix, applyUnitFallback, assembleStylesheet, camelToKebab, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles, resolveTokenAliases, resolveTransformPlaceholders, resolveValue, validateLayerOrder };
|
package/dist/prefix.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Apply namespace prefix to a variable map
|
|
2
|
+
* Apply namespace prefix to a variable map, CSS variable declarations, and theme JSON.
|
|
3
3
|
*
|
|
4
4
|
* Variable map: `{ "colors.ember": "--color-ember" }` -> `{ "colors.ember": "--prefix-color-ember" }`
|
|
5
5
|
* Variable CSS: `--color-ember: #FF2800` -> `--prefix-color-ember: #FF2800`
|
|
6
6
|
* `var(--color-ember)` -> `var(--prefix-color-ember)`
|
|
7
|
+
* Theme JSON: `{ "colors.ember": "var(--color-ember)" }` -> `{ "colors.ember": "var(--prefix-color-ember)" }`
|
|
7
8
|
*/
|
|
8
|
-
export declare function applyPrefix(prefix: string, variableMapJson: string, variableCss: string): {
|
|
9
|
+
export declare function applyPrefix(prefix: string, variableMapJson: string, variableCss: string, themeJson?: string): {
|
|
9
10
|
variableMapJson: string;
|
|
10
11
|
variableCss: string;
|
|
12
|
+
themeJson?: string;
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=prefix.d.ts.map
|
package/dist/prefix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../pipeline/prefix.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../pipeline/prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CA+BtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/extract",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.34",
|
|
4
4
|
"description": "Animus static CSS extraction pipeline (Rust/NAPI)",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"./pipeline": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"import": "./dist/index.mjs",
|
|
17
|
+
"require": "./dist/index.mjs",
|
|
17
18
|
"default": "./dist/index.mjs"
|
|
18
19
|
}
|
|
19
20
|
},
|
|
@@ -44,9 +45,9 @@
|
|
|
44
45
|
"build:pipeline": "tsdown && tsc -p tsconfig.build.json"
|
|
45
46
|
},
|
|
46
47
|
"optionalDependencies": {
|
|
47
|
-
"@animus-ui/extract-darwin-arm64": "0.1.0-next.
|
|
48
|
-
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.
|
|
49
|
-
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.
|
|
48
|
+
"@animus-ui/extract-darwin-arm64": "0.1.0-next.34",
|
|
49
|
+
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.34",
|
|
50
|
+
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.34"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@animus-ui/system": "workspace:*",
|