@animus-ui/vite-plugin 0.1.22 → 0.1.24

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.
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,WAAW,CAAC;AAGlE;;;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,CA8If"}
@@ -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,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CAmCN"}
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,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CA8CN"}
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, ManifestDiagnostic, ManifestSheets, ProjectManifest, RawSourceEntry, SourceCorpus, SourceIngestionResult, SystemConfig } from '@animus-ui/extract/pipeline';
4
+ import type { ExcludeMatcher, ExternalPackageOutcome, KitDescriptorRecord, 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. */
@@ -15,6 +15,12 @@ export declare function pruneFileCache(cache: Map<string, {
15
15
  hash: string;
16
16
  source: string;
17
17
  }>, rootDir: string, absPath: string): boolean;
18
+ /** A discovery's analysis input: its entries, and the file-cache seeding
19
+ * that follows their ingestion. */
20
+ export type DiscoveredSources = {
21
+ rawEntries: readonly RawSourceEntry[];
22
+ afterIngestion: (accepted: SourceIngestionResult) => void;
23
+ };
18
24
  export declare class PluginContext {
19
25
  readonly options: AnimusExtractOptions;
20
26
  readonly verbose: boolean;
@@ -22,14 +28,23 @@ export declare class PluginContext {
22
28
  readonly tracing: boolean;
23
29
  readonly staticCssJson: string | null;
24
30
  isProd: boolean;
31
+ /** Serving or watching: an error-level diagnostic reports, and only a
32
+ * one-shot build fails on one. */
33
+ development: boolean;
25
34
  /** Emission mode (the explicit `mode` option wins over the command); feeds
26
35
  * engine devMode and the minify default. Lifecycle stays on `isProd`. */
27
36
  emissionProd: boolean;
28
37
  rootDir: string;
29
38
  logger: Logger | null;
30
39
  system: SystemConfig;
40
+ /** Whether a system has loaded, so a failed reload has one to keep. */
41
+ private systemLoaded;
31
42
  lcssTargets: LightningTargets;
32
43
  pathAliasesJson: string | null;
44
+ /** Vite's export conditions, so the loader reads the files Vite serves. */
45
+ resolveConditions: string[];
46
+ /** Development's repeat of buildStart's discovery, with its resolver. */
47
+ rediscoverSources: (() => Promise<DiscoveredSources>) | null;
33
48
  extensionsSet: ReadonlySet<string>;
34
49
  excludeMatcher: ExcludeMatcher;
35
50
  storedManifest: ProjectManifest | null;
@@ -85,6 +100,10 @@ export declare class PluginContext {
85
100
  assetResolutionFailures: Set<string>;
86
101
  assetPassComplete: boolean;
87
102
  externalPackageDirs: string[];
103
+ /** Those whose package is linked rather than installed. */
104
+ externalLinkedDirs: string[];
105
+ /** Those read from their package's compiled output. */
106
+ externalOutputDirs: string[];
88
107
  externalDirOwners: Record<string, string>;
89
108
  /** specifier → whether its redirected source entry has side effects, from
90
109
  * the owning package's `sideEffects`; absent leaves Vite's default. */
@@ -92,6 +111,8 @@ export declare class PluginContext {
92
111
  externalFileOwners: Record<string, string>;
93
112
  externalSourceEntries: Map<string, string>;
94
113
  externalPackageOutcomes: ExternalPackageOutcome[];
114
+ /** The analysed kits' descriptors, from the last discovery. */
115
+ kitDescriptors: KitDescriptorRecord[];
95
116
  /** Configured files buildStart or a late rediscovery could not read.
96
117
  * Later analyses read no files themselves, so they replay these until the
97
118
  * file is read into the cache or deleted. */
@@ -114,8 +135,15 @@ export declare class PluginContext {
114
135
  * without opting in. */
115
136
  info(msg: string): void;
116
137
  warn(msg: string): void;
138
+ /** Development's sink for error-level diagnostics: they are reported and
139
+ * the server or watch keeps running. Only a build fails on them. */
140
+ reportErrors(): ((message: string) => void) | undefined;
141
+ /** A build-strictness check that failed: a build throws `message`, and
142
+ * development reports it at error level and takes the non-strict path. */
143
+ strictFailure(message: string, cause?: unknown): void;
117
144
  /** Load the system into `this.system`. On failure the previous config is
118
- * kept; strict mode throws instead. */
145
+ * kept; strict mode throws instead, and strict development reports the
146
+ * failure once a system has loaded, since there is one to keep. */
119
147
  loadSystem(): void;
120
148
  /** The read failures still standing: a file stops counting once the cache
121
149
  * holds a read of it or it is gone, as in the shared session, so it stops
@@ -190,7 +218,8 @@ export declare class PluginContext {
190
218
  * reaches client and ssr at once; per-environment graphs do not. */
191
219
  invalidateExtractedModules(): void;
192
220
  /** An unresolvable `.includes()` specifier or a stale dist entry under an
193
- * extended package warns, and fails the build under `strict`. */
221
+ * extended package warns, and fails the build under `strict` (strict
222
+ * development reports it). */
194
223
  enforceIncludeResolution(): void;
195
224
  enforceExternalTokenContracts(): void;
196
225
  runSelfVerify(): void;
@@ -1 +1 @@
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,oBAAoB,CAAC,CAAC,EACpC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAWZ;AA8BD;sEACsE;AACtE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAOlE;AAED;uEACuE;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,qBAAqB,CAAC;QAChC,6DAA6D;QAC7D,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,SAAS,EAAE,OAAO,CAAC;QACnB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC,CA4ED;IAED,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAQ1D;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhC;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;;2BAEuB;IACvB,gBAAgB,IAAI,IAAI,CAWvB;IAED;8EAC0E;IAC1E,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,cAAc,CAA+B;IAErD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAkBzC;IAEK,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIzC;YAEa,4BAA4B;IAU1C,OAAO,CAAC,6BAA6B;IAcrC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI3C;IAED;2EACuE;IACvE,wBAAwB,IAAI,IAAI,CAS/B;IAED;;;yEAGqE;IACrE,0BAA0B,IAAI,IAAI,CAkBjC;IAED;;mCAE+B;IAC/B,wBAAwB,IAAI,IAAI,CAS/B;IAED,6BAA6B,IAAI,IAAI,CAWpC;IAED,aAAa,IAAI,IAAI,CA2BpB;CACF"}
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
6
- let fs = require("fs");
7
6
  let path = require("path");
7
+ let fs = require("fs");
8
8
  let crypto = require("crypto");
9
9
  //#region src/build-start.ts
10
10
  /**
@@ -27,7 +27,71 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
27
27
  const groupCount = Object.keys(JSON.parse(ctx.system.groupRegistryJson)).length;
28
28
  ctx.log(`System loaded: ${propCount} props, ${groupCount} groups (${Math.round(performance.now() - t0)}ms)`);
29
29
  }
30
+ const discovered = await discoverSources(ctx, resolveSpecifier);
31
+ if (!ctx.isProd) ctx.rediscoverSources = async () => {
32
+ const rediscovered = await discoverSources(ctx, resolveSpecifier);
33
+ return {
34
+ ...rediscovered,
35
+ rawEntries: rediscovered.rawEntries.map((entry) => {
36
+ const cached = ctx.fileCache.get(entry.path);
37
+ return cached ? {
38
+ path: entry.path,
39
+ ...cached
40
+ } : entry;
41
+ })
42
+ };
43
+ };
30
44
  t0 = performance.now();
45
+ await ctx.analyzeIngested(discovered);
46
+ const assetSpecifiers = ctx.sheetAssetSpecifiers();
47
+ for (const specifier of assetSpecifiers) {
48
+ const resolvedPath = await resolveSpecifier(specifier);
49
+ if (!resolvedPath) {
50
+ ctx.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
51
+ continue;
52
+ }
53
+ if (emitAsset) try {
54
+ const referenceId = emitAsset((0, path.basename)(resolvedPath), (0, fs.readFileSync)(resolvedPath));
55
+ ctx.assetUrlBySpecifier.set(specifier, `__VITE_ASSET__${referenceId}__`);
56
+ } catch (err) {
57
+ ctx.assetFallback(specifier, `[animus-extract] failed to emit asset() specifier ${specifier}: ${String(err)}`, err);
58
+ }
59
+ else ctx.assetUrlBySpecifier.set(specifier, ctx.devFsUrl(resolvedPath));
60
+ }
61
+ ctx.substituteSheets();
62
+ ctx.assetPassComplete = true;
63
+ if (ctx.storedManifest) {
64
+ const report = ctx.storedManifest.report;
65
+ ctx.log(`Extracted ${report.components_extracted}/${report.components_total} components (${Math.round(performance.now() - t0)}ms)`);
66
+ ctx.log(`Reconciliation: ${report.components_extracted} kept, ${report.variants_eliminated} variants pruned, ${report.states_eliminated} states pruned`);
67
+ for (const d of report.eliminated_details) if (d.kind === "component") ctx.warn(`⚠ ${d.component} eliminated: ${d.reason}`);
68
+ else if (d.kind === "prospective_component" && !ctx.emissionProd) ctx.warn(`⚠ ${d.component} would be eliminated in production: ${d.reason}`);
69
+ else if (d.kind === "variant") ctx.trace(`${d.component} variant '${d.name}' pruned: ${d.reason}`);
70
+ else if (d.kind === "state") ctx.trace(`${d.component} state '${d.name}' pruned: ${d.reason}`);
71
+ ctx.log(`CSS: ${ctx.resolvedComponentCss.length} bytes (${Object.keys(ctx.storedManifest.components).length} components)`);
72
+ if (!ctx.isProd && ctx.storedSheets) {
73
+ const staticSize = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
74
+ layers: ctx.options.layers,
75
+ variableCss: ctx.variableCss,
76
+ globalCss: ctx.globalCss
77
+ }).length;
78
+ const componentSize = ctx.resolvedComponentCss.length;
79
+ ctx.log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
80
+ } else ctx.log("Delivery: single file mode (production)");
81
+ }
82
+ const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
83
+ layers: ctx.options.layers,
84
+ variableCss: "",
85
+ globalCss: "",
86
+ split: true
87
+ });
88
+ ctx.layerDeclaration = declaration;
89
+ if (ctx.options.verify) ctx.runSelfVerify();
90
+ }
91
+ /** Local and external discovery, publishing the package state on `ctx`, and
92
+ * the analysis input it yields. */
93
+ async function discoverSources(ctx, resolveSpecifier) {
94
+ const t0 = performance.now();
31
95
  ctx.excludeMatcher = (0, _animus_ui_extract_pipeline.createExcludeMatcher)(ctx.options.exclude);
32
96
  const excludePatterns = ctx.excludeMatcher;
33
97
  ctx.extensionsSet = new Set(ctx.options.extensions ?? _animus_ui_extract_pipeline.DEFAULT_EXTENSIONS);
@@ -51,7 +115,9 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
51
115
  });
52
116
  }
53
117
  const localFileCount = rawEntries.length;
54
- const packageSpecifiers = (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(ctx.resolvedSystemPath, (0, _animus_ui_extract_pipeline.engineImportParser)(ctx.engineApi()));
118
+ const discoveryDiagnostics = [];
119
+ const packageSpecifiers = await (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(ctx.resolvedSystemPath, (0, _animus_ui_extract_pipeline.engineModuleParser)(ctx.engineApi()), (diagnostic) => discoveryDiagnostics.push(diagnostic), resolveSpecifier);
120
+ discoveryDiagnostics.push(...(0, _animus_ui_extract_pipeline.importedKitDiagnostics)(rawEntries, ctx.engineApi(), ctx.rootDir, packageSpecifiers));
55
121
  ctx.externalSourceEntries.clear();
56
122
  const collected = await (0, _animus_ui_extract_pipeline.collectExternalPackageSources)({
57
123
  specifiers: packageSpecifiers,
@@ -64,9 +130,14 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
64
130
  }
65
131
  });
66
132
  ctx.ingestionFailureDiagnostics = ingestionFailures;
67
- (0, _animus_ui_extract_pipeline.surfaceManifestDiagnostics)({ diagnostics: (0, _animus_ui_extract_pipeline.noKitFilesDiagnostics)(collected.outcomes) }, (message) => ctx.warn(message));
133
+ (0, _animus_ui_extract_pipeline.surfaceManifestDiagnostics)({ diagnostics: [...discoveryDiagnostics, ...collected.diagnostics] }, (message) => ctx.warn(message), {
134
+ levels: ctx.options.diagnostics,
135
+ strict: ctx.options.strict,
136
+ reportErrors: ctx.reportErrors()
137
+ });
68
138
  ctx.packageMap = collected.packageMap;
69
139
  ctx.externalPackageOutcomes = collected.outcomes;
140
+ ctx.kitDescriptors = collected.kitDescriptors;
70
141
  ctx.externalDirOwners = (0, _animus_ui_extract_pipeline.firstOwners)(collected.dirOwnerSets);
71
142
  ctx.externalFileOwners = collected.fileOwners;
72
143
  ctx.enforceIncludeResolution();
@@ -81,11 +152,12 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
81
152
  });
82
153
  }
83
154
  ctx.externalPackageDirs = collected.packageDirs;
155
+ ctx.externalLinkedDirs = collected.linkedDirs;
156
+ ctx.externalOutputDirs = collected.outputDirs;
84
157
  ctx.registerSystemWatchPaths();
85
158
  const packageFileCount = rawEntries.length - localFileCount;
86
159
  ctx.log(`Discovered ${rawEntries.length} files (${packageFileCount} from packages) (${Math.round(performance.now() - t0)}ms)`);
87
- t0 = performance.now();
88
- await ctx.analyzeIngested({
160
+ return {
89
161
  rawEntries,
90
162
  afterIngestion: (accepted) => {
91
163
  if (!ctx.isProd) ctx.mutateFileCache((cache) => {
@@ -96,58 +168,16 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
96
168
  });
97
169
  });
98
170
  }
99
- });
100
- const assetSpecifiers = ctx.sheetAssetSpecifiers();
101
- for (const specifier of assetSpecifiers) {
102
- const resolvedPath = await resolveSpecifier(specifier);
103
- if (!resolvedPath) {
104
- ctx.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
105
- continue;
106
- }
107
- if (emitAsset) try {
108
- const referenceId = emitAsset((0, path.basename)(resolvedPath), (0, fs.readFileSync)(resolvedPath));
109
- ctx.assetUrlBySpecifier.set(specifier, `__VITE_ASSET__${referenceId}__`);
110
- } catch (err) {
111
- ctx.assetFallback(specifier, `[animus-extract] failed to emit asset() specifier ${specifier}: ${String(err)}`, err);
112
- }
113
- else ctx.assetUrlBySpecifier.set(specifier, ctx.devFsUrl(resolvedPath));
114
- }
115
- ctx.substituteSheets();
116
- ctx.assetPassComplete = true;
117
- if (ctx.storedManifest) {
118
- const report = ctx.storedManifest.report;
119
- ctx.log(`Extracted ${report.components_extracted}/${report.components_total} components (${Math.round(performance.now() - t0)}ms)`);
120
- ctx.log(`Reconciliation: ${report.components_extracted} kept, ${report.variants_eliminated} variants pruned, ${report.states_eliminated} states pruned`);
121
- for (const d of report.eliminated_details) if (d.kind === "component") ctx.warn(`⚠ ${d.component} eliminated: ${d.reason}`);
122
- else if (d.kind === "prospective_component" && !ctx.emissionProd) ctx.warn(`⚠ ${d.component} would be eliminated in production: ${d.reason}`);
123
- else if (d.kind === "variant") ctx.trace(`${d.component} variant '${d.name}' pruned: ${d.reason}`);
124
- else if (d.kind === "state") ctx.trace(`${d.component} state '${d.name}' pruned: ${d.reason}`);
125
- ctx.log(`CSS: ${ctx.resolvedComponentCss.length} bytes (${Object.keys(ctx.storedManifest.components).length} components)`);
126
- if (!ctx.isProd && ctx.storedSheets) {
127
- const staticSize = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
128
- layers: ctx.options.layers,
129
- variableCss: ctx.variableCss,
130
- globalCss: ctx.globalCss
131
- }).length;
132
- const componentSize = ctx.resolvedComponentCss.length;
133
- ctx.log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
134
- } else ctx.log("Delivery: single file mode (production)");
135
- }
136
- const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
137
- layers: ctx.options.layers,
138
- variableCss: "",
139
- globalCss: "",
140
- split: true
141
- });
142
- ctx.layerDeclaration = declaration;
143
- if (ctx.options.verify) ctx.runSelfVerify();
171
+ };
144
172
  }
