@animus-ui/next-plugin 0.1.1-beta.2 → 0.1.2

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.
Files changed (42) hide show
  1. package/README.md +83 -4
  2. package/dist/chunk-y_GBKt04.mjs +5 -0
  3. package/dist/extraction-session.d.ts +138 -0
  4. package/dist/extraction-session.d.ts.map +1 -0
  5. package/dist/index.cjs +762 -541
  6. package/dist/index.mjs +762 -540
  7. package/dist/loader-core-CbaYNhBu.cjs +71 -0
  8. package/dist/loader-core-D6Tm_b8F.mjs +66 -0
  9. package/dist/loader-core.d.ts +26 -0
  10. package/dist/loader-core.d.ts.map +1 -0
  11. package/dist/loader.cjs +12 -43
  12. package/dist/loader.d.ts +5 -9
  13. package/dist/loader.d.ts.map +1 -1
  14. package/dist/loader.mjs +12 -43
  15. package/dist/plugin.d.ts +24 -42
  16. package/dist/plugin.d.ts.map +1 -1
  17. package/dist/resolve-packages.d.ts +8 -0
  18. package/dist/resolve-packages.d.ts.map +1 -0
  19. package/dist/singleton-BKALu7Mk.mjs +108 -0
  20. package/dist/{singleton-CttvA4Rg.cjs → singleton-DH7yeWZa.cjs} +29 -60
  21. package/dist/singleton.d.ts +1 -8
  22. package/dist/singleton.d.ts.map +1 -1
  23. package/dist/timing.d.ts +7 -0
  24. package/dist/timing.d.ts.map +1 -0
  25. package/dist/turbopack-config.d.ts +55 -0
  26. package/dist/turbopack-config.d.ts.map +1 -0
  27. package/dist/turbopack-loader.cjs +90 -0
  28. package/dist/turbopack-loader.d.ts +16 -0
  29. package/dist/turbopack-loader.d.ts.map +1 -0
  30. package/dist/turbopack-loader.mjs +91 -0
  31. package/dist/turbopack-orchestrator.d.ts +31 -0
  32. package/dist/turbopack-orchestrator.d.ts.map +1 -0
  33. package/dist/types.d.ts +67 -10
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/with-animus.d.ts +1 -1
  36. package/dist/with-animus.d.ts.map +1 -1
  37. package/package.json +5 -5
  38. package/dist/analyze-project-args.d.ts +0 -33
  39. package/dist/analyze-project-args.d.ts.map +0 -1
  40. package/dist/manifest-diagnostics.d.ts +0 -10
  41. package/dist/manifest-diagnostics.d.ts.map +0 -1
  42. package/dist/singleton-CmwFBCJ5.mjs +0 -136
