@streamotter/workbench 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/THIRD_PARTY_LICENSES.txt +133 -0
- package/dist/app.js +5 -0
- package/dist/app.js.map +7 -0
- package/dist/index.html +16 -0
- package/dist/styles.css +129 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Orca Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @streamotter/workbench
|
|
2
|
+
|
|
3
|
+
The static assets of the StreamOtter local workbench. You don't use this package directly: [`@streamotter/cli`](https://www.npmjs.com/package/@streamotter/cli) depends on it, and `streamotter dev` serves it from the loopback management origin (default `http://127.0.0.1:7401/`) behind a per-run token and a restrictive Content Security Policy. In the workbench you can check source connections, edit and validate candidate configuration, preview a live subscription as a development principal, inspect payload-free delivery traces, and export the canonical `streamotter.json`. `streamotter start` (production) never serves it. See the [CLI guide](https://www.npmjs.com/package/@streamotter/cli) for the walkthrough.
|
|
4
|
+
|
|
5
|
+
> **Release candidate.** `0.1.0-rc.1` is published under the `next` tag.
|
|
6
|
+
|
|
7
|
+
`dist/THIRD_PARTY_LICENSES.txt` lists the MIT-licensed Socket.IO client packages bundled into `dist/app.js`.
|
|
8
|
+
|
|
9
|
+
[Repository](https://github.com/jfricano/StreamOtter) · [Issues](https://github.com/jfricano/StreamOtter/issues) · MIT License © 2026 Orca Solutions
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
The StreamOtter workbench bundle (app.js) includes the following third-party packages.
|
|
2
|
+
|
|
3
|
+
@socket.io/component-emitter@3.1.2 (MIT)
|
|
4
|
+
|
|
5
|
+
(The MIT License)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2014 Component contributors <dev@component.io>
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person
|
|
10
|
+
obtaining a copy of this software and associated documentation
|
|
11
|
+
files (the "Software"), to deal in the Software without
|
|
12
|
+
restriction, including without limitation the rights to use,
|
|
13
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the
|
|
15
|
+
Software is furnished to do so, subject to the following
|
|
16
|
+
conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be
|
|
19
|
+
included in all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
22
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
23
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
26
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
27
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
28
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
+
|
|
30
|
+
------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
engine.io-client@6.6.6 (MIT)
|
|
33
|
+
|
|
34
|
+
(The MIT License)
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2014-present Guillermo Rauch and Socket.IO contributors
|
|
37
|
+
|
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
39
|
+
a copy of this software and associated documentation files (the
|
|
40
|
+
'Software'), to deal in the Software without restriction, including
|
|
41
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
42
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
43
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
44
|
+
the following conditions:
|
|
45
|
+
|
|
46
|
+
The above copyright notice and this permission notice shall be
|
|
47
|
+
included in all copies or substantial portions of the Software.
|
|
48
|
+
|
|
49
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
50
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
51
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
52
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
53
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
54
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
55
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
56
|
+
|
|
57
|
+
------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
engine.io-parser@5.2.3 (MIT)
|
|
60
|
+
|
|
61
|
+
(The MIT License)
|
|
62
|
+
|
|
63
|
+
Copyright (c) 2014-present Guillermo Rauch and Socket.IO contributors
|
|
64
|
+
|
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
66
|
+
a copy of this software and associated documentation files (the
|
|
67
|
+
'Software'), to deal in the Software without restriction, including
|
|
68
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
69
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
70
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
71
|
+
the following conditions:
|
|
72
|
+
|
|
73
|
+
The above copyright notice and this permission notice shall be
|
|
74
|
+
included in all copies or substantial portions of the Software.
|
|
75
|
+
|
|
76
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
77
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
78
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
79
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
80
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
81
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
82
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
83
|
+
|
|
84
|
+
------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
socket.io-client@4.8.3 (MIT)
|
|
87
|
+
|
|
88
|
+
The MIT License (MIT)
|
|
89
|
+
|
|
90
|
+
Copyright (c) 2014-present Guillermo Rauch and Socket.IO contributors
|
|
91
|
+
|
|
92
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
93
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
94
|
+
in the Software without restriction, including without limitation the rights
|
|
95
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
96
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
97
|
+
furnished to do so, subject to the following conditions:
|
|
98
|
+
|
|
99
|
+
The above copyright notice and this permission notice shall be included in
|
|
100
|
+
all copies or substantial portions of the Software.
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
103
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
104
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
105
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
106
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
107
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
108
|
+
THE SOFTWARE.
|
|
109
|
+
|
|
110
|
+
------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
socket.io-parser@4.2.7 (MIT)
|
|
113
|
+
|
|
114
|
+
(The MIT License)
|
|
115
|
+
|
|
116
|
+
Copyright (c) 2014-present Guillermo Rauch and Socket.IO contributors
|
|
117
|
+
|
|
118
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
119
|
+
this software and associated documentation files (the 'Software'), to deal in
|
|
120
|
+
the Software without restriction, including without limitation the rights to
|
|
121
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
122
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
123
|
+
subject to the following conditions:
|
|
124
|
+
|
|
125
|
+
The above copyright notice and this permission notice shall be included in all
|
|
126
|
+
copies or substantial portions of the Software.
|
|
127
|
+
|
|
128
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
129
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
130
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
131
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
132
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
133
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var nr=Object.defineProperty;var sr=(r,e)=>{for(var t in e)nr(r,t,{get:e[t],enumerable:!0})};var _=class extends Error{status;error;constructor(e,t){super(t.message),this.status=e,this.error=t}},fe=class{#e;constructor(e){this.#e=e}async#r(e,t,n){let s=await fetch(`/management/v1${t}`,{method:e,headers:{authorization:`Bearer ${this.#e}`,...n===void 0?{}:{"content-type":"application/json"}},...n===void 0?{}:{body:JSON.stringify(n)},cache:"no-store",credentials:"omit"}),o;try{o=await s.json()}catch{throw new _(s.status,{code:"INTERNAL",message:`Unexpected response (${s.status}).`,retryable:!0,requestId:""})}if(!o.ok)throw new _(s.status,o.error);return o.data}health(){return this.#r("GET","/health")}capabilities(){return this.#r("GET","/capabilities")}sources(){return this.#r("GET","/sources")}channels(){return this.#r("GET","/channels")}config(){return this.#r("GET","/config")}principals(){return this.#r("GET","/dev/principals")}checkSource(e){return this.#r("POST","/source-checks",{sourceId:e})}resumeSource(e){return this.#r("POST","/sources/resume",{sourceId:e})}validate(e){return this.#r("POST","/config/validate",{config:e})}export(e){return this.#r("POST","/config/export",{config:e})}previewSession(e){return this.#r("POST","/preview-sessions",{fixturePrincipalRef:e})}advance(e,t){return this.#r("POST","/dev/fixtures/advance",{sourceId:e,count:t})}disconnect(e){return this.#r("POST","/dev/disconnect",{previewSessionId:e})}traces(e){let t=new URLSearchParams;for(let[s,o]of Object.entries(e))o!==void 0&&o!==""&&t.set(s,String(o));let n=t.size===0?"":`?${t.toString()}`;return this.#r("GET",`/traces${n}`)}};function i(r,e={},...t){let n=document.createElement(r);for(let[s,o]of Object.entries(e))o==null||o===!1||(s.startsWith("on")&&typeof o=="function"?n.addEventListener(s.slice(2).toLowerCase(),o):s==="class"?n.className=String(o):o===!0?n.setAttribute(s,""):n.setAttribute(s,String(o)));for(let s of t.flat())s==null||s===!1||n.append(s instanceof Node?s:String(s));return n}function p(r,...e){r.replaceChildren(...e.flat().filter(t=>t!=null&&t!==!1).map(t=>t instanceof Node?t:String(t)))}function C(r,e){return i("span",{class:`pill ${e}`},r)}function te(r){let e=new Date(r);return Number.isNaN(e.getTime())?r:`${e.toLocaleTimeString([],{hour12:!1})}.${String(e.getMilliseconds()).padStart(3,"0")}`}function Ye(r,e=8){return r===void 0?"":r.slice(0,e)}function me(r){return`${JSON.stringify(r,null,2)}
|
|
2
|
+
`}function Y(r){try{return JSON.stringify(JSON.parse(r.candidateText))!==JSON.stringify(r.active.config)}catch{return!0}}function Qe(r){switch(r){case"healthy":return"ok";case"starting":return"neutral";case"degraded":return"warn";case"paused":return"bad";default:return"neutral"}}var ir={ok:"\u2713",failed:"\u2717",skipped:"\u2013"};function Ge(r,e){let t=i("tbody"),n=i("div",{class:"stack"}),s=async()=>{try{let[{items:l},u]=await Promise.all([e.api.sources(),e.api.health()]);e.sources=l,e.ready=u.ready,e.refreshShell(),a()}catch(l){p(n,i("div",{class:"banner bad"},l.message))}},o=(l,u)=>{let h=u.find(m=>m.outcome==="failed");p(n,i("section",{class:"panel"},i("h3",{},`Connection check: ${l}`),h===void 0?i("p",{class:"muted"},"Every stage that applies to this source succeeded."):i("p",{},"The first failing stage is ",i("strong",{},h.stage),". Later stages were skipped."),i("ul",{class:"steps"},u.map(m=>i("li",{},i("span",{class:m.outcome,"aria-label":m.outcome},ir[m.outcome]),i("span",{class:"mono"},m.stage),i("span",{},m.message))))))},c=(l,u,h=!1)=>{let m=i("button",{class:h?"primary":"",type:"button"},l);return m.addEventListener("click",async()=>{m.disabled=!0;try{await u()}catch(g){let x=g instanceof _?`${g.error.code}: ${g.error.message}`:g.message;p(n,i("div",{class:"banner bad",role:"alert"},x))}finally{m.disabled=!1}}),m},a=()=>{p(t,e.sources.map(l=>{let u=e.active.config.sources[l.sourceId],h=u?.kind==="kafka"?`${u.topics.join(", ")} \xB7 group ${u.consumerGroup} \xB7 ${u.startFrom}`:u?.kind==="fixture"?`fixture "${u.fixtureRef}"`:"",m=i("input",{type:"number",min:1,max:100,value:1,"aria-label":`Records to advance for ${l.sourceId}`,class:"small"});return i("tr",{},i("td",{},i("strong",{},l.sourceId),i("div",{class:"muted small"},h)),i("td",{},l.kind),i("td",{},C(l.status,Qe(l.status)),l.reason===void 0?null:i("div",{class:"small mono"},l.reason)),i("td",{},i("div",{class:"row"},c("Check connection",async()=>o(l.sourceId,(await e.api.checkSource(l.sourceId)).steps)),l.status==="paused"?c("Resume at uncommitted position",async()=>{await e.api.resumeSource(l.sourceId),await s()},!0):null,l.kind==="fixture"?[m,c("Advance fixture",async()=>{let{advanced:g}=await e.api.advance(l.sourceId,Number(m.value));p(n,i("div",{class:"banner info"},`Advanced ${g} record(s) of "${l.sourceId}". See Inspect for their path.`)),await s()})]:null)))}))};p(r,i("section",{class:"panel stack"},i("div",{},i("h2",{},"Connect"),i("p",{class:"lede"},"Sources are configured stream connections. A check reports each stage\u2014resolve, connect, TLS, authenticate, metadata\u2014so a failure names where it stopped. Credentials are referenced by environment variable and never shown.")),i("div",{class:"table-wrap"},i("table",{},i("thead",{},i("tr",{},i("th",{},"Source"),i("th",{},"Kind"),i("th",{},"Status"),i("th",{},"Actions"))),t)),i("div",{class:"row"},c("Refresh",s))),n,i("section",{class:"panel"},i("h3",{},"What the statuses mean"),i("dl",{class:"explain"},i("dt",{},"healthy"),i("dd",{},"Consuming; subscriptions on this source can synchronize."),i("dt",{},"degraded"),i("dd",{},"Connection lost or the consumer group is rebalancing. Views are stale and resynchronize automatically when it recovers."),i("dt",{},"paused"),i("dd",{},"An unprocessable record stopped consumption without committing it. Fix the cause, then resume: the same record is retried, never skipped.")))),a(),s()}function Xe(r){return r===void 0?"unknown schema":r.type!=="object"?r.type:Object.entries(r.properties).map(([e,t])=>{let n=r.required.includes(e)?"":"?",s=t.type==="string"&&t.enum!==void 0?t.enum.map(o=>JSON.stringify(o)).join(" | "):t.type;return`${e}${n}: ${s}`}).join(", ")}function Ze(r,e){let t=i("textarea",{spellcheck:"false","aria-label":"Candidate configuration JSON"});t.value=e.candidateText;let n=i("div"),s=i("div"),o=()=>{p(n,Y(e)?i("div",{class:"banner warn",role:"status"},i("strong",{},"Candidate only. "),`The running gateway still uses the active configuration (sha256:${e.active.fingerprint.slice(0,12)}\u2026). `,"Export the candidate from the Export tab, save it as streamotter.json, and restart streamotter dev to apply it."):i("div",{class:"banner info",role:"status"},"The candidate matches the active configuration."))};t.addEventListener("input",()=>{e.candidateText=t.value,o(),e.refreshShell()});let c=i("button",{class:"primary",type:"button"},"Validate candidate");c.addEventListener("click",async()=>{let u;try{u=JSON.parse(t.value)}catch(h){p(s,i("div",{class:"banner bad",role:"alert"},`Not valid JSON: ${h.message}`));return}try{let h=await e.api.validate(u);p(s,h.valid?i("div",{class:"banner info"},"Valid. Structural, schema, and reference checks passed. Handlers and brokers were not contacted."):i("div",{class:"banner bad",role:"alert"},i("strong",{},`${h.issues.length} issue(s)`),i("ul",{class:"issues"},h.issues.map(m=>i("li",{},i("code",{},m.path||"/"),` ${m.code}: ${m.message}`)))))}catch(h){p(s,i("div",{class:"banner bad",role:"alert"},h instanceof _?h.error.message:h.message))}});let a=i("button",{type:"button"},"Reset to active");a.addEventListener("click",()=>{e.candidateText=me(e.active.config),t.value=e.candidateText,p(s),o(),e.refreshShell()});let l=e.active.config;p(r,i("section",{class:"panel stack"},i("div",{},i("h2",{},"Define"),i("p",{class:"lede"},"Channels are the application contract browsers subscribe to. They are independent of topic names; each has one deployed version, a parameter schema, a payload schema, and trusted handlers registered in server code.")),i("div",{class:"table-wrap"},i("table",{},i("thead",{},i("tr",{},i("th",{},"Channel"),i("th",{},"Version"),i("th",{},"Source"),i("th",{},"Parameters"),i("th",{},"Payload"),i("th",{},"Delivery"))),i("tbody",{},e.channels.map(u=>i("tr",{},i("td",{},i("strong",{},u.name)),i("td",{},String(u.version)),i("td",{},u.source),i("td",{},i("code",{},u.paramsSchema),i("div",{class:"muted small mono"},Xe(l.schemas[u.paramsSchema]))),i("td",{},i("code",{},u.payloadSchema),i("div",{class:"muted small mono"},Xe(l.schemas[u.payloadSchema]))),i("td",{},C("state \xB7 resync on overflow","neutral")))))))),i("section",{class:"panel stack"},i("div",{class:"row"},i("h3",{},"Candidate configuration"),i("span",{class:"muted small"},"Edits here are never applied to the running gateway.")),n,t,i("div",{class:"row"},c,a),s)),o()}function et(r,e){let t=i("div",{class:"stack"}),n=i("button",{class:"primary",type:"button"},"Export candidate");n.addEventListener("click",async()=>{let s;try{s=JSON.parse(e.candidateText)}catch(o){p(t,i("div",{class:"banner bad",role:"alert"},`The candidate is not valid JSON: ${o.message}`));return}try{let o=await e.api.export(s),c=URL.createObjectURL(new Blob([o.content],{type:"application/json"})),a=Y(e);p(t,a?i("div",{class:"banner warn",role:"status"},i("strong",{},"Restart required. "),"Save this file as streamotter.json and restart streamotter dev. The running gateway is unchanged until then."):i("div",{class:"banner info",role:"status"},"This export matches the active configuration."),i("div",{class:"row"},i("a",{href:c,download:o.filename,class:"mono"},`Download ${o.filename}`),i("span",{class:"muted small mono"},`sha256:${o.fingerprint}`)),i("h3",{},"Verify and generate from the CLI"),i("pre",{class:"data-view"},["streamotter validate --config streamotter.json",`# expect: Fingerprint: sha256:${o.fingerprint}`,"streamotter generate --config streamotter.json --out src/generated"].join(`
|
|
3
|
+
`)),i("h3",{id:"canonical-heading"},"Canonical content"),i("pre",{class:"data-view","aria-labelledby":"canonical-heading"},o.content))}catch(o){if(o instanceof _&&Array.isArray(o.error.details?.issues)){let c=o.error.details.issues;p(t,i("div",{class:"banner bad",role:"alert"},i("strong",{},"Not exported: the candidate is invalid."),i("ul",{class:"issues"},c.map(a=>i("li",{},i("code",{},a.path||"/"),` ${a.code}: ${a.message}`)))))}else p(t,i("div",{class:"banner bad",role:"alert"},o.message))}}),p(r,i("section",{class:"panel stack"},i("div",{},i("h2",{},"Export"),i("p",{class:"lede"},"Exports produce canonical, reviewable streamotter.json (sorted keys, secrets only as environment references). The workbench never writes files or changes the running gateway; the CLI validates the same fingerprint and generates your AppChannels types.")),i("div",{class:"row"},n),t),i("section",{class:"panel stack"},i("h3",{},"Integrate"),i("p",{},"Generated types plus the TypeScript SDK:"),i("pre",{class:"data-view"},['import { createClient } from "@streamotter/client";','import { channelVersions, type AppChannels } from "./generated/streamotter.generated.js";',"",`const client = createClient<AppChannels>({ origin: "${e.gatewayOrigin}", getToken: ({ signal }) => session.getAccessToken(signal) });`,`const sub = client.subscribe("${e.channels[0]?.name??"channelName"}", { channelVersion: channelVersions.${e.channels[0]?.name??"channelName"}, params });`,'sub.on("data", event => render(event.data));','sub.on("state", ({ state }) => showDeliveryState(state)); // "live" means synchronized','sub.on("error", error => showStreamError(error));',"await sub.ready();","// On unmount: await sub.unsubscribe();"].join(`
|
|
4
|
+
`))))}var or=[["source","A record was read from the source."],["validate","Size, encoding, and JSON checks. Rejections pause the source."],["map","Your map handler selected public state. Filtered means it returned no outputs."],["authorize","A handshake or subscription was authorized or rejected."],["snapshot","Your snapshot handler returned authoritative state for a subscription."],["queue","Admission into a subscription's bounded buffer. Filtered: older or duplicate revision. Rejected: overflow."],["send","A data frame was sent to the SDK."],["receipt","The SDK confirmed receipt of a frame (not application processing or rendering)."],["commit","Source progress was committed after processing. Not evidence of browser delivery."]],ar={ok:"ok",filtered:"neutral",rejected:"warn",failed:"bad"},tt=1e3;function rt(r,e){let t=[],n,s=null,o=i("tbody"),c=i("div"),a=i("select",{"aria-label":"Filter by source"},i("option",{value:""},"All sources"),e.sources.map(y=>i("option",{value:y.sourceId},y.sourceId))),l=i("select",{"aria-label":"Filter by channel"},i("option",{value:""},"All channels"),e.channels.map(y=>i("option",{value:y.name},y.name))),u=i("select",{"aria-label":"Filter by outcome"},i("option",{value:""},"All outcomes"),["ok","filtered","rejected","failed"].map(y=>i("option",{value:y},y))),h=i("input",{type:"checkbox",checked:!0,"aria-label":"Follow new traces"}),m=()=>p(o,t.length===0?i("tr",{},i("td",{colspan:7,class:"muted"},"No traces yet. Start a preview or advance a fixture to see records move through the stages.")):[...t].reverse().map(y=>i("tr",{},i("td",{class:"mono small"},te(y.at)),i("td",{},i("code",{},y.stage)),i("td",{},C(y.outcome,ar[y.outcome])),i("td",{},y.sourceId??""),i("td",{},y.channel??""),i("td",{class:"mono small",title:y.subscriptionId??""},Ye(y.subscriptionId)),i("td",{class:"mono small"},y.errorCode??"")))),g=async y=>{y&&(t.length=0,n=void 0);try{let T=await e.api.traces({limit:n===void 0?200:500,...n===void 0?{}:{cursor:n},sourceId:a.value,channel:l.value,outcome:u.value});t.push(...T.items),t.length>tt&&t.splice(0,t.length-tt),T.nextCursor!==null&&(n=T.nextCursor),p(c),m()}catch(T){if(T instanceof _&&T.error.code==="TRACE_CURSOR_EXPIRED"){p(c,i("div",{class:"banner warn"},"Older traces were evicted from the bounded buffer; showing the latest.")),await g(!0);return}p(c,i("div",{class:"banner bad"},T.message))}},x=()=>{s!==null&&clearInterval(s),s=h.checked?setInterval(()=>{g(!1)},1e3):null};for(let y of[a,l,u])y.addEventListener("change",()=>{g(!0)});h.addEventListener("change",x);let O=i("button",{type:"button"},"Reload latest");return O.addEventListener("click",()=>{g(!0)}),p(r,i("section",{class:"panel stack"},i("div",{},i("h2",{},"Inspect"),i("p",{class:"lede"},"Recent trace metadata from the gateway's bounded in-memory buffer. Payloads and credentials are never captured; traces are diagnostics, not a recovery log.")),i("div",{class:"row"},a,l,u,i("label",{class:"row"},h,i("span",{},"Follow")),O),c,i("div",{class:"table-wrap"},i("table",{},i("thead",{},i("tr",{},["Time","Stage","Outcome","Source","Channel","Subscription","Error"].map(y=>i("th",{},y)))),o))),i("section",{class:"panel"},i("h3",{},"Stages"),i("dl",{class:"explain"},or.flatMap(([y,T])=>[i("dt",{},i("code",{},y)),i("dd",{},T)])))),m(),g(!0),x(),()=>{s!==null&&clearInterval(s)}}var nt={UNAUTHENTICATED:"Authentication is required or has expired.",FORBIDDEN:"This subscription is not permitted.",INVALID_PARAMS:"The channel parameters are invalid.",CHANNEL_NOT_FOUND:"The channel is not configured.",CHANNEL_VERSION_UNSUPPORTED:"The requested channel version is not deployed.",SOURCE_UNAVAILABLE:"The source is unavailable; this view may be stale.",INVALID_PAYLOAD:"The data did not match its declared contract.",OVERLOADED:"The gateway is over its configured limits; try again later.",RESYNC_REQUIRED:"Automatic synchronization stopped; call resync() to try again.",UNSUPPORTED_CAPABILITY:"The requested capability is not supported by this gateway.",INVALID_REQUEST:"The request is malformed.",CONFIG_INVALID:"The configuration is invalid.",TIMEOUT:"The operation did not complete before its deadline.",CANCELLED:"The operation was cancelled.",CLIENT_CLOSED:"The client is closed; create a new client.",HANDLER_FAILED:"An application handler failed.",REVISION_CONFLICT:"Conflicting data was received for the same revision.",TRACE_CURSOR_EXPIRED:"The trace cursor has expired; start from the latest traces.",INTERNAL:"An unexpected error occurred."},ge={UNAUTHENTICATED:!0,FORBIDDEN:!1,INVALID_PARAMS:!1,CHANNEL_NOT_FOUND:!1,CHANNEL_VERSION_UNSUPPORTED:!1,SOURCE_UNAVAILABLE:!0,INVALID_PAYLOAD:!1,OVERLOADED:!0,RESYNC_REQUIRED:!0,UNSUPPORTED_CAPABILITY:!1,INVALID_REQUEST:!1,CONFIG_INVALID:!1,TIMEOUT:!0,CANCELLED:!1,CLIENT_CLOSED:!1,HANDLER_FAILED:!0,REVISION_CONFLICT:!1,TRACE_CURSOR_EXPIRED:!1,INTERNAL:!0},cn=Object.keys(ge);function Ie(r){return typeof r=="string"&&Object.hasOwn(ge,r)}var v=class extends Error{code;retryable;requestId;details;constructor(e,t={}){super(t.message??nt[e]),Object.defineProperty(this,"message",{enumerable:!0,writable:!0,configurable:!0,value:this.message}),Object.defineProperty(this,"name",{enumerable:!1,value:"StreamOtterError"}),this.code=e,this.retryable=t.retryable??ge[e],this.requestId=t.requestId??"",t.details!==void 0&&(this.details=t.details)}toJSON(){return cr(this)}};function E(r,e={}){let t={code:r,message:e.message??nt[r],retryable:e.retryable??ge[r],requestId:e.requestId??""};return e.details!==void 0&&(t.details=e.details),t}function cr(r){let e={code:r.code,message:r.message,retryable:r.retryable,requestId:r.requestId};return r.details!==void 0&&(e.details=r.details),e}function re(r){if(typeof r!="object"||r===null)return!1;let e=r;return Ie(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"&&typeof e.requestId=="string"}function H(r){if(r instanceof v)return r;let e={message:r.message,retryable:r.retryable,requestId:r.requestId};return r.details!==void 0&&(e.details=r.details),new v(r.code,e)}var lr=/^(?:0|[1-9][0-9]{0,38})$/;var hr=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;function st(r){return typeof r=="string"&&lr.test(r)}function ye(r,e){return r.length!==e.length?r.length<e.length?-1:1:r===e?0:r<e?-1:1}function it(r){return typeof r!="string"||!hr.test(r)?Number.NaN:Date.parse(r)}function j(r){if(typeof r!="object"||r===null||Array.isArray(r))return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}var ot="/streamotter/socket.io";var un=Object.freeze({protocolVersion:1,configVersions:Object.freeze([1]),transport:"socket.io",deliveryModes:Object.freeze(["state"]),operations:Object.freeze(["subscribe","unsubscribe","resync","receipt"])}),N=Object.freeze({hello:"so:hello",state:"so:state",data:"so:data",error:"so:error",subscribe:"so:subscribe",unsubscribe:"so:unsubscribe",resync:"so:resync",receipt:"so:receipt"}),Le=1e4,at=5e3,ct=5e3,lt=1e4,be=3e4,ht=3e4,ut=500,dt=3e4;var dn=5*6e4;var R=Object.create(null);R.open="0";R.close="1";R.ping="2";R.pong="3";R.message="4";R.upgrade="5";R.noop="6";var ne=Object.create(null);Object.keys(R).forEach(r=>{ne[R[r]]=r});var se={type:"error",data:"parser error"};var mt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",gt=typeof ArrayBuffer=="function",yt=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,ie=({type:r,data:e},t,n)=>mt&&e instanceof Blob?t?n(e):pt(e,n):gt&&(e instanceof ArrayBuffer||yt(e))?t?n(e):pt(new Blob([e]),n):n(R[r]+(e||"")),pt=(r,e)=>{let t=new FileReader;return t.onload=function(){let n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(r)};function ft(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var Pe;function bt(r,e){if(mt&&r.data instanceof Blob)return r.data.arrayBuffer().then(ft).then(e);if(gt&&(r.data instanceof ArrayBuffer||yt(r.data)))return e(ft(r.data));ie(r,!1,t=>{Pe||(Pe=new TextEncoder),e(Pe.encode(t))})}var Et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",oe=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<Et.length;r++)oe[Et.charCodeAt(r)]=r;var vt=r=>{let e=r.length*.75,t=r.length,n,s=0,o,c,a,l;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let u=new ArrayBuffer(e),h=new Uint8Array(u);for(n=0;n<t;n+=4)o=oe[r.charCodeAt(n)],c=oe[r.charCodeAt(n+1)],a=oe[r.charCodeAt(n+2)],l=oe[r.charCodeAt(n+3)],h[s++]=o<<2|c>>4,h[s++]=(c&15)<<4|a>>2,h[s++]=(a&3)<<6|l&63;return u};var ur=typeof ArrayBuffer=="function",ae=(r,e)=>{if(typeof r!="string")return{type:"message",data:St(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:dr(r.substring(1),e)}:ne[t]?r.length>1?{type:ne[t],data:r.substring(1)}:{type:ne[t]}:se},dr=(r,e)=>{if(ur){let t=vt(r);return St(t,e)}else return{base64:!0,data:r}},St=(r,e)=>e==="blob"?r instanceof Blob?r:new Blob([r]):r instanceof ArrayBuffer?r:r.buffer;var wt="",Tt=(r,e)=>{let t=r.length,n=new Array(t),s=0;r.forEach((o,c)=>{ie(o,!1,a=>{n[c]=a,++s===t&&e(n.join(wt))})})},_t=(r,e)=>{let t=r.split(wt),n=[];for(let s=0;s<t.length;s++){let o=ae(t[s],e);if(n.push(o),o.type==="error")break}return n};function Ct(){return new TransformStream({transform(r,e){bt(r,t=>{let n=t.length,s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);let o=new DataView(s.buffer);o.setUint8(0,126),o.setUint16(1,n)}else{s=new Uint8Array(9);let o=new DataView(s.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(n))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var De;function Ee(r){return r.reduce((e,t)=>e+t.length,0)}function ve(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),n=0;for(let s=0;s<e;s++)t[s]=r[0][n++],n===r[0].length&&(r.shift(),n=0);return r.length&&n<r[0].length&&(r[0]=r[0].slice(n)),t}function At(r,e){De||(De=new TextDecoder);let t=[],n=0,s=-1,o=!1;return new TransformStream({transform(c,a){for(t.push(c);;){if(n===0){if(Ee(t)<1)break;let l=ve(t,1);o=(l[0]&128)===128,s=l[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(Ee(t)<2)break;let l=ve(t,2);s=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),n=3}else if(n===2){if(Ee(t)<8)break;let l=ve(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){a.enqueue(se);break}s=h*Math.pow(2,32)+u.getUint32(4),n=3}else{if(Ee(t)<s)break;let l=ve(t,s);a.enqueue(ae(o?l:De.decode(l),e)),n=0}if(s===0||s>r){a.enqueue(se);break}}}})}var Ue=4;function S(r){if(r)return pr(r)}function pr(r){for(var e in S.prototype)r[e]=S.prototype[e];return r}S.prototype.on=S.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};S.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};S.prototype.off=S.prototype.removeListener=S.prototype.removeAllListeners=S.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};S.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};S.prototype.emitReserved=S.prototype.emit;S.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};S.prototype.hasListeners=function(r){return!!this.listeners(r).length};var D=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),A=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),kt="arraybuffer";function Se(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var fr=A.setTimeout,mr=A.clearTimeout;function U(r,e){e.useNativeTimers?(r.setTimeoutFn=fr.bind(A),r.clearTimeoutFn=mr.bind(A)):(r.setTimeoutFn=A.setTimeout.bind(A),r.clearTimeoutFn=A.clearTimeout.bind(A))}var gr=1.33;function Ot(r){return typeof r=="string"?yr(r):Math.ceil((r.byteLength||r.size)*gr)}function yr(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function we(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Nt(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Rt(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let o=t[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}var Te=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},B=class extends S{constructor(e){super(),this.writable=!1,U(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new Te(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=ae(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Nt(e);return t.length?"?"+t:""}};var ce=class extends B{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};_t(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Tt(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=we()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var xt=!1;try{xt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var It=xt;function br(){}var Be=class extends ce{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,o)=>{this.onError("xhr post error",s,o)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}},M=class r extends S{constructor(e,t,n){super(),this.createRequest=e,U(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;let t=Se(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=br,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};M.requestsCount=0;M.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Lt);else if(typeof addEventListener=="function"){let r="onpagehide"in A?"pagehide":"unload";addEventListener(r,Lt,!1)}}function Lt(){for(let r in M.requests)M.requests.hasOwnProperty(r)&&M.requests[r].abort()}var Er=(function(){let r=Pt({xdomain:!1});return r&&r.responseType!==null})(),F=class extends Be{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Er&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new M(Pt,this.uri(),e)}};function Pt(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||It))return new XMLHttpRequest}catch{}if(!e)try{return new A[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Dt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Me=class extends B{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Dt?{}:Se(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;ie(n,this.supportsBinary,o=>{try{this.doWrite(n,o)}catch{}s&&D(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=we()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},qe=A.WebSocket||A.MozWebSocket,V=class extends Me{createSocket(e,t,n){return Dt?new qe(e,t,n):t?new qe(e,t):new qe(e)}doWrite(e,t){this.ws.send(t)}};var Q=class extends B{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=At(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=Ct();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();let o=()=>{n.read().then(({done:a,value:l})=>{a||(this.onPacket(l),o())}).catch(a=>{})};o();let c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&D(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var Fe={websocket:V,webtransport:Q,polling:F};var vr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Sr=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function G(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=vr.exec(r||""),o={},c=14;for(;c--;)o[Sr[c]]=s[c]||"";return t!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=wr(o,o.path),o.queryKey=Tr(o,o.query),o}function wr(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Tr(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,o){s&&(t[s]=o)}),t}var Ve=typeof addEventListener=="function"&&typeof removeEventListener=="function",_e=[];Ve&&addEventListener("offline",()=>{_e.forEach(r=>r())},!1);var K=class r extends S{constructor(e,t){if(super(),this.binaryType=kt,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let n=G(e);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=G(t.host).host);U(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{let s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Rt(this.opts.query)),Ve&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},_e.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=Ue,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){let s=this.writeBuffer[n].data;if(s&&(t+=Ot(s)),n>0&&t>this._maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,D(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ve&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=_e.indexOf(this._offlineEventListener);n!==-1&&_e.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};K.protocol=Ue;var Ce=class extends K{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;K.priorWebsocketSuccess=!1;let s=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",m=>{if(!n)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;K.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let g=new Error("probe error");g.transport=t.name,this.emitReserved("upgradeError",g)}}))};function o(){n||(n=!0,h(),t.close(),t=null)}let c=m=>{let g=new Error("probe error: "+m);g.transport=t.name,o(),this.emitReserved("upgradeError",g)};function a(){c("transport closed")}function l(){c("socket closed")}function u(m){t&&m.name!==t.name&&o()}let h=()=>{t.removeListener("open",s),t.removeListener("error",c),t.removeListener("close",a),this.off("close",l),this.off("upgrading",u)};t.once("open",s),t.once("error",c),t.once("close",a),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},X=class extends Ce{constructor(e,t={}){let n=typeof e=="object",s=n?{...e}:{...t};(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(o=>Fe[o]).filter(o=>!!o)),super(n?s:e,s)}};var bs=X.protocol;function Ut(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),n=G(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+e,n.href=n.protocol+"://"+o+(t&&t.port===n.port?"":":"+n.port),n}var Je={};sr(Je,{Decoder:()=>je,Encoder:()=>He,PacketType:()=>f,isPacketValid:()=>Ir,protocol:()=>Vt});var Cr=typeof ArrayBuffer=="function",Ar=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Bt=Object.prototype.toString,kr=typeof Blob=="function"||typeof Blob<"u"&&Bt.call(Blob)==="[object BlobConstructor]",Or=typeof File=="function"||typeof File<"u"&&Bt.call(File)==="[object FileConstructor]";function he(r){return Cr&&(r instanceof ArrayBuffer||Ar(r))||kr&&r instanceof Blob||Or&&r instanceof File}function le(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(le(r[t]))return!0;return!1}if(he(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return le(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&le(r[t]))return!0;return!1}function qt(r){let e=[],t=r.data,n=r;return n.data=Ae(t,e),n.attachments=e.length,{packet:n,buffers:e}}function Ae(r,e,t){if(!r)return r;if(he(r)){let n={_placeholder:!0,num:e.length};return e.push(r),n}else if(Array.isArray(r)){let n=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=Ae(r[s],e);return n}else if(typeof r=="object"&&!(r instanceof Date)){if(r.toJSON&&typeof r.toJSON=="function"&&!t)return Ae(r.toJSON(),e,!0);let n={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=Ae(r[s],e));return n}return r}function Mt(r,e){return r.data=$e(r.data,e),delete r.attachments,r}function $e(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=$e(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=$e(r[t],e));return r}var Ft=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Vt=5,f;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(f||(f={}));var He=class{constructor(e){this.replacer=e}encode(e){return(e.type===f.EVENT||e.type===f.ACK)&&le(e)?this.encodeAsBinary({type:e.type===f.EVENT?f.BINARY_EVENT:f.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===f.BINARY_EVENT||e.type===f.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=qt(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}},je=class r extends S{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let n=t.type===f.BINARY_EVENT;n||t.type===f.BINARY_ACK?(t.type=n?f.EVENT:f.ACK,this.reconstructor=new Ke(t)):super.emitReserved("decoded",t)}else if(he(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,n={type:Number(e.charAt(0))};if(f[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===f.BINARY_EVENT||n.type===f.BINARY_ACK){let o=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let c=e.substring(o,t);if(c!=Number(c)||e.charAt(t)!=="-")throw new Error("Illegal attachments");let a=Number(c);if(!$t(a)||a<1)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=a}if(e.charAt(t+1)==="/"){let o=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(o,t)}else n.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let o=t+1;for(;++t;){let c=e.charAt(t);if(c==null||Number(c)!=c){--t;break}if(t===e.length)break}n.id=Number(e.substring(o,t+1))}if(e.charAt(++t)){let o=this.tryParse(e.substr(t));if(r.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case f.CONNECT:return ke(t);case f.DISCONNECT:return t===void 0;case f.CONNECT_ERROR:return typeof t=="string"||ke(t);case f.EVENT:case f.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Ft.indexOf(t[0])===-1);case f.ACK:case f.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ke=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Mt(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Nr(r){return typeof r=="string"}var $t=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function Rr(r){return r===void 0||$t(r)}function ke(r){return Object.prototype.toString.call(r)==="[object Object]"}function xr(r,e){switch(r){case f.CONNECT:return e===void 0||ke(e);case f.DISCONNECT:return e===void 0;case f.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Ft.indexOf(e[0])===-1);case f.ACK:return Array.isArray(e);case f.CONNECT_ERROR:return typeof e=="string"||ke(e);default:return!1}}function Ir(r){return Nr(r.nsp)&&Rr(r.id)&&xr(r.type,r.data)}function k(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var Lr=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Z=class extends S{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[k(e,"open",this.onopen.bind(this)),k(e,"packet",this.onpacket.bind(this)),k(e,"error",this.onerror.bind(this)),k(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,o;if(Lr.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let c={type:f.EVENT,data:t};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let h=this.ids++,m=t.pop();this._registerAckCallback(h,m),c.id=h}let a=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,l=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!a||(l?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),this.flags={},this}_registerAckCallback(e,t){var n;let s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},s),c=(...a)=>{this.io.clearTimeoutFn(o),t.apply(this,a)};c.withError=!0,this.acks[e]=c}emitWithAck(e,...t){return new Promise((n,s)=>{let o=(c,a)=>c?s(c):n(a);o.withError=!0,t.push(o),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...o)=>(this._queue[0],s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...o)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:f.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){let n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case f.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case f.EVENT:case f.BINARY_EVENT:this.onevent(e);break;case f.ACK:case f.BINARY_ACK:this.onack(e);break;case f.DISCONNECT:this.ondisconnect();break;case f.CONNECT_ERROR:this.destroy();let n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...s){n||(n=!0,t.packet({type:f.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:f.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function J(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}J.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=(Math.floor(e*10)&1)==0?r-t:r+t}return Math.min(r,this.max)|0};J.prototype.reset=function(){this.attempts=0};J.prototype.setMin=function(r){this.ms=r};J.prototype.setMax=function(r){this.max=r};J.prototype.setJitter=function(r){this.jitter=r};var ee=class extends S{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,U(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new J({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Je;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new X(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let s=k(t,"open",function(){n.onopen(),e&&e()}),o=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},c=k(t,"error",o);if(this._timeout!==!1){let a=this._timeout,l=this.setTimeoutFn(()=>{s(),o(new Error("timeout")),t.close()},a);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(s),this.subs.push(c),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(k(e,"ping",this.onping.bind(this)),k(e,"data",this.ondata.bind(this)),k(e,"error",this.onerror.bind(this)),k(e,"close",this.onclose.bind(this)),k(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){D(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Z(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var ue={};function de(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Ut(r,e.path||"/socket.io"),n=t.source,s=t.id,o=t.path,c=ue[s]&&o in ue[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||c,l;return a?l=new ee(n,e):(ue[s]||(ue[s]=new ee(n,e)),l=ue[s]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(de,{Manager:ee,Socket:Z,io:de,connect:de});var Pr=new Set(["idle","authorizing","synchronizing","live","stale","resync-required","failed","closed"]);function Ht(r){return j(r)&&r.protocolVersion===1&&r.transport==="socket.io"&&Array.isArray(r.deliveryModes)&&Array.isArray(r.operations)&&typeof r.connectionId=="string"&&typeof r.identityKey=="string"&&r.identityKey.length>0&&typeof r.authExpiresAt=="string"}function jt(r){return j(r)&&typeof r.subscriptionId=="string"&&typeof r.epoch=="string"&&typeof r.state=="string"&&Pr.has(r.state)&&(r.reason===void 0||Ie(r.reason))}function Dr(r){return j(r)&&typeof r.id=="string"&&typeof r.channel=="string"&&typeof r.channelVersion=="number"&&(r.kind==="snapshot"||r.kind==="update")&&Object.hasOwn(r,"data")&&st(r.revision)&&typeof r.receivedAt=="string"}function Kt(r){return j(r)&&typeof r.subscriptionId=="string"&&typeof r.epoch=="string"&&typeof r.sequence=="number"&&Number.isSafeInteger(r.sequence)&&r.sequence>=1&&Dr(r.event)}function Jt(r){return j(r)&&re(r.error)&&(r.subscriptionId===void 0||typeof r.subscriptionId=="string")&&(r.epoch===void 0||typeof r.epoch=="string")}function Wt(r){return!j(r)||typeof r.requestId!="string"?!1:r.ok===!0?Object.hasOwn(r,"data"):r.ok===!1&&re(r.error)}var Oe=class{ready;#e;#r;#o=!1;#i=!1;#y=!1;#t=new Set;constructor(e){this.#r=e.events,this.#e=de(e.origin,{path:e.path,transports:["websocket"],upgrade:!1,reconnection:!1,forceNew:!0,multiplex:!1,timeout:Le,auth:{token:e.token,protocolVersion:1},autoConnect:!1}),this.ready=new Promise((t,n)=>{let s=setTimeout(()=>{n(E("TIMEOUT",{message:"The gateway did not complete the handshake within ten seconds."})),this.close()},Le);this.#e.once("connect_error",o=>{clearTimeout(s),n(re(o.data)?o.data:E("SOURCE_UNAVAILABLE",{message:"The gateway could not be reached; retrying.",retryable:!0})),this.close()}),this.#e.once(N.hello,o=>{if(clearTimeout(s),!Ht(o)||o.protocolVersion!==1||!o.deliveryModes.includes("state")){n(E("UNSUPPORTED_CAPABILITY",{message:"The gateway does not support protocol version 1 state delivery."})),this.close();return}this.#o=!0,t(o)}),this.#e.once("disconnect",()=>{clearTimeout(s),this.#o||n(E("SOURCE_UNAVAILABLE",{message:"The connection closed during the handshake.",retryable:!0}))})}),this.ready.catch(()=>{}),this.#e.on(N.state,t=>{this.#o&&jt(t)&&this.#r.state(t)}),this.#e.on(N.data,t=>{this.#o&&Kt(t)&&this.#r.data(t)}),this.#e.on(N.error,t=>{Jt(t)&&this.#r.error(t)}),this.#e.on("disconnect",()=>this.#s()),this.#e.connect()}get connected(){return this.#o&&!this.#i}request(e,t){return this.connected?new Promise((n,s)=>{let o=c=>{this.#t.delete(o),s(c)};this.#t.add(o),this.#e.timeout(at).emit(e,t,(c,a)=>{if(this.#t.has(o)){if(this.#t.delete(o),c!==null){s(E("TIMEOUT",{message:"The gateway did not acknowledge a control request in time."}));return}if(!Wt(a)){s(E("INVALID_REQUEST",{message:"The gateway sent a malformed acknowledgement."}));return}n(a)}})}):Promise.reject(E("SOURCE_UNAVAILABLE",{message:"Not connected.",retryable:!0}))}receipt(e){this.connected&&this.#e.emit(N.receipt,e)}close(){this.#i||(this.#i=!0,this.#e.removeAllListeners(N.state),this.#e.removeAllListeners(N.data),this.#e.disconnect(),this.#s())}#s(){this.#i=!0;let e=this.#o;this.#o=!1;for(let t of[...this.#t])t(E("SOURCE_UNAVAILABLE",{message:"The connection closed before the request was acknowledged.",retryable:!0}));e&&!this.#y&&(this.#y=!0,this.#r.disconnect())}};var Ne=class{#e=new Set;get size(){return this.#e.size}wait(e){let t=e?.timeoutMs??be,n=e?.signal;return n?.aborted?Promise.reject(new v("CANCELLED")):new Promise((s,o)=>{let c=()=>{clearTimeout(u),n?.removeEventListener("abort",l),this.#e.delete(a)},a={resolve:()=>{c(),s()},reject:h=>{c(),o(H(h))}},l=()=>a.reject(new v("CANCELLED")),u=setTimeout(()=>a.reject(new v("TIMEOUT",{message:`The subscription did not become live within ${t} ms.`})),t);n?.addEventListener("abort",l,{once:!0}),this.#e.add(a)})}resolveAll(){for(let e of[...this.#e])e.resolve()}rejectAll(e){for(let t of[...this.#e])t.reject(e)}};var Yt=3;function Qt(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&typeof r.then=="function"}var Re=class{id;channel;channelVersion;params;#e;#r={data:new Set,state:new Set,error:new Set};#o=new Ne;#i="idle";#y;#t=!1;#s=null;#n=!1;#g=null;#l=null;#h=!0;#d=1;#a=null;#b=null;#p=0;#c=null;#m=null;#f=null;constructor(e,t,n,s){this.#e=e,this.id=e.randomId(),this.channel=t,this.channelVersion=n,this.params=s,queueMicrotask(()=>{this.#t||this.#e.register(this)})}get state(){return this.#i}get active(){return!this.#t}on(e,t){let n=this.#r[e];if(n===void 0||typeof t!="function")throw new v("INVALID_REQUEST",{message:'on() accepts "data", "state", or "error" with a function.'});return n.add(t),()=>{n.delete(t)}}ready(e){if(this.#i==="live")return Promise.resolve();let t=this.#w();return t!==null?Promise.reject(H(t)):this.#o.wait(e)}resync(e){let t=this.#w(!0);if(t!==null)return Promise.reject(H(t));let n=this.#o.wait(e);return this.#p=0,this.#C(),n}unsubscribe(){if(this.#m!==null)return this.#m;let e=this.#s,t=this.#n;return this.#v("closed",void 0,new v("CANCELLED",{message:"The subscription was unsubscribed."})),this.#m=t&&e!==null&&e.connected?this.#A(e):Promise.resolve(),this.#m}attach(e){this.#t||(this.#k(),this.#s=e,this.#n=!1,this.#g=null,this.#l=null,this.#h=!0,this.#u("authorizing"),this.#_(e))}detach(e){this.#k(),this.#s=null,this.#n=!1,this.#h=!0,this.#l=null,!(this.#t||this.#i==="resync-required")&&this.#u("stale",e)}authRequired(e){this.detach("UNAUTHENTICATED"),this.#t||this.#o.rejectAll(e)}terminateLocally(e,t,n){this.#t||(n&&this.#S(t),this.#v(e,t.code,t))}handleState(e,t){if(!(this.#t||e!==this.#s)){if(this.#n=!0,t.state==="synchronizing"){if(t.epoch===this.#g&&!this.#h)return;this.#g=t.epoch,this.#l=null,this.#h=!1,this.#d=1,this.#a=null,this.#u("synchronizing");return}if(t.epoch===(this.#g??"")&&!(this.#l!==null&&t.epoch===this.#l&&(t.state==="live"||t.state==="resync-required"))&&!(t.state==="live"&&this.#h))switch(t.state){case"failed":this.#n=!1,this.#v("failed",t.reason,this.#c??E(t.reason??"INTERNAL"));return;case"closed":this.#n=!1,this.#v("closed",t.reason,this.#c??E(t.reason??"CANCELLED"));return;case"resync-required":this.#u("resync-required",t.reason??"RESYNC_REQUIRED");return;case"live":this.#p=0,this.#u("live");return;case"stale":case"authorizing":this.#u(t.state,t.reason);return;default:return}}}handleData(e,t){if(this.#t||e!==this.#s||(this.#n=!0,this.#h||t.epoch!==this.#g))return;if(t.sequence!==this.#d){this.#E("INVALID_REQUEST",`Expected sequence ${this.#d} but received ${t.sequence}.`);return}let n=t.event;if(n.channel!==this.channel||n.channelVersion!==this.channelVersion){this.#E("INVALID_PAYLOAD","A frame named a different channel contract.");return}if(t.sequence===1){if(n.kind!=="snapshot"){this.#E("INVALID_REQUEST","The first frame of an epoch must be a snapshot.");return}if(this.#b!==null&&ye(n.revision,this.#b)<0){this.#E("INVALID_PAYLOAD","The snapshot is older than state this subscription already delivered.");return}}else if(n.kind!=="update"||this.#a!==null&&ye(n.revision,this.#a)<=0){this.#E("INVALID_REQUEST","Updates must follow the snapshot in increasing revision order.");return}this.#d++,this.#a=n.revision,(this.#b===null||ye(n.revision,this.#b)>0)&&(this.#b=n.revision);for(let s of[...this.#r.data])if(!this.#O(s,n))return;e.receipt({subscriptionId:this.id,epoch:t.epoch,sequence:t.sequence})}handleError(e,t){this.#t||e!==this.#s||(this.#c=t,this.#S(t))}#w(e=!1){return this.#e.closed&&this.#i==="closed"?E("CLIENT_CLOSED"):this.#t?this.#i==="failed"?this.#c??E("INTERNAL"):this.#e.closed?E("CLIENT_CLOSED"):E("CANCELLED",{message:"The subscription was unsubscribed."}):this.#e.authRequired?E("UNAUTHENTICATED",{message:"Authentication is required; call reconnect()."}):!e&&this.#i==="resync-required"?E("RESYNC_REQUIRED"):null}async#_(e){let t;try{t=await e.request(N.subscribe,{requestId:this.#e.randomId(),subscriptionId:this.id,channel:this.channel,channelVersion:this.channelVersion,params:this.params})}catch(n){if(e!==this.#s||this.#t)return;n.code==="TIMEOUT"&&this.#e.controlTimedOut(e);return}if(!(e!==this.#s||this.#t)){if(t.ok){this.#n=!0;return}if(this.#c=t.error,this.#S(t.error),t.error.code==="OVERLOADED"){if(this.#p++,this.#p>=Yt){this.#u("resync-required","OVERLOADED");return}this.#u("stale","OVERLOADED"),this.#f=setTimeout(()=>{this.#f=null,this.#s===e&&e.connected&&!this.#t&&this.attach(e)},1e3*2**(this.#p-1));return}this.#v("failed",t.error.code,t.error)}}#k(){this.#f!==null&&(clearTimeout(this.#f),this.#f=null)}#C(){let e=this.#s;if(!(e===null||!e.connected)){if(!this.#n){if(this.#i==="authorizing")return;this.attach(e);return}this.#i==="authorizing"||this.#i==="synchronizing"||(this.#l=this.#g,this.#h=!0,this.#u("authorizing"),e.request(N.resync,{requestId:this.#e.randomId(),subscriptionId:this.id}).then(t=>{e!==this.#s||this.#t||t.ok||(this.#c=t.error,this.#S(t.error),t.error.code==="INVALID_REQUEST"&&this.attach(e))},t=>{e===this.#s&&!this.#t&&t.code==="TIMEOUT"&&this.#e.controlTimedOut(e)}))}}#E(e,t){let n=E(e,{message:t,requestId:this.#e.randomId()});if(this.#c=n,this.#S(n),!this.#t){if(this.#p++,this.#p>=Yt){let s=this.#s;this.#n&&s!==null&&s.connected&&this.#A(s),this.#n=!1,this.#h=!0,this.#u("resync-required","RESYNC_REQUIRED");return}this.#u("stale",e),this.#C()}}#A(e){return new Promise(t=>{let n=setTimeout(t,ct);e.request(N.unsubscribe,{requestId:this.#e.randomId(),subscriptionId:this.id}).then(()=>{},()=>{}).finally(()=>{clearTimeout(n),t()})})}#v(e,t,n){this.#t||(this.#t=!0,this.#k(),this.#s=null,this.#e.unregister(this),this.#c=n,this.#u(e,t,!0),this.#o.rejectAll(n),this.#r.data.clear(),this.#r.state.clear(),this.#r.error.clear())}#u(e,t,n=!1){if(this.#t&&!n||this.#i===e&&this.#y===t)return;this.#i=e,this.#y=t;let s=t===void 0?{state:e}:{state:e,reason:t};for(let o of[...this.#r.state])if(!this.#O(o,s))return;e==="live"?this.#o.resolveAll():e==="resync-required"&&this.#o.rejectAll(E("RESYNC_REQUIRED"))}#O(e,t){let n;try{n=e(t)}catch(s){return this.#N(s),!1}return Qt(n)&&Promise.resolve(n).catch(s=>this.#N(s)),!0}#N(e){if(this.#t)return;this.#e.logListenerFailure(e);let t=E("HANDLER_FAILED",{message:"A subscription listener threw; the subscription failed.",requestId:this.#e.randomId()}),n=this.#s,s=this.#n;this.#S(t),this.#v("failed","HANDLER_FAILED",t),s&&n!==null&&n.connected&&this.#A(n)}#S(e){for(let t of[...this.#r.error])try{let n=t(e);Qt(n)&&Promise.resolve(n).catch(s=>this.#e.logListenerFailure(s))}catch(n){this.#e.logListenerFailure(n)}}};function Ur(r){let e=r??globalThis.location?.origin;if(typeof e!="string")throw new v("INVALID_REQUEST",{message:"origin is required outside a browser page."});let t;try{t=new URL(e)}catch{throw new v("INVALID_REQUEST",{message:"origin must be an absolute http(s) origin."})}if(t.protocol!=="http:"&&t.protocol!=="https:"||t.origin!==e.replace(/\/$/,""))throw new v("INVALID_REQUEST",{message:"origin must be an absolute http(s) origin without a path."});return t.origin}function Br(){return globalThis.crypto.randomUUID()}var We=class{#e;#r;#o;#i=new Set;#y=new Set;#t=new Set;#s="idle";#n=null;#g=null;#l=0;#h=!1;#d=!1;#a=!1;#b=!1;#p=0;#c=null;#m=null;#f=null;#w=null;#_=null;constructor(e){if(typeof e!="object"||e===null||typeof e.getToken!="function")throw new v("INVALID_REQUEST",{message:"createClient requires a getToken function."});if(this.#e=Ur(e.origin),this.#r=e.path??ot,!this.#r.startsWith("/"))throw new v("INVALID_REQUEST",{message:"path must start with /."});this.#o=e.getToken}get state(){return this.#s}get closed(){return this.#a}get authRequired(){return this.#d}get connection(){return this.#n!==null&&this.#n.connected?this.#n:null}register(e){if(this.#a)return;if(this.#t.add(e),this.#d){e.authRequired(this.#c??E("UNAUTHENTICATED"));return}let t=this.connection;t!==null?e.attach(t):this.#k()}unregister(e){this.#t.delete(e)}controlTimedOut(e){e===this.#n&&e.close()}randomId(){return Br()}logListenerFailure(e){console.error("[streamotter] listener failed",e)}subscribe(e,t){if(this.#a)throw new v("CLIENT_CLOSED");if(typeof e!="string"||typeof t!="object"||t===null||typeof t.channelVersion!="number"||typeof t.params!="object"||t.params===null)throw new v("INVALID_REQUEST",{message:"subscribe requires a channel name, channelVersion, and params."});let n=Object.keys(t).find(s=>s!=="channelVersion"&&s!=="params");if(n!==void 0)throw new v("UNSUPPORTED_CAPABILITY",{message:`"${n}" is not supported by this SDK version.`});return new Re(this,e,t.channelVersion,{...t.params})}on(e,t){let n=e==="state"?this.#i:e==="error"?this.#y:void 0;if(n===void 0||typeof t!="function")throw new v("INVALID_REQUEST",{message:'on() accepts "state" or "error" with a function.'});return n.add(t),()=>{n.delete(t)}}reconnect(e){if(this.#a)return Promise.reject(new v("CLIENT_CLOSED"));this.#d=!1,this.#c=null,this.#p=0,this.#x();let t=this.#n;if(this.#n=null,this.#h=!1,this.#l++,t!==null){t.close();for(let s of this.#t)s.detach()}let n=this.#U(e);return this.#C(!0),n}close(){if(this.#_!==null)return this.#_;this.#a=!0,this.#l++,this.#x(),this.#P(),this.#w?.abort();let e=E("CLIENT_CLOSED");for(let t of[...this.#t])t.terminateLocally("closed",e,!1);return this.#t.clear(),this.#n?.close(),this.#n=null,this.#T("closed"),this.#i.clear(),this.#y.clear(),this.#_=Promise.resolve(),this.#_}#k(){this.#a||this.#d||this.#h||this.#m!==null||this.#n===null&&this.#C(!1)}async#C(e){if(this.#a)return;let t=++this.#l;this.#h=!0,this.#T(this.#b&&!e?"reconnecting":"connecting");let n;try{n=await this.#E()}catch(s){if(t!==this.#l)return;this.#h=!1,this.#v(s);return}if(t!==this.#l){n.connection.close();return}this.#h=!1,this.#A(n.connection,n.hello)}async#E(){let e=new AbortController;this.#w=e;let t,n;try{t=await Promise.race([Promise.resolve().then(()=>this.#o({signal:e.signal})),new Promise((a,l)=>{n=setTimeout(()=>{e.abort(),l(E("UNAUTHENTICATED",{message:"getToken did not resolve within ten seconds.",retryable:!0}))},lt)})])}catch(a){throw typeof a=="object"&&a!==null&&"code"in a&&a.code==="UNAUTHENTICATED"?a:E("UNAUTHENTICATED",{message:"getToken failed; call reconnect() once the application session is available.",retryable:!0})}finally{clearTimeout(n),this.#w===e&&(this.#w=null)}if(typeof t!="string"||t.length===0)throw E("UNAUTHENTICATED",{message:"getToken must resolve to a non-empty string.",retryable:!1});let s=null,o={state:a=>this.#L(s,a.subscriptionId,l=>l.handleState(s,a)),data:a=>this.#L(s,a.subscriptionId,l=>l.handleData(s,a)),error:a=>this.#q(s,a),disconnect:()=>this.#u(s)};s=new Oe({origin:this.#e,path:this.#r,token:t,events:o});let c=await s.ready;return{connection:s,hello:c}}#A(e,t){if(this.#a){e.close();return}let n=this.#n;if(this.#n=e,n!==null&&n!==e&&n.close(),this.#g!==null&&t.identityKey!==this.#g){let s=E("UNAUTHENTICATED",{message:"The authenticated identity changed; create new subscriptions for the new identity."});for(let o of[...this.#t])o.terminateLocally("closed",s,!0);this.#t.clear(),this.#R(s)}this.#g=t.identityKey,this.#b=!0,this.#p=0,this.#c=null,this.#T("connected"),this.#S(t.authExpiresAt);for(let s of[...this.#t])s.attach(e)}#v(e){this.#c=e,this.#R(e),e.code==="UNAUTHENTICATED"||e.code==="FORBIDDEN"||e.code==="INVALID_REQUEST"||e.code==="UNSUPPORTED_CAPABILITY"?this.#O(e):this.#N()}#u(e){if(e===null||e!==this.#n)return;this.#n=null,this.#P();let t=this.#c,n=t?.code;for(let s of this.#t)s.detach(n);if(!this.#a){if(t!==null&&t.code==="UNAUTHENTICATED"&&!t.retryable){this.#O(t);return}t!==null&&t.code==="UNAUTHENTICATED"&&(this.#p=0),this.#N()}}#O(e){this.#d=!0,this.#x(),this.#T("auth-required",e.code);for(let t of[...this.#t])t.authRequired(e)}#N(){if(this.#a||this.#d)return;if(this.#x(),this.#t.size===0){this.#T("idle");return}this.#T("reconnecting",this.#c?.code);let e=Math.min(dt,ut*2**this.#p);this.#p++;let t=Math.random()*e;this.#m=setTimeout(()=>{if(this.#m=null,this.#t.size===0){this.#T("idle");return}this.#C(!1)},t)}#S(e){this.#P();let t=it(e);if(!Number.isFinite(t))return;let n=t-ht-Date.now();n<=0||n>2147e6||(this.#f=setTimeout(()=>{this.#f=null,this.#D(t)},n))}async#D(e){if(this.#a||this.#d||this.#n===null)return;let t=this.#l;try{let n=await this.#E();if(t!==this.#l||this.#a||this.#d){n.connection.close();return}this.#l++,this.#A(n.connection,n.hello)}catch(n){if(t!==this.#l)return;this.#R(n),Date.now()+5e3<e&&(this.#f=setTimeout(()=>{this.#f=null,this.#D(e)},5e3))}}#U(e){let t=e?.timeoutMs??be,n=e?.signal;return n?.aborted?Promise.reject(new v("CANCELLED")):new Promise((s,o)=>{let c=()=>{clearTimeout(l),n?.removeEventListener("abort",a),u()},a=()=>{c(),o(new v("CANCELLED"))},l=setTimeout(()=>{c(),o(new v("TIMEOUT",{message:`The client did not connect within ${t} ms.`}))},t),u=this.#B(h=>{h==="connected"?(c(),s()):h==="auth-required"?(c(),o(H(this.#c??E("UNAUTHENTICATED")))):h==="closed"&&(c(),o(new v("CLIENT_CLOSED")))});n?.addEventListener("abort",a,{once:!0})})}#I=new Set;#B(e){return this.#I.add(e),()=>{this.#I.delete(e)}}#L(e,t,n){if(!(e===null||e!==this.#n)){for(let s of this.#t)if(s.id===t){n(s);return}}}#q(e,t){if(!(e===null||e!==this.#n)){if(t.subscriptionId!==void 0){this.#L(e,t.subscriptionId,n=>n.handleError(e,t.error));return}this.#c=t.error,this.#R(t.error)}}#T(e,t){if(this.#s===e)return;this.#s=e;let n=t===void 0?{state:e}:{state:e,reason:t};for(let s of[...this.#I])s(e);for(let s of[...this.#i])try{s(n)}catch(o){this.logListenerFailure(o)}}#R(e){for(let t of[...this.#y])try{t(e)}catch(n){this.logListenerFailure(n)}}#x(){this.#m!==null&&(clearTimeout(this.#m),this.#m=null)}#P(){this.#f!==null&&(clearTimeout(this.#f),this.#f=null)}};function ze(r){return new We(r)}var Gt={idle:"neutral",authorizing:"info",synchronizing:"info",live:"ok",stale:"warn","resync-required":"bad",failed:"bad",closed:"neutral"},Xt={idle:"neutral",connecting:"info",connected:"ok",reconnecting:"warn","auth-required":"bad",closed:"neutral"},qr={idle:"Created; starting in the next microtask.",authorizing:"The gateway is running your authorize handler for this principal and parameters.",synchronizing:"Live capture is registered and the snapshot is loading; newer updates are buffered.",live:"Synchronized to the drain boundary while the source is healthy. Not proof of wall-clock freshness.",stale:"The view may be out of date (source outage, rebalance, overflow, disconnect, or expiry). Resynchronizes automatically.","resync-required":"Automatic synchronization stopped after its attempt budget. Call resync().",failed:"Terminal: denied, handler failure, or invalid data. Create a new subscription.",closed:"Unsubscribed or the client closed."},L=null,xe=[],$=null;function Mr(r){if(r===void 0||r.type!=="object")return{element:i("p",{class:"muted"},"This channel's parameter schema is not an object."),read:()=>({})};let e=[],t=Object.entries(r.properties).map(([n,s])=>{if(s.type==="boolean"){let c=i("input",{type:"checkbox"});return e.push(()=>[n,c.checked]),i("label",{},i("span",{},n," ",i("span",{class:"hint"},"boolean")),c)}if(s.type==="string"&&s.enum!==void 0){let c=i("select",{},s.enum.map(a=>i("option",{value:a},a)));return e.push(()=>[n,c.value]),i("label",{},i("span",{},n),c)}let o=i("input",{type:s.type==="integer"?"number":"text",placeholder:s.type==="integer"?"0":"value"});return e.push(()=>[n,s.type==="integer"?Number(o.value):o.value]),i("label",{},i("span",{},n," ",i("span",{class:"hint"},s.type)),o)});return{element:i("div",{class:"stack"},t),read:()=>Object.fromEntries(e.map(n=>n()))}}function Zt(r,e){let t=i("select",{"aria-label":"Development principal"},e.principals.map(d=>i("option",{value:d.ref},`${d.ref} (tenant ${d.tenantId}, subject ${d.subject})`))),n=i("select",{"aria-label":"Channel"},e.channels.map(d=>i("option",{value:d.name},`${d.name} v${d.version}`))),s=i("div"),o=()=>({}),c=()=>{let d=e.channels.find(I=>I.name===n.value),w=Mr(d===void 0?void 0:e.active.config.schemas[d.paramsSchema]);o=w.read,p(s,w.element)};n.addEventListener("change",c);let a=i("div",{class:"stack"}),l=i("div",{class:"data-view"}),u=i("ul",{class:"timeline","aria-label":"Preview activity"}),h=i("div",{class:"row"}),m=i("div"),g=(d,w)=>{xe.unshift({at:new Date().toISOString(),text:d,tone:w}),xe.length>200&&(xe.length=200),x()},x=()=>p(u,xe.map(d=>i("li",{},i("span",{class:"muted mono small"},te(d.at)),i("span",{},C(d.tone==="neutral"?"\xB7":d.tone,d.tone)," ",d.text)))),O=()=>{if(L===null){p(a,i("p",{class:"muted"},"No preview running.")),p(l,i("span",{class:"muted"},"Data appears here after the snapshot arrives.")),p(h);return}let d=L.subscription;p(a,i("div",{class:"row"},i("span",{class:"muted"},"Connection"),C(L.client.state,Xt[L.client.state]),i("span",{class:"muted"},"Subscription"),C(d.state,Gt[d.state])),i("p",{class:"small"},qr[d.state])),p(l,$===null?i("span",{class:"muted"},"Waiting for the snapshot\u2026"):i("div",{class:"stack"},i("div",{class:"row small"},C($.kind,$.kind==="snapshot"?"info":"neutral"),i("span",{class:"mono"},`revision ${$.revision}`),i("span",{class:"muted"},`received ${te($.receivedAt)}`)),i("pre",{},JSON.stringify($.data,null,2))));let w=(W,q,z=!1)=>{let P=i("button",{type:"button",class:z?"primary":""},W);return P.addEventListener("click",async()=>{P.disabled=!0;try{await q()}catch(b){g(y(b),"bad")}finally{P.disabled=!1}}),P},I=L;p(h,I.sourceKind==="fixture"?w(`Advance "${I.sourceId}" by 1`,async()=>{let{advanced:W}=await e.api.advance(I.sourceId,1);g(W===0?"No record was committed (the fixture is exhausted or paused).":"Advanced one fixture record.",W===0?"warn":"info")}):null,w("Disconnect this preview",async()=>{await e.api.disconnect(I.previewSessionId),g("Disconnected the preview connection. Expect stale \u2192 resynchronization with a fresh snapshot.","warn")}),w("Resync",async()=>{g("Requested a fresh synchronization.","info"),await I.subscription.resync({timeoutMs:3e4})}),w("Stop preview",async()=>{await T()},!1))},y=d=>{if(d instanceof _)return`${d.error.code}: ${d.error.message}`;let w=d;return w.code!==void 0?`${w.code}: ${w.message??""}`:d.message},T=async()=>{let d=L;L=null,$=null,d!==null&&(await d.subscription.unsubscribe(),await d.client.close(),g("Preview stopped; the subscription and client were closed.","neutral")),O()},pe=i("button",{class:"primary",type:"button"},"Start preview");pe.addEventListener("click",async()=>{if(p(m),e.principals.length===0){p(m,i("div",{class:"banner warn"},"No development principals are registered. Export `development.principals` from your handler module."));return}await T();let d=e.channels.find(b=>b.name===n.value);if(d===void 0)return;let w=t.value,I=o(),W=e.active.config.sources[d.source],q;try{q=await e.api.previewSession(w)}catch(b){p(m,i("div",{class:"banner bad",role:"alert"},y(b)));return}let z=ze({origin:e.gatewayOrigin,path:e.gatewayPath,getToken:async()=>(Date.parse(q.expiresAt)-Date.now()<45e3&&(q=await e.api.previewSession(w),L!==null&&(L.previewSessionId=q.previewSessionId)),q.token)}),P=z.subscribe(d.name,{channelVersion:d.version,params:I});L={client:z,subscription:P,principalRef:w,sourceId:d.source,sourceKind:W?.kind??"unknown",previewSessionId:q.previewSessionId},g(`Subscribing to ${d.name} v${d.version} as "${w}" with ${JSON.stringify(I)}.`,"info"),z.on("state",b=>{g(`Connection ${b.state}${b.reason===void 0?"":` (${b.reason})`}.`,Xt[b.state]),O()}),z.on("error",b=>g(`Connection error ${b.code}: ${b.message}`,"bad")),P.on("state",b=>{g(`Subscription ${b.state}${b.reason===void 0?"":` (${b.reason})`}.`,Gt[b.state]),O()}),P.on("data",b=>{$={kind:b.kind,revision:b.revision,receivedAt:b.receivedAt,data:b.data},g(`${b.kind==="snapshot"?"Snapshot":"Update"} at revision ${b.revision}.`,b.kind==="snapshot"?"info":"ok"),O()}),P.on("error",b=>g(`${b.code}: ${b.message}`,"bad")),O()}),p(r,i("section",{class:"panel stack"},i("div",{},i("h2",{},"Preview"),i("p",{class:"lede"},"Subscribe through the running gateway as a registered development principal. Preview tokens use the same authorization, snapshot, and delivery path as your application; only the identity resolver differs.")),i("div",{class:"grid-2"},i("div",{class:"stack"},i("label",{},i("span",{},"Principal"),t),i("label",{},i("span",{},"Channel"),n)),i("div",{class:"stack"},i("span",{class:"small muted"},"Parameters"),s)),i("div",{class:"row"},pe),m),i("div",{class:"grid-2"},i("section",{class:"panel stack"},i("h3",{},"Delivery state"),a,h),i("section",{class:"panel stack"},i("h3",{},"Current state"),l)),i("section",{class:"panel"},i("h3",{},"Activity"),u)),c(),O(),x()}var Fr=[["connect","Connect"],["define","Define"],["preview","Preview"],["inspect","Inspect"],["export","Export"]],tr=document.getElementById("app"),er=r=>document.querySelector(`meta[name="${r}"]`)?.content??"";function rr(r){let e=i("input",{type:"password",autocomplete:"off",spellcheck:"false",required:!0,id:"token"}),t=i("form",{class:"panel stack gate"},i("h1",{},"StreamOtter Workbench"),i("p",{class:"muted"},"Enter the management token printed by ",i("code",{},"streamotter dev"),". It is valid for this run only and is kept in memory; reloading the page asks again."),i("label",{for:"token"},"Management token",e),r===void 0?null:i("div",{class:"banner bad",role:"alert"},r),i("button",{class:"primary",type:"submit"},"Open workbench"));t.addEventListener("submit",n=>{n.preventDefault(),Vr(e.value.trim())}),p(tr,i("main",{},t)),e.focus()}async function Vr(r){let e=new fe(r);try{let[t,n,s,o,c]=await Promise.all([e.config(),e.channels(),e.sources(),e.principals(),e.health()]),a={api:e,gatewayOrigin:er("streamotter-gateway-origin"),gatewayPath:er("streamotter-gateway-path")||"/streamotter/socket.io",active:t,candidateText:me(t.config),channels:n.items,sources:s.items,principals:o.items,ready:c.ready,refreshShell:()=>x()},l=i("header",{class:"topbar"}),u=i("nav",{class:"tabs",role:"tablist","aria-label":"Workbench sections"}),h=i("main",{id:"view",role:"tabpanel"}),m="connect",g=null,x=()=>p(l,i("div",{class:"brand"},i("h1",{},"StreamOtter Workbench"),i("small",{},t.config.projectId)),i("span",{class:"spacer"}),i("span",{class:"muted small"},"Gateway ",i("code",{},a.gatewayOrigin||"unknown")),a.ready?C("Sources ready","ok"):C("Sources not ready","warn"),i("span",{class:"muted small mono",title:`Active configuration sha256:${a.active.fingerprint}`},`active sha256:${a.active.fingerprint.slice(0,12)}\u2026`),Y(a)?C("Candidate edited \xB7 restart required to apply","warn"):null),O=y=>{switch(g?.(),g=null,m=y,p(u,Fr.map(([T,pe])=>{let d=i("button",{type:"button",role:"tab","aria-selected":String(T===m),id:`tab-${T}`},pe);return d.addEventListener("click",()=>O(T)),d})),h.setAttribute("aria-labelledby",`tab-${y}`),y){case"connect":Ge(h,a);break;case"define":Ze(h,a);break;case"preview":Zt(h,a);break;case"inspect":g=rt(h,a);break;case"export":et(h,a);break}};p(tr,l,u,h),x(),O("connect")}catch(t){rr(t instanceof _&&t.status===401?"That token was not accepted. Copy it again from the streamotter dev output.":`The management API is unavailable: ${t.message}`)}}rr();
|
|
5
|
+
//# sourceMappingURL=app.js.map
|