@animus-ui/next-plugin 0.1.8 → 0.1.9

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.
@@ -64,6 +64,9 @@ export declare class ExtractionSession {
64
64
  * ownership, design D2; duplicate specifiers resolving to one canonical
65
65
  * root share it). Engine watch wiring and tests read this. */
66
66
  externalRootOwners: Map<string, Set<string>>;
67
+ /** Canonical external root → the extension set its collection walk used
68
+ * (widened for dist-only roots); rewalks and classification share it. */
69
+ private externalRootExtensions;
67
70
  /** Canonical admitted external watch roots — the engine-side watch
68
71
  * surface (webpack contextDependencies / Turbopack watchers). */
69
72
  externalWatchRoots: string[];
@@ -160,6 +163,14 @@ export declare class ExtractionSession {
160
163
  * joiner; the gate always clears.
161
164
  */
162
165
  handleWatchUpdate(changes: WatchChanges): Promise<void>;
166
+ /**
167
+ * Owner-side entry for a batch observed by a NON-OWNING compiler's
168
+ * watcher. Serializes behind any in-flight transaction, then runs the
169
+ * forwarded batch as its own transaction — never drops it (a forwarded
170
+ * batch has no other delivery; content-hash diffing makes an
171
+ * already-covered batch a cheap no-op).
172
+ */
173
+ ingestForwardedBatch(changes: WatchChanges): Promise<void>;
163
174
  /**
164
175
  * Incremental watch pass: geological reset when the system file changed,
165
176
  * otherwise content-hash diffing restricted to the watcher's change sets
@@ -1 +1 @@
1
- {"version":3,"file":"extraction-session.d.ts","sourceRoot":"","sources":["../src/extraction-session.ts"],"names":[],"mappings":"AA2FA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AASjD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAgCzD,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAiB;IAC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;;;;;;;;;;;;;;;;;;OAsBG;YACW,cAAc;YA8Bd,qBAAqB;IA4NnC;4EACwE;IACxE,OAAO,CAAC,kBAAkB;IAO1B;kDAC8C;IAC9C,OAAO,CAAC,mBAAmB;IAoB3B;;;;;OAKG;IACH,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CA+BzD;IAED,sEAAsE;IACtE,OAAO,CAAC,4BAA4B,CAAS;IAE7C;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAyB9B;6EACyE;IACzE,OAAO,CAAC,iBAAiB;IAqBzB,2EAA2E;IAC3E,OAAO,CAAC,kBAAkB;IAe1B;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAiC7B;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA4B/B;;;;;;;;;;;;;OAaG;IACH;8DAC0D;IAC1D,OAAO,CAAC,oBAAoB,CAAqB;IACjD;4EACwE;IACxE,OAAO,CAAC,cAAc,CAAuD;IAE7E,OAAO,CAAC,sBAAsB;IA8C9B;0DACsD;IACtD,OAAO,CAAC,cAAc;IAatB;;;qEAGiE;IACjE,OAAO,CAAC,sBAAsB;IA+B9B;;;;4EAIwE;IACxE,OAAO,CAAC,oBAAoB;IAU5B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,yBAAyB;IA2EjC,OAAO,CAAC,oBAAoB;IAK5B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;CA0B9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAC5B,IAAI,CAgBN"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_session_paths = require("./session-paths-CZoi19NW.cjs");
3
- const require_singleton = require("./singleton-D4vhawsW.cjs");
3
+ const require_singleton = require("./singleton-BjZyw_8b.cjs");
4
4
  require("./turbopack-loader.cjs");
5
5
  let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
6
6
  let fs = require("fs");
@@ -174,6 +174,9 @@ var ExtractionSession = class {
174
174
  * ownership, design D2; duplicate specifiers resolving to one canonical
175
175
  * root share it). Engine watch wiring and tests read this. */
176
176
  externalRootOwners = /* @__PURE__ */ new Map();
177
+ /** Canonical external root → the extension set its collection walk used
178
+ * (widened for dist-only roots); rewalks and classification share it. */
179
+ externalRootExtensions = /* @__PURE__ */ new Map();
177
180
  /** Canonical admitted external watch roots — the engine-side watch
178
181
  * surface (webpack contextDependencies / Turbopack watchers). */
179
182
  externalWatchRoots = [];
@@ -304,7 +307,34 @@ var ExtractionSession = class {
304
307
  await inflight;
305
308
  return;
306
309
  }
310
+ if (!this.system) {
311
+ const owner = require_singleton.getOwningWatchSession();
312
+ const hasBatch = (changes.modifiedFiles?.size ?? 0) > 0 || (changes.removedFiles?.size ?? 0) > 0;
313
+ if (owner && owner !== this && hasBatch) await owner.ingestForwardedBatch(changes);
314
+ return;
315
+ }
316
+ const transaction = this.processWatchUpdate(changes);
317
+ require_singleton.setWatchTransaction(transaction);
318
+ try {
319
+ await transaction;
320
+ } finally {
321
+ require_singleton.setWatchTransaction(null);
322
+ }
323
+ }
324
+ /**
325
+ * Owner-side entry for a batch observed by a NON-OWNING compiler's
326
+ * watcher. Serializes behind any in-flight transaction, then runs the
327
+ * forwarded batch as its own transaction — never drops it (a forwarded
328
+ * batch has no other delivery; content-hash diffing makes an
329
+ * already-covered batch a cheap no-op).
330
+ */
331
+ async ingestForwardedBatch(changes) {
307
332
  if (!this.system) return;
333
+ for (;;) {
334
+ const inflight = require_singleton.getWatchTransaction();
335
+ if (!inflight) break;
336
+ await inflight;
337
+ }
308
338
  const transaction = this.processWatchUpdate(changes);
309
339
  require_singleton.setWatchTransaction(transaction);
310
340
  try {
@@ -361,6 +391,7 @@ var ExtractionSession = class {
361
391
  if (!priorCacheEntries.has(key)) priorCacheEntries.set(key, this.fileCache.get(key) ?? null);
362
392
  };
363
393
  const inventoryUpdates = [];
394
+ const ownerRemovals = [];
364
395
  let removedAny = false;
365
396
  if (changes.removedFiles) for (const removedPath of changes.removedFiles) {
366
397
  let key;
@@ -383,8 +414,7 @@ var ExtractionSession = class {
383
414
  hash: null,
384
415
  abs: removedPath
385
416
  });
386
- delete this.externalFileOwners[key];
387
- delete this.externalFileOwners[key + ".tsx"];
417
+ ownerRemovals.push(key, key + ".tsx");
388
418
  }
389
419
  }
