@animus-ui/next-plugin 0.1.7 → 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.
@@ -1,15 +1,18 @@
1
- import { t as __require } from "./chunk-y_GBKt04.mjs";
1
+ import { S as __require, _ as replacementEpochPath, d as analysisStatusPath, g as readJsonEnvelope, l as analysisCommitPath, m as manifestPath, u as analysisInputsPath, v as sessionArtifactDir } from "./session-paths-DfYIPDcM.mjs";
2
2
  import { t as transformWithManifest } from "./loader-core-D6Tm_b8F.mjs";
3
- import { buildAnalyzeProjectArgs, createV2EngineApi } from "@animus-ui/extract/pipeline";
4
- import { readFileSync, statSync } from "fs";
5
- import { join, relative } from "path";
3
+ import { buildAnalyzeProjectArgs, contentHash, createV2EngineApi } from "@animus-ui/extract/pipeline";
4
+ import * as nodeFs from "fs";
5
+ import { relative } from "path";
6
6
  //#region src/turbopack-loader.ts
7
7
  let engine = null;
8
8
  let sentSources = null;
9
9
  let driftWarned = false;
10
+ /** Hydration identity: `${commitPath}:${contentHash(commitRaw)}` — the
11
+ * commit CONTENT keys hydration; mtime/size never do (design D1). */
10
12
  let hydratedKey = null;
11
13
  let hydratedManifestJson = null;
12
- let hydrateFailedWarned = false;
14
+ /** Committed per-file analyzed content hashes (from the inputs). */
15
+ let hydratedFileHashes = null;
13
16
  const engineModuleId = "@animus-ui/extract";
14
17
  const engineApi = createV2EngineApi({
15
18
  label: "animus-next-turbopack",
@@ -31,61 +34,219 @@ const engineApi = createV2EngineApi({
31
34
  }
32
35
  }
33
36
  });
