@animus-ui/next-plugin 0.1.0-next.49 → 0.1.0-next.59
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.cjs +229 -84
- package/dist/index.mjs +230 -85
- package/dist/loader.cjs +6 -4
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.mjs +6 -4
- package/dist/plugin.d.ts +56 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/{singleton-BZ7W87Ir.mjs → singleton-BY7EN689.mjs} +12 -1
- package/dist/{singleton-VPOM1BCR.cjs → singleton-ChvheNU3.cjs} +29 -0
- package/dist/singleton.d.ts +4 -0
- package/dist/singleton.d.ts.map +1 -1
- package/dist/with-animus.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_singleton = require("./singleton-
|
|
2
|
+
const require_singleton = require("./singleton-ChvheNU3.cjs");
|
|
3
3
|
let fs = require("fs");
|
|
4
4
|
let path = require("path");
|
|
5
5
|
let url = require("url");
|
|
6
6
|
let crypto = require("crypto");
|
|
7
|
-
let os = require("os");
|
|
8
7
|
let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
|
|
9
8
|
//#region src/plugin.ts
|
|
10
9
|
const PLUGIN_NAME = "AnimusWebpackPlugin";
|
|
@@ -17,8 +16,11 @@ var AnimusWebpackPlugin = class {
|
|
|
17
16
|
variableMapJson = "";
|
|
18
17
|
variableCss = "";
|
|
19
18
|
contextualVarsJson = null;
|
|
19
|
+
selectorAliasesJson = null;
|
|
20
|
+
selectorOrderJson = null;
|
|
20
21
|
globalCss = "";
|
|
21
|
-
|
|
22
|
+
globalStyleBlocksJson = null;
|
|
23
|
+
pathAliasesJson = null;
|
|
22
24
|
fileCache = /* @__PURE__ */ new Map();
|
|
23
25
|
lastCssHash = null;
|
|
24
26
|
externalPackageDirs = [];
|
|
@@ -26,10 +28,118 @@ var AnimusWebpackPlugin = class {
|
|
|
26
28
|
constructor(options) {
|
|
27
29
|
this.options = options;
|
|
28
30
|
}
|
|
31
|
+
get verbose() {
|
|
32
|
+
return this.options.verbose === true || process.env.ANIMUS_DEBUG === "1" || process.env.ANIMUS_DEBUG === "true";
|
|
33
|
+
}
|
|
34
|
+
log(msg) {
|
|
35
|
+
if (this.verbose) console.info(`[animus] ${msg}`);
|
|
36
|
+
}
|
|
37
|
+
now() {
|
|
38
|
+
return this.verbose ? performance.now() : 0;
|
|
39
|
+
}
|
|
40
|
+
elapsed(t) {
|
|
41
|
+
return this.verbose ? Math.round(performance.now() - t) : 0;
|
|
42
|
+
}
|
|
43
|
+
logBuildTimings(bt, rustTiming) {
|
|
44
|
+
if (!this.verbose) return;
|
|
45
|
+
for (const [key, label] of [
|
|
46
|
+
["systemLoad", "system-load"],
|
|
47
|
+
["fileDiscovery", "file-discovery"],
|
|
48
|
+
["fileRead", "file-read+hash"],
|
|
49
|
+
["packageResolve", "pkg-resolve"],
|
|
50
|
+
["analysis", "analysis"]
|
|
51
|
+
]) {
|
|
52
|
+
const ms = bt[key] ?? 0;
|
|
53
|
+
if (ms === 0 && !Object.hasOwn(bt, key)) continue;
|
|
54
|
+
const pad = " ".repeat(Math.max(0, 17 - label.length));
|
|
55
|
+
this.log(` ${label}${pad}${String(ms).padStart(5)}ms`);
|
|
56
|
+
if (key === "analysis") for (const [sk, sl] of [
|
|
57
|
+
["jsonSerialize", "json-serialize"],
|
|
58
|
+
["rustExtract", "rust-extract"],
|
|
59
|
+
["jsonParse", "json-parse"]
|
|
60
|
+
]) {
|
|
61
|
+
const sms = bt[sk] ?? 0;
|
|
62
|
+
const spad = " ".repeat(Math.max(0, 15 - sl.length));
|
|
63
|
+
this.log(` ${sl}${spad}${String(sms).padStart(5)}ms`);
|
|
64
|
+
if (sk === "rustExtract" && rustTiming) for (const [rk, rl] of [
|
|
65
|
+
["parseAndWalk", "parse+walk"],
|
|
66
|
+
["importResolution", "imports"],
|
|
67
|
+
["extensionProvenance", "provenance"],
|
|
68
|
+
["topologicalSort", "topo-sort"],
|
|
69
|
+
["chainEvaluation", "chains"],
|
|
70
|
+
["jsxScanning", "jsx-scan"],
|
|
71
|
+
["systemPropAggregation", "sys-props"],
|
|
72
|
+
["usageLedger", "usage"],
|
|
73
|
+
["reconciliation", "reconcile"],
|
|
74
|
+
["cssGeneration", "css-gen"],
|
|
75
|
+
["manifestSerialization", "serialize"]
|
|
76
|
+
]) {
|
|
77
|
+
const rms = rustTiming[rk] ?? 0;
|
|
78
|
+
const rpad = " ".repeat(Math.max(0, 13 - rl.length));
|
|
79
|
+
const rextra = rk === "parseAndWalk" ? ` (${rustTiming.fileCount ?? 0} files, ${rustTiming.cacheHits ?? 0} cached)` : "";
|
|
80
|
+
this.log(` ${rl}${rpad}${String(rms).padStart(5)}ms${rextra}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.log(` total ${String(bt.total).padStart(5)}ms`);
|
|
85
|
+
if (process.env.ANIMUS_TIMING_JSON === "1") {
|
|
86
|
+
const merged = {};
|
|
87
|
+
for (const [k, v] of Object.entries(bt)) merged[`buildStart.${k}`] = v;
|
|
88
|
+
if (rustTiming) {
|
|
89
|
+
for (const [k, v] of Object.entries(rustTiming)) if (typeof v === "number") merged[`rust.${k}`] = v;
|
|
90
|
+
}
|
|
91
|
+
console.info(`[animus:timing] ${JSON.stringify(merged)}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
29
94
|
initialized = false;
|
|
95
|
+
/** Extract path aliases from webpack's resolve.alias config. */
|
|
96
|
+
extractAliases(compiler) {
|
|
97
|
+
const rootDir = compiler.context;
|
|
98
|
+
const rawAlias = compiler.options?.resolve?.alias;
|
|
99
|
+
if (!rawAlias || typeof rawAlias !== "object") return;
|
|
100
|
+
const entries = [];
|
|
101
|
+
for (const [key, value] of Object.entries(rawAlias)) {
|
|
102
|
+
const target = Array.isArray(value) ? value[0] : value;
|
|
103
|
+
if (typeof target !== "string") continue;
|
|
104
|
+
if (key.includes(".animus")) continue;
|
|
105
|
+
const replacement = target.startsWith(rootDir) ? target.slice(rootDir.length + 1) : target;
|
|
106
|
+
if (/\.\w+$/.test(replacement)) entries.push({
|
|
107
|
+
pattern: key,
|
|
108
|
+
replacement,
|
|
109
|
+
type: "exact"
|
|
110
|
+
});
|
|
111
|
+
else entries.push({
|
|
112
|
+
pattern: key.endsWith("/") ? key : key + "/",
|
|
113
|
+
replacement: replacement.endsWith("/") ? replacement : replacement + "/",
|
|
114
|
+
type: "prefix"
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
entries.sort((a, b) => b.pattern.length - a.pattern.length);
|
|
118
|
+
if (entries.length > 0) this.pathAliasesJson = JSON.stringify({ aliases: entries });
|
|
119
|
+
}
|
|
30
120
|
apply(compiler) {
|
|
121
|
+
if (compiler.options?.name === "edge-server") return;
|
|
122
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
123
|
+
const stage = compiler.webpack?.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL ?? -2e3;
|
|
124
|
+
const RawSource = compiler.webpack?.sources.RawSource;
|
|
125
|
+
compilation.hooks.processAssets.tap({
|
|
126
|
+
name: PLUGIN_NAME,
|
|
127
|
+
stage
|
|
128
|
+
}, () => {
|
|
129
|
+
const css = require_singleton.getSharedCss();
|
|
130
|
+
if (!css || !RawSource) return;
|
|
131
|
+
const cssPath = (0, path.join)(this.rootDir || compiler.context, ".animus", "styles.css");
|
|
132
|
+
if (compilation.getAsset(cssPath)) {
|
|
133
|
+
compilation.updateAsset(cssPath, new RawSource(css));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const relPath = ".animus/styles.css";
|
|
137
|
+
if (compilation.getAsset(relPath)) compilation.updateAsset(relPath, new RawSource(css));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
31
140
|
compiler.hooks.run.tapPromise(PLUGIN_NAME, async (_compiler) => {
|
|
32
141
|
this.rootDir = _compiler.context;
|
|
142
|
+
this.extractAliases(_compiler);
|
|
33
143
|
const existing = require_singleton.getAnalysisPromise();
|
|
34
144
|
if (existing) {
|
|
35
145
|
await existing;
|
|
@@ -41,6 +151,7 @@ var AnimusWebpackPlugin = class {
|
|
|
41
151
|
});
|
|
42
152
|
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (_compiler) => {
|
|
43
153
|
this.rootDir = _compiler.context;
|
|
154
|
+
this.extractAliases(_compiler);
|
|
44
155
|
if (!this.initialized) {
|
|
45
156
|
const existing = require_singleton.getAnalysisPromise();
|
|
46
157
|
if (existing) {
|
|
@@ -58,6 +169,7 @@ var AnimusWebpackPlugin = class {
|
|
|
58
169
|
});
|
|
59
170
|
}
|
|
60
171
|
async handleWatchUpdate() {
|
|
172
|
+
if (this.configJson === "") return;
|
|
61
173
|
const rootDir = this.rootDir;
|
|
62
174
|
const resolvedSystemPath = (0, path.resolve)(rootDir, this.options.system);
|
|
63
175
|
try {
|
|
@@ -84,35 +196,41 @@ var AnimusWebpackPlugin = class {
|
|
|
84
196
|
".animus"
|
|
85
197
|
];
|
|
86
198
|
const files = this.discoverFiles(rootDir, rootDir, excludePatterns);
|
|
87
|
-
|
|
199
|
+
const changedPaths = [];
|
|
88
200
|
for (const filePath of files) {
|
|
89
201
|
const relPath = (0, path.relative)(rootDir, filePath);
|
|
90
202
|
const cached = this.fileCache.get(relPath);
|
|
91
203
|
const source = (0, fs.readFileSync)(filePath, "utf-8");
|
|
92
204
|
const hash = (0, crypto.createHash)("md5").update(source).digest("hex");
|
|
93
205
|
if (!cached || cached.hash !== hash) {
|
|
94
|
-
|
|
206
|
+
changedPaths.push(relPath);
|
|
95
207
|
this.fileCache.set(relPath, {
|
|
96
208
|
hash,
|
|
97
209
|
source
|
|
98
210
|
});
|
|
99
211
|
}
|
|
100
212
|
}
|
|
101
|
-
if (
|
|
213
|
+
if (changedPaths.length > 0) {
|
|
214
|
+
const fileEntries = this.buildFileEntriesFromCache(changedPaths);
|
|
102
215
|
require_singleton.resetAnalysisPromise();
|
|
103
|
-
const promise = this.
|
|
216
|
+
const promise = this.runIncrementalPipeline(fileEntries);
|
|
104
217
|
require_singleton.setAnalysisPromise(promise);
|
|
105
218
|
await promise;
|
|
106
219
|
}
|
|
107
220
|
}
|
|
108
221
|
async runFullPipeline() {
|
|
222
|
+
const pipelineStart = this.now();
|
|
223
|
+
const bt = {};
|
|
109
224
|
try {
|
|
110
225
|
const { clearAnalysisCache } = require("@animus-ui/extract");
|
|
111
226
|
clearAnalysisCache();
|
|
112
227
|
} catch {}
|
|
113
228
|
const rootDir = this.rootDir;
|
|
114
229
|
const resolvedSystemPath = (0, path.resolve)(rootDir, this.options.system);
|
|
230
|
+
let t = this.now();
|
|
115
231
|
this.loadSystem(rootDir, resolvedSystemPath);
|
|
232
|
+
bt.systemLoad = this.elapsed(t);
|
|
233
|
+
t = this.now();
|
|
116
234
|
const excludePatterns = this.options.exclude ?? [
|
|
117
235
|
"node_modules",
|
|
118
236
|
"dist",
|
|
@@ -122,6 +240,8 @@ var AnimusWebpackPlugin = class {
|
|
|
122
240
|
".animus"
|
|
123
241
|
];
|
|
124
242
|
const files = this.discoverFiles(rootDir, rootDir, excludePatterns);
|
|
243
|
+
bt.fileDiscovery = this.elapsed(t);
|
|
244
|
+
t = this.now();
|
|
125
245
|
const fileEntries = [];
|
|
126
246
|
for (const filePath of files) {
|
|
127
247
|
const source = (0, fs.readFileSync)(filePath, "utf-8");
|
|
@@ -137,6 +257,9 @@ var AnimusWebpackPlugin = class {
|
|
|
137
257
|
hash
|
|
138
258
|
});
|
|
139
259
|
}
|
|
260
|
+
bt.fileRead = this.elapsed(t);
|
|
261
|
+
bt.fileCount = fileEntries.length;
|
|
262
|
+
t = this.now();
|
|
140
263
|
const packageNames = (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(resolvedSystemPath);
|
|
141
264
|
const packageMap = this.resolvePackagesByName(rootDir, packageNames);
|
|
142
265
|
const excludePatternsForPkgs = [
|
|
@@ -178,6 +301,7 @@ var AnimusWebpackPlugin = class {
|
|
|
178
301
|
} else collectedPkgDirs.push((0, path.dirname)(absEntry));
|
|
179
302
|
}
|
|
180
303
|
this.externalPackageDirs = collectedPkgDirs;
|
|
304
|
+
bt.packageResolve = this.elapsed(t);
|
|
181
305
|
const { analyzeProject } = require("@animus-ui/extract");
|
|
182
306
|
const animusDirPath = (0, path.join)(rootDir, ".animus");
|
|
183
307
|
const emitterConfig = JSON.stringify({
|
|
@@ -185,10 +309,20 @@ var AnimusWebpackPlugin = class {
|
|
|
185
309
|
css_module_id: ".animus/styles.css",
|
|
186
310
|
system_props_module_id: (0, path.join)(animusDirPath, "system-props.js")
|
|
187
311
|
});
|
|
188
|
-
|
|
312
|
+
t = this.now();
|
|
313
|
+
const fileEntriesJson = JSON.stringify(fileEntries);
|
|
314
|
+
const packageMapJson = JSON.stringify(packageMap);
|
|
315
|
+
bt.jsonSerialize = this.elapsed(t);
|
|
316
|
+
t = this.now();
|
|
317
|
+
const manifestJson = analyzeProject(fileEntriesJson, this.themeJson, this.variableMapJson, this.contextualVarsJson || null, this.configJson, this.groupRegistryJson, packageMapJson, false, emitterConfig, this.selectorAliasesJson, this.selectorOrderJson, this.globalStyleBlocksJson, this.pathAliasesJson);
|
|
318
|
+
bt.rustExtract = this.elapsed(t);
|
|
319
|
+
t = this.now();
|
|
189
320
|
const manifest = JSON.parse(manifestJson);
|
|
321
|
+
bt.jsonParse = this.elapsed(t);
|
|
322
|
+
bt.analysis = (bt.jsonSerialize ?? 0) + (bt.rustExtract ?? 0) + (bt.jsonParse ?? 0);
|
|
323
|
+
if (manifest?.report) this.log(`Extracted ${manifest.report.components_extracted ?? "?"}/${manifest.report.components_total ?? "?"} components (${bt.analysis}ms)`);
|
|
324
|
+
this.globalCss = manifest?.sheets?.global || "";
|
|
190
325
|
let componentCss = manifest?.css || "";
|
|
191
|
-
if (this.systemResolveScript && componentCss.includes("__TRANSFORM__")) componentCss = this.resolveTransforms(rootDir, componentCss);
|
|
192
326
|
componentCss = (0, _animus_ui_extract_pipeline.applyUnitFallback)(componentCss);
|
|
193
327
|
const fullCss = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
|
|
194
328
|
layers: this.options.layers,
|
|
@@ -196,6 +330,7 @@ var AnimusWebpackPlugin = class {
|
|
|
196
330
|
globalCss: this.globalCss,
|
|
197
331
|
componentCss
|
|
198
332
|
});
|
|
333
|
+
require_singleton.setSharedCss(fullCss);
|
|
199
334
|
const cssHash = (0, crypto.createHash)("md5").update(fullCss).digest("hex");
|
|
200
335
|
if (cssHash !== this.lastCssHash) {
|
|
201
336
|
const animusDir = (0, path.join)(rootDir, ".animus");
|
|
@@ -212,87 +347,35 @@ var AnimusWebpackPlugin = class {
|
|
|
212
347
|
...meta.transform_name ? { transformName: meta.transform_name } : {},
|
|
213
348
|
...meta.scale_values && Object.keys(meta.scale_values).length > 0 ? { scaleValues: meta.scale_values } : {}
|
|
214
349
|
};
|
|
215
|
-
|
|
216
|
-
if (this.systemResolveScript) try {
|
|
217
|
-
const resolvedSystemPath = (0, path.resolve)(rootDir, this.options.system);
|
|
218
|
-
const tmpOut = (0, path.join)((0, os.tmpdir)(), `animus-transforms-${Date.now()}.json`);
|
|
219
|
-
(0, _animus_ui_extract_pipeline.execSubprocess)(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst ds = m.ds || m.default || m.system;\nconst cfg = ds.toConfig();\nconst out = {};\nfor (const [name, fn] of Object.entries(cfg.transforms || {})) {\n out[name] = fn.toString();\n}\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify(out));\n`, rootDir);
|
|
220
|
-
const fnStrings = JSON.parse((0, fs.readFileSync)(tmpOut, "utf-8"));
|
|
221
|
-
try {
|
|
222
|
-
require("fs").unlinkSync(tmpOut);
|
|
223
|
-
} catch {}
|
|
224
|
-
transformsSource = `{\n${Object.entries(fnStrings).map(([name, src]) => ` ${JSON.stringify(name)}: ${src}`).join(",\n")}\n}`;
|
|
225
|
-
} catch {}
|
|
350
|
+
const transformsSource = "{}";
|
|
226
351
|
const animusDir = (0, path.join)(rootDir, ".animus");
|
|
227
352
|
if (!(0, fs.existsSync)(animusDir)) (0, fs.mkdirSync)(animusDir, { recursive: true });
|
|
228
|
-
|
|
353
|
+
const systemPropsContent = `export const systemPropMap = ${systemPropMap};\nexport const systemPropGroups = ${this.groupRegistryJson};\nexport const dynamicPropConfig = ${JSON.stringify(dynamicPropConfig)};\nexport const transforms = ${transformsSource};\n`;
|
|
354
|
+
require_singleton.setSharedSystemProps(systemPropsContent);
|
|
355
|
+
(0, fs.writeFileSync)((0, path.join)(animusDir, "system-props.js"), systemPropsContent);
|
|
229
356
|
require_singleton.setManifestJson(manifestJson);
|
|
357
|
+
bt.total = this.elapsed(pipelineStart);
|
|
358
|
+
this.logBuildTimings(bt, manifest?.timing);
|
|
230
359
|
}
|
|
231
360
|
loadSystem(rootDir, systemPath) {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this.variableMapJson
|
|
244
|
-
this.
|
|
245
|
-
this.
|
|
246
|
-
if (this.
|
|
247
|
-
|
|
248
|
-
this.variableMapJson = prefixed.variableMapJson;
|
|
249
|
-
this.variableCss = prefixed.variableCss;
|
|
250
|
-
if (prefixed.themeJson) this.themeJson = prefixed.themeJson;
|
|
251
|
-
if (prefixed.contextualVarsJson) this.contextualVarsJson = prefixed.contextualVarsJson;
|
|
252
|
-
}
|
|
253
|
-
} else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
|
|
254
|
-
if (parsed.globalStyleBlocks) {
|
|
255
|
-
if (Object.keys(parsed.globalStyleBlocks).length > 0) try {
|
|
256
|
-
const hasTransforms = parsed.transformNames && parsed.transformNames.length > 0;
|
|
257
|
-
const flat = JSON.parse(this.themeJson);
|
|
258
|
-
const propConfig = JSON.parse(this.configJson);
|
|
259
|
-
const variableMap = {};
|
|
260
|
-
for (const [tokenPath, value] of Object.entries(flat)) if (typeof value === "string" && value.startsWith("var(") && value.endsWith(")")) variableMap[tokenPath] = value.slice(4, -1);
|
|
261
|
-
const transforms = {};
|
|
262
|
-
if (hasTransforms && parsed.transformSources) for (const [name, src] of Object.entries(parsed.transformSources)) try {
|
|
263
|
-
transforms[name] = new Function(`return (${src})`)();
|
|
264
|
-
} catch {}
|
|
265
|
-
const gsResult = (0, _animus_ui_extract_pipeline.resolveGlobalStyles)(parsed.globalStyleBlocks, propConfig, flat, variableMap, transforms);
|
|
266
|
-
const parts = Object.values(gsResult).filter(Boolean);
|
|
267
|
-
if (parts.length > 0) this.globalCss = `@layer global {\n${parts.join("\n\n")}\n}`;
|
|
268
|
-
} catch (e) {
|
|
269
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
270
|
-
if (this.options.strict) throw new Error(`[animus-extract] Global styles resolution failed: ${msg}`);
|
|
271
|
-
console.warn("[animus-extract] Global styles resolution failed:", msg);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (parsed.transformNames && parsed.transformNames.length > 0) {
|
|
275
|
-
const tmpResolve = (0, path.join)((0, os.tmpdir)(), `animus-transforms-resolve-${Date.now()}.js`);
|
|
276
|
-
(0, fs.writeFileSync)(tmpResolve, `const m = require(${JSON.stringify(systemPath)});\nconst ds = m.ds || m.default || m.system;\nconst cfg = ds.toConfig();\nconst css = require('fs').readFileSync(process.argv[2], 'utf-8');\nconst resolved = css.replace(/__TRANSFORM__(\\w+)__(.+?)__/g, (_, name, rawValue) => {\n const fn = cfg.transforms[name];\n if (!fn) return rawValue;\n const value = rawValue !== '' && !isNaN(Number(rawValue)) ? Number(rawValue) : rawValue;\n const result = fn(value);\n return typeof result === 'object' ? JSON.stringify(result) : String(result);\n});\nrequire('fs').writeFileSync(process.argv[3], resolved);\n`);
|
|
277
|
-
this.systemResolveScript = tmpResolve;
|
|
361
|
+
const { loadSystemModule } = require("@animus-ui/extract");
|
|
362
|
+
const config = loadSystemModule(systemPath, rootDir);
|
|
363
|
+
this.configJson = config.propConfig;
|
|
364
|
+
this.groupRegistryJson = config.groupRegistry;
|
|
365
|
+
this.themeJson = config.scalesJson;
|
|
366
|
+
this.variableMapJson = config.variableMapJson;
|
|
367
|
+
this.variableCss = config.variableCss;
|
|
368
|
+
this.contextualVarsJson = config.contextualVarsJson;
|
|
369
|
+
this.selectorAliasesJson = config.selectorAliases || null;
|
|
370
|
+
this.selectorOrderJson = config.selectorOrder || null;
|
|
371
|
+
if (this.options.prefix) {
|
|
372
|
+
const prefixed = (0, _animus_ui_extract_pipeline.applyPrefix)(this.options.prefix, this.variableMapJson, this.variableCss, this.themeJson, this.contextualVarsJson || void 0);
|
|
373
|
+
this.variableMapJson = prefixed.variableMapJson;
|
|
374
|
+
this.variableCss = prefixed.variableCss;
|
|
375
|
+
if (prefixed.themeJson) this.themeJson = prefixed.themeJson;
|
|
376
|
+
if (prefixed.contextualVarsJson) this.contextualVarsJson = prefixed.contextualVarsJson;
|
|
278
377
|
}
|
|
279
|
-
|
|
280
|
-
resolveTransforms(rootDir, css) {
|
|
281
|
-
const { execSync } = require("child_process");
|
|
282
|
-
const ts = Date.now();
|
|
283
|
-
const tmpIn = (0, path.join)((0, os.tmpdir)(), `animus-css-${ts}.css`);
|
|
284
|
-
const tmpOut = (0, path.join)((0, os.tmpdir)(), `animus-css-${ts}.out.css`);
|
|
285
|
-
(0, fs.writeFileSync)(tmpIn, css);
|
|
286
|
-
execSync(`${(0, _animus_ui_extract_pipeline.detectRuntime)()} run "${this.systemResolveScript}" "${tmpIn}" "${tmpOut}"`, {
|
|
287
|
-
cwd: rootDir,
|
|
288
|
-
encoding: "utf-8"
|
|
289
|
-
});
|
|
290
|
-
const resolved = (0, fs.readFileSync)(tmpOut, "utf-8");
|
|
291
|
-
try {
|
|
292
|
-
require("fs").unlinkSync(tmpIn);
|
|
293
|
-
require("fs").unlinkSync(tmpOut);
|
|
294
|
-
} catch {}
|
|
295
|
-
return resolved;
|
|
378
|
+
this.globalStyleBlocksJson = config.globalStyleBlocks || null;
|
|
296
379
|
}
|
|
297
380
|
discoverFiles(dir, rootDir, excludePatterns) {
|
|
298
381
|
const results = [];
|
|
@@ -368,6 +451,65 @@ var AnimusWebpackPlugin = class {
|
|
|
368
451
|
clearAnalysisCache();
|
|
369
452
|
} catch {}
|
|
370
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Build cache-aware file entries: full source for changed files,
|
|
456
|
+
* empty source + hash for unchanged (Rust cache-hit path skips these).
|
|
457
|
+
*/
|
|
458
|
+
buildFileEntriesFromCache(changedPaths) {
|
|
459
|
+
const changedSet = new Set(changedPaths);
|
|
460
|
+
const entries = [];
|
|
461
|
+
for (const [path$1, { hash, source }] of this.fileCache) entries.push({
|
|
462
|
+
path: path$1,
|
|
463
|
+
source: changedSet.has(path$1) ? source : "",
|
|
464
|
+
hash
|
|
465
|
+
});
|
|
466
|
+
return entries;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Run incremental pipeline with cache-aware file entries.
|
|
470
|
+
* Reuses system config from the last full pipeline run.
|
|
471
|
+
*/
|
|
472
|
+
async runIncrementalPipeline(fileEntries) {
|
|
473
|
+
const rootDir = this.rootDir;
|
|
474
|
+
const bt = {};
|
|
475
|
+
const pipelineStart = this.now();
|
|
476
|
+
const { analyzeProject } = require("@animus-ui/extract");
|
|
477
|
+
const animusDirPath = (0, path.join)(rootDir, ".animus");
|
|
478
|
+
const emitterConfig = JSON.stringify({
|
|
479
|
+
runtime_import: "@animus-ui/system/runtime",
|
|
480
|
+
css_module_id: (0, path.join)(animusDirPath, "system-props.js")
|
|
481
|
+
});
|
|
482
|
+
const packageMapJson = JSON.stringify(Object.fromEntries(Array.from(this.externalSourceEntries).map(([spec, entry]) => [spec, (0, path.relative)(rootDir, entry)])));
|
|
483
|
+
let t = this.now();
|
|
484
|
+
const fileEntriesJson = JSON.stringify(fileEntries);
|
|
485
|
+
bt.jsonSerialize = this.elapsed(t);
|
|
486
|
+
t = this.now();
|
|
487
|
+
const manifestJson = analyzeProject(fileEntriesJson, this.themeJson, this.variableMapJson, this.contextualVarsJson || null, this.configJson, this.groupRegistryJson, packageMapJson, false, emitterConfig, this.selectorAliasesJson, this.selectorOrderJson, this.globalStyleBlocksJson, this.pathAliasesJson);
|
|
488
|
+
bt.rustExtract = this.elapsed(t);
|
|
489
|
+
t = this.now();
|
|
490
|
+
const manifest = JSON.parse(manifestJson);
|
|
491
|
+
bt.jsonParse = this.elapsed(t);
|
|
492
|
+
this.globalCss = manifest?.sheets?.global || "";
|
|
493
|
+
let componentCss = manifest?.css || "";
|
|
494
|
+
componentCss = (0, _animus_ui_extract_pipeline.applyUnitFallback)(componentCss);
|
|
495
|
+
const fullCss = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
|
|
496
|
+
layers: this.options.layers,
|
|
497
|
+
variableCss: this.variableCss,
|
|
498
|
+
globalCss: this.globalCss,
|
|
499
|
+
componentCss
|
|
500
|
+
});
|
|
501
|
+
require_singleton.setSharedCss(fullCss);
|
|
502
|
+
const cssHash = (0, crypto.createHash)("md5").update(fullCss).digest("hex");
|
|
503
|
+
if (cssHash !== this.lastCssHash) {
|
|
504
|
+
const animusDir = (0, path.join)(rootDir, ".animus");
|
|
505
|
+
if (!(0, fs.existsSync)(animusDir)) (0, fs.mkdirSync)(animusDir, { recursive: true });
|
|
506
|
+
(0, fs.writeFileSync)((0, path.join)(animusDir, "styles.css"), fullCss);
|
|
507
|
+
this.lastCssHash = cssHash;
|
|
508
|
+
}
|
|
509
|
+
require_singleton.setManifestJson(manifestJson);
|
|
510
|
+
bt.total = this.elapsed(pipelineStart);
|
|
511
|
+
this.logBuildTimings(bt, manifest?.timing);
|
|
512
|
+
}
|
|
371
513
|
/** Expose file cache for HMR change detection */
|
|
372
514
|
getFileCache() {
|
|
373
515
|
return this.fileCache;
|
|
@@ -408,6 +550,8 @@ function withAnimus(options) {
|
|
|
408
550
|
const rootDir = process.cwd();
|
|
409
551
|
const animusDir = (0, path.join)(rootDir, ".animus");
|
|
410
552
|
if (!(0, fs.existsSync)(animusDir)) (0, fs.mkdirSync)(animusDir, { recursive: true });
|
|
553
|
+
const stubCssPath = (0, path.join)(animusDir, "styles.css");
|
|
554
|
+
if (!(0, fs.existsSync)(stubCssPath)) (0, fs.writeFileSync)(stubCssPath, "@layer anm-global, anm-base, anm-variants, anm-compounds, anm-states, anm-system, anm-custom;\n");
|
|
411
555
|
if (!warnedGitignore) {
|
|
412
556
|
warnedGitignore = true;
|
|
413
557
|
try {
|
|
@@ -434,6 +578,7 @@ function withAnimus(options) {
|
|
|
434
578
|
compiler.hooks.normalModuleFactory.tap("AnimusVirtualResolve", (nmf) => {
|
|
435
579
|
nmf.hooks.beforeResolve.tap("AnimusVirtualResolve", (resolveData) => {
|
|
436
580
|
if (resolveData.request === "virtual:animus/system-props") resolveData.request = systemPropsPath;
|
|
581
|
+
if (resolveData.request === "virtual:animus/styles.css") resolveData.request = (0, path.join)(rootDir, ".animus", "styles.css");
|
|
437
582
|
const srcEntry = plugin.getExternalSourceEntries().get(resolveData.request);
|
|
438
583
|
if (srcEntry) resolveData.request = srcEntry;
|
|
439
584
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as setAnalysisPromise, c as setSharedSystemProps, i as resetAnalysisPromise, l as __require, o as setManifestJson, r as getSharedCss, s as setSharedCss, t as getAnalysisPromise } from "./singleton-BY7EN689.mjs";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
|
|
3
3
|
import { dirname, extname, join, relative, resolve, sep } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
|
-
import {
|
|
7
|
-
import { applyPrefix, applyUnitFallback, assembleStylesheet, detectRuntime, execSubprocess, extractSystemFilePackages, resolveGlobalStyles } from "@animus-ui/extract/pipeline";
|
|
6
|
+
import { applyPrefix, applyUnitFallback, assembleStylesheet, extractSystemFilePackages } from "@animus-ui/extract/pipeline";
|
|
8
7
|
//#region src/plugin.ts
|
|
9
8
|
const PLUGIN_NAME = "AnimusWebpackPlugin";
|
|
10
9
|
var AnimusWebpackPlugin = class {
|
|
@@ -16,8 +15,11 @@ var AnimusWebpackPlugin = class {
|
|
|
16
15
|
variableMapJson = "";
|
|
17
16
|
variableCss = "";
|
|
18
17
|
contextualVarsJson = null;
|
|
18
|
+
selectorAliasesJson = null;
|
|
19
|
+
selectorOrderJson = null;
|
|
19
20
|
globalCss = "";
|
|
20
|
-
|
|
21
|
+
globalStyleBlocksJson = null;
|
|
22
|
+
pathAliasesJson = null;
|
|
21
23
|
fileCache = /* @__PURE__ */ new Map();
|
|
22
24
|
lastCssHash = null;
|
|
23
25
|
externalPackageDirs = [];
|
|
@@ -25,10 +27,118 @@ var AnimusWebpackPlugin = class {
|
|
|
25
27
|
constructor(options) {
|
|
26
28
|
this.options = options;
|
|
27
29
|
}
|
|
30
|
+
get verbose() {
|
|
31
|
+
return this.options.verbose === true || process.env.ANIMUS_DEBUG === "1" || process.env.ANIMUS_DEBUG === "true";
|
|
32
|
+
}
|
|
33
|
+
log(msg) {
|
|
34
|
+
if (this.verbose) console.info(`[animus] ${msg}`);
|
|
35
|
+
}
|
|
36
|
+
now() {
|
|
37
|
+
return this.verbose ? performance.now() : 0;
|
|
38
|
+
}
|
|
39
|
+
elapsed(t) {
|
|
40
|
+
return this.verbose ? Math.round(performance.now() - t) : 0;
|
|
41
|
+
}
|
|
42
|
+
logBuildTimings(bt, rustTiming) {
|
|
43
|
+
if (!this.verbose) return;
|
|
44
|
+
for (const [key, label] of [
|
|
45
|
+
["systemLoad", "system-load"],
|
|
46
|
+
["fileDiscovery", "file-discovery"],
|
|
47
|
+
["fileRead", "file-read+hash"],
|
|
48
|
+
["packageResolve", "pkg-resolve"],
|
|
49
|
+
["analysis", "analysis"]
|
|
50
|
+
]) {
|
|
51
|
+
const ms = bt[key] ?? 0;
|
|
52
|
+
if (ms === 0 && !Object.hasOwn(bt, key)) continue;
|
|
53
|
+
const pad = " ".repeat(Math.max(0, 17 - label.length));
|
|
54
|
+
this.log(` ${label}${pad}${String(ms).padStart(5)}ms`);
|
|
55
|
+
if (key === "analysis") for (const [sk, sl] of [
|
|
56
|
+
["jsonSerialize", "json-serialize"],
|
|
57
|
+
["rustExtract", "rust-extract"],
|
|
58
|
+
["jsonParse", "json-parse"]
|
|
59
|
+
]) {
|
|
60
|
+
const sms = bt[sk] ?? 0;
|
|
61
|
+
const spad = " ".repeat(Math.max(0, 15 - sl.length));
|
|
62
|
+
this.log(` ${sl}${spad}${String(sms).padStart(5)}ms`);
|
|
63
|
+
if (sk === "rustExtract" && rustTiming) for (const [rk, rl] of [
|
|
64
|
+
["parseAndWalk", "parse+walk"],
|
|
65
|
+
["importResolution", "imports"],
|
|
66
|
+
["extensionProvenance", "provenance"],
|
|
67
|
+
["topologicalSort", "topo-sort"],
|
|
68
|
+
["chainEvaluation", "chains"],
|
|
69
|
+
["jsxScanning", "jsx-scan"],
|
|
70
|
+
["systemPropAggregation", "sys-props"],
|
|
71
|
+
["usageLedger", "usage"],
|
|
72
|
+
["reconciliation", "reconcile"],
|
|
73
|
+
["cssGeneration", "css-gen"],
|
|
74
|
+
["manifestSerialization", "serialize"]
|
|
75
|
+
]) {
|
|
76
|
+
const rms = rustTiming[rk] ?? 0;
|
|
77
|
+
const rpad = " ".repeat(Math.max(0, 13 - rl.length));
|
|
78
|
+
const rextra = rk === "parseAndWalk" ? ` (${rustTiming.fileCount ?? 0} files, ${rustTiming.cacheHits ?? 0} cached)` : "";
|
|
79
|
+
this.log(` ${rl}${rpad}${String(rms).padStart(5)}ms${rextra}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.log(` total ${String(bt.total).padStart(5)}ms`);
|
|
84
|
+
if (process.env.ANIMUS_TIMING_JSON === "1") {
|
|
85
|
+
const merged = {};
|
|
86
|
+
for (const [k, v] of Object.entries(bt)) merged[`buildStart.${k}`] = v;
|
|
87
|
+
if (rustTiming) {
|
|
88
|
+
for (const [k, v] of Object.entries(rustTiming)) if (typeof v === "number") merged[`rust.${k}`] = v;
|
|
89
|
+
}
|
|
90
|
+
console.info(`[animus:timing] ${JSON.stringify(merged)}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
28
93
|
initialized = false;
|
|
94
|
+
/** Extract path aliases from webpack's resolve.alias config. */
|
|
95
|
+
extractAliases(compiler) {
|
|
96
|
+
const rootDir = compiler.context;
|
|
97
|
+
const rawAlias = compiler.options?.resolve?.alias;
|
|
98
|
+
if (!rawAlias || typeof rawAlias !== "object") return;
|
|
99
|
+
const entries = [];
|
|
100
|
+
for (const [key, value] of Object.entries(rawAlias)) {
|
|
101
|
+
const target = Array.isArray(value) ? value[0] : value;
|
|
102
|
+
if (typeof target !== "string") continue;
|
|
103
|
+
if (key.includes(".animus")) continue;
|
|
104
|
+
const replacement = target.startsWith(rootDir) ? target.slice(rootDir.length + 1) : target;
|
|
105
|
+
if (/\.\w+$/.test(replacement)) entries.push({
|
|
106
|
+
pattern: key,
|
|
107
|
+
replacement,
|
|
108
|
+
type: "exact"
|
|
109
|
+
});
|
|
110
|
+
else entries.push({
|
|
111
|
+
pattern: key.endsWith("/") ? key : key + "/",
|
|
112
|
+
replacement: replacement.endsWith("/") ? replacement : replacement + "/",
|
|
113
|
+
type: "prefix"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
entries.sort((a, b) => b.pattern.length - a.pattern.length);
|
|
117
|
+
if (entries.length > 0) this.pathAliasesJson = JSON.stringify({ aliases: entries });
|
|
118
|
+
}
|
|
29
119
|
apply(compiler) {
|
|
120
|
+
if (compiler.options?.name === "edge-server") return;
|
|
121
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
122
|
+
const stage = compiler.webpack?.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL ?? -2e3;
|
|
123
|
+
const RawSource = compiler.webpack?.sources.RawSource;
|
|
124
|
+
compilation.hooks.processAssets.tap({
|
|
125
|
+
name: PLUGIN_NAME,
|
|
126
|
+
stage
|
|
127
|
+
}, () => {
|
|
128
|
+
const css = getSharedCss();
|
|
129
|
+
if (!css || !RawSource) return;
|
|
130
|
+
const cssPath = join(this.rootDir || compiler.context, ".animus", "styles.css");
|
|
131
|
+
if (compilation.getAsset(cssPath)) {
|
|
132
|
+
compilation.updateAsset(cssPath, new RawSource(css));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const relPath = ".animus/styles.css";
|
|
136
|
+
if (compilation.getAsset(relPath)) compilation.updateAsset(relPath, new RawSource(css));
|
|
137
|
+
});
|
|
138
|
+
});
|
|
30
139
|
compiler.hooks.run.tapPromise(PLUGIN_NAME, async (_compiler) => {
|
|
31
140
|
this.rootDir = _compiler.context;
|
|
141
|
+
this.extractAliases(_compiler);
|
|
32
142
|
const existing = getAnalysisPromise();
|
|
33
143
|
if (existing) {
|
|
34
144
|
await existing;
|
|
@@ -40,6 +150,7 @@ var AnimusWebpackPlugin = class {
|
|
|
40
150
|
});
|
|
41
151
|
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (_compiler) => {
|
|
42
152
|
this.rootDir = _compiler.context;
|
|
153
|
+
this.extractAliases(_compiler);
|
|
43
154
|
if (!this.initialized) {
|
|
44
155
|
const existing = getAnalysisPromise();
|
|
45
156
|
if (existing) {
|
|
@@ -57,6 +168,7 @@ var AnimusWebpackPlugin = class {
|
|
|
57
168
|
});
|
|
58
169
|
}
|
|
59
170
|
async handleWatchUpdate() {
|
|
171
|
+
if (this.configJson === "") return;
|
|
60
172
|
const rootDir = this.rootDir;
|
|
61
173
|
const resolvedSystemPath = resolve(rootDir, this.options.system);
|
|
62
174
|
try {
|
|
@@ -83,35 +195,41 @@ var AnimusWebpackPlugin = class {
|
|
|
83
195
|
".animus"
|
|
84
196
|
];
|
|
85
197
|
const files = this.discoverFiles(rootDir, rootDir, excludePatterns);
|
|
86
|
-
|
|
198
|
+
const changedPaths = [];
|
|
87
199
|
for (const filePath of files) {
|
|
88
200
|
const relPath = relative(rootDir, filePath);
|
|
89
201
|
const cached = this.fileCache.get(relPath);
|
|
90
202
|
const source = readFileSync(filePath, "utf-8");
|
|
91
203
|
const hash = createHash("md5").update(source).digest("hex");
|
|
92
204
|
if (!cached || cached.hash !== hash) {
|
|
93
|
-
|
|
205
|
+
changedPaths.push(relPath);
|
|
94
206
|
this.fileCache.set(relPath, {
|
|
95
207
|
hash,
|
|
96
208
|
source
|
|
97
209
|
});
|
|
98
210
|
}
|
|
99
211
|
}
|
|
100
|
-
if (
|
|
212
|
+
if (changedPaths.length > 0) {
|
|
213
|
+
const fileEntries = this.buildFileEntriesFromCache(changedPaths);
|
|
101
214
|
resetAnalysisPromise();
|
|
102
|
-
const promise = this.
|
|
215
|
+
const promise = this.runIncrementalPipeline(fileEntries);
|
|
103
216
|
setAnalysisPromise(promise);
|
|
104
217
|
await promise;
|
|
105
218
|
}
|
|
106
219
|
}
|
|
107
220
|
async runFullPipeline() {
|
|
221
|
+
const pipelineStart = this.now();
|
|
222
|
+
const bt = {};
|
|
108
223
|
try {
|
|
109
224
|
const { clearAnalysisCache } = __require("@animus-ui/extract");
|
|
110
225
|
clearAnalysisCache();
|
|
111
226
|
} catch {}
|
|
112
227
|
const rootDir = this.rootDir;
|
|
113
228
|
const resolvedSystemPath = resolve(rootDir, this.options.system);
|
|
229
|
+
let t = this.now();
|
|
114
230
|
this.loadSystem(rootDir, resolvedSystemPath);
|
|
231
|
+
bt.systemLoad = this.elapsed(t);
|
|
232
|
+
t = this.now();
|
|
115
233
|
const excludePatterns = this.options.exclude ?? [
|
|
116
234
|
"node_modules",
|
|
117
235
|
"dist",
|
|
@@ -121,6 +239,8 @@ var AnimusWebpackPlugin = class {
|
|
|
121
239
|
".animus"
|
|
122
240
|
];
|
|
123
241
|
const files = this.discoverFiles(rootDir, rootDir, excludePatterns);
|
|
242
|
+
bt.fileDiscovery = this.elapsed(t);
|
|
243
|
+
t = this.now();
|
|
124
244
|
const fileEntries = [];
|
|
125
245
|
for (const filePath of files) {
|
|
126
246
|
const source = readFileSync(filePath, "utf-8");
|
|
@@ -136,6 +256,9 @@ var AnimusWebpackPlugin = class {
|
|
|
136
256
|
hash
|
|
137
257
|
});
|
|
138
258
|
}
|
|
259
|
+
bt.fileRead = this.elapsed(t);
|
|
260
|
+
bt.fileCount = fileEntries.length;
|
|
261
|
+
t = this.now();
|
|
139
262
|
const packageNames = extractSystemFilePackages(resolvedSystemPath);
|
|
140
263
|
const packageMap = this.resolvePackagesByName(rootDir, packageNames);
|
|
141
264
|
const excludePatternsForPkgs = [
|
|
@@ -177,6 +300,7 @@ var AnimusWebpackPlugin = class {
|
|
|
177
300
|
} else collectedPkgDirs.push(dirname(absEntry));
|
|
178
301
|
}
|
|
179
302
|
this.externalPackageDirs = collectedPkgDirs;
|
|
303
|
+
bt.packageResolve = this.elapsed(t);
|
|
180
304
|
const { analyzeProject } = __require("@animus-ui/extract");
|
|
181
305
|
const animusDirPath = join(rootDir, ".animus");
|
|
182
306
|
const emitterConfig = JSON.stringify({
|
|
@@ -184,10 +308,20 @@ var AnimusWebpackPlugin = class {
|
|
|
184
308
|
css_module_id: ".animus/styles.css",
|
|
185
309
|
system_props_module_id: join(animusDirPath, "system-props.js")
|
|
186
310
|
});
|
|
187
|
-
|
|
311
|
+
t = this.now();
|
|
312
|
+
const fileEntriesJson = JSON.stringify(fileEntries);
|
|
313
|
+
const packageMapJson = JSON.stringify(packageMap);
|
|
314
|
+
bt.jsonSerialize = this.elapsed(t);
|
|
315
|
+
t = this.now();
|
|
316
|
+
const manifestJson = analyzeProject(fileEntriesJson, this.themeJson, this.variableMapJson, this.contextualVarsJson || null, this.configJson, this.groupRegistryJson, packageMapJson, false, emitterConfig, this.selectorAliasesJson, this.selectorOrderJson, this.globalStyleBlocksJson, this.pathAliasesJson);
|
|
317
|
+
bt.rustExtract = this.elapsed(t);
|
|
318
|
+
t = this.now();
|
|
188
319
|
const manifest = JSON.parse(manifestJson);
|
|
320
|
+
bt.jsonParse = this.elapsed(t);
|
|
321
|
+
bt.analysis = (bt.jsonSerialize ?? 0) + (bt.rustExtract ?? 0) + (bt.jsonParse ?? 0);
|
|
322
|
+
if (manifest?.report) this.log(`Extracted ${manifest.report.components_extracted ?? "?"}/${manifest.report.components_total ?? "?"} components (${bt.analysis}ms)`);
|
|
323
|
+
this.globalCss = manifest?.sheets?.global || "";
|
|
189
324
|
let componentCss = manifest?.css || "";
|
|
190
|
-
if (this.systemResolveScript && componentCss.includes("__TRANSFORM__")) componentCss = this.resolveTransforms(rootDir, componentCss);
|
|
191
325
|
componentCss = applyUnitFallback(componentCss);
|
|
192
326
|
const fullCss = assembleStylesheet({
|
|
193
327
|
layers: this.options.layers,
|
|
@@ -195,6 +329,7 @@ var AnimusWebpackPlugin = class {
|
|
|
195
329
|
globalCss: this.globalCss,
|
|
196
330
|
componentCss
|
|
197
331
|
});
|
|
332
|
+
setSharedCss(fullCss);
|
|
198
333
|
const cssHash = createHash("md5").update(fullCss).digest("hex");
|
|
199
334
|
if (cssHash !== this.lastCssHash) {
|
|
200
335
|
const animusDir = join(rootDir, ".animus");
|
|
@@ -211,87 +346,35 @@ var AnimusWebpackPlugin = class {
|
|
|
211
346
|
...meta.transform_name ? { transformName: meta.transform_name } : {},
|
|
212
347
|
...meta.scale_values && Object.keys(meta.scale_values).length > 0 ? { scaleValues: meta.scale_values } : {}
|
|
213
348
|
};
|
|
214
|
-
|
|
215
|
-
if (this.systemResolveScript) try {
|
|
216
|
-
const resolvedSystemPath = resolve(rootDir, this.options.system);
|
|
217
|
-
const tmpOut = join(tmpdir(), `animus-transforms-${Date.now()}.json`);
|
|
218
|
-
execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst ds = m.ds || m.default || m.system;\nconst cfg = ds.toConfig();\nconst out = {};\nfor (const [name, fn] of Object.entries(cfg.transforms || {})) {\n out[name] = fn.toString();\n}\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify(out));\n`, rootDir);
|
|
219
|
-
const fnStrings = JSON.parse(readFileSync(tmpOut, "utf-8"));
|
|
220
|
-
try {
|
|
221
|
-
__require("fs").unlinkSync(tmpOut);
|
|
222
|
-
} catch {}
|
|
223
|
-
transformsSource = `{\n${Object.entries(fnStrings).map(([name, src]) => ` ${JSON.stringify(name)}: ${src}`).join(",\n")}\n}`;
|
|
224
|
-
} catch {}
|
|
349
|
+
const transformsSource = "{}";
|
|
225
350
|
const animusDir = join(rootDir, ".animus");
|
|
226
351
|
if (!existsSync(animusDir)) mkdirSync(animusDir, { recursive: true });
|
|
227
|
-
|
|
352
|
+
const systemPropsContent = `export const systemPropMap = ${systemPropMap};\nexport const systemPropGroups = ${this.groupRegistryJson};\nexport const dynamicPropConfig = ${JSON.stringify(dynamicPropConfig)};\nexport const transforms = ${transformsSource};\n`;
|
|
353
|
+
setSharedSystemProps(systemPropsContent);
|
|
354
|
+
writeFileSync(join(animusDir, "system-props.js"), systemPropsContent);
|
|
228
355
|
setManifestJson(manifestJson);
|
|
356
|
+
bt.total = this.elapsed(pipelineStart);
|
|
357
|
+
this.logBuildTimings(bt, manifest?.timing);
|
|
229
358
|
}
|
|
230
359
|
loadSystem(rootDir, systemPath) {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.variableMapJson
|
|
243
|
-
this.
|
|
244
|
-
this.
|
|
245
|
-
if (this.
|
|
246
|
-
|
|
247
|
-
this.variableMapJson = prefixed.variableMapJson;
|
|
248
|
-
this.variableCss = prefixed.variableCss;
|
|
249
|
-
if (prefixed.themeJson) this.themeJson = prefixed.themeJson;
|
|
250
|
-
if (prefixed.contextualVarsJson) this.contextualVarsJson = prefixed.contextualVarsJson;
|
|
251
|
-
}
|
|
252
|
-
} else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
|
|
253
|
-
if (parsed.globalStyleBlocks) {
|
|
254
|
-
if (Object.keys(parsed.globalStyleBlocks).length > 0) try {
|
|
255
|
-
const hasTransforms = parsed.transformNames && parsed.transformNames.length > 0;
|
|
256
|
-
const flat = JSON.parse(this.themeJson);
|
|
257
|
-
const propConfig = JSON.parse(this.configJson);
|
|
258
|
-
const variableMap = {};
|
|
259
|
-
for (const [tokenPath, value] of Object.entries(flat)) if (typeof value === "string" && value.startsWith("var(") && value.endsWith(")")) variableMap[tokenPath] = value.slice(4, -1);
|
|
260
|
-
const transforms = {};
|
|
261
|
-
if (hasTransforms && parsed.transformSources) for (const [name, src] of Object.entries(parsed.transformSources)) try {
|
|
262
|
-
transforms[name] = new Function(`return (${src})`)();
|
|
263
|
-
} catch {}
|
|
264
|
-
const gsResult = resolveGlobalStyles(parsed.globalStyleBlocks, propConfig, flat, variableMap, transforms);
|
|
265
|
-
const parts = Object.values(gsResult).filter(Boolean);
|
|
266
|
-
if (parts.length > 0) this.globalCss = `@layer global {\n${parts.join("\n\n")}\n}`;
|
|
267
|
-
} catch (e) {
|
|
268
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
269
|
-
if (this.options.strict) throw new Error(`[animus-extract] Global styles resolution failed: ${msg}`);
|
|
270
|
-
console.warn("[animus-extract] Global styles resolution failed:", msg);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (parsed.transformNames && parsed.transformNames.length > 0) {
|
|
274
|
-
const tmpResolve = join(tmpdir(), `animus-transforms-resolve-${Date.now()}.js`);
|
|
275
|
-
writeFileSync(tmpResolve, `const m = require(${JSON.stringify(systemPath)});\nconst ds = m.ds || m.default || m.system;\nconst cfg = ds.toConfig();\nconst css = require('fs').readFileSync(process.argv[2], 'utf-8');\nconst resolved = css.replace(/__TRANSFORM__(\\w+)__(.+?)__/g, (_, name, rawValue) => {\n const fn = cfg.transforms[name];\n if (!fn) return rawValue;\n const value = rawValue !== '' && !isNaN(Number(rawValue)) ? Number(rawValue) : rawValue;\n const result = fn(value);\n return typeof result === 'object' ? JSON.stringify(result) : String(result);\n});\nrequire('fs').writeFileSync(process.argv[3], resolved);\n`);
|
|
276
|
-
this.systemResolveScript = tmpResolve;
|
|
360
|
+
const { loadSystemModule } = __require("@animus-ui/extract");
|
|
361
|
+
const config = loadSystemModule(systemPath, rootDir);
|
|
362
|
+
this.configJson = config.propConfig;
|
|
363
|
+
this.groupRegistryJson = config.groupRegistry;
|
|
364
|
+
this.themeJson = config.scalesJson;
|
|
365
|
+
this.variableMapJson = config.variableMapJson;
|
|
366
|
+
this.variableCss = config.variableCss;
|
|
367
|
+
this.contextualVarsJson = config.contextualVarsJson;
|
|
368
|
+
this.selectorAliasesJson = config.selectorAliases || null;
|
|
369
|
+
this.selectorOrderJson = config.selectorOrder || null;
|
|
370
|
+
if (this.options.prefix) {
|
|
371
|
+
const prefixed = applyPrefix(this.options.prefix, this.variableMapJson, this.variableCss, this.themeJson, this.contextualVarsJson || void 0);
|
|
372
|
+
this.variableMapJson = prefixed.variableMapJson;
|
|
373
|
+
this.variableCss = prefixed.variableCss;
|
|
374
|
+
if (prefixed.themeJson) this.themeJson = prefixed.themeJson;
|
|
375
|
+
if (prefixed.contextualVarsJson) this.contextualVarsJson = prefixed.contextualVarsJson;
|
|
277
376
|
}
|
|
278
|
-
|
|
279
|
-
resolveTransforms(rootDir, css) {
|
|
280
|
-
const { execSync } = __require("child_process");
|
|
281
|
-
const ts = Date.now();
|
|
282
|
-
const tmpIn = join(tmpdir(), `animus-css-${ts}.css`);
|
|
283
|
-
const tmpOut = join(tmpdir(), `animus-css-${ts}.out.css`);
|
|
284
|
-
writeFileSync(tmpIn, css);
|
|
285
|
-
execSync(`${detectRuntime()} run "${this.systemResolveScript}" "${tmpIn}" "${tmpOut}"`, {
|
|
286
|
-
cwd: rootDir,
|
|
287
|
-
encoding: "utf-8"
|
|
288
|
-
});
|
|
289
|
-
const resolved = readFileSync(tmpOut, "utf-8");
|
|
290
|
-
try {
|
|
291
|
-
__require("fs").unlinkSync(tmpIn);
|
|
292
|
-
__require("fs").unlinkSync(tmpOut);
|
|
293
|
-
} catch {}
|
|
294
|
-
return resolved;
|
|
377
|
+
this.globalStyleBlocksJson = config.globalStyleBlocks || null;
|
|
295
378
|
}
|
|
296
379
|
discoverFiles(dir, rootDir, excludePatterns) {
|
|
297
380
|
const results = [];
|
|
@@ -367,6 +450,65 @@ var AnimusWebpackPlugin = class {
|
|
|
367
450
|
clearAnalysisCache();
|
|
368
451
|
} catch {}
|
|
369
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Build cache-aware file entries: full source for changed files,
|
|
455
|
+
* empty source + hash for unchanged (Rust cache-hit path skips these).
|
|
456
|
+
*/
|
|
457
|
+
buildFileEntriesFromCache(changedPaths) {
|
|
458
|
+
const changedSet = new Set(changedPaths);
|
|
459
|
+
const entries = [];
|
|
460
|
+
for (const [path, { hash, source }] of this.fileCache) entries.push({
|
|
461
|
+
path,
|
|
462
|
+
source: changedSet.has(path) ? source : "",
|
|
463
|
+
hash
|
|
464
|
+
});
|
|
465
|
+
return entries;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Run incremental pipeline with cache-aware file entries.
|
|
469
|
+
* Reuses system config from the last full pipeline run.
|
|
470
|
+
*/
|
|
471
|
+
async runIncrementalPipeline(fileEntries) {
|
|
472
|
+
const rootDir = this.rootDir;
|
|
473
|
+
const bt = {};
|
|
474
|
+
const pipelineStart = this.now();
|
|
475
|
+
const { analyzeProject } = __require("@animus-ui/extract");
|
|
476
|
+
const animusDirPath = join(rootDir, ".animus");
|
|
477
|
+
const emitterConfig = JSON.stringify({
|
|
478
|
+
runtime_import: "@animus-ui/system/runtime",
|
|
479
|
+
css_module_id: join(animusDirPath, "system-props.js")
|
|
480
|
+
});
|
|
481
|
+
const packageMapJson = JSON.stringify(Object.fromEntries(Array.from(this.externalSourceEntries).map(([spec, entry]) => [spec, relative(rootDir, entry)])));
|
|
482
|
+
let t = this.now();
|
|
483
|
+
const fileEntriesJson = JSON.stringify(fileEntries);
|
|
484
|
+
bt.jsonSerialize = this.elapsed(t);
|
|
485
|
+
t = this.now();
|
|
486
|
+
const manifestJson = analyzeProject(fileEntriesJson, this.themeJson, this.variableMapJson, this.contextualVarsJson || null, this.configJson, this.groupRegistryJson, packageMapJson, false, emitterConfig, this.selectorAliasesJson, this.selectorOrderJson, this.globalStyleBlocksJson, this.pathAliasesJson);
|
|
487
|
+
bt.rustExtract = this.elapsed(t);
|
|
488
|
+
t = this.now();
|
|
489
|
+
const manifest = JSON.parse(manifestJson);
|
|
490
|
+
bt.jsonParse = this.elapsed(t);
|
|
491
|
+
this.globalCss = manifest?.sheets?.global || "";
|
|
492
|
+
let componentCss = manifest?.css || "";
|
|
493
|
+
componentCss = applyUnitFallback(componentCss);
|
|
494
|
+
const fullCss = assembleStylesheet({
|
|
495
|
+
layers: this.options.layers,
|
|
496
|
+
variableCss: this.variableCss,
|
|
497
|
+
globalCss: this.globalCss,
|
|
498
|
+
componentCss
|
|
499
|
+
});
|
|
500
|
+
setSharedCss(fullCss);
|
|
501
|
+
const cssHash = createHash("md5").update(fullCss).digest("hex");
|
|
502
|
+
if (cssHash !== this.lastCssHash) {
|
|
503
|
+
const animusDir = join(rootDir, ".animus");
|
|
504
|
+
if (!existsSync(animusDir)) mkdirSync(animusDir, { recursive: true });
|
|
505
|
+
writeFileSync(join(animusDir, "styles.css"), fullCss);
|
|
506
|
+
this.lastCssHash = cssHash;
|
|
507
|
+
}
|
|
508
|
+
setManifestJson(manifestJson);
|
|
509
|
+
bt.total = this.elapsed(pipelineStart);
|
|
510
|
+
this.logBuildTimings(bt, manifest?.timing);
|
|
511
|
+
}
|
|
370
512
|
/** Expose file cache for HMR change detection */
|
|
371
513
|
getFileCache() {
|
|
372
514
|
return this.fileCache;
|
|
@@ -407,6 +549,8 @@ function withAnimus(options) {
|
|
|
407
549
|
const rootDir = process.cwd();
|
|
408
550
|
const animusDir = join(rootDir, ".animus");
|
|
409
551
|
if (!existsSync(animusDir)) mkdirSync(animusDir, { recursive: true });
|
|
552
|
+
const stubCssPath = join(animusDir, "styles.css");
|
|
553
|
+
if (!existsSync(stubCssPath)) writeFileSync(stubCssPath, "@layer anm-global, anm-base, anm-variants, anm-compounds, anm-states, anm-system, anm-custom;\n");
|
|
410
554
|
if (!warnedGitignore) {
|
|
411
555
|
warnedGitignore = true;
|
|
412
556
|
try {
|
|
@@ -433,6 +577,7 @@ function withAnimus(options) {
|
|
|
433
577
|
compiler.hooks.normalModuleFactory.tap("AnimusVirtualResolve", (nmf) => {
|
|
434
578
|
nmf.hooks.beforeResolve.tap("AnimusVirtualResolve", (resolveData) => {
|
|
435
579
|
if (resolveData.request === "virtual:animus/system-props") resolveData.request = systemPropsPath;
|
|
580
|
+
if (resolveData.request === "virtual:animus/styles.css") resolveData.request = join(rootDir, ".animus", "styles.css");
|
|
436
581
|
const srcEntry = plugin.getExternalSourceEntries().get(resolveData.request);
|
|
437
582
|
if (srcEntry) resolveData.request = srcEntry;
|
|
438
583
|
});
|
package/dist/loader.cjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
const require_singleton = require("./singleton-
|
|
1
|
+
const require_singleton = require("./singleton-ChvheNU3.cjs");
|
|
2
2
|
let path = require("path");
|
|
3
3
|
//#region src/loader.ts
|
|
4
4
|
/**
|
|
5
5
|
* Regex matching CSS import lines injected by the Rust emitter.
|
|
6
|
-
* Catches both the alias form (`import '.animus/styles.css'`)
|
|
7
|
-
* relative forms (`import '../.animus/styles.css'`)
|
|
6
|
+
* Catches both the alias form (`import '.animus/styles.css'`),
|
|
7
|
+
* relative forms (`import '../.animus/styles.css'`), and the Vite
|
|
8
|
+
* virtual module form (`import 'virtual:animus/styles.css'`) which
|
|
9
|
+
* appears in pre-built external packages compiled with the Vite plugin.
|
|
8
10
|
*/
|
|
9
|
-
const CSS_IMPORT_RE = /import\s+['"][^'"]*\.animus\/styles\.css['"];\n?/g;
|
|
11
|
+
const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
|
|
10
12
|
/**
|
|
11
13
|
* Root entry file patterns. CSS is imported ONLY here to prevent
|
|
12
14
|
* per-chunk duplication in Next.js builds.
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxC,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxC,CAAC;AAuBF;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAwCR"}
|
package/dist/loader.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as __require, n as getManifestJson } from "./singleton-BY7EN689.mjs";
|
|
2
2
|
import { relative } from "path";
|
|
3
3
|
//#region src/loader.ts
|
|
4
4
|
/**
|
|
5
5
|
* Regex matching CSS import lines injected by the Rust emitter.
|
|
6
|
-
* Catches both the alias form (`import '.animus/styles.css'`)
|
|
7
|
-
* relative forms (`import '../.animus/styles.css'`)
|
|
6
|
+
* Catches both the alias form (`import '.animus/styles.css'`),
|
|
7
|
+
* relative forms (`import '../.animus/styles.css'`), and the Vite
|
|
8
|
+
* virtual module form (`import 'virtual:animus/styles.css'`) which
|
|
9
|
+
* appears in pre-built external packages compiled with the Vite plugin.
|
|
8
10
|
*/
|
|
9
|
-
const CSS_IMPORT_RE = /import\s+['"][^'"]*\.animus\/styles\.css['"];\n?/g;
|
|
11
|
+
const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
|
|
10
12
|
/**
|
|
11
13
|
* Root entry file patterns. CSS is imported ONLY here to prevent
|
|
12
14
|
* per-chunk duplication in Next.js builds.
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { AnimusNextOptions } from './types';
|
|
2
|
+
type WebpackSource = {
|
|
3
|
+
source(): string | Buffer;
|
|
4
|
+
size(): number;
|
|
5
|
+
};
|
|
6
|
+
type Compilation = {
|
|
7
|
+
hooks: {
|
|
8
|
+
processAssets: {
|
|
9
|
+
tap: (options: {
|
|
10
|
+
name: string;
|
|
11
|
+
stage: number;
|
|
12
|
+
}, fn: (assets: Record<string, WebpackSource>) => void) => void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
getAsset(name: string): {
|
|
16
|
+
source: WebpackSource;
|
|
17
|
+
} | undefined;
|
|
18
|
+
updateAsset(name: string, newSource: WebpackSource): void;
|
|
19
|
+
};
|
|
2
20
|
type Compiler = {
|
|
3
21
|
hooks: {
|
|
4
22
|
run: {
|
|
@@ -7,8 +25,25 @@ type Compiler = {
|
|
|
7
25
|
watchRun: {
|
|
8
26
|
tapPromise: (name: string, fn: (c: Compiler) => Promise<void>) => void;
|
|
9
27
|
};
|
|
28
|
+
compilation: {
|
|
29
|
+
tap: (name: string, fn: (compilation: Compilation) => void) => void;
|
|
30
|
+
};
|
|
10
31
|
};
|
|
11
32
|
context: string;
|
|
33
|
+
options?: {
|
|
34
|
+
name?: string;
|
|
35
|
+
resolve?: {
|
|
36
|
+
alias?: Record<string, string | string[] | false>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
webpack?: {
|
|
40
|
+
Compilation: {
|
|
41
|
+
PROCESS_ASSETS_STAGE_ADDITIONAL: number;
|
|
42
|
+
};
|
|
43
|
+
sources: {
|
|
44
|
+
RawSource: new (source: string) => WebpackSource;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
12
47
|
};
|
|
13
48
|
export declare class AnimusWebpackPlugin {
|
|
14
49
|
private options;
|
|
@@ -19,25 +54,44 @@ export declare class AnimusWebpackPlugin {
|
|
|
19
54
|
private variableMapJson;
|
|
20
55
|
private variableCss;
|
|
21
56
|
private contextualVarsJson;
|
|
57
|
+
private selectorAliasesJson;
|
|
58
|
+
private selectorOrderJson;
|
|
22
59
|
private globalCss;
|
|
23
|
-
private
|
|
60
|
+
private globalStyleBlocksJson;
|
|
61
|
+
private pathAliasesJson;
|
|
24
62
|
private fileCache;
|
|
25
63
|
private lastCssHash;
|
|
26
64
|
private externalPackageDirs;
|
|
27
65
|
private externalSourceEntries;
|
|
28
66
|
constructor(options: AnimusNextOptions);
|
|
67
|
+
private get verbose();
|
|
68
|
+
private log;
|
|
69
|
+
private now;
|
|
70
|
+
private elapsed;
|
|
71
|
+
private logBuildTimings;
|
|
29
72
|
private initialized;
|
|
73
|
+
/** Extract path aliases from webpack's resolve.alias config. */
|
|
74
|
+
private extractAliases;
|
|
30
75
|
apply(compiler: Compiler): void;
|
|
31
76
|
private handleWatchUpdate;
|
|
32
77
|
private runFullPipeline;
|
|
33
78
|
private loadSystem;
|
|
34
|
-
private resolveTransforms;
|
|
35
79
|
private discoverFiles;
|
|
36
80
|
private resolvePackagesByName;
|
|
37
81
|
/**
|
|
38
82
|
* Reset analysis state for HMR geological reset.
|
|
39
83
|
*/
|
|
40
84
|
resetForHmr(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Build cache-aware file entries: full source for changed files,
|
|
87
|
+
* empty source + hash for unchanged (Rust cache-hit path skips these).
|
|
88
|
+
*/
|
|
89
|
+
private buildFileEntriesFromCache;
|
|
90
|
+
/**
|
|
91
|
+
* Run incremental pipeline with cache-aware file entries.
|
|
92
|
+
* Reuses system config from the last full pipeline run.
|
|
93
|
+
*/
|
|
94
|
+
private runIncrementalPipeline;
|
|
41
95
|
/** Expose file cache for HMR change detection */
|
|
42
96
|
getFileCache(): Map<string, {
|
|
43
97
|
hash: string;
|
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":"AA2BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,aAAa,GAAG;IACnB,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE;QACL,aAAa,EAAE;YACb,GAAG,EAAE,CACH,OAAO,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,EACxC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,IAAI,KAChD,IAAI,CAAC;SACX,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE,GAAG,SAAS,CAAC;IAC9D,WAAW,CACT,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,GACvB,IAAI,CAAC;CACT,CAAC;AAEF,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;QACF,WAAW,EAAE;YACX,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,KAAK,IAAI,CAAC;SACrE,CAAC;KACH,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE;YACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;SACnD,CAAC;KACH,CAAC;IACF,OAAO,CAAC,EAAE;QACR,WAAW,EAAE;YACX,+BAA+B,EAAE,MAAM,CAAC;SACzC,CAAC;QACF,OAAO,EAAE;YACP,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,aAAa,CAAC;SAClD,CAAC;KACH,CAAC;CACH,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,mBAAmB,CAAuB;IAClD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,eAAe,CAAuB;IAG9C,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,KAAK,OAAO,GAMlB;IAED,OAAO,CAAC,GAAG;IAOX,OAAO,CAAC,GAAG;IAGX,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,eAAe;IAyEvB,OAAO,CAAC,WAAW,CAAS;IAE5B,gEAAgE;IAChE,OAAO,CAAC,cAAc;IAyCtB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;YA4EjB,iBAAiB;YA+DjB,eAAe;IA+O7B,OAAO,CAAC,UAAU;IAgClB,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,qBAAqB;IAmD7B;;OAEG;IACH,WAAW,IAAI,IAAI;IASnB;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAejC;;;OAGG;YACW,sBAAsB;IAmFpC,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"}
|
|
@@ -12,6 +12,8 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
12
12
|
*/
|
|
13
13
|
const MANIFEST_KEY = "__animus_manifest_json__";
|
|
14
14
|
const PROMISE_KEY = "__animus_analysis_promise__";
|
|
15
|
+
const SHARED_CSS_KEY = "__animus_shared_css__";
|
|
16
|
+
const SHARED_SYSTEM_PROPS_KEY = "__animus_shared_system_props__";
|
|
15
17
|
function getManifestJson() {
|
|
16
18
|
return globalThis[MANIFEST_KEY];
|
|
17
19
|
}
|
|
@@ -27,5 +29,14 @@ function setAnalysisPromise(promise) {
|
|
|
27
29
|
function resetAnalysisPromise() {
|
|
28
30
|
globalThis[PROMISE_KEY] = null;
|
|
29
31
|
}
|
|
32
|
+
function getSharedCss() {
|
|
33
|
+
return globalThis[SHARED_CSS_KEY] || "";
|
|
34
|
+
}
|
|
35
|
+
function setSharedCss(css) {
|
|
36
|
+
globalThis[SHARED_CSS_KEY] = css;
|
|
37
|
+
}
|
|
38
|
+
function setSharedSystemProps(content) {
|
|
39
|
+
globalThis[SHARED_SYSTEM_PROPS_KEY] = content;
|
|
40
|
+
}
|
|
30
41
|
//#endregion
|
|
31
|
-
export {
|
|
42
|
+
export { setAnalysisPromise as a, setSharedSystemProps as c, resetAnalysisPromise as i, __require as l, getManifestJson as n, setManifestJson as o, getSharedCss as r, setSharedCss as s, getAnalysisPromise as t };
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
const MANIFEST_KEY = "__animus_manifest_json__";
|
|
10
10
|
const PROMISE_KEY = "__animus_analysis_promise__";
|
|
11
|
+
const SHARED_CSS_KEY = "__animus_shared_css__";
|
|
12
|
+
const SHARED_SYSTEM_PROPS_KEY = "__animus_shared_system_props__";
|
|
11
13
|
function getManifestJson() {
|
|
12
14
|
return globalThis[MANIFEST_KEY];
|
|
13
15
|
}
|
|
@@ -23,6 +25,15 @@ function setAnalysisPromise(promise) {
|
|
|
23
25
|
function resetAnalysisPromise() {
|
|
24
26
|
globalThis[PROMISE_KEY] = null;
|
|
25
27
|
}
|
|
28
|
+
function getSharedCss() {
|
|
29
|
+
return globalThis[SHARED_CSS_KEY] || "";
|
|
30
|
+
}
|
|
31
|
+
function setSharedCss(css) {
|
|
32
|
+
globalThis[SHARED_CSS_KEY] = css;
|
|
33
|
+
}
|
|
34
|
+
function setSharedSystemProps(content) {
|
|
35
|
+
globalThis[SHARED_SYSTEM_PROPS_KEY] = content;
|
|
36
|
+
}
|
|
26
37
|
//#endregion
|
|
27
38
|
Object.defineProperty(exports, "getAnalysisPromise", {
|
|
28
39
|
enumerable: true,
|
|
@@ -36,6 +47,12 @@ Object.defineProperty(exports, "getManifestJson", {
|
|
|
36
47
|
return getManifestJson;
|
|
37
48
|
}
|
|
38
49
|
});
|
|
50
|
+
Object.defineProperty(exports, "getSharedCss", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function() {
|
|
53
|
+
return getSharedCss;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
39
56
|
Object.defineProperty(exports, "resetAnalysisPromise", {
|
|
40
57
|
enumerable: true,
|
|
41
58
|
get: function() {
|
|
@@ -54,3 +71,15 @@ Object.defineProperty(exports, "setManifestJson", {
|
|
|
54
71
|
return setManifestJson;
|
|
55
72
|
}
|
|
56
73
|
});
|
|
74
|
+
Object.defineProperty(exports, "setSharedCss", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function() {
|
|
77
|
+
return setSharedCss;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "setSharedSystemProps", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function() {
|
|
83
|
+
return setSharedSystemProps;
|
|
84
|
+
}
|
|
85
|
+
});
|
package/dist/singleton.d.ts
CHANGED
|
@@ -10,4 +10,8 @@ export declare function setManifestJson(json: string): void;
|
|
|
10
10
|
export declare function getAnalysisPromise(): Promise<void> | null;
|
|
11
11
|
export declare function setAnalysisPromise(promise: Promise<void>): void;
|
|
12
12
|
export declare function resetAnalysisPromise(): void;
|
|
13
|
+
export declare function getSharedCss(): string;
|
|
14
|
+
export declare function setSharedCss(css: string): void;
|
|
15
|
+
export declare function getSharedSystemProps(): string;
|
|
16
|
+
export declare function setSharedSystemProps(content: string): void;
|
|
13
17
|
//# sourceMappingURL=singleton.d.ts.map
|
package/dist/singleton.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAElD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAIzD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAE/D;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,KAAK,aAAa,GAAG;IACnB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,KAAK,CAAC;YACZ,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,GAAG,CAAC,EAAE,KAAK,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aAAE,CAAC,CAAC;SACpE,CAAC,CAAC;KACJ,CAAC;CACH,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1C,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,aAAa,CAAC;CACpB,CAAC;AAIF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,iBAAiB,GACzB,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,KAAK,aAAa,GAAG;IACnB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,KAAK,CAAC;YACZ,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,GAAG,CAAC,EAAE,KAAK,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aAAE,CAAC,CAAC;SACpE,CAAC,CAAC;KACJ,CAAC;CACH,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1C,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,aAAa,CAAC;CACpB,CAAC;AAIF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,iBAAiB,GACzB,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,CAgLxC"}
|
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.59",
|
|
4
4
|
"description": "Animus static CSS extraction for Next.js (webpack)",
|
|
5
5
|
"author": "codecaaron <airrobb@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"webpack": ">=5.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@animus-ui/extract": "0.1.0-next.
|
|
56
|
+
"@animus-ui/extract": "0.1.0-next.59"
|
|
57
57
|
}
|
|
58
58
|
}
|