@animus-ui/next-plugin 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/loader.mjs CHANGED
@@ -1,34 +1,12 @@
1
- import { t as transformWithManifest } from "./loader-core-DwiidYBi.mjs";
1
+ import { t as transformWithManifest } from "./loader-core-x6cOzF9v.mjs";
2
2
  import { contentHash } from "@animus-ui/extract/pipeline";
3
3
  import { engineApi, getAnalyzedHashes, getManifestJson, getSessionArtifactDir, replacementEpochPath } from "@animus-ui/extract/session";
4
4
  import { existsSync } from "fs";
5
5
  import { relative } from "path";
6
6
  //#region src/loader.ts
7
- /** Session dirs whose epoch artifact has been SEEN on disk. A sibling
8
- * session's reconciliation may delete the artifact, but the owning
9
- * session self-heals it on its next publish, so a positive existsSync
10
- * stays a sound basis for registering the dependency: a module built
11
- * during the missing window records a missing-file witness that the
12
- * recreation then invalidates (over-invalidation, never under).
13
- * Negatives always re-probe. */
14
7
  const epochSeenForSessionDir = /* @__PURE__ */ new Set();
15
- /**
16
- * Webpack loader for Animus source transformation.
17
- * Runs with enforce: 'pre' to see original source before Babel/SWC.
18
- * The manifest arrives via the process singleton (the webpack pipeline and
19
- * this loader share one process); the transform + CSS-import policy lives
20
- * in the shared loader-core.
21
- *
22
- * Coherence duties (openspec: next-webpack-served-transform-coherence):
23
- * every dev invocation registers the replacement-epoch artifact as a file
24
- * dependency (design D2 — restored persistent-cache modules snapshot it, so
25
- * offline epoch moves invalidate them), and an analyzed file whose current
26
- * source hash mismatches its analyzed hash fails with the stable diagnostic
27
- * `ANIMUS_ANALYSIS_CATCHING_UP` after one refreshed re-check (design D4 —
28
- * unconditional: a zero-entry stale manifest must never publish raw bytes).
29
- */
30
8
  function animusLoader(source) {
31
- if (this.mode !== "production" && typeof this.addDependency === "function") {
9
+ if (this.mode !== "production" && this.addDependency !== void 0) {
32
10
  const sessionDir = getSessionArtifactDir();
33
11
  if (sessionDir) {
34
12
  const epochPath = replacementEpochPath(sessionDir);
package/dist/plugin.d.ts CHANGED
@@ -4,6 +4,10 @@ type WebpackSource = {
4
4
  source(): string | Buffer;
5
5
  size(): number;
6
6
  };
7
+ type WatchIgnoreEntry = string | RegExp;
8
+ type WatchIgnoreMatcher = (path: string) => boolean;
9
+ type WatchIgnored = WatchIgnoreEntry | WatchIgnoreEntry[] | WatchIgnoreMatcher | null | undefined;
10
+ type WebpackAliasMap = Record<string, string | string[] | false>;
7
11
  type Compilation = {
8
12
  hooks: {
9
13
  processAssets: {
@@ -13,19 +17,12 @@ type Compilation = {
13
17
  }, fn: (assets: Record<string, WebpackSource>) => void) => void;
14
18
  };
15
19
  };
16
- /** Watch inputs webpack rebuilds per compilation (webpack 5 LazySet). */
17
20
  fileDependencies: {
18
21
  add(path: string): void;
19
22
  };
20
- /** Currently-absent paths whose creation must trigger a rebuild. */
21
23
  missingDependencies: {
22
24
  add(path: string): void;
23
25
  };
24
- /** Directory watch inputs (webpack 5 LazySet). External kit roots are
25
- * registered here every compilation so UNIMPORTED creations still
26
- * produce watch turns — webpack reports the DIRECTORY, and the
27
- * session's root-dirty rewalk reconstructs the delta (openspec:
28
- * external-source-watch-ingestion, design D3; probe E). */
29
26
  contextDependencies: {
30
27
  add(path: string): void;
31
28
  };
@@ -34,17 +31,17 @@ type Compilation = {
34
31
  } | undefined;
35
32
  updateAsset(name: string, newSource: WebpackSource): void;
36
33
  };
37
- /** The slice of a webpack Module the needBuild predicate inspects. */
38
34
  type CandidateModule = {
39
35
  loaders?: Array<{
40
36
  loader?: string;
41
37
  }>;
42
38
  };
43
39
  type NeedBuildCallback = (err?: Error | null, result?: boolean) => void;
44
- /** NormalModule.getCompilationHooks(...) slice (webpack 5). */
40
+ type NeedBuildContext = Record<never, never>;
41
+ type CompilationIdentity = Record<never, never>;
45
42
  type NormalModuleCompilationHooks = {
46
43
  needBuild?: {
47
- tapAsync: (name: string, fn: (module: CandidateModule, context: unknown, callback: NeedBuildCallback) => void) => void;
44
+ tapAsync: (name: string, fn: (module: CandidateModule, context: NeedBuildContext, callback: NeedBuildCallback) => void) => void;
48
45
  };
49
46
  };
50
47
  type Compiler = {
@@ -59,7 +56,7 @@ type Compiler = {
59
56
  tap: (name: string, fn: (compilation: Compilation) => void) => void;
60
57
  };
61
58
  thisCompilation: {
62
- tap: (name: string, fn: (compilation: unknown) => void) => void;
59
+ tap: (name: string, fn: (compilation: CompilationIdentity) => void) => void;
63
60
  };
64
61
  };
65
62
  context: string;
@@ -69,10 +66,10 @@ type Compiler = {
69
66
  options?: {
70
67
  name?: string;
71
68
  resolve?: {
72
- alias?: Record<string, string | string[] | false>;
69
+ alias?: WebpackAliasMap;
73
70
  };
74
71
  watchOptions?: {
75
- ignored?: unknown;
72
+ ignored?: WatchIgnored;
76
73
  };
77
74
  };
78
75
  webpack?: {
@@ -82,87 +79,38 @@ type Compiler = {
82
79
  sources: {
83
80
  RawSource: new (source: string) => WebpackSource;
84
81
  };
85
- /** Obtained from the compiler instance at hook time — NEVER a top-level
86
- * webpack import (Next ships its own compiled webpack). */
82
+ /** Read from the compiler instance, never a top-level webpack import —
83
+ * Next ships its own compiled webpack. */
87
84
  NormalModule?: {
88
- getCompilationHooks?: (compilation: unknown) => NormalModuleCompilationHooks;
85
+ getCompilationHooks?: (compilation: CompilationIdentity) => NormalModuleCompilationHooks;
89
86
  };
90
87
  };
91
88
  };
92
- /**
93
- * Webpack adapter for the extraction pipeline. All pipeline logic lives in
94
- * the bundler-agnostic ExtractionSession — this class owns only the webpack
95
- * wiring: hook registration, cross-compiler analysis dedup, alias
96
- * harvesting from the compiler config, watch-event translation, and
97
- * in-memory CSS asset replacement.
98
- */
99
89
  export declare class AnimusWebpackPlugin {
100
90
  private options;
101
91
  private session;
102
92
  private initialized;
103
93
  private aliasesExtracted;
104
- /** Loader paths counting as "the animus loader" in a module's chain —
105
- * this package's own loader plus an optional harness override. */
106
94
  private readonly animusLoaderPaths;
107
- /** Epoch THIS compiler last proceeded with (set after every awaited
108
- * watchRun transaction — including joined ones). Null until the
109
- * initialization pipeline publishes. */
110
95
  private lastBuiltEpoch;
111
- /** Armed by watchRun when the transaction moved the epoch; captured and
112
- * disarmed by the next compilation's needBuild wiring (design D1). */
113
96
  private epochMovedForNextCompilation;
114
97
  constructor(options: AnimusNextOptions);
115
- /** True when the module's loader chain contains the animus loader — the
116
- * needBuild fan-out predicate (design D1: no historical records; covers
117
- * restored persistent-cache modules and raw passthroughs alike). */
118
98
  private moduleUsesAnimusLoader;
119
- /** Append the exact epoch artifact path to `watchOptions.ignored`,
120
- * preserving the user's shape (design D2: the artifact participates in
121
- * module snapshots via addDependency but never triggers live watch
122
- * turns — no echo compilations). Session identity is process-claimed,
123
- * so every compiler's plugin instance derives the SAME session-scoped
124
- * path here regardless of which instance ends up owning the pipeline.
125
- * Derived from the ONE root (session.rootDir, set at config time by
126
- * with-animus); compiler.context is the fallback for bare-apply
127
- * harnesses — identical when compiler.context === cwd. */
128
99
  private appendEpochWatchIgnore;
129
- /** Extract path aliases from webpack's resolve.alias config. Runs once per
130
- * plugin instance — the resolve config is immutable after apply. */
131
100
  private extractAliases;
132
101
  apply(compiler: Compiler): void;
133
- /**
134
- * Reset analysis state for HMR geological reset.
135
- */
136
102
  resetForHmr(): void;
137
- /** Session identity (process-claimed) — with-animus derives the
138
- * session-scoped alias/stub paths from it (design D2). */
139
103
  get sessionId(): string;
140
- /** Set the project root at CONFIG time (with-animus) — the ONE root all
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. */
144
104
  setRootDir(rootDir: string): void;
145
- /** One warning per plugin instance for a context/root mismatch. */
146
105
  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). */
106
+ /** Adopts `compiler.context` only when no config-time root exists: every
107
+ * frozen derivation came from that root, so an overwrite re-keys it.
108
+ * Stub path, css alias, virtual system-props target and watch-ignore are
109
+ * all frozen from it, so a disagreement is warned, never reconciled. */
156
110
  private adoptCompilerContext;
157
- /** This session's artifact directory, derived from the one root. */
158
111
  get sessionDir(): string;
159
- /** Expose options for the loader */
160
112
  getOptions(): AnimusNextOptions;
161
- /** Expose external package directories for webpack loader allowlisting.
162
- * Falls back to shared globalThis state for non-owning compiler instances. */
163
113
  getExternalPackageDirs(): string[];
164
- /** Expose external package source entries for webpack resolve alias.
165
- * Falls back to shared globalThis state for non-owning compiler instances. */
166
114
  getExternalSourceEntries(): Map<string, string>;
167
115
  }
168
116
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,KAAK,aAAa,GAAG;IACnB,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE;QACL,aAAa,EAAE;YACb,GAAG,EAAE,CACH,OAAO,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,EACxC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,IAAI,KAChD,IAAI,CAAC;SACX,CAAC;KACH,CAAC;IACF,yEAAyE;IACzE,gBAAgB,EAAE;QAAE,GAAG,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,IAAI,iBAAiB,CAE9B;IAED,sBAAsB,IAAI,MAAM,EAAE,CAIjC;IAED,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAI9C;CACF"}
@@ -1,46 +1,26 @@
1
1
  import { TURBOPACK_SYSTEM_PROPS_ID } from '@animus-ui/extract/session';
2
+ import type { TurbopackLoaderOptions } from './turbopack-loader';
2
3
  import type { AnimusNextOptions } from './types';
3
- /**
4
- * Turbopack config fragment generation (spec: next-turbopack-integration).
5
- * Everything emitted here MUST be JSON-serializable — Turbopack forwards
6
- * loader options across process boundaries and rejects live values.
7
- */
4
+ /** Everything emitted here must be JSON-serializable: Turbopack forwards
5
+ * loader options across process boundaries and rejects live values. */
8
6
  export type TurbopackMode = 'off' | 'auto' | 'on';
9
7
  export interface TurbopackRule {
10
8
  loaders: Array<{
11
9
  loader: string;
12
- options: Record<string, unknown>;
10
+ options: TurbopackLoaderOptions;
13
11
  }>;
14
12
  }
15
13
  export interface TurbopackConfigFragment {
16
14
  rules: Record<string, TurbopackRule>;
17
15
  resolveAlias: Record<string, string>;
18
16
  }
19
- /** The single glob the Animus loader registers under — derived from the
20
- * ONE shared engine extension set (also the unplugin transform gate's
21
- * source), so the two bundler families cannot drift. `.mjs` is in that
22
- * set for webpack parity: an external package without `src/` is ingested
23
- * via its resolved dist entry (often `dist/index.mjs`) and must still
24
- * reach the loader — manifest lookup remains the file-level gate. */
17
+ /** The one glob the loader registers under, derived from the shared engine
18
+ * extension set so the bundler families cannot drift. `.mjs` belongs in that
19
+ * set: an external package with no src/ is ingested through its dist entry
20
+ * and must still reach the loader, so do not trim it. */
25
21
  export declare const ANIMUS_TURBOPACK_RULE_GLOB: string;
26
22
  export { TURBOPACK_SYSTEM_PROPS_ID };
27
- /**
28
- * Resolve whether Turbopack wiring is active for this process. Default is
29
- * `'auto'`: active exactly when the TURBOPACK environment variable is set
30
- * (Next sets it for every Turbopack dev/build). The stable `turbopack`
31
- * option wins over the deprecated `unstable_turbopack` alias.
32
- */
33
23
  export declare function resolveTurbopackMode(options: AnimusNextOptions, env?: Record<string, string | undefined>): boolean;
34
- /**
35
- * Build the `turbopack` config fragment: one glob-keyed loader rule
36
- * (file-level allowlisting lives in the loader via manifest lookup — Next 15
37
- * rules have no condition algebra) plus resolve aliases for the virtual
38
- * system-props id, the emitter's stylesheet id, and each collected external
39
- * package specifier redirected to its source entry. Loader options carry
40
- * the session identity (design D2: an options-borne, JSON-serializable
41
- * Turbopack task input — restart-cold by construction), and the artifact
42
- * aliases point into the session-scoped tree.
43
- */
44
24
  export declare function buildTurbopackConfig(args: {
45
25
  rootDir: string;
46
26
  loaderPath: string;
@@ -49,12 +29,5 @@ export declare function buildTurbopackConfig(args: {
49
29
  sessionId: string;
50
30
  sessionDir: string;
51
31
  }): TurbopackConfigFragment;
52
- /**
53
- * Locate the Turbopack loader module: built dist first, source fallback for
54
- * in-repo development. CJS preferred — Turbopack's loader-runner follows
55
- * the webpack loader contract (`module.exports = fn`), and the .cjs build
56
- * is loadable by every runner version; ESM default-export acceptance is
57
- * not guaranteed.
58
- */
59
32
  export declare function resolveTurbopackLoaderPath(pluginDir: string): string;
60
33
  //# sourceMappingURL=turbopack-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"turbopack-config.d.ts","sourceRoot":"","sources":["../src/turbopack-config.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,uBAAuB;I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AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;;0DAG0D;AAC1D,eAAO,MAAM,0BAA0B,QAAiD,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAMT;AAMD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,qBAAqB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,uBAAuB,CA0C1B;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMpE"}
@@ -19,12 +19,12 @@ var __copyProps = (to, from, except, desc) => {
19
19
  }
20
20
  return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
23
  value: mod,
24
24
  enumerable: true
25
25
  }) : target, mod));
26
26
  //#endregion
27
- const require_loader_core = require("./loader-core-D2rh--tX.cjs");
27
+ const require_loader_core = require("./loader-core-BthLSJQF.cjs");
28
28
  let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
29
29
  let _animus_ui_extract_session = require("@animus-ui/extract/session");
30
30
  let fs = require("fs");
@@ -34,11 +34,8 @@ let path = require("path");
34
34
  let engine = null;
35
35
  let sentSources = null;
36
36
  let driftWarned = false;
37
- /** Hydration identity: `${commitPath}:${contentHash(commitRaw)}` — the
38
- * commit CONTENT keys hydration; mtime/size never do (design D1). */
39
37
  let hydratedKey = null;
40
38
  let hydratedManifestJson = null;
41
- /** Committed per-file analyzed content hashes (from the inputs). */
42
39
  let hydratedFileHashes = null;
43
40
  const engineModuleId = "@animus-ui/extract";
44
41
  const engineApi = (0, _animus_ui_extract_pipeline.createV2EngineApi)({
@@ -61,15 +58,18 @@ const engineApi = (0, _animus_ui_extract_pipeline.createV2EngineApi)({
61
58
  }
62
59
  }
63
60
  });
61
+ let engineApiImpl = engineApi;
62
+ /** @internal test seam. */
63
+ function __setTurbopackLoaderEngineApiForTests(api) {
64
+ engineApiImpl = api ?? engineApi;
65
+ }
64
66
  let fsImpl = fs;
65
- /** @internal test seam — pass null to restore the real fs. */
67
+ /** @internal test seam. */
66
68
  function __setTurbopackLoaderFsForTests(fs$1) {
67
69
  fsImpl = fs$1 ?? fs;
68
70
  }
69
- /** Epoch artifact paths SEEN on disk (per-worker) — the artifact is never
70
- * deleted once written, so a positive probe is stable; negatives re-probe. */
71
71
  const epochSeenPaths = /* @__PURE__ */ new Set();
72
- /** @internal test seam — drop worker-local hydration state. */
72
+ /** @internal test seam. */
73
73
  function __resetTurbopackLoaderStateForTests() {
74
74
  hydratedKey = null;
75
75
  hydratedManifestJson = null;
@@ -83,16 +83,10 @@ function readFileOrNull(path$1) {
83
83
  return null;
84
84
  }
85
85
  }
86
- const SEQLOCK_RETRIES = 5;
87
- /**
88
- * Seqlock-style artifact read: commit C0 → payloads → hash verification
89
- * against C0 → commit re-read; accept only if unchanged, else retry
90
- * (bounded) — a torn or mismatched set is never consumed (design D1).
91
- * Hydration replays the committed analysis inputs once per commit content.
92
- */
86
+ const ARTIFACT_READ_RETRIES = 5;
93
87
  function hydrateSession(sessionDir, sessionId) {
94
88
  const commitPath = (0, _animus_ui_extract_session.analysisCommitPath)(sessionDir);
95
- for (let attempt = 0; attempt < SEQLOCK_RETRIES; attempt++) {
89
+ for (let attempt = 0; attempt < ARTIFACT_READ_RETRIES; attempt++) {
96
90
  const c0raw = readFileOrNull(commitPath);
97
91
  if (c0raw === null) return { kind: "absent" };
98
92
  let c0;
@@ -129,11 +123,11 @@ function hydrateSession(sessionDir, sessionId) {
129
123
  };
130
124
  const inputsParsed = JSON.parse(inputsRaw);
131
125
  inputs = inputsParsed;
132
- fileHashes = inputsParsed.analyzedHashes ? new Map(Object.entries(inputsParsed.analyzedHashes)) : new Map(JSON.parse(inputs.filesJson).map((entry) => [entry.path, entry.hash ?? (0, _animus_ui_extract_pipeline.contentHash)(entry.source)]));
126
+ fileHashes = inputsParsed.analyzedHashes ? new Map(Object.entries(inputsParsed.analyzedHashes)) : new Map((0, _animus_ui_extract_pipeline.parseFilesJson)(inputs.filesJson, "animus-next-turbopack").map((entry) => [entry.path, entry.hash ?? (0, _animus_ui_extract_pipeline.contentHash)(entry.source)]));
133
127
  } catch {
134
128
  return { kind: "torn" };
135
129
  }
136
- const { analyzeProject } = engineApi();
130
+ const { analyzeProject } = engineApiImpl();
137
131
  hydratedManifestJson = analyzeProject(...(0, _animus_ui_extract_pipeline.buildAnalyzeProjectArgs)(inputs));
138
132
  hydratedFileHashes = fileHashes;
139
133
  hydratedKey = key;
@@ -157,33 +151,28 @@ function readStatus(sessionDir) {
157
151
  return null;
158
152
  }
159
153
  }
154
+ const hasReadableDeadline = (status) => Object.prototype.toString.call(status.deadlineAt) === "[object Number]";
160
155
  const CATCHUP_POLL_INITIAL_MS = 10;
161
156
  const CATCHUP_POLL_MAX_MS = 25;
162
157
  const CATCHUP_WAIT_MARGIN_MS = 50;
163
- const CATCHUP_WATCHDOG_MS = 2e3;
164
- /** The loader cannot read the orchestrator's configured debounce, so its
165
- * own ceiling assumes the default watcher debounce. */
166
- const DEFAULT_DEBOUNCE_CEILING_MS = 75;
158
+ /** Bounds the one wait carrying no deadline — a status whose `deadlineAt` is
159
+ * not numeric. The session-published deadline bounds every other wait.
160
+ * Equal to the session's status watchdog by coincidence only: never unify
161
+ * them, and never re-derive a deadline from the watcher debounce. */
162
+ const CATCHUP_NO_DEADLINE_CAP_MS = 2e3;
167
163
  function sleep(ms) {
168
164
  return new Promise((resolve) => setTimeout(resolve, ms));
169
165
  }
170
- const ACTIVE_STATES = new Set([
166
+ const ACTIVE_STATES = /* @__PURE__ */ new Set([
171
167
  "starting",
172
168
  "debouncing",
173
169
  "analyzing",
174
170
  "committing"
175
171
  ]);
176
- /**
177
- * Turbopack loader for Animus source transformation. Derives everything
178
- * from the incoming source, its JSON-serializable options (carrying the
179
- * session identity), and the session's COMMITTED disk artifacts written by
180
- * the out-of-band orchestrator. Async by contract — the evidence-based
181
- * catch-up (design D3) waits, bounded, for an imminent commit.
182
- */
183
172
  function animusTurbopackLoader(source) {
184
- if (typeof this.async !== "function") throw new Error("[animus-extract] the Animus Turbopack loader requires an async-capable loader runner (this.async is unavailable)");
173
+ if (this.async === void 0) throw new Error("[animus-extract] the Animus Turbopack loader requires an async-capable loader runner (this.async is unavailable)");
185
174
  const callback = this.async();
186
- runLoader(this, source).then((code) => callback(null, code), (err) => callback(err instanceof Error ? err : new Error(String(err))));
175
+ runLoader(this, source).then((code) => callback(null, code), (thrown) => callback(thrown instanceof Error ? thrown : new Error(String(thrown))));
187
176
  }
188
177
  async function runLoader(ctx, source) {
189
178
  const opts = ctx.getOptions?.() ?? {};
@@ -194,17 +183,15 @@ async function runLoader(ctx, source) {
194
183
  const commitPath = (0, _animus_ui_extract_session.analysisCommitPath)(sessionDir);
195
184
  const statusPath = (0, _animus_ui_extract_session.analysisStatusPath)(sessionDir);
196
185
  const epochPath = (0, _animus_ui_extract_session.replacementEpochPath)(sessionDir);
197
- if (typeof ctx.addDependency === "function" && (epochSeenPaths.has(epochPath) || fsImpl.existsSync(epochPath))) {
186
+ if (ctx.addDependency !== void 0 && (epochSeenPaths.has(epochPath) || fsImpl.existsSync(epochPath))) {
198
187
  epochSeenPaths.add(epochPath);
199
188
  ctx.addDependency(epochPath);
200
189
  }
201
190
  const filename = (0, path.relative)(rootDir, ctx.resourcePath);
202
- /** EVERY failing path registers the commit + status artifacts as
203
- * dependencies BEFORE throwing (the loader-runner sends dependency IPC
204
- * ahead of the error check upstream), so a landing commit or status
205
- * transition re-triggers the invocation — the documented
206
- * read→registration race makes this a recovery aid, never the primary
207
- * wakeup (design D3). Successful paths add NO commit/status dependency. */
191
+ /** Registers commit and status as dependencies before throwing: the runner
192
+ * sends dependency IPC ahead of the error, so a landing commit re-fires.
193
+ * Failure paths only — successful paths register neither, so this must not
194
+ * be hoisted out of the failure helper. */
208
195
  const coverageFailure = (message) => {
209
196
  ctx.addDependency?.(commitPath);
210
197
  ctx.addDependency?.(statusPath);
@@ -214,12 +201,12 @@ async function runLoader(ctx, source) {
214
201
  source,
215
202
  filename,
216
203
  manifestJson,
217
- engineApi,
204
+ engineApi: engineApiImpl,
218
205
  opts
219
206
  });
220
207
  const outcome = hydrateSession(sessionDir, sessionId);
221
208
  if (outcome.kind === "foreign") throw coverageFailure(`ANIMUS_FOREIGN_SESSION: artifacts under ${sessionDir} belong to session ${outcome.artifactSessionId}, not ${sessionId} — refusing to transform from a foreign generation`);
222
- if (outcome.kind === "torn") throw coverageFailure(`ANIMUS_ARTIFACT_READ_TORN: could not obtain a consistent committed artifact set for ${filename} after ${SEQLOCK_RETRIES} attempts`);
209
+ if (outcome.kind === "torn") throw coverageFailure(`ANIMUS_ARTIFACT_READ_TORN: could not obtain a consistent committed artifact set for ${filename} after ${ARTIFACT_READ_RETRIES} attempts`);
223
210
  let sourceHash = null;
224
211
  if (outcome.kind === "ok") {
225
212
  const analyzedHash = outcome.hydration.fileHashes.get(filename);
@@ -237,17 +224,9 @@ async function runLoader(ctx, source) {
237
224
  transform
238
225
  });
239
226
  }
240
- /**
241
- * The catch-up decision table (design D3 — implemented verbatim). Waits —
242
- * polled, bounded — ONLY in the two evidence states: commit absent while an
243
- * attempt is active, or the active attempt's pending set contains this file
244
- * at its current hash. Everything else fails immediately with its stable
245
- * diagnostic. The moment a commit lands that covers the input, the seqlock
246
- * hydration consumes it and the transform proceeds with no diagnostic.
247
- */
248
227
  async function awaitCoverage(args) {
249
228
  const { source, sourceHash, filename, sessionId, sessionDir, coverageFailure, transform } = args;
250
- const ceiling = Date.now() + DEFAULT_DEBOUNCE_CEILING_MS + CATCHUP_WATCHDOG_MS + CATCHUP_WAIT_MARGIN_MS;
229
+ const noDeadlineCap = Date.now() + CATCHUP_NO_DEADLINE_CAP_MS + CATCHUP_WAIT_MARGIN_MS;
251
230
  let poll = CATCHUP_POLL_INITIAL_MS;
252
231
  for (;;) {
253
232
  const outcome = hydrateSession(sessionDir, sessionId);
@@ -269,14 +248,15 @@ async function awaitCoverage(args) {
269
248
  if (!(status.pending ?? []).some(([key, hash]) => key === filename && hash === sourceHash)) throw coverageFailure(`ANIMUS_ANALYSIS_NOT_SCHEDULED: the active analysis attempt (${status.attemptId}) has not observed ${filename} at its current content`);
270
249
  }
271
250
  const now = Date.now();
272
- if (typeof status.deadlineAt === "number" && now > status.deadlineAt) throw coverageFailure(`ANIMUS_ANALYSIS_STALLED: analysis attempt ${status.attemptId} exceeded its deadline while ${filename} waited for coverage`);
273
- if (now > ceiling) throw coverageFailure(`ANIMUS_ANALYSIS_CATCHING_UP: ${filename} changed after the committed analysis; timed out waiting for the commit to advance — retrying on the next invalidation`);
251
+ if (hasReadableDeadline(status)) {
252
+ if (now > status.deadlineAt) throw coverageFailure(`ANIMUS_ANALYSIS_STALLED: analysis attempt ${status.attemptId} exceeded its deadline while ${filename} waited for coverage`);
253
+ } else if (now > noDeadlineCap) throw coverageFailure(`ANIMUS_ANALYSIS_CATCHING_UP: ${filename} changed after the committed analysis; timed out waiting for the commit to advance — retrying on the next invalidation`);
274
254
  await sleep(poll);
275
255
  poll = CATCHUP_POLL_MAX_MS;
276
256
  }
277
257
  }
278
258
  //#endregion
279
259
  exports.__resetTurbopackLoaderStateForTests = __resetTurbopackLoaderStateForTests;
260
+ exports.__setTurbopackLoaderEngineApiForTests = __setTurbopackLoaderEngineApiForTests;
280
261
  exports.__setTurbopackLoaderFsForTests = __setTurbopackLoaderFsForTests;
281
- exports.__toESM = __toESM;
282
262
  exports.default = animusTurbopackLoader;
@@ -1,39 +1,27 @@
1
1
  import * as nodeFs from 'fs';
2
- import type { LoaderPolicyOptions } from './loader-core';
3
- /** JSON-serializable loader options (Turbopack forwards them across process
4
- * boundaries). The session identity is a REAL task input (design D2):
5
- * restarts mint a new session id, so cross-session cache reuse is
6
- * impossible by construction — restart-cold is normative. */
2
+ import type { LoaderContextBase, LoaderPolicyOptions } from './loader-core';
3
+ import type { EngineApi } from '@animus-ui/extract/pipeline';
4
+ /** Turbopack runs loaders in isolated worker processes, so globalThis-keyed
5
+ * session state answers about another process: identity arrives through
6
+ * these options. The session barrel may be imported here for its pure path
7
+ * builders and JSON readers only, never for its singleton accessors. */
7
8
  export interface TurbopackLoaderOptions extends LoaderPolicyOptions {
8
9
  rootDir?: string;
9
10
  sessionId?: string;
10
11
  sessionDir?: string;
11
12
  }
12
13
  type LoaderCallback = (err: Error | null, content?: string) => void;
13
- type LoaderContext = {
14
- resourcePath: string;
15
- rootContext: string;
16
- getOptions: () => TurbopackLoaderOptions;
17
- /** File-dependency registration (Turbopack loader-runner IPC sends
18
- * dependencies BEFORE the error check — throw-after-addDependency is a
19
- * sound recovery primitive; see design D3). */
20
- addDependency?: (file: string) => void;
21
- /** Async-completion handle (webpack loader convention) — required: the
22
- * evidence-based catch-up wait cannot run synchronously. */
14
+ type LoaderContext = LoaderContextBase<TurbopackLoaderOptions> & {
23
15
  async?: () => LoaderCallback;
24
16
  };
17
+ type LoaderEngineApi = () => Pick<EngineApi, 'analyzeProject' | 'transformFile'>;
18
+ /** @internal test seam. */
19
+ export declare function __setTurbopackLoaderEngineApiForTests(api: LoaderEngineApi | null): void;
25
20
  type LoaderFs = Pick<typeof nodeFs, 'readFileSync' | 'existsSync'>;
26
- /** @internal test seam — pass null to restore the real fs. */
21
+ /** @internal test seam. */
27
22
  export declare function __setTurbopackLoaderFsForTests(fs: LoaderFs | null): void;
28
- /** @internal test seam — drop worker-local hydration state. */
23
+ /** @internal test seam. */
29
24
  export declare function __resetTurbopackLoaderStateForTests(): void;
30
- /**
31
- * Turbopack loader for Animus source transformation. Derives everything
32
- * from the incoming source, its JSON-serializable options (carrying the
33
- * session identity), and the session's COMMITTED disk artifacts written by
34
- * the out-of-band orchestrator. Async by contract — the evidence-based
35
- * catch-up (design D3) waits, bounded, for an imminent commit.
36
- */
37
25
  export default function animusTurbopackLoader(this: LoaderContext, source: string): void;
38
26
  export {};
39
27
  //# sourceMappingURL=turbopack-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"turbopack-loader.d.ts","sourceRoot":"","sources":["../src/turbopack-loader.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,MAAM,MAAM,IAAI,CAAC;AAK7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAOzD;;;8DAG8D;AAC9D,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpE,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,sBAAsB,CAAC;IACzC;;oDAEgD;IAChD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;iE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