@@ -0,0 +1,71 @@
1
+ //#region src/loader-core.ts
2
+ /**
3
+ * Regex matching CSS import lines injected by the Rust emitter.
4
+ * Catches both the alias form (`import '.animus/styles.css'`),
5
+ * relative forms (`import '../.animus/styles.css'`), and the Vite
6
+ * virtual module form (`import 'virtual:animus/styles.css'`) which
7
+ * appears in pre-built external packages compiled with the Vite plugin.
8
+ */
9
+ const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
10
+ /**
11
+ * Default root entry file patterns. CSS is imported ONLY in the root entry
12
+ * to prevent per-chunk duplication in Next.js builds.
13
+ *
14
+ * - App Router: `app/layout.tsx` (root layout wraps all routes)
15
+ * - Pages Router: `pages/_app.tsx` (custom App wraps all pages)
16
+ *
17
+ * The `(src\/)?` prefix handles projects that use a `src/` directory.
18
+ * Projects whose root entry doesn't match (nested layouts, monorepo roots)
19
+ * set the `cssImportTarget` plugin option, which replaces this detection.
20
+ */
21
+ const ROOT_ENTRY_RE = /^(src\/)?(?:app\/layout|pages\/_app)\.[tj]sx?$/;
22
+ /** Normalize separators and strip a leading './' for path comparison. */
23
+ function normalizePath(p) {
24
+ return p.replace(/\\/g, "/").replace(/^\.\//, "");
25
+ }
26
+ /**
27
+ * Decide whether `filename` (project-root-relative) is the file that
28
+ * receives the single CSS import. An explicit `cssImportTarget` replaces
29
+ * the default filename-convention detection. Separators are normalized
30
+ * first — Windows `relative()` yields backslashes the patterns would miss.
31
+ */
32
+ function isCssImportTarget(filename, cssImportTarget) {
33
+ const normalized = normalizePath(filename);
34
+ if (cssImportTarget) return normalized === normalizePath(cssImportTarget);
35
+ return ROOT_ENTRY_RE.test(normalized);
36
+ }
37
+ /**
38
+ * Transform one source file against a manifest: replace builder chains via
39
+ * the engine, strip emitter-injected stylesheet imports everywhere, and
40
+ * re-inject a single import at the root entry (after any leading
41
+ * `'use client'` directive). On failure: throw in strict mode, otherwise
42
+ * warn and return the source unchanged.
43
+ */
44
+ function transformWithManifest(args) {
45
+ const { source, filename, manifestJson, engineApi, opts } = args;
46
+ const isRootEntry = isCssImportTarget(filename, opts.cssImportTarget);
47
+ try {
48
+ const { transformFile } = engineApi();
49
+ const result = transformFile(source, filename, manifestJson);
50
+ let code = result.hasComponents ? result.code : source;
51
+ code = code.replace(CSS_IMPORT_RE, "");
52
+ if (isRootEntry && !code.includes(".animus/styles.css")) if (code.startsWith("'use client'") || code.startsWith("\"use client\"")) {
53
+ const nl = code.indexOf("\n");
54
+ if (nl === -1) code = `${code}\nimport '.animus/styles.css';\n`;
55
+ else code = `${code.slice(0, nl + 1)}import '.animus/styles.css';\n${code.slice(nl + 1)}`;
56
+ } else code = `import '.animus/styles.css';\n${code}`;
57
+ return code;
58
+ } catch (e) {
59
+ const msg = e instanceof Error ? e.message : String(e);
60
+ if (opts.strict) throw new Error(`[animus-extract] Transform failed for ${filename}: ${msg}`, { cause: e });
61
+ console.warn(`[animus-extract] Transform failed for ${filename}:`, msg);
62
+ return source;
63
+ }
64
+ }
65
+ //#endregion
66
+ Object.defineProperty(exports, "transformWithManifest", {
67
+ enumerable: true,
68
+ get: function() {
69
+ return transformWithManifest;
70
+ }
71
+ });
@@ -0,0 +1,66 @@
1
+ //#region src/loader-core.ts
2
+ /**
3
+ * Regex matching CSS import lines injected by the Rust emitter.
4
+ * Catches both the alias form (`import '.animus/styles.css'`),
5
+ * relative forms (`import '../.animus/styles.css'`), and the Vite
6
+ * virtual module form (`import 'virtual:animus/styles.css'`) which
7
+ * appears in pre-built external packages compiled with the Vite plugin.
8
+ */
9
+ const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
10
+ /**
11
+ * Default root entry file patterns. CSS is imported ONLY in the root entry
12
+ * to prevent per-chunk duplication in Next.js builds.
13
+ *
14
+ * - App Router: `app/layout.tsx` (root layout wraps all routes)
15
+ * - Pages Router: `pages/_app.tsx` (custom App wraps all pages)
16
+ *
17
+ * The `(src\/)?` prefix handles projects that use a `src/` directory.
18
+ * Projects whose root entry doesn't match (nested layouts, monorepo roots)
19
+ * set the `cssImportTarget` plugin option, which replaces this detection.
20
+ */
21
+ const ROOT_ENTRY_RE = /^(src\/)?(?:app\/layout|pages\/_app)\.[tj]sx?$/;
22
+ /** Normalize separators and strip a leading './' for path comparison. */
23
+ function normalizePath(p) {
24
+ return p.replace(/\\/g, "/").replace(/^\.\//, "");
25
+ }
26
+ /**
27
+ * Decide whether `filename` (project-root-relative) is the file that
28
+ * receives the single CSS import. An explicit `cssImportTarget` replaces
29
+ * the default filename-convention detection. Separators are normalized
30
+ * first — Windows `relative()` yields backslashes the patterns would miss.
31
+ */
32
+ function isCssImportTarget(filename, cssImportTarget) {
33
+ const normalized = normalizePath(filename);
34
+ if (cssImportTarget) return normalized === normalizePath(cssImportTarget);
35
+ return ROOT_ENTRY_RE.test(normalized);
36
+ }
37
+ /**
38
+ * Transform one source file against a manifest: replace builder chains via
39
+ * the engine, strip emitter-injected stylesheet imports everywhere, and
40
+ * re-inject a single import at the root entry (after any leading
41
+ * `'use client'` directive). On failure: throw in strict mode, otherwise
42
+ * warn and return the source unchanged.
43
+ */
44
+ function transformWithManifest(args) {
45
+ const { source, filename, manifestJson, engineApi, opts } = args;
46
+ const isRootEntry = isCssImportTarget(filename, opts.cssImportTarget);
47
+ try {
48
+ const { transformFile } = engineApi();
49
+ const result = transformFile(source, filename, manifestJson);
50
+ let code = result.hasComponents ? result.code : source;
51
+ code = code.replace(CSS_IMPORT_RE, "");
52
+ if (isRootEntry && !code.includes(".animus/styles.css")) if (code.startsWith("'use client'") || code.startsWith("\"use client\"")) {
53
+ const nl = code.indexOf("\n");
54
+ if (nl === -1) code = `${code}\nimport '.animus/styles.css';\n`;
55
+ else code = `${code.slice(0, nl + 1)}import '.animus/styles.css';\n${code.slice(nl + 1)}`;
56
+ } else code = `import '.animus/styles.css';\n${code}`;
57
+ return code;
58
+ } catch (e) {
59
+ const msg = e instanceof Error ? e.message : String(e);
60
+ if (opts.strict) throw new Error(`[animus-extract] Transform failed for ${filename}: ${msg}`, { cause: e });
61
+ console.warn(`[animus-extract] Transform failed for ${filename}:`, msg);
62
+ return source;
63
+ }
64
+ }
65
+ //#endregion
66
+ export { transformWithManifest as t };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Bundler-neutral loader policy shared by the webpack loader (manifest from
3
+ * the process singleton) and the Turbopack loader (manifest hydrated from
4
+ * disk artifacts). Owns the transform invocation, strict-mode error
5
+ * handling, and the single-stylesheet-import policy.
6
+ */
7
+ export interface LoaderPolicyOptions {
8
+ strict?: boolean;
9
+ cssImportTarget?: string;
10
+ }
11
+ /**
12
+ * Transform one source file against a manifest: replace builder chains via
13
+ * the engine, strip emitter-injected stylesheet imports everywhere, and
14
+ * re-inject a single import at the root entry (after any leading
15
+ * `'use client'` directive). On failure: throw in strict mode, otherwise
16
+ * warn and return the source unchanged.
17
+ */
18
+ export declare function transformWithManifest(args: {
19
+ source: string;
20
+ /** Project-root-relative path of the file being transformed. */
21
+ filename: string;
22
+ manifestJson: string;
23
+ engineApi: () => any;
24
+ opts: LoaderPolicyOptions;
25
+ }): string;
26
+ //# sourceMappingURL=loader-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-core.d.ts","sourceRoot":"","sources":["../src/loader-core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA+CD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,MAAM,GAAG,CAAC;IACrB,IAAI,EAAE,mBAAmB,CAAC;CAC3B,GAAG,MAAM,CA4CT"}
package/dist/loader.cjs CHANGED
@@ -1,55 +1,24 @@
1
- const require_singleton = require("./singleton-CttvA4Rg.cjs");
1
+ const require_singleton = require("./singleton-DH7yeWZa.cjs");
2
+ const require_loader_core = require("./loader-core-CbaYNhBu.cjs");
2
3
  let path = require("path");
3
4
  //#region src/loader.ts
4
5
  /**
5
- * Regex matching CSS import lines injected by the Rust emitter.
6
- * Catches both the alias form (`import '.animus/styles.css'`),
7
- * relative forms (`import '../.animus/styles.css'`), and the Vite
8
- * virtual module form (`import 'virtual:animus/styles.css'`) which
9
- * appears in pre-built external packages compiled with the Vite plugin.
10
- */
11
- const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
12
- /**
13
- * Root entry file patterns. CSS is imported ONLY here to prevent
14
- * per-chunk duplication in Next.js builds.
15
- *
16
- * - App Router: `app/layout.tsx` (root layout wraps all routes)
17
- * - Pages Router: `pages/_app.tsx` (custom App wraps all pages)
18
- *
19
- * The `(src\/)?` prefix handles projects that use a `src/` directory.
20
- */
21
- const ROOT_ENTRY_RE = /^(src\/)?(?:app\/layout|pages\/_app)\.[tj]sx?$/;
22
- /**
23
6
  * Webpack loader for Animus source transformation.
24
7
  * Runs with enforce: 'pre' to see original source before Babel/SWC.
25
- * Replaces builder chains with createComponent() calls using the pre-built manifest.
26
- *
27
- * CSS handling: the Rust emitter injects `import '.animus/styles.css'` into every
28
- * file with extracted components. Without intervention, webpack duplicates the full
29
- * stylesheet into every route chunk. This loader strips those imports and re-injects
30
- * a single CSS import in the root layout/app file, ensuring one copy for the whole app.
8
+ * The manifest arrives via the process singleton (the webpack pipeline and
9
+ * this loader share one process); the transform + CSS-import policy lives
10
+ * in the shared loader-core.
31
11
  */
32
12
  function animusLoader(source) {
33
13
  const manifestJson = require_singleton.getManifestJson();
34
14
  if (!manifestJson) return source;
35
- const filename = (0, path.relative)(this.rootContext, this.resourcePath);
36
- const isRootEntry = ROOT_ENTRY_RE.test(filename);
37
- try {
38
- const { transformFile } = require_singleton.engineApi();
39
- const result = transformFile(source, filename, manifestJson);
40
- let code = result.hasComponents ? result.code : source;
41
- code = code.replace(CSS_IMPORT_RE, "");
42
- if (isRootEntry && !code.includes(".animus/styles.css")) if (code.startsWith("'use client'") || code.startsWith("\"use client\"")) {
43
- const nl = code.indexOf("\n");
44
- code = `${code.slice(0, nl + 1)}import '.animus/styles.css';\n${code.slice(nl + 1)}`;
45
- } else code = `import '.animus/styles.css';\n${code}`;
46
- return code;
47
- } catch (e) {
48
- const msg = e instanceof Error ? e.message : String(e);
49
- if ((this.getOptions?.() ?? {}).strict) throw new Error(`[animus-extract] Transform failed for ${filename}: ${msg}`, { cause: e });
50
- console.warn(`[animus-extract] Transform failed for ${filename}:`, msg);
51
- return source;
52
- }
15
+ return require_loader_core.transformWithManifest({
16
+ source,
17
+ filename: (0, path.relative)(this.rootContext, this.resourcePath),
18
+ manifestJson,
19
+ engineApi: require_singleton.engineApi,
20
+ opts: this.getOptions?.() ?? {}
21
+ });
53
22
  }
54
23
  //#endregion
55
24
  module.exports = animusLoader;
package/dist/loader.d.ts CHANGED
@@ -1,19 +1,15 @@
1
+ import type { LoaderPolicyOptions } from './loader-core';
1
2
  type LoaderContext = {
2
3
  resourcePath: string;
3
4
  rootContext: string;
4
- getOptions: () => {
5
- strict?: boolean;
6
- };
5
+ getOptions: () => LoaderPolicyOptions;
7
6
  };
8
7
  /**
9
8
  * Webpack loader for Animus source transformation.
10
9
  * Runs with enforce: 'pre' to see original source before Babel/SWC.
11
- * Replaces builder chains with createComponent() calls using the pre-built manifest.
12
- *
13
- * CSS handling: the Rust emitter injects `import '.animus/styles.css'` into every
14
- * file with extracted components. Without intervention, webpack duplicates the full
15
- * stylesheet into every route chunk. This loader strips those imports and re-injects
16
- * a single CSS import in the root layout/app file, ensuring one copy for the whole app.
10
+ * The manifest arrives via the process singleton (the webpack pipeline and
11
+ * this loader share one process); the transform + CSS-import policy lives
12
+ * in the shared loader-core.
17
13
  */
18
14
  export default function animusLoader(this: LoaderContext, source: string): string;
19
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxC,CAAC;AAuBF;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CA0CR"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,mBAAmB,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAYR"}
package/dist/loader.mjs CHANGED
@@ -1,55 +1,24 @@
1
- import { r as getManifestJson, t as engineApi } from "./singleton-CmwFBCJ5.mjs";
1
+ import { r as getManifestJson, t as engineApi } from "./singleton-BKALu7Mk.mjs";
2
+ import { t as transformWithManifest } from "./loader-core-D6Tm_b8F.mjs";
2
3
  import { relative } from "path";
3
4
  //#region src/loader.ts
4
5
  /**
5
- * Regex matching CSS import lines injected by the Rust emitter.
6
- * Catches both the alias form (`import '.animus/styles.css'`),
7
- * relative forms (`import '../.animus/styles.css'`), and the Vite
8
- * virtual module form (`import 'virtual:animus/styles.css'`) which
9
- * appears in pre-built external packages compiled with the Vite plugin.
10
- */
11
- const CSS_IMPORT_RE = /import\s+['"](?:[^'"]*\.animus\/styles\.css|virtual:animus\/styles\.css)['"];\n?/g;
12
- /**
13
- * Root entry file patterns. CSS is imported ONLY here to prevent
14
- * per-chunk duplication in Next.js builds.
15
- *
16
- * - App Router: `app/layout.tsx` (root layout wraps all routes)
17
- * - Pages Router: `pages/_app.tsx` (custom App wraps all pages)
18
- *
19
- * The `(src\/)?` prefix handles projects that use a `src/` directory.
20
- */
21
- const ROOT_ENTRY_RE = /^(src\/)?(?:app\/layout|pages\/_app)\.[tj]sx?$/;
22
- /**
23
6
  * Webpack loader for Animus source transformation.
24
7
  * Runs with enforce: 'pre' to see original source before Babel/SWC.
25
- * Replaces builder chains with createComponent() calls using the pre-built manifest.
26
- *
27
- * CSS handling: the Rust emitter injects `import '.animus/styles.css'` into every
28
- * file with extracted components. Without intervention, webpack duplicates the full
29
- * stylesheet into every route chunk. This loader strips those imports and re-injects
30
- * a single CSS import in the root layout/app file, ensuring one copy for the whole app.
8
+ * The manifest arrives via the process singleton (the webpack pipeline and
9
+ * this loader share one process); the transform + CSS-import policy lives
10
+ * in the shared loader-core.
31
11
  */
32
12
  function animusLoader(source) {
33
13
  const manifestJson = getManifestJson();
34
14
  if (!manifestJson) return source;
35
- const filename = relative(this.rootContext, this.resourcePath);
36
- const isRootEntry = ROOT_ENTRY_RE.test(filename);
37
- try {
38
- const { transformFile } = engineApi();
39
- const result = transformFile(source, filename, manifestJson);
40
- let code = result.hasComponents ? result.code : source;
41
- code = code.replace(CSS_IMPORT_RE, "");
42
- if (isRootEntry && !code.includes(".animus/styles.css")) if (code.startsWith("'use client'") || code.startsWith("\"use client\"")) {
43
- const nl = code.indexOf("\n");
44
- code = `${code.slice(0, nl + 1)}import '.animus/styles.css';\n${code.slice(nl + 1)}`;
45
- } else code = `import '.animus/styles.css';\n${code}`;
46
- return code;
47
- } catch (e) {
48
- const msg = e instanceof Error ? e.message : String(e);
49
- if ((this.getOptions?.() ?? {}).strict) throw new Error(`[animus-extract] Transform failed for ${filename}: ${msg}`, { cause: e });
50
- console.warn(`[animus-extract] Transform failed for ${filename}:`, msg);
51
- return source;
52
- }
15
+ return transformWithManifest({
16
+ source,
17
+ filename: relative(this.rootContext, this.resourcePath),
18
+ manifestJson,
19
+ engineApi,
20
+ opts: this.getOptions?.() ?? {}
21
+ });
53
22
  }
54
23
  //#endregion
55
24
  export { animusLoader as default };
package/dist/plugin.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AnimusNextOptions } from './types';
2
+ export { ANIMUS_CSS_MODULE_ID } from './extraction-session';
2
3
  type WebpackSource = {
3
4
  source(): string | Buffer;
4
5
  size(): number;
@@ -12,6 +13,14 @@ type Compilation = {
12
13
  }, fn: (assets: Record<string, WebpackSource>) => void) => void;
