@animus-ui/next-plugin 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/index.mjs +16 -9
- package/dist/plugin.d.ts.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSy
|
|
|
3
3
|
import { dirname, extname, join, relative, resolve, sep } from "path";
|
|
4
4
|
import { createHash } from "crypto";
|
|
5
5
|
import { tmpdir } from "os";
|
|
6
|
-
import { applyPrefix, applyUnitFallback, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles } from "@animus-ui/extract/pipeline";
|
|
6
|
+
import { applyPrefix, applyUnitFallback, assembleStylesheet, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles } from "@animus-ui/extract/pipeline";
|
|
7
7
|
//#region src/plugin.ts
|
|
8
8
|
const PLUGIN_NAME = "AnimusWebpackPlugin";
|
|
9
9
|
var AnimusWebpackPlugin = class {
|
|
@@ -184,11 +184,12 @@ var AnimusWebpackPlugin = class {
|
|
|
184
184
|
let componentCss = manifest?.css || "";
|
|
185
185
|
if (this.systemResolveScript && componentCss.includes("__TRANSFORM__")) componentCss = this.resolveTransforms(rootDir, componentCss);
|
|
186
186
|
componentCss = applyUnitFallback(componentCss);
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
const fullCss = assembleStylesheet({
|
|
188
|
+
layers: this.options.layers,
|
|
189
|
+
variableCss: this.variableCss,
|
|
190
|
+
globalCss: this.globalCss,
|
|
191
|
+
componentCss
|
|
192
|
+
});
|
|
192
193
|
const cssHash = createHash("md5").update(fullCss).digest("hex");
|
|
193
194
|
if (cssHash !== this.lastCssHash) {
|
|
194
195
|
const animusDir = join(rootDir, ".animus");
|
|
@@ -223,7 +224,7 @@ var AnimusWebpackPlugin = class {
|
|
|
223
224
|
}
|
|
224
225
|
loadSystem(rootDir, systemPath) {
|
|
225
226
|
const tmpOut = join(tmpdir(), `animus-system-${Date.now()}.json`);
|
|
226
|
-
execSubprocess(`const m = require(${JSON.stringify(systemPath)});\nconst ds = m.ds || m.default || m.system;\nif (!ds || !ds.toConfig) { throw new Error('Module does not export a SystemInstance with .serialize()'); }\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);
|
|
227
|
+
execSubprocess(`const m = require(${JSON.stringify(systemPath)});\nconst ds = m.ds || m.default || m.system;\nif (!ds || !ds.toConfig) { throw new Error('Module does not export a SystemInstance with .serialize()'); }\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}\nconst transformSources = {};\nfor (const [name, fn] of Object.entries(cfg.transforms || {})) {\n transformSources[name] = fn.toString();\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 transformSources: transformSources,\n globalStyleBlocks: Object.keys(globalStyleBlocks).length > 0 ? globalStyleBlocks : null\n}));\n`, rootDir);
|
|
227
228
|
const result = readFileSync(tmpOut, "utf-8");
|
|
228
229
|
try {
|
|
229
230
|
__require("fs").unlinkSync(tmpOut);
|
|
@@ -237,18 +238,24 @@ var AnimusWebpackPlugin = class {
|
|
|
237
238
|
this.variableCss = parsed.serialized.variableCss;
|
|
238
239
|
this.contextualVarsJson = parsed.serialized.contextualVarsJson;
|
|
239
240
|
if (this.options.prefix) {
|
|
240
|
-
const prefixed = applyPrefix(this.options.prefix, this.variableMapJson, this.variableCss);
|
|
241
|
+
const prefixed = applyPrefix(this.options.prefix, this.variableMapJson, this.variableCss, this.themeJson);
|
|
241
242
|
this.variableMapJson = prefixed.variableMapJson;
|
|
242
243
|
this.variableCss = prefixed.variableCss;
|
|
244
|
+
if (prefixed.themeJson) this.themeJson = prefixed.themeJson;
|
|
243
245
|
}
|
|
244
246
|
} else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
|
|
245
247
|
if (parsed.globalStyleBlocks) {
|
|
246
248
|
if (Object.keys(parsed.globalStyleBlocks).length > 0) try {
|
|
249
|
+
const hasTransforms = parsed.transformNames && parsed.transformNames.length > 0;
|
|
247
250
|
const flat = JSON.parse(this.themeJson);
|
|
248
251
|
const propConfig = JSON.parse(this.configJson);
|
|
249
252
|
const variableMap = {};
|
|
250
253
|
for (const [tokenPath, value] of Object.entries(flat)) if (typeof value === "string" && value.startsWith("var(") && value.endsWith(")")) variableMap[tokenPath] = value.slice(4, -1);
|
|
251
|
-
const
|
|
254
|
+
const transforms = {};
|
|
255
|
+
if (hasTransforms && parsed.transformSources) for (const [name, src] of Object.entries(parsed.transformSources)) try {
|
|
256
|
+
transforms[name] = new Function(`return (${src})`)();
|
|
257
|
+
} catch {}
|
|
258
|
+
const gsResult = resolveGlobalStyles(parsed.globalStyleBlocks, propConfig, flat, variableMap, transforms);
|
|
252
259
|
const parts = Object.values(gsResult).filter(Boolean);
|
|
253
260
|
if (parts.length > 0) this.globalCss = `@layer global {\n${parts.join("\n\n")}\n}`;
|
|
254
261
|
} catch (e) {
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE;QACL,GAAG,EAAE;YACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;SACxE,CAAC;QACF,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;SACxE,CAAC;KACH,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAuB;IAGtC,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,mBAAmB,CAAuB;IAGlD,OAAO,CAAC,SAAS,CAAuD;IACxE,OAAO,CAAC,WAAW,CAAuB;IAG1C,OAAO,CAAC,mBAAmB,CAAgB;IAG3C,OAAO,CAAC,qBAAqB,CAA6B;gBAE9C,OAAO,EAAE,iBAAiB;IAItC,OAAO,CAAC,WAAW,CAAS;IAE5B,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;YA2CjB,iBAAiB;YAwDjB,eAAe;IA8M7B,OAAO,CAAC,UAAU;IA0JlB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,qBAAqB;IAmD7B;;OAEG;IACH,WAAW,IAAI,IAAI;IASnB,iDAAiD;IACjD,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAI7D,oCAAoC;IACpC,UAAU,IAAI,iBAAiB;IAI/B,0EAA0E;IAC1E,sBAAsB,IAAI,MAAM,EAAE;IAIlC,uEAAuE;IACvE,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAGhD"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,5 +9,13 @@ export interface AnimusNextOptions {
|
|
|
9
9
|
verbose?: boolean;
|
|
10
10
|
/** Namespace prefix for CSS variables and class names. */
|
|
11
11
|
prefix?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Full `@layer` declaration order. Must include all 7 Animus layers
|
|
14
|
+
* (`global`, `base`, `variants`, `compounds`, `states`, `system`, `custom`)
|
|
15
|
+
* as a subsequence. Consumer layers may be interleaved.
|
|
16
|
+
*
|
|
17
|
+
* @example ['reset', 'global', 'base', 'variants', 'compounds', 'states', 'system', 'custom', 'overrides']
|
|
18
|
+
*/
|
|
19
|
+
layers?: string[];
|
|
12
20
|
}
|
|
13
21
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/next-plugin",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.34",
|
|
4
4
|
"description": "Animus static CSS extraction for Next.js (webpack)",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"webpack": ">=5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
41
|
+
"@animus-ui/extract": "0.1.0-next.34"
|
|
42
42
|
}
|
|
43
43
|
}
|