@hyperspan/framework 2.0.0-alpha.13 → 2.0.0-alpha.14
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 +2 -2
- package/src/adapter.test.ts +1 -5
- package/src/index.ts +2 -0
- package/src/types.ts +24 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperspan/framework",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
4
4
|
"description": "Hyperspan Web Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/server.ts",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"vitest": "^4.1.10"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@hyperspan/html": "^2.0.0-alpha.
|
|
107
|
+
"@hyperspan/html": "^2.0.0-alpha.14",
|
|
108
108
|
"debug": "^4.4.3",
|
|
109
109
|
"isbot": "^5.1.32",
|
|
110
110
|
"zod": "^4.4.3"
|
package/src/adapter.test.ts
CHANGED
|
@@ -4,11 +4,7 @@ import { createConfig } from './server';
|
|
|
4
4
|
|
|
5
5
|
const cloudflare: Adapter = {
|
|
6
6
|
name: 'cloudflare',
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
fetch: async () => new Response('ok'),
|
|
10
|
-
};
|
|
11
|
-
},
|
|
7
|
+
renderServerEntry: (template) => template(),
|
|
12
8
|
};
|
|
13
9
|
|
|
14
10
|
describe('createConfig deployAdapter', () => {
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -69,8 +69,12 @@ export namespace Hyperspan {
|
|
|
69
69
|
outDir: string;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
export type ServerCreateContext = {
|
|
73
|
+
env: unknown;
|
|
74
|
+
};
|
|
75
|
+
|
|
72
76
|
export type DeployEntryContext = {
|
|
73
|
-
createHyperspanServer: () => Promise<Server>;
|
|
77
|
+
createHyperspanServer: (ctx: ServerCreateContext) => Promise<Server>;
|
|
74
78
|
config: Config;
|
|
75
79
|
};
|
|
76
80
|
|
|
@@ -79,6 +83,18 @@ export namespace Hyperspan {
|
|
|
79
83
|
fetch?(request: Request, env?: unknown, ctx?: unknown): Response | Promise<Response>;
|
|
80
84
|
};
|
|
81
85
|
|
|
86
|
+
/** Optional snippets interpolated into generated `dist/server.ts`. Null/omitted slots emit nothing. */
|
|
87
|
+
export type ServerEntrySlots = {
|
|
88
|
+
beforeFileContent?: string | null;
|
|
89
|
+
beforeCreateServer?: string | null;
|
|
90
|
+
afterCreateServer?: string | null;
|
|
91
|
+
beforeRoutes?: string | null;
|
|
92
|
+
afterRoutes?: string | null;
|
|
93
|
+
afterFileContent?: string | null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type ServerEntryTemplate = (slots?: ServerEntrySlots) => string;
|
|
97
|
+
|
|
82
98
|
export type Adapter = {
|
|
83
99
|
/** Diagnostic name, e.g. `node`, `cloudflare`. */
|
|
84
100
|
name: string;
|
|
@@ -88,18 +104,17 @@ export namespace Hyperspan {
|
|
|
88
104
|
*/
|
|
89
105
|
devModule?: string;
|
|
90
106
|
resolveDevEnv?(root: string): Promise<unknown>;
|
|
91
|
-
/**
|
|
92
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Render generated `dist/server.ts` from the shared bootstrap template.
|
|
109
|
+
* Fill slots (especially `afterFileContent`) for the platform entry.
|
|
110
|
+
*/
|
|
111
|
+
renderServerEntry(template: ServerEntryTemplate): string | Promise<string>;
|
|
93
112
|
afterBuild?(ctx: AdapterAfterBuildContext): void | Promise<void>;
|
|
94
113
|
};
|
|
95
114
|
|
|
96
115
|
/** Runtime adapter object (`nodeAdapter()`, `cloudflareAdapter()`, …). */
|
|
97
116
|
export type DeployAdapter = Adapter;
|
|
98
117
|
|
|
99
|
-
export type ServerCreateContext = {
|
|
100
|
-
env: unknown;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
118
|
export type Config = {
|
|
104
119
|
appDir: string;
|
|
105
120
|
publicDir: string;
|
|
@@ -443,6 +458,8 @@ export type Adapter = Hyperspan.Adapter;
|
|
|
443
458
|
export type AdapterAfterBuildContext = Hyperspan.AdapterAfterBuildContext;
|
|
444
459
|
export type DeployEntry = Hyperspan.DeployEntry;
|
|
445
460
|
export type DeployEntryContext = Hyperspan.DeployEntryContext;
|
|
461
|
+
export type ServerEntrySlots = Hyperspan.ServerEntrySlots;
|
|
462
|
+
export type ServerEntryTemplate = Hyperspan.ServerEntryTemplate;
|
|
446
463
|
|
|
447
464
|
declare global {
|
|
448
465
|
interface DocumentEventMap {
|