145
173
  //#endregion
146
174
  //#region src/config.ts
147
175
  function applyResolvedConfig(ctx, config) {
148
176
  ctx.isProd = config.command === "build";
177
+ ctx.development = !ctx.isProd || Boolean(config.build.watch);
149
178
  ctx.emissionProd = (0, _animus_ui_extract_pipeline.resolveMode)(ctx.options.mode, () => config.command === "build" ? "production" : "development").mode === "production";
150
179
  ctx.rootDir = config.root;
180
+ ctx.resolveConditions = config.resolve.conditions.map((condition) => condition === "development|production" ? config.isProduction ? "production" : "development" : condition);
151
181
  ctx.logger = config.logger;
152
182
  ctx.base = config.base ?? "/";
153
183
  ctx.lcssTargets = (0, _animus_ui_extract_pipeline.resolveLightningTargets)(ctx.options.targets, ctx.rootDir);
@@ -396,14 +426,23 @@ var PluginContext = class {
396
426
  tracing;
397
427
  staticCssJson;
398
428
  isProd = false;
429
+ /** Serving or watching: an error-level diagnostic reports, and only a
430
+ * one-shot build fails on one. */
431
+ development = false;
399
432
  /** Emission mode (the explicit `mode` option wins over the command); feeds
400
433
  * engine devMode and the minify default. Lifecycle stays on `isProd`. */
401
434
  emissionProd = false;
402
435
  rootDir = "";
403
436
  logger = null;
404
437
  system = emptySystemConfig();
438
+ /** Whether a system has loaded, so a failed reload has one to keep. */
439
+ systemLoaded = false;
405
440
  lcssTargets = {};
406
441
  pathAliasesJson = null;
442
+ /** Vite's export conditions, so the loader reads the files Vite serves. */
443
+ resolveConditions = [];
444
+ /** Development's repeat of buildStart's discovery, with its resolver. */
445
+ rediscoverSources = null;
407
446
  extensionsSet;
408
447
  excludeMatcher;
409
448
  storedManifest = null;
@@ -439,7 +478,8 @@ var PluginContext = class {
439
478
  engineApi: () => this.engineApi(),
440
479
  prefix: "[animus-extract]",
441
480
  strict: () => !!this.options.strict,
442
- warn: (message) => this.warn(message)
481
+ warn: (message) => this.warn(message),
482
+ reportErrors: () => this.reportErrors()
443
483
  });
444
484
  rawExtensionFallbacks = /* @__PURE__ */ new Set();
445
485
  /** Original path → hash of bytes whose parse aborted in a rejected attempt;
@@ -469,6 +509,10 @@ var PluginContext = class {
469
509
  assetResolutionFailures = /* @__PURE__ */ new Set();
470
510
  assetPassComplete = false;
471
511
  externalPackageDirs = [];
512
+ /** Those whose package is linked rather than installed. */
513
+ externalLinkedDirs = [];
514
+ /** Those read from their package's compiled output. */
515
+ externalOutputDirs = [];
472
516
  externalDirOwners = {};
473
517
  /** specifier → whether its redirected source entry has side effects, from
474
518
  * the owning package's `sideEffects`; absent leaves Vite's default. */
@@ -476,6 +520,8 @@ var PluginContext = class {
476
520
  externalFileOwners = {};
477
521
  externalSourceEntries = /* @__PURE__ */ new Map();
478
522
  externalPackageOutcomes = [];
523
+ /** The analysed kits' descriptors, from the last discovery. */
524
+ kitDescriptors = [];
479
525
  /** Configured files buildStart or a late rediscovery could not read.
480
526
  * Later analyses read no files themselves, so they replay these until the
481
527
  * file is read into the cache or deleted. */
@@ -545,8 +591,22 @@ var PluginContext = class {
545
591
  warn(msg) {
546
592
  (this.logger ?? console).warn(`[animus] ${msg}`);
547
593
  }
594
+ /** Development's sink for error-level diagnostics: they are reported and
595
+ * the server or watch keeps running. Only a build fails on them. */
596
+ reportErrors() {
597
+ if (!this.development) return void 0;
598
+ return (message) => (this.logger ?? console).error(/^\[animus(?::verify)?\] /.test(message) ? message : `[animus] ${message.replace(/^\[animus-extract\] /, "")}`);
599
+ }
600
+ /** A build-strictness check that failed: a build throws `message`, and
601
+ * development reports it at error level and takes the non-strict path. */
602
+ strictFailure(message, cause) {
603
+ const report = this.reportErrors();
604
+ if (!report) throw new Error(message, cause === void 0 ? void 0 : { cause });
605
+ report(message);
606
+ }
548
607
  /** Load the system into `this.system`. On failure the previous config is
549
- * kept; strict mode throws instead. */
608
+ * kept; strict mode throws instead, and strict development reports the
609
+ * failure once a system has loaded, since there is one to keep. */
550
610
  loadSystem() {
551
611
  this.resolvedSystemPath = (0, path.resolve)(this.rootDir, this.options.system);
552
612
  for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(this.resolvedSystemPath)) this.systemDependencyKeys.add(key);
@@ -555,23 +615,24 @@ var PluginContext = class {
555
615
  systemPath: this.resolvedSystemPath,
556
616
  rootDir: this.rootDir,
557
617
  prefix: this.options.prefix,
558
- prefixContextualVars: this.options.prefixContextualVars
618
+ prefixContextualVars: this.options.prefixContextualVars,
619
+ conditions: this.resolveConditions
559
620
  });
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];
621
+ const deps = this.system.dependencies ?? [];
567
622
  const keys = /* @__PURE__ */ new Set();
568
623
  for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(this.resolvedSystemPath)) keys.add(key);
