@animus-ui/vite-plugin 0.1.23 → 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,CAgPf"}
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":"AAwCA,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);
@@ -53,6 +117,7 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
53
117
  const localFileCount = rawEntries.length;
54
118
  const discoveryDiagnostics = [];
55
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));
56
121
  ctx.externalSourceEntries.clear();
57
122
  const collected = await (0, _animus_ui_extract_pipeline.collectExternalPackageSources)({
58
123
  specifiers: packageSpecifiers,
@@ -65,9 +130,14 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
65
130
  }
66
131
  });
67
132
  ctx.ingestionFailureDiagnostics = ingestionFailures;
68
- (0, _animus_ui_extract_pipeline.surfaceManifestDiagnostics)({ diagnostics: [...discoveryDiagnostics, ...ctx.options.verify ? [] : (0, _animus_ui_extract_pipeline.noKitFilesDiagnostics)(collected.outcomes)] }, (message) => ctx.warn(message), { levels: ctx.options.diagnostics });
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
+ });
69
138
  ctx.packageMap = collected.packageMap;
70
139
  ctx.externalPackageOutcomes = collected.outcomes;
140
+ ctx.kitDescriptors = collected.kitDescriptors;
71
141
  ctx.externalDirOwners = (0, _animus_ui_extract_pipeline.firstOwners)(collected.dirOwnerSets);
72
142
  ctx.externalFileOwners = collected.fileOwners;
73
143
  ctx.enforceIncludeResolution();
@@ -82,11 +152,12 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
82
152
  });
83
153
  }
84
154
  ctx.externalPackageDirs = collected.packageDirs;
155
+ ctx.externalLinkedDirs = collected.linkedDirs;
156
+ ctx.externalOutputDirs = collected.outputDirs;
85
157
  ctx.registerSystemWatchPaths();
86
158
  const packageFileCount = rawEntries.length - localFileCount;
87
159
  ctx.log(`Discovered ${rawEntries.length} files (${packageFileCount} from packages) (${Math.round(performance.now() - t0)}ms)`);
88
- t0 = performance.now();
89
- await ctx.analyzeIngested({
160
+ return {
90
161
  rawEntries,
91
162
  afterIngestion: (accepted) => {
92
163
  if (!ctx.isProd) ctx.mutateFileCache((cache) => {
@@ -97,58 +168,16 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
97
168
  });
98
169
  });
99
170
  }
100
- });
101
- const assetSpecifiers = ctx.sheetAssetSpecifiers();
102
- for (const specifier of assetSpecifiers) {
103
- const resolvedPath = await resolveSpecifier(specifier);
104
- if (!resolvedPath) {
105
- ctx.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
106
- continue;
107
- }
108
- if (emitAsset) try {
109
- const referenceId = emitAsset((0, path.basename)(resolvedPath), (0, fs.readFileSync)(resolvedPath));
110
- ctx.assetUrlBySpecifier.set(specifier, `__VITE_ASSET__${referenceId}__`);
111
- } catch (err) {
112
- ctx.assetFallback(specifier, `[animus-extract] failed to emit asset() specifier ${specifier}: ${String(err)}`, err);
113
- }
114
- else ctx.assetUrlBySpecifier.set(specifier, ctx.devFsUrl(resolvedPath));
115
- }
116
- ctx.substituteSheets();
117
- ctx.assetPassComplete = true;
118
- if (ctx.storedManifest) {
119
- const report = ctx.storedManifest.report;
120
- ctx.log(`Extracted ${report.components_extracted}/${report.components_total} components (${Math.round(performance.now() - t0)}ms)`);
121
- ctx.log(`Reconciliation: ${report.components_extracted} kept, ${report.variants_eliminated} variants pruned, ${report.states_eliminated} states pruned`);
122
- for (const d of report.eliminated_details) if (d.kind === "component") ctx.warn(`⚠ ${d.component} eliminated: ${d.reason}`);
123
- else if (d.kind === "prospective_component" && !ctx.emissionProd) ctx.warn(`⚠ ${d.component} would be eliminated in production: ${d.reason}`);
124
- else if (d.kind === "variant") ctx.trace(`${d.component} variant '${d.name}' pruned: ${d.reason}`);
125
- else if (d.kind === "state") ctx.trace(`${d.component} state '${d.name}' pruned: ${d.reason}`);
126
- ctx.log(`CSS: ${ctx.resolvedComponentCss.length} bytes (${Object.keys(ctx.storedManifest.components).length} components)`);
127
- if (!ctx.isProd && ctx.storedSheets) {
128
- const staticSize = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
129
- layers: ctx.options.layers,
130
- variableCss: ctx.variableCss,
131
- globalCss: ctx.globalCss
132
- }).length;
133
- const componentSize = ctx.resolvedComponentCss.length;
134
- ctx.log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
135
- } else ctx.log("Delivery: single file mode (production)");
136
- }
137
- const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
138
- layers: ctx.options.layers,
139
- variableCss: "",
140
- globalCss: "",
141
- split: true
142
- });
143
- ctx.layerDeclaration = declaration;
144
- if (ctx.options.verify) ctx.runSelfVerify();
171
+ };
145
172
  }
