@workflow/web 5.0.0-beta.9 → 5.0.1
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/README.md +1 -0
- package/build/client/assets/app-BIKwaF7E.css +1 -0
- package/build/client/assets/arrow-up-right-CIRm41Zm.js +15 -0
- package/build/client/assets/{entry.client-DtOpLtMQ.js → entry.client-DmlDFlyx.js} +25 -185
- package/build/client/assets/{highlighted-body-B3W2YXNL-ijzNrESJ.js → highlighted-body-B3W2YXNL-DQ3Je3B9.js} +2 -2
- package/build/client/assets/{home-MRChHR_P.js → home-Dl1wTnFS.js} +1791 -291
- package/build/client/assets/index-HqNj_XIX.js +200 -0
- package/build/client/assets/{index-BsV8i_Jn.js → index-thGVuYbY.js} +19 -19
- package/build/client/assets/loader-circle-CD4z6T9x.js +12 -0
- package/build/client/assets/manifest-7d7b25b4.js +1 -0
- package/build/client/assets/mermaid-3ZIDBTTL-D8CjRQta.css +1 -0
- package/build/client/assets/{mermaid-3ZIDBTTL-3cOa-aZ5.js → mermaid-3ZIDBTTL-fKP9rqOT.js} +17574 -12966
- package/build/client/assets/{root-3uuTxUQN.js → root-ESATuWiF.js} +17 -42
- package/build/client/assets/root-grl25rxS.css +1 -0
- package/build/client/assets/run-detail-CWoGxu_0.css +1 -0
- package/build/client/assets/{run-detail-8qGjUNCj.js → run-detail-ClvtUP5Y.js} +3035 -2447
- package/build/client/assets/{workflow-graph-viewer-DaYMiBT9.js → workflow-graph-viewer-DWfB9i-1.js} +5143 -5261
- package/build/client/assets/zstd-B5R2yJjB.wasm +0 -0
- package/build/client/assets/zstd-browser-decoder-Cg5apldO.js +27 -0
- package/build/server/assets/{server-build-Ctg6FoI8.js → app-DB1r_8VA.js} +101534 -71696
- package/build/server/assets/{highlighted-body-B3W2YXNL-B4fAdNsB.js → highlighted-body-B3W2YXNL-CHWCmTRA.js} +22 -9
- package/build/server/assets/index-B2Fjee_4.js +1262 -0
- package/build/server/assets/index-BfLBLRRi.js +204 -0
- package/build/server/assets/index-CETb4fkq.js +1164 -0
- package/build/server/assets/index-CvPUU1wY.js +187 -0
- package/build/server/assets/{mermaid-3ZIDBTTL-C6M7jb0V.js → mermaid-3ZIDBTTL-CNO9LDDa.js} +22 -9
- package/build/server/assets/{token-BNjLoJXz.js → token-C2ZfbDqj.js} +5 -2
- package/build/server/assets/{token-util-DwTdh-aG.js → token-util-Df3UC21b.js} +5 -2
- package/build/server/assets/wrapper-D66LMJdl.js +67 -0
- package/build/server/assets/zstd-browser-decoder-DF4c9PWF.js +77 -0
- package/build/server/index.js +55 -3
- package/handler.d.ts +22 -0
- package/handler.js +103 -0
- package/package.json +28 -15
- package/registry.d.ts +29 -0
- package/registry.js +89 -0
- package/server.d.ts +5 -1
- package/server.js +32 -39
- package/static.js +86 -0
- package/build/client/assets/encryption-C69WMRfh.js +0 -34
- package/build/client/assets/index-Byi8AWfe.js +0 -280
- package/build/client/assets/manifest-b100514d.js +0 -1
- package/build/client/assets/mermaid-3ZIDBTTL-DKxHcEOp.css +0 -1
- package/build/client/assets/root-BYtlAgHl.css +0 -1
- package/build/client/assets/server-build-ByHD2s6b.css +0 -1
- package/build/client/assets/worker-CqHKTA7D.js +0 -115
- package/build/server/assets/app-BEgkHdDF.js +0 -9213
- package/build/server/assets/index-DltGJ3CV.js +0 -89
- package/build/server/assets/index-meg9qk8y.js +0 -1282
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/web",
|
|
3
3
|
"description": "Workflow Observability UI",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
8
8
|
"build",
|
|
9
9
|
"server.js",
|
|
10
10
|
"server.d.ts",
|
|
11
|
+
"handler.js",
|
|
12
|
+
"handler.d.ts",
|
|
13
|
+
"registry.js",
|
|
14
|
+
"registry.d.ts",
|
|
15
|
+
"static.js",
|
|
11
16
|
"package.json"
|
|
12
17
|
],
|
|
13
18
|
"exports": {
|
|
@@ -15,6 +20,14 @@
|
|
|
15
20
|
"types": "./server.d.ts",
|
|
16
21
|
"default": "./server.js"
|
|
17
22
|
},
|
|
23
|
+
"./handler": {
|
|
24
|
+
"types": "./handler.d.ts",
|
|
25
|
+
"default": "./handler.js"
|
|
26
|
+
},
|
|
27
|
+
"./registry": {
|
|
28
|
+
"types": "./registry.d.ts",
|
|
29
|
+
"default": "./registry.js"
|
|
30
|
+
},
|
|
18
31
|
"./package.json": "./package.json"
|
|
19
32
|
},
|
|
20
33
|
"publishConfig": {
|
|
@@ -27,10 +40,11 @@
|
|
|
27
40
|
"directory": "packages/web"
|
|
28
41
|
},
|
|
29
42
|
"dependencies": {
|
|
30
|
-
"
|
|
43
|
+
"@workflow/world-local": "5.0.1",
|
|
44
|
+
"srvx": "^0.12.4",
|
|
45
|
+
"swr": "^2.3.6"
|
|
31
46
|
},
|
|
32
47
|
"devDependencies": {
|
|
33
|
-
"@testing-library/react": "^16.3.0",
|
|
34
48
|
"@biomejs/biome": "^2.4.4",
|
|
35
49
|
"@radix-ui/react-alert-dialog": "1.1.5",
|
|
36
50
|
"@radix-ui/react-checkbox": "1.1.4",
|
|
@@ -43,14 +57,19 @@
|
|
|
43
57
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
44
58
|
"@radix-ui/react-tooltip": "1.2.8",
|
|
45
59
|
"@react-router/dev": "7.13.1",
|
|
46
|
-
"@react-router/express": "7.13.1",
|
|
47
60
|
"@react-router/node": "7.13.1",
|
|
48
|
-
"@vercel/react-router": "1.2.6",
|
|
49
61
|
"@tailwindcss/vite": "4",
|
|
50
|
-
"@
|
|
62
|
+
"@testing-library/react": "^16.3.0",
|
|
51
63
|
"@types/node": "22.19.0",
|
|
52
64
|
"@types/react": "19",
|
|
53
65
|
"@types/react-dom": "19",
|
|
66
|
+
"@vercel/react-router": "1.2.6",
|
|
67
|
+
"@workflow/core": "5.0.1",
|
|
68
|
+
"@workflow/errors": "5.0.1",
|
|
69
|
+
"@workflow/utils": "5.0.0",
|
|
70
|
+
"@workflow/web-shared": "5.0.1",
|
|
71
|
+
"@workflow/world": "5.0.1",
|
|
72
|
+
"@workflow/world-vercel": "5.0.1",
|
|
54
73
|
"@xyflow/react": "12.10.1",
|
|
55
74
|
"cbor-x": "^1",
|
|
56
75
|
"class-variance-authority": "0.7.1",
|
|
@@ -59,6 +78,7 @@
|
|
|
59
78
|
"date-fns": "4.1.0",
|
|
60
79
|
"geist": "^1.7.0",
|
|
61
80
|
"isbot": "^5",
|
|
81
|
+
"jsdom": "^26",
|
|
62
82
|
"lucide-react": "0.575.0",
|
|
63
83
|
"next-themes": "0.4.6",
|
|
64
84
|
"react": "19.1.0",
|
|
@@ -68,16 +88,9 @@
|
|
|
68
88
|
"sonner": "2.0.7",
|
|
69
89
|
"tailwind-merge": "3.5.0",
|
|
70
90
|
"tailwindcss": "4",
|
|
71
|
-
"typescript": "^
|
|
91
|
+
"typescript": "^6.0.3",
|
|
72
92
|
"vite": "^6",
|
|
73
|
-
"vitest": "^3"
|
|
74
|
-
"jsdom": "^26",
|
|
75
|
-
"@workflow/core": "5.0.0-beta.9",
|
|
76
|
-
"@workflow/errors": "5.0.0-beta.5",
|
|
77
|
-
"@workflow/utils": "5.0.0-beta.3",
|
|
78
|
-
"@workflow/web-shared": "5.0.0-beta.9",
|
|
79
|
-
"@workflow/world": "5.0.0-beta.5",
|
|
80
|
-
"@workflow/world-vercel": "5.0.0-beta.8"
|
|
93
|
+
"vitest": "^3.2.7"
|
|
81
94
|
},
|
|
82
95
|
"scripts": {
|
|
83
96
|
"dev": "react-router dev",
|
package/registry.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A recorded embedded-dashboard instance. */
|
|
2
|
+
export interface DashboardRegistryEntry {
|
|
3
|
+
/** Public base URL the dashboard is reachable at (e.g. `http://localhost:3000/_workflow`). */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Mount path the dashboard is served under (e.g. `/_workflow`; `""` at root). */
|
|
6
|
+
basename: string;
|
|
7
|
+
/** World backend identifier, for display (e.g. `local`, `@workflow/world-postgres`). */
|
|
8
|
+
world: string;
|
|
9
|
+
/** PID of the process hosting the dashboard. */
|
|
10
|
+
pid: number;
|
|
11
|
+
/** ISO timestamp the entry was recorded. */
|
|
12
|
+
startedAt: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Absolute path of the registry file for the current working directory. */
|
|
16
|
+
export function dashboardRegistryPath(): string;
|
|
17
|
+
|
|
18
|
+
/** Read the registry entries (always returns an array; never throws). */
|
|
19
|
+
export function readDashboardRegistry(): DashboardRegistryEntry[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Record this process's embedded dashboard (idempotent per process). Entirely
|
|
23
|
+
* best-effort — never throws.
|
|
24
|
+
*/
|
|
25
|
+
export function recordDashboard(entry: {
|
|
26
|
+
url: string;
|
|
27
|
+
basename?: string;
|
|
28
|
+
world?: string;
|
|
29
|
+
}): void;
|
package/registry.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort registry of live, embedded observability dashboards.
|
|
3
|
+
*
|
|
4
|
+
* When the dashboard is embedded in another server (e.g. `@workflow/nitro` at
|
|
5
|
+
* `/_workflow`), the running process records its public URL here. The CLI
|
|
6
|
+
* (`workflow web` / `inspect … --web`) reads this so it can point the user at
|
|
7
|
+
* an already-running dashboard instead of spawning a redundant standalone
|
|
8
|
+
* server on a fixed port.
|
|
9
|
+
*
|
|
10
|
+
* This is a coordination hint, never a source of truth: entries may be stale
|
|
11
|
+
* (a SIGKILL'd dev server can't clean up), so consumers MUST health-check a URL
|
|
12
|
+
* before trusting it. A missing or corrupt registry is treated as "none".
|
|
13
|
+
*
|
|
14
|
+
* The file is keyed by the current working directory so multiple projects don't
|
|
15
|
+
* collide, while multiple dev servers for the same project share one file
|
|
16
|
+
* (keyed by pid within it).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createHash } from 'node:crypto';
|
|
20
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import os from 'node:os';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
|
|
24
|
+
/** Absolute path of the registry file for the current working directory. */
|
|
25
|
+
export function dashboardRegistryPath() {
|
|
26
|
+
const key = createHash('sha256')
|
|
27
|
+
.update(process.cwd())
|
|
28
|
+
.digest('hex')
|
|
29
|
+
.slice(0, 16);
|
|
30
|
+
return path.join(os.tmpdir(), 'workflow-observability', `${key}.json`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Read the registry entries (always returns an array; never throws). */
|
|
34
|
+
export function readDashboardRegistry() {
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(readFileSync(dashboardRegistryPath(), 'utf8'));
|
|
37
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
38
|
+
} catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function writeEntries(entries) {
|
|
44
|
+
const file = dashboardRegistryPath();
|
|
45
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
46
|
+
writeFileSync(file, JSON.stringify(entries));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let recorded = false;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Record this process's embedded dashboard in the registry (idempotent per
|
|
53
|
+
* process). Call once the public origin is known (e.g. from the first request).
|
|
54
|
+
* Entirely best-effort — never throws.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ url: string, basename?: string, world?: string }} entry
|
|
57
|
+
*/
|
|
58
|
+
export function recordDashboard(entry) {
|
|
59
|
+
if (recorded) return;
|
|
60
|
+
recorded = true;
|
|
61
|
+
try {
|
|
62
|
+
const others = readDashboardRegistry().filter(
|
|
63
|
+
(e) => e && e.pid !== process.pid
|
|
64
|
+
);
|
|
65
|
+
others.push({
|
|
66
|
+
url: entry.url,
|
|
67
|
+
basename: entry.basename ?? '',
|
|
68
|
+
world: entry.world ?? '',
|
|
69
|
+
pid: process.pid,
|
|
70
|
+
startedAt: new Date().toISOString(),
|
|
71
|
+
});
|
|
72
|
+
writeEntries(others);
|
|
73
|
+
// Best-effort cleanup on normal exit. Signal-terminated processes (Ctrl+C,
|
|
74
|
+
// SIGKILL) won't run this — consumers prune via health checks instead. We
|
|
75
|
+
// intentionally don't hook SIGINT/SIGTERM so we don't interfere with the
|
|
76
|
+
// host framework's own shutdown handling.
|
|
77
|
+
process.once('exit', () => {
|
|
78
|
+
try {
|
|
79
|
+
writeEntries(
|
|
80
|
+
readDashboardRegistry().filter((e) => e && e.pid !== process.pid)
|
|
81
|
+
);
|
|
82
|
+
} catch {
|
|
83
|
+
// ignore
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch {
|
|
87
|
+
// best-effort: a failed write must never break request handling
|
|
88
|
+
}
|
|
89
|
+
}
|
package/server.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import type { Server } from '
|
|
1
|
+
import type { Server } from 'srvx';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Start the standalone observability UI server on `port` (defaults to `PORT`, then 3000),
|
|
5
|
+
* and resolve once it is listening.
|
|
6
|
+
*/
|
|
3
7
|
export function startServer(port?: number): Promise<Server>;
|
package/server.js
CHANGED
|
@@ -10,57 +10,50 @@
|
|
|
10
10
|
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
13
|
-
import
|
|
13
|
+
import { serve } from 'srvx';
|
|
14
|
+
import { createStaticHandler } from './static.js';
|
|
14
15
|
|
|
15
16
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
17
|
const buildDir = path.resolve(__dirname, 'build');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Import the compiled server build, which exports { app } (an Express app
|
|
20
|
-
// with the React Router request handler already mounted by server/app.ts)
|
|
21
|
-
const { app } = await import(
|
|
22
|
-
pathToFileURL(path.join(buildDir, 'server/index.js')).href
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
// Add static file serving in front of the React Router handler.
|
|
26
|
-
// We create a wrapper app so static middleware runs first.
|
|
27
|
-
const server = express();
|
|
28
|
-
|
|
29
|
-
// Serve immutable assets with long-lived cache
|
|
30
|
-
server.use(
|
|
31
|
-
'/assets',
|
|
32
|
-
express.static(path.join(buildDir, 'client/assets'), {
|
|
33
|
-
immutable: true,
|
|
34
|
-
maxAge: '1y',
|
|
35
|
-
})
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// Serve static client files with short cache
|
|
39
|
-
server.use(express.static(path.join(buildDir, 'client'), { maxAge: '1h' }));
|
|
40
|
-
|
|
41
|
-
// Mount the React Router app
|
|
42
|
-
server.use(app);
|
|
43
|
-
|
|
44
|
-
return server;
|
|
45
|
-
}
|
|
18
|
+
const clientDir = path.join(buildDir, 'client');
|
|
19
|
+
const serverEntry = path.join(buildDir, 'server', 'index.js');
|
|
46
20
|
|
|
47
21
|
/**
|
|
48
22
|
* Start the production HTTP server.
|
|
49
23
|
*
|
|
50
24
|
* @param {number} [port] - Port to listen on. Defaults to PORT env or 3000.
|
|
51
|
-
* @returns {Promise<import("
|
|
25
|
+
* @returns {Promise<import("srvx").Server>} The listening server. The
|
|
26
|
+
* underlying Node `http.Server` remains reachable via `server.node.server`.
|
|
52
27
|
*/
|
|
53
28
|
export async function startServer(port) {
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
// Import the compiled server build, which exports `createFetchHandler` (the
|
|
30
|
+
// React Router request handler, as a Web `Request` -> `Response` function).
|
|
31
|
+
const { createFetchHandler } = await import(pathToFileURL(serverEntry).href);
|
|
32
|
+
|
|
33
|
+
// Static assets are resolved before the SSR handler ever runs. Compression is
|
|
34
|
+
// left on here (unlike the embedded handler): this server can be self-hosted
|
|
35
|
+
// over a real network, where trading CPU for bytes is worth it.
|
|
36
|
+
const serveStatic = createStaticHandler({ dir: clientDir });
|
|
37
|
+
const ssr = createFetchHandler('/');
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
39
|
+
const server = serve({
|
|
40
|
+
port: port ?? parseInt(process.env.PORT || '3000', 10),
|
|
41
|
+
async fetch(request) {
|
|
42
|
+
return (await serveStatic(request)) ?? ssr(request);
|
|
43
|
+
},
|
|
44
|
+
// Safety net — prevents an unhandled error from taking down the server when
|
|
45
|
+
// the React Router error boundary cannot render (e.g. during SSR).
|
|
46
|
+
error(error) {
|
|
47
|
+
console.error('Unhandled request error:', error);
|
|
48
|
+
return new Response('Internal Server Error', { status: 500 });
|
|
49
|
+
},
|
|
50
|
+
// We print our own listening line below.
|
|
51
|
+
silent: true,
|
|
63
52
|
});
|
|
53
|
+
|
|
54
|
+
await server.ready();
|
|
55
|
+
console.log(`@workflow/web server listening on ${server.url}`);
|
|
56
|
+
return server;
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
// When run directly, start the server
|
package/static.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static file serving for the prebuilt client bundle (`build/client`), shared
|
|
3
|
+
* by both ways @workflow/web is served:
|
|
4
|
+
*
|
|
5
|
+
* - `server.js` — the standalone server, mounted at the root.
|
|
6
|
+
* - `handler.js` — the embedded handler, mounted under a base path inside
|
|
7
|
+
* another server.
|
|
8
|
+
*
|
|
9
|
+
* Internal: this file ships in the package (both consumers import it
|
|
10
|
+
* relatively) but is deliberately absent from the `exports` map, so it is not
|
|
11
|
+
* part of the public API.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { staticMiddleware } from 'srvx/static';
|
|
15
|
+
|
|
16
|
+
const ONE_YEAR_SECONDS = 31_536_000;
|
|
17
|
+
const ONE_HOUR_SECONDS = 3600;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sentinel handed to `staticMiddleware` as its `next()`. Returned by identity
|
|
21
|
+
* when no file matched, so a miss is distinguishable from a real 404 the
|
|
22
|
+
* middleware itself produced. Never sent to a client.
|
|
23
|
+
*/
|
|
24
|
+
const MISS = new Response(null, { status: 404 });
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Build a static file handler for `dir`.
|
|
28
|
+
*
|
|
29
|
+
* Two middlewares over the same directory, differing only in freshness policy:
|
|
30
|
+
* everything under `/assets/` is content-hashed by Vite (its URL changes when
|
|
31
|
+
* its bytes do) and can be cached indefinitely without revalidation, while the
|
|
32
|
+
* rest — `favicon.ico` and anything else copied from `public/` — keeps a stable
|
|
33
|
+
* URL and so gets a short lifetime. Both emit ETag/Last-Modified validators
|
|
34
|
+
* regardless, so a stale client revalidates into a 304 rather than a full body.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} options
|
|
37
|
+
* @param {string} options.dir - Directory to serve from (the client build).
|
|
38
|
+
* @param {string} [options.basename] - Mount prefix to strip before resolving,
|
|
39
|
+
* already normalized (no trailing slash; `""` for the root).
|
|
40
|
+
* @param {boolean} [options.compress] - Compress compressible bodies on the
|
|
41
|
+
* fly. Defaults to true.
|
|
42
|
+
* @returns {(request: Request) => Promise<Response | null>} The response, or
|
|
43
|
+
* `null` when the request maps to no file and should fall through to SSR.
|
|
44
|
+
*/
|
|
45
|
+
export function createStaticHandler({ dir, basename = '', compress = true }) {
|
|
46
|
+
const hashedAssets = staticMiddleware({
|
|
47
|
+
dir,
|
|
48
|
+
maxAge: ONE_YEAR_SECONDS,
|
|
49
|
+
immutable: true,
|
|
50
|
+
compress,
|
|
51
|
+
});
|
|
52
|
+
const publicFiles = staticMiddleware({
|
|
53
|
+
dir,
|
|
54
|
+
maxAge: ONE_HOUR_SECONDS,
|
|
55
|
+
compress,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return async (request) => {
|
|
59
|
+
// Everything else (including the index) is the SSR handler's.
|
|
60
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') return null;
|
|
61
|
+
|
|
62
|
+
let url;
|
|
63
|
+
try {
|
|
64
|
+
url = new URL(request.url);
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let target = request;
|
|
70
|
+
if (basename) {
|
|
71
|
+
// A request at exactly `basename` is the dashboard index, not a file.
|
|
72
|
+
if (!url.pathname.startsWith(`${basename}/`)) return null;
|
|
73
|
+
url.pathname = url.pathname.slice(basename.length);
|
|
74
|
+
// `staticMiddleware` resolves against the request's own pathname, so the
|
|
75
|
+
// mount prefix has to come off the URL rather than be passed alongside.
|
|
76
|
+
// Safe to rebuild for GET/HEAD, which carry no body.
|
|
77
|
+
target = new Request(url, request);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const middleware = url.pathname.startsWith('/assets/')
|
|
81
|
+
? hashedAssets
|
|
82
|
+
: publicFiles;
|
|
83
|
+
const response = await middleware(target, () => MISS);
|
|
84
|
+
return response === MISS ? null : response;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { W as WorkflowRuntimeError } from "./index-Byi8AWfe.js";
|
|
2
|
-
import "./index-BsV8i_Jn.js";
|
|
3
|
-
const NONCE_LENGTH = 12;
|
|
4
|
-
const TAG_LENGTH = 128;
|
|
5
|
-
const KEY_LENGTH = 32;
|
|
6
|
-
async function importKey(raw, usages = ["encrypt", "decrypt"]) {
|
|
7
|
-
if (raw.byteLength !== KEY_LENGTH) {
|
|
8
|
-
throw new WorkflowRuntimeError(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw.byteLength}`);
|
|
9
|
-
}
|
|
10
|
-
return globalThis.crypto.subtle.importKey(
|
|
11
|
-
"raw",
|
|
12
|
-
raw,
|
|
13
|
-
"AES-GCM",
|
|
14
|
-
false,
|
|
15
|
-
// `KeyUsage` is a DOM-lib type that's not in scope under `es2022`.
|
|
16
|
-
// The `ReadonlyArray<'encrypt' | 'decrypt'>` parameter type matches
|
|
17
|
-
// a strict subset of `KeyUsage[]`, so this cast is sound.
|
|
18
|
-
usages
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
async function decrypt(key, data) {
|
|
22
|
-
const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
|
|
23
|
-
if (data.byteLength < minLength) {
|
|
24
|
-
throw new WorkflowRuntimeError(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`);
|
|
25
|
-
}
|
|
26
|
-
const nonce = data.subarray(0, NONCE_LENGTH);
|
|
27
|
-
const ciphertext = data.subarray(NONCE_LENGTH);
|
|
28
|
-
const plaintext = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, ciphertext);
|
|
29
|
-
return new Uint8Array(plaintext);
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
decrypt,
|
|
33
|
-
importKey
|
|
34
|
-
};
|