@floegence/floe-webapp-boot 0.55.1 → 0.55.2
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/index.d.ts +1 -1
- package/dist/index.js +25 -24
- package/dist/server-sent-events.d.ts +2 -0
- package/dist/server-sent-events.js +50 -46
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ export type { AcquisitionConnectionLifecycle, AcquisitionConnectionLifecycleOpti
|
|
|
13
13
|
export type { DirectArtifactConnectionOptions, HTTPDirectConnectionOptions, FlowersecConnectionConfig, PrivateLoopbackDirectConnectionOptions, ProxyRuntimeTunnelConnectionOptions, TunnelArtifactConnectionOptions, } from './connection';
|
|
14
14
|
export { createArtifactDirectConnectionConfig, createHTTPDirectConnectionConfig, createArtifactTunnelConnectionConfig, createPrivateLoopbackDirectConnectionConfig, createProxyRuntimeTunnelConnectionConfig, } from './connection';
|
|
15
15
|
export type { FetchServerSentEventsOptions, ServerSentEvent, ServerSentEventStreamErrorCode, } from './server-sent-events';
|
|
16
|
-
export { fetchServerSentEvents, ServerSentEventStreamError } from './server-sent-events';
|
|
16
|
+
export { createServerSentEventRequestInit, fetchServerSentEvents, ServerSentEventStreamError } from './server-sent-events';
|
|
17
17
|
export { closeProxyBootstrap, createProxyBootstrapOwner, ProxyBootstrapOwner, synchronizeProxyBootstrap, } from './proxy-bootstrap';
|
|
18
18
|
export type { ControllerBridgeProxyBootstrapContext, ProxyBootstrapBinding, ProxyBootstrapOwnerOptions, ProxyBootstrapSnapshot, ServiceWorkerProxyBootstrapContext, } from './proxy-bootstrap';
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { clearLocationHash as r, parseHashParam as t } from "./hash.js";
|
|
2
2
|
import { postMessageToOrigins as i, waitForMessage as a } from "./messaging.js";
|
|
3
3
|
import { getSessionStorage as s, removeSessionStorage as l, setSessionStorage as p } from "./storage.js";
|
|
4
|
-
import { ControlplaneRequestError as
|
|
5
|
-
import { AcquisitionError as P, ConnectedAcquisition as
|
|
6
|
-
import { createAcquisitionConnectionLifecycle as
|
|
7
|
-
import { createArtifactDirectConnectionConfig as
|
|
8
|
-
import { ServerSentEventStreamError as w, fetchServerSentEvents as M } from "./server-sent-events.js";
|
|
9
|
-
import { ProxyBootstrapOwner as
|
|
4
|
+
import { ControlplaneRequestError as f, classifyControlplaneFailure as u, createControlplaneArtifactSource as C, createHTTPDirectControlplaneArtifactSource as m, createIsolatedControlplaneArtifactSource as x, createPrivateLoopbackControlplaneArtifactSource as A } from "./artifact-source.js";
|
|
5
|
+
import { AcquisitionError as P, ConnectedAcquisition as q, IsolatedOneShotAcquisition as v, clearAcquisitionSource as h, connectIsolatedOneShot as y, materializeHTTPDirectAcquisitionForSource as T, materializeIsolatedOneShot as E, materializePrivateLoopbackAcquisitionForSource as O, synchronizeAcquisitionSourceSnapshot as d } from "./acquisition.js";
|
|
6
|
+
import { createAcquisitionConnectionLifecycle as D } from "./acquisition-lifecycle.js";
|
|
7
|
+
import { createArtifactDirectConnectionConfig as I, createArtifactTunnelConnectionConfig as L, createHTTPDirectConnectionConfig as B, createPrivateLoopbackDirectConnectionConfig as F, createProxyRuntimeTunnelConnectionConfig as b } from "./connection.js";
|
|
8
|
+
import { ServerSentEventStreamError as w, createServerSentEventRequestInit as R, fetchServerSentEvents as M } from "./server-sent-events.js";
|
|
9
|
+
import { ProxyBootstrapOwner as G, closeProxyBootstrap as J, createProxyBootstrapOwner as K, synchronizeProxyBootstrap as N } from "./proxy-bootstrap.js";
|
|
10
10
|
export {
|
|
11
11
|
P as AcquisitionError,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
q as ConnectedAcquisition,
|
|
13
|
+
f as ControlplaneRequestError,
|
|
14
|
+
v as IsolatedOneShotAcquisition,
|
|
15
|
+
G as ProxyBootstrapOwner,
|
|
16
16
|
w as ServerSentEventStreamError,
|
|
17
17
|
u as classifyControlplaneFailure,
|
|
18
|
-
|
|
18
|
+
h as clearAcquisitionSource,
|
|
19
19
|
r as clearLocationHash,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
J as closeProxyBootstrap,
|
|
21
|
+
y as connectIsolatedOneShot,
|
|
22
|
+
D as createAcquisitionConnectionLifecycle,
|
|
23
|
+
I as createArtifactDirectConnectionConfig,
|
|
24
|
+
L as createArtifactTunnelConnectionConfig,
|
|
25
25
|
C as createControlplaneArtifactSource,
|
|
26
|
-
|
|
26
|
+
B as createHTTPDirectConnectionConfig,
|
|
27
27
|
m as createHTTPDirectControlplaneArtifactSource,
|
|
28
28
|
x as createIsolatedControlplaneArtifactSource,
|
|
29
29
|
A as createPrivateLoopbackControlplaneArtifactSource,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
F as createPrivateLoopbackDirectConnectionConfig,
|
|
31
|
+
K as createProxyBootstrapOwner,
|
|
32
32
|
b as createProxyRuntimeTunnelConnectionConfig,
|
|
33
|
+
R as createServerSentEventRequestInit,
|
|
33
34
|
M as fetchServerSentEvents,
|
|
34
35
|
s as getSessionStorage,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
T as materializeHTTPDirectAcquisitionForSource,
|
|
37
|
+
E as materializeIsolatedOneShot,
|
|
38
|
+
O as materializePrivateLoopbackAcquisitionForSource,
|
|
38
39
|
t as parseHashParam,
|
|
39
40
|
i as postMessageToOrigins,
|
|
40
41
|
l as removeSessionStorage,
|
|
41
42
|
p as setSessionStorage,
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
d as synchronizeAcquisitionSourceSnapshot,
|
|
44
|
+
N as synchronizeProxyBootstrap,
|
|
44
45
|
a as waitForMessage
|
|
45
46
|
};
|
|
@@ -21,4 +21,6 @@ export type FetchServerSentEventsOptions = Omit<RequestInit, 'signal'> & Readonl
|
|
|
21
21
|
maxBufferBytes?: number;
|
|
22
22
|
onActivity?: () => void;
|
|
23
23
|
}>;
|
|
24
|
+
/** Persistent event streams must not hold Chromium's high-priority request budget. */
|
|
25
|
+
export declare function createServerSentEventRequestInit(init?: RequestInit): RequestInit;
|
|
24
26
|
export declare function fetchServerSentEvents(input: RequestInfo | URL, options?: FetchServerSentEventsOptions): AsyncGenerator<ServerSentEvent, void, undefined>;
|
|
@@ -6,23 +6,26 @@ class i extends Error {
|
|
|
6
6
|
super(m, c), this.name = "ServerSentEventStreamError", this.code = d, c.status !== void 0 && (this.status = c.status), c.retryAfter !== void 0 && (this.retryAfter = c.retryAfter);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const R = 1024 * 1024, U = 2 * 1024 * 1024;
|
|
10
|
+
function N(r = {}) {
|
|
11
|
+
return { ...r, priority: r.priority ?? "low" };
|
|
12
|
+
}
|
|
13
|
+
function T(r, d) {
|
|
14
|
+
if (r === void 0) return d;
|
|
15
|
+
if (!Number.isSafeInteger(r) || r <= 0)
|
|
13
16
|
throw new TypeError("server-sent event byte limits must be positive safe integers");
|
|
14
|
-
return
|
|
17
|
+
return r;
|
|
15
18
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
19
|
+
function q(r) {
|
|
20
|
+
return r.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === "text/event-stream";
|
|
18
21
|
}
|
|
19
|
-
async function A(
|
|
22
|
+
async function A(r) {
|
|
20
23
|
try {
|
|
21
|
-
await
|
|
24
|
+
await r.body?.cancel();
|
|
22
25
|
} catch {
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
async function* O(
|
|
28
|
+
async function* O(r, d = {}) {
|
|
26
29
|
const {
|
|
27
30
|
fetch: m = globalThis.fetch,
|
|
28
31
|
maxFrameBytes: c,
|
|
@@ -30,10 +33,10 @@ async function* O(n, d = {}) {
|
|
|
30
33
|
onActivity: x,
|
|
31
34
|
signal: L,
|
|
32
35
|
...k
|
|
33
|
-
} = d, M = T(c,
|
|
36
|
+
} = d, M = T(c, R), I = T(F, U);
|
|
34
37
|
let a;
|
|
35
38
|
try {
|
|
36
|
-
a = await m(
|
|
39
|
+
a = await m(r, N({ ...k, signal: L }));
|
|
37
40
|
} catch (e) {
|
|
38
41
|
throw new i("transport", "failed to open server-sent event stream", { cause: e });
|
|
39
42
|
}
|
|
@@ -45,46 +48,46 @@ async function* O(n, d = {}) {
|
|
|
45
48
|
{ status: a.status, retryAfter: e }
|
|
46
49
|
);
|
|
47
50
|
}
|
|
48
|
-
if (!
|
|
51
|
+
if (!q(a))
|
|
49
52
|
throw await A(a), new i(
|
|
50
53
|
"unsupported_content_type",
|
|
51
54
|
"server-sent event response must use text/event-stream"
|
|
52
55
|
);
|
|
53
56
|
if (a.body === null)
|
|
54
57
|
throw new i("malformed_frame", "server-sent event response has no body");
|
|
55
|
-
const y = a.body.getReader(),
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
h = 0, w = [],
|
|
59
|
-
},
|
|
60
|
-
if (h +=
|
|
58
|
+
const y = a.body.getReader(), E = new TextDecoder("utf-8", { fatal: !0 }), B = new TextEncoder();
|
|
59
|
+
let n = "", h = 0, w = [], v, b, l, p = !1, S = !1;
|
|
60
|
+
const g = () => {
|
|
61
|
+
h = 0, w = [], v = void 0, l = void 0, p = !1;
|
|
62
|
+
}, D = (e, o) => {
|
|
63
|
+
if (h += B.encode(e).byteLength + o, h > M)
|
|
61
64
|
throw new i("oversized_frame", "server-sent event frame exceeds its byte limit");
|
|
62
65
|
if (e === "") {
|
|
63
66
|
if (!p) {
|
|
64
|
-
|
|
67
|
+
g();
|
|
65
68
|
return;
|
|
66
69
|
}
|
|
67
70
|
const f = {
|
|
68
71
|
data: w.join(`
|
|
69
72
|
`),
|
|
70
|
-
...
|
|
73
|
+
...v === void 0 ? {} : { event: v },
|
|
71
74
|
...b === void 0 ? {} : { id: b },
|
|
72
|
-
...
|
|
75
|
+
...l === void 0 ? {} : { retry: l }
|
|
73
76
|
};
|
|
74
|
-
return
|
|
77
|
+
return g(), f;
|
|
75
78
|
}
|
|
76
79
|
if (e.startsWith(":")) {
|
|
77
80
|
x?.();
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
|
-
const
|
|
81
|
-
let t =
|
|
82
|
-
switch (t.startsWith(" ") && (t = t.slice(1)),
|
|
83
|
+
const s = e.indexOf(":"), u = s < 0 ? e : e.slice(0, s);
|
|
84
|
+
let t = s < 0 ? "" : e.slice(s + 1);
|
|
85
|
+
switch (t.startsWith(" ") && (t = t.slice(1)), u) {
|
|
83
86
|
case "data":
|
|
84
87
|
p = !0, w.push(t);
|
|
85
88
|
break;
|
|
86
89
|
case "event":
|
|
87
|
-
|
|
90
|
+
v = t;
|
|
88
91
|
break;
|
|
89
92
|
case "id":
|
|
90
93
|
t.includes("\0") || (b = t);
|
|
@@ -92,7 +95,7 @@ async function* O(n, d = {}) {
|
|
|
92
95
|
case "retry":
|
|
93
96
|
if (/^[0-9]+$/u.test(t)) {
|
|
94
97
|
const f = Number(t);
|
|
95
|
-
Number.isSafeInteger(f) && (
|
|
98
|
+
Number.isSafeInteger(f) && (l = f);
|
|
96
99
|
}
|
|
97
100
|
break;
|
|
98
101
|
}
|
|
@@ -102,41 +105,41 @@ async function* O(n, d = {}) {
|
|
|
102
105
|
let e;
|
|
103
106
|
try {
|
|
104
107
|
e = await y.read();
|
|
105
|
-
} catch (
|
|
106
|
-
throw new i("transport", "failed while reading server-sent event stream", { cause:
|
|
108
|
+
} catch (s) {
|
|
109
|
+
throw new i("transport", "failed while reading server-sent event stream", { cause: s });
|
|
107
110
|
}
|
|
108
111
|
if (e.value !== void 0) {
|
|
109
112
|
x?.();
|
|
110
113
|
try {
|
|
111
|
-
|
|
112
|
-
} catch (
|
|
113
|
-
throw new i("malformed_frame", "server-sent event stream is not valid UTF-8", { cause:
|
|
114
|
+
n += E.decode(e.value, { stream: !e.done });
|
|
115
|
+
} catch (s) {
|
|
116
|
+
throw new i("malformed_frame", "server-sent event stream is not valid UTF-8", { cause: s });
|
|
114
117
|
}
|
|
115
118
|
} else if (e.done)
|
|
116
119
|
try {
|
|
117
|
-
|
|
118
|
-
} catch (
|
|
119
|
-
throw new i("malformed_frame", "server-sent event stream ends with invalid UTF-8", { cause:
|
|
120
|
+
n += E.decode();
|
|
121
|
+
} catch (s) {
|
|
122
|
+
throw new i("malformed_frame", "server-sent event stream ends with invalid UTF-8", { cause: s });
|
|
120
123
|
}
|
|
121
124
|
let o = 0;
|
|
122
|
-
for (; o <
|
|
123
|
-
const
|
|
124
|
-
`, o),
|
|
125
|
+
for (; o < n.length; ) {
|
|
126
|
+
const s = n.indexOf(`
|
|
127
|
+
`, o), u = n.indexOf("\r", o);
|
|
125
128
|
let t = -1;
|
|
126
|
-
if (
|
|
127
|
-
const f =
|
|
128
|
-
` ? 2 : 1,
|
|
129
|
-
o = t + f,
|
|
129
|
+
if (s >= 0 && u >= 0 ? t = Math.min(s, u) : t = Math.max(s, u), t < 0 || n[t] === "\r" && t + 1 === n.length && !e.done) break;
|
|
130
|
+
const f = n[t] === "\r" && n[t + 1] === `
|
|
131
|
+
` ? 2 : 1, _ = D(n.slice(o, t), f);
|
|
132
|
+
o = t + f, _ !== void 0 && (yield _);
|
|
130
133
|
}
|
|
131
|
-
if (
|
|
134
|
+
if (n = n.slice(o), B.encode(n).byteLength > I)
|
|
132
135
|
throw new i("oversized_buffer", "server-sent event pending buffer exceeds its byte limit");
|
|
133
136
|
if (e.done) {
|
|
134
|
-
|
|
137
|
+
S = !0;
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
} finally {
|
|
139
|
-
if (!
|
|
142
|
+
if (!S)
|
|
140
143
|
try {
|
|
141
144
|
await y.cancel();
|
|
142
145
|
} catch {
|
|
@@ -146,5 +149,6 @@ async function* O(n, d = {}) {
|
|
|
146
149
|
}
|
|
147
150
|
export {
|
|
148
151
|
i as ServerSentEventStreamError,
|
|
152
|
+
N as createServerSentEventRequestInit,
|
|
149
153
|
O as fetchServerSentEvents
|
|
150
154
|
};
|