@animus-ui/extract 0.1.0-next.44 → 0.1.0-next.48
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/animus-extract.darwin-arm64.node +0 -0
- package/animus-extract.linux-arm64-gnu.node +0 -0
- package/animus-extract.linux-x64-gnu.node +0 -0
- package/dist/assemble-stylesheet.d.ts +11 -6
- package/dist/assemble-stylesheet.d.ts.map +1 -1
- package/dist/index.mjs +34 -24
- package/index.d.ts +1 -1
- package/package.json +5 -5
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The 7 Animus cascade layers
|
|
2
|
+
* The 7 Animus cascade layers. Always prefixed with `anm-` to avoid
|
|
3
|
+
* collision with other frameworks' layer names (e.g., Tailwind's `base`).
|
|
3
4
|
*/
|
|
4
|
-
export declare const ANIMUS_LAYERS: readonly ["global", "base", "variants", "compounds", "states", "system", "custom"];
|
|
5
|
+
export declare const ANIMUS_LAYERS: readonly ["anm-global", "anm-base", "anm-variants", "anm-compounds", "anm-states", "anm-system", "anm-custom"];
|
|
5
6
|
/**
|
|
6
7
|
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
7
8
|
* in the correct relative order. Consumer layers may be interleaved.
|
|
@@ -10,11 +11,15 @@ export declare const ANIMUS_LAYERS: readonly ["global", "base", "variants", "com
|
|
|
10
11
|
*/
|
|
11
12
|
export declare function validateLayerOrder(layers: string[]): void;
|
|
12
13
|
export interface AssembleStylesheetOptions {
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Custom layer order. Must contain all 7 Animus `anm-*` layers as a subsequence.
|
|
16
|
+
* Example: `['reset', 'anm-global', 'anm-base', ..., 'anm-custom', 'overrides']`
|
|
17
|
+
* Names are emitted as-is — this is the actual `@layer` declaration.
|
|
18
|
+
*/
|
|
14
19
|
layers?: string[];
|
|
15
20
|
/** Variable CSS: `:root { --color-*: ... }` + color mode selectors */
|
|
16
21
|
variableCss?: string;
|
|
17
|
-
/** Global CSS: `@layer global { reset + global styles }` */
|
|
22
|
+
/** Global CSS: `@layer anm-global { reset + global styles }` */
|
|
18
23
|
globalCss?: string;
|
|
19
24
|
/** Component CSS from the Rust crate (may contain embedded @layer declaration) */
|
|
20
25
|
componentCss?: string;
|
|
@@ -24,8 +29,8 @@ export interface AssembleStylesheetOptions {
|
|
|
24
29
|
*
|
|
25
30
|
* 1. `@layer` declaration (cascade ordering)
|
|
26
31
|
* 2. Emitted variables (`:root`, color mode selectors)
|
|
27
|
-
* 3. `@layer global { ... }` (reset + global styles)
|
|
28
|
-
* 4. `@layer base/variants/compounds/states/system/custom { ... }` (components)
|
|
32
|
+
* 3. `@layer anm-global { ... }` (reset + global styles)
|
|
33
|
+
* 4. `@layer anm-base/variants/compounds/states/system/custom { ... }` (components)
|
|
29
34
|
*
|
|
30
35
|
* This is the single source of truth for stylesheet assembly.
|
|
31
36
|
* Both Vite and Next.js plugins must use this function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble-stylesheet.d.ts","sourceRoot":"","sources":["../pipeline/assemble-stylesheet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"assemble-stylesheet.d.ts","sourceRoot":"","sources":["../pipeline/assemble-stylesheet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,gHAQhB,CAAC;AAiBX;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CA2BzD;AAYD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,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,CAqB7E"}
|
package/dist/index.mjs
CHANGED
|
@@ -7,18 +7,28 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region pipeline/assemble-stylesheet.ts
|
|
9
9
|
/**
|
|
10
|
-
* The 7 Animus cascade layers
|
|
10
|
+
* The 7 Animus cascade layers. Always prefixed with `anm-` to avoid
|
|
11
|
+
* collision with other frameworks' layer names (e.g., Tailwind's `base`).
|
|
11
12
|
*/
|
|
12
13
|
const ANIMUS_LAYERS = [
|
|
13
|
-
"global",
|
|
14
|
-
"base",
|
|
15
|
-
"variants",
|
|
16
|
-
"compounds",
|
|
17
|
-
"states",
|
|
18
|
-
"system",
|
|
19
|
-
"custom"
|
|
14
|
+
"anm-global",
|
|
15
|
+
"anm-base",
|
|
16
|
+
"anm-variants",
|
|
17
|
+
"anm-compounds",
|
|
18
|
+
"anm-states",
|
|
19
|
+
"anm-system",
|
|
20
|
+
"anm-custom"
|
|
20
21
|
];
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Build the `@layer` declaration line.
|
|
24
|
+
*
|
|
25
|
+
* When `isCustom` is false (default layers), uses ANIMUS_LAYERS directly.
|
|
26
|
+
* When `isCustom` is true, passes names through as-is — the consumer already
|
|
27
|
+
* wrote the final names including the `anm-` prefixed entries.
|
|
28
|
+
*/
|
|
29
|
+
function buildLayerDeclaration(layers, isCustom) {
|
|
30
|
+
return `@layer ${(isCustom ? layers : [...ANIMUS_LAYERS]).join(", ")};\n`;
|
|
31
|
+
}
|
|
22
32
|
/**
|
|
23
33
|
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
24
34
|
* in the correct relative order. Consumer layers may be interleaved.
|
|
@@ -26,16 +36,17 @@ const DEFAULT_LAYER_DECLARATION = `@layer ${ANIMUS_LAYERS.join(", ")};\n`;
|
|
|
26
36
|
* @throws Error with descriptive message on violation
|
|
27
37
|
*/
|
|
28
38
|
function validateLayerOrder(layers) {
|
|
39
|
+
const expected = [...ANIMUS_LAYERS];
|
|
29
40
|
let cursor = 0;
|
|
30
|
-
for (const layer of layers) if (cursor <
|
|
31
|
-
if (cursor <
|
|
32
|
-
const missing =
|
|
33
|
-
const found =
|
|
34
|
-
if (!
|
|
35
|
-
const absent =
|
|
36
|
-
throw new Error(`[animus-extract] Custom layers missing required layers: ${absent.join(", ")}. All 7 Animus layers must be present: ${
|
|
41
|
+
for (const layer of layers) if (cursor < expected.length && layer === expected[cursor]) cursor++;
|
|
42
|
+
if (cursor < expected.length) {
|
|
43
|
+
const missing = expected.slice(cursor);
|
|
44
|
+
const found = expected.slice(0, cursor);
|
|
45
|
+
if (!expected.every((l) => layers.includes(l))) {
|
|
46
|
+
const absent = expected.filter((l) => !layers.includes(l));
|
|
47
|
+
throw new Error(`[animus-extract] Custom layers missing required layers: ${absent.join(", ")}. All 7 Animus layers must be present: ${expected.join(", ")}`);
|
|
37
48
|
}
|
|
38
|
-
throw new Error(`[animus-extract] Custom layers have wrong order. Found ${found.join(", ")} but then expected ${missing[0]}. Required order: (${
|
|
49
|
+
throw new Error(`[animus-extract] Custom layers have wrong order. Found ${found.join(", ")} but then expected ${missing[0]}. Required order: (${expected.join(" < ")}). You may interleave custom layers but must preserve this subsequence.`);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
/**
|
|
@@ -51,18 +62,17 @@ function stripLeadingLayerDeclaration(css) {
|
|
|
51
62
|
*
|
|
52
63
|
* 1. `@layer` declaration (cascade ordering)
|
|
53
64
|
* 2. Emitted variables (`:root`, color mode selectors)
|
|
54
|
-
* 3. `@layer global { ... }` (reset + global styles)
|
|
55
|
-
* 4. `@layer base/variants/compounds/states/system/custom { ... }` (components)
|
|
65
|
+
* 3. `@layer anm-global { ... }` (reset + global styles)
|
|
66
|
+
* 4. `@layer anm-base/variants/compounds/states/system/custom { ... }` (components)
|
|
56
67
|
*
|
|
57
68
|
* This is the single source of truth for stylesheet assembly.
|
|
58
69
|
* Both Vite and Next.js plugins must use this function.
|
|
59
70
|
*/
|
|
60
71
|
function assembleStylesheet(options) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else layerDeclaration = DEFAULT_LAYER_DECLARATION;
|
|
72
|
+
const hasCustomLayers = !!options.layers;
|
|
73
|
+
const layers = options.layers ?? ANIMUS_LAYERS;
|
|
74
|
+
if (options.layers) validateLayerOrder(options.layers);
|
|
75
|
+
const layerDeclaration = buildLayerDeclaration(layers, hasCustomLayers);
|
|
66
76
|
const componentCss = options.componentCss ? stripLeadingLayerDeclaration(options.componentCss) : "";
|
|
67
77
|
return [
|
|
68
78
|
layerDeclaration,
|
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* Overrides hardcoded import paths in generated source. When `None`, defaults to
|
|
17
17
|
* `@animus-ui/system` and `virtual:animus/styles.css`.
|
|
18
18
|
*/
|
|
19
|
-
export declare function analyzeProject(fileEntriesJson: string, themeJson: string, variableMapJson: string, contextualVarsJson: string | undefined | null, configJson: string, groupRegistryJson: string, packageResolutionJson: string, devMode?: boolean | undefined | null,
|
|
19
|
+
export declare function analyzeProject(fileEntriesJson: string, themeJson: string, variableMapJson: string, contextualVarsJson: string | undefined | null, configJson: string, groupRegistryJson: string, packageResolutionJson: string, devMode?: boolean | undefined | null, emitterConfigJson?: string | undefined | null, selectorAliasesJson?: string | undefined | null, selectorOrderJson?: string | undefined | null): string
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Clear the per-file extraction cache used by `analyze_project()`.
|
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.48",
|
|
4
4
|
"description": "Animus static CSS extraction pipeline (Rust/NAPI)",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"compile": "tsc -p tsconfig.build.json --noEmit"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@animus-ui/extract-darwin-arm64": "0.1.0-next.
|
|
62
|
-
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.
|
|
63
|
-
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.
|
|
61
|
+
"@animus-ui/extract-darwin-arm64": "0.1.0-next.48",
|
|
62
|
+
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.48",
|
|
63
|
+
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.48"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@animus-ui/properties": "0.1.0-next.
|
|
66
|
+
"@animus-ui/properties": "0.1.0-next.48"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@animus-ui/system": "workspace:*",
|