@floegence/floe-webapp-boot 0.55.1 → 0.56.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/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 S, 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 h, IsolatedOneShotAcquisition as q, clearAcquisitionSource as y, connectIsolatedOneShot as T, materializeHTTPDirectAcquisitionForSource as v, materializeIsolatedOneShot as O, materializePrivateLoopbackAcquisitionForSource as d, synchronizeAcquisitionSourceSnapshot as z } from "./acquisition.js";
6
- import { createAcquisitionConnectionLifecycle as E } from "./acquisition-lifecycle.js";
7
- import { createArtifactDirectConnectionConfig as L, createArtifactTunnelConnectionConfig as B, createHTTPDirectConnectionConfig as F, createPrivateLoopbackDirectConnectionConfig as I, createProxyRuntimeTunnelConnectionConfig as b } from "./connection.js";
8
- import { ServerSentEventStreamError as w, fetchServerSentEvents as M } from "./server-sent-events.js";
9
- import { ProxyBootstrapOwner as j, closeProxyBootstrap as G, createProxyBootstrapOwner as J, synchronizeProxyBootstrap as K } from "./proxy-bootstrap.js";
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
- h as ConnectedAcquisition,
13
- S as ControlplaneRequestError,
14
- q as IsolatedOneShotAcquisition,
15
- j as ProxyBootstrapOwner,
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
- y as clearAcquisitionSource,
18
+ h as clearAcquisitionSource,
19
19
  r as clearLocationHash,
20
- G as closeProxyBootstrap,
21
- T as connectIsolatedOneShot,
22
- E as createAcquisitionConnectionLifecycle,
23
- L as createArtifactDirectConnectionConfig,
24
- B as createArtifactTunnelConnectionConfig,
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
- F as createHTTPDirectConnectionConfig,
26
+ B as createHTTPDirectConnectionConfig,
27
27
  m as createHTTPDirectControlplaneArtifactSource,
28
28
  x as createIsolatedControlplaneArtifactSource,
29
29
  A as createPrivateLoopbackControlplaneArtifactSource,
30
- I as createPrivateLoopbackDirectConnectionConfig,
31
- J as createProxyBootstrapOwner,
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
- v as materializeHTTPDirectAcquisitionForSource,
36
- O as materializeIsolatedOneShot,
37
- d as materializePrivateLoopbackAcquisitionForSource,
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
- z as synchronizeAcquisitionSourceSnapshot,
43
- K as synchronizeProxyBootstrap,
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 U = 1024 * 1024, N = 2 * 1024 * 1024;
10
- function T(n, d) {
11
- if (n === void 0) return d;
12
- if (!Number.isSafeInteger(n) || n <= 0)
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 n;
17
+ return r;
15
18
  }
16
- function R(n) {
17
- return n.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === "text/event-stream";
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(n) {
22
+ async function A(r) {
20
23
  try {
21
- await n.body?.cancel();
24
+ await r.body?.cancel();
22
25
  } catch {
23
26
  }
24
27
  }
25
- async function* O(n, d = {}) {
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, U), D = T(F, N);
36
+ } = d, M = T(c, R), I = T(F, U);
34
37
  let a;
35
38
  try {
36
- a = await m(n, { ...k, signal: L });
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 (!R(a))
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(), B = new TextDecoder("utf-8", { fatal: !0 }), E = new TextEncoder();
56
- let s = "", h = 0, w = [], l, b, u, p = !1, g = !1;
57
- const _ = () => {
58
- h = 0, w = [], l = void 0, u = void 0, p = !1;
59
- }, I = (e, o) => {
60
- if (h += E.encode(e).byteLength + o, h > M)
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
- ...l === void 0 ? {} : { event: l },
73
+ ...v === void 0 ? {} : { event: v },
71
74
  ...b === void 0 ? {} : { id: b },
72
- ...u === void 0 ? {} : { retry: u }
75
+ ...l === void 0 ? {} : { retry: l }
73
76
  };
74
- return _(), f;
77
+ return g(), f;
75
78
  }
76
79
  if (e.startsWith(":")) {
77
80
  x?.();
78
81
  return;
79
82
  }
80
- const r = e.indexOf(":"), v = r < 0 ? e : e.slice(0, r);
81
- let t = r < 0 ? "" : e.slice(r + 1);
82
- switch (t.startsWith(" ") && (t = t.slice(1)), v) {
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
- l = t;
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) && (u = 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 (r) {
106
- throw new i("transport", "failed while reading server-sent event stream", { cause: r });
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
- s += B.decode(e.value, { stream: !e.done });
112
- } catch (r) {
113
- throw new i("malformed_frame", "server-sent event stream is not valid UTF-8", { cause: r });
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
- s += B.decode();
118
- } catch (r) {
119
- throw new i("malformed_frame", "server-sent event stream ends with invalid UTF-8", { cause: r });
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 < s.length; ) {
123
- const r = s.indexOf(`
124
- `, o), v = s.indexOf("\r", 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 (r >= 0 && v >= 0 ? t = Math.min(r, v) : t = Math.max(r, v), t < 0 || s[t] === "\r" && t + 1 === s.length && !e.done) break;
127
- const f = s[t] === "\r" && s[t + 1] === `
128
- ` ? 2 : 1, S = I(s.slice(o, t), f);
129
- o = t + f, S !== void 0 && (yield S);
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 (s = s.slice(o), E.encode(s).byteLength > D)
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
- g = !0;
137
+ S = !0;
135
138
  return;
136
139
  }
137
140
  }
138
141
  } finally {
139
- if (!g)
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-boot",
3
- "version": "0.55.1",
3
+ "version": "0.56.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",