13
14
  };
14
15
  };
16
+ /** Watch inputs webpack rebuilds per compilation (webpack 5 LazySet). */
17
+ fileDependencies: {
18
+ add(path: string): void;
19
+ };
20
+ /** Currently-absent paths whose creation must trigger a rebuild. */
21
+ missingDependencies: {
22
+ add(path: string): void;
23
+ };
15
24
  getAsset(name: string): {
16
25
  source: WebpackSource;
17
26
  } | undefined;
@@ -30,6 +39,9 @@ type Compiler = {
30
39
  };
31
40
  };
32
41
  context: string;
42
+ /** Present on watchRun compilers after the first compilation (webpack 5). */
43
+ modifiedFiles?: ReadonlySet<string>;
44
+ removedFiles?: ReadonlySet<string>;
33
45
  options?: {
34
46
  name?: string;
35
47
  resolve?: {
@@ -45,56 +57,27 @@ type Compiler = {
45
57
  };
46
58
  };
47
59
  };
60
+ /**
61
+ * Webpack adapter for the extraction pipeline. All pipeline logic lives in
62
+ * the bundler-agnostic ExtractionSession — this class owns only the webpack
63
+ * wiring: hook registration, cross-compiler analysis dedup, alias
64
+ * harvesting from the compiler config, watch-event translation, and
65
+ * in-memory CSS asset replacement.
66
+ */
48
67
  export declare class AnimusWebpackPlugin {
49
68
  private options;
50
- private rootDir;
51
- private configJson;
52
- private groupRegistryJson;
53
- private themeJson;
54
- private variableMapJson;
55
- private variableCss;
56
- private contextualVarsJson;
57
- private selectorAliasesJson;
58
- private globalCss;
59
- private globalStyleBlocksJson;
60
- private keyframesBlocksJson;
61
- private pathAliasesJson;
62
- private fileCache;
63
- private lastCssHash;
64
- private lastSystemPropsHash;
65
- private externalPackageDirs;
66
- private externalSourceEntries;
67
- constructor(options: AnimusNextOptions);
68
- private get verbose();
69
- private log;
70
- private warn;
71
- private now;
72
- private elapsed;
73
- private logBuildTimings;
69
+ private session;
74
70
  private initialized;
75
- /** Extract path aliases from webpack's resolve.alias config. */
71
+ private aliasesExtracted;
72
+ constructor(options: AnimusNextOptions);
73
+ /** Extract path aliases from webpack's resolve.alias config. Runs once per
74
+ * plugin instance — the resolve config is immutable after apply. */
76
75
  private extractAliases;
77
76
  apply(compiler: Compiler): void;
78
- private handleWatchUpdate;
79
- private runFullPipeline;
80
- private loadSystem;
81
- private discoverFiles;
82
- private resolvePackagesByName;
83
77
  /**
84
78
  * Reset analysis state for HMR geological reset.
85
79
  */
86
80
  resetForHmr(): void;
87
- /**
88
- * Build cache-aware file entries: full source for changed files,
89
- * empty source + hash for unchanged (Rust cache-hit path skips these).
90
- */
91
- private buildFileEntriesFromCache;
92
- private runIncrementalPipeline;
93
- /** Expose file cache for HMR change detection */
94
- getFileCache(): Map<string, {
95
- hash: string;
96
- source: string;
97
- }>;
98
81
  /** Expose options for the loader */
99
82
  getOptions(): AnimusNextOptions;
100
83
  /** Expose external package directories for webpack loader allowlisting.
@@ -104,5 +87,4 @@ export declare class AnimusWebpackPlugin {
104
87
  * Falls back to shared globalThis state for non-owning compiler instances. */
105
88
  getExternalSourceEntries(): Map<string, string>;
106
89
  }
