@animus-ui/vite-plugin 0.1.19 → 0.1.21
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/build-start.d.ts.map +1 -1
- package/dist/context.d.ts +19 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +105 -24
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/rediscovery.d.ts.map +1 -1
- package/dist/virtual-modules.d.ts +4 -1
- package/dist/virtual-modules.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -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":"AAoBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C;;;GAGG;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,CAoOf"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HotUpdateEvents } from './hot-update-events';
|
|
2
2
|
import type { LightningTargets } from './css';
|
|
3
3
|
import type { AnimusExtractOptions } from './index';
|
|
4
|
-
import type { ExcludeMatcher, ExternalPackageOutcome, ManifestSheets, ProjectManifest, RawSourceEntry, SourceCorpus, SourceIngestionResult, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
4
|
+
import type { ExcludeMatcher, ExternalPackageOutcome, ManifestDiagnostic, ManifestSheets, ProjectManifest, RawSourceEntry, SourceCorpus, SourceIngestionResult, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
5
5
|
import type { Logger } from 'vite';
|
|
6
6
|
/** Runs `task` after every analysis transaction already scheduled for this
|
|
7
7
|
* context. Entry points only — a nested call waits on its own chain. */
|
|
@@ -86,9 +86,16 @@ export declare class PluginContext {
|
|
|
86
86
|
assetPassComplete: boolean;
|
|
87
87
|
externalPackageDirs: string[];
|
|
88
88
|
externalDirOwners: Record<string, string>;
|
|
89
|
+
/** specifier → whether its redirected source entry has side effects, from
|
|
90
|
+
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
91
|
+
externalSourceSideEffects: Map<string, boolean>;
|
|
89
92
|
externalFileOwners: Record<string, string>;
|
|
90
93
|
externalSourceEntries: Map<string, string>;
|
|
91
94
|
externalPackageOutcomes: ExternalPackageOutcome[];
|
|
95
|
+
/** Configured files buildStart or a late rediscovery could not read.
|
|
96
|
+
* Later analyses read no files themselves, so they replay these until the
|
|
97
|
+
* file is read into the cache or deleted. */
|
|
98
|
+
ingestionFailureDiagnostics: ManifestDiagnostic[];
|
|
92
99
|
devServer: any;
|
|
93
100
|
resolvedSystemPath: string | null;
|
|
94
101
|
systemDependencyKeys: Set<string>;
|
|
@@ -110,13 +117,19 @@ export declare class PluginContext {
|
|
|
110
117
|
/** Load the system into `this.system`. On failure the previous config is
|
|
111
118
|
* kept; strict mode throws instead. */
|
|
112
119
|
loadSystem(): void;
|
|
120
|
+
/** The read failures still standing: a file stops counting once the cache
|
|
121
|
+
* holds a read of it or it is gone, as in the shared session, so it stops
|
|
122
|
+
* warning and stops holding pruning off. */
|
|
123
|
+
private unsettledIngestionFailures;
|
|
113
124
|
/** Runs project analysis and updates every manifest-derived state. Returns
|
|
114
|
-
* false when nothing published, and the caller must roll its cache back.
|
|
125
|
+
* false when nothing published, and the caller must roll its cache back.
|
|
126
|
+
* While a source is skipped or unreadable, its renders are unseen, so
|
|
127
|
+
* nothing is pruned. */
|
|
115
128
|
runAnalysis(fileEntries: Array<{
|
|
116
129
|
path: string;
|
|
117
130
|
source: string;
|
|
118
131
|
hash?: string;
|
|
119
|
-
}
|
|
132
|
+
}>, skippedOriginals?: readonly string[]): boolean;
|
|
120
133
|
private assertRuntimeImportSuppliesTerminals;
|
|
121
134
|
/** The one ingest → quarantine → analyze → publish transaction. The corpus
|
|
122
135
|
* publishes only on success. `afterIngestion` runs after quarantine even
|
|
@@ -155,8 +168,9 @@ export declare class PluginContext {
|
|
|
155
168
|
* `system`, however and whenever that was assigned; `system` keeps the
|
|
156
169
|
* placeholders for the next asset pass. */
|
|
157
170
|
get variableCss(): string;
|
|
158
|
-
/** Substitutes the analysis sheets in place
|
|
159
|
-
* substituted on read
|
|
171
|
+
/** Substitutes the analysis sheets in place, through the same step as the
|
|
172
|
+
* session; the theme's variable CSS is substituted on read
|
|
173
|
+
* (`variableCss`). */
|
|
160
174
|
substituteSheets(): void;
|
|
161
175
|
/** Resolves asset specifiers a system reload introduced. Node-side only —
|
|
162
176
|
* the plugin hook context is unavailable here, so results can differ. */
|
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":"AAuCA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,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,kBAAkB,EAClB,cAAc,EAEd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,YAAY,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAoBnC;yEACyE;AACzE,wBAAgB,oB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AI,CA0BpB;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -33,18 +33,25 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
|
|
|
33
33
|
ctx.extensionsSet = new Set(ctx.options.extensions ?? _animus_ui_extract_pipeline.DEFAULT_EXTENSIONS);
|
|
34
34
|
const filePaths = (0, _animus_ui_extract_pipeline.discoverFiles)(ctx.rootDir, ctx.rootDir, excludePatterns, ctx.extensionsSet);
|
|
35
35
|
const rawEntries = [];
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const ingestionFailures = [];
|
|
37
|
+
for (const filePath of filePaths) {
|
|
38
38
|
const relPath = (0, path.relative)(ctx.rootDir, filePath);
|
|
39
|
+
let source;
|
|
40
|
+
try {
|
|
41
|
+
source = (0, fs.readFileSync)(filePath, "utf-8");
|
|
42
|
+
} catch (err) {
|
|
43
|
+
if (!(0, _animus_ui_extract_pipeline.isDeletedSource)(err)) ingestionFailures.push((0, _animus_ui_extract_pipeline.unreadableSourceDiagnostic)(relPath, err));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
39
46
|
const hash = !ctx.isProd ? (0, _animus_ui_extract_pipeline.contentHash)(source) : void 0;
|
|
40
47
|
rawEntries.push({
|
|
41
48
|
path: relPath,
|
|
42
49
|
source,
|
|
43
50
|
hash
|
|
44
51
|
});
|
|
45
|
-
}
|
|
52
|
+
}
|
|
46
53
|
const localFileCount = rawEntries.length;
|
|
47
|
-
const packageSpecifiers = (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(ctx.resolvedSystemPath);
|
|
54
|
+
const packageSpecifiers = (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(ctx.resolvedSystemPath, (0, _animus_ui_extract_pipeline.engineImportParser)(ctx.engineApi()));
|
|
48
55
|
ctx.externalSourceEntries.clear();
|
|
49
56
|
const collected = await (0, _animus_ui_extract_pipeline.collectExternalPackageSources)({
|
|
50
57
|
specifiers: packageSpecifiers,
|
|
@@ -52,14 +59,19 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
|
|
|
52
59
|
rootDir: ctx.rootDir,
|
|
53
60
|
extensionsSet: ctx.extensionsSet,
|
|
54
61
|
hasEntry: (relPath) => rawEntries.some((entry) => entry.path === relPath),
|
|
55
|
-
onUnreadable: (relPath, err) =>
|
|
62
|
+
onUnreadable: (relPath, err) => {
|
|
63
|
+
if (!(0, _animus_ui_extract_pipeline.isDeletedSource)(err)) ingestionFailures.push((0, _animus_ui_extract_pipeline.unreadableSourceDiagnostic)(relPath, err));
|
|
64
|
+
}
|
|
56
65
|
});
|
|
66
|
+
ctx.ingestionFailureDiagnostics = ingestionFailures;
|
|
67
|
+
(0, _animus_ui_extract_pipeline.surfaceManifestDiagnostics)({ diagnostics: (0, _animus_ui_extract_pipeline.noKitFilesDiagnostics)(collected.outcomes) }, (message) => ctx.warn(message));
|
|
57
68
|
ctx.packageMap = collected.packageMap;
|
|
58
69
|
ctx.externalPackageOutcomes = collected.outcomes;
|
|
59
70
|
ctx.externalDirOwners = (0, _animus_ui_extract_pipeline.firstOwners)(collected.dirOwnerSets);
|
|
60
71
|
ctx.externalFileOwners = collected.fileOwners;
|
|
61
72
|
ctx.enforceIncludeResolution();
|
|
62
73
|
for (const [specifier, srcEntry] of collected.sourceEntries) ctx.externalSourceEntries.set(specifier, srcEntry);
|
|
74
|
+
ctx.externalSourceSideEffects = collected.sourceEntrySideEffects;
|
|
63
75
|
for (const entry of collected.entries) {
|
|
64
76
|
const hash = !ctx.isProd ? (0, _animus_ui_extract_pipeline.contentHash)(entry.source) : void 0;
|
|
65
77
|
rawEntries.push({
|
|
@@ -107,7 +119,7 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
|
|
|
107
119
|
ctx.log(`Extracted ${report.components_extracted}/${report.components_total} components (${Math.round(performance.now() - t0)}ms)`);
|
|
108
120
|
ctx.log(`Reconciliation: ${report.components_extracted} kept, ${report.variants_eliminated} variants pruned, ${report.states_eliminated} states pruned`);
|
|
109
121
|
for (const d of report.eliminated_details) if (d.kind === "component") ctx.warn(`⚠ ${d.component} eliminated: ${d.reason}`);
|
|
110
|
-
else if (d.kind === "prospective_component") ctx.warn(`⚠ ${d.component} would be eliminated in production: ${d.reason}`);
|
|
122
|
+
else if (d.kind === "prospective_component" && !ctx.emissionProd) ctx.warn(`⚠ ${d.component} would be eliminated in production: ${d.reason}`);
|
|
111
123
|
else if (d.kind === "variant") ctx.trace(`${d.component} variant '${d.name}' pruned: ${d.reason}`);
|
|
112
124
|
else if (d.kind === "state") ctx.trace(`${d.component} state '${d.name}' pruned: ${d.reason}`);
|
|
113
125
|
ctx.log(`CSS: ${ctx.resolvedComponentCss.length} bytes (${Object.keys(ctx.storedManifest.components).length} components)`);
|
|
@@ -372,6 +384,11 @@ function pruneFileCache(cache, rootDir, absPath) {
|
|
|
372
384
|
const rel = (0, path.relative)(rootDir, (0, path.resolve)(absPath));
|
|
373
385
|
return cache.delete(rel);
|
|
374
386
|
}
|
|
387
|
+
const NO_SHEETS = {
|
|
388
|
+
variableCss: "",
|
|
389
|
+
globalCss: "",
|
|
390
|
+
componentCss: ""
|
|
391
|
+
};
|
|
375
392
|
var PluginContext = class {
|
|
376
393
|
options;
|
|
377
394
|
verbose;
|
|
@@ -453,9 +470,16 @@ var PluginContext = class {
|
|
|
453
470
|
assetPassComplete = false;
|
|
454
471
|
externalPackageDirs = [];
|
|
455
472
|
externalDirOwners = {};
|
|
473
|
+
/** specifier → whether its redirected source entry has side effects, from
|
|
474
|
+
* the owning package's `sideEffects`; absent leaves Vite's default. */
|
|
475
|
+
externalSourceSideEffects = /* @__PURE__ */ new Map();
|
|
456
476
|
externalFileOwners = {};
|
|
457
477
|
externalSourceEntries = /* @__PURE__ */ new Map();
|
|
458
478
|
externalPackageOutcomes = [];
|
|
479
|
+
/** Configured files buildStart or a late rediscovery could not read.
|
|
480
|
+
* Later analyses read no files themselves, so they replay these until the
|
|
481
|
+
* file is read into the cache or deleted. */
|
|
482
|
+
ingestionFailureDiagnostics = [];
|
|
459
483
|
devServer;
|
|
460
484
|
resolvedSystemPath = null;
|
|
461
485
|
systemDependencyKeys = /* @__PURE__ */ new Set();
|
|
@@ -530,9 +554,16 @@ var PluginContext = class {
|
|
|
530
554
|
this.system = (0, _animus_ui_extract_pipeline.loadSystemConfig)(this.engineApi, {
|
|
531
555
|
systemPath: this.resolvedSystemPath,
|
|
532
556
|
rootDir: this.rootDir,
|
|
533
|
-
prefix: this.options.prefix
|
|
557
|
+
prefix: this.options.prefix,
|
|
558
|
+
prefixContextualVars: this.options.prefixContextualVars
|
|
534
559
|
});
|
|
535
|
-
const
|
|
560
|
+
const appManifest = (0, path.join)((0, _animus_ui_extract_pipeline.findPackageRoot)(this.resolvedSystemPath), "package.json");
|
|
561
|
+
const manifests = /* @__PURE__ */ new Set();
|
|
562
|
+
for (const dep of this.system.dependencies ?? []) {
|
|
563
|
+
const manifest = (0, path.join)((0, _animus_ui_extract_pipeline.findPackageRoot)(dep), "package.json");
|
|
564
|
+
if (manifest !== appManifest && (0, fs.existsSync)(manifest)) manifests.add(manifest);
|
|
565
|
+
}
|
|
566
|
+
const deps = [...this.system.dependencies ?? [], ...manifests];
|
|
536
567
|
const keys = /* @__PURE__ */ new Set();
|
|
537
568
|
for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(this.resolvedSystemPath)) keys.add(key);
|
|
538
569
|
for (const dep of deps) for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(dep)) keys.add(key);
|
|
@@ -544,9 +575,26 @@ var PluginContext = class {
|
|
|
544
575
|
console.warn(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}:`, e);
|
|
545
576
|
}
|
|
546
577
|
}
|
|
578
|
+
/** The read failures still standing: a file stops counting once the cache
|
|
579
|
+
* holds a read of it or it is gone, as in the shared session, so it stops
|
|
580
|
+
* warning and stops holding pruning off. */
|
|
581
|
+
unsettledIngestionFailures() {
|
|
582
|
+
return this.ingestionFailureDiagnostics.filter(({ file }) => {
|
|
583
|
+
if (this.fileCache.has(file)) return false;
|
|
584
|
+
try {
|
|
585
|
+
(0, fs.statSync)((0, path.resolve)(this.rootDir, file));
|
|
586
|
+
return true;
|
|
587
|
+
} catch (err) {
|
|
588
|
+
return !(0, _animus_ui_extract_pipeline.isDeletedSource)(err);
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
547
592
|
/** Runs project analysis and updates every manifest-derived state. Returns
|
|
548
|
-
* false when nothing published, and the caller must roll its cache back.
|
|
549
|
-
|
|
593
|
+
* false when nothing published, and the caller must roll its cache back.
|
|
594
|
+
* While a source is skipped or unreadable, its renders are unseen, so
|
|
595
|
+
* nothing is pruned. */
|
|
596
|
+
runAnalysis(fileEntries, skippedOriginals = []) {
|
|
597
|
+
const ingestionFailures = this.unsettledIngestionFailures();
|
|
550
598
|
let result;
|
|
551
599
|
try {
|
|
552
600
|
result = (0, _animus_ui_extract_pipeline.runProjectAnalysis)(this.engineApi, {
|
|
@@ -561,9 +609,15 @@ var PluginContext = class {
|
|
|
561
609
|
staticCssJson: this.staticCssJson,
|
|
562
610
|
externalDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir)),
|
|
563
611
|
devMode: !this.emissionProd,
|
|
612
|
+
analysisContext: {
|
|
613
|
+
skippedSources: [...skippedOriginals, ...ingestionFailures.map((d) => d.file)].map((file) => (0, path.isAbsolute)(file) ? (0, path.relative)(this.rootDir, file) : file),
|
|
614
|
+
unbundledComputedImports: true,
|
|
615
|
+
packageDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir))
|
|
616
|
+
},
|
|
564
617
|
warn: (m) => this.warn(m),
|
|
565
618
|
info: (m) => this.log(m),
|
|
566
|
-
strict: this.options.strict
|
|
619
|
+
strict: this.options.strict,
|
|
620
|
+
extraDiagnostics: ingestionFailures
|
|
567
621
|
});
|
|
568
622
|
} catch (e) {
|
|
569
623
|
if (this.options.strict) throw new Error(`[animus-extract] analyzeProject failed: ${e}`, { cause: e });
|
|
@@ -572,8 +626,15 @@ var PluginContext = class {
|
|
|
572
626
|
}
|
|
573
627
|
(0, _animus_ui_extract_pipeline.assertNoErrorDiagnostics)(result.manifest.diagnostics);
|
|
574
628
|
this.assertRuntimeImportSuppliesTerminals(result.manifest);
|
|
629
|
+
(0, _animus_ui_extract_pipeline.reportSurvivingAssetPlaceholders)((0, _animus_ui_extract_pipeline.generatedModuleCode)(result.manifest), {
|
|
630
|
+
strict: this.options.strict,
|
|
631
|
+
warn: (message) => this.warn(message),
|
|
632
|
+
prefix: "[animus-extract]",
|
|
633
|
+
surface: "generated runtime modules"
|
|
634
|
+
});
|
|
575
635
|
this.storedManifest = result.manifest;
|
|
576
636
|
this.storedManifestJson = result.manifestJson;
|
|
637
|
+
this.ingestionFailureDiagnostics = ingestionFailures;
|
|
577
638
|
this.storedSystemPropMapJson = JSON.stringify(result.manifest.system_prop_map);
|
|
578
639
|
this.storedDynamicPropsJson = JSON.stringify(result.manifest.dynamic_props);
|
|
579
640
|
this.storedAdmittedTransformsJson = JSON.stringify(result.manifest.admitted_transforms);
|
|
@@ -638,7 +699,7 @@ var PluginContext = class {
|
|
|
638
699
|
}
|
|
639
700
|
if (reloadingSystem) (0, _animus_ui_extract_pipeline.clearEngineCache)(this.engineApi);
|
|
640
701
|
options?.beforeAnalysis?.(accepted);
|
|
641
|
-
const ok = this.runAnalysis(accepted.analysisEntries) !== false;
|
|
702
|
+
const ok = this.runAnalysis(accepted.analysisEntries, accepted.skippedOriginals) !== false;
|
|
642
703
|
if (!ok) return {
|
|
643
704
|
ok,
|
|
644
705
|
accepted,
|
|
@@ -699,13 +760,22 @@ var PluginContext = class {
|
|
|
699
760
|
* `system`, however and whenever that was assigned; `system` keeps the
|
|
700
761
|
* placeholders for the next asset pass. */
|
|
701
762
|
get variableCss() {
|
|
702
|
-
return (0, _animus_ui_extract_pipeline.
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
763
|
+
return (0, _animus_ui_extract_pipeline.substituteSheetAssets)({
|
|
764
|
+
...NO_SHEETS,
|
|
765
|
+
variableCss: this.system.variableCss
|
|
766
|
+
}, this.assetUrlBySpecifier).variableCss;
|
|
767
|
+
}
|
|
768
|
+
/** Substitutes the analysis sheets in place, through the same step as the
|
|
769
|
+
* session; the theme's variable CSS is substituted on read
|
|
770
|
+
* (`variableCss`). */
|
|
706
771
|
substituteSheets() {
|
|
707
|
-
|
|
708
|
-
|
|
772
|
+
const substituted = (0, _animus_ui_extract_pipeline.substituteSheetAssets)({
|
|
773
|
+
...NO_SHEETS,
|
|
774
|
+
globalCss: this.globalCss,
|
|
775
|
+
componentCss: this.resolvedComponentCss
|
|
776
|
+
}, this.assetUrlBySpecifier);
|
|
777
|
+
this.globalCss = substituted.globalCss;
|
|
778
|
+
this.resolvedComponentCss = substituted.componentCss;
|
|
709
779
|
}
|
|
710
780
|
/** Resolves asset specifiers a system reload introduced. Node-side only —
|
|
711
781
|
* the plugin hook context is unavailable here, so results can differ. */
|
|
@@ -821,7 +891,8 @@ var PluginContext = class {
|
|
|
821
891
|
globalCss: this.globalCss,
|
|
822
892
|
componentCss: this.resolvedComponentCss,
|
|
823
893
|
layers: this.options.layers,
|
|
824
|
-
externalOutcomes: this.externalPackageOutcomes
|
|
894
|
+
externalOutcomes: this.externalPackageOutcomes,
|
|
895
|
+
variableMapJson: this.system.variableMapJson
|
|
825
896
|
});
|
|
826
897
|
for (const message of failures) {
|
|
827
898
|
const line = `[animus:verify] ${message}`;
|
|
@@ -880,8 +951,10 @@ async function reconcileSourceCorpus(ctx) {
|
|
|
880
951
|
const dropKey = drops.map((d) => `${d.file}\0${d.component}\0${d.parent}`).sort().join("\n");
|
|
881
952
|
const memo = barrenWalkMemos.get(ctx);
|
|
882
953
|
if (memo && memo.dropKey === dropKey && memo.cacheGeneration === ctx.fileCacheGeneration) return reanalyzed;
|
|
954
|
+
const recordedFailures = ctx.ingestionFailureDiagnostics.length;
|
|
883
955
|
const folded = foldUndiscoveredFiles(ctx);
|
|
884
|
-
|
|
956
|
+
const newlyUnreadable = ctx.ingestionFailureDiagnostics.length > recordedFailures;
|
|
957
|
+
if (folded.length === 0 && !newlyUnreadable) {
|
|
885
958
|
barrenWalkMemos.set(ctx, {
|
|
886
959
|
dropKey,
|
|
887
960
|
cacheGeneration: ctx.fileCacheGeneration
|
|
@@ -890,7 +963,7 @@ async function reconcileSourceCorpus(ctx) {
|
|
|
890
963
|
return reanalyzed;
|
|
891
964
|
}
|
|
892
965
|
barrenWalkMemos.delete(ctx);
|
|
893
|
-
ctx.log(`rediscovery: folded ${folded.length} on-disk file(s) after unresolved-parent drop`);
|
|
966
|
+
if (folded.length > 0) ctx.log(`rediscovery: folded ${folded.length} on-disk file(s) after unresolved-parent drop`);
|
|
894
967
|
reanalyzed = true;
|
|
895
968
|
let published = false;
|
|
896
969
|
let held = false;
|
|
@@ -909,7 +982,8 @@ async function reconcileSourceCorpus(ctx) {
|
|
|
909
982
|
return reanalyzed;
|
|
910
983
|
}
|
|
911
984
|
/** Returns the cache keys this fold added: a failed analysis must restore
|
|
912
|
-
* the cache, or the content-hash gate suppresses the retry forever.
|
|
985
|
+
* the cache, or the content-hash gate suppresses the retry forever. A file
|
|
986
|
+
* it cannot read joins the context's ingestion failures instead. */
|
|
913
987
|
function foldUndiscoveredFiles(ctx) {
|
|
914
988
|
const excludeMatcher = ctx.excludeMatcher;
|
|
915
989
|
const filePaths = (0, _animus_ui_extract_pipeline.discoverFiles)(ctx.rootDir, ctx.rootDir, excludeMatcher, ctx.extensionsSet);
|
|
@@ -922,7 +996,8 @@ function foldUndiscoveredFiles(ctx) {
|
|
|
922
996
|
let source;
|
|
923
997
|
try {
|
|
924
998
|
source = (0, fs.readFileSync)(filePath, "utf-8");
|
|
925
|
-
} catch {
|
|
999
|
+
} catch (err) {
|
|
1000
|
+
if (!(0, _animus_ui_extract_pipeline.isDeletedSource)(err) && !ctx.ingestionFailureDiagnostics.some((d) => d.file === relPath)) ctx.ingestionFailureDiagnostics.push((0, _animus_ui_extract_pipeline.unreadableSourceDiagnostic)(relPath, err));
|
|
926
1001
|
continue;
|
|
927
1002
|
}
|
|
928
1003
|
pending.push([relPath, {
|
|
@@ -1357,7 +1432,13 @@ function resolveVirtualId(ctx, id) {
|
|
|
1357
1432
|
if (id === VIRTUAL_BRIDGE_ID) return RESOLVED_BRIDGE_ID;
|
|
1358
1433
|
if (id === VIRTUAL_SYSTEM_PROPS_ID) return RESOLVED_SYSTEM_PROPS_ID;
|
|
1359
1434
|
const srcEntry = ctx.externalSourceEntries.get(id);
|
|
1360
|
-
if (srcEntry)
|
|
1435
|
+
if (srcEntry) {
|
|
1436
|
+
const moduleSideEffects = ctx.externalSourceSideEffects.get(id);
|
|
1437
|
+
return moduleSideEffects === void 0 ? srcEntry : {
|
|
1438
|
+
id: srcEntry,
|
|
1439
|
+
moduleSideEffects
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1361
1442
|
return null;
|
|
1362
1443
|
}
|
|
1363
1444
|
function loadVirtualModule(ctx, id) {
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ export interface AnimusExtractOptions {
|
|
|
48
48
|
mode?: 'development' | 'production';
|
|
49
49
|
/** Namespace prefix for CSS variables and class names. */
|
|
50
50
|
prefix?: string;
|
|
51
|
+
/** With `prefix` set, contextual variables take the prefixed name
|
|
52
|
+
* everywhere Animus emits them, while authors keep writing the declared
|
|
53
|
+
* name. */
|
|
54
|
+
prefixContextualVars?: boolean;
|
|
51
55
|
/**
|
|
52
56
|
* Forced-emission declarations for usage the scanner cannot observe;
|
|
53
57
|
* declared variants, states and prop values are emitted as if used.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE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E,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;+CAE2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;gBAEY;IACZ,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;OAGG;IACH,mBAAmB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAMD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAsFnE;eAEc,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rediscovery.d.ts","sourceRoot":"","sources":["../src/rediscovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rediscovery.d.ts","sourceRoot":"","sources":["../src/rediscovery.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,aAAa,GACjB,oBAAoB,EAAE,CAWxB;AAOD,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAa3E;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,OAAO,CAAC,CAgFlB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { PluginContext } from './context';
|
|
2
|
-
export declare function resolveVirtualId(ctx: PluginContext, id: string): string |
|
|
2
|
+
export declare function resolveVirtualId(ctx: PluginContext, id: string): string | {
|
|
3
|
+
id: string;
|
|
4
|
+
moduleSideEffects: boolean;
|
|
5
|
+
} | null;
|
|
3
6
|
export declare function loadVirtualModule(ctx: PluginContext, id: string): string | null;
|
|
4
7
|
//# sourceMappingURL=virtual-modules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../src/virtual-modules.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAa/C,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,MAAM,GACT,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../src/virtual-modules.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAa/C,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,MAAM,GACT,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAmB5D;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,MAAM,GACT,MAAM,GAAG,IAAI,CA+Gf"}
|
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.21",
|
|
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.21",
|
|
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.21"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@mdx-js/mdx": "^3.0.0",
|