@animus-ui/vite-plugin 0.1.26 → 0.1.27
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/context.d.ts +42 -60
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +87 -112
- package/package.json +3 -3
package/dist/context.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExtractionSession } from '@animus-ui/extract/session';
|
|
1
|
+
import { EnvironmentBuilds, ExtractionSession } from '@animus-ui/extract/session';
|
|
2
2
|
import { HotUpdateEvents } from './hot-update-events';
|
|
3
3
|
import type { LightningTargets } from './css';
|
|
4
4
|
import type { AnimusExtractOptions } from './index';
|
|
5
5
|
import type { ExcludeMatcher, ExternalPackageOutcome, HostAssetClassification, HostExtensionPolicy, HostLoadExpander, ProjectManifest, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
6
|
-
import type { SessionOutcome, WatchChanges } from '@animus-ui/extract/session';
|
|
6
|
+
import type { SessionOutcome, SessionPublication, WatchChanges } from '@animus-ui/extract/session';
|
|
7
7
|
import type { Logger } from 'vite';
|
|
8
8
|
/** A Session outcome, and whether its publication changed the served
|
|
9
9
|
* system-props module. */
|
|
@@ -11,11 +11,6 @@ export interface ObservedOutcome {
|
|
|
11
11
|
outcome: SessionOutcome;
|
|
12
12
|
systemPropsChanged: boolean;
|
|
13
13
|
}
|
|
14
|
-
/** One environment's build, as Vite hands it to a hook: the object is its
|
|
15
|
-
* identity, the name its key. */
|
|
16
|
-
export interface BuildingEnvironment {
|
|
17
|
-
readonly name: string;
|
|
18
|
-
}
|
|
19
14
|
export declare class PluginContext {
|
|
20
15
|
readonly options: AnimusExtractOptions;
|
|
21
16
|
readonly verbose: boolean;
|
|
@@ -30,7 +25,6 @@ export declare class PluginContext {
|
|
|
30
25
|
emissionProd: boolean;
|
|
31
26
|
rootDir: string;
|
|
32
27
|
logger: Logger | null;
|
|
33
|
-
system: SystemConfig;
|
|
34
28
|
lcssTargets: LightningTargets;
|
|
35
29
|
pathAliasesJson: string | null;
|
|
36
30
|
/** Vite's export conditions, so the loader reads the files Vite serves. */
|
|
@@ -51,27 +45,35 @@ export declare class PluginContext {
|
|
|
51
45
|
* as structural exclusions; none outside the root. Set in
|
|
52
46
|
* `configResolved`. */
|
|
53
47
|
outputExcludes: string[];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
/** The Session publication this context serves, adopted whole as the
|
|
49
|
+
* Session commits it; null until one commits, and a failed analysis
|
|
50
|
+
* leaves the previous one served. Every view below reads it. */
|
|
51
|
+
served: SessionPublication | null;
|
|
52
|
+
/** What a context serves before a first publication. */
|
|
53
|
+
private readonly unpublishedSystem;
|
|
54
|
+
get storedManifest(): ProjectManifest | null;
|
|
55
|
+
get storedManifestJson(): string;
|
|
56
|
+
get system(): SystemConfig;
|
|
57
|
+
get reverseProvenance(): Record<string, string[]>;
|
|
58
|
+
/** The exact source `virtual:animus/system-props` serves: the served
|
|
59
|
+
* publication's, so the served bytes and the HMR change decision cannot
|
|
60
|
+
* diverge. */
|
|
61
|
+
get systemPropsModule(): string;
|
|
62
|
+
get externalPackageDirs(): string[];
|
|
63
|
+
/** specifier → whether its redirected source entry has side effects, from
|
|
64
|
+
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
65
|
+
get externalSourceSideEffects(): ReadonlyMap<string, boolean>;
|
|
66
|
+
get externalSourceEntries(): ReadonlyMap<string, string>;
|
|
67
|
+
/** The analysis sheets keep their asset() placeholders; these views
|
|
68
|
+
* substitute the current asset URLs, so an edited asset changes its URL
|
|
69
|
+
* without re-analysis. */
|
|
62
70
|
get globalCss(): string;
|
|
63
|
-
set globalCss(css: string);
|
|
64
71
|
get resolvedComponentCss(): string;
|
|
65
|
-
|
|
72
|
+
private analysisSheets;
|
|
66
73
|
private substitutedSheets;
|
|
67
74
|
layerDeclaration: string;
|
|
68
75
|
transformOutputHashes: Map<string, string>;
|
|
69
76
|
recordTransformOutput(relativePath: string, code: string): void;
|
|
70
|
-
reverseProvenance: Record<string, string[]>;
|
|
71
|
-
/** The exact source `virtual:animus/system-props` serves: the last
|
|
72
|
-
* publication's, so the served bytes and the HMR change decision cannot
|
|
73
|
-
* diverge. */
|
|
74
|
-
systemPropsModule: string;
|
|
75
77
|
/** Original path → hash of bytes whose parse aborted in a rejected attempt;
|
|
76
78
|
* non-empty while that rejection holds publication. Those bytes are served
|
|
77
79
|
* raw so the host reports its own syntax error instead of receiving the
|
|
@@ -97,16 +99,12 @@ export declare class PluginContext {
|
|
|
97
99
|
servesFile: (path: string) => boolean;
|
|
98
100
|
assetResolutionFailures: Set<string>;
|
|
99
101
|
assetPassComplete: boolean;
|
|
100
|
-
|
|
101
|
-
/** specifier → whether its redirected source entry has side effects, from
|
|
102
|
-
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
103
|
-
externalSourceSideEffects: Map<string, boolean>;
|
|
104
|
-
externalSourceEntries: ReadonlyMap<string, string>;
|
|
102
|
+
/** The Session's last external package outcomes, for the self-verify. */
|
|
105
103
|
externalPackageOutcomes: ExternalPackageOutcome[];
|
|
106
104
|
devServer: any;
|
|
107
|
-
/** The
|
|
108
|
-
*
|
|
109
|
-
private readonly
|
|
105
|
+
/** The paths already registered, per watcher: a reused plugin instance
|
|
106
|
+
* whose dev server is replaced registers everything with the new one. */
|
|
107
|
+
private readonly watchedPaths;
|
|
110
108
|
/** Every native extraction call goes through this one accessor. */
|
|
111
109
|
readonly engineApi: () => any;
|
|
112
110
|
/** The native module's stateless lookups, before the root resolves: the
|
|
@@ -134,26 +132,13 @@ export declare class PluginContext {
|
|
|
134
132
|
* error itself); any other failure rejects. Either way the watcher
|
|
135
133
|
* learns the paths the attempt's system load named. */
|
|
136
134
|
runAttempt(attempt: (session: ExtractionSession) => Promise<void>): Promise<ObservedOutcome[]>;
|
|
137
|
-
/** Serves the Session's last publication
|
|
138
|
-
*
|
|
139
|
-
* the package map and the external-package state. */
|
|
135
|
+
/** Serves the Session's last publication whole (asset placeholders
|
|
136
|
+
* kept; Vite substitutes them). */
|
|
140
137
|
adoptPublication(session: ExtractionSession): void;
|
|
141
|
-
/** The environment a
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* the context's build retires with the last of them, not the first. */
|
|
146
|
-
private readonly openBuilds;
|
|
147
|
-
/** Opens `environment`'s build, after any open build under its name has
|
|
148
|
-
* ended: a builder reused while an earlier build still runs, or a second
|
|
149
|
-
* environment under one name, builds after it rather than beside it.
|
|
150
|
-
* Each build then ends its own generation once, in `buildEnd`. */
|
|
151
|
-
openBuild(environment: BuildingEnvironment): Promise<void>;
|
|
152
|
-
/** Ends `environment`'s open build; whether that left none open. Vite
|
|
153
|
-
* ends each build once, in `buildEnd`, and a dev server ends only the
|
|
154
|
-
* environments that started, so only the build that opened an entry
|
|
155
|
-
* ends it. */
|
|
156
|
-
endBuild(environment: BuildingEnvironment): boolean;
|
|
138
|
+
/** The context's environment builds: a custom `buildApp` builds a shared
|
|
139
|
+
* plugin's environments in parallel, so the context's build retires with
|
|
140
|
+
* the last of them, not the first. */
|
|
141
|
+
readonly builds: EnvironmentBuilds;
|
|
157
142
|
/** Retires this context's build when Vite closes it: the Session leaves
|
|
158
143
|
* the registry (with its manifest and watch state) and the engine handle
|
|
159
144
|
* is released, injected engine or not. The next build start rejoins. */
|
|
@@ -201,17 +186,14 @@ export declare class PluginContext {
|
|
|
201
186
|
private applyAssetSubstitutions;
|
|
202
187
|
invalidateSystemReloadModules(reloadClient: boolean): void;
|
|
203
188
|
isSystemDependency(absFile: string): boolean;
|
|
204
|
-
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
189
|
+
/** Registers the Session's watch plan with Vite's watcher, each path
|
|
190
|
+
* once per watcher. Vite also watches its packages' own directories beside the
|
|
191
|
+
* plan's canonical roots, and an absent path either covers (or the root
|
|
192
|
+
* does) is left to their watch: a watch on an absent file inside a
|
|
193
|
+
* watched directory stops that directory's events under inotify
|
|
194
|
+
* (chokidar's non-fsevents handler). Vite hard-ignores node_modules, so
|
|
195
|
+
* dependencies installed there produce no events. */
|
|
209
196
|
registerSystemWatchPaths(): void;
|
|
210
|
-
/** The absent paths no watched directory reports a creation for. Vite's
|
|
211
|
-
* root watch and a package root's watch already do, and a watch on an
|
|
212
|
-
* absent file inside a watched directory stops that directory's events
|
|
213
|
-
* under inotify (chokidar's non-fsevents handler). */
|
|
214
|
-
private uncoveredMissingPaths;
|
|
215
197
|
/** Invalidate the component CSS and system-props modules, then reload. The
|
|
216
198
|
* reload alone rescues nothing: Vite keeps serving its cached transform.
|
|
217
199
|
* `devServer.moduleGraph` is the mixed back-compat graph on purpose — it
|
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":"AAeA,OAAO,EAGL,iBAAiB,EAGjB,iBAAiB,EAGlB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAEV,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAEV,cAAc,EACd,kBAAkB,EAClB,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAgBnC;2BAC2B;AAC3B,MA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AAO,GAAG,IAAI,CAMpD;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhC;IAED;6EACyE;IACzE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAqBtD;IAED;;uDAEmD;IACnD,OAAO,CAAC,eAAe;IAevB,2DAA2D;IAC3D,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKtC;IAED;oCACgC;IAChC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAgBxC;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAKvE;IAED,8DAA8D;IAC9D,oBAAoB,IAAI,MAAM,EAAE,CAM/B;IAED;;;gDAG4C;IAC5C,IAAI,WAAW,IAAI,MAAM,CAKxB;IAED;8EAC0E;IAC1E,OAAO,CAAC,uBAAuB;IA2B/B,6BAA6B,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAYzD;IAED,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3C;IAED;;;;;;0DAMsD;IACtD,wBAAwB,IAAI,IAAI,CAsB/B;IAED;;;yEAGqE;IACrE,0BAA0B,IAAI,IAAI,CAcjC;IAED,aAAa,IAAI,IAAI,CA2BpB;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -176,7 +176,7 @@ function applyResolvedConfig(ctx, config) {
|
|
|
176
176
|
const copyDir = (0, path.resolve)(config.cacheDir, "animus-assets", processCopyDir());
|
|
177
177
|
const served = (0, vite.isFileLoadingAllowed)(config, (0, path.join)(copyDir, "asset"));
|
|
178
178
|
ctx.assetCopyDir = served ? copyDir : null;
|
|
179
|
-
ctx.servesFile = (path$
|
|
179
|
+
ctx.servesFile = (path$9) => (0, vite.isFileLoadingAllowed)(config, path$9);
|
|
180
180
|
if (!served) ctx.warn(`[animus-extract] asset() copies in ${copyDir} are not served under server.fs; serving the live files instead, so an edited asset keeps its URL`);
|
|
181
181
|
}
|
|
182
182
|
ctx.outputExcludes = (0, _animus_ui_extract_pipeline.outputExclusions)(config.root, (0, _animus_ui_extract_pipeline.viteOutputTargets)(config));
|
|
@@ -326,7 +326,6 @@ var PluginContext = class {
|
|
|
326
326
|
emissionProd = false;
|
|
327
327
|
rootDir = "";
|
|
328
328
|
logger = null;
|
|
329
|
-
system = emptySystemConfig();
|
|
330
329
|
lcssTargets = {};
|
|
331
330
|
pathAliasesJson = null;
|
|
332
331
|
/** Vite's export conditions, so the loader reads the files Vite serves. */
|
|
@@ -347,43 +346,65 @@ var PluginContext = class {
|
|
|
347
346
|
* as structural exclusions; none outside the root. Set in
|
|
348
347
|
* `configResolved`. */
|
|
349
348
|
outputExcludes = [];
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
349
|
+
/** The Session publication this context serves, adopted whole as the
|
|
350
|
+
* Session commits it; null until one commits, and a failed analysis
|
|
351
|
+
* leaves the previous one served. Every view below reads it. */
|
|
352
|
+
served = null;
|
|
353
|
+
/** What a context serves before a first publication. */
|
|
354
|
+
unpublishedSystem = emptySystemConfig();
|
|
355
|
+
get storedManifest() {
|
|
356
|
+
return this.served?.manifest ?? null;
|
|
357
|
+
}
|
|
358
|
+
get storedManifestJson() {
|
|
359
|
+
return this.served?.manifestJson ?? "";
|
|
360
|
+
}
|
|
361
|
+
get system() {
|
|
362
|
+
return this.served?.system ?? this.unpublishedSystem;
|
|
363
|
+
}
|
|
364
|
+
get reverseProvenance() {
|
|
365
|
+
return this.served?.manifest.reverse_provenance ?? {};
|
|
366
|
+
}
|
|
367
|
+
/** The exact source `virtual:animus/system-props` serves: the served
|
|
368
|
+
* publication's, so the served bytes and the HMR change decision cannot
|
|
369
|
+
* diverge. */
|
|
370
|
+
get systemPropsModule() {
|
|
371
|
+
return this.served?.systemPropsModule ?? EMPTY_SYSTEM_PROPS_MODULE;
|
|
372
|
+
}
|
|
373
|
+
get externalPackageDirs() {
|
|
374
|
+
return this.served?.externalPackageDirs ?? [];
|
|
375
|
+
}
|
|
376
|
+
/** specifier → whether its redirected source entry has side effects, from
|
|
377
|
+
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
378
|
+
get externalSourceSideEffects() {
|
|
379
|
+
return this.served?.externalSourceSideEffects ?? /* @__PURE__ */ new Map();
|
|
380
|
+
}
|
|
381
|
+
get externalSourceEntries() {
|
|
382
|
+
return this.served?.externalSourceEntries ?? /* @__PURE__ */ new Map();
|
|
383
|
+
}
|
|
384
|
+
/** The analysis sheets keep their asset() placeholders; these views
|
|
385
|
+
* substitute the current asset URLs, so an edited asset changes its URL
|
|
386
|
+
* without re-analysis. */
|
|
358
387
|
get globalCss() {
|
|
359
388
|
return this.substitutedSheets().globalCss;
|
|
360
389
|
}
|
|
361
|
-
set globalCss(css) {
|
|
362
|
-
this.analysisGlobalCss = css;
|
|
363
|
-
}
|
|
364
390
|
get resolvedComponentCss() {
|
|
365
391
|
return this.substitutedSheets().componentCss;
|
|
366
392
|
}
|
|
367
|
-
|
|
368
|
-
|
|
393
|
+
analysisSheets() {
|
|
394
|
+
return {
|
|
395
|
+
...NO_SHEETS,
|
|
396
|
+
globalCss: this.served?.analysisGlobalCss ?? "",
|
|
397
|
+
componentCss: this.served?.analysisComponentCss ?? ""
|
|
398
|
+
};
|
|
369
399
|
}
|
|
370
400
|
substitutedSheets() {
|
|
371
|
-
return (0, _animus_ui_extract_pipeline.substituteSheetAssets)(
|
|
372
|
-
...NO_SHEETS,
|
|
373
|
-
globalCss: this.analysisGlobalCss,
|
|
374
|
-
componentCss: this.analysisComponentCss
|
|
375
|
-
}, this.assetUrlBySpecifier);
|
|
401
|
+
return (0, _animus_ui_extract_pipeline.substituteSheetAssets)(this.analysisSheets(), this.assetUrlBySpecifier);
|
|
376
402
|
}
|
|
377
403
|
layerDeclaration = "";
|
|
378
404
|
transformOutputHashes = /* @__PURE__ */ new Map();
|
|
379
405
|
recordTransformOutput(relativePath, code) {
|
|
380
406
|
this.transformOutputHashes.set(relativePath, (0, _animus_ui_extract_pipeline.contentHash)(code));
|
|
381
407
|
}
|
|
382
|
-
reverseProvenance = {};
|
|
383
|
-
/** The exact source `virtual:animus/system-props` serves: the last
|
|
384
|
-
* publication's, so the served bytes and the HMR change decision cannot
|
|
385
|
-
* diverge. */
|
|
386
|
-
systemPropsModule = EMPTY_SYSTEM_PROPS_MODULE;
|
|
387
408
|
/** Original path → hash of bytes whose parse aborted in a rejected attempt;
|
|
388
409
|
* non-empty while that rejection holds publication. Those bytes are served
|
|
389
410
|
* raw so the host reports its own syntax error instead of receiving the
|
|
@@ -411,16 +432,12 @@ var PluginContext = class {
|
|
|
411
432
|
servesFile = () => true;
|
|
412
433
|
assetResolutionFailures = /* @__PURE__ */ new Set();
|
|
413
434
|
assetPassComplete = false;
|
|
414
|
-
|
|
415
|
-
/** specifier → whether its redirected source entry has side effects, from
|
|
416
|
-
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
417
|
-
externalSourceSideEffects = /* @__PURE__ */ new Map();
|
|
418
|
-
externalSourceEntries = /* @__PURE__ */ new Map();
|
|
435
|
+
/** The Session's last external package outcomes, for the self-verify. */
|
|
419
436
|
externalPackageOutcomes = [];
|
|
420
437
|
devServer;
|
|
421
|
-
/** The
|
|
422
|
-
*
|
|
423
|
-
|
|
438
|
+
/** The paths already registered, per watcher: a reused plugin instance
|
|
439
|
+
* whose dev server is replaced registers everything with the new one. */
|
|
440
|
+
watchedPaths = /* @__PURE__ */ new WeakMap();
|
|
424
441
|
/** Every native extraction call goes through this one accessor. */
|
|
425
442
|
engineApi;
|
|
426
443
|
/** The native module's stateless lookups, before the root resolves: the
|
|
@@ -480,6 +497,7 @@ var PluginContext = class {
|
|
|
480
497
|
staticCss: options.staticCss,
|
|
481
498
|
layers: options.layers,
|
|
482
499
|
engine: options.engine,
|
|
500
|
+
runtimeImport: options.runtimeImport,
|
|
483
501
|
mode: this.emissionProd ? "production" : "development"
|
|
484
502
|
}, {
|
|
485
503
|
build: this.build,
|
|
@@ -502,9 +520,10 @@ var PluginContext = class {
|
|
|
502
520
|
session.assetClassification = this.assetClassification;
|
|
503
521
|
session.loadExpander = this.loadExpander;
|
|
504
522
|
session.pathAliasesJson = this.pathAliasesJson;
|
|
505
|
-
session.
|
|
506
|
-
|
|
507
|
-
|
|
523
|
+
session.delivery = {
|
|
524
|
+
cssModuleId: VIRTUAL_CSS_ID,
|
|
525
|
+
systemPropsModuleId: VIRTUAL_SYSTEM_PROPS_ID
|
|
526
|
+
};
|
|
508
527
|
session.structuralExclude = this.outputExcludes;
|
|
509
528
|
this.session = session;
|
|
510
529
|
return session;
|
|
@@ -549,63 +568,18 @@ var PluginContext = class {
|
|
|
549
568
|
}
|
|
550
569
|
return collected;
|
|
551
570
|
}
|
|
552
|
-
/** Serves the Session's last publication
|
|
553
|
-
*
|
|
554
|
-
* the package map and the external-package state. */
|
|
571
|
+
/** Serves the Session's last publication whole (asset placeholders
|
|
572
|
+
* kept; Vite substitutes them). */
|
|
555
573
|
adoptPublication(session) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const manifest = publication.manifest;
|
|
559
|
-
this.system = publication.system;
|
|
560
|
-
this.storedManifest = manifest;
|
|
561
|
-
this.storedManifestJson = publication.manifestJson;
|
|
562
|
-
this.globalCss = publication.analysisGlobalCss;
|
|
563
|
-
this.resolvedComponentCss = publication.analysisComponentCss;
|
|
564
|
-
this.reverseProvenance = manifest.reverse_provenance;
|
|
565
|
-
this.systemPropsModule = publication.systemPropsModule;
|
|
566
|
-
this.externalPackageDirs = session.externalPackageDirs;
|
|
567
|
-
this.externalSourceEntries = session.externalSourceEntries;
|
|
568
|
-
this.externalSourceSideEffects = session.externalSourceSideEffects;
|
|
574
|
+
if (session.publication === null) return;
|
|
575
|
+
this.served = session.publication;
|
|
569
576
|
this.externalPackageOutcomes = session.lastExternalOutcomes;
|
|
570
577
|
this.applyAssetSubstitutions();
|
|
571
578
|
}
|
|
572
|
-
/** The environment a
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
* the context's build retires with the last of them, not the first. */
|
|
577
|
-
openBuilds = /* @__PURE__ */ new Map();
|
|
578
|
-
/** Opens `environment`'s build, after any open build under its name has
|
|
579
|
-
* ended: a builder reused while an earlier build still runs, or a second
|
|
580
|
-
* environment under one name, builds after it rather than beside it.
|
|
581
|
-
* Each build then ends its own generation once, in `buildEnd`. */
|
|
582
|
-
async openBuild(environment) {
|
|
583
|
-
for (;;) {
|
|
584
|
-
const open = this.openBuilds.get(environment.name);
|
|
585
|
-
if (open === void 0) break;
|
|
586
|
-
await open.ended;
|
|
587
|
-
}
|
|
588
|
-
let end = () => {};
|
|
589
|
-
const ended = new Promise((settle) => {
|
|
590
|
-
end = settle;
|
|
591
|
-
});
|
|
592
|
-
this.openBuilds.set(environment.name, {
|
|
593
|
-
environment,
|
|
594
|
-
ended,
|
|
595
|
-
end
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
/** Ends `environment`'s open build; whether that left none open. Vite
|
|
599
|
-
* ends each build once, in `buildEnd`, and a dev server ends only the
|
|
600
|
-
* environments that started, so only the build that opened an entry
|
|
601
|
-
* ends it. */
|
|
602
|
-
endBuild(environment) {
|
|
603
|
-
const open = this.openBuilds.get(environment.name);
|
|
604
|
-
if (open === void 0 || open.environment !== environment) return false;
|
|
605
|
-
this.openBuilds.delete(environment.name);
|
|
606
|
-
open.end();
|
|
607
|
-
return this.openBuilds.size === 0;
|
|
608
|
-
}
|
|
579
|
+
/** The context's environment builds: a custom `buildApp` builds a shared
|
|
580
|
+
* plugin's environments in parallel, so the context's build retires with
|
|
581
|
+
* the last of them, not the first. */
|
|
582
|
+
builds = new _animus_ui_extract_session.EnvironmentBuilds();
|
|
609
583
|
/** Retires this context's build when Vite closes it: the Session leaves
|
|
610
584
|
* the registry (with its manifest and watch state) and the engine handle
|
|
611
585
|
* is released, injected engine or not. The next build start rejoins. */
|
|
@@ -711,8 +685,8 @@ var PluginContext = class {
|
|
|
711
685
|
sheetAssetSpecifiers() {
|
|
712
686
|
return (0, _animus_ui_extract_pipeline.findSheetAssetSpecifiers)({
|
|
713
687
|
variableCss: this.system.variableCss,
|
|
714
|
-
globalCss: this.
|
|
715
|
-
componentCss: this.
|
|
688
|
+
globalCss: this.analysisSheets().globalCss,
|
|
689
|
+
componentCss: this.analysisSheets().componentCss
|
|
716
690
|
});
|
|
717
691
|
}
|
|
718
692
|
/** `system.variableCss` with its asset() placeholders substituted from
|
|
@@ -752,34 +726,35 @@ var PluginContext = class {
|
|
|
752
726
|
isSystemDependency(absFile) {
|
|
753
727
|
return this.session?.isSystemDependency(absFile) ?? false;
|
|
754
728
|
}
|
|
755
|
-
/**
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
729
|
+
/** Registers the Session's watch plan with Vite's watcher, each path
|
|
730
|
+
* once per watcher. Vite also watches its packages' own directories beside the
|
|
731
|
+
* plan's canonical roots, and an absent path either covers (or the root
|
|
732
|
+
* does) is left to their watch: a watch on an absent file inside a
|
|
733
|
+
* watched directory stops that directory's events under inotify
|
|
734
|
+
* (chokidar's non-fsevents handler). Vite hard-ignores node_modules, so
|
|
735
|
+
* dependencies installed there produce no events. */
|
|
760
736
|
registerSystemWatchPaths() {
|
|
761
737
|
const watcher = this.devServer?.watcher;
|
|
762
738
|
const session = this.session;
|
|
763
739
|
if (!watcher || !session) return;
|
|
740
|
+
const directories = [.../* @__PURE__ */ new Set([...session.watchPlan().directories, ...session.externalPackageDirs])];
|
|
741
|
+
const covered = this.rootDir ? [this.rootDir, ...directories] : directories;
|
|
742
|
+
const plan = session.watchPlan(covered);
|
|
743
|
+
let registered = this.watchedPaths.get(watcher);
|
|
744
|
+
if (registered === void 0) {
|
|
745
|
+
registered = /* @__PURE__ */ new Set();
|
|
746
|
+
this.watchedPaths.set(watcher, registered);
|
|
747
|
+
}
|
|
764
748
|
for (const paths of [
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
749
|
+
plan.files,
|
|
750
|
+
plan.missing,
|
|
751
|
+
directories
|
|
768
752
|
]) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
const added = paths === session.systemMissingPaths ? this.uncoveredMissingPaths(paths, session.externalPackageDirs) : paths;
|
|
753
|
+
const added = paths.filter((path$7) => !registered.has(path$7));
|
|
754
|
+
for (const path$8 of added) registered.add(path$8);
|
|
772
755
|
if (added.length > 0) watcher.add(added);
|
|
773
756
|
}
|
|
774
757
|
}
|
|
775
|
-
/** The absent paths no watched directory reports a creation for. Vite's
|
|
776
|
-
* root watch and a package root's watch already do, and a watch on an
|
|
777
|
-
* absent file inside a watched directory stops that directory's events
|
|
778
|
-
* under inotify (chokidar's non-fsevents handler). */
|
|
779
|
-
uncoveredMissingPaths(paths, packageDirs) {
|
|
780
|
-
const watchedDirs = this.rootDir ? [this.rootDir, ...packageDirs] : packageDirs;
|
|
781
|
-
return paths.filter((path$7) => !watchedDirs.some((dir) => (0, _animus_ui_extract_pipeline.isPathWithinRoot)(dir, path$7)));
|
|
782
|
-
}
|
|
783
758
|
/** Invalidate the component CSS and system-props modules, then reload. The
|
|
784
759
|
* reload alone rescues nothing: Vite keeps serving its cached transform.
|
|
785
760
|
* `devServer.moduleGraph` is the mixed back-compat graph on purpose — it
|
|
@@ -1474,12 +1449,12 @@ function animusExtract(options) {
|
|
|
1474
1449
|
applyResolvedConfig(ctx, config);
|
|
1475
1450
|
},
|
|
1476
1451
|
buildEnd() {
|
|
1477
|
-
if (!ctx.
|
|
1452
|
+
if (!ctx.builds.end(this.environment ?? ctx.builds.single)) return;
|
|
1478
1453
|
cancelSystemReload(ctx);
|
|
1479
1454
|
ctx.close();
|
|
1480
1455
|
},
|
|
1481
1456
|
async buildStart() {
|
|
1482
|
-
await ctx.
|
|
1457
|
+
await ctx.builds.open(this.environment ?? ctx.builds.single);
|
|
1483
1458
|
await runBuildStart(ctx, async (specifier, importer) => {
|
|
1484
1459
|
return (await this.resolve(specifier, importer))?.id ?? null;
|
|
1485
1460
|
}, ctx.isProd ? (fileName, source) => this.emitFile({
|
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.27",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animus",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"compile": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@animus-ui/extract": "0.1.
|
|
42
|
+
"@animus-ui/extract": "0.1.27",
|
|
43
43
|
"browserslist": "^4.28.8",
|
|
44
44
|
"lightningcss": "^1.33.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@animus-ui/assertions": "0.1.
|
|
47
|
+
"@animus-ui/assertions": "0.1.27"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@mdx-js/mdx": "^3.0.0",
|