@nifrajs/web 2.14.1 → 3.2.0
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/boundary.d.ts +158 -0
- package/dist/boundary.d.ts.map +1 -0
- package/dist/boundary.js +237 -0
- package/dist/boundary.js.map +1 -0
- package/dist/build-plan.d.ts +228 -0
- package/dist/build-plan.d.ts.map +1 -0
- package/dist/build-plan.js +514 -0
- package/dist/build-plan.js.map +1 -0
- package/dist/build-vite.d.ts +2 -1
- package/dist/build-vite.d.ts.map +1 -1
- package/dist/build-vite.js +5 -3
- package/dist/build-vite.js.map +1 -1
- package/dist/build.d.ts +2 -197
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +92 -515
- package/dist/build.js.map +1 -1
- package/dist/chunk-names.d.ts.map +1 -1
- package/dist/chunk-names.js +3 -2
- package/dist/chunk-names.js.map +1 -1
- package/dist/dev-ssr-graph.d.ts.map +1 -1
- package/dist/dev-ssr-graph.js +63 -28
- package/dist/dev-ssr-graph.js.map +1 -1
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +9 -2
- package/dist/diagnostic.js.map +1 -1
- package/dist/fonts-google.d.ts.map +1 -1
- package/dist/fonts-google.js +3 -1
- package/dist/fonts-google.js.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +2 -1
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +16 -589
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1824
- package/dist/index.js.map +1 -1
- package/dist/internal/codegen.d.ts +68 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +317 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/fetcher-runtime.d.ts +19 -0
- package/dist/internal/fetcher-runtime.d.ts.map +1 -0
- package/dist/internal/fetcher-runtime.js +26 -0
- package/dist/internal/fetcher-runtime.js.map +1 -0
- package/dist/internal/head-merge.d.ts +2 -0
- package/dist/internal/head-merge.d.ts.map +1 -1
- package/dist/internal/head-merge.js +17 -1
- package/dist/internal/head-merge.js.map +1 -1
- package/dist/internal/identity-policy.d.ts +51 -0
- package/dist/internal/identity-policy.d.ts.map +1 -0
- package/dist/internal/identity-policy.js +67 -0
- package/dist/internal/identity-policy.js.map +1 -0
- package/dist/internal/parity.d.ts +104 -8
- package/dist/internal/parity.d.ts.map +1 -1
- package/dist/internal/parity.js +472 -56
- package/dist/internal/parity.js.map +1 -1
- package/dist/internal/query-runtime.d.ts +8 -0
- package/dist/internal/query-runtime.d.ts.map +1 -0
- package/dist/internal/query-runtime.js +29 -0
- package/dist/internal/query-runtime.js.map +1 -0
- package/dist/internal/render-document.d.ts +372 -0
- package/dist/internal/render-document.d.ts.map +1 -0
- package/dist/internal/render-document.js +744 -0
- package/dist/internal/render-document.js.map +1 -0
- package/dist/internal/runtime-contract.d.ts +48 -0
- package/dist/internal/runtime-contract.d.ts.map +1 -0
- package/dist/internal/runtime-contract.js +27 -0
- package/dist/internal/runtime-contract.js.map +1 -0
- package/dist/internal/web-app.d.ts +171 -0
- package/dist/internal/web-app.d.ts.map +1 -0
- package/dist/internal/web-app.js +844 -0
- package/dist/internal/web-app.js.map +1 -0
- package/dist/islands.d.ts +50 -2
- package/dist/islands.d.ts.map +1 -1
- package/dist/islands.js +96 -36
- package/dist/islands.js.map +1 -1
- package/dist/manifest.d.ts +41 -6
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js.map +1 -1
- package/dist/module-graph.d.ts.map +1 -1
- package/dist/module-graph.js +22 -9
- package/dist/module-graph.js.map +1 -1
- package/dist/nano.d.ts +125 -0
- package/dist/nano.d.ts.map +1 -0
- package/dist/nano.js +190 -0
- package/dist/nano.js.map +1 -0
- package/dist/plugins/css-modules.js +2 -2
- package/dist/plugins/css-modules.js.map +1 -1
- package/dist/plugins/kit.d.ts +12 -0
- package/dist/plugins/kit.d.ts.map +1 -1
- package/dist/plugins/kit.js +62 -12
- package/dist/plugins/kit.js.map +1 -1
- package/dist/plugins/postcss.js +2 -2
- package/dist/plugins/postcss.js.map +1 -1
- package/dist/plugins/scss.js +2 -2
- package/dist/plugins/scss.js.map +1 -1
- package/dist/plugins/stylex.d.ts +70 -0
- package/dist/plugins/stylex.d.ts.map +1 -0
- package/dist/plugins/stylex.js +166 -0
- package/dist/plugins/stylex.js.map +1 -0
- package/dist/plugins/svg.js +2 -2
- package/dist/plugins/svg.js.map +1 -1
- package/dist/render-seam.d.ts +5 -0
- package/dist/render-seam.d.ts.map +1 -1
- package/dist/render-seam.js +10 -0
- package/dist/render-seam.js.map +1 -1
- package/dist/router.d.ts +11 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +254 -47
- package/dist/router.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +34 -16
- package/dist/vite.js.map +1 -1
- package/package.json +49 -2
- package/src/boundary.ts +407 -0
- package/src/build-plan.ts +741 -0
- package/src/build-vite.ts +6 -7
- package/src/build.ts +120 -730
- package/src/chunk-names.ts +3 -2
- package/src/dev-ssr-graph.ts +63 -28
- package/src/diagnostic.ts +14 -2
- package/src/fonts-google.ts +3 -1
- package/src/fs.ts +2 -1
- package/src/index.ts +107 -2553
- package/src/internal/codegen.ts +400 -0
- package/src/internal/fetcher-runtime.ts +36 -0
- package/src/internal/head-merge.ts +19 -1
- package/src/internal/identity-policy.ts +94 -0
- package/src/internal/parity.ts +603 -71
- package/src/internal/query-runtime.ts +31 -0
- package/src/internal/render-document.ts +1116 -0
- package/src/internal/runtime-contract.ts +54 -0
- package/src/internal/web-app.ts +1114 -0
- package/src/islands.ts +106 -40
- package/src/manifest.ts +50 -3
- package/src/module-graph.ts +23 -9
- package/src/nano.ts +246 -0
- package/src/plugins/css-modules.ts +2 -2
- package/src/plugins/kit.ts +65 -12
- package/src/plugins/postcss.ts +2 -2
- package/src/plugins/scss.ts +2 -2
- package/src/plugins/stylex.ts +298 -0
- package/src/plugins/svg.ts +2 -2
- package/src/render-seam.ts +6 -0
- package/src/router.ts +293 -51
- package/src/vite.ts +41 -15
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
// Server head serialization may memoize only objects that came exclusively from a static meta export.
|
|
2
|
+
// A dynamic function is allowed to reuse and mutate one object, including an object another route also
|
|
3
|
+
// exports statically, so identity alone does not prove cacheability. Once observed dynamically, an
|
|
4
|
+
// object stays uncacheable: losing a small static optimization is safer than cross-request stale data.
|
|
5
|
+
const STATIC_META = new WeakSet();
|
|
6
|
+
const DYNAMIC_META = new WeakSet();
|
|
7
|
+
/** @internal Whether `resolveMeta` observed this object as a static export. */
|
|
8
|
+
export function isStaticMeta(meta) {
|
|
9
|
+
return STATIC_META.has(meta) && !DYNAMIC_META.has(meta);
|
|
10
|
+
}
|
|
1
11
|
/** Resolve a route's `meta` export - a static object, or a function of the route's data/params. */
|
|
2
12
|
export function resolveMeta(meta, args) {
|
|
3
13
|
if (meta === undefined)
|
|
4
14
|
return {};
|
|
5
|
-
|
|
15
|
+
if (typeof meta === "function") {
|
|
16
|
+
const resolved = meta(args);
|
|
17
|
+
DYNAMIC_META.add(resolved);
|
|
18
|
+
return resolved;
|
|
19
|
+
}
|
|
20
|
+
STATIC_META.add(meta);
|
|
21
|
+
return meta;
|
|
6
22
|
}
|
|
7
23
|
/**
|
|
8
24
|
* Merge a layout chain's heads, outermost first: `title`/`lang`/`dir` are nearest-wins, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"head-merge.js","sourceRoot":"","sources":["../../src/internal/head-merge.ts"],"names":[],"mappings":"AAuBA,mGAAmG;AACnG,MAAM,UAAU,WAAW,CAAC,IAA2B,EAAE,IAAc;IACrE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IACjC,
|
|
1
|
+
{"version":3,"file":"head-merge.js","sourceRoot":"","sources":["../../src/internal/head-merge.ts"],"names":[],"mappings":"AAuBA,sGAAsG;AACtG,uGAAuG;AACvG,mGAAmG;AACnG,uGAAuG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MAAM,CAAC,GAAG,GAAG,GAAG,CAAA;IACvC,OAAO,MAAc,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One source for which packages are identity-sensitive, and how each frontend framework is pinned to a
|
|
3
|
+
* single physical copy in a bundle.
|
|
4
|
+
*
|
|
5
|
+
* The identity-sensitive PACKAGE set lives in `@nifrajs/core` (`IDENTITY_SENSITIVE_PACKAGES`) - it is
|
|
6
|
+
* what single-copy enforcement and `nifra check` read, and it must be the same answer everywhere. This
|
|
7
|
+
* module does not restate it; it re-exports the one predicate every web caller should ask
|
|
8
|
+
* (`isIdentitySensitivePackage`) so a second list can never drift from core's.
|
|
9
|
+
*
|
|
10
|
+
* What this module DOES own is the per-bundler dedupe STRATEGY, which is a web concern (it names Bun and
|
|
11
|
+
* Vite mechanics core knows nothing about). The two client pipelines - `Bun.build` (build.ts) and Vite
|
|
12
|
+
* (build-vite.ts) - used to spell their framework coverage out independently, and they had already
|
|
13
|
+
* drifted: the Bun build pinned react + preact + svelte while the Vite build deduped react alone, so a
|
|
14
|
+
* Vite-built app silently shipped a second Preact or Svelte runtime. Both now read {@link
|
|
15
|
+
* FRONTEND_DEDUPE_POLICIES}, so their coverage cannot diverge again.
|
|
16
|
+
*
|
|
17
|
+
* Not every identity-sensitive framework is name-pinned here. Solid and Vue select their single runtime
|
|
18
|
+
* through export CONDITIONS rather than a resolver override, so they carry no entry - the conformance
|
|
19
|
+
* test allows core's set to be a superset of this table for exactly that reason, and only forbids the
|
|
20
|
+
* reverse (a strategy for a package core does not consider identity-sensitive).
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Whether nifra treats a package as identity-sensitive: a second physical copy breaks behaviour (a hook
|
|
24
|
+
* dispatcher, a renderer's options global, a `Server` class identity) rather than merely costing bytes.
|
|
25
|
+
* The single predicate the whole web package asks, delegating to core's canonical declaration.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isIdentitySensitivePackage: (name: string) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* How one frontend framework's runtime is pinned to a single copy in each client bundler.
|
|
30
|
+
*
|
|
31
|
+
* The two arms differ because the bundlers resolve differently. `Bun.build` needs an `onResolve` hook,
|
|
32
|
+
* fed either a fixed specifier list (each resolved once) or a pattern (resolved per matched import, for
|
|
33
|
+
* a framework with an open-ended subpath surface like `svelte/internal/*`). Vite takes bare package
|
|
34
|
+
* names in `resolve.dedupe` and handles the subpaths itself. A framework declares whichever Bun arm
|
|
35
|
+
* fits plus its Vite names, so both pipelines pin the same framework from this one entry.
|
|
36
|
+
*/
|
|
37
|
+
export interface FrontendDedupePolicy {
|
|
38
|
+
readonly framework: string;
|
|
39
|
+
/** Exact specifiers the Bun build pins to the app's copy. Mutually exclusive with `bunPattern`. */
|
|
40
|
+
readonly bunSpecs?: readonly string[];
|
|
41
|
+
/** Specifier pattern the Bun build resolves per match, for an open-ended subpath surface. */
|
|
42
|
+
readonly bunPattern?: RegExp;
|
|
43
|
+
/** Bare package names the Vite build lists in `resolve.dedupe`. */
|
|
44
|
+
readonly viteDedupe: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
export declare const FRONTEND_DEDUPE_POLICIES: readonly FrontendDedupePolicy[];
|
|
47
|
+
/** Look up one framework's dedupe policy, throwing if a plugin references a framework the table dropped. */
|
|
48
|
+
export declare const dedupePolicyFor: (framework: string) => FrontendDedupePolicy;
|
|
49
|
+
/** The flat, de-duplicated `resolve.dedupe` list for the Vite client build. */
|
|
50
|
+
export declare const viteDedupePackages: () => readonly string[];
|
|
51
|
+
//# sourceMappingURL=identity-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-policy.d.ts","sourceRoot":"","sources":["../../src/internal/identity-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,MAAM,KAAG,OACO,CAAA;AAEjE;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,6FAA6F;IAC7F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC;AAED,eAAO,MAAM,wBAAwB,EAAE,SAAS,oBAAoB,EAyBnE,CAAA;AAED,4GAA4G;AAC5G,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,KAAG,oBAMnD,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,QAAO,SAAS,MAAM,EAEpD,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One source for which packages are identity-sensitive, and how each frontend framework is pinned to a
|
|
3
|
+
* single physical copy in a bundle.
|
|
4
|
+
*
|
|
5
|
+
* The identity-sensitive PACKAGE set lives in `@nifrajs/core` (`IDENTITY_SENSITIVE_PACKAGES`) - it is
|
|
6
|
+
* what single-copy enforcement and `nifra check` read, and it must be the same answer everywhere. This
|
|
7
|
+
* module does not restate it; it re-exports the one predicate every web caller should ask
|
|
8
|
+
* (`isIdentitySensitivePackage`) so a second list can never drift from core's.
|
|
9
|
+
*
|
|
10
|
+
* What this module DOES own is the per-bundler dedupe STRATEGY, which is a web concern (it names Bun and
|
|
11
|
+
* Vite mechanics core knows nothing about). The two client pipelines - `Bun.build` (build.ts) and Vite
|
|
12
|
+
* (build-vite.ts) - used to spell their framework coverage out independently, and they had already
|
|
13
|
+
* drifted: the Bun build pinned react + preact + svelte while the Vite build deduped react alone, so a
|
|
14
|
+
* Vite-built app silently shipped a second Preact or Svelte runtime. Both now read {@link
|
|
15
|
+
* FRONTEND_DEDUPE_POLICIES}, so their coverage cannot diverge again.
|
|
16
|
+
*
|
|
17
|
+
* Not every identity-sensitive framework is name-pinned here. Solid and Vue select their single runtime
|
|
18
|
+
* through export CONDITIONS rather than a resolver override, so they carry no entry - the conformance
|
|
19
|
+
* test allows core's set to be a superset of this table for exactly that reason, and only forbids the
|
|
20
|
+
* reverse (a strategy for a package core does not consider identity-sensitive).
|
|
21
|
+
*/
|
|
22
|
+
import { IDENTITY_SENSITIVE_PACKAGES, matchesSingleCopyDeclaration, } from "@nifrajs/core/single-copy";
|
|
23
|
+
/**
|
|
24
|
+
* Whether nifra treats a package as identity-sensitive: a second physical copy breaks behaviour (a hook
|
|
25
|
+
* dispatcher, a renderer's options global, a `Server` class identity) rather than merely costing bytes.
|
|
26
|
+
* The single predicate the whole web package asks, delegating to core's canonical declaration.
|
|
27
|
+
*/
|
|
28
|
+
export const isIdentitySensitivePackage = (name) => matchesSingleCopyDeclaration(IDENTITY_SENSITIVE_PACKAGES, name);
|
|
29
|
+
export const FRONTEND_DEDUPE_POLICIES = [
|
|
30
|
+
{
|
|
31
|
+
framework: "react",
|
|
32
|
+
// react-dom is absent on purpose: it imports react, so pinning react's core (and its JSX runtimes)
|
|
33
|
+
// gives it the one dispatcher. Vite dedupes react-dom by name because it collapses by package.
|
|
34
|
+
bunSpecs: ["react", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
|
35
|
+
viteDedupe: ["react", "react-dom"],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
framework: "preact",
|
|
39
|
+
bunSpecs: [
|
|
40
|
+
"preact",
|
|
41
|
+
"preact/hooks",
|
|
42
|
+
"preact/compat",
|
|
43
|
+
"preact/jsx-runtime",
|
|
44
|
+
"preact/jsx-dev-runtime",
|
|
45
|
+
],
|
|
46
|
+
viteDedupe: ["preact"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
framework: "svelte",
|
|
50
|
+
// Svelte's client runtime has many internal subpaths, so match the family and resolve each per hit.
|
|
51
|
+
bunPattern: /^svelte($|\/internal\/)/,
|
|
52
|
+
viteDedupe: ["svelte"],
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
/** Look up one framework's dedupe policy, throwing if a plugin references a framework the table dropped. */
|
|
56
|
+
export const dedupePolicyFor = (framework) => {
|
|
57
|
+
const policy = FRONTEND_DEDUPE_POLICIES.find((entry) => entry.framework === framework);
|
|
58
|
+
if (policy === undefined) {
|
|
59
|
+
throw new Error(`[nifra/web] no frontend dedupe policy for ${framework}`);
|
|
60
|
+
}
|
|
61
|
+
return policy;
|
|
62
|
+
};
|
|
63
|
+
/** The flat, de-duplicated `resolve.dedupe` list for the Vite client build. */
|
|
64
|
+
export const viteDedupePackages = () => [
|
|
65
|
+
...new Set(FRONTEND_DEDUPE_POLICIES.flatMap((policy) => policy.viteDedupe)),
|
|
66
|
+
];
|
|
67
|
+
//# sourceMappingURL=identity-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-policy.js","sourceRoot":"","sources":["../../src/internal/identity-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAA;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAW,EAAE,CAClE,4BAA4B,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;AAqBjE,MAAM,CAAC,MAAM,wBAAwB,GAAoC;IACvE;QACE,SAAS,EAAE,OAAO;QAClB,mGAAmG;QACnG,+FAA+F;QAC/F,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,CAAC;QACjE,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;KACnC;IACD;QACE,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE;YACR,QAAQ;YACR,cAAc;YACd,eAAe;YACf,oBAAoB;YACpB,wBAAwB;SACzB;QACD,UAAU,EAAE,CAAC,QAAQ,CAAC;KACvB;IACD;QACE,SAAS,EAAE,QAAQ;QACnB,oGAAoG;QACpG,UAAU,EAAE,yBAAyB;QACrC,UAAU,EAAE,CAAC,QAAQ,CAAC;KACvB;CACF,CAAA;AAED,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAwB,EAAE;IACzE,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA;IACtF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,6CAA6C,SAAS,EAAE,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAsB,EAAE,CAAC;IACzD,GAAG,IAAI,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;CAC5E,CAAA"}
|
|
@@ -5,9 +5,16 @@
|
|
|
5
5
|
* modules and emitted app surfaces resolve to one coherent graph? This internal seam owns path and
|
|
6
6
|
* manifest normalization so those callers cannot quietly grow separate rules.
|
|
7
7
|
*/
|
|
8
|
+
import { type SingleCopyRegistration } from "@nifrajs/core/single-copy";
|
|
8
9
|
export interface IdentityParityCopy {
|
|
9
10
|
readonly version: string;
|
|
10
11
|
readonly path: string;
|
|
12
|
+
/**
|
|
13
|
+
* The resolved realpath of the copy. `path` is display-relative to the invoked directory, which
|
|
14
|
+
* reads well in a report but cannot be pasted into a resolver or an editor from anywhere else.
|
|
15
|
+
* Absent on a finding built by hand (a test fixture, an older cached result).
|
|
16
|
+
*/
|
|
17
|
+
readonly absolutePath?: string;
|
|
11
18
|
readonly importers: readonly string[];
|
|
12
19
|
}
|
|
13
20
|
export type IdentityParityCause = "version-skew" | "duplicate-path";
|
|
@@ -20,14 +27,84 @@ export interface IdentityParityFinding {
|
|
|
20
27
|
readonly cause: IdentityParityCause;
|
|
21
28
|
readonly explanation: string;
|
|
22
29
|
readonly remediation: string;
|
|
30
|
+
/**
|
|
31
|
+
* Why the copies exist, in install-topology terms: how many physical paths sit under how many
|
|
32
|
+
* install roots, and whether any of those roots is outside the scanned project.
|
|
33
|
+
*
|
|
34
|
+
* A path list alone leaves the reader to reverse-engineer the shape. The two shapes need opposite
|
|
35
|
+
* fixes: a NESTED install under the scanned root shadows the hoisted copy and one reinstall
|
|
36
|
+
* collapses it, while a SIBLING install root (a linked checkout, a standalone app beside this one)
|
|
37
|
+
* owns its own `node_modules` and no reinstall here can touch it.
|
|
38
|
+
*
|
|
39
|
+
* Absent on a finding built by hand (a test fixture, an older cached result).
|
|
40
|
+
*/
|
|
41
|
+
readonly topology?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Why a copy the invoked directory does not import is still fatal here.
|
|
44
|
+
*
|
|
45
|
+
* The gate is workspace-wide on purpose. Scoping it to the invoked app would be more precise and
|
|
46
|
+
* would also reintroduce the blindness this guard was built for: a copy that arrives through a
|
|
47
|
+
* workspace-linked dependency is not visible from the app directory, and that case shipped a
|
|
48
|
+
* broken dev server while the check reported "none". A workspace-wide answer over-reports in
|
|
49
|
+
* exchange for never under-reporting - and over-reporting is the failure a developer can see and
|
|
50
|
+
* act on, where under-reporting is the one nobody knows happened.
|
|
51
|
+
*
|
|
52
|
+
* Present only when the answer would otherwise look wrong: a subdirectory was scanned as its
|
|
53
|
+
* workspace, and at least one copy sits outside that subdirectory.
|
|
54
|
+
*/
|
|
55
|
+
readonly scope?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The copies exist but the app declared this package single-copy, so the resolver collapses them
|
|
58
|
+
* before anything loads. Reported, never fatal - see `SingleCopyCoverage`.
|
|
59
|
+
*/
|
|
60
|
+
readonly deduplicated: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* What the app declared about deduplication, and how much of it is actually armed.
|
|
64
|
+
*
|
|
65
|
+
* A duplicate physical path is only a defect if something still LOADS both copies. An app consuming a
|
|
66
|
+
* linked sibling repository cannot collapse the paths without giving up the property it chose `link:`
|
|
67
|
+
* for - each repository owning its own `node_modules` - so nifra lets it declare the packages instead
|
|
68
|
+
* (`"nifra": { "singleCopy": [...] }` in package.json) and verifies the declaration here rather than
|
|
69
|
+
* failing on the raw path count.
|
|
70
|
+
*
|
|
71
|
+
* Bundled phases need nothing further: `buildClient`/`buildServer`/dev inject the resolver themselves.
|
|
72
|
+
* Unbundled phases do, because Bun's runtime never offers a bare specifier to a resolver hook, so the
|
|
73
|
+
* plugin has to be preloaded to intercept the load. `registration` is that proof, read statically out
|
|
74
|
+
* of `bunfig.toml`.
|
|
75
|
+
*/
|
|
76
|
+
export interface SingleCopyCoverage {
|
|
77
|
+
/** Declared package names and patterns, exactly as written. Empty when nothing was declared. */
|
|
78
|
+
readonly declared: readonly string[];
|
|
79
|
+
readonly registration: SingleCopyRegistration;
|
|
23
80
|
}
|
|
24
81
|
export interface IdentityParityResult {
|
|
82
|
+
/**
|
|
83
|
+
* The governing workspace root: where importer enumeration starts, and how far a copy lookup may
|
|
84
|
+
* walk up from an importer.
|
|
85
|
+
*
|
|
86
|
+
* EVERY caller resolves this the same way. The doctor and the build/dev preflight used to differ
|
|
87
|
+
* here - one anchored at the workspace, the other at the app directory - so the same project could
|
|
88
|
+
* be told it had duplicates by one command and a clean bill by the other. Two answers from one
|
|
89
|
+
* toolchain is worse than either answer, so the basis is now fixed and reported rather than chosen.
|
|
90
|
+
*/
|
|
25
91
|
readonly workspaceRoot: string;
|
|
92
|
+
/** The directory the caller asked about. Differs from `workspaceRoot` when a package subdirectory
|
|
93
|
+
* is governed by a workspace above it; carried so a report can state the basis it scanned on. */
|
|
94
|
+
readonly requestedRoot: string;
|
|
95
|
+
/**
|
|
96
|
+
* Enumeration stopped at `MAX_WORKSPACE_IMPORTERS`, so this scan is PARTIAL.
|
|
97
|
+
*
|
|
98
|
+
* An empty `findings` then means "nothing found in the part that was scanned", never "clean" - a
|
|
99
|
+
* caller that prints a clean bill on a truncated scan is the exact silence this flag exists to
|
|
100
|
+
* prevent.
|
|
101
|
+
*/
|
|
102
|
+
readonly truncated: boolean;
|
|
103
|
+
/** Findings that no declaration covers - the ones a build must refuse to start on. */
|
|
26
104
|
readonly findings: readonly IdentityParityFinding[];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly useWorkspaceRoot?: boolean;
|
|
105
|
+
/** Duplicates the declaration covers. Worth printing, never worth failing. */
|
|
106
|
+
readonly deduplicated: readonly IdentityParityFinding[];
|
|
107
|
+
readonly singleCopy: SingleCopyCoverage;
|
|
31
108
|
}
|
|
32
109
|
export interface BuildManifestLike {
|
|
33
110
|
readonly entry: string;
|
|
@@ -49,6 +126,9 @@ export interface DevelopmentParityInput {
|
|
|
49
126
|
readonly routes: Readonly<Record<string, number>>;
|
|
50
127
|
readonly publicFiles: readonly string[];
|
|
51
128
|
readonly css: readonly string[];
|
|
129
|
+
/** The scanned first-party source root, carried only so a css parity failure can name where the
|
|
130
|
+
* scanner looked. Optional: callers that hand-build an input for a unit test may omit it. */
|
|
131
|
+
readonly sourceRoot?: string;
|
|
52
132
|
}
|
|
53
133
|
export type ManifestParitySection = "module-graph" | "public-files" | "css";
|
|
54
134
|
export interface ManifestParityDifference {
|
|
@@ -56,6 +136,7 @@ export interface ManifestParityDifference {
|
|
|
56
136
|
readonly development: unknown;
|
|
57
137
|
readonly production: unknown;
|
|
58
138
|
}
|
|
139
|
+
export declare const pathInside: (root: string, path: string) => boolean;
|
|
59
140
|
/** Resolve the workspace root once, even when the caller starts in a workspace package. */
|
|
60
141
|
export declare function resolveParityWorkspaceRoot(start: string): Promise<{
|
|
61
142
|
readonly root: string;
|
|
@@ -67,13 +148,28 @@ export declare const resolvedInstalledCopy: (importer: string, boundary: string,
|
|
|
67
148
|
} | undefined>;
|
|
68
149
|
export declare const displayPath: (cwd: string, path: string) => string;
|
|
69
150
|
/** Find duplicate identity-sensitive package realpaths without reading application payloads. */
|
|
70
|
-
export declare function collectIdentityParity(cwd: string, rootPackage?: Record<string, unknown
|
|
71
|
-
/** One `- pkg [cause]: ...`
|
|
151
|
+
export declare function collectIdentityParity(cwd: string, rootPackage?: Record<string, unknown>): Promise<IdentityParityResult>;
|
|
152
|
+
/** One `- pkg [cause]: ...` block per finding, shared by the hard failure and the dev warning. */
|
|
72
153
|
export declare function formatIdentityParityFindings(findings: readonly IdentityParityFinding[]): string;
|
|
154
|
+
/**
|
|
155
|
+
* The basis a scan ran on, for any surface that reports its result.
|
|
156
|
+
*
|
|
157
|
+
* A verdict about installs is only as good as where it looked, and the reader cannot see that from a
|
|
158
|
+
* list of relative paths. Stating it also makes a truncated scan impossible to read as a clean one.
|
|
159
|
+
*/
|
|
160
|
+
export declare function identityParityBasis(result: IdentityParityResult): string;
|
|
73
161
|
/** `2 primary package findings` / `1 primary package finding`. */
|
|
74
162
|
export declare const identityParityHeadline: (count: number) => string;
|
|
75
|
-
/**
|
|
76
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Fail before dev/build when the same identity-sensitive package has multiple realpaths AND nothing
|
|
165
|
+
* is collapsing them.
|
|
166
|
+
*
|
|
167
|
+
* A declared package is not a suppression: the build injects the single-copy resolver, so the duplicate
|
|
168
|
+
* genuinely cannot reach the output. Failing on it anyway would leave the only supported answer being
|
|
169
|
+
* to change the install topology, which is the thing an app using linked sibling repositories cannot
|
|
170
|
+
* do. `result.deduplicated` still carries every covered duplicate for the caller to print.
|
|
171
|
+
*/
|
|
172
|
+
export declare function assertIdentityParity(cwd: string, rootPackage?: Record<string, unknown>): Promise<IdentityParityResult>;
|
|
77
173
|
/** Convert hashed production asset names into the stable module-graph contract. */
|
|
78
174
|
export declare function logicalStaticAssets(manifest: BuildManifestLike): readonly string[];
|
|
79
175
|
export declare function normalizeBuildManifest(manifest: BuildManifestLike): ParityManifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parity.d.ts","sourceRoot":"","sources":["../../src/internal/parity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"parity.d.ts","sourceRoot":"","sources":["../../src/internal/parity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAKL,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAA;AAclC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,gBAAgB,CAAA;AAEnE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAA;IAC9C,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,sGAAsG;IACtG,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;CAC/B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,QAA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