146
173
  //#endregion
147
174
  //#region src/config.ts
148
175
  function applyResolvedConfig(ctx, config) {
149
176
  ctx.isProd = config.command === "build";
177
+ ctx.development = !ctx.isProd || Boolean(config.build.watch);
150
178
  ctx.emissionProd = (0, _animus_ui_extract_pipeline.resolveMode)(ctx.options.mode, () => config.command === "build" ? "production" : "development").mode === "production";
151
179
  ctx.rootDir = config.root;
180
+ ctx.resolveConditions = config.resolve.conditions.map((condition) => condition === "development|production" ? config.isProduction ? "production" : "development" : condition);
152
181
  ctx.logger = config.logger;
153
182
  ctx.base = config.base ?? "/";
154
183
  ctx.lcssTargets = (0, _animus_ui_extract_pipeline.resolveLightningTargets)(ctx.options.targets, ctx.rootDir);
@@ -397,14 +426,23 @@ var PluginContext = class {
397
426
  tracing;
398
427
  staticCssJson;
399
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;
400
432
  /** Emission mode (the explicit `mode` option wins over the command); feeds
401
433
  * engine devMode and the minify default. Lifecycle stays on `isProd`. */
402
434
  emissionProd = false;
403
435
  rootDir = "";
404
436
  logger = null;
405
437
  system = emptySystemConfig();
438
+ /** Whether a system has loaded, so a failed reload has one to keep. */
439
+ systemLoaded = false;
406
440
  lcssTargets = {};
407
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;
408
446
  extensionsSet;
409
447
  excludeMatcher;
410
448
  storedManifest = null;
@@ -440,7 +478,8 @@ var PluginContext = class {
440
478
  engineApi: () => this.engineApi(),
441
479
  prefix: "[animus-extract]",
442
480
  strict: () => !!this.options.strict,
443
- warn: (message) => this.warn(message)
481
+ warn: (message) => this.warn(message),
482
+ reportErrors: () => this.reportErrors()
444
483
  });
445
484
  rawExtensionFallbacks = /* @__PURE__ */ new Set();
446
485
  /** Original path → hash of bytes whose parse aborted in a rejected attempt;
@@ -470,6 +509,10 @@ var PluginContext = class {
470
509
  assetResolutionFailures = /* @__PURE__ */ new Set();
471
510
  assetPassComplete = false;
472
511
  externalPackageDirs = [];
512
+ /** Those whose package is linked rather than installed. */
513
+ externalLinkedDirs = [];
514
+ /** Those read from their package's compiled output. */
515
+ externalOutputDirs = [];
473
516
  externalDirOwners = {};
474
517
  /** specifier → whether its redirected source entry has side effects, from
475
518
  * the owning package's `sideEffects`; absent leaves Vite's default. */
@@ -477,6 +520,8 @@ var PluginContext = class {
477
520
  externalFileOwners = {};
478
521
  externalSourceEntries = /* @__PURE__ */ new Map();
479
522
  externalPackageOutcomes = [];
523
+ /** The analysed kits' descriptors, from the last discovery. */
524
+ kitDescriptors = [];
480
525
  /** Configured files buildStart or a late rediscovery could not read.
481
526
  * Later analyses read no files themselves, so they replay these until the
482
527
  * file is read into the cache or deleted. */
@@ -546,8 +591,22 @@ var PluginContext = class {
546
591
  warn(msg) {
547
592
  (this.logger ?? console).warn(`[animus] ${msg}`);
548
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
+ }
549
607
  /** Load the system into `this.system`. On failure the previous config is
550
- * 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. */
551
610
  loadSystem() {
552
611
  this.resolvedSystemPath = (0, path.resolve)(this.rootDir, this.options.system);
553
612
  for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(this.resolvedSystemPath)) this.systemDependencyKeys.add(key);
@@ -556,23 +615,24 @@ var PluginContext = class {
556
615
  systemPath: this.resolvedSystemPath,
557
616
  rootDir: this.rootDir,
558
617
  prefix: this.options.prefix,
559
- prefixContextualVars: this.options.prefixContextualVars
618
+ prefixContextualVars: this.options.prefixContextualVars,
619
+ conditions: this.resolveConditions
560
620
  });
561
- const appManifest = (0, path.join)((0, _animus_ui_extract_pipeline.findPackageRoot)(this.resolvedSystemPath), "package.json");
562
- const manifests = /* @__PURE__ */ new Set();
563
- for (const dep of this.system.dependencies ?? []) {
564
- const manifest = (0, path.join)((0, _animus_ui_extract_pipeline.findPackageRoot)(dep), "package.json");
565
- if (manifest !== appManifest && (0, fs.existsSync)(manifest)) manifests.add(manifest);
566
- }
567
- const deps = [...this.system.dependencies ?? [], ...manifests];
621
+ const deps = this.system.dependencies ?? [];
568
622
  const keys = /* @__PURE__ */ new Set();
569
623
  for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(this.resolvedSystemPath)) keys.add(key);
570
624
  for (const dep of deps) for (const key of (0, _animus_ui_extract_pipeline.toWatchKeys)(dep)) keys.add(key);
571
625
  this.systemDependencyKeys = keys;
572
626
  this.systemDependencyPaths = deps;
573
627
  this.registerSystemWatchPaths();
628
+ this.systemLoaded = true;
574
629
  } catch (e) {
575
- 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
+ }
576
636
  console.warn(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}:`, e);
577
637
  }
578
638
  }
@@ -613,24 +673,34 @@ var PluginContext = class {
613
673
  analysisContext: {
614
674
  skippedSources: [...skippedOriginals, ...ingestionFailures.map((d) => d.file)].map((file) => (0, path.isAbsolute)(file) ? (0, path.relative)(this.rootDir, file) : file),
615
675
  unbundledComputedImports: true,
616
- 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))
617
679
  },
618
680
  warn: (m) => this.warn(m),
619
681
  info: (m) => this.log(m),
620
682
  strict: this.options.strict,
621
683
  diagnostics: this.options.diagnostics,
622
- extraDiagnostics: ingestionFailures
684
+ reportErrors: this.reportErrors(),
685
+ extraDiagnostics: ingestionFailures,
686
+ kitDescriptors: this.kitDescriptors
623
687
  });
624
688
  } catch (e) {
625
- if (this.options.strict || e instanceof _animus_ui_extract_pipeline.DiagnosticFailure) 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
+ }
626
696
  console.warn("[animus-extract] analyzeProject failed:", e);
627
697
  return false;
628
698
  }
629
- (0, _animus_ui_extract_pipeline.assertNoErrorDiagnostics)(result.manifest.diagnostics);
630
699
  this.assertRuntimeImportSuppliesTerminals(result.manifest);
631
700
  (0, _animus_ui_extract_pipeline.reportSurvivingAssetPlaceholders)((0, _animus_ui_extract_pipeline.generatedModuleCode)(result.manifest), {
632
701
  strict: this.options.strict,
633
702
  warn: (message) => this.warn(message),
703
+ reportErrors: this.reportErrors(),
634
704
  prefix: "[animus-extract]",
635
705
  surface: "generated runtime modules"
636
706
  });
@@ -744,8 +814,8 @@ var PluginContext = class {
744
814
  return `${this.base.endsWith("/") ? this.base.slice(0, -1) : this.base}/@fs${absPath}`;
745
815
  }
746
816
  assetFallback(specifier, message, cause) {
747
- if (this.options.strict) throw new Error(message, cause === void 0 ? void 0 : { cause });
748
- this.warn(message);
817
+ if (this.options.strict) this.strictFailure(message, cause);
818
+ else this.warn(message);
749
819
  this.assetUrlBySpecifier.set(specifier, specifier);
750
820
  this.assetResolutionFailures.add(specifier);
751
821
  }
@@ -821,7 +891,7 @@ var PluginContext = class {
821
891
  async performSystemReloadExclusive() {
822
892
  const resetStart = performance.now();
823
893
  this.systemReloadOwed = true;
824
- const { ok } = await this.analyzeIngested();
894
+ const { ok } = await this.analyzeIngested(await this.rediscoverSources?.());
825
895
  if (!ok) return;
826
896
  this.log(`HMR system reload complete: ${Math.round(performance.now() - resetStart)}ms`);
827
897
  }
@@ -867,12 +937,13 @@ var PluginContext = class {
867
937
  }, 100);
868
938
  }
869
939
  /** An unresolvable `.includes()` specifier or a stale dist entry under an
870
- * extended package warns, and fails the build under `strict`. */
940
+ * extended package warns, and fails the build under `strict` (strict
941
+ * development reports it). */
871
942
  enforceIncludeResolution() {
872
943
  for (const message of [(0, _animus_ui_extract_pipeline.unresolvableIncludesMessage)(this.externalPackageOutcomes), (0, _animus_ui_extract_pipeline.staleDistIncludesMessage)(this.externalPackageOutcomes)]) {
873
944
  if (message === null) continue;
874
- if (this.options.strict) throw new Error(message);
875
- this.warn(message);
945
+ if (this.options.strict) this.strictFailure(message);
946
+ else this.warn(message);
876
947
  }
877
948
  }
878
949
  enforceExternalTokenContracts() {
@@ -883,7 +954,8 @@ var PluginContext = class {
883
954
  sourceThemeManifestsJson: this.system.sourceThemeManifestsJson,
884
955
  strict: this.options.strict,
885
956
  prefix: "[animus-extract]",
886
- warn: (message) => this.warn(message)
957
+ warn: (message) => this.warn(message),
958
+ reportErrors: this.reportErrors()
887
959
  });
888
960
  }
889
961
  runSelfVerify() {
@@ -898,7 +970,10 @@ var PluginContext = class {
898
970
  });
899
971
  for (const message of failures) {
900
972
  const line = `[animus:verify] ${message}`;
901
- if (this.options.strict) throw new Error(line);
973
+ if (this.options.strict) {
974
+ this.strictFailure(line);
975
+ continue;
976
+ }
902
977
  if (this.logger) this.logger.warn(line, { timestamp: true });
903
978
  else console.warn(line);
904
979
  }
@@ -1174,8 +1249,8 @@ async function transformSource(ctx, code, id) {
1174
1249
  map: null
1175
1250
  };
1176
1251
  } catch (e) {
1177
- if (ctx.options.strict) throw new Error(`[animus-extract] Failed to transform ${id}: ${e}`, { cause: e });
1178
- 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);
1179
1254
  ctx.recordFallbackState(relativePath, true);
1180
1255
  return null;
1181
1256
  }
@@ -1453,6 +1528,7 @@ function loadVirtualModule(ctx, id) {
1453
1528
  (0, _animus_ui_extract_pipeline.reportSurvivingAssetPlaceholders)(css, {
1454
1529
  strict: ctx.options.strict,
1455
1530
  warn: (message) => ctx.warn(message),
1531
+ reportErrors: ctx.reportErrors(),
1456
1532
  prefix: "[animus-extract]"
1457
1533
  });
1458
1534
  return css;
@@ -1533,6 +1609,17 @@ if (import.meta.hot) {
1533
1609
  }
1534
1610
  //#endregion
1535
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
+ }
1536
1623
  function animusExtract(options) {
1537
1624
  (0, _animus_ui_extract_pipeline.assertNoRetiredEngineSelection)(options.engine);
1538
1625
  (0, _animus_ui_extract_pipeline.assertKnownOptionKeys)(options, ["verify", "appearanceBootstrap"], [{
@@ -1546,9 +1633,14 @@ function animusExtract(options) {
1546
1633
  return {
1547
1634
  name: "animus-extract",
1548
1635
  enforce: "pre",
1549
- config(_config, env) {
1636
+ config(userConfig, env) {
1550
1637
  const { mode } = (0, _animus_ui_extract_pipeline.resolveMode)(options.mode, () => env.command === "build" ? "production" : "development");
1551
- 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 };
1552
1644
  },
1553
1645
  configureServer(server) {
1554
1646
  ctx.devServer = server;
@@ -1566,8 +1658,17 @@ function animusExtract(options) {
1566
1658
  source
1567
1659
  }) : void 0);
1568
1660
  },
1569
- resolveId(id) {
1570
- 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
+ };
1571
1672
  },
1572
1673
  load(id) {
1573
1674
  return loadVirtualModule(ctx, id);
package/dist/index.d.ts CHANGED
@@ -21,15 +21,21 @@ 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;
28
32
  /**
29
- * Each `animus.*` code's level, by exact code or a prefix ending in `.*`
30
- * (`'animus.style.*'`): `'off'`, `'info'`, `'warn'` or `'error'`, which
31
- * fails the build. An exact code beats the longest matching prefix, and an
32
- * entry beats `strict` and the code's own severity.
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.
33
39
  */
34
40
  diagnostics?: DiagnosticLevels;
35
41
  /**
@@ -53,7 +59,9 @@ export interface AnimusExtractOptions {
53
59
  * selects production for `build` and development elsewhere.
54
60
  */
55
61
  mode?: 'development' | 'production';
56
- /** 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. */
57
65
  prefix?: string;
58
66
  /** With `prefix` set, contextual variables take the prefixed name
59
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,EACV,gBAAgB,EAChB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,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;;;;;OAKG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;;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,EAA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,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.23",
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.23",
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.23"
47
+ "@animus-ui/assertions": "0.1.24"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@mdx-js/mdx": "^3.0.0",