@workflow/web 5.0.0-beta.56 → 5.0.0-beta.58

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.
Files changed (27) hide show
  1. package/build/client/assets/{arrow-up-right-XpJjI06G.js → arrow-up-right-jHPcOZmb.js} +1 -1
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-DA3N01jE.js → highlighted-body-B3W2YXNL-CBBI0JQ-.js} +1 -1
  3. package/build/client/assets/{home-CLktiGIz.js → home-BcIEUw9E.js} +33 -12
  4. package/build/client/assets/{loader-circle-Cj8CH5bR.js → loader-circle-HeezuKOU.js} +1 -1
  5. package/build/client/assets/{manifest-3ffb4984.js → manifest-a541ae9e.js} +1 -1
  6. package/build/client/assets/{mermaid-3ZIDBTTL-DG0Grjgm.js → mermaid-3ZIDBTTL-ClcCzUqi.js} +62 -8
  7. package/build/client/assets/{root-3gE7cfR2.js → root-DLS5V7HU.js} +3 -3
  8. package/build/client/assets/{run-detail-gOfjBB1S.js → run-detail-DWoMKBqC.js} +37 -11
  9. package/build/client/assets/{workflow-graph-viewer-Cg3Lr_h8.js → workflow-graph-viewer-syfKq6DB.js} +29 -9
  10. package/build/client/assets/{zstd-browser-decoder-CEJ92wdJ.js → zstd-browser-decoder-D2p6f8lN.js} +1 -1
  11. package/build/server/assets/{app-Bl4MnK_A.js → app-CEqDw6uM.js} +23169 -12284
  12. package/build/server/assets/{highlighted-body-B3W2YXNL-DEO_Ibma.js → highlighted-body-B3W2YXNL-C2u3JoU4.js} +7 -2
  13. package/build/server/assets/{index-bN9Oj_dl.js → index-BG8LHWgA.js} +71 -64
  14. package/build/server/assets/{index-B_qUqg3k.js → index-BrFZB5-R.js} +1 -1
  15. package/build/server/assets/{mermaid-3ZIDBTTL-Dr7Wk8Bh.js → mermaid-3ZIDBTTL-BZ2gmvHb.js} +7 -2
  16. package/build/server/assets/{token-CUWJi08Y.js → token-KvMwAySl.js} +1 -1
  17. package/build/server/assets/{token-util-B4OMKRZB.js → token-util-DGBKzRwD.js} +1 -1
  18. package/build/server/assets/{wrapper-Cs9Wzu7M.js → wrapper-CBRVXtq2.js} +12 -14
  19. package/build/server/assets/{zstd-browser-decoder-DSPBib47.js → zstd-browser-decoder-BxTIaNvq.js} +7 -2
  20. package/build/server/index.js +8 -4
  21. package/handler.js +13 -96
  22. package/package.json +9 -10
  23. package/server.d.ts +5 -1
  24. package/server.js +32 -39
  25. package/static.js +86 -0
  26. package/build/server/assets/websocket-server-FV9R_mnP.js +0 -3669
  27. package/build/server/assets/ws-transport-B4h16CAX.js +0 -551
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
+ }