569
624
  for (const dep of deps) for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(dep)) keys.add(key);
570
625
  this.systemDependencyKeys = keys;
571
626
  this.systemDependencyPaths = deps;
572
627
  this.registerSystemWatchPaths();
628
+ this.systemLoaded = true;
573
629
  } catch (e) {
574
- if (this.options.strict) throw new Error(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}: ${e}`, { cause: e });
630
+ if (this.options.strict) {
631
+ const message = `[animus-extract] Failed to load system from ${this.resolvedSystemPath}: ${e}`;
632
+ if (!this.systemLoaded) throw new Error(message, { cause: e });
633
+ this.strictFailure(message, e);
634
+ return;
635
+ }
575
636
  console.warn(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}:`, e);
576
637
  }
577
638
  }
@@ -612,23 +673,34 @@ var PluginContext = class {
612
673
  analysisContext: {
613
674
  skippedSources: [...skippedOriginals, ...ingestionFailures.map((d) => d.file)].map((file) => (0, path.isAbsolute)(file) ? (0, path.relative)(this.rootDir, file) : file),
614
675
  unbundledComputedImports: true,
615
- packageDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir))
676
+ packageDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir)),
677
+ linkedDirs: this.externalLinkedDirs.map((dir) => (0, path.relative)(this.rootDir, dir)),
678
+ outputDirs: this.externalOutputDirs.map((dir) => (0, path.relative)(this.rootDir, dir))
616
679
  },
