@vesk/adapter 0.2.15 → 0.2.16
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/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +51 -0
- package/dist/events.d.ts +9 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +109 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +2 -1
- package/dist/platform-deploy.d.ts.map +1 -1
- package/dist/platform-deploy.js +1 -0
- package/dist/platform-handler.d.ts +2 -0
- package/dist/platform-handler.d.ts.map +1 -1
- package/dist/platform-handler.js +14 -2
- package/dist/prod-server.d.ts.map +1 -1
- package/dist/prod-server.js +60 -12
- package/dist/runtime-bundle.d.ts.map +1 -1
- package/dist/runtime-bundle.js +10 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/dev-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAA6C,MAAM,WAAW,CAAC;AAOjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAI7C,OAAO,KAAK,EAAa,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AAgBjG;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB;+EAC2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAuCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AAkBD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mHAAmH;IACnH,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B;;8BAE0B;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,WAAW,CAAC;IAChC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG;IACvE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAChH,CAUA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAa3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AA8CD,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAA6C,MAAM,WAAW,CAAC;AAOjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAI7C,OAAO,KAAK,EAAa,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AAgBjG;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB;+EAC2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAuCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AAkBD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mHAAmH;IACnH,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B;;8BAE0B;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,WAAW,CAAC;IAChC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG;IACvE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAChH,CAUA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAa3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AA8CD,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8hBvG"}
|
package/dist/dev-server.js
CHANGED
|
@@ -355,6 +355,20 @@ export async function startDevServer(appDir, options) {
|
|
|
355
355
|
let ssrVersion = Date.now();
|
|
356
356
|
let routeTree = [];
|
|
357
357
|
let runtimeBundle = '';
|
|
358
|
+
let eventsMod = null;
|
|
359
|
+
async function reloadEventsMod() {
|
|
360
|
+
const eventsPath = resolve(devDir, 'server', 'events.js');
|
|
361
|
+
if (existsSync(eventsPath)) {
|
|
362
|
+
try {
|
|
363
|
+
eventsMod = await import(`${eventsPath}?t=${Date.now()}`);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
// ignore — events file present but failed to load
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
eventsMod = null;
|
|
371
|
+
}
|
|
358
372
|
async function doBuild() {
|
|
359
373
|
const start = Date.now();
|
|
360
374
|
try {
|
|
@@ -368,6 +382,7 @@ export async function startDevServer(appDir, options) {
|
|
|
368
382
|
const monorepoRoot = resolve(__dirname, '..', '..', '..');
|
|
369
383
|
const runtimeDir = resolve(monorepoRoot, 'packages', 'runtime', 'dist');
|
|
370
384
|
runtimeBundle = buildRuntimeCode(runtimeDir);
|
|
385
|
+
await reloadEventsMod();
|
|
371
386
|
lastBuild = Date.now();
|
|
372
387
|
console.error(`vesk dev: rebuilt in ${Date.now() - start}ms`);
|
|
373
388
|
}
|
|
@@ -505,6 +520,24 @@ export async function startDevServer(appDir, options) {
|
|
|
505
520
|
return;
|
|
506
521
|
}
|
|
507
522
|
}
|
|
523
|
+
if (eventsMod) {
|
|
524
|
+
const serverStore = globalThis.__vesk_server_ctx || {};
|
|
525
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
526
|
+
const evtCtx = {
|
|
527
|
+
request: webRequest,
|
|
528
|
+
params: {},
|
|
529
|
+
url,
|
|
530
|
+
locals: Object.assign({}, serverStore),
|
|
531
|
+
cookies: {},
|
|
532
|
+
};
|
|
533
|
+
globalThis.__vesk_request = evtCtx;
|
|
534
|
+
try {
|
|
535
|
+
await eventsMod.executeRequest?.(evtCtx);
|
|
536
|
+
}
|
|
537
|
+
catch (e) {
|
|
538
|
+
console.error('vesk request: onRequest error:', e instanceof Error ? e.message : e);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
508
541
|
if (config && url.pathname.startsWith('/_vesk/action/')) {
|
|
509
542
|
const actionId = url.pathname.replace('/_vesk/action/', '');
|
|
510
543
|
const actionEntry = config.actions && config.actions.find(a => a.id === actionId);
|
|
@@ -676,6 +709,24 @@ export async function startDevServer(appDir, options) {
|
|
|
676
709
|
catch (e) {
|
|
677
710
|
console.error('vesk dev: file watching unavailable');
|
|
678
711
|
}
|
|
712
|
+
const bootEventsMod = eventsMod;
|
|
713
|
+
try {
|
|
714
|
+
await bootEventsMod?.executeStart?.({ server, port, host });
|
|
715
|
+
}
|
|
716
|
+
catch (e) {
|
|
717
|
+
console.error('vesk dev: onStart error:', e instanceof Error ? e.message : e);
|
|
718
|
+
}
|
|
719
|
+
server.on('close', () => {
|
|
720
|
+
void (async () => {
|
|
721
|
+
const stopEventsMod = eventsMod;
|
|
722
|
+
try {
|
|
723
|
+
await stopEventsMod?.executeStop?.({ server, port, host });
|
|
724
|
+
}
|
|
725
|
+
catch (e) {
|
|
726
|
+
console.error('vesk dev: onStop error:', e instanceof Error ? e.message : e);
|
|
727
|
+
}
|
|
728
|
+
})();
|
|
729
|
+
});
|
|
679
730
|
await new Promise(resolve => {
|
|
680
731
|
server.listen(port, host, () => {
|
|
681
732
|
console.error(`vesk dev server at http://localhost:${port} (listening on ${host})`);
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile the app's `_events.ts` (if present) into a self-contained
|
|
3
|
+
* `server/events.js` next to the server runtime. Returns true when an events
|
|
4
|
+
* file existed and was compiled. Relative imports inside `_events.ts` are
|
|
5
|
+
* bundled by esbuild; node builtins stay external so node (prod-server) and
|
|
6
|
+
* edge (platform handler) can both resolve them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function compileEvents(appDir: string, outDir: string): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAqEA;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiCpF"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { writeFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import * as esbuild from './esbuild-fallback.js';
|
|
4
|
+
import { collectEventsFile } from '@vesk/compiler/src/events';
|
|
5
|
+
let buildId = 0;
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper module bundled into `server/events.js`. It lifts the user's
|
|
8
|
+
* `_events.ts` exports into `executeStart` / `executeRequest` / `executeStop`
|
|
9
|
+
* entry points with a context that routes `set`/`get` into the process-wide
|
|
10
|
+
* server context (`globalThis.__vesk_server_ctx`).
|
|
11
|
+
*
|
|
12
|
+
* The `__vesk_events_started` guard is global (not module-local) so lazy edge
|
|
13
|
+
* isolates and the Node prod server share one lifetime; `onStop` clears it so
|
|
14
|
+
* dev HMR reloads can boot a fresh module.
|
|
15
|
+
*/
|
|
16
|
+
function buildEntry(sourcePath) {
|
|
17
|
+
return [
|
|
18
|
+
`import * as __events from ${JSON.stringify(sourcePath)};`,
|
|
19
|
+
'',
|
|
20
|
+
'const __store = () => (globalThis.__vesk_server_ctx ||= {});',
|
|
21
|
+
'',
|
|
22
|
+
'const __handlers = {};',
|
|
23
|
+
"for (const __name of ['onStart', 'onRequest', 'onStop']) {",
|
|
24
|
+
' const __fn = __events[__name];',
|
|
25
|
+
" if (typeof __fn === 'function') __handlers[__name] = __fn;",
|
|
26
|
+
'}',
|
|
27
|
+
'',
|
|
28
|
+
'function __makeCtx(base) {',
|
|
29
|
+
' const store = __store();',
|
|
30
|
+
' const start = base && typeof base === \'object\' ? base : {};',
|
|
31
|
+
' return Object.assign({}, start, {',
|
|
32
|
+
' server: start.server !== undefined ? start.server : null,',
|
|
33
|
+
' port: start.port !== undefined ? start.port : 0,',
|
|
34
|
+
' host: start.host,',
|
|
35
|
+
' serverLocals: store,',
|
|
36
|
+
' set(key, value) { store[key] = value; return value; },',
|
|
37
|
+
' get(key) { return store[key]; },',
|
|
38
|
+
' });',
|
|
39
|
+
'}',
|
|
40
|
+
'',
|
|
41
|
+
'export async function executeStart(base) {',
|
|
42
|
+
' if (globalThis.__vesk_events_started) return;',
|
|
43
|
+
' globalThis.__vesk_events_started = true;',
|
|
44
|
+
' if (typeof __handlers.onStart === \'function\') await __handlers.onStart(__makeCtx(base));',
|
|
45
|
+
'}',
|
|
46
|
+
'',
|
|
47
|
+
'export async function executeRequest(base) {',
|
|
48
|
+
' if (typeof __handlers.onRequest !== \'function\') return;',
|
|
49
|
+
' await __handlers.onRequest(__makeCtx(base));',
|
|
50
|
+
'}',
|
|
51
|
+
'',
|
|
52
|
+
'export async function executeStop(base) {',
|
|
53
|
+
' if (typeof __handlers.onStop !== \'function\') return;',
|
|
54
|
+
' try {',
|
|
55
|
+
' await __handlers.onStop(__makeCtx(base));',
|
|
56
|
+
' } finally {',
|
|
57
|
+
' globalThis.__vesk_events_started = false;',
|
|
58
|
+
' }',
|
|
59
|
+
'}',
|
|
60
|
+
'',
|
|
61
|
+
'export const onStart = __handlers.onStart;',
|
|
62
|
+
'export const onRequest = __handlers.onRequest;',
|
|
63
|
+
'export const onStop = __handlers.onStop;',
|
|
64
|
+
'',
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Compile the app's `_events.ts` (if present) into a self-contained
|
|
69
|
+
* `server/events.js` next to the server runtime. Returns true when an events
|
|
70
|
+
* file existed and was compiled. Relative imports inside `_events.ts` are
|
|
71
|
+
* bundled by esbuild; node builtins stay external so node (prod-server) and
|
|
72
|
+
* edge (platform handler) can both resolve them.
|
|
73
|
+
*/
|
|
74
|
+
export async function compileEvents(appDir, outDir) {
|
|
75
|
+
const sourcePath = collectEventsFile(appDir);
|
|
76
|
+
if (!sourcePath)
|
|
77
|
+
return false;
|
|
78
|
+
const serverDir = resolve(outDir, 'server');
|
|
79
|
+
mkdirSync(serverDir, { recursive: true });
|
|
80
|
+
const entryFile = resolve(serverDir, `.events-entry-${buildId++}.mjs`);
|
|
81
|
+
writeFileSync(entryFile, buildEntry(sourcePath), 'utf-8');
|
|
82
|
+
try {
|
|
83
|
+
const result = await esbuild.build({
|
|
84
|
+
entryPoints: [entryFile],
|
|
85
|
+
bundle: true,
|
|
86
|
+
platform: 'neutral',
|
|
87
|
+
format: 'esm',
|
|
88
|
+
minify: true,
|
|
89
|
+
outfile: resolve(serverDir, 'events.js'),
|
|
90
|
+
external: ['fs', 'node:fs', 'path', 'node:path', 'module', 'node:module', 'node:async_hooks'],
|
|
91
|
+
target: ['es2022'],
|
|
92
|
+
treeShaking: true,
|
|
93
|
+
});
|
|
94
|
+
if (result.errors.length > 0) {
|
|
95
|
+
throw new Error(`esbuild errors: ${result.errors.map((e) => e.text).join(', ')}`);
|
|
96
|
+
}
|
|
97
|
+
if (result.warnings.length > 0) {
|
|
98
|
+
for (const w of result.warnings)
|
|
99
|
+
console.error('vesk build warning:', w.text);
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
try {
|
|
105
|
+
unlinkSync(entryFile);
|
|
106
|
+
}
|
|
107
|
+
catch { /* ignore */ }
|
|
108
|
+
}
|
|
109
|
+
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACe,YAAY,EAAE,WAAW,EAC7B,UAAU,EAChC,MAAM,yBAAyB,CAAC;AAiBjC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,GAC9C,UAAU,EAAE,CAQd;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EAAE,EACrB,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GACxC,UAAU,EAAE,CAGd;AA+BD,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAyUpG;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { resolveUserCssPath, stripTailwindDirectives, isTailwindPlugin, resolveC
|
|
|
7
7
|
import { collectActionIds } from '@vesk/compiler/src/actions';
|
|
8
8
|
import { generateApiFunction } from '@vesk/adapter/src/api-function';
|
|
9
9
|
import { compileMiddleware, compileMiddlewareCode } from '@vesk/adapter/src/middleware';
|
|
10
|
+
import { compileEvents } from '@vesk/adapter/src/events';
|
|
10
11
|
import { generateClientBundle } from '@vesk/adapter/src/client-bundle';
|
|
11
12
|
import { generateManifest } from '@vesk/adapter/src/manifest';
|
|
12
13
|
import { copyStaticAssets } from '@vesk/adapter/src/static';
|
|
@@ -280,6 +281,9 @@ export async function build(appDir, options) {
|
|
|
280
281
|
console.error(`vesk build: mw → server/middleware.js (${mwChain.length} middlewares)`);
|
|
281
282
|
}
|
|
282
283
|
}
|
|
284
|
+
const hasEvents = await compileEvents(appDir, outDir);
|
|
285
|
+
if (hasEvents)
|
|
286
|
+
console.error('vesk build: evt → server/events.js (onStart/onRequest/onStop)');
|
|
283
287
|
console.error('vesk build: bundling client runtime...');
|
|
284
288
|
const bundleOpts = {};
|
|
285
289
|
if (options?.codeSplit)
|
|
@@ -345,7 +349,7 @@ export async function build(appDir, options) {
|
|
|
345
349
|
console.error(`vesk build: seo → static/public/robots.txt (${robots.length} bytes)`);
|
|
346
350
|
}
|
|
347
351
|
}
|
|
348
|
-
const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra);
|
|
352
|
+
const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
|
|
349
353
|
writeFileSync(resolve(outDir, 'config.json'), JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
350
354
|
console.error('vesk build: config → config.json');
|
|
351
355
|
{
|
|
@@ -362,6 +366,7 @@ export async function build(appDir, options) {
|
|
|
362
366
|
prerenderedPaths: prerenderedRoutes.map(r => r.path),
|
|
363
367
|
prerenderedRoutes,
|
|
364
368
|
hasMiddleware: middlewareEnabled,
|
|
369
|
+
hasEvents,
|
|
365
370
|
});
|
|
366
371
|
if (outRoot) {
|
|
367
372
|
console.error(`vesk build: ${platform} → ${relative(projectRoot, outRoot)}`);
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RouteNode, ApiRouteNode, Manifest, SsgRouteResult } from '@vesk/adapter/src/types';
|
|
2
|
-
export declare function generateManifest(routes: RouteNode[], ssrRoutes: RouteNode[], apiRoutes: ApiRouteNode[], staticRoutes: SsgRouteResult[], middlewareEnabled: boolean, actionMap?: Record<string, string>, headExtra?: string): Manifest;
|
|
2
|
+
export declare function generateManifest(routes: RouteNode[], ssrRoutes: RouteNode[], apiRoutes: ApiRouteNode[], staticRoutes: SsgRouteResult[], middlewareEnabled: boolean, actionMap?: Record<string, string>, headExtra?: string, eventsEnabled?: boolean): Manifest;
|
|
3
3
|
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAqE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEpK,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,SAAS,EAAE,SAAS,EAAE,EACtB,SAAS,EAAE,YAAY,EAAE,EACzB,YAAY,EAAE,cAAc,EAAE,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,SAAS,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAqE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEpK,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,SAAS,EAAE,SAAS,EAAE,EACtB,SAAS,EAAE,YAAY,EAAE,EACzB,YAAY,EAAE,cAAc,EAAE,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,SAAS,CAAC,EAAE,MAAM,EAClB,aAAa,UAAQ,GACpB,QAAQ,CAmDV"}
|
package/dist/manifest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middlewareEnabled, actionMap, headExtra) {
|
|
1
|
+
export function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middlewareEnabled, actionMap, headExtra, eventsEnabled = false) {
|
|
2
2
|
const routeEntries = [];
|
|
3
3
|
for (const r of ssrRoutes) {
|
|
4
4
|
const urlParts = r.fullPath.split('/').filter(Boolean);
|
|
@@ -44,5 +44,6 @@ export function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, mid
|
|
|
44
44
|
},
|
|
45
45
|
...(actionEntries.length > 0 ? { actions: actionEntries } : {}),
|
|
46
46
|
...(headExtra ? { headExtra } : {}),
|
|
47
|
+
...(eventsEnabled ? { events: true } : {}),
|
|
47
48
|
};
|
|
48
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-deploy.d.ts","sourceRoot":"","sources":["../src/platform-deploy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAErI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,iBAAiB,EAAE,cAAc,EAAE,CAAC;CACrC;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"platform-deploy.d.ts","sourceRoot":"","sources":["../src/platform-deploy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAErI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,iBAAiB,EAAE,cAAc,EAAE,CAAC;CACrC;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0EvG"}
|
package/dist/platform-deploy.js
CHANGED
|
@@ -21,6 +21,7 @@ export async function emitPlatformOutput(platform, ctx) {
|
|
|
21
21
|
apiRoutes: ctx.apiRoutes,
|
|
22
22
|
prerenderedPaths,
|
|
23
23
|
hasMiddleware: ctx.hasMiddleware,
|
|
24
|
+
hasEvents: ctx.hasEvents,
|
|
24
25
|
});
|
|
25
26
|
const shell = shellFor(platform);
|
|
26
27
|
const projectRoot = resolve(ctx.outDir, '..');
|
|
@@ -4,6 +4,7 @@ export interface PlatformHandlerInput {
|
|
|
4
4
|
apiRoutes: ApiRouteNode[];
|
|
5
5
|
prerenderedPaths: string[];
|
|
6
6
|
hasMiddleware: boolean;
|
|
7
|
+
hasEvents?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare function routeName(segments: string[]): string;
|
|
9
10
|
export declare function apiRouteName(fullPath: string): string;
|
|
@@ -28,5 +29,6 @@ export interface PlatformBuildContext {
|
|
|
28
29
|
apiRoutes: ApiRouteNode[];
|
|
29
30
|
prerenderedPaths: string[];
|
|
30
31
|
hasMiddleware: boolean;
|
|
32
|
+
hasEvents?: boolean;
|
|
31
33
|
}
|
|
32
34
|
//# sourceMappingURL=platform-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAQD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CA8IjF;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFzF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/platform-handler.js
CHANGED
|
@@ -31,6 +31,7 @@ function findCompilerSrc() {
|
|
|
31
31
|
*/
|
|
32
32
|
export function generatePlatformHandlerSource(input) {
|
|
33
33
|
const { ssrRoutes, apiRoutes, prerenderedPaths, hasMiddleware } = input;
|
|
34
|
+
const hasEvents = !!input.hasEvents;
|
|
34
35
|
let imports = '';
|
|
35
36
|
const routeEntries = [];
|
|
36
37
|
for (const r of ssrRoutes) {
|
|
@@ -51,10 +52,15 @@ export function generatePlatformHandlerSource(input) {
|
|
|
51
52
|
}
|
|
52
53
|
const mwImport = hasMiddleware ? "import { execute as __executeMw } from './server/middleware.js';" : '';
|
|
53
54
|
const hasMwLiteral = hasMiddleware ? 'true' : 'false';
|
|
55
|
+
const eventsImport = hasEvents ? "import { executeStart as __eventsStart, executeRequest as __eventsRequest } from './server/events.js';" : '';
|
|
54
56
|
const prerenderedList = prerenderedPaths.length > 0
|
|
55
57
|
? `const __prerendered = new Set(${JSON.stringify(prerenderedPaths)});\n`
|
|
56
58
|
: 'const __prerendered = new Set();\n';
|
|
57
59
|
const isrCache = 'const __isrCache = new Map();';
|
|
60
|
+
const serverStoreLine = hasEvents ? 'const __serverStore = globalThis.__vesk_server_ctx || {};' : '';
|
|
61
|
+
const eventsStartLine = hasEvents ? ' await __eventsStart({ server: null });' : '';
|
|
62
|
+
const eventsRequestLine = hasEvents ? ' await __eventsRequest(mwCtx);' : '';
|
|
63
|
+
const localsSeed = hasEvents ? 'Object.assign({}, __serverStore)' : '{}';
|
|
58
64
|
const compilerSrc = findCompilerSrc();
|
|
59
65
|
const parseCookiesImport = hasMiddleware
|
|
60
66
|
? `import { parseCookies } from ${JSON.stringify(resolve(compilerSrc, 'server-cookies.js'))};`
|
|
@@ -63,6 +69,7 @@ export function generatePlatformHandlerSource(input) {
|
|
|
63
69
|
${imports}
|
|
64
70
|
${parseCookiesImport}
|
|
65
71
|
${mwImport}
|
|
72
|
+
${eventsImport}
|
|
66
73
|
${prerenderedList}
|
|
67
74
|
${isrCache}
|
|
68
75
|
const __routes = [${routeEntries.join(',\n')}];
|
|
@@ -91,23 +98,28 @@ export async function handleRequest(request) {
|
|
|
91
98
|
const url = new URL(request.url);
|
|
92
99
|
const pathname = url.pathname;
|
|
93
100
|
const isDataRequest = request.headers.get('x-vesk-data') === '1';
|
|
101
|
+
${serverStoreLine}
|
|
94
102
|
|
|
95
103
|
if (__prerendered.has(pathname) && !isDataRequest) {
|
|
96
104
|
return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
|
|
97
105
|
}
|
|
98
106
|
|
|
99
|
-
|
|
107
|
+
${eventsStartLine}
|
|
108
|
+
let mwCtx = { params: {}, url, locals: ${localsSeed}, cookies: {}, request, resolveUrl(u) { return new URL(u, request.url).href; }, set() {}, get() { return undefined; } };
|
|
100
109
|
if (${hasMwLiteral}) {
|
|
101
110
|
mwCtx = {
|
|
102
111
|
request,
|
|
103
112
|
params: {},
|
|
104
113
|
url,
|
|
105
|
-
locals: {},
|
|
114
|
+
locals: ${localsSeed},
|
|
106
115
|
cookies: typeof parseCookies !== 'undefined' ? parseCookies(request.headers.get('cookie') || '') : {},
|
|
107
116
|
resolveUrl(u) { return new URL(u, request.url).href; },
|
|
108
117
|
set(key, value) { this.locals[key] = value; },
|
|
109
118
|
get(key) { return this.locals[key]; },
|
|
110
119
|
};
|
|
120
|
+
}
|
|
121
|
+
${eventsRequestLine}
|
|
122
|
+
if (${hasMwLiteral}) {
|
|
111
123
|
const mwResult = await __executeMw(mwCtx);
|
|
112
124
|
if (mwResult.response) return mwResult.response;
|
|
113
125
|
if (mwResult.rewriteUrl) url.pathname = mwResult.rewriteUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2D,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AA+CjG,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AA+FD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2D,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AA+CjG,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AA+FD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmcxI"}
|
package/dist/prod-server.js
CHANGED
|
@@ -192,6 +192,16 @@ export async function startProdServer(outDir, options) {
|
|
|
192
192
|
// ignore
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
+
let eventsMod = null;
|
|
196
|
+
const eventsPath = resolve(outDir, 'server', 'events.js');
|
|
197
|
+
if (existsSync(eventsPath)) {
|
|
198
|
+
try {
|
|
199
|
+
eventsMod = await import(`${eventsPath}?t=${Date.now()}`);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// ignore
|
|
203
|
+
}
|
|
204
|
+
}
|
|
195
205
|
const functionCache = new Map();
|
|
196
206
|
async function loadFunction(funcPath) {
|
|
197
207
|
if (functionCache.has(funcPath))
|
|
@@ -325,38 +335,49 @@ export async function startProdServer(outDir, options) {
|
|
|
325
335
|
}
|
|
326
336
|
}
|
|
327
337
|
let mwCtx;
|
|
338
|
+
const serverStore = globalThis.__vesk_server_ctx;
|
|
328
339
|
if (middlewareMod) {
|
|
329
340
|
mwCtx = {
|
|
330
341
|
request: new Request(url.href, { headers: req.headers, method: req.method || 'GET' }),
|
|
331
342
|
params: {},
|
|
332
343
|
url,
|
|
333
|
-
locals: {},
|
|
344
|
+
locals: Object.assign({}, serverStore || {}),
|
|
334
345
|
cookies: {},
|
|
335
346
|
set(key, value) { this.locals[key] = value; },
|
|
336
347
|
get(key) { return this.locals[key]; },
|
|
337
348
|
};
|
|
338
|
-
const mwResult = await middlewareMod.execute(mwCtx);
|
|
339
|
-
if (mwResult.response) {
|
|
340
|
-
const body = await mwResult.response.text();
|
|
341
|
-
res.writeHead(mwResult.response.status, Object.fromEntries(mwResult.response.headers));
|
|
342
|
-
res.end(body);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (mwResult.rewriteUrl) {
|
|
346
|
-
url.pathname = mwResult.rewriteUrl;
|
|
347
|
-
}
|
|
348
349
|
}
|
|
349
350
|
else {
|
|
350
351
|
mwCtx = {
|
|
351
352
|
params: {},
|
|
352
353
|
url,
|
|
353
|
-
locals: {},
|
|
354
|
+
locals: Object.assign({}, serverStore || {}),
|
|
354
355
|
cookies: {},
|
|
355
356
|
request: null,
|
|
356
357
|
set() { },
|
|
357
358
|
get() { return undefined; },
|
|
358
359
|
};
|
|
359
360
|
}
|
|
361
|
+
if (eventsMod) {
|
|
362
|
+
try {
|
|
363
|
+
await eventsMod.executeRequest?.(mwCtx);
|
|
364
|
+
}
|
|
365
|
+
catch (e) {
|
|
366
|
+
console.error('vesk request: onRequest error:', e instanceof Error ? e.message : e);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (middlewareMod) {
|
|
370
|
+
const mwResult = await middlewareMod.execute(mwCtx);
|
|
371
|
+
if (mwResult.response) {
|
|
372
|
+
const body = await mwResult.response.text();
|
|
373
|
+
res.writeHead(mwResult.response.status, Object.fromEntries(mwResult.response.headers));
|
|
374
|
+
res.end(body);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (mwResult.rewriteUrl) {
|
|
378
|
+
url.pathname = mwResult.rewriteUrl;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
360
381
|
// Expose root middleware locals to API/SSR handlers (which seed their own
|
|
361
382
|
// ctx.locals from this before running route-level middleware).
|
|
362
383
|
globalThis.__vesk_request = mwCtx;
|
|
@@ -510,6 +531,33 @@ export async function startProdServer(outDir, options) {
|
|
|
510
531
|
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
511
532
|
res.end(notFoundHtml || '<!DOCTYPE html><html><body><h1>404</h1><p>Not Found</p></body></html>');
|
|
512
533
|
});
|
|
534
|
+
try {
|
|
535
|
+
await eventsMod?.executeStart?.({ server, port, host });
|
|
536
|
+
}
|
|
537
|
+
catch (e) {
|
|
538
|
+
console.error('vesk start: onStart error:', e instanceof Error ? e.message : e);
|
|
539
|
+
}
|
|
540
|
+
server.on('close', () => {
|
|
541
|
+
void (async () => {
|
|
542
|
+
try {
|
|
543
|
+
await eventsMod?.executeStop?.({ server, port, host });
|
|
544
|
+
}
|
|
545
|
+
catch (e) {
|
|
546
|
+
console.error('vesk stop: onStop error:', e instanceof Error ? e.message : e);
|
|
547
|
+
}
|
|
548
|
+
})();
|
|
549
|
+
});
|
|
550
|
+
let shuttingDown = false;
|
|
551
|
+
function shutdown(signal) {
|
|
552
|
+
if (shuttingDown)
|
|
553
|
+
return;
|
|
554
|
+
shuttingDown = true;
|
|
555
|
+
console.error(`vesk stop: received ${signal}, closing…`);
|
|
556
|
+
server.close(() => process.exit(0));
|
|
557
|
+
setTimeout(() => process.exit(0), 3000).unref();
|
|
558
|
+
}
|
|
559
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
560
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
513
561
|
server.listen(port, host, () => {
|
|
514
562
|
console.error(`vesk production server at http://localhost:${port} (listening on ${host})`);
|
|
515
563
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-bundle.d.ts","sourceRoot":"","sources":["../src/runtime-bundle.ts"],"names":[],"mappings":"AAuCA,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"runtime-bundle.d.ts","sourceRoot":"","sources":["../src/runtime-bundle.ts"],"names":[],"mappings":"AAuCA,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqHnF"}
|
package/dist/runtime-bundle.js
CHANGED
|
@@ -113,6 +113,16 @@ export async function bundleRuntime(appDir, outDir) {
|
|
|
113
113
|
'export const clearActions = __veskRuntime.clearActions;',
|
|
114
114
|
'export const validateActionInput = __veskRuntime.validateActionInput;',
|
|
115
115
|
'export const issuesToFieldMap = __veskRuntime.issuesToFieldMap;',
|
|
116
|
+
'',
|
|
117
|
+
'// Server-wide context store (server events)',
|
|
118
|
+
'export const serverLocals = __veskRuntime.serverLocals;',
|
|
119
|
+
'export const getServerContext = __veskRuntime.getServerContext;',
|
|
120
|
+
'export const setServerContext = __veskRuntime.setServerContext;',
|
|
121
|
+
'export const clearServerContext = __veskRuntime.clearServerContext;',
|
|
122
|
+
'export const server_locals = __veskRuntime.server_locals;',
|
|
123
|
+
'export const get_server_context = __veskRuntime.get_server_context;',
|
|
124
|
+
'export const set_server_context = __veskRuntime.set_server_context;',
|
|
125
|
+
'export const clear_server_context = __veskRuntime.clear_server_context;',
|
|
116
126
|
].join('\n');
|
|
117
127
|
writeFileSync(entryFile, entryContent, 'utf-8');
|
|
118
128
|
try {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { RouteNode, ApiRouteNode, VeskPlugin, VeskSecurity, VeskCors, VeskRateLimit, VeskSecurityPreset, SecurityConfig, MiddlewareChainItem, MiddlewareExtractResult, AncestorLayout, BuildOptions, DevServerOptions, ProdServerOptions, SsrFunctionOptions, ApiFunctionOptions, ClientBundleOptions, ClientBundleFileEntry, ClientBundleCache, ChunkEntry, ClientBundleResult, MonolithicBundleParts, Manifest, ManifestRouteEntry, ManifestActionEntry, ManifestPrerenderedEntry, SsgRouteResult, BuildResult, ImageRef, ImageResult, SeoCheckIssue, SeoAuditResult, CombinedPageInfo, Tracked, Resource, UseFetchOptions, UseFetchStreamOptions, VeskRequest, VeskResponse, SetCookieOptions, CookieStore, ServerRequest, SsrDataSink, MdProps, MdConfig, MdHtmlMode, MarkdownOptions, MdHtmlWarning, } from '@vesk/types';
|
|
1
|
+
export type { RouteNode, ApiRouteNode, VeskPlugin, ServerEventContext, VeskEventHandlers, VeskSecurity, VeskCors, VeskRateLimit, VeskSecurityPreset, SecurityConfig, MiddlewareChainItem, MiddlewareExtractResult, AncestorLayout, BuildOptions, DevServerOptions, ProdServerOptions, SsrFunctionOptions, ApiFunctionOptions, ClientBundleOptions, ClientBundleFileEntry, ClientBundleCache, ChunkEntry, ClientBundleResult, MonolithicBundleParts, Manifest, ManifestRouteEntry, ManifestActionEntry, ManifestPrerenderedEntry, SsgRouteResult, BuildResult, ImageRef, ImageResult, SeoCheckIssue, SeoAuditResult, CombinedPageInfo, Tracked, Resource, UseFetchOptions, UseFetchStreamOptions, VeskRequest, VeskResponse, SetCookieOptions, CookieStore, ServerRequest, SsrDataSink, MdProps, MdConfig, MdHtmlMode, MarkdownOptions, MdHtmlWarning, } from '@vesk/types';
|
|
2
2
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,WAAW,EACX,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,WAAW,EACX,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk adapter — builds deployable .vesk/ output for Deno and Node serverless",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"sharp": "^0.35.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vesk/compiler": "^0.2.
|
|
27
|
-
"@vesk/runtime": "^0.2.
|
|
28
|
-
"@vesk/types": "^0.2.
|
|
26
|
+
"@vesk/compiler": "^0.2.16",
|
|
27
|
+
"@vesk/runtime": "^0.2.16",
|
|
28
|
+
"@vesk/types": "^0.2.16"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|