@animus-ui/vite-plugin 0.1.0-next.39 → 0.1.0-next.44
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.d.ts.map +1 -1
- package/dist/index.mjs +32 -3
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA0hCnE;AAED,eAAe,aAAa,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -113,6 +113,8 @@ function animusExtract(options) {
|
|
|
113
113
|
let contextualVarsJson = "{}";
|
|
114
114
|
let configJson = "{}";
|
|
115
115
|
let groupRegistryJson = "{}";
|
|
116
|
+
let selectorAliasesJson = null;
|
|
117
|
+
let selectorOrderJson = null;
|
|
116
118
|
let isProd = false;
|
|
117
119
|
let rootDir = "";
|
|
118
120
|
const verbose = options.verbose || process.env.ANIMUS_DEBUG === "1" || process.env.ANIMUS_DEBUG === "true";
|
|
@@ -138,6 +140,7 @@ function animusExtract(options) {
|
|
|
138
140
|
let packageMap = {};
|
|
139
141
|
let externalPackageDirs = [];
|
|
140
142
|
const externalSourceEntries = /* @__PURE__ */ new Map();
|
|
143
|
+
let devServer;
|
|
141
144
|
let bridgeInjected = false;
|
|
142
145
|
let resolvedSystemPath = null;
|
|
143
146
|
/**
|
|
@@ -150,7 +153,7 @@ function animusExtract(options) {
|
|
|
150
153
|
try {
|
|
151
154
|
const ts = Date.now();
|
|
152
155
|
const tmpOut = join(tmpdir(), `animus-system-${ts}.json`);
|
|
153
|
-
execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst exportNames = Object.keys(m);\nconst candidates = exportNames.filter(k => m[k] && typeof m[k].toConfig === 'function');\nif (candidates.length === 0) {\n throw new Error('[animus-extract] No SystemInstance found. Exports: [' + exportNames.join(', ') + ']. None have a .toConfig() method. A SystemInstance is created by: export const ds = createSystem().build()');\n}\nif (candidates.length > 1) {\n throw new Error('[animus-extract] Multiple SystemInstance candidates found: [' + candidates.join(', ') + ']. Specify which one to use.');\n}\nconst ds = m[candidates[0]];\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);
|
|
156
|
+
execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst exportNames = Object.keys(m);\nconst candidates = exportNames.filter(k => m[k] && typeof m[k].toConfig === 'function');\nif (candidates.length === 0) {\n throw new Error('[animus-extract] No SystemInstance found. Exports: [' + exportNames.join(', ') + ']. None have a .toConfig() method. A SystemInstance is created by: export const ds = createSystem().build()');\n}\nif (candidates.length > 1) {\n throw new Error('[animus-extract] Multiple SystemInstance candidates found: [' + candidates.join(', ') + ']. Specify which one to use.');\n}\nconst ds = m[candidates[0]];\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 selectorAliases: cfg.selectorAliases || null,\n selectorOrder: cfg.selectorOrder || null,\n globalStyleBlocks: Object.keys(globalStyleBlocks).length > 0 ? globalStyleBlocks : null\n}));\n`, rootDir);
|
|
154
157
|
const result = readFileSync(tmpOut, "utf-8");
|
|
155
158
|
try {
|
|
156
159
|
unlinkSync(tmpOut);
|
|
@@ -158,6 +161,8 @@ function animusExtract(options) {
|
|
|
158
161
|
const parsed = JSON.parse(result);
|
|
159
162
|
configJson = parsed.propConfig;
|
|
160
163
|
groupRegistryJson = parsed.groupRegistry;
|
|
164
|
+
selectorAliasesJson = parsed.selectorAliases || null;
|
|
165
|
+
selectorOrderJson = parsed.selectorOrder || null;
|
|
161
166
|
if (parsed.serialized) {
|
|
162
167
|
themeJson = parsed.serialized.scalesJson;
|
|
163
168
|
variableMapJson = parsed.serialized.variableMapJson;
|
|
@@ -233,7 +238,7 @@ function animusExtract(options) {
|
|
|
233
238
|
runtime_import: "@animus-ui/system",
|
|
234
239
|
css_module_id: "virtual:animus/styles.css"
|
|
235
240
|
});
|
|
236
|
-
const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, contextualVarsJson || null, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd, options.prefix || null, emitterConfig);
|
|
241
|
+
const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, contextualVarsJson || null, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd, options.prefix || null, emitterConfig, selectorAliasesJson, selectorOrderJson);
|
|
237
242
|
storedManifest = JSON.parse(manifestJson);
|
|
238
243
|
storedManifestJson = manifestJson;
|
|
239
244
|
storedSystemPropMapJson = JSON.stringify(storedManifest?.system_prop_map ?? {});
|
|
@@ -283,6 +288,9 @@ function animusExtract(options) {
|
|
|
283
288
|
return {
|
|
284
289
|
name: "animus-extract",
|
|
285
290
|
enforce: "pre",
|
|
291
|
+
configureServer(server) {
|
|
292
|
+
devServer = server;
|
|
293
|
+
},
|
|
286
294
|
configResolved(config) {
|
|
287
295
|
isProd = config.command === "build";
|
|
288
296
|
rootDir = config.root;
|
|
@@ -502,7 +510,28 @@ if (import.meta.hot) {
|
|
|
502
510
|
if (id.includes("node_modules")) return null;
|
|
503
511
|
}
|
|
504
512
|
const relativePath = relative(rootDir, id);
|
|
505
|
-
if (!storedManifest.files?.[relativePath]?.length)
|
|
513
|
+
if (!storedManifest.files?.[relativePath]?.length) {
|
|
514
|
+
if (!isProd && !fileCache.has(relativePath)) {
|
|
515
|
+
const hash = contentHash(code);
|
|
516
|
+
fileCache.set(relativePath, {
|
|
517
|
+
hash,
|
|
518
|
+
source: code
|
|
519
|
+
});
|
|
520
|
+
runAnalysis(buildFileEntriesFromCache(fileCache, relativePath));
|
|
521
|
+
const compCount = storedManifest.files?.[relativePath]?.length ?? 0;
|
|
522
|
+
log(`New file detected: ${relativePath} — ${compCount ? `${compCount} components extracted` : "no components"}`);
|
|
523
|
+
if (compCount && devServer) {
|
|
524
|
+
const compModule = devServer.moduleGraph.getModuleById(RESOLVED_COMPONENTS_ID);
|
|
525
|
+
if (compModule) devServer.moduleGraph.invalidateModule(compModule);
|
|
526
|
+
const sysPropModule = devServer.moduleGraph.getModuleById(RESOLVED_SYSTEM_PROPS_ID);
|
|
527
|
+
if (sysPropModule) devServer.moduleGraph.invalidateModule(sysPropModule);
|
|
528
|
+
setTimeout(() => {
|
|
529
|
+
devServer.hot.send({ type: "full-reload" });
|
|
530
|
+
}, 100);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (!storedManifest.files?.[relativePath]?.length) return null;
|
|
534
|
+
}
|
|
506
535
|
try {
|
|
507
536
|
const { transformFile } = __require("@animus-ui/extract");
|
|
508
537
|
const result = transformFile(code, relativePath, storedManifestJson);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/vite-plugin",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.44",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"vite": ">=5.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
41
|
-
"@animus-ui/system": "0.1.0-next.
|
|
40
|
+
"@animus-ui/extract": "0.1.0-next.44",
|
|
41
|
+
"@animus-ui/system": "0.1.0-next.44",
|
|
42
42
|
"browserslist": "^4.24.0",
|
|
43
43
|
"lightningcss": "^1.29.0"
|
|
44
44
|
}
|