617
680
  warn: (m) => this.warn(m),
618
681
  info: (m) => this.log(m),
619
682
  strict: this.options.strict,
620
- extraDiagnostics: ingestionFailures
683
+ diagnostics: this.options.diagnostics,
684
+ reportErrors: this.reportErrors(),
685
+ extraDiagnostics: ingestionFailures,
686
+ kitDescriptors: this.kitDescriptors
621
687
  });
622
688
  } catch (e) {
623
- if (this.options.strict) throw new Error(`[animus-extract] analyzeProject failed: ${e}`, { cause: e });
689
+ const message = `[animus-extract] analyzeProject failed: ${e}`;
690
+ if (e instanceof _animus_ui_extract_pipeline.DiagnosticFailure) throw new Error(message, { cause: e });
691
+ if (this.options.strict) {
692
+ if (this.storedManifest === null) throw new Error(message, { cause: e });
693
+ this.strictFailure(message, e);
694
+ return false;
695
+ }
624
696
  console.warn("[animus-extract] analyzeProject failed:", e);
625
697
  return false;
626
698
  }
627
- (0, _animus_ui_extract_pipeline.assertNoErrorDiagnostics)(result.manifest.diagnostics);
628
699
  this.assertRuntimeImportSuppliesTerminals(result.manifest);
