@animus-ui/extract 0.1.0-next.40 → 0.1.0-next.45
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 +18 -2
- package/dist/assemble-stylesheet.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +39 -16
- package/package.json +5 -5
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,16 +2,32 @@
|
|
|
2
2
|
* The 7 Animus cascade layers in required order.
|
|
3
3
|
*/
|
|
4
4
|
export declare const ANIMUS_LAYERS: readonly ["global", "base", "variants", "compounds", "states", "system", "custom"];
|
|
5
|
+
/**
|
|
6
|
+
* Prefix a layer name with dot-notation sublayer syntax.
|
|
7
|
+
* Only Animus layer names are prefixed; consumer layer names pass through.
|
|
8
|
+
*/
|
|
9
|
+
export declare function prefixLayerName(name: string, prefix?: string): string;
|
|
5
10
|
/**
|
|
6
11
|
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
7
12
|
* in the correct relative order. Consumer layers may be interleaved.
|
|
8
13
|
*
|
|
14
|
+
* When `prefix` is set, the expected Animus layer names are `{prefix}.{name}`
|
|
15
|
+
* (e.g. `acme.base`). This lets consumers write the actual CSS layer names
|
|
16
|
+
* in their config — important when composing with other frameworks that have
|
|
17
|
+
* their own `@layer base` etc.
|
|
18
|
+
*
|
|
9
19
|
* @throws Error with descriptive message on violation
|
|
10
20
|
*/
|
|
11
|
-
export declare function validateLayerOrder(layers: string[]): void;
|
|
21
|
+
export declare function validateLayerOrder(layers: string[], prefix?: string): void;
|
|
12
22
|
export interface AssembleStylesheetOptions {
|
|
13
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Custom layer order. Must contain all 7 Animus layers as a subsequence.
|
|
25
|
+
* When `prefix` is set, use prefixed names: `['reset', 'acme.global', 'acme.base', ...]`.
|
|
26
|
+
* Names are emitted as-is — this is the actual `@layer` declaration.
|
|
27
|
+
*/
|
|
14
28
|
layers?: string[];
|
|
29
|
+
/** Namespace prefix — Animus layer names become `{prefix}.{name}` sublayers. */
|
|
30
|
+
prefix?: string;
|
|
15
31
|
/** Variable CSS: `:root { --color-*: ... }` + color mode selectors */
|
|
16
32
|
variableCss?: string;
|
|
17
33
|
/** Global CSS: `@layer global { reset + global styles }` */
|
|
@@ -1 +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
|
|
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;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrE;AAkBD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CA2BN;AAYD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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,CAyB7E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { AssembleStylesheetOptions } from './assemble-stylesheet';
|
|
2
|
-
export { ANIMUS_LAYERS, assembleStylesheet, validateLayerOrder, } from './assemble-stylesheet';
|
|
2
|
+
export { ANIMUS_LAYERS, assembleStylesheet, prefixLayerName, validateLayerOrder, } from './assemble-stylesheet';
|
|
3
3
|
export { extractSystemFilePackages } from './discover-packages';
|
|
4
4
|
export { applyPrefix } from './prefix';
|
|
5
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,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"}
|
|
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,eAAe,EACf,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
|
@@ -18,24 +18,48 @@ const ANIMUS_LAYERS = [
|
|
|
18
18
|
"system",
|
|
19
19
|
"custom"
|
|
20
20
|
];
|
|
21
|
-
const
|
|
21
|
+
const ANIMUS_LAYER_SET = new Set(ANIMUS_LAYERS);
|
|
22
|
+
/**
|
|
23
|
+
* Prefix a layer name with dot-notation sublayer syntax.
|
|
24
|
+
* Only Animus layer names are prefixed; consumer layer names pass through.
|
|
25
|
+
*/
|
|
26
|
+
function prefixLayerName(name, prefix) {
|
|
27
|
+
if (!prefix || !ANIMUS_LAYER_SET.has(name)) return name;
|
|
28
|
+
return `${prefix}.${name}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build the `@layer` declaration line.
|
|
32
|
+
*
|
|
33
|
+
* When `isCustom` is false (default layers), applies prefix to Animus names.
|
|
34
|
+
* When `isCustom` is true, passes names through as-is — the consumer already
|
|
35
|
+
* wrote the final names including any `{prefix}.{name}` entries.
|
|
36
|
+
*/
|
|
37
|
+
function buildLayerDeclaration(layers, prefix, isCustom) {
|
|
38
|
+
return `@layer ${(isCustom ? layers : layers.map((l) => prefixLayerName(l, prefix))).join(", ")};\n`;
|
|
39
|
+
}
|
|
22
40
|
/**
|
|
23
41
|
* Validate that a consumer `layers` array contains all 7 Animus layers
|
|
24
42
|
* in the correct relative order. Consumer layers may be interleaved.
|
|
25
43
|
*
|
|
44
|
+
* When `prefix` is set, the expected Animus layer names are `{prefix}.{name}`
|
|
45
|
+
* (e.g. `acme.base`). This lets consumers write the actual CSS layer names
|
|
46
|
+
* in their config — important when composing with other frameworks that have
|
|
47
|
+
* their own `@layer base` etc.
|
|
48
|
+
*
|
|
26
49
|
* @throws Error with descriptive message on violation
|
|
27
50
|
*/
|
|
28
|
-
function validateLayerOrder(layers) {
|
|
51
|
+
function validateLayerOrder(layers, prefix) {
|
|
52
|
+
const expected = ANIMUS_LAYERS.map((l) => prefixLayerName(l, prefix));
|
|
29
53
|
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: ${
|
|
54
|
+
for (const layer of layers) if (cursor < expected.length && layer === expected[cursor]) cursor++;
|
|
55
|
+
if (cursor < expected.length) {
|
|
56
|
+
const missing = expected.slice(cursor);
|
|
57
|
+
const found = expected.slice(0, cursor);
|
|
58
|
+
if (!expected.every((l) => layers.includes(l))) {
|
|
59
|
+
const absent = expected.filter((l) => !layers.includes(l));
|
|
60
|
+
throw new Error(`[animus-extract] Custom layers missing required layers: ${absent.join(", ")}. All 7 Animus layers must be present: ${expected.join(", ")}`);
|
|
37
61
|
}
|
|
38
|
-
throw new Error(`[animus-extract] Custom layers have wrong order. Found ${found.join(", ")} but then expected ${missing[0]}. Required order: (${
|
|
62
|
+
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
63
|
}
|
|
40
64
|
}
|
|
41
65
|
/**
|
|
@@ -58,11 +82,10 @@ function stripLeadingLayerDeclaration(css) {
|
|
|
58
82
|
* Both Vite and Next.js plugins must use this function.
|
|
59
83
|
*/
|
|
60
84
|
function assembleStylesheet(options) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else layerDeclaration = DEFAULT_LAYER_DECLARATION;
|
|
85
|
+
const hasCustomLayers = !!options.layers;
|
|
86
|
+
const layers = options.layers ?? ANIMUS_LAYERS;
|
|
87
|
+
if (options.layers) validateLayerOrder(options.layers, options.prefix);
|
|
88
|
+
const layerDeclaration = buildLayerDeclaration(layers, options.prefix, hasCustomLayers);
|
|
66
89
|
const componentCss = options.componentCss ? stripLeadingLayerDeclaration(options.componentCss) : "";
|
|
67
90
|
return [
|
|
68
91
|
layerDeclaration,
|
|
@@ -358,4 +381,4 @@ function applyUnitFallback(css) {
|
|
|
358
381
|
});
|
|
359
382
|
}
|
|
360
383
|
//#endregion
|
|
361
|
-
export { ANIMUS_LAYERS, applyPrefix, applyUnitFallback, assembleStylesheet, camelToKebab, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles, resolveTokenAliases, resolveTransformPlaceholders, resolveValue, validateLayerOrder };
|
|
384
|
+
export { ANIMUS_LAYERS, applyPrefix, applyUnitFallback, assembleStylesheet, camelToKebab, detectRuntime, execSubprocess, extractSystemFilePackages, prefixLayerName, resolveGlobalStyles, resolveTokenAliases, resolveTransformPlaceholders, resolveValue, validateLayerOrder };
|
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.45",
|
|
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.45",
|
|
62
|
+
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.45",
|
|
63
|
+
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.45"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@animus-ui/properties": "0.1.0-next.
|
|
66
|
+
"@animus-ui/properties": "0.1.0-next.45"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@animus-ui/system": "workspace:*",
|