@nifrajs/core 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.
Files changed (226) hide show
  1. package/README.md +25 -0
  2. package/dist/assurance.d.ts +16 -8
  3. package/dist/assurance.d.ts.map +1 -1
  4. package/dist/assurance.js +33 -0
  5. package/dist/assurance.js.map +1 -1
  6. package/dist/durable-adapters.d.ts.map +1 -1
  7. package/dist/durable-adapters.js +26 -3
  8. package/dist/durable-adapters.js.map +1 -1
  9. package/dist/durable-approval.d.ts +56 -0
  10. package/dist/durable-approval.d.ts.map +1 -0
  11. package/dist/durable-approval.js +233 -0
  12. package/dist/durable-approval.js.map +1 -0
  13. package/dist/durable-effect.d.ts +42 -0
  14. package/dist/durable-effect.d.ts.map +1 -0
  15. package/dist/durable-effect.js +234 -0
  16. package/dist/durable-effect.js.map +1 -0
  17. package/dist/durable-execution.d.ts +8 -346
  18. package/dist/durable-execution.d.ts.map +1 -1
  19. package/dist/durable-execution.js +7 -1150
  20. package/dist/durable-execution.js.map +1 -1
  21. package/dist/durable-saga.d.ts +94 -0
  22. package/dist/durable-saga.d.ts.map +1 -0
  23. package/dist/durable-saga.js +550 -0
  24. package/dist/durable-saga.js.map +1 -0
  25. package/dist/edge-kit.d.ts +27 -0
  26. package/dist/edge-kit.d.ts.map +1 -0
  27. package/dist/edge-kit.js +24 -0
  28. package/dist/edge-kit.js.map +1 -0
  29. package/dist/errors.d.ts +1 -1
  30. package/dist/errors.d.ts.map +1 -1
  31. package/dist/errors.js.map +1 -1
  32. package/dist/index.d.ts +23 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/durable-approval-protocol.d.ts +1 -1
  37. package/dist/internal/durable-approval-protocol.d.ts.map +1 -1
  38. package/dist/internal/durable-effect-protocol.d.ts +1 -1
  39. package/dist/internal/durable-effect-protocol.d.ts.map +1 -1
  40. package/dist/internal/durable-saga-protocol.d.ts +1 -1
  41. package/dist/internal/durable-saga-protocol.d.ts.map +1 -1
  42. package/dist/internal/durable-shared.d.ts +26 -0
  43. package/dist/internal/durable-shared.d.ts.map +1 -0
  44. package/dist/internal/durable-shared.js +131 -0
  45. package/dist/internal/durable-shared.js.map +1 -0
  46. package/dist/internal/durable-types.d.ts +159 -0
  47. package/dist/internal/durable-types.d.ts.map +1 -0
  48. package/dist/internal/durable-types.js +2 -0
  49. package/dist/internal/durable-types.js.map +1 -0
  50. package/dist/internal/route-compiler.d.ts +61 -0
  51. package/dist/internal/route-compiler.d.ts.map +1 -0
  52. package/dist/internal/route-compiler.js +121 -0
  53. package/dist/internal/route-compiler.js.map +1 -0
  54. package/dist/internal/route-execution.d.ts +17 -9
  55. package/dist/internal/route-execution.d.ts.map +1 -1
  56. package/dist/internal/route-execution.js +4 -18
  57. package/dist/internal/route-execution.js.map +1 -1
  58. package/dist/internal/route-lanes.d.ts +35 -0
  59. package/dist/internal/route-lanes.d.ts.map +1 -0
  60. package/dist/internal/route-lanes.js +150 -0
  61. package/dist/internal/route-lanes.js.map +1 -0
  62. package/dist/internal/route-program.d.ts +67 -0
  63. package/dist/internal/route-program.d.ts.map +1 -0
  64. package/dist/internal/route-program.js +199 -0
  65. package/dist/internal/route-program.js.map +1 -0
  66. package/dist/response-observer.d.ts +25 -0
  67. package/dist/response-observer.d.ts.map +1 -0
  68. package/dist/response-observer.js +40 -0
  69. package/dist/response-observer.js.map +1 -0
  70. package/dist/security/baseline.d.ts +68 -0
  71. package/dist/security/baseline.d.ts.map +1 -0
  72. package/dist/security/baseline.js +118 -0
  73. package/dist/security/baseline.js.map +1 -0
  74. package/dist/server/bare-error-lane.d.ts +26 -0
  75. package/dist/server/bare-error-lane.d.ts.map +1 -0
  76. package/dist/server/bare-error-lane.js +60 -0
  77. package/dist/server/bare-error-lane.js.map +1 -0
  78. package/dist/server/body-lane.d.ts +13 -0
  79. package/dist/server/body-lane.d.ts.map +1 -0
  80. package/dist/server/body-lane.js +134 -0
  81. package/dist/server/body-lane.js.map +1 -0
  82. package/dist/server/body.d.ts +7 -0
  83. package/dist/server/body.d.ts.map +1 -1
  84. package/dist/server/body.js +7 -0
  85. package/dist/server/body.js.map +1 -1
  86. package/dist/server/bridge-markers.d.ts +25 -0
  87. package/dist/server/bridge-markers.d.ts.map +1 -0
  88. package/dist/server/bridge-markers.js +25 -0
  89. package/dist/server/bridge-markers.js.map +1 -0
  90. package/dist/server/context.d.ts +6 -1
  91. package/dist/server/context.d.ts.map +1 -1
  92. package/dist/server/contract.d.ts +40 -14
  93. package/dist/server/contract.d.ts.map +1 -1
  94. package/dist/server/contract.js +7 -0
  95. package/dist/server/contract.js.map +1 -1
  96. package/dist/server/cookies.d.ts.map +1 -1
  97. package/dist/server/cookies.js +16 -2
  98. package/dist/server/cookies.js.map +1 -1
  99. package/dist/server/header-case.d.ts.map +1 -1
  100. package/dist/server/header-case.js +2 -1
  101. package/dist/server/header-case.js.map +1 -1
  102. package/dist/server/http.d.ts +36 -3
  103. package/dist/server/http.d.ts.map +1 -1
  104. package/dist/server/http.js +49 -3
  105. package/dist/server/http.js.map +1 -1
  106. package/dist/server/install.d.ts +6 -8
  107. package/dist/server/install.d.ts.map +1 -1
  108. package/dist/server/install.js +7 -0
  109. package/dist/server/install.js.map +1 -1
  110. package/dist/server/node-outcome-hook.d.ts +2 -1
  111. package/dist/server/node-outcome-hook.d.ts.map +1 -1
  112. package/dist/server/node-outcome-hook.js.map +1 -1
  113. package/dist/server/node-outcome.d.ts +17 -2
  114. package/dist/server/node-outcome.d.ts.map +1 -1
  115. package/dist/server/node-outcome.js +37 -3
  116. package/dist/server/node-outcome.js.map +1 -1
  117. package/dist/server/plugin.d.ts +2 -2
  118. package/dist/server/plugin.d.ts.map +1 -1
  119. package/dist/server/plugin.js +6 -1
  120. package/dist/server/plugin.js.map +1 -1
  121. package/dist/server/query.d.ts +7 -1
  122. package/dist/server/query.d.ts.map +1 -1
  123. package/dist/server/query.js +8 -3
  124. package/dist/server/query.js.map +1 -1
  125. package/dist/server/registry.d.ts +40 -12
  126. package/dist/server/registry.d.ts.map +1 -1
  127. package/dist/server/request-context.d.ts +2 -13
  128. package/dist/server/request-context.d.ts.map +1 -1
  129. package/dist/server/request-context.js +18 -159
  130. package/dist/server/request-context.js.map +1 -1
  131. package/dist/server/respond.d.ts.map +1 -1
  132. package/dist/server/respond.js +58 -4
  133. package/dist/server/respond.js.map +1 -1
  134. package/dist/server/response-contract-lane.d.ts.map +1 -1
  135. package/dist/server/response-contract-lane.js +5 -2
  136. package/dist/server/response-contract-lane.js.map +1 -1
  137. package/dist/server/response-observer-runtime.d.ts +20 -0
  138. package/dist/server/response-observer-runtime.d.ts.map +1 -0
  139. package/dist/server/response-observer-runtime.js +95 -0
  140. package/dist/server/response-observer-runtime.js.map +1 -0
  141. package/dist/server/runtime-core.d.ts +76 -0
  142. package/dist/server/runtime-core.d.ts.map +1 -1
  143. package/dist/server/runtime-core.js +42 -1
  144. package/dist/server/runtime-core.js.map +1 -1
  145. package/dist/server/server-types.d.ts +6 -1
  146. package/dist/server/server-types.d.ts.map +1 -1
  147. package/dist/server/server.d.ts +158 -116
  148. package/dist/server/server.d.ts.map +1 -1
  149. package/dist/server/server.js +707 -844
  150. package/dist/server/server.js.map +1 -1
  151. package/dist/server/validation.d.ts +5 -0
  152. package/dist/server/validation.d.ts.map +1 -0
  153. package/dist/server/validation.js +13 -0
  154. package/dist/server/validation.js.map +1 -0
  155. package/dist/server/websocket.d.ts +20 -4
  156. package/dist/server/websocket.d.ts.map +1 -1
  157. package/dist/server/websocket.js +81 -11
  158. package/dist/server/websocket.js.map +1 -1
  159. package/dist/server/ws-bun.d.ts +12 -4
  160. package/dist/server/ws-bun.d.ts.map +1 -1
  161. package/dist/server/ws-bun.js +50 -16
  162. package/dist/server/ws-bun.js.map +1 -1
  163. package/dist/server/ws-hook.d.ts +3 -2
  164. package/dist/server/ws-hook.d.ts.map +1 -1
  165. package/dist/server.d.ts +3 -2
  166. package/dist/server.d.ts.map +1 -1
  167. package/dist/server.js +2 -1
  168. package/dist/server.js.map +1 -1
  169. package/dist/single-copy-register.d.ts +2 -0
  170. package/dist/single-copy-register.d.ts.map +1 -0
  171. package/dist/single-copy-register.js +24 -0
  172. package/dist/single-copy-register.js.map +1 -0
  173. package/dist/single-copy.d.ts +156 -0
  174. package/dist/single-copy.d.ts.map +1 -0
  175. package/dist/single-copy.js +472 -0
  176. package/dist/single-copy.js.map +1 -0
  177. package/package.json +28 -3
  178. package/src/assurance.ts +58 -1
  179. package/src/durable-adapters.ts +20 -0
  180. package/src/durable-approval.ts +281 -0
  181. package/src/durable-effect.ts +300 -0
  182. package/src/durable-execution.ts +8 -1627
  183. package/src/durable-saga.ts +744 -0
  184. package/src/edge-kit.ts +27 -0
  185. package/src/errors.ts +1 -0
  186. package/src/index.ts +129 -2
  187. package/src/internal/durable-approval-protocol.ts +1 -1
  188. package/src/internal/durable-effect-protocol.ts +1 -1
  189. package/src/internal/durable-saga-protocol.ts +1 -1
  190. package/src/internal/durable-shared.ts +157 -0
  191. package/src/internal/durable-types.ts +194 -0
  192. package/src/internal/route-compiler.ts +234 -0
  193. package/src/internal/route-execution.ts +53 -96
  194. package/src/internal/route-lanes.ts +221 -0
  195. package/src/internal/route-program.ts +404 -0
  196. package/src/response-observer.ts +64 -0
  197. package/src/security/baseline.ts +172 -0
  198. package/src/server/bare-error-lane.ts +77 -0
  199. package/src/server/body-lane.ts +203 -0
  200. package/src/server/body.ts +8 -0
  201. package/src/server/bridge-markers.ts +24 -0
  202. package/src/server/context.ts +6 -1
  203. package/src/server/contract.ts +70 -20
  204. package/src/server/cookies.ts +16 -2
  205. package/src/server/header-case.ts +3 -1
  206. package/src/server/http.ts +53 -3
  207. package/src/server/install.ts +14 -0
  208. package/src/server/node-outcome-hook.ts +2 -1
  209. package/src/server/node-outcome.ts +44 -3
  210. package/src/server/plugin.ts +11 -5
  211. package/src/server/query.ts +10 -4
  212. package/src/server/registry.ts +71 -16
  213. package/src/server/request-context.ts +13 -216
  214. package/src/server/respond.ts +71 -3
  215. package/src/server/response-contract-lane.ts +6 -2
  216. package/src/server/response-observer-runtime.ts +135 -0
  217. package/src/server/runtime-core.ts +124 -1
  218. package/src/server/server-types.ts +6 -1
  219. package/src/server/server.ts +1446 -1485
  220. package/src/server/validation.ts +19 -0
  221. package/src/server/websocket.ts +127 -17
  222. package/src/server/ws-bun.ts +67 -15
  223. package/src/server/ws-hook.ts +3 -2
  224. package/src/server.ts +8 -2
  225. package/src/single-copy-register.ts +24 -0
  226. package/src/single-copy.ts +526 -0