629
700
  (0, _animus_ui_extract_pipeline.reportSurvivingAssetPlaceholders)((0, _animus_ui_extract_pipeline.generatedModuleCode)(result.manifest), {
630
701
  strict: this.options.strict,
631
702
  warn: (message) => this.warn(message),
703
+ reportErrors: this.reportErrors(),
632
704
  prefix: "[animus-extract]",
633
705
  surface: "generated runtime modules"
634
706
  });
@@ -742,8 +814,8 @@ var PluginContext = class {
742
814
  return `${this.base.endsWith("/") ? this.base.slice(0, -1) : this.base}/@fs${absPath}`;
743
815
  }
744
816
  assetFallback(specifier, message, cause) {
745
- if (this.options.strict) throw new Error(message, cause === void 0 ? void 0 : { cause });
746
- this.warn(message);
817
+ if (this.options.strict) this.strictFailure(message, cause);
818
+ else this.warn(message);
747
819
  this.assetUrlBySpecifier.set(specifier, specifier);
748
820
  this.assetResolutionFailures.add(specifier);
749
821
  }
@@ -819,7 +891,7 @@ var PluginContext = class {
819
891
  async performSystemReloadExclusive() {
820
892
  const resetStart = performance.now();
821
893
  this.systemReloadOwed = true;
822
- const { ok } = await this.analyzeIngested();
894
+ const { ok } = await this.analyzeIngested(await this.rediscoverSources?.());
823
895
  if (!ok) return;
824
896
  this.log(`HMR system reload complete: ${Math.round(performance.now() - resetStart)}ms`);
825
897
  }
@@ -865,12 +937,13 @@ var PluginContext = class {
865
937
  }, 100);
