@animus-ui/extract 0.1.0-next.23 → 0.1.0-next.31
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/discover-packages.d.ts +12 -0
- package/dist/discover-packages.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +330 -0
- package/dist/prefix.d.ts +12 -0
- package/dist/prefix.d.ts.map +1 -0
- package/dist/resolve-global-styles.d.ts +25 -0
- package/dist/resolve-global-styles.d.ts.map +1 -0
- package/dist/resolve-transforms.d.ts +9 -0
- package/dist/resolve-transforms.d.ts.map +1 -0
- package/dist/subprocess.d.ts +17 -0
- package/dist/subprocess.d.ts.map +1 -0
- package/dist/unit-fallback.d.ts +7 -0
- package/dist/unit-fallback.d.ts.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/index.d.ts +4 -1
- package/package.json +21 -7
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract external DS package names from `.includes([...])` calls in the system file.
|
|
3
|
+
*
|
|
4
|
+
* Reads the system file source, finds `.includes([identifier, ...])` calls in the
|
|
5
|
+
* builder chain, traces each identifier back to its import declaration, and returns
|
|
6
|
+
* the import specifiers. This is the authoritative mechanism — only packages explicitly
|
|
7
|
+
* declared via `.includes()` are treated as external DS dependencies.
|
|
8
|
+
*
|
|
9
|
+
* Falls back to empty array if no `.includes()` call is found.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractSystemFilePackages(systemFilePath: string): string[];
|
|
12
|
+
//# sourceMappingURL=discover-packages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-packages.d.ts","sourceRoot":"","sources":["../pipeline/discover-packages.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAyE1E"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { extractSystemFilePackages } from './discover-packages';
|
|
2
|
+
export { applyPrefix } from './prefix';
|
|
3
|
+
export { resolveGlobalStyles, resolveTokenAliases, resolveValue, } from './resolve-global-styles';
|
|
4
|
+
export { resolveTransformPlaceholders } from './resolve-transforms';
|
|
5
|
+
export { detectRuntime, execSubprocess } from './subprocess';
|
|
6
|
+
export { applyUnitFallback } from './unit-fallback';
|
|
7
|
+
export { camelToKebab } from './utils';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { execSync } from "child_process";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region pipeline/discover-packages.ts
|
|
8
|
+
/**
|
|
9
|
+
* Extract external DS package names from `.includes([...])` calls in the system file.
|
|
10
|
+
*
|
|
11
|
+
* Reads the system file source, finds `.includes([identifier, ...])` calls in the
|
|
12
|
+
* builder chain, traces each identifier back to its import declaration, and returns
|
|
13
|
+
* the import specifiers. This is the authoritative mechanism — only packages explicitly
|
|
14
|
+
* declared via `.includes()` are treated as external DS dependencies.
|
|
15
|
+
*
|
|
16
|
+
* Falls back to empty array if no `.includes()` call is found.
|
|
17
|
+
*/
|
|
18
|
+
function extractSystemFilePackages(systemFilePath) {
|
|
19
|
+
let source;
|
|
20
|
+
try {
|
|
21
|
+
source = readFileSync(systemFilePath, "utf-8");
|
|
22
|
+
} catch {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const includesRegex = /\.includes\(\s*\[([^\]]*)\]\s*\)/gs;
|
|
26
|
+
const identifiers = /* @__PURE__ */ new Set();
|
|
27
|
+
let includesMatch;
|
|
28
|
+
while ((includesMatch = includesRegex.exec(source)) !== null) {
|
|
29
|
+
const inner = includesMatch[1];
|
|
30
|
+
for (const token of inner.split(",")) {
|
|
31
|
+
const id = token.trim();
|
|
32
|
+
if (id && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(id)) identifiers.add(id);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (identifiers.size === 0) return [];
|
|
36
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
37
|
+
const importRegex = /^\s*import\s+(?:([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*)?(?:\{([^}]*)\}|([a-zA-Z_$][a-zA-Z0-9_$]*))\s+from\s+['"]([^'"]+)['"]/gm;
|
|
38
|
+
let importMatch;
|
|
39
|
+
while ((importMatch = importRegex.exec(source)) !== null) {
|
|
40
|
+
const [, comboDefault, namedImports, defaultImport, specifier] = importMatch;
|
|
41
|
+
if (comboDefault) importMap.set(comboDefault, specifier);
|
|
42
|
+
if (defaultImport) importMap.set(defaultImport, specifier);
|
|
43
|
+
if (namedImports) for (const binding of namedImports.split(",")) {
|
|
44
|
+
const parts = binding.trim().split(/\s+as\s+/);
|
|
45
|
+
const localName = (parts[1] || parts[0]).trim();
|
|
46
|
+
if (localName) importMap.set(localName, specifier);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const packages = /* @__PURE__ */ new Set();
|
|
50
|
+
for (const id of identifiers) {
|
|
51
|
+
const specifier = importMap.get(id);
|
|
52
|
+
if (specifier && !specifier.startsWith(".")) {
|
|
53
|
+
const pkgName = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
54
|
+
packages.add(pkgName);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return Array.from(packages);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region pipeline/prefix.ts
|
|
61
|
+
/**
|
|
62
|
+
* Apply namespace prefix to a variable map and CSS variable declarations.
|
|
63
|
+
*
|
|
64
|
+
* Variable map: `{ "colors.ember": "--color-ember" }` -> `{ "colors.ember": "--prefix-color-ember" }`
|
|
65
|
+
* Variable CSS: `--color-ember: #FF2800` -> `--prefix-color-ember: #FF2800`
|
|
66
|
+
* `var(--color-ember)` -> `var(--prefix-color-ember)`
|
|
67
|
+
*/
|
|
68
|
+
function applyPrefix(prefix, variableMapJson, variableCss) {
|
|
69
|
+
if (!prefix) return {
|
|
70
|
+
variableMapJson,
|
|
71
|
+
variableCss
|
|
72
|
+
};
|
|
73
|
+
const map = JSON.parse(variableMapJson);
|
|
74
|
+
const prefixed = {};
|
|
75
|
+
for (const [key, varName] of Object.entries(map)) prefixed[key] = varName.startsWith("--") ? `--${prefix}-${varName.slice(2)}` : varName;
|
|
76
|
+
let css = variableCss;
|
|
77
|
+
css = css.replace(/--([a-zA-Z][\w-]*)\s*:/g, `--${prefix}-$1:`);
|
|
78
|
+
css = css.replace(/var\(--([a-zA-Z][\w-]*)\)/g, `var(--${prefix}-$1)`);
|
|
79
|
+
return {
|
|
80
|
+
variableMapJson: JSON.stringify(prefixed),
|
|
81
|
+
variableCss: css
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region pipeline/utils.ts
|
|
86
|
+
/** Convert camelCase CSS property names to kebab-case. */
|
|
87
|
+
function camelToKebab(str) {
|
|
88
|
+
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region pipeline/resolve-global-styles.ts
|
|
92
|
+
/**
|
|
93
|
+
* Resolve {scale.path} and {scale.path/alpha} token aliases in a CSS value string.
|
|
94
|
+
* Mirrors the Rust theme_resolver's resolve_token_aliases logic.
|
|
95
|
+
*/
|
|
96
|
+
function resolveTokenAliases(value, flat, variableMap) {
|
|
97
|
+
if (!value.includes("{")) return value;
|
|
98
|
+
return value.replace(/\{([^}]+)\}/g, (_match, content) => {
|
|
99
|
+
const slashIdx = content.indexOf("/");
|
|
100
|
+
const tokenPath = slashIdx >= 0 ? content.slice(0, slashIdx) : content;
|
|
101
|
+
const alpha = slashIdx >= 0 ? Number.parseInt(content.slice(slashIdx + 1), 10) : null;
|
|
102
|
+
const flatKey = tokenPath;
|
|
103
|
+
let resolved;
|
|
104
|
+
if (variableMap[flatKey]) resolved = `var(${variableMap[flatKey]})`;
|
|
105
|
+
else if (flat[flatKey] != null) resolved = flat[flatKey];
|
|
106
|
+
else return `{${content}}`;
|
|
107
|
+
if (alpha === 0) return "transparent";
|
|
108
|
+
if (alpha != null && alpha !== 100) return `color-mix(in srgb, ${resolved} ${alpha}%, transparent)`;
|
|
109
|
+
return resolved;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve a single CSS value through prop config: scale lookup, transform, token aliases.
|
|
114
|
+
*/
|
|
115
|
+
function resolveValue(raw, config, flat, variableMap, transforms) {
|
|
116
|
+
let resolved = String(raw);
|
|
117
|
+
if (config?.scale) {
|
|
118
|
+
const key = config.scale + "." + raw;
|
|
119
|
+
if (flat[key] != null) resolved = flat[key];
|
|
120
|
+
}
|
|
121
|
+
if (config?.transform && transforms[config.transform]) {
|
|
122
|
+
const fn = transforms[config.transform];
|
|
123
|
+
const input = typeof resolved === "string" && !Number.isNaN(Number(resolved)) ? Number(resolved) : resolved;
|
|
124
|
+
resolved = String(fn(input));
|
|
125
|
+
}
|
|
126
|
+
return resolveTokenAliases(resolved, flat, variableMap);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a block of selectors -> style objects using prop config + theme.
|
|
130
|
+
* @keyframes selectors are resolved with full prop config support.
|
|
131
|
+
*/
|
|
132
|
+
function resolveBlock(selectors, propConfig, flat, variableMap, transforms) {
|
|
133
|
+
const rules = [];
|
|
134
|
+
for (const [selector, styleObj] of Object.entries(selectors)) {
|
|
135
|
+
if (selector.startsWith("@keyframes")) {
|
|
136
|
+
const frames = [];
|
|
137
|
+
for (const [pct, frameStyles] of Object.entries(styleObj)) if (typeof frameStyles === "object" && frameStyles !== null) {
|
|
138
|
+
const decls = [];
|
|
139
|
+
for (const [prop, raw] of Object.entries(frameStyles)) {
|
|
140
|
+
const cfg = propConfig[prop];
|
|
141
|
+
const cssProps = cfg?.properties?.length ? cfg.properties : cfg ? [cfg.property] : [prop];
|
|
142
|
+
const resolved = resolveValue(raw, cfg, flat, variableMap, transforms);
|
|
143
|
+
for (const cssProp of cssProps) decls.push(` ${camelToKebab(cssProp)}: ${resolved};`);
|
|
144
|
+
}
|
|
145
|
+
frames.push(` ${pct} {\n${decls.join("\n")}\n }`);
|
|
146
|
+
}
|
|
147
|
+
rules.push(`${selector} {\n${frames.join("\n")}\n}`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const decls = [];
|
|
151
|
+
for (const [prop, raw] of Object.entries(styleObj)) {
|
|
152
|
+
const config = propConfig[prop];
|
|
153
|
+
const cssProps = config?.properties?.length ? config.properties : config ? [config.property] : [prop];
|
|
154
|
+
const resolved = resolveValue(raw, config, flat, variableMap, transforms);
|
|
155
|
+
for (const cssProp of cssProps) decls.push(` ${camelToKebab(cssProp)}: ${resolved};`);
|
|
156
|
+
}
|
|
157
|
+
if (decls.length) rules.push(`${selector} {\n${decls.join("\n")}\n}`);
|
|
158
|
+
}
|
|
159
|
+
return rules.join("\n\n");
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Resolve global style blocks into CSS strings.
|
|
163
|
+
*
|
|
164
|
+
* Takes the global style map (block name -> selectors -> props -> values),
|
|
165
|
+
* resolves prop shorthand, scale lookups, transforms, and token aliases,
|
|
166
|
+
* and returns a map of block name -> resolved CSS string.
|
|
167
|
+
*/
|
|
168
|
+
function resolveGlobalStyles(globalStyles, propConfig, flat, variableMap, transforms) {
|
|
169
|
+
const result = {};
|
|
170
|
+
for (const [name, block] of Object.entries(globalStyles)) {
|
|
171
|
+
const resolved = resolveBlock(block, propConfig, flat, variableMap, transforms);
|
|
172
|
+
if (resolved) result[name] = resolved;
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region pipeline/resolve-transforms.ts
|
|
178
|
+
/**
|
|
179
|
+
* Resolve __TRANSFORM__ placeholders in extracted CSS.
|
|
180
|
+
*
|
|
181
|
+
* Pattern: `__TRANSFORM__name__rawValue__` -> transform function result.
|
|
182
|
+
* The Rust crate emits these placeholders for CSS values that require
|
|
183
|
+
* JS transform functions (e.g., size, grid) which can't be evaluated in Rust.
|
|
184
|
+
*/
|
|
185
|
+
function resolveTransformPlaceholders(css, transforms) {
|
|
186
|
+
return css.replace(/__TRANSFORM__(\w+)__(.+?)__/g, (_, name, rawValue) => {
|
|
187
|
+
const fn = transforms[name];
|
|
188
|
+
if (!fn) return rawValue;
|
|
189
|
+
const result = fn(rawValue !== "" && !Number.isNaN(Number(rawValue)) ? Number(rawValue) : rawValue);
|
|
190
|
+
return typeof result === "object" ? JSON.stringify(result) : String(result);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region pipeline/subprocess.ts
|
|
195
|
+
let cachedRuntime = null;
|
|
196
|
+
/**
|
|
197
|
+
* Detect which JS runtime is available for subprocess execution.
|
|
198
|
+
* Prefers bun (faster startup), falls back to node.
|
|
199
|
+
* Result is cached for the process lifetime.
|
|
200
|
+
*/
|
|
201
|
+
function detectRuntime() {
|
|
202
|
+
if (cachedRuntime) return cachedRuntime;
|
|
203
|
+
try {
|
|
204
|
+
execSync("bun --version", { stdio: "ignore" });
|
|
205
|
+
cachedRuntime = "bun";
|
|
206
|
+
} catch {
|
|
207
|
+
cachedRuntime = "node";
|
|
208
|
+
}
|
|
209
|
+
return cachedRuntime;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Execute a CJS script string via the detected runtime.
|
|
213
|
+
* The script must use `require()` and synchronous Node APIs — compatible with both bun and node.
|
|
214
|
+
*
|
|
215
|
+
* @param script - The CJS script content to execute
|
|
216
|
+
* @param cwd - Working directory for the subprocess
|
|
217
|
+
* @param args - Optional CLI arguments passed after the script path
|
|
218
|
+
* @returns stdout of the subprocess
|
|
219
|
+
*/
|
|
220
|
+
function execSubprocess(script, cwd, args = []) {
|
|
221
|
+
const { writeFileSync, unlinkSync } = __require("fs");
|
|
222
|
+
const { join } = __require("path");
|
|
223
|
+
const { tmpdir } = __require("os");
|
|
224
|
+
const runtime = detectRuntime();
|
|
225
|
+
const ts = Date.now();
|
|
226
|
+
const tmpScript = join(tmpdir(), `animus-subprocess-${ts}.cjs`);
|
|
227
|
+
writeFileSync(tmpScript, script);
|
|
228
|
+
try {
|
|
229
|
+
const argsStr = args.map((a) => `"${a}"`).join(" ");
|
|
230
|
+
return execSync(runtime === "bun" ? `bun run "${tmpScript}" ${argsStr}` : `node "${tmpScript}" ${argsStr}`, {
|
|
231
|
+
cwd,
|
|
232
|
+
encoding: "utf-8"
|
|
233
|
+
});
|
|
234
|
+
} finally {
|
|
235
|
+
try {
|
|
236
|
+
unlinkSync(tmpScript);
|
|
237
|
+
} catch {}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region pipeline/unit-fallback.ts
|
|
242
|
+
/**
|
|
243
|
+
* CSS properties that accept unitless numeric values.
|
|
244
|
+
* Matches @emotion/unitless and React DOM's style handling.
|
|
245
|
+
* Bare numerics on properties NOT in this set receive `px`.
|
|
246
|
+
*/
|
|
247
|
+
const UNITLESS_PROPERTIES = new Set([
|
|
248
|
+
"animation-iteration-count",
|
|
249
|
+
"border-image-outset",
|
|
250
|
+
"border-image-slice",
|
|
251
|
+
"border-image-width",
|
|
252
|
+
"box-flex",
|
|
253
|
+
"box-flex-group",
|
|
254
|
+
"box-ordinal-group",
|
|
255
|
+
"column-count",
|
|
256
|
+
"columns",
|
|
257
|
+
"flex",
|
|
258
|
+
"flex-grow",
|
|
259
|
+
"flex-positive",
|
|
260
|
+
"flex-shrink",
|
|
261
|
+
"flex-negative",
|
|
262
|
+
"flex-order",
|
|
263
|
+
"grid-area",
|
|
264
|
+
"grid-row",
|
|
265
|
+
"grid-row-end",
|
|
266
|
+
"grid-row-span",
|
|
267
|
+
"grid-row-start",
|
|
268
|
+
"grid-column",
|
|
269
|
+
"grid-column-end",
|
|
270
|
+
"grid-column-span",
|
|
271
|
+
"grid-column-start",
|
|
272
|
+
"font-weight",
|
|
273
|
+
"line-clamp",
|
|
274
|
+
"line-height",
|
|
275
|
+
"opacity",
|
|
276
|
+
"order",
|
|
277
|
+
"orphans",
|
|
278
|
+
"tab-size",
|
|
279
|
+
"widows",
|
|
280
|
+
"z-index",
|
|
281
|
+
"zoom",
|
|
282
|
+
"fill-opacity",
|
|
283
|
+
"flood-opacity",
|
|
284
|
+
"stop-opacity",
|
|
285
|
+
"stroke-dasharray",
|
|
286
|
+
"stroke-dashoffset",
|
|
287
|
+
"stroke-miterlimit",
|
|
288
|
+
"stroke-opacity",
|
|
289
|
+
"stroke-width"
|
|
290
|
+
]);
|
|
291
|
+
/**
|
|
292
|
+
* Append `px` to bare numeric values in CSS declarations for properties
|
|
293
|
+
* that expect length units. Unitless properties are preserved as-is.
|
|
294
|
+
* Numbers inside CSS function calls (cubic-bezier, rgb, calc, etc.) are skipped.
|
|
295
|
+
*/
|
|
296
|
+
function applyUnitFallback(css) {
|
|
297
|
+
return css.replace(/([a-z-]+)\s*:\s*([^;{}]+);/g, (match, prop, value) => {
|
|
298
|
+
if (UNITLESS_PROPERTIES.has(prop)) return match;
|
|
299
|
+
let depth = 0;
|
|
300
|
+
let fixed = "";
|
|
301
|
+
let i = 0;
|
|
302
|
+
while (i < value.length) if (value[i] === "(") {
|
|
303
|
+
depth++;
|
|
304
|
+
fixed += value[i];
|
|
305
|
+
i++;
|
|
306
|
+
} else if (value[i] === ")") {
|
|
307
|
+
depth--;
|
|
308
|
+
fixed += value[i];
|
|
309
|
+
i++;
|
|
310
|
+
} else if (depth > 0) {
|
|
311
|
+
fixed += value[i];
|
|
312
|
+
i++;
|
|
313
|
+
} else {
|
|
314
|
+
const numMatch = value.slice(i).match(/^(-?\d+\.?\d*)/);
|
|
315
|
+
if (numMatch) {
|
|
316
|
+
const num = numMatch[1];
|
|
317
|
+
const after = value[i + num.length];
|
|
318
|
+
if (after && /[a-z%]/i.test(after)) fixed += num;
|
|
319
|
+
else fixed += num + "px";
|
|
320
|
+
i += num.length;
|
|
321
|
+
} else {
|
|
322
|
+
fixed += value[i];
|
|
323
|
+
i++;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return fixed !== value ? `${prop}:${fixed};` : match;
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
//#endregion
|
|
330
|
+
export { applyPrefix, applyUnitFallback, camelToKebab, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles, resolveTokenAliases, resolveTransformPlaceholders, resolveValue };
|
package/dist/prefix.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply namespace prefix to a variable map and CSS variable declarations.
|
|
3
|
+
*
|
|
4
|
+
* Variable map: `{ "colors.ember": "--color-ember" }` -> `{ "colors.ember": "--prefix-color-ember" }`
|
|
5
|
+
* Variable CSS: `--color-ember: #FF2800` -> `--prefix-color-ember: #FF2800`
|
|
6
|
+
* `var(--color-ember)` -> `var(--prefix-color-ember)`
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyPrefix(prefix: string, variableMapJson: string, variableCss: string): {
|
|
9
|
+
variableMapJson: string;
|
|
10
|
+
variableCss: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../pipeline/prefix.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAmBlD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface PropConfigEntry {
|
|
2
|
+
property?: string;
|
|
3
|
+
properties?: string[];
|
|
4
|
+
scale?: string;
|
|
5
|
+
transform?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolve {scale.path} and {scale.path/alpha} token aliases in a CSS value string.
|
|
9
|
+
* Mirrors the Rust theme_resolver's resolve_token_aliases logic.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveTokenAliases(value: string, flat: Record<string, string>, variableMap: Record<string, string>): string;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a single CSS value through prop config: scale lookup, transform, token aliases.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveValue(raw: unknown, config: PropConfigEntry | undefined, flat: Record<string, string>, variableMap: Record<string, string>, transforms: Record<string, (v: unknown) => unknown>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve global style blocks into CSS strings.
|
|
18
|
+
*
|
|
19
|
+
* Takes the global style map (block name -> selectors -> props -> values),
|
|
20
|
+
* resolves prop shorthand, scale lookups, transforms, and token aliases,
|
|
21
|
+
* and returns a map of block name -> resolved CSS string.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveGlobalStyles(globalStyles: Record<string, Record<string, Record<string, unknown>>>, propConfig: Record<string, PropConfigEntry>, flat: Record<string, string>, variableMap: Record<string, string>, transforms: Record<string, (v: unknown) => unknown>): Record<string, string>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=resolve-global-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-global-styles.d.ts","sourceRoot":"","sources":["../pipeline/resolve-global-styles.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,MAAM,CA2BR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,GAClD,MAAM,CAkBR;AAsED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EACrE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,GAClD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAexB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve __TRANSFORM__ placeholders in extracted CSS.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: `__TRANSFORM__name__rawValue__` -> transform function result.
|
|
5
|
+
* The Rust crate emits these placeholders for CSS values that require
|
|
6
|
+
* JS transform functions (e.g., size, grid) which can't be evaluated in Rust.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveTransformPlaceholders(css: string, transforms: Record<string, (v: unknown) => unknown>): string;
|
|
9
|
+
//# sourceMappingURL=resolve-transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-transforms.d.ts","sourceRoot":"","sources":["../pipeline/resolve-transforms.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,GAClD,MAAM,CAgBR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect which JS runtime is available for subprocess execution.
|
|
3
|
+
* Prefers bun (faster startup), falls back to node.
|
|
4
|
+
* Result is cached for the process lifetime.
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectRuntime(): 'bun' | 'node';
|
|
7
|
+
/**
|
|
8
|
+
* Execute a CJS script string via the detected runtime.
|
|
9
|
+
* The script must use `require()` and synchronous Node APIs — compatible with both bun and node.
|
|
10
|
+
*
|
|
11
|
+
* @param script - The CJS script content to execute
|
|
12
|
+
* @param cwd - Working directory for the subprocess
|
|
13
|
+
* @param args - Optional CLI arguments passed after the script path
|
|
14
|
+
* @returns stdout of the subprocess
|
|
15
|
+
*/
|
|
16
|
+
export declare function execSubprocess(script: string, cwd: string, args?: string[]): string;
|
|
17
|
+
//# sourceMappingURL=subprocess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subprocess.d.ts","sourceRoot":"","sources":["../pipeline/subprocess.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,KAAK,GAAG,MAAM,CAW9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAwBR"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append `px` to bare numeric values in CSS declarations for properties
|
|
3
|
+
* that expect length units. Unitless properties are preserved as-is.
|
|
4
|
+
* Numbers inside CSS function calls (cubic-bezier, rgb, calc, etc.) are skipped.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyUnitFallback(css: string): string;
|
|
7
|
+
//# sourceMappingURL=unit-fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-fallback.d.ts","sourceRoot":"","sources":["../pipeline/unit-fallback.ts"],"names":[],"mappings":"AAkDA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA2CrD"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../pipeline/utils.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/index.d.ts
CHANGED
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
* e.g. `{ "@my-ui/components": "pkg-barrel/index.ts" }`. Pass `"{}"` when not needed.
|
|
13
13
|
* - `prefix`: optional namespace prefix for class names and CSS custom properties.
|
|
14
14
|
* When set, `animus-` is replaced with `{prefix}-` in all generated identifiers.
|
|
15
|
+
* - `emitter_config_json`: optional JSON `{ "runtime_import": "...", "css_module_id": "..." }`.
|
|
16
|
+
* Overrides hardcoded import paths in generated source. When `None`, defaults to
|
|
17
|
+
* `@animus-ui/system` and `virtual:animus/styles.css`.
|
|
15
18
|
*/
|
|
16
|
-
export declare function analyzeProject(fileEntriesJson: string, themeJson: string, variableMapJson: string, contextualVarsJson: string | undefined | null, configJson: string, groupRegistryJson: string, packageResolutionJson: string, devMode?: boolean | undefined | null, prefix?: string | undefined | null): string
|
|
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, prefix?: string | undefined | null, emitterConfigJson?: string | undefined | null): string
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Clear the per-file extraction cache used by `analyze_project()`.
|
package/package.json
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/extract",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.31",
|
|
4
4
|
"description": "Animus static CSS extraction pipeline (Rust/NAPI)",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"require": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./pipeline": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
9
20
|
"files": [
|
|
10
21
|
"index.js",
|
|
11
22
|
"index.d.ts",
|
|
12
|
-
"*.node"
|
|
23
|
+
"*.node",
|
|
24
|
+
"dist"
|
|
13
25
|
],
|
|
14
26
|
"publishConfig": {
|
|
15
27
|
"access": "public"
|
|
@@ -27,15 +39,17 @@
|
|
|
27
39
|
]
|
|
28
40
|
},
|
|
29
41
|
"scripts": {
|
|
30
|
-
"build": "napi build --platform --release",
|
|
31
|
-
"build:debug": "napi build --platform"
|
|
42
|
+
"build": "napi build --platform --release && tsdown && tsc -p tsconfig.build.json",
|
|
43
|
+
"build:debug": "napi build --platform",
|
|
44
|
+
"build:pipeline": "tsdown && tsc -p tsconfig.build.json"
|
|
32
45
|
},
|
|
33
46
|
"optionalDependencies": {
|
|
34
|
-
"@animus-ui/extract-darwin-arm64": "0.1.0-next.
|
|
35
|
-
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.
|
|
36
|
-
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.
|
|
47
|
+
"@animus-ui/extract-darwin-arm64": "0.1.0-next.31",
|
|
48
|
+
"@animus-ui/extract-linux-x64-gnu": "0.1.0-next.31",
|
|
49
|
+
"@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.31"
|
|
37
50
|
},
|
|
38
51
|
"devDependencies": {
|
|
52
|
+
"@animus-ui/system": "workspace:*",
|
|
39
53
|
"@napi-rs/cli": "^3.0.0"
|
|
40
54
|
}
|
|
41
55
|
}
|