34
- /**
35
- * Hydrate this worker's engine from the `.animus/` artifact pair — the v2
36
- * engine serves transforms only from analyze-retained state, so a fresh
37
- * worker replays the persisted analysis inputs once (and again whenever
38
- * either artifact changes; keyed by mtime+size of both). The persisted
39
- * manifest is a hard prerequisite (spec: next-turbopack-integration /
40
- * Stateless per-file transformation — absent or unreadable
41
- * `.animus/manifest.json` means passthrough, even when analysis inputs
42
- * exist). Returns the manifest JSON, or null (caller passes through).
43
- */
44
- function hydrate(rootDir) {
45
- const inputsPath = join(rootDir, ".animus", "analysis-inputs.json");
46
- const manifestPath = join(rootDir, ".animus", "manifest.json");
47
- let inputsStat;
48
- let manifestStat;
37
+ let fsImpl = nodeFs;
38
+ /** @internal test seam — pass null to restore the real fs. */
39
+ function __setTurbopackLoaderFsForTests(fs) {
40
+ fsImpl = fs ?? nodeFs;
41
+ }
42
+ /** Epoch artifact paths SEEN on disk (per-worker) — the artifact is never
43
+ * deleted once written, so a positive probe is stable; negatives re-probe. */
44
+ const epochSeenPaths = /* @__PURE__ */ new Set();
45
+ /** @internal test seam — drop worker-local hydration state. */
46
+ function __resetTurbopackLoaderStateForTests() {
47
+ hydratedKey = null;
48
+ hydratedManifestJson = null;
49
+ hydratedFileHashes = null;
50
+ epochSeenPaths.clear();
51
+ }
52
+ function readFileOrNull(path) {
49
53
  try {
50
- inputsStat = statSync(inputsPath, { bigint: true });
51
- manifestStat = statSync(manifestPath, { bigint: true });
54
+ return fsImpl.readFileSync(path, "utf-8");
52
55
  } catch {
53
56
  return null;
54
57
  }
55
- const key = `${inputsPath}:${inputsStat.mtimeNs}:${inputsStat.size}:${manifestStat.mtimeNs}:${manifestStat.size}`;
56
- if (key === hydratedKey && hydratedManifestJson !== null) return hydratedManifestJson;
57
- try {
58
- JSON.parse(readFileSync(manifestPath, "utf-8"));
59
- const inputs = JSON.parse(readFileSync(inputsPath, "utf-8"));
58
+ }
59
+ const SEQLOCK_RETRIES = 5;
60
+ /**
61
+ * Seqlock-style artifact read: commit C0 → payloads → hash verification
62
+ * against C0 → commit re-read; accept only if unchanged, else retry
63
+ * (bounded) — a torn or mismatched set is never consumed (design D1).
64
+ * Hydration replays the committed analysis inputs once per commit content.
65
+ */
66
+ function hydrateSession(sessionDir, sessionId) {
67
+ const commitPath = analysisCommitPath(sessionDir);
68
+ for (let attempt = 0; attempt < SEQLOCK_RETRIES; attempt++) {
69
+ const c0raw = readFileOrNull(commitPath);
70
+ if (c0raw === null) return { kind: "absent" };
71
+ let c0;
72
+ try {
73
+ c0 = JSON.parse(c0raw);
74
+ } catch {
75
+ continue;
76
+ }
77
+ if (c0.sessionId !== sessionId) return {
78
+ kind: "foreign",
79
+ artifactSessionId: String(c0.sessionId)
80
+ };
81
+ const key = `${commitPath}:${contentHash(c0raw)}`;
82
+ if (key === hydratedKey && hydratedManifestJson !== null && hydratedFileHashes !== null) return {
83
+ kind: "ok",
84
+ hydration: {
85
+ manifestJson: hydratedManifestJson,
86
+ fileHashes: hydratedFileHashes,
87
+ commitRaw: c0raw
88
+ }
89
+ };
90
+ const manifestRaw = readFileOrNull(manifestPath(sessionDir));
91
+ const inputsRaw = readFileOrNull(analysisInputsPath(sessionDir));
92
+ if (manifestRaw === null || inputsRaw === null) continue;
93
+ if (contentHash(manifestRaw) !== c0.manifestHash || contentHash(inputsRaw) !== c0.inputsHash) continue;
94
+ if (readFileOrNull(commitPath) !== c0raw) continue;
95
+ let inputs;
96
+ let fileHashes;
97
+ try {
98
+ const envelopeSession = readJsonEnvelope(manifestRaw)?.sessionId;
99
+ if (envelopeSession !== void 0 && envelopeSession !== sessionId) return {
100
+ kind: "foreign",
101
+ artifactSessionId: String(envelopeSession)
102
+ };
103
+ const inputsParsed = JSON.parse(inputsRaw);
104
+ inputs = inputsParsed;
105
+ fileHashes = inputsParsed.analyzedHashes ? new Map(Object.entries(inputsParsed.analyzedHashes)) : new Map(JSON.parse(inputs.filesJson).map((entry) => [entry.path, entry.hash ?? contentHash(entry.source)]));
106
+ } catch {
107
+ return { kind: "torn" };
108
+ }
60
109
  const { analyzeProject } = engineApi();
61
110
  hydratedManifestJson = analyzeProject(...buildAnalyzeProjectArgs(inputs));
111
+ hydratedFileHashes = fileHashes;
62
112
  hydratedKey = key;
63
- return hydratedManifestJson;
64
- } catch (e) {
65
- if (!hydrateFailedWarned) {
66
- hydrateFailedWarned = true;
67
- console.warn(`[animus-extract] Turbopack worker hydration failed (${String(e)}); sources pass through untransformed`);
68
- }
113
+ return {
114
+ kind: "ok",
115
+ hydration: {
116
+ manifestJson: hydratedManifestJson,
117
+ fileHashes,
118
+ commitRaw: c0raw
119
+ }
120
+ };
121
+ }
122
+ return { kind: "torn" };
123
+ }
124
+ function readStatus(sessionDir) {
125
+ const raw = readFileOrNull(analysisStatusPath(sessionDir));
126
+ if (raw === null) return null;
127
+ try {
128
+ return JSON.parse(raw);
129
+ } catch {
69
130
  return null;
70
131
  }
71
132
  }
133
+ const CATCHUP_POLL_INITIAL_MS = 10;
134
+ const CATCHUP_POLL_MAX_MS = 25;
135
+ const CATCHUP_WAIT_MARGIN_MS = 50;
136
+ const CATCHUP_WATCHDOG_MS = 2e3;
137
+ /** The loader cannot read the orchestrator's configured debounce, so its
138
+ * own ceiling assumes the default watcher debounce. */
139
+ const DEFAULT_DEBOUNCE_CEILING_MS = 75;
140
+ function sleep(ms) {
141
+ return new Promise((resolve) => setTimeout(resolve, ms));
142
+ }
143
+ const ACTIVE_STATES = new Set([
144
+ "starting",
145
+ "debouncing",
146
+ "analyzing",
147
+ "committing"
148
+ ]);
72
149
  /**
73
150
  * Turbopack loader for Animus source transformation. Derives everything
74
- * from the incoming source, its JSON-serializable options, and the
75
- * `.animus/` disk artifacts written by the out-of-band orchestrator.
151
+ * from the incoming source, its JSON-serializable options (carrying the
152
+ * session identity), and the session's COMMITTED disk artifacts written by
153
+ * the out-of-band orchestrator. Async by contract — the evidence-based
154
+ * catch-up (design D3) waits, bounded, for an imminent commit.
76
155
  */
77
156
  function animusTurbopackLoader(source) {
78
- const opts = this.getOptions?.() ?? {};
79
- const rootDir = opts.rootDir ?? this.rootContext;
80
- const manifestJson = hydrate(rootDir);
81
- if (!manifestJson) return source;
82
- return transformWithManifest({
157
+ if (typeof this.async !== "function") throw new Error("[animus-extract] the Animus Turbopack loader requires an async-capable loader runner (this.async is unavailable)");
158
+ const callback = this.async();
159
+ runLoader(this, source).then((code) => callback(null, code), (err) => callback(err instanceof Error ? err : new Error(String(err))));
160
+ }
161
+ async function runLoader(ctx, source) {
162
+ const opts = ctx.getOptions?.() ?? {};
163
+ const rootDir = opts.rootDir ?? ctx.rootContext;
164
+ const sessionId = opts.sessionId;
165
+ const sessionDir = opts.sessionDir ?? (sessionId !== void 0 ? sessionArtifactDir(rootDir, sessionId) : void 0);
166
+ if (sessionId === void 0 || sessionDir === void 0) return source;
167
+ const commitPath = analysisCommitPath(sessionDir);
168
+ const statusPath = analysisStatusPath(sessionDir);
169
+ const epochPath = replacementEpochPath(sessionDir);
170
+ if (typeof ctx.addDependency === "function" && (epochSeenPaths.has(epochPath) || fsImpl.existsSync(epochPath))) {
171
+ epochSeenPaths.add(epochPath);
172
+ ctx.addDependency(epochPath);
173
+ }
174
+ const filename = relative(rootDir, ctx.resourcePath);
175
+ /** EVERY failing path registers the commit + status artifacts as
176
+ * dependencies BEFORE throwing (the loader-runner sends dependency IPC
177
+ * ahead of the error check upstream), so a landing commit or status
178
+ * transition re-triggers the invocation — the documented
179
+ * read→registration race makes this a recovery aid, never the primary
180
+ * wakeup (design D3). Successful paths add NO commit/status dependency. */
181
+ const coverageFailure = (message) => {
182
+ ctx.addDependency?.(commitPath);
183
+ ctx.addDependency?.(statusPath);
184
+ return new Error(message);
185
+ };
186
+ const transform = (manifestJson) => transformWithManifest({
83
187
  source,
84
- filename: relative(rootDir, this.resourcePath),
188
+ filename,
85
189
  manifestJson,
86
190
  engineApi,
87
191
  opts
88
192
  });
193
+ const outcome = hydrateSession(sessionDir, sessionId);
194
+ 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`);
195
+ if (outcome.kind === "torn") throw coverageFailure(`ANIMUS_ARTIFACT_READ_TORN: could not obtain a consistent committed artifact set for ${filename} after ${SEQLOCK_RETRIES} attempts`);
196
+ let sourceHash = null;
197
+ if (outcome.kind === "ok") {
198
+ const analyzedHash = outcome.hydration.fileHashes.get(filename);
199
+ if (analyzedHash === void 0) return transform(outcome.hydration.manifestJson);
200
+ sourceHash = contentHash(source);
201
+ if (analyzedHash === sourceHash) return transform(outcome.hydration.manifestJson);
202
+ }
203
+ return awaitCoverage({
204
+ source,
205
+ sourceHash: sourceHash ?? contentHash(source),
206
+ filename,
207
+ sessionId,
208
+ sessionDir,
209
+ coverageFailure,
210
+ transform
211
+ });
212
+ }
213
+ /**
214
+ * The catch-up decision table (design D3 — implemented verbatim). Waits —
215
+ * polled, bounded — ONLY in the two evidence states: commit absent while an
216
+ * attempt is active, or the active attempt's pending set contains this file
217
+ * at its current hash. Everything else fails immediately with its stable
218
+ * diagnostic. The moment a commit lands that covers the input, the seqlock
219
+ * hydration consumes it and the transform proceeds with no diagnostic.
220
+ */
221
+ async function awaitCoverage(args) {
222
+ const { source, sourceHash, filename, sessionId, sessionDir, coverageFailure, transform } = args;
223
+ const ceiling = Date.now() + DEFAULT_DEBOUNCE_CEILING_MS + CATCHUP_WATCHDOG_MS + CATCHUP_WAIT_MARGIN_MS;
224
+ let poll = CATCHUP_POLL_INITIAL_MS;
225
+ for (;;) {
226
+ const outcome = hydrateSession(sessionDir, sessionId);
227
+ if (outcome.kind === "foreign") throw coverageFailure(`ANIMUS_FOREIGN_SESSION: artifacts under ${sessionDir} belong to session ${outcome.artifactSessionId}, not ${sessionId}`);
228
+ if (outcome.kind === "ok") {
229
+ const analyzedHash = outcome.hydration.fileHashes.get(filename);
230
+ if (analyzedHash !== void 0 && analyzedHash === sourceHash) return transform(outcome.hydration.manifestJson);
231
+ }
232
+ const commitPresent = outcome.kind === "ok";
233
+ const status = readStatus(sessionDir);
234
+ if (status === null) {
235
+ if (!commitPresent) return source;
236
+ throw coverageFailure(`ANIMUS_ANALYSIS_CATCHING_UP: ${filename} is not covered by the committed analysis and no analysis-status exists for session ${sessionId} — is the animus orchestrator running?`);
237
+ }
238
+ if (status.sessionId !== sessionId) throw coverageFailure(`ANIMUS_FOREIGN_SESSION: analysis-status belongs to session ${status.sessionId}, not ${sessionId}`);
239
+ if (status.state === "failed") throw coverageFailure(`ANIMUS_ANALYSIS_FAILED: the analysis covering ${filename} failed: ${status.diagnostic ?? "unknown analysis error"}`);
240
+ if (status.state === "idle" || !ACTIVE_STATES.has(status.state)) throw coverageFailure(`ANIMUS_ANALYSIS_NOT_SCHEDULED: ${filename} changed but no analysis attempt is scheduled for it (watcher miss?)`);
241
+ if (commitPresent) {
242
+ 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`);
243
+ }
244
+ const now = Date.now();
245
+ 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`);
246
+ 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`);
247
+ await sleep(poll);
248
+ poll = CATCHUP_POLL_MAX_MS;
249
+ }
89
250
  }
