@animus-ui/vite-plugin 0.1.0 → 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=analyze-project-args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-project-args.d.ts","sourceRoot":"","sources":["../src/analyze-project-args.ts"],"names":[],"mappings":""}
@@ -1,12 +1,63 @@
1
- import { createRequire } from "node:module";
2
- import { DEFAULT_EXTENSIONS, applyUnitFallback, assembleStylesheet, extractSystemFilePackages, preprocessMdx, stripLeadingLayerDeclaration, validateLayerOrder } from "@animus-ui/extract/pipeline";
3
- import browserslist from "browserslist";
4
- import { createHash } from "crypto";
5
- import { existsSync, readFileSync, readdirSync, statSync } from "fs";
6
- import { browserslistToTargets, transform } from "lightningcss";
7
- import { dirname, extname, join, relative, resolve } from "path";
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
8
5
  //#region \0rolldown/runtime.js
9
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
28
+ let browserslist = require("browserslist");
29
+ browserslist = __toESM(browserslist);
30
+ let crypto = require("crypto");
31
+ let fs = require("fs");
32
+ let lightningcss = require("lightningcss");
33
+ let path = require("path");
34
+ //#region src/analyze-project-args.ts
35
+ /** @internal */
36
+ function buildAnalyzeProjectArgs(inputs) {
37
+ return [
38
+ inputs.filesJson,
39
+ inputs.scalesJson,
40
+ inputs.variableMapJson,
41
+ inputs.contextualVarsJson,
42
+ inputs.propConfigJson,
43
+ inputs.groupRegistryJson,
44
+ inputs.packageResolutionJson,
45
+ inputs.devMode,
46
+ inputs.emitterConfigJson,
47
+ inputs.selectorAliasesJson,
48
+ null,
49
+ inputs.globalStyleBlocksJson,
50
+ inputs.pathAliasesJson,
51
+ inputs.keyframesJson
52
+ ];
53
+ }
54
+ //#endregion
55
+ //#region src/manifest-diagnostics.ts
56
+ function surfaceManifestDiagnostics(manifest, warn) {
57
+ for (const diagnostic of manifest.diagnostics ?? []) if (diagnostic.kind === "bail") warn(`⚠ ${diagnostic.component} not extracted: ${diagnostic.message}`);
58
+ else if (diagnostic.kind === "skip") warn(`⚠ ${diagnostic.component}: skipped ${diagnostic.message}`);
59
+ else if (diagnostic.kind === "warn") warn(`⚠ ${diagnostic.file}: ${diagnostic.component}: ${diagnostic.message}`);
60
+ }
10
61
  //#endregion
11
62
  //#region src/index.ts
12
63
  const VIRTUAL_CSS_ID = "virtual:animus/styles.css";
@@ -27,22 +78,22 @@ function discoverFiles(dir, rootDir, excludePatterns, extensionsSet) {
27
78
  const results = [];
28
79
  let entries;
29
80
  try {
30
- entries = readdirSync(dir, { encoding: "utf8" });
81
+ entries = (0, fs.readdirSync)(dir, { encoding: "utf8" });
31
82
  } catch {
32
83
  return results;
33
84
  }
34
85
  for (const entry of entries) {
35
- const fullPath = join(dir, entry);
36
- const relativePath = relative(rootDir, fullPath);
86
+ const fullPath = (0, path.join)(dir, entry);
87
+ const relativePath = (0, path.relative)(rootDir, fullPath);
37
88
  if (excludePatterns.some((pattern) => fullPath.includes(pattern) || relativePath.includes(pattern))) continue;
38
89
  let stat;
39
90
  try {
40
- stat = statSync(fullPath);
91
+ stat = (0, fs.statSync)(fullPath);
41
92
  } catch {
42
93
  continue;
43
94
  }
44
95
  if (stat.isDirectory()) results.push(...discoverFiles(fullPath, rootDir, excludePatterns, extensionsSet));
45
- else if (extensionsSet.has(extname(entry))) results.push(fullPath);
96
+ else if (extensionsSet.has((0, path.extname)(entry))) results.push(fullPath);
46
97
  }
47
98
  return results;
48
99
  }