390
420
  }
@@ -468,6 +498,7 @@ var ExtractionSession = class {
468
498
  abs: update.abs
469
499
  });
470
500
  }
501
+ for (const key of ownerRemovals) delete this.externalFileOwners[key];
471
502
  } else if (this.statusAttemptOpen) {
472
503
  this.debouncePending.clear();
473
504
  this.writeAnalysisStatus("idle", []);
@@ -626,11 +657,14 @@ var ExtractionSession = class {
626
657
  const admitted = (0, _animus_ui_extract_pipeline.excludeCollectedPackages)(collected, rejectedSpecifiers, rootDir);
627
658
  const identity = (0, _animus_ui_extract_pipeline.createSourceIdentity)(rootDir);
628
659
  this.externalRootOwners = /* @__PURE__ */ new Map();
660
+ this.externalRootExtensions = /* @__PURE__ */ new Map();
629
661
  for (const [dir, specifiers] of Object.entries(admitted.dirOwnerSets)) {
630
662
  const canonical = identity.registerExternalRoot(dir);
631
663
  const owners = this.externalRootOwners.get(canonical) ?? /* @__PURE__ */ new Set();
632
664
  for (const specifier of specifiers) owners.add(specifier);
633
665
  this.externalRootOwners.set(canonical, owners);
666
+ const exts = admitted.dirExtensions[dir];
667
+ if (exts) this.externalRootExtensions.set(canonical, new Set(exts));
634
668
  }
635
669
  this.sourceIdentity = identity;
636
670
  this.externalWatchRoots = identity.externalRoots();
@@ -673,12 +707,13 @@ var ExtractionSession = class {
673
707
  const merge = (0, _animus_ui_extract_pipeline.mergeExternalKeyframes)((entry, root) => api.scanKeyframesExports(entry, root), this.system.keyframesJson, admitted.keyframesScanEntries.values(), this.rootDir);
674
708
  this.system.keyframesJson = merge.keyframesJson;
675
709
  this.externalKeyframesDiagnostics = merge.diagnostics;
676
- }
710
+ } else this.externalKeyframesDiagnostics = [];
677
711
  bt.packageResolve = this.elapsed(t);
678
712
  const universe = new Set(fileEntries.map((entry) => entry.path));
679
713
  for (const key of [...this.fileCache.keys()]) if (!universe.has(key)) this.fileCache.delete(key);
680
714
  await this.analyzeAndEmit(fileEntries, packageMap, false, bt, pipelineStart, pending);
681
715
  this.onExternalRootsCommitted?.(this.externalWatchRoots);
716
+ require_singleton.setOwningWatchSession(this);
682
717
  }
683
718
  /**
684
719
  * Reset analysis state for HMR geological reset. Payload write guards go
@@ -759,7 +794,8 @@ var ExtractionSession = class {
759
794
  for (const root of dirtyRoots) {
760
795
  const previous = this.externalInventory.get(root) ?? /* @__PURE__ */ new Map();
761
796
  const seen = /* @__PURE__ */ new Set();