90
251
  //#endregion
91
- export { animusTurbopackLoader as default };
252
+ export { __resetTurbopackLoaderStateForTests, __setTurbopackLoaderFsForTests, animusTurbopackLoader as default };
@@ -7,9 +7,12 @@ import type { ExtractionSession } from './extraction-session';
7
7
  * filesystem watcher — the bundler only ever sees the `.animus/` disk
8
8
  * artifacts.
9
9
  */
10
- /** Run the full pipeline with the Turbopack emitter identity: hydration
11
- * artifacts persisted, and the virtual system-props id (Turbopack rejects
12
- * the webpack path's absolute-path imports). */
10
+ /** Run the full pipeline with the Turbopack emitter identity: the virtual
11
+ * system-props id (Turbopack rejects the webpack path's absolute-path
12
+ * imports). Turbopack orchestration persists the analysis-inputs
13
+ * hydration corpus — its isolated loader workers replay it (spec:
14
+ * next-turbopack-integration, "Manifest disk artifact"; webpack mode
15
+ * skips the corpus). */
13
16
  export declare function runTurbopackPipeline(session: ExtractionSession): Promise<void>;
14
17
  /**
15
18
  * Start the dev watcher: fs.watch per eligible top-level directory (plus a
@@ -1 +1 @@
1
- {"version":3,"file":"turbopack-orchestrator.d.ts","sourceRoot":"","sources":["../src/turbopack-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,EAAE,MAAM,IAAI,CAAC;AAK9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AAEH;;iDAEiD;AACjD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAIf;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,EACf,UAAU,SAAK,EAGf,OAAO,GAAE,OAAO,KAAa,GAC5B;IAAE,KAAK,IAAI,IAAI,CAAA;CAAE,GAAG,IAAI,CA0G1B"}
1
+ {"version":3,"file":"turbopack-orchestrator.d.ts","sourceRoot":"","sources":["../src/turbopack-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,EAAE,MAAM,IAAI,CAAC;AAK9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AAEH;;;;;yBAKyB;AACzB,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAIf;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,EACf,UAAU,SAAK,EAGf,OAAO,GAAE,OAAO,KAAa,GAC5B;IAAE,KAAK,IAAI,IAAI,CAAA;CAAE,GAAG,IAAI,CAiS1B"}
package/dist/types.d.ts CHANGED
@@ -85,6 +85,13 @@ export interface AnimusNextOptions {
85
85
  unstable_turbopack?: {
86
86
  mode?: 'off' | 'auto' | 'on';
87
87
  };
88
+ /**
89
+ * @internal Absolute path of the loader module registered in the webpack
90
+ * rule when it is not this package's own dist/src loader (test harnesses
91
+ * wrapping the real loader in a require-able shim). Feeds the needBuild
92
+ * loader-chain predicate; `withAnimus` never sets it.
93
+ */
94
+ loaderPath?: string;
88
95
  /**
89
96
  * Full `@layer` declaration order. Must include all 7 Animus `anm-*`
90
97
  * layers (`anm-global`, `anm-base`, `anm-variants`, `anm-compounds`,
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;KAAE,CAAC;IAC7C;;;OAGG;IACH,kBAAkB,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACtD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;KAAE,CAAC;IAC7C;;;OAGG;IACH,kBAAkB,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACtD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,KAAK,aAAa,GAAG;IACnB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,KAAK,CAAC;YACZ,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,GAAG,CAAC,EAAE,KAAK,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aAAE,CAAC,CAAC;SACpE,CAAC,CAAC;KACJ,CAAC;CACH,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1C,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,aAAa,CAAC;CACpB,CAAC;AAKF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,iBAAiB,GACzB,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAiN9D"}
1
+ {"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,KAAK,aAAa,GAAG;IACnB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,KAAK,CAAC;YACZ,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;YAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,GAAG,CAAC,EAAE,KAAK,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aAAE,CAAC,CAAC;SACpE,CAAC,CAAC;KACJ,CAAC;CACH,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1C,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,aAAa,CAAC;CACpB,CAAC;AAKF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,iBAAiB,GACzB,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAwN9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/next-plugin",
3
- "version": "0.1.7",
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.7"
43
+ "@animus-ui/extract": "0.1.9"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@mdx-js/mdx": "^3.0.0",
@@ -1,5 +0,0 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
- //#endregion
5
- export { __require as t };
@@ -1,108 +0,0 @@
1
- import { t as __require } from "./chunk-y_GBKt04.mjs";
2
- import { createV2EngineApi } from "@animus-ui/extract/pipeline";
3
- //#region src/singleton.ts
4
- /**
5
- * Module-scope singleton for sharing analysis state between the webpack plugin and loader.
6
- *
7
- * Uses globalThis to survive the ESM/CJS module boundary: the plugin is loaded via ESM
8
- * (next.config.ts import) while the loader is loaded by webpack via require(). Without
9
- * globalThis, each module system gets its own singleton instance.
10
- */
11
- const MANIFEST_KEY = "__animus_manifest_json__";
12
- const PROMISE_KEY = "__animus_analysis_promise__";
13
- const SHARED_CSS_KEY = "__animus_shared_css__";
14
- const SHARED_SYSTEM_PROPS_KEY = "__animus_shared_system_props__";
15
- const SHARED_EXTERNAL_DIRS_KEY = "__animus_external_pkg_dirs__";
16
- const SHARED_EXTERNAL_ENTRIES_KEY = "__animus_external_source_entries__";
17
- function getManifestJson() {
18
- return globalThis[MANIFEST_KEY];
19
- }
20
- function setManifestJson(json) {
21
- globalThis[MANIFEST_KEY] = json;
22
- }
23
- function getAnalysisPromise() {
24
- return globalThis[PROMISE_KEY];
25
- }
26
- function setAnalysisPromise(promise) {
27
- globalThis[PROMISE_KEY] = promise;
28
- }
29
- function resetAnalysisPromise() {
30
- globalThis[PROMISE_KEY] = null;
31
- }
32
- function getSharedCss() {
33
- return globalThis[SHARED_CSS_KEY] || "";
34
- }
35
- function setSharedCss(css) {
36
- globalThis[SHARED_CSS_KEY] = css;
37
- }
38
- function setSharedSystemProps(content) {
39
- globalThis[SHARED_SYSTEM_PROPS_KEY] = content;
40
- }
41
- function getSharedExternalDirs() {
42
- return globalThis[SHARED_EXTERNAL_DIRS_KEY] || [];
43
- }
44
- function setSharedExternalDirs(dirs) {
45
- globalThis[SHARED_EXTERNAL_DIRS_KEY] = dirs;
46
- }
47
- function getSharedExternalEntries() {
48
- return globalThis[SHARED_EXTERNAL_ENTRIES_KEY] || /* @__PURE__ */ new Map();
49
- }
50
- function setSharedExternalEntries(entries) {
51
- globalThis[SHARED_EXTERNAL_ENTRIES_KEY] = entries;
52
- }
53
- const ENGINE_KEY = "__animus_engine__";
54
- /** Engine selection travels through the singleton so non-owning compiler
55
- * instances and the webpack loader honor the same choice as the owner. */
56
- function setSharedEngine(engine) {
57
- globalThis[ENGINE_KEY] = engine;
58
- }
59
- function getSharedEngine() {
60
- return globalThis[ENGINE_KEY] || "v2";
61
- }
62
- /** Single engine choke-point for every native extraction call. Return type
63
- * mirrors the untyped `require` the call sites previously used — the NAPI
64
- * module's own .d.ts is the authoritative surface. */
65
- function requireEngine() {
66
- return __require("@animus-ui/extract");
67
- }
68
- const V2_ENGINE_KEY = "__animus_v2_engine__";
69
- /**
70
- * Engine-agnostic API over both engines (extract-v2-spine row 13). The
71
- * v2 leg adapts the v1 function surface onto a stateful ExtractEngine
72
- * (hoisted to `createV2EngineApi` in @animus-ui/extract/pipeline — the
73
- * single authoritative copy shared with vite-plugin). The engine INSTANCE,
74
- * its analyze-time sources, and the one-shot drift flag all live on
75
- * globalThis for the same reason the manifest does — the ESM plugin and the
76
- * CJS webpack loader must see one engine (and one drift warning) across the
77
- * double-load. (The next-plugin is already process-singleton by design:
78
- * manifest, css, and system props share the same globalThis keys.)
79
- * loadSystemModule is exported by both bindings from one engine-neutral
80
- * Rust crate, so the default path no longer loads the v1 binary.
81
- */
82
- const V2_SENT_SOURCES_KEY = "__animus_v2_sent_sources__";
83
- const V2_DRIFT_WARNED_KEY = "__animus_v2_drift_warned__";
84
- const v2EngineApi = createV2EngineApi({
85
- label: "animus-next",
86
- isV2: () => getSharedEngine() === "v2",
87
- loadNativeEngine: requireEngine,
88
- passThroughUnknownPaths: true,
89
- store: {
90
- getEngine: () => globalThis[V2_ENGINE_KEY],
91
- setEngine: (engine) => {
92
- globalThis[V2_ENGINE_KEY] = engine;
93
- },
94
- getSentSources: () => globalThis[V2_SENT_SOURCES_KEY] ?? null,
95
- setSentSources: (sources) => {
96
- globalThis[V2_SENT_SOURCES_KEY] = sources;
97
- },
98
- getDriftWarned: () => Boolean(globalThis[V2_DRIFT_WARNED_KEY]),
99
- setDriftWarned: (value) => {
100
- globalThis[V2_DRIFT_WARNED_KEY] = value;
101
- }
102
- }
103
- });
104
- function engineApi() {
105
- return v2EngineApi();
106
- }
107
- //#endregion
108
- export { getSharedExternalDirs as a, setAnalysisPromise as c, setSharedEngine as d, setSharedExternalDirs as f, getSharedCss as i, setManifestJson as l, setSharedSystemProps as m, getAnalysisPromise as n, getSharedExternalEntries as o, setSharedExternalEntries as p, getManifestJson as r, resetAnalysisPromise as s, engineApi as t, setSharedCss as u };
@@ -1,190 +0,0 @@
1
- let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
2
- //#region src/singleton.ts
3
- /**
4
- * Module-scope singleton for sharing analysis state between the webpack plugin and loader.
5
- *
6
- * Uses globalThis to survive the ESM/CJS module boundary: the plugin is loaded via ESM
7
- * (next.config.ts import) while the loader is loaded by webpack via require(). Without
8
- * globalThis, each module system gets its own singleton instance.
9
- */
10
- const MANIFEST_KEY = "__animus_manifest_json__";
11
- const PROMISE_KEY = "__animus_analysis_promise__";
12
- const SHARED_CSS_KEY = "__animus_shared_css__";
13
- const SHARED_SYSTEM_PROPS_KEY = "__animus_shared_system_props__";
14
- const SHARED_EXTERNAL_DIRS_KEY = "__animus_external_pkg_dirs__";
15
- const SHARED_EXTERNAL_ENTRIES_KEY = "__animus_external_source_entries__";
16
- function getManifestJson() {
17
- return globalThis[MANIFEST_KEY];
18
- }
19
- function setManifestJson(json) {
20
- globalThis[MANIFEST_KEY] = json;
21
- }
22
- function getAnalysisPromise() {
23
- return globalThis[PROMISE_KEY];
24
- }
25
- function setAnalysisPromise(promise) {
26
- globalThis[PROMISE_KEY] = promise;
27
- }
28
- function resetAnalysisPromise() {
29
- globalThis[PROMISE_KEY] = null;
30
- }
31
- function getSharedCss() {
32
- return globalThis[SHARED_CSS_KEY] || "";
33
- }
34
- function setSharedCss(css) {
35
- globalThis[SHARED_CSS_KEY] = css;
36
- }
37
- function setSharedSystemProps(content) {
38
- globalThis[SHARED_SYSTEM_PROPS_KEY] = content;
39
- }
40
- function getSharedExternalDirs() {
41
- return globalThis[SHARED_EXTERNAL_DIRS_KEY] || [];
42
- }
43
- function setSharedExternalDirs(dirs) {
44
- globalThis[SHARED_EXTERNAL_DIRS_KEY] = dirs;
45
- }
46
- function getSharedExternalEntries() {
47
- return globalThis[SHARED_EXTERNAL_ENTRIES_KEY] || /* @__PURE__ */ new Map();
48
- }
49
- function setSharedExternalEntries(entries) {
50
- globalThis[SHARED_EXTERNAL_ENTRIES_KEY] = entries;
51
- }
52
- const ENGINE_KEY = "__animus_engine__";
53
- /** Engine selection travels through the singleton so non-owning compiler
54
- * instances and the webpack loader honor the same choice as the owner. */
55
- function setSharedEngine(engine) {
56
- globalThis[ENGINE_KEY] = engine;
57
- }
58
- function getSharedEngine() {
59
- return globalThis[ENGINE_KEY] || "v2";
60
- }
61
- /** Single engine choke-point for every native extraction call. Return type
62
- * mirrors the untyped `require` the call sites previously used — the NAPI
63
- * module's own .d.ts is the authoritative surface. */
64
- function requireEngine() {
65
- return require("@animus-ui/extract");
66
- }
67
- const V2_ENGINE_KEY = "__animus_v2_engine__";
68
- /**
69
- * Engine-agnostic API over both engines (extract-v2-spine row 13). The
70
- * v2 leg adapts the v1 function surface onto a stateful ExtractEngine
71
- * (hoisted to `createV2EngineApi` in @animus-ui/extract/pipeline — the
72
- * single authoritative copy shared with vite-plugin). The engine INSTANCE,
73
- * its analyze-time sources, and the one-shot drift flag all live on
74
- * globalThis for the same reason the manifest does — the ESM plugin and the
75
- * CJS webpack loader must see one engine (and one drift warning) across the
76
- * double-load. (The next-plugin is already process-singleton by design:
77
- * manifest, css, and system props share the same globalThis keys.)
78
- * loadSystemModule is exported by both bindings from one engine-neutral
79
- * Rust crate, so the default path no longer loads the v1 binary.
80
- */
81
- const V2_SENT_SOURCES_KEY = "__animus_v2_sent_sources__";
82
- const V2_DRIFT_WARNED_KEY = "__animus_v2_drift_warned__";
83
- const v2EngineApi = (0, _animus_ui_extract_pipeline.createV2EngineApi)({
84
- label: "animus-next",
85
- isV2: () => getSharedEngine() === "v2",
86
- loadNativeEngine: requireEngine,
87
- passThroughUnknownPaths: true,
88
- store: {
89
- getEngine: () => globalThis[V2_ENGINE_KEY],
90
- setEngine: (engine) => {
91
- globalThis[V2_ENGINE_KEY] = engine;
92
- },
93
- getSentSources: () => globalThis[V2_SENT_SOURCES_KEY] ?? null,
94
- setSentSources: (sources) => {
95
- globalThis[V2_SENT_SOURCES_KEY] = sources;
96
- },
97
- getDriftWarned: () => Boolean(globalThis[V2_DRIFT_WARNED_KEY]),
98
- setDriftWarned: (value) => {
99
- globalThis[V2_DRIFT_WARNED_KEY] = value;
100
- }
101
- }
102
- });
103
- function engineApi() {
104
- return v2EngineApi();
105
- }
106
- //#endregion
107
- Object.defineProperty(exports, "engineApi", {
108
- enumerable: true,
109
- get: function() {
110
- return engineApi;
111
- }
112
- });
113
- Object.defineProperty(exports, "getAnalysisPromise", {
114
- enumerable: true,
115
- get: function() {
116
- return getAnalysisPromise;
117
- }
118
- });
119
- Object.defineProperty(exports, "getManifestJson", {
120
- enumerable: true,
121
- get: function() {
122
- return getManifestJson;
123
- }
124
- });
125
- Object.defineProperty(exports, "getSharedCss", {
126
- enumerable: true,
127
- get: function() {
128
- return getSharedCss;
129
- }
130
- });
131
- Object.defineProperty(exports, "getSharedExternalDirs", {
132
- enumerable: true,
133
- get: function() {
134
- return getSharedExternalDirs;
135
- }
136
- });
137
- Object.defineProperty(exports, "getSharedExternalEntries", {
138
- enumerable: true,
139
- get: function() {
140
- return getSharedExternalEntries;
141
- }
142
- });
143
- Object.defineProperty(exports, "resetAnalysisPromise", {
144
- enumerable: true,
145
- get: function() {
146
- return resetAnalysisPromise;
147
- }
148
- });
149
- Object.defineProperty(exports, "setAnalysisPromise", {
150
- enumerable: true,
151
- get: function() {
152
- return setAnalysisPromise;
153
- }
154
- });
155
- Object.defineProperty(exports, "setManifestJson", {
156
- enumerable: true,
157
- get: function() {
158
- return setManifestJson;
159
- }
160
- });
161
- Object.defineProperty(exports, "setSharedCss", {
162
- enumerable: true,
163
- get: function() {
164
- return setSharedCss;
165
- }
166
- });
167
- Object.defineProperty(exports, "setSharedEngine", {
168
- enumerable: true,
169
- get: function() {
170
- return setSharedEngine;
171
- }
172
- });
173
- Object.defineProperty(exports, "setSharedExternalDirs", {
174
- enumerable: true,
175
- get: function() {
176
- return setSharedExternalDirs;
177
- }
178
- });
179
- Object.defineProperty(exports, "setSharedExternalEntries", {
180
- enumerable: true,
181
- get: function() {
182
- return setSharedExternalEntries;
183
- }
184
- });
185
- Object.defineProperty(exports, "setSharedSystemProps", {
186
- enumerable: true,
187
- get: function() {
188
- return setSharedSystemProps;
189
- }
190
- });