@c9up/aurora 0.1.37 → 0.1.38

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.
@@ -20,10 +20,12 @@ import { isAbsolute, resolve as resolvePath } from "node:path";
20
20
  import { fileURLToPath } from "node:url";
21
21
  import { AuroraManager } from "./AuroraManager.js";
22
22
  import { auroraRoute } from "./route.js";
23
- import { setAurora } from "./services/main.js";
23
+ import { clearAurora, getAurora, setAurora } from "./services/main.js";
24
24
  import { renderToString } from "./ssr.js";
25
25
  export default class AuroraProvider {
26
26
  app;
27
+ /** What this provider bound, so shutdown only clears its own. */
28
+ #owned;
27
29
  constructor(app) {
28
30
  this.app = app;
29
31
  }
@@ -46,6 +48,7 @@ export default class AuroraProvider {
46
48
  // Force-resolve so `setAurora` runs even if the app never
47
49
  // touches the singleton from a preload.
48
50
  const manager = await this.app.container.resolve(AuroraManager);
51
+ this.#owned = manager;
49
52
  setAurora(manager);
50
53
  }
51
54
  async start() {
@@ -77,7 +80,15 @@ export default class AuroraProvider {
77
80
  }
78
81
  }
79
82
  async ready() { }
80
- async shutdown() { }
83
+ async shutdown() {
84
+ // Release the module-level singleton, while it is still ours. A stopped
85
+ // application left a dead Aurora manager reachable through `services/main`, and
86
+ // with two applications in one process the survivor's binding must not
87
+ // be the one cleared.
88
+ if (this.#owned !== undefined && getAurora() === this.#owned)
89
+ clearAurora();
90
+ this.#owned = undefined;
91
+ }
81
92
  /**
82
93
  * Resolve the user-supplied config:
83
94
  * - relative `pages.root` (e.g. `./resources/pages`) is joined to
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import "./augmentations.js";
2
1
  export type { CookieCodec, CookieOptions, PersistedSignalOptions, ShareData, StorageArea, WebStorageOptions, WindowSize, } from "./browser.js";
3
2
  export { back, booleanCookie, clipboard, cookie, cookieSignal, cookieState, forward, getCookieStore, hash, jsonCookie, mediaQuery, navigate, online, persistedSignal, prefersDark, queryParam, redirect, reload, replace, session, setCookieStore, share, storage, visibility, WebStorage, windowSize, } from "./browser.js";
4
3
  export { type ClassValue, clsx, cn, twMerge } from "./cn.js";
package/dist/index.js CHANGED
@@ -4,7 +4,15 @@
4
4
  // node:fs / node:path / node:url live in `@c9up/aurora/server`. Keeping them off
5
5
  // this barrel is what lets a browser bundle import the client primitives without
6
6
  // the bundler dragging Node built-ins through the import graph.
7
- import "./augmentations.js";
7
+ //
8
+ // `./augmentations.js` is NOT loaded here either, and for a related reason: it
9
+ // augments ream's HttpContext and ContainerBindings, so it names `@c9up/ream`
10
+ // and drags ream's whole source into any program that imports this barrel. A
11
+ // component library that only wants `component`/`html` was compiling ream's
12
+ // decorated console commands under its own tsconfig, which does not enable
13
+ // decorators — a build failure, in a package that never mentions ream. The
14
+ // augmentations load from `@c9up/aurora/server` and `@c9up/aurora/provider`,
15
+ // which is where every type they describe is reachable from anyway.
8
16
  export { back, booleanCookie, clipboard, cookie, cookieSignal, cookieState, forward, getCookieStore, hash, jsonCookie, mediaQuery, navigate, online, persistedSignal, prefersDark, queryParam, redirect, reload, replace, session, setCookieStore, share, storage, visibility, WebStorage, windowSize, } from "./browser.js";
9
17
  export { clsx, cn, twMerge } from "./cn.js";
10
18
  export { command } from "./command.js";
package/dist/server.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./augmentations.js";
1
2
  export { AuroraManager, type AuroraManagerConfig } from "./AuroraManager.js";
2
3
  export { type AuroraRequestRenderer, auroraContext, } from "./middleware.js";
3
4
  export { type PageFactory, Pages, type PagesConfig } from "./Pages.js";
package/dist/server.js CHANGED
@@ -4,6 +4,12 @@
4
4
  // importing client primitives (component/html/hydrate/render) never pulls the
5
5
  // Node built-ins through the import graph. Server code imports from
6
6
  // `@c9up/aurora/server`; the client `.` entry stays node-free.
7
+ //
8
+ // The ream augmentations (`ctx.aurora`, the `aurora` container binding) load
9
+ // here rather than from the client barrel: everything they describe is
10
+ // server-side, and naming `@c9up/ream` from the browser entry pulled ream's
11
+ // source into every consumer's program — including ones that never use it.
12
+ import "./augmentations.js";
7
13
  export { AuroraManager } from "./AuroraManager.js";
8
14
  export { auroraContext, } from "./middleware.js";
9
15
  export { Pages } from "./Pages.js";
@@ -14,5 +14,14 @@ import type { AuroraManager } from "../AuroraManager.js";
14
14
  export declare function setAurora(value: AuroraManager): void;
15
15
  /** @internal Read the singleton (or `undefined` pre-boot). */
16
16
  export declare function getAurora(): AuroraManager | undefined;
17
+ /**
18
+ * @internal Release the singleton, so a shut-down application does not leave a
19
+ * dead Aurora manager reachable through `services/main`.
20
+ *
21
+ * The caller checks ownership first (`getAurora() === mine`): two applications
22
+ * share this module in one process, and the one shutting down must not clear
23
+ * what the other has since bound.
24
+ */
25
+ export declare function clearAurora(): void;
17
26
  declare const aurora: AuroraManager;
18
27
  export default aurora;
@@ -18,6 +18,17 @@ export function setAurora(value) {
18
18
  export function getAurora() {
19
19
  return instance;
20
20
  }
21
+ /**
22
+ * @internal Release the singleton, so a shut-down application does not leave a
23
+ * dead Aurora manager reachable through `services/main`.
24
+ *
25
+ * The caller checks ownership first (`getAurora() === mine`): two applications
26
+ * share this module in one process, and the one shutting down must not clear
27
+ * what the other has since bound.
28
+ */
29
+ export function clearAurora() {
30
+ instance = undefined;
31
+ }
21
32
  const aurora = new Proxy({}, {
22
33
  get(_target, prop) {
23
34
  // A module loader inspects what it imports before anyone uses it: it reads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/aurora",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "Aurora — reactive UI runtime for the Ream framework. Tagged-template DOM, signal-based state, isomorphic SSR + hydration, zero build step.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,7 +26,7 @@ import type {
26
26
  AssetsRequest,
27
27
  AssetsResponse,
28
28
  } from "./server/serveAssets.js";
29
- import { setAurora } from "./services/main.js";
29
+ import { clearAurora, getAurora, setAurora } from "./services/main.js";
30
30
  import { renderToString } from "./ssr.js";
31
31
 
32
32
  interface AuroraContainer {
@@ -50,6 +50,9 @@ interface ReamRouter {
50
50
  }
51
51
 
52
52
  export default class AuroraProvider {
53
+ /** What this provider bound, so shutdown only clears its own. */
54
+ #owned: AuroraManager | undefined;
55
+
53
56
  constructor(protected app: AuroraAppContext) {}
54
57
 
55
58
  register(): void {
@@ -75,6 +78,7 @@ export default class AuroraProvider {
75
78
  // touches the singleton from a preload.
76
79
  const manager =
77
80
  await this.app.container.resolve<AuroraManager>(AuroraManager);
81
+ this.#owned = manager;
78
82
  setAurora(manager);
79
83
  }
80
84
 
@@ -114,7 +118,14 @@ export default class AuroraProvider {
114
118
  }
115
119
 
116
120
  async ready(): Promise<void> {}
117
- async shutdown(): Promise<void> {}
121
+ async shutdown(): Promise<void> {
122
+ // Release the module-level singleton, while it is still ours. A stopped
123
+ // application left a dead Aurora manager reachable through `services/main`, and
124
+ // with two applications in one process the survivor's binding must not
125
+ // be the one cleared.
126
+ if (this.#owned !== undefined && getAurora() === this.#owned) clearAurora();
127
+ this.#owned = undefined;
128
+ }
118
129
 
119
130
  /**
120
131
  * Resolve the user-supplied config:
package/src/index.ts CHANGED
@@ -4,7 +4,15 @@
4
4
  // node:fs / node:path / node:url live in `@c9up/aurora/server`. Keeping them off
5
5
  // this barrel is what lets a browser bundle import the client primitives without
6
6
  // the bundler dragging Node built-ins through the import graph.
7
- import "./augmentations.js";
7
+ //
8
+ // `./augmentations.js` is NOT loaded here either, and for a related reason: it
9
+ // augments ream's HttpContext and ContainerBindings, so it names `@c9up/ream`
10
+ // and drags ream's whole source into any program that imports this barrel. A
11
+ // component library that only wants `component`/`html` was compiling ream's
12
+ // decorated console commands under its own tsconfig, which does not enable
13
+ // decorators — a build failure, in a package that never mentions ream. The
14
+ // augmentations load from `@c9up/aurora/server` and `@c9up/aurora/provider`,
15
+ // which is where every type they describe is reachable from anyway.
8
16
 
9
17
  export type {
10
18
  CookieCodec,
package/src/server.ts CHANGED
@@ -4,6 +4,12 @@
4
4
  // importing client primitives (component/html/hydrate/render) never pulls the
5
5
  // Node built-ins through the import graph. Server code imports from
6
6
  // `@c9up/aurora/server`; the client `.` entry stays node-free.
7
+ //
8
+ // The ream augmentations (`ctx.aurora`, the `aurora` container binding) load
9
+ // here rather than from the client barrel: everything they describe is
10
+ // server-side, and naming `@c9up/ream` from the browser entry pulled ream's
11
+ // source into every consumer's program — including ones that never use it.
12
+ import "./augmentations.js";
7
13
 
8
14
  export { AuroraManager, type AuroraManagerConfig } from "./AuroraManager.js";
9
15
  export {
@@ -24,6 +24,18 @@ export function getAurora(): AuroraManager | undefined {
24
24
  return instance;
25
25
  }
26
26
 
27
+ /**
28
+ * @internal Release the singleton, so a shut-down application does not leave a
29
+ * dead Aurora manager reachable through `services/main`.
30
+ *
31
+ * The caller checks ownership first (`getAurora() === mine`): two applications
32
+ * share this module in one process, and the one shutting down must not clear
33
+ * what the other has since bound.
34
+ */
35
+ export function clearAurora(): void {
36
+ instance = undefined;
37
+ }
38
+
27
39
  const aurora: AuroraManager = new Proxy({} as AuroraManager, {
28
40
  get(_target, prop) {
29
41
  // A module loader inspects what it imports before anyone uses it: it reads