@kabmo-labs/kabmo 0.39.0 → 0.39.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/dist/client/index.html +1 -1
- package/dist/client/index.js +270 -270
- package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-7synegzg.js} +1 -1
- package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-v5d9n5yw.js} +1 -1
- package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-ww7y98tt.js} +1 -1
- package/dist/client/static/js/{ImageView-nreh25s0.js → ImageView-t3rkypzs.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-0x1q1q5z.js → LayoutWrapper-th2pd4yt.js} +1 -1
- package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-qj39shgb.js} +1 -1
- package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-t9v4datp.js} +1 -1
- package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-yqy0a1xg.js} +1 -1
- package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-6zkxbjd4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-7rt2p1y1.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-b04e26rb.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-32ph2m52.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-hwnaa333.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-5v3rzdxd.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-7er2jwy1.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-yf61ftn0.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-cn3rs9xn.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-7kvtsj6c.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-g3zg3r5e.js} +1 -1
- package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-f9j396wm.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-227xs61z.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-4671gdym.js} +1 -1
- package/dist/client/static/js/{index-a7qccdq2.js → index-28a5kf88.js} +1 -1
- package/dist/client/static/js/{index-ymp2wqtc.js → index-35mh9kbs.js} +1 -1
- package/dist/client/static/js/{index-3fw3sd10.js → index-4c2zcvem.js} +7 -7
- package/dist/client/static/js/{index-jkph8wqq.js → index-4ry8kz8h.js} +1 -1
- package/dist/client/static/js/{index-v8vjh5jj.js → index-668chrpq.js} +1 -1
- package/dist/client/static/js/{index-8qgwj6m8.js → index-6rs8e8ng.js} +1 -1
- package/dist/client/static/js/{index-56w8m083.js → index-7qc2avfy.js} +1 -1
- package/dist/client/static/js/{index-5kvvb0zm.js → index-87qandgr.js} +1 -1
- package/dist/client/static/js/{index-ntx3bbmb.js → index-8xasfxf3.js} +1 -1
- package/dist/client/static/js/{index-gvkc9e32.js → index-d3prrt2q.js} +1 -1
- package/dist/client/static/js/{index-4pehdq5h.js → index-f1nqk6z6.js} +1 -1
- package/dist/client/static/js/{index-pzqsp5jw.js → index-f73v86a3.js} +1 -1
- package/dist/client/static/js/{index-270y5r9k.js → index-fjqp03xe.js} +1 -1
- package/dist/client/static/js/{index-mmsszqvn.js → index-fs3pbqwn.js} +1 -1
- package/dist/client/static/js/{index-xdqsqhnn.js → index-h8rr48px.js} +1 -1
- package/dist/client/static/js/{index-dmd26a1y.js → index-hdd8nqz8.js} +1 -1
- package/dist/client/static/js/{index-me7m3516.js → index-j2g39xq7.js} +1 -1
- package/dist/client/static/js/{index-dt22v9ns.js → index-jze0zg3z.js} +1 -1
- package/dist/client/static/js/{index-m3r0j562.js → index-kkfbd1db.js} +1 -1
- package/dist/client/static/js/{index-7h5n5rz4.js → index-m847wafq.js} +1 -1
- package/dist/client/static/js/{index-y2prm0xm.js → index-mtadrbxt.js} +1 -1
- package/dist/client/static/js/{index-7z63xr1s.js → index-phm1zb8m.js} +1 -1
- package/dist/client/static/js/{index-p89z1qmj.js → index-qbnd827h.js} +1 -1
- package/dist/client/static/js/{index-8w2tx2k9.js → index-s80x8d58.js} +1 -1
- package/dist/client/static/js/{index-ywpdhntc.js → index-tmnnafht.js} +1 -1
- package/dist/client/static/js/{index-hh05xd1d.js → index-vb3srfyc.js} +1 -1
- package/dist/client/static/js/{index-k61tdd4a.js → index-w0rbyw47.js} +1 -1
- package/dist/client/static/js/{index-5a4w58r2.js → index-w0xvdda9.js} +1 -1
- package/dist/client/static/js/{index-878d61js.js → index-wfcgqjzr.js} +1 -1
- package/dist/client/static/js/{index-pr7gk5eq.js → index-wgvysmnr.js} +1 -1
- package/dist/client/static/js/{index-mdxnhndy.js → index-xfr6r539.js} +1 -1
- package/dist/client/static/js/{index-k3c3n69j.js → index-xnk1500f.js} +2 -2
- package/dist/client/static/js/{index-61qjr1k0.js → index-y5ymgp20.js} +2 -2
- package/dist/client/static/js/{index-k5a6r25s.js → index-y91j4t1q.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +1 -1
- package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-0gafsqrm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +1 -1
- package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
- package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-66mn2qnt.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +1 -1
- package/dist/client/static/js/{rust-jatm47v6.js → rust-jvkbr060.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zk37paj9.js → swimlanesDiagram-TC7HE7FX-d48g5gjf.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/terminal/attach-replay.test.ts +80 -17
- package/src/server/plugins/static.test.ts +23 -1
- package/src/server/plugins/static.ts +24 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
- package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
- package/dist/client/static/js/one-light-czk9dzya.js +0 -1
|
@@ -26,27 +26,42 @@ import { attachTerminal, forgetTerminal, writeTerminalInput } from '@/server/lib
|
|
|
26
26
|
import type { TerminalViewer } from '@/server/lib/terminal/session.server';
|
|
27
27
|
|
|
28
28
|
const dec = new TextDecoder();
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Lines the flood prints. Windows' PTY is roughly two orders of magnitude
|
|
32
|
+
* slower than Linux's — the 30,000-line flood took ~3.3 s there and ~30 ms
|
|
33
|
+
* here — so the flood is sized per platform: long enough on Linux that the
|
|
34
|
+
* poll below cannot be delayed past its end, short enough on Windows that the
|
|
35
|
+
* test stays bounded.
|
|
36
|
+
*/
|
|
37
|
+
const TOTAL = process.platform === 'win32' ? 30_000 : 2_000_000;
|
|
30
38
|
|
|
31
39
|
interface Collected {
|
|
32
40
|
viewer: TerminalViewer;
|
|
33
41
|
frames: Uint8Array[];
|
|
42
|
+
/** Bytes delivered so far; the mid-flood attach trigger reads this. */
|
|
43
|
+
bytes: number;
|
|
34
44
|
text: () => string;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
function collector(): Collected {
|
|
38
48
|
const frames: Uint8Array[] = [];
|
|
39
|
-
|
|
49
|
+
const collected: Collected = {
|
|
40
50
|
viewer: {
|
|
41
51
|
send(frame) {
|
|
42
|
-
if (typeof frame !== 'string')
|
|
52
|
+
if (typeof frame !== 'string') {
|
|
53
|
+
frames.push(frame);
|
|
54
|
+
collected.bytes += frame.length;
|
|
55
|
+
}
|
|
43
56
|
return true;
|
|
44
57
|
},
|
|
45
58
|
drop() {},
|
|
46
59
|
},
|
|
47
60
|
frames,
|
|
61
|
+
bytes: 0,
|
|
48
62
|
text: () => dec.decode(join(frames)),
|
|
49
63
|
};
|
|
64
|
+
return collected;
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
function join(parts: Uint8Array[]): Uint8Array {
|
|
@@ -70,12 +85,24 @@ function join(parts: Uint8Array[]): Uint8Array {
|
|
|
70
85
|
* `gap(replayed)` with `5135 -> 51 at 5134` on a terminal that was working. The
|
|
71
86
|
* same rule makes the live collectors safe for the same reason: a line counts
|
|
72
87
|
* once the shell has finished writing it.
|
|
88
|
+
*
|
|
89
|
+
* `dropFirst` applies the same rule to the START of the text: the retained
|
|
90
|
+
* scrollback is capped at 512 KiB, so a long flood's replay begins inside a
|
|
91
|
+
* line, and its prefix is a number that happens to parse. The caller says the
|
|
92
|
+
* text does not start at a line boundary.
|
|
73
93
|
*/
|
|
74
|
-
function numbers(text: string): number[] {
|
|
75
|
-
|
|
94
|
+
function numbers(text: string, dropFirst = false): number[] {
|
|
95
|
+
let complete = text.endsWith('\n') ? text : text.slice(0, text.lastIndexOf('\n') + 1);
|
|
96
|
+
if (dropFirst) {
|
|
97
|
+
const firstNewline = complete.indexOf('\n');
|
|
98
|
+
complete = firstNewline === -1 ? '' : complete.slice(firstNewline + 1);
|
|
99
|
+
}
|
|
76
100
|
return complete
|
|
77
101
|
.split('\n')
|
|
78
|
-
|
|
102
|
+
// The terminal echoes Ctrl-C as `^C` at the cursor, which lands in front of
|
|
103
|
+
// the line `seq` was writing when the test stopped it. Strip that echo so
|
|
104
|
+
// the interrupted line still counts as the number it is.
|
|
105
|
+
.map((line) => line.replace(/\r$/, '').replace(/^\^C/, '').trim())
|
|
79
106
|
.filter((line) => /^\d+$/.test(line))
|
|
80
107
|
.map(Number);
|
|
81
108
|
}
|
|
@@ -97,6 +124,30 @@ async function until(predicate: () => boolean, timeoutMs = 20_000): Promise<bool
|
|
|
97
124
|
return false;
|
|
98
125
|
}
|
|
99
126
|
|
|
127
|
+
/**
|
|
128
|
+
* True once `read()` has stopped changing for `quietMs`.
|
|
129
|
+
*
|
|
130
|
+
* Real time on purpose: this is an integration test against a real PTY, and
|
|
131
|
+
* what it waits for is the shell's own output stopping after Ctrl-C. There is
|
|
132
|
+
* no promise or event to await — the PTY is the clock.
|
|
133
|
+
*/
|
|
134
|
+
async function settle(read: () => number, quietMs = 200, timeoutMs = 30_000): Promise<boolean> {
|
|
135
|
+
let last = read();
|
|
136
|
+
let quietSince = Date.now();
|
|
137
|
+
const started = Date.now();
|
|
138
|
+
while (Date.now() - started < timeoutMs) {
|
|
139
|
+
await Bun.sleep(20);
|
|
140
|
+
const now = read();
|
|
141
|
+
if (now !== last) {
|
|
142
|
+
last = now;
|
|
143
|
+
quietSince = Date.now();
|
|
144
|
+
} else if (Date.now() - quietSince >= quietMs) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
100
151
|
const ids: string[] = [];
|
|
101
152
|
|
|
102
153
|
afterAll(() => {
|
|
@@ -110,25 +161,36 @@ test('a viewer attaching mid-stream sees the replay and live output exactly once
|
|
|
110
161
|
const first = collector();
|
|
111
162
|
await attachTerminal(first.viewer, { id, cols: 100, rows: 30, theme: 'dark' });
|
|
112
163
|
|
|
164
|
+
// A flood long enough that the poll below cannot be delayed past its end.
|
|
165
|
+
// The original 30,000-line flood took ~30 ms on Linux, and under load the
|
|
166
|
+
// poll was delayed past it: the late viewer then had no live output at all
|
|
167
|
+
// and the test timed out waiting for a line the replay already held. That is
|
|
168
|
+
// exactly how it failed on the Linux gate. `TOTAL` is sized per platform for
|
|
169
|
+
// that reason.
|
|
113
170
|
writeTerminalInput(id, new TextEncoder().encode(`seq 1 ${TOTAL}\r`));
|
|
114
171
|
expect(await until(() => numbers(first.text()).length > 2_000)).toBe(true);
|
|
115
172
|
|
|
116
173
|
// Mid-flood by construction: the shell is emitting, the first viewer is
|
|
117
174
|
// receiving, and the coalescer holds bytes that history already has.
|
|
118
|
-
const
|
|
119
|
-
const attachment = await attachTerminal(
|
|
120
|
-
const replayed = numbers(dec.decode(attachment.replay));
|
|
175
|
+
const late = collector();
|
|
176
|
+
const attachment = await attachTerminal(late.viewer, { id, cols: 100, rows: 30, theme: 'dark' });
|
|
177
|
+
const replayed = numbers(dec.decode(attachment.replay), true);
|
|
178
|
+
|
|
179
|
+
// The late viewer must receive live output: that is what proves the attach
|
|
180
|
+
// landed mid-flood and the boundary below is real.
|
|
181
|
+
expect(await until(() => numbers(late.text()).length > 0)).toBe(true);
|
|
121
182
|
|
|
122
|
-
|
|
123
|
-
expect(await
|
|
183
|
+
// The flood ends on its own; wait for both streams to go quiet.
|
|
184
|
+
expect(await settle(() => first.bytes)).toBe(true);
|
|
185
|
+
expect(await settle(() => late.bytes)).toBe(true);
|
|
124
186
|
|
|
125
187
|
const firstLines = numbers(first.text());
|
|
126
|
-
const
|
|
188
|
+
const lateLines = numbers(late.text(), true);
|
|
127
189
|
|
|
128
190
|
// The viewer there from the start saw every line once, in order.
|
|
191
|
+
expect(firstLines.length).toBeGreaterThan(0);
|
|
129
192
|
expect(gap(firstLines)).toBeNull();
|
|
130
193
|
expect(firstLines.length).toBe(new Set(firstLines).size);
|
|
131
|
-
expect(firstLines.at(-1)).toBe(TOTAL);
|
|
132
194
|
|
|
133
195
|
// The late viewer's replay is the retained scrollback, contiguous…
|
|
134
196
|
expect(replayed.length).toBeGreaterThan(0);
|
|
@@ -136,15 +198,16 @@ test('a viewer attaching mid-stream sees the replay and live output exactly once
|
|
|
136
198
|
|
|
137
199
|
// …and the replay plus its live stream is ONE seamless rendering: no line
|
|
138
200
|
// twice, none skipped. Asserted on the CONCATENATION rather than by comparing
|
|
139
|
-
// `
|
|
201
|
+
// `lateLines[0]` to the replay's last line, because the boundary is allowed
|
|
140
202
|
// to land inside a line — the replay is captured mid-flood, and measured on
|
|
141
203
|
// the Linux gate it ended two bytes into `5135`. A per-side comparison then
|
|
142
204
|
// reads that fragment as its own line and reports a gap on a working
|
|
143
205
|
// terminal; the concatenation is what the viewer actually renders, so a
|
|
144
206
|
// duplicate or a hole still fails here.
|
|
145
|
-
const combined = numbers(dec.decode(attachment.replay) +
|
|
146
|
-
expect(
|
|
207
|
+
const combined = numbers(dec.decode(attachment.replay) + late.text(), true);
|
|
208
|
+
expect(lateLines.length).toBeGreaterThan(0);
|
|
147
209
|
expect(gap(combined)).toBeNull();
|
|
148
210
|
expect(new Set(combined).size).toBe(combined.length);
|
|
149
|
-
|
|
211
|
+
// Both viewers saw the same tail, so the late one lost nothing.
|
|
212
|
+
expect(combined.at(-1)).toBe(firstLines.at(-1));
|
|
150
213
|
}, 60_000);
|
|
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';
|
|
|
3
3
|
import { tmpdir } from 'os';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
|
|
6
|
-
import { servePublicAsset } from '@/server/plugins/static';
|
|
6
|
+
import { servePublicAsset, tryServeStatic } from '@/server/plugins/static';
|
|
7
7
|
|
|
8
8
|
// `public/` is the only asset root now: the client bundle is served by Bun's own
|
|
9
9
|
// routing table (`/_bun/*` in dev, `/chunk-*` in production), so there is no
|
|
@@ -120,3 +120,25 @@ describe('servePublicAsset compression', () => {
|
|
|
120
120
|
expect(second?.headers.get('vary')).toBe('accept-encoding');
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
describe('tryServeStatic', () => {
|
|
125
|
+
// The shell's own `<script type="module">` is a `/static/` URL. Answering a
|
|
126
|
+
// missing one with the HTML shell is a MIME mismatch the browser refuses, so
|
|
127
|
+
// the document loads and paints nothing — the blank window this route exists
|
|
128
|
+
// to prevent. A 404 names the missing file instead.
|
|
129
|
+
test('a missing build asset is a 404, not the shell', async () => {
|
|
130
|
+
const response = await tryServeStatic('/static/js/does-not-exist.js');
|
|
131
|
+
expect(response?.status).toBe(404);
|
|
132
|
+
expect(response?.headers.get('content-type')).toContain('text/plain');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('a traversal attempt under /static/ is a 404 too', async () => {
|
|
136
|
+
expect((await tryServeStatic('/static/../secret.txt'))?.status).toBe(404);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// The SPA's own routes are not under `/static/`, so they must still reach the
|
|
140
|
+
// shell — the 404 above is scoped to build assets.
|
|
141
|
+
test('a missing public asset still reaches the app', async () => {
|
|
142
|
+
expect(await tryServeStatic('/nope.svg')).toBeNull();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -169,6 +169,21 @@ export async function servePublicAsset(
|
|
|
169
169
|
return null;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* A build asset that is not on disk.
|
|
174
|
+
*
|
|
175
|
+
* Never the shell: a `<script type="module">` answered with HTML is refused by
|
|
176
|
+
* the browser's MIME check, so the page loads and then paints nothing — the
|
|
177
|
+
* blank window this route exists to prevent. A 404 names the missing file in
|
|
178
|
+
* the network panel instead.
|
|
179
|
+
*/
|
|
180
|
+
function missingAsset(): Response {
|
|
181
|
+
return new Response('Not found', {
|
|
182
|
+
status: 404,
|
|
183
|
+
headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' },
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
172
187
|
/** A file for `pathname`, or null when the request should reach the app. */
|
|
173
188
|
export async function tryServeStatic(pathname: string, request?: Request): Promise<Response | null> {
|
|
174
189
|
// The production bundle's own assets. `scripts/build-client.ts` emits the
|
|
@@ -177,9 +192,17 @@ export async function tryServeStatic(pathname: string, request?: Request): Promi
|
|
|
177
192
|
// makes that `/static/...`, which is this branch. In development the same
|
|
178
193
|
// files are served by Bun's own routing table (`/_bun/asset/*`,
|
|
179
194
|
// `/_bun/client/*`) and never reach here.
|
|
195
|
+
//
|
|
196
|
+
// A miss is a 404, NOT a fall-through to the shell. The shell's own script
|
|
197
|
+
// tag is a `/static/` URL, so a stale build (a cached shell whose hashed
|
|
198
|
+
// chunk was replaced) used to answer that script with HTML: the document
|
|
199
|
+
// loaded, the module never executed, and the window stayed blank with no
|
|
200
|
+
// error anywhere. The SPA's own routes are not under `/static/`, so they
|
|
201
|
+
// still reach the shell below.
|
|
180
202
|
if (pathname.startsWith('/static/')) {
|
|
181
203
|
const filePath = resolveWithin(CLIENT_ROOT, pathname);
|
|
182
|
-
|
|
204
|
+
if (!filePath) return missingAsset();
|
|
205
|
+
return (await serveFile(filePath, ASSET_CACHE, request)) ?? missingAsset();
|
|
183
206
|
}
|
|
184
207
|
// The assembled `@font-face` stylesheet and the files it names. Bun's CSS
|
|
185
208
|
// loader cannot carry either — every local `url()` is resolved, so a bundled
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-61qjr1k0.js";import"./index-4pehdq5h.js";import{Ah}from"./index-pr7gk5eq.js";export{Ah as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Vg}from"./index-3fw3sd10.js";export{Vg as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Kg}from"./index-3fw3sd10.js";export{Kg as default};
|