@animus-ui/vite-plugin 0.1.3 → 0.1.4
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/README.md +2 -2
- package/dist/build-start.d.ts +4 -2
- package/dist/build-start.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/context.d.ts +47 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +141 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/reset-coalescer.d.ts +2 -1
- package/dist/reset-coalescer.d.ts.map +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,9 +50,9 @@ import { createAppearanceBootstrap } from '@animus-ui/system/bootstrap';
|
|
|
50
50
|
import { animusExtract } from '@animus-ui/vite-plugin';
|
|
51
51
|
import { defineConfig } from 'vite';
|
|
52
52
|
|
|
53
|
-
import {
|
|
53
|
+
import { theme } from './src/ds';
|
|
54
54
|
|
|
55
|
-
const appearanceBootstrap = createAppearanceBootstrap(
|
|
55
|
+
const appearanceBootstrap = createAppearanceBootstrap(theme);
|
|
56
56
|
|
|
57
57
|
export default defineConfig({
|
|
58
58
|
plugins: [animusExtract({ system: './src/ds.ts', appearanceBootstrap })],
|
package/dist/build-start.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import type { PluginContext } from './context';
|
|
|
3
3
|
* buildStart: load the system, discover and ingest sources (local +
|
|
4
4
|
* external packages), run whole-project analysis, and log the report.
|
|
5
5
|
* `resolveSpecifier` is the bundler seam — Vite's `this.resolve` mapped to
|
|
6
|
-
* an absolute id.
|
|
6
|
+
* an absolute id. `emitAsset` (build mode only) is Rollup's `this.emitFile`
|
|
7
|
+
* for `asset()` placeholder substitution; absent in dev, where resolved
|
|
8
|
+
* files are served via base + `/@fs/` instead.
|
|
7
9
|
*/
|
|
8
|
-
export declare function runBuildStart(ctx: PluginContext, resolveSpecifier: (specifier: string) => Promise<string | null
|
|
10
|
+
export declare function runBuildStart(ctx: PluginContext, resolveSpecifier: (specifier: string) => Promise<string | null>, emitAsset?: (fileName: string, source: Uint8Array) => string): Promise<void>;
|
|
9
11
|
//# sourceMappingURL=build-start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAC/D,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CAkRf"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CAwDN"}
|
package/dist/context.d.ts
CHANGED
|
@@ -90,7 +90,13 @@ export declare class PluginContext {
|
|
|
90
90
|
}>;
|
|
91
91
|
readonly hotUpdateEvents: HotUpdateEvents;
|
|
92
92
|
packageMap: Record<string, string>;
|
|
93
|
+
base: string;
|
|
94
|
+
assetUrlBySpecifier: Map<string, string>;
|
|
95
|
+
assetResolutionFailures: Set<string>;
|
|
96
|
+
assetPassComplete: boolean;
|
|
93
97
|
externalPackageDirs: string[];
|
|
98
|
+
externalDirOwners: Record<string, string>;
|
|
99
|
+
externalFileOwners: Record<string, string>;
|
|
94
100
|
externalSourceEntries: Map<string, string>;
|
|
95
101
|
externalPackageOutcomes: ExternalPackageOutcome[];
|
|
96
102
|
devServer: any;
|
|
@@ -103,7 +109,7 @@ export declare class PluginContext {
|
|
|
103
109
|
private v2DriftWarned;
|
|
104
110
|
/** Single engine choke-point for every native extraction call. */
|
|
105
111
|
readonly engineApi: () => any;
|
|
106
|
-
constructor(options: AnimusExtractOptions);
|
|
112
|
+
constructor(options: AnimusExtractOptions, engineApiOverride?: () => any);
|
|
107
113
|
log(msg: string): void;
|
|
108
114
|
warn(msg: string): void;
|
|
109
115
|
logTimingWaterfall(timing: Record<string, number>): void;
|
|
@@ -122,6 +128,24 @@ export declare class PluginContext {
|
|
|
122
128
|
source: string;
|
|
123
129
|
hash?: string;
|
|
124
130
|
}>): void;
|
|
131
|
+
/** Base-prefixed dev URL for an absolute file (Vite mounts /@fs under base). */
|
|
132
|
+
devFsUrl(absPath: string): string;
|
|
133
|
+
/**
|
|
134
|
+
* The shared unresolvable-asset policy: fail the build under `strict`,
|
|
135
|
+
* else warn and record the identity mapping so the specifier emits
|
|
136
|
+
* literally.
|
|
137
|
+
*/
|
|
138
|
+
assetFallback(specifier: string, message: string, cause?: unknown): void;
|
|
139
|
+
/**
|
|
140
|
+
* The one asset-substitution pass per analysis. In dev, a specifier not
|
|
141
|
+
* already mapped by buildStart's bundler-resolved pass (a geological
|
|
142
|
+
* reset regenerates globalCss from an edited system, which may reference
|
|
143
|
+
* NEW assets) is resolved Node-side first — host aliases, then Node,
|
|
144
|
+
* then package root; bundler-only resolutions can differ, since the
|
|
145
|
+
* plugin hook context is unavailable on this path. Strict semantics
|
|
146
|
+
* match buildStart.
|
|
147
|
+
*/
|
|
148
|
+
private applyAssetSubstitutions;
|
|
125
149
|
private resetCoalescer;
|
|
126
150
|
/**
|
|
127
151
|
* Schedule a geological reset through the burst coalescer. N dependency
|
|
@@ -129,6 +153,15 @@ export declare class PluginContext {
|
|
|
129
153
|
* running reset produce exactly one follow-up.
|
|
130
154
|
*/
|
|
131
155
|
requestGeologicalReset(trigger: string): void;
|
|
156
|
+
/**
|
|
157
|
+
* A failed reset must surface without killing the server: the coalescer
|
|
158
|
+
* fires from a bare timer, OUTSIDE Vite's handleHMRUpdate catch, so a
|
|
159
|
+
* strict-mode throw (asset resolution, token contracts, system load)
|
|
160
|
+
* would otherwise be an unhandled exception that exits the process.
|
|
161
|
+
* Strict-in-dev means the error overlay, matching the transform/HMR
|
|
162
|
+
* strict paths that Vite itself catches.
|
|
163
|
+
*/
|
|
164
|
+
private geologicalResetFailed;
|
|
132
165
|
/**
|
|
133
166
|
* The geological reset: reload the system (refreshing the dependency
|
|
134
167
|
* set), clear the Rust per-file cache, re-analyze everything with full
|
|
@@ -171,9 +204,21 @@ export declare class PluginContext {
|
|
|
171
204
|
* (external-package-file-discovery: silence is never an outcome). An
|
|
172
205
|
* unresolvable `.includes()` specifier warns in non-strict mode and FAILS
|
|
173
206
|
* the build under `strict: true`, naming every offending specifier —
|
|
174
|
-
* a typo'd include must not ship a build missing its component CSS.
|
|
207
|
+
* a typo'd include must not ship a build missing its component CSS. A
|
|
208
|
+
* stale dist entry under an extended package (first-class-extension D13)
|
|
209
|
+
* rides the same seam: a merge against it would silently skew registry
|
|
210
|
+
* content the discovered sources no longer match.
|
|
175
211
|
*/
|
|
176
212
|
enforceIncludeResolution(): void;
|
|
213
|
+
/**
|
|
214
|
+
* The post-analysis gate over cross-source token contracts
|
|
215
|
+
* (extraction-diagnostics): a discovered component referencing a token its
|
|
216
|
+
* OWN package defines but the consumer theme does not gets the teaching
|
|
217
|
+
* error naming the token, component, source package, and the missing
|
|
218
|
+
* `createTheme().extend(...)`. Wiring and severity routing live in the
|
|
219
|
+
* shared pipeline gate (next-plugin parity by construction).
|
|
220
|
+
*/
|
|
221
|
+
enforceExternalTokenContracts(): void;
|
|
177
222
|
runSelfVerify(): void;
|
|
178
223
|
}
|
|
179
224
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAiBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EA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;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAClE,IAAI,CAsEN;IAED,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhC;IAED;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAOvE;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA6B/B,OAAO,CAAC,cAAc,CAA+B;IAErD;;;;OAIG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAO5C;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;OAKG;IACH,sBAAsB,IAAI,IAAI,CA4B7B;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI3C;IAED;;;;;;;OAOG;IACH,wBAAwB,IAAI,IAAI,CAe/B;IAED;;;;;;;;;;;;OAYG;IACH,0BAA0B,IAAI,IAAI,CAkBjC;IAED;;;;;;;;;OASG;IACH,wBAAwB,IAAI,IAAI,CAW/B;IAED;;;;;;;OAOG;IACH,6BAA6B,IAAI,IAAI,CAUpC;IAED,aAAa,IAAI,IAAI,CAiEpB;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -26,10 +26,15 @@ const DEFAULT_EXCLUDE = [
|
|
|
26
26
|
* buildStart: load the system, discover and ingest sources (local +
|
|
27
27
|
* external packages), run whole-project analysis, and log the report.
|
|
28
28
|
* `resolveSpecifier` is the bundler seam — Vite's `this.resolve` mapped to
|
|
29
|
-
* an absolute id.
|
|
29
|
+
* an absolute id. `emitAsset` (build mode only) is Rollup's `this.emitFile`
|
|
30
|
+
* for `asset()` placeholder substitution; absent in dev, where resolved
|
|
31
|
+
* files are served via base + `/@fs/` instead.
|
|
30
32
|
*/
|
|
31
|
-
async function runBuildStart(ctx, resolveSpecifier) {
|
|
33
|
+
async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
|
|
32
34
|
(0, _animus_ui_extract_pipeline.clearEngineCache)(ctx.engineApi);
|
|
35
|
+
ctx.assetPassComplete = false;
|
|
36
|
+
ctx.assetUrlBySpecifier.clear();
|
|
37
|
+
ctx.assetResolutionFailures.clear();
|
|
33
38
|
let t0 = performance.now();
|
|
34
39
|
ctx.loadSystem();
|
|
35
40
|
if (ctx.options.layers) {
|
|
@@ -106,6 +111,8 @@ async function runBuildStart(ctx, resolveSpecifier) {
|
|
|
106
111
|
});
|
|
107
112
|
ctx.packageMap = collected.packageMap;
|
|
108
113
|
ctx.externalPackageOutcomes = collected.outcomes;
|
|
114
|
+
ctx.externalDirOwners = collected.dirOwners;
|
|
115
|
+
ctx.externalFileOwners = collected.fileOwners;
|
|
109
116
|
ctx.enforceIncludeResolution();
|
|
110
117
|
for (const [specifier, srcEntry] of collected.sourceEntries) ctx.externalSourceEntries.set(specifier, srcEntry);
|
|
111
118
|
for (const entry of collected.entries) {
|
|
@@ -126,6 +133,23 @@ async function runBuildStart(ctx, resolveSpecifier) {
|
|
|
126
133
|
ctx.log(`Discovered ${fileEntries.length} files (${packageFileCount} from packages) (${Math.round(performance.now() - t0)}ms)`);
|
|
127
134
|
t0 = performance.now();
|
|
128
135
|
ctx.runAnalysis(fileEntries);
|
|
136
|
+
const assetSpecifiers = (0, _animus_ui_extract_pipeline.findAssetSpecifiers)(ctx.globalCss);
|
|
137
|
+
for (const specifier of assetSpecifiers) {
|
|
138
|
+
const resolvedPath = await resolveSpecifier(specifier);
|
|
139
|
+
if (!resolvedPath) {
|
|
140
|
+
ctx.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (emitAsset) try {
|
|
144
|
+
const referenceId = emitAsset((0, path.basename)(resolvedPath), (0, fs.readFileSync)(resolvedPath));
|
|
145
|
+
ctx.assetUrlBySpecifier.set(specifier, `__VITE_ASSET__${referenceId}__`);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
ctx.assetFallback(specifier, `[animus-extract] failed to emit asset() specifier ${specifier}: ${String(err)}`, err);
|
|
148
|
+
}
|
|
149
|
+
else ctx.assetUrlBySpecifier.set(specifier, ctx.devFsUrl(resolvedPath));
|
|
150
|
+
}
|
|
151
|
+
ctx.globalCss = (0, _animus_ui_extract_pipeline.substituteAssetPlaceholders)(ctx.globalCss, ctx.assetUrlBySpecifier);
|
|
152
|
+
ctx.assetPassComplete = true;
|
|
129
153
|
if (ctx.storedManifest) {
|
|
130
154
|
const report = ctx.storedManifest.report;
|
|
131
155
|
if (report) {
|
|
@@ -169,6 +193,7 @@ function applyResolvedConfig(ctx, config) {
|
|
|
169
193
|
ctx.isProd = config.command === "build";
|
|
170
194
|
ctx.rootDir = config.root;
|
|
171
195
|
ctx.logger = config.logger;
|
|
196
|
+
ctx.base = config.base ?? "/";
|
|
172
197
|
ctx.lcssTargets = (0, _animus_ui_extract_pipeline.resolveLightningTargets)(ctx.options.targets, ctx.rootDir);
|
|
173
198
|
ctx.log(`Lightning CSS targets resolved (${Object.keys(ctx.lcssTargets).length} browsers)`);
|
|
174
199
|
const rawAlias = config.resolve?.alias;
|
|
@@ -261,8 +286,9 @@ var ResetCoalescer = class {
|
|
|
261
286
|
timer = null;
|
|
262
287
|
running = false;
|
|
263
288
|
dirty = false;
|
|
264
|
-
constructor(run, quietMs = 60, schedule = (fn, ms) => setTimeout(fn, ms), cancel = (timer) => clearTimeout(timer)) {
|
|
289
|
+
constructor(run, onError, quietMs = 60, schedule = (fn, ms) => setTimeout(fn, ms), cancel = (timer) => clearTimeout(timer)) {
|
|
265
290
|
this.run = run;
|
|
291
|
+
this.onError = onError;
|
|
266
292
|
this.quietMs = quietMs;
|
|
267
293
|
this.schedule = schedule;
|
|
268
294
|
this.cancel = cancel;
|
|
@@ -279,6 +305,8 @@ var ResetCoalescer = class {
|
|
|
279
305
|
this.running = true;
|
|
280
306
|
try {
|
|
281
307
|
this.run();
|
|
308
|
+
} catch (err) {
|
|
309
|
+
this.onError(err);
|
|
282
310
|
} finally {
|
|
283
311
|
this.running = false;
|
|
284
312
|
if (this.dirty) {
|
|
@@ -370,7 +398,13 @@ var PluginContext = class {
|
|
|
370
398
|
fileCache = /* @__PURE__ */ new Map();
|
|
371
399
|
hotUpdateEvents = new HotUpdateEvents();
|
|
372
400
|
packageMap = {};
|
|
401
|
+
base = "/";
|
|
402
|
+
assetUrlBySpecifier = /* @__PURE__ */ new Map();
|
|
403
|
+
assetResolutionFailures = /* @__PURE__ */ new Set();
|
|
404
|
+
assetPassComplete = false;
|
|
373
405
|
externalPackageDirs = [];
|
|
406
|
+
externalDirOwners = {};
|
|
407
|
+
externalFileOwners = {};
|
|
374
408
|
externalSourceEntries = /* @__PURE__ */ new Map();
|
|
375
409
|
externalPackageOutcomes = [];
|
|
376
410
|
devServer;
|
|
@@ -383,11 +417,15 @@ var PluginContext = class {
|
|
|
383
417
|
v2DriftWarned = false;
|
|
384
418
|
/** Single engine choke-point for every native extraction call. */
|
|
385
419
|
engineApi;
|
|
386
|
-
constructor(options) {
|
|
420
|
+
constructor(options, engineApiOverride) {
|
|
387
421
|
this.options = options;
|
|
388
422
|
this.staticCssJson = (0, _animus_ui_extract_pipeline.serializeStaticCss)(options.staticCss);
|
|
389
423
|
this.verbose = options.verbose || process.env.ANIMUS_DEBUG === "1" || process.env.ANIMUS_DEBUG === "true";
|
|
390
424
|
this.extensionsSet = new Set(options.extensions ?? _animus_ui_extract_pipeline.DEFAULT_EXTENSIONS);
|
|
425
|
+
if (engineApiOverride) {
|
|
426
|
+
this.engineApi = engineApiOverride;
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
391
429
|
const engineModuleId = "@animus-ui/extract";
|
|
392
430
|
this.engineApi = (0, _animus_ui_extract_pipeline.createV2EngineApi)({
|
|
393
431
|
label: "animus-extract",
|
|
@@ -470,6 +508,7 @@ var PluginContext = class {
|
|
|
470
508
|
},
|
|
471
509
|
pathAliasesJson: this.pathAliasesJson,
|
|
472
510
|
staticCssJson: this.staticCssJson,
|
|
511
|
+
externalDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir)),
|
|
473
512
|
devMode: !this.isProd,
|
|
474
513
|
warn: (m) => this.warn(m)
|
|
475
514
|
});
|
|
@@ -490,7 +529,44 @@ var PluginContext = class {
|
|
|
490
529
|
} catch (e) {
|
|
491
530
|
if (this.options.strict) throw new Error(`[animus-extract] analyzeProject failed: ${e}`, { cause: e });
|
|
492
531
|
console.warn("[animus-extract] analyzeProject failed:", e);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
this.applyAssetSubstitutions();
|
|
535
|
+
this.enforceExternalTokenContracts();
|
|
536
|
+
}
|
|
537
|
+
/** Base-prefixed dev URL for an absolute file (Vite mounts /@fs under base). */
|
|
538
|
+
devFsUrl(absPath) {
|
|
539
|
+
return `${this.base.endsWith("/") ? this.base.slice(0, -1) : this.base}/@fs${absPath}`;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* The shared unresolvable-asset policy: fail the build under `strict`,
|
|
543
|
+
* else warn and record the identity mapping so the specifier emits
|
|
544
|
+
* literally.
|
|
545
|
+
*/
|
|
546
|
+
assetFallback(specifier, message, cause) {
|
|
547
|
+
if (this.options.strict) throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
548
|
+
this.warn(message);
|
|
549
|
+
this.assetUrlBySpecifier.set(specifier, specifier);
|
|
550
|
+
this.assetResolutionFailures.add(specifier);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* The one asset-substitution pass per analysis. In dev, a specifier not
|
|
554
|
+
* already mapped by buildStart's bundler-resolved pass (a geological
|
|
555
|
+
* reset regenerates globalCss from an edited system, which may reference
|
|
556
|
+
* NEW assets) is resolved Node-side first — host aliases, then Node,
|
|
557
|
+
* then package root; bundler-only resolutions can differ, since the
|
|
558
|
+
* plugin hook context is unavailable on this path. Strict semantics
|
|
559
|
+
* match buildStart.
|
|
560
|
+
*/
|
|
561
|
+
applyAssetSubstitutions() {
|
|
562
|
+
if (!this.isProd && this.assetPassComplete) for (const specifier of (0, _animus_ui_extract_pipeline.findAssetSpecifiers)(this.globalCss)) {
|
|
563
|
+
if (this.assetResolutionFailures.delete(specifier)) this.assetUrlBySpecifier.delete(specifier);
|
|
564
|
+
if (this.assetUrlBySpecifier.has(specifier)) continue;
|
|
565
|
+
const resolved = (0, _animus_ui_extract_pipeline.resolveAssetFile)(specifier, this.rootDir, this.pathAliasesJson);
|
|
566
|
+
if (resolved) this.assetUrlBySpecifier.set(specifier, this.devFsUrl(resolved));
|
|
567
|
+
else this.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
|
|
493
568
|
}
|
|
569
|
+
this.globalCss = (0, _animus_ui_extract_pipeline.substituteAssetPlaceholders)(this.globalCss, this.assetUrlBySpecifier);
|
|
494
570
|
}
|
|
495
571
|
resetCoalescer = null;
|
|
496
572
|
/**
|
|
@@ -500,10 +576,31 @@ var PluginContext = class {
|
|
|
500
576
|
*/
|
|
501
577
|
requestGeologicalReset(trigger) {
|
|
502
578
|
this.log(`HMR geological reset scheduled: ${trigger}`);
|
|
503
|
-
this.resetCoalescer ??= new ResetCoalescer(() => this.performGeologicalReset());
|
|
579
|
+
this.resetCoalescer ??= new ResetCoalescer(() => this.performGeologicalReset(), (err) => this.geologicalResetFailed(err));
|
|
504
580
|
this.resetCoalescer.request();
|
|
505
581
|
}
|
|
506
582
|
/**
|
|
583
|
+
* A failed reset must surface without killing the server: the coalescer
|
|
584
|
+
* fires from a bare timer, OUTSIDE Vite's handleHMRUpdate catch, so a
|
|
585
|
+
* strict-mode throw (asset resolution, token contracts, system load)
|
|
586
|
+
* would otherwise be an unhandled exception that exits the process.
|
|
587
|
+
* Strict-in-dev means the error overlay, matching the transform/HMR
|
|
588
|
+
* strict paths that Vite itself catches.
|
|
589
|
+
*/
|
|
590
|
+
geologicalResetFailed(err) {
|
|
591
|
+
this.warn(`[animus-extract] geological reset failed: ${err}`);
|
|
592
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
593
|
+
const stack = err instanceof Error ? err.stack ?? "" : "";
|
|
594
|
+
this.devServer?.hot?.send({
|
|
595
|
+
type: "error",
|
|
596
|
+
err: {
|
|
597
|
+
message,
|
|
598
|
+
stack,
|
|
599
|
+
plugin: "animus-extract"
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
507
604
|
* The geological reset: reload the system (refreshing the dependency
|
|
508
605
|
* set), clear the Rust per-file cache, re-analyze everything with full
|
|
509
606
|
* sources, then invalidate the static/component/system-prop virtual
|
|
@@ -585,13 +682,36 @@ var PluginContext = class {
|
|
|
585
682
|
* (external-package-file-discovery: silence is never an outcome). An
|
|
586
683
|
* unresolvable `.includes()` specifier warns in non-strict mode and FAILS
|
|
587
684
|
* the build under `strict: true`, naming every offending specifier —
|
|
588
|
-
* a typo'd include must not ship a build missing its component CSS.
|
|
685
|
+
* a typo'd include must not ship a build missing its component CSS. A
|
|
686
|
+
* stale dist entry under an extended package (first-class-extension D13)
|
|
687
|
+
* rides the same seam: a merge against it would silently skew registry
|
|
688
|
+
* content the discovered sources no longer match.
|
|
589
689
|
*/
|
|
590
690
|
enforceIncludeResolution() {
|
|
591
|
-
const message
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
691
|
+
for (const message of [(0, _animus_ui_extract_pipeline.unresolvableIncludesMessage)(this.externalPackageOutcomes), (0, _animus_ui_extract_pipeline.staleDistIncludesMessage)(this.externalPackageOutcomes)]) {
|
|
692
|
+
if (message === null) continue;
|
|
693
|
+
if (this.options.strict) throw new Error(message);
|
|
694
|
+
this.warn(message);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* The post-analysis gate over cross-source token contracts
|
|
699
|
+
* (extraction-diagnostics): a discovered component referencing a token its
|
|
700
|
+
* OWN package defines but the consumer theme does not gets the teaching
|
|
701
|
+
* error naming the token, component, source package, and the missing
|
|
702
|
+
* `createTheme().extend(...)`. Wiring and severity routing live in the
|
|
703
|
+
* shared pipeline gate (next-plugin parity by construction).
|
|
704
|
+
*/
|
|
705
|
+
enforceExternalTokenContracts() {
|
|
706
|
+
(0, _animus_ui_extract_pipeline.enforceExternalTokenContracts)({
|
|
707
|
+
diagnostics: this.storedManifest?.diagnostics,
|
|
708
|
+
fileOwners: this.externalFileOwners,
|
|
709
|
+
dirOwners: this.externalDirOwners,
|
|
710
|
+
sourceThemeManifestsJson: this.system.sourceThemeManifestsJson,
|
|
711
|
+
strict: this.options.strict,
|
|
712
|
+
prefix: "[animus-extract]",
|
|
713
|
+
warn: (message) => this.warn(message)
|
|
714
|
+
});
|
|
595
715
|
}
|
|
596
716
|
runSelfVerify() {
|
|
597
717
|
const failures = [];
|
|
@@ -836,13 +956,18 @@ function buildIndexHtmlTags(ctx) {
|
|
|
836
956
|
*/
|
|
837
957
|
function transformSource(ctx, code, id) {
|
|
838
958
|
if (!ctx.storedManifest) return null;
|
|
839
|
-
|
|
959
|
+
const isExternalPkg = ctx.externalPackageDirs.some((dir) => id.startsWith(dir + path.sep) || id === dir);
|
|
960
|
+
if (!isExternalPkg) {
|
|
840
961
|
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
841
962
|
if (id.includes("node_modules")) return null;
|
|
842
963
|
}
|
|
843
964
|
const relativePath = (0, path.relative)(ctx.rootDir, id);
|
|
844
965
|
if (!ctx.storedManifest.files?.[relativePath]?.length) {
|
|
845
966
|
if (!ctx.isProd && !ctx.fileCache.has(relativePath)) {
|
|
967
|
+
if (isExternalPkg) {
|
|
968
|
+
const owner = Object.entries(ctx.externalDirOwners).find(([dir]) => id === dir || id.startsWith(dir + path.sep));
|
|
969
|
+
if (owner) ctx.externalFileOwners[relativePath] = owner[1];
|
|
970
|
+
}
|
|
846
971
|
const hash = (0, _animus_ui_extract_pipeline.contentHash)(code);
|
|
847
972
|
ctx.fileCache.set(relativePath, {
|
|
848
973
|
hash,
|
|
@@ -992,7 +1117,11 @@ function animusExtract(options) {
|
|
|
992
1117
|
async buildStart() {
|
|
993
1118
|
await runBuildStart(ctx, async (specifier) => {
|
|
994
1119
|
return (await this.resolve(specifier))?.id ?? null;
|
|
995
|
-
})
|
|
1120
|
+
}, ctx.isProd ? (fileName, source) => this.emitFile({
|
|
1121
|
+
type: "asset",
|
|
1122
|
+
name: fileName,
|
|
1123
|
+
source
|
|
1124
|
+
}) : void 0);
|
|
996
1125
|
},
|
|
997
1126
|
resolveId(id) {
|
|
998
1127
|
return resolveVirtualId(ctx, id);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,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;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;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E,CAAC;IAClB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,mBAAmB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAmEnE;eAEc,aAAa"}
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class ResetCoalescer {
|
|
11
11
|
private readonly run;
|
|
12
|
+
private readonly onError;
|
|
12
13
|
private readonly quietMs;
|
|
13
14
|
private readonly schedule;
|
|
14
15
|
private readonly cancel;
|
|
15
16
|
private timer;
|
|
16
17
|
private running;
|
|
17
18
|
private dirty;
|
|
18
|
-
constructor(run: () => void, quietMs?: number, schedule?: (fn: () => void, ms: number) => unknown, cancel?: (timer: unknown) => void);
|
|
19
|
+
constructor(run: () => void, onError: (err: unknown) => void, quietMs?: number, schedule?: (fn: () => void, ms: number) => unknown, cancel?: (timer: unknown) => void);
|
|
19
20
|
/** Ask for a reset; bursts within the quiescence window collapse. */
|
|
20
21
|
request(): void;
|
|
21
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-coalescer.d.ts","sourceRoot":"","sources":["../src/reset-coalescer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAMvB,OAAO,CAAC,QAAQ,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"reset-coalescer.d.ts","sourceRoot":"","sources":["../src/reset-coalescer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAMvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAKpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAIzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAhBzB,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IAEtB,YACmB,GAAG,EAAE,MAAM,IAAI,EAKf,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,EAC/B,OAAO,SAAK,EACZ,QAAQ,GAAE,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,OAGpC,EACN,MAAM,GAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IACS,EACpD;IAEJ,qEAAqE;IACrE,OAAO,IAAI,IAAI,CAqBd;CACF"}
|
package/dist/transform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAuFpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animus",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"compile": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@animus-ui/extract": "0.1.
|
|
42
|
+
"@animus-ui/extract": "0.1.4",
|
|
43
43
|
"browserslist": "^4.24.0",
|
|
44
44
|
"lightningcss": "^1.29.0"
|
|
45
45
|
},
|