107
- export {};
108
90
  //# sourceMappingURL=plugin.d.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AE,GAAG,KAAK,CAAC,CAAC;SACnD,CAAC;KACH,CAAC;IACF,OAAO,CAAC,EAAE;QACR,WAAW,EAAE;YACX,+BAA+B,EAAE,MAAM,CAAC;SACzC,CAAC;QACF,OAAO,EAAE;YACP,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,aAAa,CAAC;SAClD,CAAC;KACH,CAAC;CACH,CAAC;AAIF;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YAAY,OAAO,EAAE,iBAAiB,EASrC;IAED;yEACqE;IACrE,OAAO,CAAC,cAAc;IAwBtB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CA6F9B;IAED;;OAEG;IACH,WAAW,IAAI,IAAI,CAElB;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"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolve external DS package specifiers to rootDir-relative entry paths.
3
+ * Node-generic (no webpack APIs): Pass 1 walks the consumer's workspaces for
4
+ * matching package names; Pass 2 falls back to `require.resolve`. Specifiers
5
+ * that resolve nowhere are simply omitted (spec: silent skip).
6
+ */
7
+ export declare function resolvePackagesByName(rootDir: string, names: string[]): Record<string, string>;
8
+ //# sourceMappingURL=resolve-packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-packages.d.ts","sourceRoot":"","sources":["../src/resolve-packages.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0DxB"}
@@ -0,0 +1,108 @@
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 };