@hyperspan/framework 2.0.0-alpha.19 → 2.0.0-alpha.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperspan/framework",
3
- "version": "2.0.0-alpha.19",
3
+ "version": "2.0.0-alpha.20",
4
4
  "description": "Hyperspan Web Framework",
5
5
  "type": "module",
6
6
  "main": "src/server.ts",
@@ -108,7 +108,7 @@
108
108
  "vitest": "^4.1.10"
109
109
  },
110
110
  "dependencies": {
111
- "@hyperspan/html": "^2.0.0-alpha.19",
111
+ "@hyperspan/html": "^2.0.0-alpha.20",
112
112
  "debug": "^4.4.3",
113
113
  "isbot": "^5.1.32",
114
114
  "zod": "^4.4.3"
@@ -6,56 +6,61 @@ export type AssetManifest = {
6
6
  clients: Record<string, string>;
7
7
  };
8
8
 
9
- let _manifest: AssetManifest = {
10
- imports: {},
11
- css: {},
12
- clients: {},
13
- };
9
+ const MANIFEST_KEY = Symbol.for('@hyperspan/asset-manifest');
10
+
11
+ function sharedManifest(): AssetManifest {
12
+ const globalStore = globalThis as typeof globalThis & {
13
+ [MANIFEST_KEY]?: AssetManifest;
14
+ };
15
+ if (!globalStore[MANIFEST_KEY]) {
16
+ globalStore[MANIFEST_KEY] = { imports: {}, css: {}, clients: {} };
17
+ }
18
+ return globalStore[MANIFEST_KEY];
19
+ }
14
20
 
15
21
  /**
16
22
  * Set the build-time asset manifest (called by Vite plugin or build step).
17
23
  */
18
24
  export function setAssetManifest(manifest: AssetManifest): void {
19
- _manifest = {
20
- imports: manifest.imports ?? {},
21
- css: manifest.css ?? {},
22
- clients: manifest.clients ?? {},
23
- };
25
+ const store = sharedManifest();
26
+ store.imports = { ...(manifest.imports ?? {}) };
27
+ store.css = { ...(manifest.css ?? {}) };
28
+ store.clients = { ...(manifest.clients ?? {}) };
24
29
  }
25
30
 
26
31
  /**
27
32
  * Get the current asset manifest.
28
33
  */
29
34
  export function getAssetManifest(): AssetManifest {
30
- return _manifest;
35
+ return sharedManifest();
31
36
  }
32
37
 
33
38
  /**
34
39
  * Resolve a module import name to its public URL.
35
40
  */
36
41
  export function resolveImport(name: string): string | undefined {
37
- return _manifest.imports[name];
42
+ return sharedManifest().imports[name];
38
43
  }
39
44
 
40
45
  /**
41
46
  * Get CSS files for a route path.
42
47
  */
43
48
  export function getRouteCss(path: string): string[] {
44
- return _manifest.css[path] ?? [];
49
+ return sharedManifest().css[path] ?? [];
45
50
  }
46
51
 
47
52
  /**
48
53
  * Build import map object for layout script tags.
49
54
  */
50
55
  export function getImportMap(): Record<string, string> {
51
- return { ..._manifest.imports };
56
+ return { ...sharedManifest().imports };
52
57
  }
53
58
 
54
59
  /**
55
60
  * Register a client module URL at runtime (dev fallback).
56
61
  */
57
62
  export function registerImport(name: string, publicPath: string): void {
58
- _manifest.imports[name] = publicPath;
63
+ sharedManifest().imports[name] = publicPath;
59
64
  }
60
65
 
61
66
  export type ClientJSBuildResult = HS.ClientJSBuildResult;
@@ -67,7 +72,7 @@ export function getClientJSFromManifest(
67
72
  moduleId: string,
68
73
  _exportNames = 'default'
69
74
  ): ClientJSBuildResult {
70
- const publicPath = _manifest.clients[moduleId];
75
+ const publicPath = sharedManifest().clients[moduleId];
71
76
  if (!publicPath) {
72
77
  throw new Error(
73
78
  `[Hyperspan] Client module "${moduleId}" not found in asset manifest. Run hyperspan build or start dev server.`