866
938
  }
867
939
  /** An unresolvable `.includes()` specifier or a stale dist entry under an
868
- * extended package warns, and fails the build under `strict`. */
940
+ * extended package warns, and fails the build under `strict` (strict
941
+ * development reports it). */
869
942
  enforceIncludeResolution() {
870
943
  for (const message of [(0, _animus_ui_extract_pipeline.unresolvableIncludesMessage)(this.externalPackageOutcomes), (0, _animus_ui_extract_pipeline.staleDistIncludesMessage)(this.externalPackageOutcomes)]) {
871
944
  if (message === null) continue;
872
- if (this.options.strict) throw new Error(message);
873
- this.warn(message);
945
+ if (this.options.strict) this.strictFailure(message);
946
+ else this.warn(message);
874
947
  }
875
948
  }
876
949
  enforceExternalTokenContracts() {
@@ -881,7 +954,8 @@ var PluginContext = class {
881
954
  sourceThemeManifestsJson: this.system.sourceThemeManifestsJson,
882
955
  strict: this.options.strict,
883
956
  prefix: "[animus-extract]",
884
- warn: (message) => this.warn(message)
957
+ warn: (message) => this.warn(message),
958
+ reportErrors: this.reportErrors()
885
959
  });
886
960
  }
887
961
  runSelfVerify() {
@@ -896,7 +970,10 @@ var PluginContext = class {
896
970
  });