762
- const walked = (0, _animus_ui_extract_pipeline.walkPackageSources)(root, extensionsSet);
797
+ const walked = (0, _animus_ui_extract_pipeline.walkPackageSources)(root, this.externalRootExtensions.get(root) ?? extensionsSet);
798
+ if (walked.length === 0 && previous.size > 0) this.warn(`external root rewalk found no files under ${root} while its inventory holds ${previous.size} — reconciling as full deletion`);
763
799
  for (const abs of walked) {
764
800
  const resolved = identity.resolveSourceId(abs);
765
801
  if (!resolved || resolved.owningRoot !== root) continue;
@@ -788,9 +824,10 @@ var ExtractionSession = class {
788
824
  * Returns null for dropped paths.
789
825
  */
790
826
  classifyWatchPath(absPath, scan) {
791
- if (!scan.extensionsSet.has((0, path.extname)(absPath))) return null;
827
+ const ext = (0, path.extname)(absPath);
792
828
  const rootDir = this.rootDir;
793
829
  if ((0, _animus_ui_extract_pipeline.isPathWithinRoot)(rootDir, absPath)) {
830
+ if (!scan.extensionsSet.has(ext)) return null;
794
831
  const rel = (0, path.relative)(rootDir, absPath);
795
832
  if (scan.excludePatterns.some((pattern) => absPath.includes(pattern) || rel.includes(pattern))) return null;
796
833
  return {
@@ -801,12 +838,14 @@ var ExtractionSession = class {
801
838
  const resolved = this.sourceIdentity?.resolveSourceId(absPath);
802
839
  if (!resolved) return null;
803
840
  if (resolved.owningRoot === null) {
841
+ if (!scan.extensionsSet.has(ext)) return null;
804
842
  if (scan.excludePatterns.some((pattern) => resolved.sourceKey.includes(pattern))) return null;
805
843
  return {
806
844
  key: resolved.sourceKey,
807
845
  owningRoot: null
808
846
  };
809
847
  }
848
+ if (!(this.externalRootExtensions.get(resolved.owningRoot) ?? scan.extensionsSet).has(ext)) return null;
810
849
  if ((0, _animus_ui_extract_pipeline.isExcludedPackageRelativePath)(resolved.pathInRoot)) return null;
811
850
  return {
812
851
  key: resolved.sourceKey,
@@ -895,6 +934,7 @@ var ExtractionSession = class {
895
934
  strict: this.options.strict,
896
935
  extraDiagnostics: this.externalKeyframesDiagnostics
897
936
  });
937
+ (0, _animus_ui_extract_pipeline.assertNoErrorDiagnostics)(result.manifest?.diagnostics);
898
938
  (0, _animus_ui_extract_pipeline.enforceExternalTokenContracts)({
899
939
  diagnostics: result.manifest?.diagnostics,
900
940
  fileOwners: this.externalFileOwners,
@@ -1001,7 +1041,11 @@ var ExtractionSession = class {
1001
1041
  queueMicrotask(() => {
1002
1042
  this.debounceStatusWriteScheduled = false;
1003
1043
  if (this.debouncePending.size === 0) return;
1004
- this.writeAnalysisStatus("debouncing", [...this.debouncePending.entries()]);
1044
+ try {
1045
+ this.writeAnalysisStatus("debouncing", [...this.debouncePending.entries()]);
1046
+ } catch (err) {
1047
+ this.warn(`debounce status write failed: ${String(err)}`);
1048
+ }
1005
1049
  });
1006
1050
  }
1007
1051
  /** One pending microtask flushes a burst of debounce observations. */
@@ -1097,13 +1141,14 @@ var ExtractionSession = class {
1097
1141
  * artifacts (below) — the webpack cold-cache validity witness.
1098
1142
  */
1099
1143
  publishReplacementEpoch(epoch) {
1100
- if (this.lastEpochValue === null) this.lastEpochValue = this.diskEpochValue();
1144
+ const onDisk = this.diskEpochValue();
1145
+ if (this.lastEpochValue === null) this.lastEpochValue = onDisk;
1146
+ if (epoch !== onDisk) this.writeSessionArtifact(require_session_paths.REPLACEMENT_EPOCH_ARTIFACT, JSON.stringify({
1147
+ schema: 1,
1148
+ sessionId: this.sessionId,
1149
+ epoch
1150
+ }));
1101
1151
  if (epoch !== this.lastEpochValue) {
1102
- this.writeSessionArtifact(require_session_paths.REPLACEMENT_EPOCH_ARTIFACT, JSON.stringify({
1103
- schema: 1,
1104
- sessionId: this.sessionId,
1105
- epoch
1106
- }));
1107
1152
  this.lastEpochValue = epoch;
1108
1153
  this.reconcileSiblingEpochs(epoch);
1109
1154
  }
@@ -1487,7 +1532,7 @@ var AnimusWebpackPlugin = class {
1487
1532
  });
1488
1533
  });
1489
1534
  compiler.hooks.run.tapPromise(PLUGIN_NAME, async (_compiler) => {
1490
- this.session.rootDir = _compiler.context;
1535
+ this.adoptCompilerContext(_compiler);
1491
1536
  this.extractAliases(_compiler);
1492
1537
  const existing = require_singleton.getAnalysisPromise();
1493
1538
  if (existing) {
@@ -1499,7 +1544,7 @@ var AnimusWebpackPlugin = class {
1499
1544
  await promise;
1500
1545
  });
1501
1546
  compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (_compiler) => {
1502
- this.session.rootDir = _compiler.context;
1547
+ this.adoptCompilerContext(_compiler);
1503
1548
  this.extractAliases(_compiler);
1504
1549
  if (!this.initialized) {
1505
1550
  const existing = require_singleton.getAnalysisPromise();
@@ -1534,11 +1579,34 @@ var AnimusWebpackPlugin = class {
1534
1579
  return this.session.sessionId;
1535
1580
  }
1536
1581
  /** Set the project root at CONFIG time (with-animus) — the ONE root all
1537
- * session-path derivations use. The compiler hooks re-assert it from
1538
- * compiler.context (identical when compiler.context === cwd). */
1582
+ * session-path derivations use. The compiler hooks ADOPT
1583
+ * compiler.context only when no root was published (bare-apply
1584
+ * harnesses); they never overwrite this. */
1539
1585
  setRootDir(rootDir) {
1540
1586
  this.session.rootDir = rootDir;
1541
1587
  }
1588
+ /** One warning per plugin instance for a context/root mismatch. */
1589
+ warnedRootDivergence = false;
1590
+ /** The run/watchRun taps' root handling: adopt compiler.context when no
1591
+ * config-time root exists; otherwise KEEP the configured root — every
1592
+ * frozen config-time derivation (stub path, css alias target,
1593
+ * virtual:animus/system-props target, watch-ignore) came from it, and a
1594
+ * silent overwrite re-keys sessionDir so the pipeline publishes
1595
+ * artifacts where none of those consumers look. A disagreement is
1596
+ * surfaced loudly instead (with-animus derives the root from Next's own
1597
+ * `dir`, which equals compiler.context in real Next runs — a mismatch
1598
+ * means a custom-webpack setup wired the plugin differently). */
1599
+ adoptCompilerContext(compiler) {
1600
+ const context = compiler.context;
1601
+ if (!this.session.rootDir) {
1602
+ this.session.rootDir = context;
1603
+ return;
1604
+ }
1605
+ if (context && this.session.rootDir !== context && !this.warnedRootDivergence) {
1606
+ this.warnedRootDivergence = true;
1607
+ console.warn(`[animus-extract] compiler.context (${context}) differs from the configured project root (${this.session.rootDir}); keeping the configured root — run next against the app directory (or align your custom webpack context) so both agree`);
1608
+ }
1609
+ }
1542
1610
  /** This session's artifact directory, derived from the one root. */
1543
1611
  get sessionDir() {
1544
1612
  return this.session.sessionDir;
@@ -1860,7 +1928,7 @@ function withAnimus(options) {
1860
1928
  ...nextConfig,
1861
1929
  webpack(config, context) {
1862
1930
  if (typeof existingWebpack === "function") config = existingWebpack(config, context);
1863
- const rootDir = process.cwd();
1931
+ const rootDir = typeof context.dir === "string" && context.dir.length > 0 ? context.dir : process.cwd();
1864
1932
  const plugin = new AnimusWebpackPlugin(options);
1865
1933
  plugin.setRootDir(rootDir);
1866
1934
  const sessionDir = plugin.sessionDir;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { S as __require, _ as replacementEpochPath, a as REPLACEMENT_EPOCH_ARTIFACT, b as stylesPath, c as SYSTEM_PROPS_ARTIFACT, f as envelopeCssArtifact, g as readJsonEnvelope, h as readCssEnvelope, i as MANIFEST_ARTIFACT, l as analysisCommitPath, n as ANALYSIS_INPUTS_ARTIFACT, o as SESSION_ASSETS_DIR, p as envelopeJsonArtifact, r as ANALYSIS_STATUS_ARTIFACT, s as STYLES_ARTIFACT, t as ANALYSIS_COMMIT_ARTIFACT, v as sessionArtifactDir, x as systemPropsPath, y as sessionsRootDir } from "./session-paths-DfYIPDcM.mjs";
2
- import { C as setWatchTransaction, S as setSharedSystemProps, _ as setSessionArtifactDir, b as setSharedExternalDirs, c as getSharedCss, d as getWatchTransaction, f as resetAnalysisPromise, g as setReplacementEpoch, h as setManifestJson, l as getSharedExternalDirs, m as setAnalyzedHashes, n as engineApi, o as getReplacementEpoch, p as setAnalysisPromise, r as getAnalysisPromise, t as claimProcessSessionId, u as getSharedExternalEntries, v as setSharedCss, x as setSharedExternalEntries, y as setSharedEngine } from "./singleton-372wiSRr.mjs";
3
- import { DEFAULT_EXTENSIONS, assembleStylesheet, assertNoRetiredEngineSelection, buildPathAliasesJson, buildSystemPropsModule, clearEngineCache, collectExternalPackageSources, contentHash, createSourceIdentity, discoverFiles, enforceExternalTokenContracts, excludeCollectedPackages, extractSystemFilePackages, findAssetSpecifiers, findPackageRoot, firstOwners, formatRustTimingWaterfall, hashReplacementPlans, isExcludedPackageRelativePath, isPathWithinRoot, loadSystemConfig, mergeExternalKeyframes, postProcessCss, preprocessMdx, readTsconfigAliasPairs, resolveAssetFile, resolveLightningTargets, runProjectAnalysis, serializeStaticCss, sharesVolumeRoot, snapshotFilePlans, staleDistIncludesMessage, substituteAssetPlaceholders, toWatchKeys, unresolvableIncludesMessage, walkPackageSources } from "@animus-ui/extract/pipeline";
2
+ import { C as setSharedExternalEntries, S as setSharedExternalDirs, T as setWatchTransaction, _ as setOwningWatchSession, b as setSharedCss, d as getSharedExternalEntries, f as getWatchTransaction, g as setManifestJson, h as setAnalyzedHashes, l as getSharedCss, m as setAnalysisPromise, n as engineApi, o as getOwningWatchSession, p as resetAnalysisPromise, r as getAnalysisPromise, s as getReplacementEpoch, t as claimProcessSessionId, u as getSharedExternalDirs, v as setReplacementEpoch, w as setSharedSystemProps, x as setSharedEngine, y as setSessionArtifactDir } from "./singleton-BjSsGjsg.mjs";
3
+ import { DEFAULT_EXTENSIONS, assembleStylesheet, assertNoErrorDiagnostics, assertNoRetiredEngineSelection, buildPathAliasesJson, buildSystemPropsModule, clearEngineCache, collectExternalPackageSources, contentHash, createSourceIdentity, discoverFiles, enforceExternalTokenContracts, excludeCollectedPackages, extractSystemFilePackages, findAssetSpecifiers, findPackageRoot, firstOwners, formatRustTimingWaterfall, hashReplacementPlans, isExcludedPackageRelativePath, isPathWithinRoot, loadSystemConfig, mergeExternalKeyframes, postProcessCss, preprocessMdx, readTsconfigAliasPairs, resolveAssetFile, resolveLightningTargets, runProjectAnalysis, serializeStaticCss, sharesVolumeRoot, snapshotFilePlans, staleDistIncludesMessage, substituteAssetPlaceholders, toWatchKeys, unresolvableIncludesMessage, walkPackageSources } from "@animus-ui/extract/pipeline";
4
4
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, watch, writeFileSync } from "fs";
5
5
  import { basename, dirname, extname, join, relative, resolve } from "path";
6
6
  import { fileURLToPath } from "url";
@@ -172,6 +172,9 @@ var ExtractionSession = class {
172
172
  * ownership, design D2; duplicate specifiers resolving to one canonical
173
173
  * root share it). Engine watch wiring and tests read this. */
174
174
  externalRootOwners = /* @__PURE__ */ new Map();
175
+ /** Canonical external root → the extension set its collection walk used
176
+ * (widened for dist-only roots); rewalks and classification share it. */
177
+ externalRootExtensions = /* @__PURE__ */ new Map();
175
178
  /** Canonical admitted external watch roots — the engine-side watch
176
179
  * surface (webpack contextDependencies / Turbopack watchers). */
177
180
  externalWatchRoots = [];
@@ -302,7 +305,34 @@ var ExtractionSession = class {
302
305
  await inflight;
303
306
  return;
304
307
  }
308
+ if (!this.system) {
309
+ const owner = getOwningWatchSession();
310
+ const hasBatch = (changes.modifiedFiles?.size ?? 0) > 0 || (changes.removedFiles?.size ?? 0) > 0;
311
+ if (owner && owner !== this && hasBatch) await owner.ingestForwardedBatch(changes);
312
+ return;
313
+ }
314
+ const transaction = this.processWatchUpdate(changes);
315
+ setWatchTransaction(transaction);
316
+ try {
317
+ await transaction;
318
+ } finally {
319
+ setWatchTransaction(null);
320
+ }
321
+ }
322
+ /**
323
+ * Owner-side entry for a batch observed by a NON-OWNING compiler's
324
+ * watcher. Serializes behind any in-flight transaction, then runs the
325
+ * forwarded batch as its own transaction — never drops it (a forwarded
326
+ * batch has no other delivery; content-hash diffing makes an
327
+ * already-covered batch a cheap no-op).
328
+ */
329
+ async ingestForwardedBatch(changes) {
305
330
  if (!this.system) return;
331
+ for (;;) {
332
+ const inflight = getWatchTransaction();
333
+ if (!inflight) break;
334
+ await inflight;
335
+ }
306
336
  const transaction = this.processWatchUpdate(changes);
307
337
  setWatchTransaction(transaction);
308
338
  try {
@@ -359,6 +389,7 @@ var ExtractionSession = class {
359
389
  if (!priorCacheEntries.has(key)) priorCacheEntries.set(key, this.fileCache.get(key) ?? null);
360
390
  };
361
391
  const inventoryUpdates = [];
392
+ const ownerRemovals = [];
362
393
  let removedAny = false;
363
394
  if (changes.removedFiles) for (const removedPath of changes.removedFiles) {
364
395
  let key;
@@ -381,8 +412,7 @@ var ExtractionSession = class {
381
412
  hash: null,
382
413
  abs: removedPath
383
414
  });
384
- delete this.externalFileOwners[key];
385
- delete this.externalFileOwners[key + ".tsx"];
415
+ ownerRemovals.push(key, key + ".tsx");
386
416
  }
387
417
  }
388
418
  }
@@ -466,6 +496,7 @@ var ExtractionSession = class {
466
496
  abs: update.abs
467
497
  });
468
498
  }
499
+ for (const key of ownerRemovals) delete this.externalFileOwners[key];
469
500
  } else if (this.statusAttemptOpen) {
470
501
  this.debouncePending.clear();
471
502
  this.writeAnalysisStatus("idle", []);
@@ -624,11 +655,14 @@ var ExtractionSession = class {
624
655
  const admitted = excludeCollectedPackages(collected, rejectedSpecifiers, rootDir);
625
656
  const identity = createSourceIdentity(rootDir);
626
657
  this.externalRootOwners = /* @__PURE__ */ new Map();
658
+ this.externalRootExtensions = /* @__PURE__ */ new Map();
627
659
  for (const [dir, specifiers] of Object.entries(admitted.dirOwnerSets)) {
628
660
  const canonical = identity.registerExternalRoot(dir);
629
661
  const owners = this.externalRootOwners.get(canonical) ?? /* @__PURE__ */ new Set();
630
662
  for (const specifier of specifiers) owners.add(specifier);
631
663
  this.externalRootOwners.set(canonical, owners);
664
+ const exts = admitted.dirExtensions[dir];
665
+ if (exts) this.externalRootExtensions.set(canonical, new Set(exts));
632
666
  }
633
667
  this.sourceIdentity = identity;
634
668
  this.externalWatchRoots = identity.externalRoots();
@@ -671,12 +705,13 @@ var ExtractionSession = class {
671
705
  const merge = mergeExternalKeyframes((entry, root) => api.scanKeyframesExports(entry, root), this.system.keyframesJson, admitted.keyframesScanEntries.values(), this.rootDir);
672
706
  this.system.keyframesJson = merge.keyframesJson;
673
707
  this.externalKeyframesDiagnostics = merge.diagnostics;
674
- }
708
+ } else this.externalKeyframesDiagnostics = [];
675
709
  bt.packageResolve = this.elapsed(t);
676
710
  const universe = new Set(fileEntries.map((entry) => entry.path));
677
711
  for (const key of [...this.fileCache.keys()]) if (!universe.has(key)) this.fileCache.delete(key);
678
712
  await this.analyzeAndEmit(fileEntries, packageMap, false, bt, pipelineStart, pending);
679
713
  this.onExternalRootsCommitted?.(this.externalWatchRoots);
714
+ setOwningWatchSession(this);
680
715
  }
681
716
  /**
682
717
  * Reset analysis state for HMR geological reset. Payload write guards go
@@ -757,7 +792,8 @@ var ExtractionSession = class {
757
792
  for (const root of dirtyRoots) {
758
793
  const previous = this.externalInventory.get(root) ?? /* @__PURE__ */ new Map();
759
794
  const seen = /* @__PURE__ */ new Set();
760
- const walked = walkPackageSources(root, extensionsSet);
795
+ const walked = walkPackageSources(root, this.externalRootExtensions.get(root) ?? extensionsSet);
796
+ if (walked.length === 0 && previous.size > 0) this.warn(`external root rewalk found no files under ${root} while its inventory holds ${previous.size} — reconciling as full deletion`);
761
797
  for (const abs of walked) {
762
798
  const resolved = identity.resolveSourceId(abs);
763
799
  if (!resolved || resolved.owningRoot !== root) continue;
@@ -786,9 +822,10 @@ var ExtractionSession = class {
786
822
  * Returns null for dropped paths.
787
823
  */
788
824
  classifyWatchPath(absPath, scan) {
789
- if (!scan.extensionsSet.has(extname(absPath))) return null;
825
+ const ext = extname(absPath);
790
826
  const rootDir = this.rootDir;
791
827
  if (isPathWithinRoot(rootDir, absPath)) {
828
+ if (!scan.extensionsSet.has(ext)) return null;
792
829
  const rel = relative(rootDir, absPath);
793
830
  if (scan.excludePatterns.some((pattern) => absPath.includes(pattern) || rel.includes(pattern))) return null;
794
831
  return {
@@ -799,12 +836,14 @@ var ExtractionSession = class {
799
836
  const resolved = this.sourceIdentity?.resolveSourceId(absPath);
800
837
  if (!resolved) return null;
801
838
  if (resolved.owningRoot === null) {
839
+ if (!scan.extensionsSet.has(ext)) return null;
802
840
  if (scan.excludePatterns.some((pattern) => resolved.sourceKey.includes(pattern))) return null;
803
841
  return {
804
842
  key: resolved.sourceKey,
805
843
  owningRoot: null
806
844
  };
807
845
  }
846
+ if (!(this.externalRootExtensions.get(resolved.owningRoot) ?? scan.extensionsSet).has(ext)) return null;
808
847
  if (isExcludedPackageRelativePath(resolved.pathInRoot)) return null;
809
848
  return {
810
849
  key: resolved.sourceKey,
@@ -893,6 +932,7 @@ var ExtractionSession = class {
893
932
  strict: this.options.strict,
894
933
  extraDiagnostics: this.externalKeyframesDiagnostics
895
934
  });
935
+ assertNoErrorDiagnostics(result.manifest?.diagnostics);
896
936
  enforceExternalTokenContracts({
897
937
  diagnostics: result.manifest?.diagnostics,
898
938
  fileOwners: this.externalFileOwners,
@@ -999,7 +1039,11 @@ var ExtractionSession = class {
999
1039
  queueMicrotask(() => {
1000
1040
  this.debounceStatusWriteScheduled = false;
1001
1041
  if (this.debouncePending.size === 0) return;
1002
- this.writeAnalysisStatus("debouncing", [...this.debouncePending.entries()]);
1042
+ try {
1043
+ this.writeAnalysisStatus("debouncing", [...this.debouncePending.entries()]);
1044
+ } catch (err) {
1045
+ this.warn(`debounce status write failed: ${String(err)}`);
1046
+ }
1003
1047
  });
1004
1048
  }
1005
1049
  /** One pending microtask flushes a burst of debounce observations. */
@@ -1095,13 +1139,14 @@ var ExtractionSession = class {
1095
1139
  * artifacts (below) — the webpack cold-cache validity witness.
1096
1140
  */
1097
1141
  publishReplacementEpoch(epoch) {
1098
- if (this.lastEpochValue === null) this.lastEpochValue = this.diskEpochValue();
1142
+ const onDisk = this.diskEpochValue();
1143
+ if (this.lastEpochValue === null) this.lastEpochValue = onDisk;
1144
+ if (epoch !== onDisk) this.writeSessionArtifact(REPLACEMENT_EPOCH_ARTIFACT, JSON.stringify({
1145
+ schema: 1,
1146
+ sessionId: this.sessionId,
1147
+ epoch
1148
+ }));
1099
1149
  if (epoch !== this.lastEpochValue) {
1100
- this.writeSessionArtifact(REPLACEMENT_EPOCH_ARTIFACT, JSON.stringify({
1101
- schema: 1,
1102
- sessionId: this.sessionId,
1103
- epoch
1104
- }));
1105
1150
  this.lastEpochValue = epoch;
1106
1151
  this.reconcileSiblingEpochs(epoch);
1107
1152
  }
@@ -1485,7 +1530,7 @@ var AnimusWebpackPlugin = class {
1485
1530
  });
1486
1531
  });
1487
1532
  compiler.hooks.run.tapPromise(PLUGIN_NAME, async (_compiler) => {
1488
- this.session.rootDir = _compiler.context;
1533
+ this.adoptCompilerContext(_compiler);
1489
1534
  this.extractAliases(_compiler);
1490
1535
  const existing = getAnalysisPromise();
1491
1536
  if (existing) {
@@ -1497,7 +1542,7 @@ var AnimusWebpackPlugin = class {
1497
1542
  await promise;
1498
1543
  });
1499
1544
  compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (_compiler) => {
1500
- this.session.rootDir = _compiler.context;
1545
+ this.adoptCompilerContext(_compiler);
1501
1546
  this.extractAliases(_compiler);
1502
1547
  if (!this.initialized) {
1503
1548
  const existing = getAnalysisPromise();
@@ -1532,11 +1577,34 @@ var AnimusWebpackPlugin = class {
1532
1577
  return this.session.sessionId;
1533
1578
  }
1534
1579
  /** Set the project root at CONFIG time (with-animus) — the ONE root all
1535
- * session-path derivations use. The compiler hooks re-assert it from
1536
- * compiler.context (identical when compiler.context === cwd). */
1580
+ * session-path derivations use. The compiler hooks ADOPT
1581
+ * compiler.context only when no root was published (bare-apply
1582
+ * harnesses); they never overwrite this. */
1537
1583
  setRootDir(rootDir) {
1538
1584
  this.session.rootDir = rootDir;
1539
1585
  }
1586
+ /** One warning per plugin instance for a context/root mismatch. */
1587
+ warnedRootDivergence = false;
1588
+ /** The run/watchRun taps' root handling: adopt compiler.context when no
1589
+ * config-time root exists; otherwise KEEP the configured root — every
1590
+ * frozen config-time derivation (stub path, css alias target,
1591
+ * virtual:animus/system-props target, watch-ignore) came from it, and a
1592
+ * silent overwrite re-keys sessionDir so the pipeline publishes
1593
+ * artifacts where none of those consumers look. A disagreement is
1594
+ * surfaced loudly instead (with-animus derives the root from Next's own
1595
+ * `dir`, which equals compiler.context in real Next runs — a mismatch
1596
+ * means a custom-webpack setup wired the plugin differently). */
1597
+ adoptCompilerContext(compiler) {
1598
+ const context = compiler.context;
1599
+ if (!this.session.rootDir) {
1600
+ this.session.rootDir = context;
1601
+ return;
1602
+ }
1603
+ if (context && this.session.rootDir !== context && !this.warnedRootDivergence) {
1604
+ this.warnedRootDivergence = true;
1605
+ console.warn(`[animus-extract] compiler.context (${context}) differs from the configured project root (${this.session.rootDir}); keeping the configured root — run next against the app directory (or align your custom webpack context) so both agree`);
1606
+ }
1607
+ }
1540
1608
  /** This session's artifact directory, derived from the one root. */
1541
1609
  get sessionDir() {
1542
1610
  return this.session.sessionDir;
@@ -1858,7 +1926,7 @@ function withAnimus(options) {
1858
1926
  ...nextConfig,
1859
1927
  webpack(config, context) {
1860
1928
  if (typeof existingWebpack === "function") config = existingWebpack(config, context);
1861
- const rootDir = process.cwd();
1929
+ const rootDir = typeof context.dir === "string" && context.dir.length > 0 ? context.dir : process.cwd();
1862
1930
  const plugin = new AnimusWebpackPlugin(options);
1863
1931
  plugin.setRootDir(rootDir);
1864
1932
  const sessionDir = plugin.sessionDir;
package/dist/loader.cjs CHANGED
@@ -1,14 +1,18 @@
1
1
  const require_session_paths = require("./session-paths-CZoi19NW.cjs");
2
- const require_singleton = require("./singleton-D4vhawsW.cjs");
2
+ const require_singleton = require("./singleton-BjZyw_8b.cjs");
3
3
  const require_loader_core = require("./loader-core-C40WbC6s.cjs");
4
4
  require("./turbopack-loader.cjs");
5
5
  let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
6
6
  let fs = require("fs");
7
7
  let path = require("path");
8
8
  //#region src/loader.ts
9
- /** Session dirs whose epoch artifact has been SEEN on disk — the artifact
10
- * is never deleted once written, so a positive existsSync is stable for
11
- * the life of the process (negatives always re-probe). */
9
+ /** Session dirs whose epoch artifact has been SEEN on disk. A sibling
10
+ * session's reconciliation may delete the artifact, but the owning
11
+ * session self-heals it on its next publish, so a positive existsSync
12
+ * stays a sound basis for registering the dependency: a module built
13
+ * during the missing window records a missing-file witness that the
14
+ * recreation then invalidates (over-invalidation, never under).
15
+ * Negatives always re-probe. */
12
16
  const epochSeenForSessionDir = /* @__PURE__ */ new Set();
13
17
  /**
14
18
  * Webpack loader for Animus source transformation.
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAOzD,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,mBAAmB,CAAC;IACtC;uDACmD;IACnD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,uEAAuE;IACvE,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAmDR"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAWzD,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,mBAAmB,CAAC;IACtC;uDACmD;IACnD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,uEAAuE;IACvE,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAmDR"}
package/dist/loader.mjs CHANGED
@@ -1,13 +1,17 @@
1
1
  import { _ as replacementEpochPath } from "./session-paths-DfYIPDcM.mjs";
2
- import { a as getManifestJson, i as getAnalyzedHashes, n as engineApi, s as getSessionArtifactDir } from "./singleton-372wiSRr.mjs";
2
+ import { a as getManifestJson, c as getSessionArtifactDir, i as getAnalyzedHashes, n as engineApi } from "./singleton-BjSsGjsg.mjs";
3
3
  import { t as transformWithManifest } from "./loader-core-D6Tm_b8F.mjs";
4
4
  import { contentHash } from "@animus-ui/extract/pipeline";
5
5
  import { existsSync } from "fs";
6
6
  import { relative } from "path";
7
7
  //#region src/loader.ts
8
- /** Session dirs whose epoch artifact has been SEEN on disk — the artifact
9
- * is never deleted once written, so a positive existsSync is stable for
10
- * the life of the process (negatives always re-probe). */
8
+ /** Session dirs whose epoch artifact has been SEEN on disk. A sibling
9
+ * session's reconciliation may delete the artifact, but the owning
10
+ * session self-heals it on its next publish, so a positive existsSync
11
+ * stays a sound basis for registering the dependency: a module built
12
+ * during the missing window records a missing-file witness that the
13
+ * recreation then invalidates (over-invalidation, never under).
14
+ * Negatives always re-probe. */
11
15
  const epochSeenForSessionDir = /* @__PURE__ */ new Set();
12
16
  /**
13
17
  * Webpack loader for Animus source transformation.
package/dist/plugin.d.ts CHANGED
@@ -138,9 +138,22 @@ export declare class AnimusWebpackPlugin {
138
138
  * session-scoped alias/stub paths from it (design D2). */
139
139
  get sessionId(): string;
140
140
  /** Set the project root at CONFIG time (with-animus) — the ONE root all
141
- * session-path derivations use. The compiler hooks re-assert it from
142
- * compiler.context (identical when compiler.context === cwd). */
141
+ * session-path derivations use. The compiler hooks ADOPT
142
+ * compiler.context only when no root was published (bare-apply
143
+ * harnesses); they never overwrite this. */
143
144
  setRootDir(rootDir: string): void;
145
+ /** One warning per plugin instance for a context/root mismatch. */
146
+ private warnedRootDivergence;
147
+ /** The run/watchRun taps' root handling: adopt compiler.context when no
148
+ * config-time root exists; otherwise KEEP the configured root — every
149
+ * frozen config-time derivation (stub path, css alias target,
150
+ * virtual:animus/system-props target, watch-ignore) came from it, and a
151
+ * silent overwrite re-keys sessionDir so the pipeline publishes
152
+ * artifacts where none of those consumers look. A disagreement is
153
+ * surfaced loudly instead (with-animus derives the root from Next's own
154
+ * `dir`, which equals compiler.context in real Next runs — a mismatch
155
+ * means a custom-webpack setup wired the plugin differently). */
156
+ private adoptCompilerContext;
144
157
  /** This session's artifact directory, derived from the one root. */
145
158
  get sessionDir(): string;
146
159
  /** Expose options for the loader */
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,aAAa,GAAG;IACnB,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,IAAI,MA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AAoB,CAAS;IAErC;;;;;;;;sEAQkE;IAClE,OAAO,CAAC,oBAAoB;IAqB5B,oEAAoE;IACpE,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,oCAAoC;IACpC,UAAU,IAAI,iBAAiB,CAE9B;IAED;mFAC+E;IAC/E,sBAAsB,IAAI,MAAM,EAAE,CAIjC;IAED;mFAC+E;IAC/E,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAI9C;CACF"}
@@ -67,10 +67,25 @@ const REPLACEMENT_EPOCH_KEY = "__animus_replacement_epoch__";
67
67
  const WATCH_TRANSACTION_KEY = "__animus_watch_transaction__";
68
68
  const PROCESS_SESSION_ID_KEY = "__animus_process_session_id__";
69
69
  const SESSION_ARTIFACT_DIR_KEY = "__animus_session_artifact_dir__";
70
+ const OWNING_WATCH_SESSION_KEY = "__animus_owning_watch_session__";
70
71
  const analyzedHashesSlot = globalSlot(ANALYZED_HASHES_KEY);
71
72
  const replacementEpochSlot = globalSlot(REPLACEMENT_EPOCH_KEY);
72
73
  const watchTransactionSlot = globalSlot(WATCH_TRANSACTION_KEY);
73
74
  const sessionArtifactDirSlot = globalSlot(SESSION_ARTIFACT_DIR_KEY);
75
+ const owningWatchSessionSlot = globalSlot(OWNING_WATCH_SESSION_KEY);
76
+ /**
77
+ * The session that completed the full pipeline and holds system state — the
78
+ * only instance that can run watch analysis. Each MultiCompiler child holds
79
+ * its own session AND its own watcher with its own modified set; a
80
+ * non-owning session forwards its batch here instead of dropping it (a file
81
+ * only that compiler watches would otherwise never be analyzed).
82
+ */
83
+ function getOwningWatchSession() {
84
+ return owningWatchSessionSlot.get();
85
+ }
86
+ function setOwningWatchSession(session) {
87
+ owningWatchSessionSlot.set(session);
88
+ }
74
89
  /**
75
90
  * Per-file analyzed content hashes of the last published analysis (relPath →
76
91
  * contentHash of the exact bytes analyzed) — the loader's witness for the
@@ -199,4 +214,4 @@ function engineApi() {
199
214
  return v2EngineApi();
200
215
  }
201
216
  //#endregion
202
- export { setWatchTransaction as C, setSharedSystemProps as S, setSessionArtifactDir as _, getManifestJson as a, setSharedExternalDirs as b, getSharedCss as c, getWatchTransaction as d, resetAnalysisPromise as f, setReplacementEpoch as g, setManifestJson as h, getAnalyzedHashes as i, getSharedExternalDirs as l, setAnalyzedHashes as m, engineApi as n, getReplacementEpoch as o, setAnalysisPromise as p, getAnalysisPromise as r, getSessionArtifactDir as s, claimProcessSessionId as t, getSharedExternalEntries as u, setSharedCss as v, setSharedExternalEntries as x, setSharedEngine as y };
217
+ export { setSharedExternalEntries as C, setSharedExternalDirs as S, setWatchTransaction as T, setOwningWatchSession as _, getManifestJson as a, setSharedCss as b, getSessionArtifactDir as c, getSharedExternalEntries as d, getWatchTransaction as f, setManifestJson as g, setAnalyzedHashes as h, getAnalyzedHashes as i, getSharedCss as l, setAnalysisPromise as m, engineApi as n, getOwningWatchSession as o, resetAnalysisPromise as p, getAnalysisPromise as r, getReplacementEpoch as s, claimProcessSessionId as t, getSharedExternalDirs as u, setReplacementEpoch as v, setSharedSystemProps as w, setSharedEngine as x, setSessionArtifactDir as y };
@@ -67,10 +67,25 @@ const REPLACEMENT_EPOCH_KEY = "__animus_replacement_epoch__";
67
67
  const WATCH_TRANSACTION_KEY = "__animus_watch_transaction__";
68
68
  const PROCESS_SESSION_ID_KEY = "__animus_process_session_id__";
69
69
  const SESSION_ARTIFACT_DIR_KEY = "__animus_session_artifact_dir__";
70
+ const OWNING_WATCH_SESSION_KEY = "__animus_owning_watch_session__";
70
71
  const analyzedHashesSlot = globalSlot(ANALYZED_HASHES_KEY);
71
72
  const replacementEpochSlot = globalSlot(REPLACEMENT_EPOCH_KEY);
72
73
  const watchTransactionSlot = globalSlot(WATCH_TRANSACTION_KEY);
73
74
  const sessionArtifactDirSlot = globalSlot(SESSION_ARTIFACT_DIR_KEY);
75
+ const owningWatchSessionSlot = globalSlot(OWNING_WATCH_SESSION_KEY);
76
+ /**
77
+ * The session that completed the full pipeline and holds system state — the
78
+ * only instance that can run watch analysis. Each MultiCompiler child holds
79
+ * its own session AND its own watcher with its own modified set; a
80
+ * non-owning session forwards its batch here instead of dropping it (a file
81
+ * only that compiler watches would otherwise never be analyzed).
82
+ */
83
+ function getOwningWatchSession() {
84
+ return owningWatchSessionSlot.get();
85
+ }
86
+ function setOwningWatchSession(session) {
87
+ owningWatchSessionSlot.set(session);
88
+ }
74
89
  /**
75
90
  * Per-file analyzed content hashes of the last published analysis (relPath →
76
91
  * contentHash of the exact bytes analyzed) — the loader's witness for the
@@ -229,6 +244,12 @@ Object.defineProperty(exports, "getManifestJson", {
229
244
  return getManifestJson;
230
245
  }
231
246
  });
247
+ Object.defineProperty(exports, "getOwningWatchSession", {
248
+ enumerable: true,
249
+ get: function() {
250
+ return getOwningWatchSession;
251
+ }
252
+ });
232
253
  Object.defineProperty(exports, "getReplacementEpoch", {
233
254
  enumerable: true,
234
255
  get: function() {
@@ -289,6 +310,12 @@ Object.defineProperty(exports, "setManifestJson", {
289
310
  return setManifestJson;
290
311
  }
291
312
  });
313
+ Object.defineProperty(exports, "setOwningWatchSession", {
314
+ enumerable: true,
315
+ get: function() {
316
+ return setOwningWatchSession;
317
+ }
318
+ });
292
319
  Object.defineProperty(exports, "setReplacementEpoch", {
293
320
  enumerable: true,
294
321
  get: function() {
@@ -10,6 +10,24 @@ export declare function getSharedExternalDirs(): string[];
10
10
  export declare function setSharedExternalDirs(dirs: string[]): void;
11
11
  export declare function getSharedExternalEntries(): Map<string, string>;
12
12
  export declare function setSharedExternalEntries(entries: Map<string, string>): void;
13
+ /** Structural view of the owning session a forwarded watch batch targets —
14
+ * kept minimal (and defined here, not imported) so the singleton never
15
+ * depends on the session module it serves. */
16
+ export interface WatchBatchTarget {
17
+ ingestForwardedBatch(changes: {
18
+ modifiedFiles?: ReadonlySet<string>;
19
+ removedFiles?: ReadonlySet<string>;
20
+ }): Promise<void>;
21
+ }
22
+ /**
23
+ * The session that completed the full pipeline and holds system state — the
24
+ * only instance that can run watch analysis. Each MultiCompiler child holds
25
+ * its own session AND its own watcher with its own modified set; a
26
+ * non-owning session forwards its batch here instead of dropping it (a file
27
+ * only that compiler watches would otherwise never be analyzed).
28
+ */
29
+ export declare function getOwningWatchSession(): WatchBatchTarget | null;
30
+ export declare function setOwningWatchSession(session: WatchBatchTarget | null): void;
13
31
  /**
14
32
  * Per-file analyzed content hashes of the last published analysis (relPath →
15
33
  * contentHash of the exact bytes analyzed) — the loader's witness for the
@@ -74,5 +92,5 @@ export declare function engineApi(): any;
74
92
  * Every globalThis key this module owns — the single authority test
75
93
  * harnesses snapshot/clear per test (never re-declare this list).
76
94
  */
77
- export declare const SINGLETON_GLOBAL_KEYS: readonly ["__animus_manifest_json__", "__animus_analysis_promise__", "__animus_shared_css__", "__animus_shared_system_props__", "__animus_external_pkg_dirs__", "__animus_external_source_entries__", "__animus_analyzed_hashes__", "__animus_replacement_epoch__", "__animus_watch_transaction__", "__animus_process_session_id__", "__animus_session_artifact_dir__", "__animus_engine__", "__animus_v2_engine__", "__animus_v2_sent_sources__", "__animus_v2_drift_warned__"];
95
+ export declare const SINGLETON_GLOBAL_KEYS: readonly ["__animus_manifest_json__", "__animus_analysis_promise__", "__animus_shared_css__", "__animus_shared_system_props__", "__animus_external_pkg_dirs__", "__animus_external_source_entries__", "__animus_analyzed_hashes__", "__animus_replacement_epoch__", "__animus_watch_transaction__", "__animus_process_session_id__", "__animus_session_artifact_dir__", "__animus_owning_watch_session__", "__animus_engine__", "__animus_v2_engine__", "__animus_v2_sent_sources__", "__animus_v2_drift_warned__"];
78
96
  //# sourceMappingURL=singleton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAmBA,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAElD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,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2
2
  "name": "@animus-ui/next-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Animus static CSS extraction for Next.js (webpack)",
5
5
  "keywords": [
6
6
  "animus",
@@ -40,7 +40,7 @@
40
40
  "compile": "tsc --noEmit"
41
41
  },
42
42
  "dependencies": {
43
- "@animus-ui/extract": "0.1.8"
43
+ "@animus-ui/extract": "0.1.9"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@mdx-js/mdx": "^3.0.0",