@@ -54,10 +105,10 @@ function resolveLightningTargets(explicitTargets, rootDir) {
54
105
  let queries;
55
106
  if (explicitTargets) queries = Array.isArray(explicitTargets) ? explicitTargets : [explicitTargets];
56
107
  else {
57
- const detected = browserslist(void 0, { path: rootDir });
58
- queries = detected.length > 0 ? detected : browserslist("defaults");
108
+ const detected = (0, browserslist.default)(void 0, { path: rootDir });
109
+ queries = detected.length > 0 ? detected : (0, browserslist.default)("defaults");
59
110
  }
60
- return browserslistToTargets(Array.isArray(queries) && typeof queries[0] === "string" && queries[0].includes(" ") ? browserslist(queries) : queries);
111
+ return (0, lightningcss.browserslistToTargets)(Array.isArray(queries) && typeof queries[0] === "string" && queries[0].includes(" ") ? (0, browserslist.default)(queries) : queries);
61
112
  }
62
113
  /**
63
114
  * Post-process CSS with Lightning CSS: autoprefixing + optional minification.
@@ -66,7 +117,7 @@ function resolveLightningTargets(explicitTargets, rootDir) {
66
117
  function postProcessCss(css, opts) {
67
118
  if (!css) return css;
68
119
  try {
69
- return transform({
120
+ return (0, lightningcss.transform)({
70
121
  filename: "animus-extracted.css",
71
122
  code: Buffer.from(css),
72
123
  minify: opts.minify,
@@ -80,7 +131,7 @@ function postProcessCss(css, opts) {
80
131
  }
81
132
  /** Compute MD5 content hash for a string. */
82
133
  function contentHash(source) {
83
- return createHash("md5").update(source).digest("hex");
134
+ return (0, crypto.createHash)("md5").update(source).digest("hex");
84
135
  }
85
136
  /**
86
137
  * Reconstruct file entries from cache, including content hashes.
@@ -90,21 +141,76 @@ function contentHash(source) {
90
141
  */