897
971
  for (const message of failures) {
898
972
  const line = `[animus:verify] ${message}`;
899
- if (this.options.strict) throw new Error(line);
973
+ if (this.options.strict) {
974
+ this.strictFailure(line);
975
+ continue;
976
+ }
900
977
  if (this.logger) this.logger.warn(line, { timestamp: true });
901
978
  else console.warn(line);
902
979
  }
@@ -1172,8 +1249,8 @@ async function transformSource(ctx, code, id) {
1172
1249
  map: null
1173
1250
  };
1174
1251
  } catch (e) {
1175
- if (ctx.options.strict) throw new Error(`[animus-extract] Failed to transform ${id}: ${e}`, { cause: e });
1176
- console.warn(`[animus-extract] Failed to transform ${id}:`, e);
1252
+ if (ctx.options.strict) ctx.strictFailure(`[animus-extract] Failed to transform ${id}: ${e}`, e);
1253
+ else console.warn(`[animus-extract] Failed to transform ${id}:`, e);
1177
1254
  ctx.recordFallbackState(relativePath, true);
1178
1255
  return null;
1179
1256
  }
@@ -1451,6 +1528,7 @@ function loadVirtualModule(ctx, id) {
1451
1528
  (0, _animus_ui_extract_pipeline.reportSurvivingAssetPlaceholders)(css, {
1452
1529
  strict: ctx.options.strict,
1453
1530
  warn: (message) => ctx.warn(message),
1531
+ reportErrors: ctx.reportErrors(),
1454
1532
  prefix: "[animus-extract]"
1455
1533
  });
1456
1534
  return css;
@@ -1531,6 +1609,17 @@ if (import.meta.hot) {
1531
1609
  }
1532
1610
  //#endregion
1533
1611
  //#region src/index.ts
1612
+ function sourceKitConfig(rootDir, serving) {
1613
+ const kits = (0, _animus_ui_extract_pipeline.sourceKitDependencies)(rootDir).filter((kit) => kit.installed);
1614
+ if (kits.length === 0) return void 0;
1615
+ const names = kits.map((kit) => kit.name);
1616
+ const config = { optimizeDeps: {
1617
+ exclude: names,
1618
+ include: kits.flatMap((kit) => kit.dependencies.map((dependency) => `${kit.name} > ${dependency}`))
1619
+ } };
1620
+ if (serving) config.ssr = { noExternal: names };
1621
+ return config;
1622
+ }
1534
1623
  function animusExtract(options) {
1535
1624
  (0, _animus_ui_extract_pipeline.assertNoRetiredEngineSelection)(options.engine);
1536
1625
  (0, _animus_ui_extract_pipeline.assertKnownOptionKeys)(options, ["verify", "appearanceBootstrap"], [{
@@ -1544,9 +1633,14 @@ function animusExtract(options) {
1544
1633
  return {
1545
1634
  name: "animus-extract",
1546
1635
  enforce: "pre",
1547
- config(_config, env) {
1636
+ config(userConfig, env) {
1548
1637
  const { mode } = (0, _animus_ui_extract_pipeline.resolveMode)(options.mode, () => env.command === "build" ? "production" : "development");
1549
- return { define: { __ANIMUS_DEV__: mode === "development" } };
1638
+ const define = { __ANIMUS_DEV__: mode === "development" };
1639
+ const kits = sourceKitConfig((0, path.resolve)(userConfig.root ?? process.cwd()), env.command === "serve");
1640
+ return kits ? {
1641
+ define,
1642
+ ...kits
1643
+ } : { define };
1550
1644
  },
1551
1645
  configureServer(server) {
1552
1646
  ctx.devServer = server;
@@ -1564,8 +1658,17 @@ function animusExtract(options) {
1564
1658
  source
1565
1659
  }) : void 0);
1566
1660
  },
1567
- resolveId(id) {
1568
- return resolveVirtualId(ctx, id);
1661
+ async resolveId(id, importer) {
1662
+ const virtual = resolveVirtualId(ctx, id);
1663
+ if (virtual !== null || !id.startsWith(".") || importer === void 0) return virtual;
1664
+ const importerPath = importer.split("?")[0];
1665
+ if (!ctx.externalPackageDirs.some((dir) => (0, _animus_ui_extract_pipeline.isPathWithinRoot)(dir, importerPath))) return null;
1666
+ const resolved = await this.resolve(id, importer, { skipSelf: true });
1667
+ if (resolved === null || resolved.external || !(0, _animus_ui_extract_pipeline.keepsKitSourceEffects)(resolved.id.split("?")[0], ctx.externalPackageDirs)) return null;
1668
+ return {
1669
+ ...resolved,
1670
+ moduleSideEffects: true
1671
+ };
1569
1672
  },
1570
1673
  load(id) {
1571
1674
  return loadVirtualModule(ctx, id);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StaticCssConfig } from '@animus-ui/extract/pipeline';
1
+ import type { DiagnosticLevels, StaticCssConfig } from '@animus-ui/extract/pipeline';
2
2
  import type { Plugin } from 'vite';
3
3
  export { discoverFiles } from '@animus-ui/extract/pipeline';
4
4
  export interface AnimusExtractOptions {
@@ -21,10 +21,23 @@ export interface AnimusExtractOptions {
21
21
  extensions?: string[];
22
22
  /**
23
23
  * Error-severity diagnostics — lost configured inputs and classified
24
- * unsupported Animus declarations — fail the build instead of warning.
24
+ * unsupported Animus declarations — and failed checks, such as an
25
+ * unresolved include or `asset()` specifier or a failed `verify`
26
+ * self-check, fail a build instead of warning. The dev server reports them
27
+ * and keeps running; a system that fails to load at startup, or a first
28
+ * analysis that throws, still stops it, since nothing exists to serve.
25
29
  * Omitted or `false` warns.
26
30
  */
27
31
  strict?: boolean;
32
+ /**
33
+ * Each `animus.*` code's level, by exact code, by a prefix ending in `.*`
34
+ * (`'animus.style.*'`), or by kind (`'kind:bail'`, `'kind:skip'`,
35
+ * `'kind:warn'`, `'kind:error'`): `'off'`, `'info'`, `'warn'` or `'error'`,
36
+ * which fails a build and is reported by the dev server, which keeps
37
+ * running. An exact code beats the longest matching prefix, which beats a
38
+ * kind, and an entry beats `strict` and the code's own severity.
39
+ */
40
+ diagnostics?: DiagnosticLevels;
28
41
  /**
29
42
  * Run a structural self-check at the end of `buildStart`; failures throw
30
43
  * under `strict`, otherwise warn.
@@ -46,7 +59,9 @@ export interface AnimusExtractOptions {
46
59
  * selects production for `build` and development elsewhere.
47
60
  */
48
61
  mode?: 'development' | 'production';
49
- /** Namespace prefix for CSS variables and class names. */
62
+ /** Namespace prefix for the names Animus generates: theme token
63
+ * variables, classes and slots. Contextual variables keep their declared
64
+ * names unless `prefixContextualVars` is set. */
50
65
  prefix?: string;
51
66
  /** With `prefix` set, contextual variables take the prefixed name
52
67
  * everywhere Animus emits them, while authors keep writing the declared
@@ -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;AAEnC,OAAO,EAAE,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,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AAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC;;sDAEkD;IAClD,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,CAqHnE;eAEc,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,GAAG,CAAC,MAAM,CAAC,CAkBb;AAQD,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CAuK7C"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,GAAG,CAAC,MAAM,CAAC,CAkBb;AAQD,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CAsK7C"}
@@ -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;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"}
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,CAgHf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
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.22",
42
+ "@animus-ui/extract": "0.1.24",
43
43
  "browserslist": "^4.28.8",
44
44
  "lightningcss": "^1.33.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@animus-ui/assertions": "0.1.22"
47
+ "@animus-ui/assertions": "0.1.24"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@mdx-js/mdx": "^3.0.0",