@@ -0,0 +1,156 @@
1
+ /**
2
+ * One physical copy of an identity-sensitive package, enforced at LOAD time.
3
+ *
4
+ * ## The gap this closes
5
+ *
6
+ * `@nifrajs/web`'s build already pins react/preact/svelte to the app's copy through `onResolve`
7
+ * (`reactDedupePlugin` and friends), and that covers every bundled phase. It cannot cover an
8
+ * UNBUNDLED one: Bun's runtime plugin API delivers only the entry point and RELATIVE specifiers to
9
+ * `onResolve`, so a bare `import "react"` inside a linked package never reaches a resolver hook. The
10
+ * surfaces that run app sources unbundled - `bun test`, a preloaded script, a route imported natively
11
+ * - therefore keep loading a second copy no matter what the build does. `onLoad` DOES fire on the
12
+ * resolved file, which is the one hook that can still intervene, and it is what this module uses.
13
+ *
14
+ * It also covers a package class the build plugins never did: `@nifrajs/*` itself. Two copies of
15
+ * `@nifrajs/core` are two `Server` classes, and `Server` carries private members, so `.merge()` stops
16
+ * accepting the other's app with a type error that names neither copy.
17
+ *
18
+ * ## Why a topology needs it at all
19
+ *
20
+ * A package consumed with `link:` (or `file:`, or an `npm link`) resolves ITS OWN imports from where
21
+ * it physically lives. A shared component library in a sibling repository therefore loads that
22
+ * repository's react, while the app loads its own - same version, two paths, two module registries.
23
+ * React reads hooks off a dispatcher the other copy never set, and SSR dies with `Invalid hook call
24
+ * … resolveDispatcher() is null`, naming neither react nor the package that shadowed it.
25
+ *
26
+ * The conventional fixes both cost something real: a cross-repo `workspaces` entry makes the
27
+ * consumer's install the owner of the other repository's tree and writes into it, and vendoring or
28
+ * packing copies files that exist precisely so they are not copied. This module is the third option -
29
+ * leave the topology alone and make the resolution answer correctly - and it is not a workaround:
30
+ * these packages declare react as a `peerDependency`, which means "the consumer supplies the copy".
31
+ * That sentence has simply never been enforceable at runtime. Now it is.
32
+ *
33
+ * ## What it will not do
34
+ *
35
+ * Redirect across a VERSION difference. Two versions is a different defect (someone's range is wrong)
36
+ * and silently serving 19.2.8 to a package that asked for 19.2.7 turns a loud install problem into a
37
+ * quiet behavioural one. A version skew is left untouched, so `nifra check` still fails it.
38
+ *
39
+ * @example Declare it in package.json, then preload the registrar in bunfig.toml.
40
+ * ```json
41
+ * { "nifra": { "singleCopy": ["react", "react-dom", "@nifrajs/*"] } }
42
+ * ```
43
+ * ```toml
44
+ * preload = ["@nifrajs/core/single-copy/register"]
45
+ * [test]
46
+ * preload = ["@nifrajs/core/single-copy/register"]
47
+ * ```
48
+ */
49
+ import type { BunPlugin } from "bun";
50
+ /**
51
+ * Packages whose duplication is a defect rather than a waste. Each keeps module-scoped state that
52
+ * every importer must share - a hook dispatcher, a renderer's options global, a class identity - so a
53
+ * second physical copy breaks behaviour instead of merely costing bytes. Anything scoped `@nifrajs/`
54
+ * qualifies for the same reason and is matched by pattern.
55
+ */
56
+ export declare const IDENTITY_SENSITIVE_PACKAGES: readonly string[];
57
+ export type SingleCopySkipReason = "version-skew" | "no-counterpart";
58
+ /** One foreign copy that will be redirected into the app's copy. */
59
+ export interface SingleCopyRedirect {
60
+ readonly package: string;
61
+ /** Absolute realpath of the copy that loses - the one a linked package would otherwise load. */
62
+ readonly from: string;
63
+ /** Absolute realpath of the copy that wins - the one resolvable from the app root. */
64
+ readonly to: string;
65
+ readonly version: string;
66
+ }
67
+ /** A foreign copy deliberately left alone, and why - never silently dropped. */
68
+ export interface SingleCopySkip {
69
+ readonly package: string;
70
+ readonly from: string;
71
+ readonly reason: SingleCopySkipReason;
72
+ readonly detail: string;
73
+ }
74
+ export interface SingleCopyPlan {
75
+ /** The app root whose installed copy wins. */
76
+ readonly root: string;
77
+ /** Declared package names and patterns, as written. */
78
+ readonly declared: readonly string[];
79
+ readonly redirects: readonly SingleCopyRedirect[];
80
+ readonly skipped: readonly SingleCopySkip[];
81
+ }
82
+ export interface SingleCopyOptions {
83
+ /** The app root whose copy wins. Defaults to `process.cwd()`. */
84
+ readonly cwd?: string;
85
+ /** Package names or `@scope/*` patterns. Defaults to the `nifra.singleCopy` declaration. */
86
+ readonly packages?: readonly string[];
87
+ }
88
+ /**
89
+ * The declaration, read from `package.json` - deliberately NOT from `nifra.config.ts`.
90
+ *
91
+ * `nifra check` holds a pre-load invariant: it never imports the app's config, because importing is
92
+ * executing. A dedupe claim has to be verifiable by a checker that refuses to run the app, so it lives
93
+ * in the one file every tool already parses. `true` means the built-in identity-sensitive set.
94
+ */
95
+ export declare function readSingleCopyDeclaration(cwd: string): readonly string[] | undefined;
96
+ /**
97
+ * Match a package name against a declaration entry: an exact name, or a `@scope/*` prefix.
98
+ *
99
+ * Exported because the enforcement and the CHECK must agree on it exactly. If `nifra check` decided
100
+ * coverage by its own rule, a package could be reported as deduplicated while the plugin walked past
101
+ * it - which is worse than no check at all, because it is a green light for a broken graph.
102
+ */
103
+ export declare const matchesSingleCopyDeclaration: (declared: readonly string[], name: string) => boolean;
104
+ /** The public specifier a `bunfig.toml` preload must name to arm the runtime. */
105
+ export declare const SINGLE_COPY_REGISTER_SPECIFIER = "@nifrajs/core/single-copy/register";
106
+ /** Which unbundled phases have the resolver preloaded. Bundled phases never need it - nifra's build
107
+ * injects the plugin itself. */
108
+ export interface SingleCopyRegistration {
109
+ /** `preload` at the top level: covers `bun run` and anything that loads app sources directly. */
110
+ readonly run: boolean;
111
+ /** `[test] preload`: covers `bun test`, the surface that runs app sources unbundled. */
112
+ readonly test: boolean;
113
+ /** The `bunfig.toml` that was read, if one exists. */
114
+ readonly config?: string;
115
+ }
116
+ /**
117
+ * Read the runtime proof out of `bunfig.toml`.
118
+ *
119
+ * Line-oriented on purpose: this runs inside `nifra check`, which must not execute or import anything
120
+ * from the project, and the shape being read is a literal array of strings under a known key. A full
121
+ * TOML parse would buy nothing here and would turn an unrelated syntax error elsewhere in the file
122
+ * into a failure to answer this question.
123
+ */
124
+ export declare function readSingleCopyRegistration(cwd: string): SingleCopyRegistration;
125
+ /**
126
+ * Work out which foreign copies exist and which of them may be redirected.
127
+ *
128
+ * Pure discovery: it reads `package.json` files and symlink targets, never application source, and
129
+ * never mutates anything. Both the plugin and `nifra check`'s verification are built on it, so the
130
+ * enforcement and the report cannot drift apart.
131
+ */
132
+ export declare function planSingleCopy(options?: SingleCopyOptions): SingleCopyPlan;
133
+ /** A Bun plugin - `Bun.plugin(...)` for the runtime, or a `plugins:` entry for `Bun.build`. */
134
+ export interface SingleCopyPlugin extends BunPlugin {
135
+ /** What it will do, computed once at construction. Exposed so a caller can report it. */
136
+ readonly plan: SingleCopyPlan;
137
+ }
138
+ /**
139
+ * Pin every declared package to the app's copy.
140
+ *
141
+ * Two hooks, because the two phases resolve differently. `onResolve` is the direct statement of the
142
+ * rule and it is what a BUNDLER honours - it sees every bare specifier. The runtime does not deliver
143
+ * bare specifiers to it at all, so the `onLoad` arm intercepts the foreign file itself and hands back
144
+ * a re-export of the counterpart in the winning copy. The importer gets the same function objects and
145
+ * therefore the same module state, which is the entire requirement.
146
+ */
147
+ export declare function singleCopyPlugin(options?: SingleCopyOptions): SingleCopyPlugin;
148
+ /** Set once the runtime plugin is installed, so a checker can tell "one copy" from "deduplicated". */
149
+ export declare const SINGLE_COPY_ACTIVE: unique symbol;
150
+ /**
151
+ * Install the plugin into the Bun RUNTIME. Import `@nifrajs/core/single-copy/register` from a
152
+ * `bunfig.toml` preload rather than calling this from application code: a resolver installed from
153
+ * inside a module cannot affect the imports that module already resolved.
154
+ */
155
+ export declare function registerSingleCopy(options?: SingleCopyOptions): SingleCopyPlan;
156
+ //# sourceMappingURL=single-cop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AAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAyBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAYpF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,SAAS,MAAM,EAAE,EAAE,MAAM,MAAM,KAAG,OAGtF,CAAA;AAEH,iFAAiF;AACjF,eAAO,MAAM,8BAA8B,uCAAuC,CAAA;AAElF;gCACgC;AAChC,MAAM,WAAW,sBAAsB;IACrC,iGAAiG;IACjG,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAgCD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAyB9E;AAuHD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAkC9E;AA0CD,+FAA+F;AAC/F,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,yFAAyF;IACzF,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAgDlF;AAED,sGAAsG;AACtG,eAAO,MAAM,kBAAkB,eAAyC,CAAA;AAExE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAKlF"}
@@ -0,0 +1,472 @@
1
+ /**
2
+ * One physical copy of an identity-sensitive package, enforced at LOAD time.
3
+ *
4
+ * ## The gap this closes
5
+ *
6
+ * `@nifrajs/web`'s build already pins react/preact/svelte to the app's copy through `onResolve`
7
+ * (`reactDedupePlugin` and friends), and that covers every bundled phase. It cannot cover an
8
+ * UNBUNDLED one: Bun's runtime plugin API delivers only the entry point and RELATIVE specifiers to
9
+ * `onResolve`, so a bare `import "react"` inside a linked package never reaches a resolver hook. The
10
+ * surfaces that run app sources unbundled - `bun test`, a preloaded script, a route imported natively
11
+ * - therefore keep loading a second copy no matter what the build does. `onLoad` DOES fire on the
12
+ * resolved file, which is the one hook that can still intervene, and it is what this module uses.
13
+ *
14
+ * It also covers a package class the build plugins never did: `@nifrajs/*` itself. Two copies of
15
+ * `@nifrajs/core` are two `Server` classes, and `Server` carries private members, so `.merge()` stops
16
+ * accepting the other's app with a type error that names neither copy.
17
+ *
18
+ * ## Why a topology needs it at all
19
+ *
20
+ * A package consumed with `link:` (or `file:`, or an `npm link`) resolves ITS OWN imports from where
21
+ * it physically lives. A shared component library in a sibling repository therefore loads that
22
+ * repository's react, while the app loads its own - same version, two paths, two module registries.
23
+ * React reads hooks off a dispatcher the other copy never set, and SSR dies with `Invalid hook call
24
+ * … resolveDispatcher() is null`, naming neither react nor the package that shadowed it.
25
+ *
26
+ * The conventional fixes both cost something real: a cross-repo `workspaces` entry makes the
27
+ * consumer's install the owner of the other repository's tree and writes into it, and vendoring or
28
+ * packing copies files that exist precisely so they are not copied. This module is the third option -
29
+ * leave the topology alone and make the resolution answer correctly - and it is not a workaround:
30
+ * these packages declare react as a `peerDependency`, which means "the consumer supplies the copy".
31
+ * That sentence has simply never been enforceable at runtime. Now it is.
32
+ *
33
+ * ## What it will not do
34
+ *
35
+ * Redirect across a VERSION difference. Two versions is a different defect (someone's range is wrong)
36
+ * and silently serving 19.2.8 to a package that asked for 19.2.7 turns a loud install problem into a
37
+ * quiet behavioural one. A version skew is left untouched, so `nifra check` still fails it.
38
+ *
39
+ * @example Declare it in package.json, then preload the registrar in bunfig.toml.
40
+ * ```json
41
+ * { "nifra": { "singleCopy": ["react", "react-dom", "@nifrajs/*"] } }
42
+ * ```
43
+ * ```toml
44
+ * preload = ["@nifrajs/core/single-copy/register"]
45
+ * [test]
46
+ * preload = ["@nifrajs/core/single-copy/register"]
47
+ * ```
48
+ */
49
+ import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
50
+ import { dirname, join, relative, resolve, sep } from "node:path";
51
+ /**
52
+ * Packages whose duplication is a defect rather than a waste. Each keeps module-scoped state that
53
+ * every importer must share - a hook dispatcher, a renderer's options global, a class identity - so a
54
+ * second physical copy breaks behaviour instead of merely costing bytes. Anything scoped `@nifrajs/`
55
+ * qualifies for the same reason and is matched by pattern.
56
+ */
57
+ export const IDENTITY_SENSITIVE_PACKAGES = [
58
+ "@nifrajs/*",
59
+ "react",
60
+ "react-dom",
61
+ "preact",
62
+ "solid-js",
63
+ "svelte",
64
+ "vue",
65
+ ];
66
+ /** Files a redirect may rewrite. Everything else in a package (json, css, wasm) loads unchanged. */
67
+ const REDIRECTABLE = /\.(?:m|c)?[jt]sx?$/;
68
+ /** Runaway guards. A real `node_modules` top level is hundreds of entries, a repo walk is a few. */
69
+ const MAX_SCANNED_ENTRIES = 4_096;
70
+ const MAX_ANCESTOR_DIRS = 16;
71
+ const MAX_REPO_DEPTH = 8;
72
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
73
+ const readJsonSync = (path) => {
74
+ try {
75
+ const value = JSON.parse(readFileSync(path, "utf8"));
76
+ return isRecord(value) ? value : undefined;
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ };
82
+ const realpathOrSelf = (path) => {
83
+ try {
84
+ return realpathSync(path);
85
+ }
86
+ catch {
87
+ return path;
88
+ }
89
+ };
90
+ const inside = (root, path) => path === root || path.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
91
+ /**
92
+ * The declaration, read from `package.json` - deliberately NOT from `nifra.config.ts`.
93
+ *
94
+ * `nifra check` holds a pre-load invariant: it never imports the app's config, because importing is
95
+ * executing. A dedupe claim has to be verifiable by a checker that refuses to run the app, so it lives
96
+ * in the one file every tool already parses. `true` means the built-in identity-sensitive set.
97
+ */
98
+ export function readSingleCopyDeclaration(cwd) {
99
+ const pkg = readJsonSync(join(resolve(cwd), "package.json"));
100
+ const nifra = pkg?.nifra;
101
+ if (!isRecord(nifra))
102
+ return undefined;
103
+ const declared = nifra.singleCopy;
104
+ if (declared === true)
105
+ return IDENTITY_SENSITIVE_PACKAGES;
106
+ if (declared === false || declared === undefined)
107
+ return undefined;
108
+ if (!Array.isArray(declared))
109
+ return undefined;
110
+ const names = declared.filter((name) => typeof name === "string" && name.length > 0);
111
+ return names.length > 0 ? names : undefined;
112
+ }
113
+ /**
114
+ * Match a package name against a declaration entry: an exact name, or a `@scope/*` prefix.
115
+ *
116
+ * Exported because the enforcement and the CHECK must agree on it exactly. If `nifra check` decided
117
+ * coverage by its own rule, a package could be reported as deduplicated while the plugin walked past
118
+ * it - which is worse than no check at all, because it is a green light for a broken graph.
119
+ */
120
+ export const matchesSingleCopyDeclaration = (declared, name) => declared.some((entry) => entry.endsWith("/*") ? name.startsWith(entry.slice(0, -1)) : entry === name);
121
+ /** The public specifier a `bunfig.toml` preload must name to arm the runtime. */
122
+ export const SINGLE_COPY_REGISTER_SPECIFIER = "@nifrajs/core/single-copy/register";
123
+ /** Every `preload = [...]` assignment, tagged with the section it appears under. */
124
+ const PRELOAD_ASSIGNMENT = /^\s*(?:\[(?<section>[^\]]+)\]|preload\s*=\s*(?<value>\[[^\]]*\]|.+))\s*$/;
125
+ /**
126
+ * The exact entries of a `preload` assignment: a single-line array, or one quoted string.
127
+ *
128
+ * A substring test on the raw assignment is not proof. `preload =
129
+ * ["@nifrajs/core/single-copy/register-extra"]` contains the specifier and satisfies an
130
+ * `includes()`, while Bun loads that other module and the registrar never runs - the check then
131
+ * reports single-copy enforcement as armed on a process that still loads both copies. An entry only
132
+ * counts when it IS the specifier. Anything this cannot read as a quoted entry (a multi-line array,
133
+ * an interpolated value) yields nothing, so the caller reports "not registered" rather than proof.
134
+ */
135
+ function preloadEntries(value) {
136
+ const closing = value.lastIndexOf("]");
137
+ const inner = value.startsWith("[") && closing !== -1 ? value.slice(1, closing) : value;
138
+ const entries = [];
139
+ for (const raw of inner.split(",")) {
140
+ const entry = raw.trim();
141
+ // A TOML string is quoted at both ends with the same quote; two characters is the shortest one.
142
+ if (entry.length < 2)
143
+ continue;
144
+ const quote = entry.charCodeAt(0);
145
+ if (quote !== 34 && quote !== 39)
146
+ continue;
147
+ if (entry.charCodeAt(entry.length - 1) !== quote)
148
+ continue;
149
+ entries.push(entry.slice(1, -1));
150
+ }
151
+ return entries;
152
+ }
153
+ /**
154
+ * Read the runtime proof out of `bunfig.toml`.
155
+ *
156
+ * Line-oriented on purpose: this runs inside `nifra check`, which must not execute or import anything
157
+ * from the project, and the shape being read is a literal array of strings under a known key. A full
158
+ * TOML parse would buy nothing here and would turn an unrelated syntax error elsewhere in the file
159
+ * into a failure to answer this question.
160
+ */
161
+ export function readSingleCopyRegistration(cwd) {
162
+ const config = join(resolve(cwd), "bunfig.toml");
163
+ let text;
164
+ try {
165
+ text = readFileSync(config, "utf8");
166
+ }
167
+ catch {
168
+ return { run: false, test: false };
169
+ }
170
+ let section = "";
171
+ let run = false;
172
+ let test = false;
173
+ for (const line of text.split(/\r?\n/)) {
174
+ const match = PRELOAD_ASSIGNMENT.exec(line);
175
+ if (match?.groups === undefined)
176
+ continue;
177
+ const { section: heading, value } = match.groups;
178
+ if (heading !== undefined) {
179
+ section = heading.trim();
180
+ continue;
181
+ }
182
+ if (value === undefined || !preloadEntries(value).includes(SINGLE_COPY_REGISTER_SPECIFIER))
183
+ continue;
184
+ if (section === "test")
185
+ test = true;
186
+ else if (section === "")
187
+ run = true;
188
+ }
189
+ return { run, test, config };
190
+ }
191
+ /** The repository a linked checkout resolves its own dependencies from: its nearest `.git` ancestor.
192
+ * A path that lands inside a `node_modules` is a package-manager store copy rather than a checkout,
193
+ * and everything above it belongs to whoever owns that store - clamp to the copy itself. */
194
+ const repoBoundary = (packageRoot) => {
195
+ if (packageRoot.split(sep).includes("node_modules"))
196
+ return packageRoot;
197
+ let dir = packageRoot;
198
+ for (let depth = 0; depth < MAX_REPO_DEPTH; depth++) {
199
+ if (existsSync(join(dir, ".git")))
200
+ return dir;
201
+ const parent = dirname(dir);
202
+ if (parent === dir)
203
+ break;
204
+ dir = parent;
205
+ }
206
+ return packageRoot;
207
+ };
208
+ /** Walk up from `start` for `node_modules/<name>/package.json`, stopping after `boundary`. */
209
+ const installedCopy = (start, name, boundary) => {
210
+ const parts = name.split("/");
211
+ for (let dir = start;; dir = dirname(dir)) {
212
+ const packageRoot = join(dir, "node_modules", ...parts);
213
+ const meta = readJsonSync(join(packageRoot, "package.json"));
214
+ if (meta !== undefined) {
215
+ return {
216
+ root: realpathOrSelf(packageRoot),
217
+ version: typeof meta.version === "string" ? meta.version : "unknown",
218
+ };
219
+ }
220
+ if (dir === boundary)
221
+ return undefined;
222
+ const parent = dirname(dir);
223
+ if (parent === dir)
224
+ return undefined;
225
+ }
226
+ };
227
+ /** Every `node_modules` from the app root up to (and including) its repository root. */
228
+ const nodeModulesDirs = (root) => {
229
+ const boundary = repoBoundary(root);
230
+ const dirs = [];
231
+ let dir = root;
232
+ for (let depth = 0; depth < MAX_ANCESTOR_DIRS; depth++) {
233
+ const candidate = join(dir, "node_modules");
234
+ if (existsSync(candidate))
235
+ dirs.push(candidate);
236
+ if (dir === boundary)
237
+ break;
238
+ const parent = dirname(dir);
239
+ if (parent === dir)
240
+ break;
241
+ dir = parent;
242
+ }
243
+ return dirs;
244
+ };
245
+ /**
246
+ * Package directories that are symlinked OUT of this repository - the `link:` / `file:` / `npm link`
247
+ * consumers whose own imports resolve somewhere this install does not own. Those are the only
248
+ * importers that can introduce a second copy; a normally-installed dependency resolves inside the
249
+ * tree that just installed it.
250
+ */
251
+ const linkedPackageDirs = (root) => {
252
+ const repo = realpathOrSelf(repoBoundary(root));
253
+ const found = new Set();
254
+ let scanned = 0;
255
+ for (const nodeModules of nodeModulesDirs(root)) {
256
+ let entries;
257
+ try {
258
+ entries = readdirSync(nodeModules);
259
+ }
260
+ catch {
261
+ continue;
262
+ }
263
+ for (const entry of entries) {
264
+ if (scanned++ >= MAX_SCANNED_ENTRIES)
265
+ return [...found];
266
+ if (entry === ".bin" || entry === ".cache")
267
+ continue;
268
+ const path = join(nodeModules, entry);
269
+ // A scope directory is not a package; its children are.
270
+ const children = entry.startsWith("@")
271
+ ? readdirSync(path, { withFileTypes: true }).map((child) => join(path, child.name))
272
+ : [path];
273
+ for (const candidate of children) {
274
+ if (scanned++ >= MAX_SCANNED_ENTRIES)
275
+ return [...found];
276
+ let link;
277
+ try {
278
+ link = lstatSync(candidate);
279
+ }
280
+ catch {
281
+ continue;
282
+ }
283
+ if (!link.isSymbolicLink())
284
+ continue;
285
+ const target = realpathOrSelf(candidate);
286
+ if (inside(repo, target))
287
+ continue;
288
+ found.add(target);
289
+ }
290
+ }
291
+ }
292
+ return [...found];
293
+ };
294
+ /** Concrete package names a declaration covers, taken from what is actually installed for the app. */
295
+ const declaredNames = (root, declared) => {
296
+ const names = new Set();
297
+ for (const entry of declared) {
298
+ if (!entry.endsWith("/*")) {
299
+ names.add(entry);
300
+ continue;
301
+ }
302
+ const scope = entry.slice(0, -2);
303
+ for (const nodeModules of nodeModulesDirs(root)) {
304
+ const scopeDir = join(nodeModules, ...scope.split("/"));
305
+ try {
306
+ for (const child of readdirSync(scopeDir))
307
+ names.add(`${scope}/${child}`);
308
+ }
309
+ catch {
310
+ // No such scope installed here - the pattern simply matches nothing in this tree.
311
+ }
312
+ }
313
+ }
314
+ return [...names].sort();
315
+ };
316
+ /**
317
+ * Work out which foreign copies exist and which of them may be redirected.
318
+ *
319
+ * Pure discovery: it reads `package.json` files and symlink targets, never application source, and
320
+ * never mutates anything. Both the plugin and `nifra check`'s verification are built on it, so the
321
+ * enforcement and the report cannot drift apart.
322
+ */
323
+ export function planSingleCopy(options = {}) {
324
+ const root = realpathOrSelf(resolve(options.cwd ?? process.cwd()));
325
+ const declared = options.packages ?? readSingleCopyDeclaration(root) ?? [];
326
+ if (declared.length === 0)
327
+ return { root, declared, redirects: [], skipped: [] };
328
+ const names = declaredNames(root, declared);
329
+ const redirects = [];
330
+ const skipped = [];
331
+ const rootBoundary = repoBoundary(root);
332
+ for (const linked of linkedPackageDirs(root)) {
333
+ const boundary = repoBoundary(linked);
334
+ for (const name of names) {
335
+ if (!matchesSingleCopyDeclaration(declared, name))
336
+ continue;
337
+ const theirs = installedCopy(linked, name, boundary);
338
+ if (theirs === undefined)
339
+ continue;
340
+ const ours = installedCopy(root, name, rootBoundary);
341
+ if (ours === undefined || ours.root === theirs.root)
342
+ continue;
343
+ if (ours.version !== theirs.version) {
344
+ skipped.push({
345
+ package: name,
346
+ from: theirs.root,
347
+ reason: "version-skew",
348
+ detail: `${theirs.version} there, ${ours.version} here - redirecting would serve a version that copy did not ask for`,
349
+ });
350
+ continue;
351
+ }
352
+ if (redirects.some((redirect) => redirect.from === theirs.root))
353
+ continue;
354
+ redirects.push({ package: name, from: theirs.root, to: ours.root, version: ours.version });
355
+ }
356
+ }
357
+ redirects.sort((a, b) => a.from.localeCompare(b.from));
358
+ skipped.sort((a, b) => a.from.localeCompare(b.from));
359
+ return { root, declared, redirects, skipped };
360
+ }
361
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
362
+ /**
363
+ * The module a foreign file should become: the same relative file inside the winning copy.
364
+ *
365
+ * Mapping FILE to FILE rather than file to export subpath is what makes this safe on a package with a
366
+ * rich exports map. Guessing that `dist/server.js` is the `./server` subpath is guesswork that fails
367
+ * on the first package whose map is not one-to-one; the counterpart path is a fact, and the two trees
368
+ * hold the same version, so the layout matches by construction. When it does not, the file loads
369
+ * untouched.
370
+ */
371
+ const counterpart = (redirect, path) => {
372
+ const rel = relative(redirect.from, path);
373
+ if (rel === "" || rel.startsWith(`..${sep}`))
374
+ return undefined;
375
+ const target = join(redirect.to, rel);
376
+ try {
377
+ return statSync(target).isFile() ? target : undefined;
378
+ }
379
+ catch {
380
+ return undefined;
381
+ }
382
+ };
383
+ /**
384
+ * A re-export of the winning file, written so both module systems keep working.
385
+ *
386
+ * `export *` forwards the named bindings, including the ones Bun synthesizes for a CommonJS target,
387
+ * and the explicit default covers `module.exports` (react is CommonJS, and its consumers `require` it
388
+ * as often as they import it). Static imports keep the module SYNCHRONOUS, which matters more than it
389
+ * looks: an `await import()` here would make the module async, and a CommonJS `require` of an async
390
+ * module fails outright with `require() async module … is unsupported`.
391
+ */
392
+ const reexport = (target) => {
393
+ const from = JSON.stringify(target);
394
+ return (`export * from ${from};\n` +
395
+ `import * as __singleCopy from ${from};\n` +
396
+ `export default __singleCopy.default ?? __singleCopy;\n`);
397
+ };
398
+ /**
399
+ * Pin every declared package to the app's copy.
400
+ *
401
+ * Two hooks, because the two phases resolve differently. `onResolve` is the direct statement of the
402
+ * rule and it is what a BUNDLER honours - it sees every bare specifier. The runtime does not deliver
403
+ * bare specifiers to it at all, so the `onLoad` arm intercepts the foreign file itself and hands back
404
+ * a re-export of the counterpart in the winning copy. The importer gets the same function objects and
405
+ * therefore the same module state, which is the entire requirement.
406
+ */
407
+ export function singleCopyPlugin(options = {}) {
408
+ const plan = planSingleCopy(options);
409
+ const declared = plan.declared;
410
+ return {
411
+ name: "nifra-single-copy",
412
+ plan,
413
+ setup(build) {
414
+ if (declared.length > 0) {
415
+ const exact = declared.filter((entry) => !entry.endsWith("/*")).map(escapeRegExp);
416
+ const scopes = declared
417
+ .filter((entry) => entry.endsWith("/*"))
418
+ .map((entry) => `${escapeRegExp(entry.slice(0, -1))}[^/]+`);
419
+ // Subpaths pin too, for exact names and scope patterns alike: `@nifrajs/core/server` must
420
+ // resolve to the same copy as `@nifrajs/core`, or a deep import quietly splits the package.
421
+ const alternatives = [...exact, ...scopes].map((name) => `${name}(?:/.*)?`);
422
+ if (alternatives.length > 0) {
423
+ const filter = new RegExp(`^(?:${alternatives.join("|")})$`);
424
+ build.onResolve({ filter }, (args) => {
425
+ try {
426
+ return { path: Bun.resolveSync(args.path, plan.root) };
427
+ }
428
+ catch {
429
+ // Not installed for the app, so there is nothing to dedupe TO. Forcing a resolution here
430
+ // would turn a working import into a build failure.
431
+ return undefined;
432
+ }
433
+ });
434
+ }
435
+ }
436
+ if (plan.redirects.length === 0)
437
+ return;
438
+ const roots = plan.redirects.map((redirect) => escapeRegExp(redirect.from)).join("|");
439
+ // Anchored at the foreign roots so the winning copy can never match itself. It must not: this
440
+ // hook has to return contents for everything it matches, and re-emitting a CommonJS entry as an
441
+ // ES module is how `Export named 'useEffect' not found` happens.
442
+ const filter = new RegExp(`^(?:${roots})[/\\\\].*${REDIRECTABLE.source}`);
443
+ build.onLoad({ filter }, (args) => {
444
+ for (const redirect of plan.redirects) {
445
+ const target = counterpart(redirect, args.path);
446
+ if (target === undefined)
447
+ continue;
448
+ return { contents: reexport(target), loader: "js" };
449
+ }
450
+ // A runtime `onLoad` must always return an object - returning nothing fails the load rather
451
+ // than falling through to the default. Hand back the file as it was, at its own path, so its
452
+ // relative imports keep resolving exactly as they would have.
453
+ return { contents: readFileSync(args.path, "utf8"), loader: "js" };
454
+ });
455
+ },
456
+ };
457
+ }
458
+ /** Set once the runtime plugin is installed, so a checker can tell "one copy" from "deduplicated". */
459
+ export const SINGLE_COPY_ACTIVE = Symbol.for("nifra.single-copy.active");
460
+ /**
461
+ * Install the plugin into the Bun RUNTIME. Import `@nifrajs/core/single-copy/register` from a
462
+ * `bunfig.toml` preload rather than calling this from application code: a resolver installed from
463
+ * inside a module cannot affect the imports that module already resolved.
464
+ */
465
+ export function registerSingleCopy(options = {}) {
466
+ const plugin = singleCopyPlugin(options);
467
+ if (plugin.plan.declared.length > 0)
468
+ Bun.plugin(plugin);
469
+ globalThis[SINGLE_COPY_ACTIVE] = plugin.plan;
470
+ return plugin.plan;
471
+ }
472
+ //# sourceMappingURL=single-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-copy.js","sourceRoot":"","sources":["../src/single-copy.ts"],"names":[],"mappings":"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