91
142
  function buildFileEntriesFromCache(cache, changedPath) {
92
143
  const entries = [];
93
- for (const [path, { hash, source }] of cache) entries.push({
94
- path,
95
- source: path === changedPath ? source : "",
144
+ for (const [path$1, { hash, source }] of cache) entries.push({
145
+ path: path$1,
146
+ source: path$1 === changedPath ? source : "",
96
147
  hash
97
148
  });
98
149
  return entries;
99
150
  }
100
151
  function animusExtract(options) {
152
+ const resolvedEngine = options.engine ?? "v2";
153
+ const engineModuleId = resolvedEngine === "v2" ? "@animus-ui/extract/engine-v2" : "@animus-ui/extract";
154
+ const requireEngine = () => require(engineModuleId);
155
+ let v2Engine = null;
156
+ const v2SentSources = /* @__PURE__ */ new Map();
157
+ let v2DriftWarned = false;
158
+ const engineApi = () => {
159
+ if (resolvedEngine !== "v2") return requireEngine();
160
+ const native = requireEngine();
161
+ return {
162
+ loadSystemModule: (...args) => native.loadSystemModule(...args),
163
+ analyzeProject: (filesJsonRaw, themeJson_, variableMapJson_, contextualVarsJson_, configJson_, groupRegistryJson_, packageResolutionJson_, devMode, emitterConfigJson, selectorAliasesJson_, _selectorOrderJson, globalStyleBlocksJson_, pathAliasesJson_, keyframesJson_) => {
164
+ let filesJson = filesJsonRaw;
165
+ if (filesJsonRaw.includes("\"source\":\"\"")) {
166
+ const entries = JSON.parse(filesJsonRaw);
167
+ for (const entry of entries) if (entry.source === "") entry.source = fileCache.get(entry.path)?.source ?? "";
168
+ filesJson = JSON.stringify(entries);
169
+ }
170
+ v2SentSources.clear();
171
+ for (const entry of JSON.parse(filesJson)) v2SentSources.set(entry.path, entry.source);
172
+ const emitterConfig = emitterConfigJson ? JSON.parse(emitterConfigJson) : {};
173
+ v2Engine = null;
174
+ const engine = new native.ExtractEngine({
175
+ runtimeImport: emitterConfig.runtime_import ?? void 0,
176
+ cssModuleId: emitterConfig.css_module_id ?? void 0,
177
+ systemPropsModuleId: emitterConfig.system_props_module_id ?? void 0,
178
+ themeJson: themeJson_,
179
+ variableMapJson: variableMapJson_,
180
+ contextualVarsJson: contextualVarsJson_ ?? void 0,
181
+ configJson: configJson_,
182
+ groupRegistryJson: groupRegistryJson_,
183
+ selectorAliasesJson: selectorAliasesJson_ ?? void 0,
184
+ globalStyleBlocksJson: globalStyleBlocksJson_ ?? void 0,
185
+ keyframesJson: keyframesJson_ ?? void 0,
186
+ packageResolutionJson: packageResolutionJson_ ?? void 0,
187
+ pathAliasesJson: pathAliasesJson_ ?? void 0,
188
+ devMode
189
+ });
190
+ v2Engine = engine;
191
+ return engine.analyze(filesJson);
192
+ },
193
+ transformFile: (source, path$2, _manifest) => {
194
+ if (!v2Engine) throw new Error("[animus-extract] v2 transform before analyze — engine state is per-instance");
195
+ const sent = v2SentSources.get(path$2);
196
+ if (sent !== void 0 && sent !== source && !v2DriftWarned) {
197
+ v2DriftWarned = true;
198
+ console.warn(`[animus-extract] v2: transform-time source for ${path$2} differs from analyze-time source — an upstream plugin transform may be reverted (engine v2 emits from analyzed sources)`);
199
+ }
200
+ return JSON.parse(v2Engine.transformFile(path$2));
201
+ },
202
+ clearAnalysisCache: () => {
203
+ if (v2Engine) v2Engine.clearCache();
204
+ v2Engine = null;
205
+ }
206
+ };
207
+ };
101
208
  let themeJson = "{}";
102
209
  let variableMapJson = "{}";
103
210
  let contextualVarsJson = "{}";
104
211
  let configJson = "{}";
105
212
  let groupRegistryJson = "{}";
106
213
  let selectorAliasesJson = null;
107
- let selectorOrderJson = null;
108
214
  let isProd = false;
109
215
  let rootDir = "";
110
216
  const verbose = options.verbose || process.env.ANIMUS_DEBUG === "1" || process.env.ANIMUS_DEBUG === "true";
@@ -142,7 +248,7 @@ function animusExtract(options) {
142
248
  let globalStyleBlocksJson = null;
143
249
  let keyframesBlocksJson = null;
144
250
  let pathAliasesJson = null;
145
- let extensionsSet = new Set(options.extensions ?? DEFAULT_EXTENSIONS);
251
+ let extensionsSet = new Set(options.extensions ?? _animus_ui_extract_pipeline.DEFAULT_EXTENSIONS);
146
252
  let storedManifest = null;
147
253
  let storedManifestJson = "";
148
254
  let resolvedComponentCss = "";
@@ -167,14 +273,13 @@ function animusExtract(options) {
167
273
  * rquickjs, and returns serialized config directly — no subprocess needed.
168
274
  */
169
275
  function loadSystem() {
170
- resolvedSystemPath = resolve(rootDir, options.system);
276
+ resolvedSystemPath = (0, path.resolve)(rootDir, options.system);
171
277
  try {
172
- const { loadSystemModule } = __require("@animus-ui/extract");
278
+ const { loadSystemModule } = engineApi();
173
279
  const config = loadSystemModule(resolvedSystemPath, rootDir);
174
280
  configJson = config.propConfig;
175
281
  groupRegistryJson = config.groupRegistry;
176
282
  selectorAliasesJson = config.selectorAliases || null;
177
- selectorOrderJson = config.selectorOrder || null;
178
283
  themeJson = config.scalesJson;
179
284
  variableMapJson = config.variableMapJson;
180
285
  variableCss = config.variableCss;
@@ -195,14 +300,29 @@ function animusExtract(options) {
195
300
  */
196
301
  function runAnalysis(fileEntries) {
197
302
  try {
198
- const { analyzeProject } = __require("@animus-ui/extract");
303
+ const { analyzeProject } = engineApi();
199
304
  const emitterConfig = JSON.stringify({
200
305
  runtime_import: "@animus-ui/system",
201
306
  css_module_id: "virtual:animus/styles.css"
202
307
  });
203
- const manifestJson = analyzeProject(JSON.stringify(fileEntries), themeJson, variableMapJson, contextualVarsJson || null, configJson, groupRegistryJson, JSON.stringify(packageMap), !isProd, emitterConfig, selectorAliasesJson, selectorOrderJson, globalStyleBlocksJson, pathAliasesJson, keyframesBlocksJson);
308
+ const manifestJson = analyzeProject(...buildAnalyzeProjectArgs({
309
+ filesJson: JSON.stringify(fileEntries),
310
+ scalesJson: themeJson,
311
+ variableMapJson,
312
+ contextualVarsJson: contextualVarsJson || null,
313
+ propConfigJson: configJson,
314
+ groupRegistryJson,
315
+ packageResolutionJson: JSON.stringify(packageMap),
316
+ devMode: !isProd,
317
+ emitterConfigJson: emitterConfig,
318
+ selectorAliasesJson,
319
+ globalStyleBlocksJson,
320
+ pathAliasesJson,
321
+ keyframesJson: keyframesBlocksJson
322
+ }));
204
323
  storedManifest = JSON.parse(manifestJson);
205
324
  storedManifestJson = manifestJson;
325
+ surfaceManifestDiagnostics(storedManifest, warn);
206
326
  storedSystemPropMapJson = JSON.stringify(storedManifest?.system_prop_map ?? {});
207
327
  const dynamicProps = storedManifest?.dynamic_props ?? {};
208
328
  const newDynamicPropsJson = JSON.stringify(dynamicProps);
@@ -228,7 +348,7 @@ function animusExtract(options) {
228
348
  storedSheets = storedManifest?.sheets ?? null;
229
349
  globalCss = storedManifest?.sheets?.global || "";
230
350
  resolvedComponentCss = storedManifest?.css || "";
231
- resolvedComponentCss = applyUnitFallback(resolvedComponentCss);
351
+ resolvedComponentCss = (0, _animus_ui_extract_pipeline.applyUnitFallback)(resolvedComponentCss);
232
352
  } catch (e) {
233
353
  if (options.strict) throw new Error(`[animus-extract] analyzeProject failed: ${e}`, { cause: e });
234
354
  console.warn("[animus-extract] analyzeProject failed:", e);
@@ -240,7 +360,7 @@ function animusExtract(options) {
240
360
  if (!variableCss.includes(":root")) failures.push("No :root variable block found in variable CSS");
241
361
  if (`${variableCss}\n${globalCss}\n${resolvedComponentCss}`.includes("__TRANSFORM__")) failures.push("Unresolved __TRANSFORM__ placeholders found in CSS output");
242
362
  if (storedManifest && resolvedComponentCss.length > 0) {
243
- const assembled = assembleStylesheet({
363
+ const assembled = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
244
364
  layers: options.layers,
245
365
  variableCss,
246
366
  globalCss,
@@ -306,13 +426,13 @@ function animusExtract(options) {
306
426
  },
307
427
  async buildStart() {
308
428
  try {
309
- const { clearAnalysisCache } = __require("@animus-ui/extract");
429
+ const { clearAnalysisCache } = engineApi();
310
430
  clearAnalysisCache();
311
431
  } catch {}
312
432
  let t0 = performance.now();
313
433
  loadSystem();
314
434
  if (options.layers) {
315
- validateLayerOrder(options.layers);
435
+ (0, _animus_ui_extract_pipeline.validateLayerOrder)(options.layers);
316
436
  log(`Custom layers: [${options.layers.join(", ")}]`);
317
437
  }
318
438
  if (verbose) {
@@ -322,16 +442,16 @@ function animusExtract(options) {
322
442
  }
323
443
  t0 = performance.now();
324
444
  const excludePatterns = options.exclude ?? DEFAULT_EXCLUDE;
325
- extensionsSet = new Set(options.extensions ?? DEFAULT_EXTENSIONS);
445
+ extensionsSet = new Set(options.extensions ?? _animus_ui_extract_pipeline.DEFAULT_EXTENSIONS);
326
446
  const shouldHandleMdx = extensionsSet.has(".mdx");
327
447
  let mdxMissingDepWarned = false;
328
448
  const filePaths = discoverFiles(rootDir, rootDir, excludePatterns, extensionsSet);
329
449
  const fileEntries = [];
330
450
  for (const filePath of filePaths) try {
331
- let source = readFileSync(filePath, "utf-8");
332
- let relPath = relative(rootDir, filePath);
333
- if (shouldHandleMdx && extname(filePath) === ".mdx") {
334
- const result = await preprocessMdx(source, relPath);
451
+ let source = (0, fs.readFileSync)(filePath, "utf-8");
452
+ let relPath = (0, path.relative)(rootDir, filePath);
453
+ if (shouldHandleMdx && (0, path.extname)(filePath) === ".mdx") {
454
+ const result = await (0, _animus_ui_extract_pipeline.preprocessMdx)(source, relPath);
335
455
  if (result.kind === "missing-dep") {
336
456
  if (!mdxMissingDepWarned) {
337
457
  warn("⚠ .mdx in extensions but @mdx-js/mdx not installed; MDX files skipped");
@@ -358,7 +478,7 @@ function animusExtract(options) {
358
478
  });
359
479
  } catch {}
360
480
  const localFileCount = fileEntries.length;
361
- const packageSpecifiers = extractSystemFilePackages(resolvedSystemPath);
481
+ const packageSpecifiers = (0, _animus_ui_extract_pipeline.extractSystemFilePackages)(resolvedSystemPath);
362
482
  packageMap = {};
363
483
  externalSourceEntries.clear();
364
484
  const collectedPkgDirs = [];
@@ -366,18 +486,18 @@ function animusExtract(options) {
366
486
  const resolved = await this.resolve(specifier);
367
487
  if (resolved && resolved.id) {
368
488
  const absPath = resolved.id;
369
- let pkgRoot = dirname(absPath);
370
- while (pkgRoot !== dirname(pkgRoot) && !existsSync(join(pkgRoot, "package.json"))) pkgRoot = dirname(pkgRoot);
371
- const srcDir = join(pkgRoot, "src");
372
- if (existsSync(srcDir)) {
489
+ let pkgRoot = (0, path.dirname)(absPath);
490
+ while (pkgRoot !== (0, path.dirname)(pkgRoot) && !(0, fs.existsSync)((0, path.join)(pkgRoot, "package.json"))) pkgRoot = (0, path.dirname)(pkgRoot);
491
+ const srcDir = (0, path.join)(pkgRoot, "src");
492
+ if ((0, fs.existsSync)(srcDir)) {
373
493
  collectedPkgDirs.push(srcDir);
374
494
  const pkgFiles = discoverFiles(srcDir, rootDir, excludePatterns, extensionsSet);
375
495
  for (const pkgFile of pkgFiles) {
376
- let pkgRelPath = relative(rootDir, pkgFile);
496
+ let pkgRelPath = (0, path.relative)(rootDir, pkgFile);
377
497
  if (!fileEntries.some((e) => e.path === pkgRelPath)) {
378
- let pkgSource = readFileSync(pkgFile, "utf-8");
379
- if (shouldHandleMdx && extname(pkgFile) === ".mdx") {
380
- const result = await preprocessMdx(pkgSource, pkgRelPath);
498
+ let pkgSource = (0, fs.readFileSync)(pkgFile, "utf-8");
499
+ if (shouldHandleMdx && (0, path.extname)(pkgFile) === ".mdx") {
500
+ const result = await (0, _animus_ui_extract_pipeline.preprocessMdx)(pkgSource, pkgRelPath);
381
501
  if (result.kind === "missing-dep") {
382
502
  if (!mdxMissingDepWarned) {
383
503
  warn("⚠ .mdx in extensions but @mdx-js/mdx not installed; MDX files skipped");
@@ -404,15 +524,15 @@ function animusExtract(options) {
404
524
  });
405
525
  }
406
526
  }
407
- const srcEntry = join(srcDir, "index.ts");
408
- if (existsSync(srcEntry)) {
409
- packageMap[specifier] = relative(rootDir, srcEntry);
527
+ const srcEntry = (0, path.join)(srcDir, "index.ts");
528
+ if ((0, fs.existsSync)(srcEntry)) {
529
+ packageMap[specifier] = (0, path.relative)(rootDir, srcEntry);
410
530
  externalSourceEntries.set(specifier, srcEntry);
411
- } else packageMap[specifier] = relative(rootDir, absPath);
531
+ } else packageMap[specifier] = (0, path.relative)(rootDir, absPath);
412
532
  } else {
413
- const relPath = relative(rootDir, absPath);
533
+ const relPath = (0, path.relative)(rootDir, absPath);
414
534
  if (!fileEntries.some((e) => e.path === relPath)) {
415
- const entrySource = readFileSync(absPath, "utf-8");
535
+ const entrySource = (0, fs.readFileSync)(absPath, "utf-8");
416
536
  const entryHash = !isProd ? contentHash(entrySource) : void 0;
417
537
  fileEntries.push({
418
538
  path: relPath,
@@ -424,7 +544,7 @@ function animusExtract(options) {
424
544
  source: entrySource
425
545
  });
426
546
  }
427
- collectedPkgDirs.push(dirname(absPath));
547
+ collectedPkgDirs.push((0, path.dirname)(absPath));
428
548
  packageMap[specifier] = relPath;
429
549
  }
430
550
  }
@@ -446,12 +566,9 @@ function animusExtract(options) {
446
566
  else if (d.kind === "variant") warn(`⚠ ${d.component} variant '${d.name}' pruned: ${d.reason}`);
447
567
  else if (d.kind === "state") warn(`⚠ ${d.component} state '${d.name}' pruned: ${d.reason}`);
448
568
  }
449
- const diagnostics = storedManifest.diagnostics || [];
450
- for (const d of diagnostics) if (d.kind === "bail") warn(`⚠ ${d.component} not extracted: ${d.message}`);
451
- else if (d.kind === "skip") warn(`⚠ ${d.component}: skipped ${d.message}`);
452
569
  log(`CSS: ${resolvedComponentCss.length} bytes (${Object.keys(storedManifest.components || {}).length} components)`);
453
570
  if (!isProd && storedSheets) {
454
- const staticSize = assembleStylesheet({
571
+ const staticSize = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
455
572
  layers: options.layers,
456
573
  variableCss,
457
574
  globalCss
@@ -460,7 +577,7 @@ function animusExtract(options) {
460
577
  log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
461
578
  } else log("Delivery: single file mode (production)");
462
579
  }
463
- const { declaration } = assembleStylesheet({
580
+ const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
464
581
  layers: options.layers,
465
582
  variableCss: "",
466
583
  globalCss: "",
@@ -486,7 +603,7 @@ function animusExtract(options) {
486
603
  };
487
604
  if (id === RESOLVED_CSS_ID) {
488
605
  if (!isProd && storedSheets) {
489
- const { variables, body } = assembleStylesheet({
606
+ const { variables, body } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
490
607
  layers: options.layers,
491
608
  variableCss,
492
609
  globalCss,
@@ -497,7 +614,7 @@ function animusExtract(options) {
497
614
  minify: false
498
615
  })].filter(Boolean).join("\n");
499
616
  }
500
- const { variables, body } = assembleStylesheet({
617
+ const { variables, body } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
501
618
  layers: options.layers,
502
619
  variableCss,
503
620
  globalCss,
@@ -506,14 +623,14 @@ function animusExtract(options) {
506
623
  });
507
624
  return [variables, postProcessCss(body, lcssOpts)].filter(Boolean).join("\n");
508
625
  }
509
- if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss(stripLeadingLayerDeclaration(resolvedComponentCss || ""), {
626
+ if (id === RESOLVED_COMPONENTS_ID) return `export default \`${postProcessCss((0, _animus_ui_extract_pipeline.stripLeadingLayerDeclaration)(resolvedComponentCss || ""), {
510
627
  ...lcssOpts,
511
628
  minify: false
512
629
  }).replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;`;
513
630
  if (id === RESOLVED_BRIDGE_ID) return `
514
631
  import css from '${VIRTUAL_COMPONENTS_ID}';
515
632
 
516
- const GLOBAL_KEY = '__animus_sheet_${createHash("md5").update(options.system).digest("hex").slice(0, 8)}__';
633
+ const GLOBAL_KEY = '__animus_sheet_${(0, crypto.createHash)("md5").update(options.system).digest("hex").slice(0, 8)}__';
517
634
  let sheet = globalThis[GLOBAL_KEY] || null;
518
635
 
519
636
  if (typeof CSSStyleSheet !== 'undefined' && 'adoptedStyleSheets' in document) {
@@ -569,7 +686,7 @@ if (import.meta.hot) {
569
686
  if (!/\.[jt]sx?$/.test(id)) return null;
570
687
  if (id.includes("node_modules")) return null;
571
688
  }
572
- const relativePath = relative(rootDir, id);
689
+ const relativePath = (0, path.relative)(rootDir, id);
573
690
  if (!storedManifest.files?.[relativePath]?.length) {
574
691
  if (!isProd && !fileCache.has(relativePath)) {
575
692
  const hash = contentHash(code);
@@ -593,7 +710,7 @@ if (import.meta.hot) {
593
710
  if (!storedManifest.files?.[relativePath]?.length) return null;
594
711
  }
595
712
  try {
596
- const { transformFile } = __require("@animus-ui/extract");
713
+ const { transformFile } = engineApi();
597
714
  const result = transformFile(code, relativePath, storedManifestJson);
598
715
  if (!result.hasComponents) return null;
599
716
  let transformedCode = result.code;
@@ -627,23 +744,23 @@ if (import.meta.hot) {
627
744
  },
628
745
  async handleHotUpdate({ file, server: hmrServer, modules }) {
629
746
  if (isProd) return;
630
- const ext = extname(file);
747
+ const ext = (0, path.extname)(file);
631
748
  if (!extensionsSet.has(ext)) return;
632
749
  const excludePatterns = options.exclude ?? DEFAULT_EXCLUDE;
633
- if (!externalPackageDirs.some((dir) => file.startsWith(dir)) && excludePatterns.some((pattern) => file.includes(pattern) || relative(rootDir, file).includes(pattern))) return;
634
- const absFile = resolve(file);
635
- const relPath = relative(rootDir, absFile);
636
- if (resolvedSystemPath && absFile === resolve(resolvedSystemPath)) {
750
+ if (!externalPackageDirs.some((dir) => file.startsWith(dir)) && excludePatterns.some((pattern) => file.includes(pattern) || (0, path.relative)(rootDir, file).includes(pattern))) return;
751
+ const absFile = (0, path.resolve)(file);
752
+ const relPath = (0, path.relative)(rootDir, absFile);
753
+ if (resolvedSystemPath && absFile === (0, path.resolve)(resolvedSystemPath)) {
637
754
  const resetStart = performance.now();
638
755
  log(`HMR geological reset: ${relPath}`);
639
756
  loadSystem();
640
757
  try {
641
- const { clearAnalysisCache } = __require("@animus-ui/extract");
758
+ const { clearAnalysisCache } = engineApi();
642
759
  clearAnalysisCache();
643
760
  } catch {}
644
761
  const fileEntries = [];
645
- for (const [path, { hash, source }] of fileCache) fileEntries.push({
646
- path,
762
+ for (const [path$3, { hash, source }] of fileCache) fileEntries.push({
763
+ path: path$3,
647
764
  source,
648
765
  hash
649
766
  });
@@ -669,13 +786,13 @@ if (import.meta.hot) {
669
786
  }
670
787
  let source;
671
788
  try {
672
- source = readFileSync(absFile, "utf-8");
789
+ source = (0, fs.readFileSync)(absFile, "utf-8");
673
790
  } catch {
674
791
  return;
675
792
  }
676
793
  let scannerRelPath = relPath;
677
794
  if (ext === ".mdx") {
678
- const result = await preprocessMdx(source, relPath);
795
+ const result = await (0, _animus_ui_extract_pipeline.preprocessMdx)(source, relPath);
679
796
  if (result.kind === "missing-dep") {
680
797
  warn("⚠ .mdx HMR skipped: @mdx-js/mdx not installed; restart dev server after installing");
681
798
  return;
@@ -732,7 +849,7 @@ if (import.meta.hot) {
732
849
  const staleFiles = /* @__PURE__ */ new Set();
733
850
  for (const [id, desc] of Object.entries(storedManifest.components)) if ((desc.replacement ?? "") !== (prevReplacements.get(id) ?? "")) staleFiles.add(desc.file);
734
851
  for (const defFile of staleFiles) {
735
- const absDefPath = resolve(rootDir, defFile);
852
+ const absDefPath = (0, path.resolve)(rootDir, defFile);
736
853
  if (absDefPath === absFile) continue;
737
854
  const defModule = hmrServer.moduleGraph.getModuleById(absDefPath) ?? hmrServer.moduleGraph.getModulesByFile(absDefPath)?.values().next().value;
738
855
  if (defModule) {
@@ -750,4 +867,6 @@ if (import.meta.hot) {
750
867
  };
751
868
  }
752
869
  //#endregion
753
- export { animusExtract, animusExtract as default, discoverFiles };
870
+ exports.animusExtract = animusExtract;
871
+ exports.default = animusExtract;
872
+ exports.discoverFiles = discoverFiles;
package/dist/index.d.ts CHANGED
@@ -54,6 +54,15 @@ export interface AnimusExtractOptions {
54
54
  * Example: `['reset', 'anm-global', 'anm-base', ..., 'anm-custom', 'overrides']`
55
55
  */
56
56
  layers?: string[];
57
+ /**
58
+ * Extraction engine selection. `'v2'` (default) is the production
59
+ * engine — parity-proven against v1 with 8× fewer parses and no cache
60
+ * machinery. `'v1'` remains selectable and functional as the escape
61
+ * hatch until v1 retires.
62
+ *
63
+ * @default 'v2'
64
+ */
65
+ engine?: 'v1' | 'v2';
57
66
  }
58
67
  export declare function discoverFiles(dir: string, rootDir: string, excludePatterns: string[], extensionsSet: ReadonlySet<string>): string[];
59
68
  export declare function animusExtract(options: AnimusExtractOptions): Plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAgBD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,EAAE,CAqCV;AAqFD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA2rCnE;eAEc,aAAa"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAgBD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,EAAE,CAqCV;AAqFD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAgzCnE;eAEc,aAAa"}
@@ -0,0 +1,10 @@
1
+ export type ManifestDiagnostic = {
2
+ file: string;
3
+ component: string;
4
+ kind: string;
5
+ message: string;
6
+ };
7
+ export declare function surfaceManifestDiagnostics(manifest: {
8
+ diagnostics?: ManifestDiagnostic[];
9
+ }, warn: (message: string) => void): void;
10
+ //# sourceMappingURL=manifest-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-diagnostics.d.ts","sourceRoot":"","sources":["../src/manifest-diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE;IAAE,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAE,EAChD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAC9B,IAAI,CAYN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Animus static CSS extraction Vite plugin",
5
5
  "keywords": [
6
6
  "animus",
@@ -22,9 +22,14 @@
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
- "main": "./dist/index.mjs",
26
- "module": "./dist/index.mjs",
25
+ "main": "./dist/index.cjs",
27
26
  "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.cjs"
31
+ }
32
+ },
28
33
  "publishConfig": {
29
34
  "access": "public"
30
35
  },
@@ -34,13 +39,13 @@
34
39
  "compile": "tsgo --noEmit"
35
40
  },
36
41
  "dependencies": {
37
- "@animus-ui/extract": "0.1.0",
42
+ "@animus-ui/extract": "0.1.1",
38
43
  "browserslist": "^4.24.0",
39
44
  "lightningcss": "^1.29.0"
40
45
  },
41
46
  "peerDependencies": {
42
47
  "@mdx-js/mdx": "^3.0.0",
43
- "vite": ">=5.0.0"
48
+ "vite": ">=8 <9"
44
49
  },
45
50
  "peerDependenciesMeta": {
46
51
  "@mdx-js/mdx": {