@apple-pie/slice 0.1.2 → 0.1.4
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/README.md +89 -27
- package/dist/cjs/chunks/{Button-TfMwGVI5.js → Button-krf4dQeL.js} +4 -2
- package/dist/cjs/chunks/{ButtonBar-BqGC6sad.js → ButtonBar-C9Nm9faU.js} +1 -1
- package/dist/cjs/chunks/{Camera-om1AA2D0.js → Camera-Dx_PT3pS.js} +63 -46
- package/dist/cjs/chunks/{Card-Ctwbhu26.js → Card-AgEMKJ4O.js} +1 -1
- package/dist/cjs/chunks/{CheckBox-CeDIiSvi.js → CheckBox-CLMxlUff.js} +1 -1
- package/dist/cjs/chunks/{Chip-DdTtB57x.js → Chip-CIy_Xe3i.js} +1 -1
- package/dist/cjs/chunks/{DropDown-CC90XfyD.js → DropDown-FZb52YxR.js} +1 -1
- package/dist/cjs/chunks/{FileList-ClTfGKIL.js → FileList-CkpMj-os.js} +1 -1
- package/dist/cjs/chunks/{Grouper-jiYhVC82.js → Grouper-Bgc1wrQM.js} +1 -1
- package/dist/cjs/chunks/{IconButton-BiUfqoPb.js → IconButton-CBWmUZxR.js} +1 -1
- package/dist/cjs/chunks/{ProgressIndicator-B3-OxGYF.js → ProgressIndicator-DVD-gD3T.js} +1 -1
- package/dist/cjs/chunks/{PromptInput-Dsziepzs.js → PromptInput-DULf5ock.js} +1 -1
- package/dist/cjs/chunks/{RadioButton-i5n_nNV5.js → RadioButton-Ce9uf54a.js} +1 -1
- package/dist/cjs/chunks/{RadioButtonList-BCdk-5aD.js → RadioButtonList-dhPr-Uhs.js} +1 -1
- package/dist/cjs/chunks/SSEConnection-B_yE8cXz.js +140 -0
- package/dist/cjs/chunks/{TabBar-BF5CvZ-v.js → TabBar-DuwypMB6.js} +1 -1
- package/dist/cjs/chunks/{TextArea-BmOomEKp.js → TextArea-BJCjRUEG.js} +1 -1
- package/dist/cjs/chunks/{TextField-CXMyCClp.js → TextField-CjT26H_6.js} +18 -16
- package/dist/cjs/chunks/{Toast-CQ0-yuzl.js → Toast-DMUM1wuL.js} +1 -1
- package/dist/cjs/chunks/{UploadArea-B5Xvp0H4.js → UploadArea-BE6but3t.js} +1 -1
- package/dist/cjs/chunks/WSConnection-DCBuJGmb.js +206 -0
- package/dist/cjs/chunks/{_types-Cxk9tRiB.js → _types-C_zOsCbB.js} +57 -50
- package/dist/cjs/chunks/colors-uej0anrN.js +27 -0
- package/dist/cjs/chunks/sseStore-CIIeshjm.js +59 -0
- package/dist/cjs/chunks/windowStore-CCxCOUqa.js +156 -0
- package/dist/cjs/components/Button/index.js +3 -3
- package/dist/cjs/components/ButtonBar/index.js +3 -3
- package/dist/cjs/components/Camera/index.js +4 -4
- package/dist/cjs/components/Card/index.js +2 -2
- package/dist/cjs/components/CheckBox/index.js +2 -2
- package/dist/cjs/components/Chip/index.js +2 -2
- package/dist/cjs/components/DropDown/index.js +2 -2
- package/dist/cjs/components/FileList/index.js +3 -3
- package/dist/cjs/components/Grouper/index.js +2 -2
- package/dist/cjs/components/Icon/index.js +1 -1
- package/dist/cjs/components/IconButton/index.js +2 -2
- package/dist/cjs/components/Progress/index.js +2 -2
- package/dist/cjs/components/PromptInput/index.js +5 -5
- package/dist/cjs/components/RadioButton/index.js +2 -2
- package/dist/cjs/components/RadioButtonList/index.js +3 -3
- package/dist/cjs/components/TabBar/index.js +3 -3
- package/dist/cjs/components/TextArea/index.js +4 -4
- package/dist/cjs/components/Textfield/index.js +5 -5
- package/dist/cjs/components/Toast/index.js +2 -2
- package/dist/cjs/components/UploadArea/index.js +4 -4
- package/dist/cjs/hooks/useWindow.js +46 -11
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/stores/SSE.js +9 -0
- package/dist/cjs/stores/WS.js +62 -0
- package/dist/cjs/stores/window.js +14 -3
- package/dist/cjs/stores.js +20 -5
- package/dist/cjs/utils/index.js +4 -26
- package/dist/cjs/utils/objects/index.js +6 -0
- package/dist/esm/chunks/{Avatar-BQT1r-Ge.mjs → Avatar-CDMV6f9w.mjs} +1 -1
- package/dist/esm/chunks/{AvatarGroup-B787aNtD.mjs → AvatarGroup-BZ18GwhK.mjs} +1 -1
- package/dist/esm/chunks/{Button-1MgE-kl9.mjs → Button-kXFJmcKv.mjs} +5 -3
- package/dist/esm/chunks/{ButtonBar-Eahfd-40.mjs → ButtonBar-DIsqJmrS.mjs} +1 -1
- package/dist/esm/chunks/{Camera-Bvoug1KF.mjs → Camera-BvJJ5cd-.mjs} +65 -48
- package/dist/esm/chunks/{Card-RSZhXncV.mjs → Card-DjHdCav5.mjs} +1 -1
- package/dist/esm/chunks/{CheckBox-CfLedK0e.mjs → CheckBox-C1LPehvl.mjs} +1 -1
- package/dist/esm/chunks/{Chip-Db4N0WVH.mjs → Chip-ByaaWpFx.mjs} +1 -1
- package/dist/esm/chunks/{DivInput-BEpjdfu4.mjs → DivInput-B7BliU1p.mjs} +1 -1
- package/dist/esm/chunks/{DrggablePanel-DJm1Mx5u.mjs → DrggablePanel-DvactFf5.mjs} +1 -1
- package/dist/esm/chunks/{DropDown-ryz3GK81.mjs → DropDown-CM01mO_W.mjs} +1 -1
- package/dist/esm/chunks/{FileIcon-_mK2EcB2.mjs → FileIcon-CC_k5dUW.mjs} +1 -1
- package/dist/esm/chunks/{FileList-hCMTALyN.mjs → FileList-Bon537-t.mjs} +4 -4
- package/dist/esm/chunks/{Grouper-B1gjd3Sx.mjs → Grouper-DNmAYWdR.mjs} +1 -1
- package/dist/esm/chunks/{IconButton-SyRu990z.mjs → IconButton-C8RBNFzh.mjs} +1 -1
- package/dist/esm/chunks/{Label-DGOkB_Px.mjs → Label-DOvquc82.mjs} +1 -1
- package/dist/esm/chunks/{Pager-BA0lD9mI.mjs → Pager-BX4TMwD_.mjs} +1 -1
- package/dist/esm/chunks/{ProgressIndicator-BayyosKr.mjs → ProgressIndicator-D2eairZl.mjs} +1 -1
- package/dist/esm/chunks/{PromptInput-CUXCuYVA.mjs → PromptInput-DXFAZspz.mjs} +2 -2
- package/dist/esm/chunks/{RadioButton-BRFSVtmm.mjs → RadioButton-_lo_FJ8g.mjs} +2 -2
- package/dist/esm/chunks/{RadioButtonList-D6a_EcB6.mjs → RadioButtonList-CLHJxrI_.mjs} +1 -1
- package/dist/esm/chunks/SSEConnection-Dj9P0SWE.mjs +140 -0
- package/dist/esm/chunks/{Slider-D2XVyi2g.mjs → Slider-Bih21QiT.mjs} +1 -1
- package/dist/esm/chunks/{TabBar-BqajqueL.mjs → TabBar-CDDzA_m1.mjs} +2 -2
- package/dist/esm/chunks/{TextArea-C5EbLAN1.mjs → TextArea-DBmM6aQm.mjs} +1 -1
- package/dist/esm/chunks/{TextField-DnQxDxus.mjs → TextField-DyUTMegV.mjs} +20 -18
- package/dist/esm/chunks/{Tip-B64Pa9eq.mjs → Tip-B-cDOFvV.mjs} +1 -1
- package/dist/esm/chunks/{Toast-B3GgzcTW.mjs → Toast-ovxR12_-.mjs} +2 -2
- package/dist/esm/chunks/{UploadArea-DpWT-5DA.mjs → UploadArea-tT5V8q23.mjs} +4 -4
- package/dist/esm/chunks/WSConnection-DlYSitff.mjs +206 -0
- package/dist/esm/chunks/{_types-DGDKmYIh.mjs → _types-CTmvSEX0.mjs} +36 -29
- package/dist/esm/chunks/colors-DR9fLI5X.mjs +30 -0
- package/dist/esm/chunks/{misc-Osk7tIah.mjs → misc-cg9I7drO.mjs} +1 -1
- package/dist/esm/chunks/sseStore-DdqmnAAf.mjs +56 -0
- package/dist/esm/chunks/windowStore-BOTh1g37.mjs +148 -0
- package/dist/esm/components/Avatar/index.mjs +2 -2
- package/dist/esm/components/AvatarGroup/index.mjs +3 -3
- package/dist/esm/components/Button/index.mjs +4 -4
- package/dist/esm/components/ButtonBar/index.mjs +4 -4
- package/dist/esm/components/Camera/index.mjs +5 -5
- package/dist/esm/components/Card/index.mjs +3 -3
- package/dist/esm/components/CheckBox/index.mjs +3 -3
- package/dist/esm/components/Chip/index.mjs +3 -3
- package/dist/esm/components/DivInput/index.mjs +2 -2
- package/dist/esm/components/DraggablePanel/index.mjs +2 -2
- package/dist/esm/components/DropDown/index.mjs +3 -3
- package/dist/esm/components/FileIcon/index.mjs +2 -2
- package/dist/esm/components/FileList/index.mjs +5 -5
- package/dist/esm/components/Grouper/index.mjs +3 -3
- package/dist/esm/components/Icon/index.mjs +2 -2
- package/dist/esm/components/IconButton/index.mjs +3 -3
- package/dist/esm/components/Label/index.mjs +2 -2
- package/dist/esm/components/Pager/index.mjs +2 -2
- package/dist/esm/components/Progress/index.mjs +3 -3
- package/dist/esm/components/PromptInput/index.mjs +7 -7
- package/dist/esm/components/RadioButton/index.mjs +3 -3
- package/dist/esm/components/RadioButtonList/index.mjs +4 -4
- package/dist/esm/components/Slider/index.mjs +2 -2
- package/dist/esm/components/TabBar/index.mjs +4 -4
- package/dist/esm/components/TextArea/index.mjs +5 -5
- package/dist/esm/components/Textfield/index.mjs +6 -6
- package/dist/esm/components/Tip/index.mjs +2 -2
- package/dist/esm/components/Toast/index.mjs +3 -3
- package/dist/esm/components/UploadArea/index.mjs +6 -6
- package/dist/esm/hooks/useTrackRenders.mjs +1 -1
- package/dist/esm/hooks/useWindow.mjs +47 -11
- package/dist/esm/index.mjs +31 -31
- package/dist/esm/stores/SSE.mjs +7 -0
- package/dist/esm/stores/WS.mjs +59 -0
- package/dist/esm/stores/window.mjs +3 -1
- package/dist/esm/stores.mjs +6 -2
- package/dist/esm/utils/index.mjs +6 -30
- package/dist/esm/utils/objects/index.mjs +5 -0
- package/dist/types/components/Camera/_types.d.ts +1 -0
- package/dist/types/components/Icon/_types.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/hooks/useWindow/useWindow.d.ts +19 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/stores/SSE/_types.d.ts +17 -0
- package/dist/types/stores/SSE/index.d.ts +2 -0
- package/dist/types/stores/SSE/sseStore.d.ts +28 -0
- package/dist/types/stores/WS/_types.d.ts +17 -0
- package/dist/types/stores/WS/index.d.ts +2 -0
- package/dist/types/stores/WS/wsStore.d.ts +19 -0
- package/dist/types/stores/index.d.ts +1 -0
- package/dist/types/stores/window/_types.d.ts +5 -0
- package/dist/types/stores/window/index.d.ts +3 -2
- package/dist/types/stores/window/windowStore.d.ts +8 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/objects/SSEConnection/SSEConnection.d.ts +166 -0
- package/dist/types/utils/objects/WSConnection/WSConnection.d.ts +147 -0
- package/dist/types/utils/objects/index.d.ts +4 -0
- package/package.json +6 -1
- package/dist/cjs/chunks/windowStore-RaJswiHM.js +0 -70
- package/dist/esm/chunks/windowStore-CwW0i_le.mjs +0 -71
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require("./tslib.es6-C8dZW5nY.js");
|
|
4
|
+
|
|
5
|
+
exports.WSConnection = class {
|
|
6
|
+
get connected() {
|
|
7
|
+
var _a;
|
|
8
|
+
return (null === (_a = this.socket) || void 0 === _a ? void 0 : _a.readyState) === WebSocket.OPEN;
|
|
9
|
+
}
|
|
10
|
+
get connection() {
|
|
11
|
+
return this.socket;
|
|
12
|
+
}
|
|
13
|
+
constructor(options) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
|
+
if (this.socket = null, this.keepAliveTimer = null, this.reconnectIntervalTimer = null,
|
|
16
|
+
this.reconnectAttemptsCount = 0, this.manuallyClosed = !1,
|
|
17
|
+
/**
|
|
18
|
+
* Open handler
|
|
19
|
+
*/
|
|
20
|
+
this.onOpen = event => tslib_es6.__awaiter(this, void 0, void 0, function*() {
|
|
21
|
+
var _a;
|
|
22
|
+
if (this.clearReconnectTimer(), this.reconnectAttemptsCount = 0, this.manuallyClosed = !1,
|
|
23
|
+
null === (_a = this.onOpenCallback) || void 0 === _a || _a.call(this, event), this.emitUnifiedMessage({
|
|
24
|
+
type: "open",
|
|
25
|
+
event: event
|
|
26
|
+
}), this.token) try {
|
|
27
|
+
const token = "string" == typeof this.token ? this.token : yield this.token();
|
|
28
|
+
if (!token) return void this.closeSocket({
|
|
29
|
+
code: 1e3,
|
|
30
|
+
reason: "Access token not provided"
|
|
31
|
+
});
|
|
32
|
+
this.send({
|
|
33
|
+
token: token
|
|
34
|
+
});
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const errorEvent = new ErrorEvent("token error", {
|
|
37
|
+
message: "Failed to resolve access token",
|
|
38
|
+
error: error
|
|
39
|
+
});
|
|
40
|
+
return this.emitErrorEvent(errorEvent), void this.closeSocket({
|
|
41
|
+
code: 1011,
|
|
42
|
+
reason: "Access token resolution failed"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
this.keepAlive && this.setKeepAlive();
|
|
46
|
+
}),
|
|
47
|
+
/**
|
|
48
|
+
* Message handler
|
|
49
|
+
*/
|
|
50
|
+
this.onMessage = event => {
|
|
51
|
+
const data = this.parseEventData(event.data);
|
|
52
|
+
void 0 !== data && (this.emitParsedMessage(data), this.emitUnifiedMessage({
|
|
53
|
+
type: "message",
|
|
54
|
+
data: data,
|
|
55
|
+
event: event
|
|
56
|
+
}));
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Close handler with the reconnection logic as needed
|
|
60
|
+
*/
|
|
61
|
+
this.onClose = event => {
|
|
62
|
+
var _a;
|
|
63
|
+
null === (_a = this.onCloseCallback) || void 0 === _a || _a.call(this, event), this.emitUnifiedMessage({
|
|
64
|
+
type: "close",
|
|
65
|
+
event: event
|
|
66
|
+
}), this.closeSocket(event), this.shouldReconnect(event) && this.reconnect();
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Error handler
|
|
70
|
+
*/
|
|
71
|
+
this.onError = event => {
|
|
72
|
+
const error = event instanceof ErrorEvent ? event : new ErrorEvent("websocket error", {
|
|
73
|
+
message: "WebSocket connection error"
|
|
74
|
+
});
|
|
75
|
+
this.emitErrorEvent(error);
|
|
76
|
+
}, this.url = options.url, this.autoReconnect = null === (_a = options.autoReconnect) || void 0 === _a || _a,
|
|
77
|
+
this.reconnectInterval = null !== (_b = options.reconnectInterval) && void 0 !== _b ? _b : 1e3,
|
|
78
|
+
this.reconnectAttempts = null !== (_c = options.reconnectAttempts) && void 0 !== _c ? _c : 5,
|
|
79
|
+
this.reconnectFalloff = null === (_d = options.reconnectFalloff) || void 0 === _d || _d,
|
|
80
|
+
this.keepAlive = null === (_e = options.keepAlive) || void 0 === _e || _e, this.keepAliveInterval = null !== (_f = options.keepAliveInterval) && void 0 !== _f ? _f : 3e4,
|
|
81
|
+
this.unifiedMessages = null !== (_g = options.unifiedMessages) && void 0 !== _g && _g,
|
|
82
|
+
this.token = null !== (_h = options.token) && void 0 !== _h ? _h : "", this.onMessageCallback = options.onMessageCallback,
|
|
83
|
+
this.onOpenCallback = options.onOpenCallback, this.onCloseCallback = options.onCloseCallback,
|
|
84
|
+
this.onErrorCallback = options.onErrorCallback, "undefined" == typeof WebSocket) throw new TypeError("WebSocket is not supported in this environment.");
|
|
85
|
+
this.connect();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gracefully handle sending messages
|
|
89
|
+
*/ send(message) {
|
|
90
|
+
var _a;
|
|
91
|
+
const data = "string" == typeof message ? message : JSON.stringify(message);
|
|
92
|
+
null === (_a = this.socket) || void 0 === _a || _a.send(data);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gracefully expose socket close
|
|
96
|
+
*/ close(closeEvent) {
|
|
97
|
+
this.manuallyClosed = !0, this.clearReconnectTimer(), this.reconnectAttemptsCount = 0,
|
|
98
|
+
this.closeSocket(closeEvent);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Emit the parsed message content for standard mode
|
|
102
|
+
*/ emitParsedMessage(data) {
|
|
103
|
+
if (this.unifiedMessages) return;
|
|
104
|
+
const callback = this.onMessageCallback;
|
|
105
|
+
null == callback || callback(data);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Emit a unified message if the unified flag is on
|
|
109
|
+
*/ emitUnifiedMessage(message) {
|
|
110
|
+
if (!this.unifiedMessages) return;
|
|
111
|
+
const callback = this.onMessageCallback;
|
|
112
|
+
null == callback || callback(message);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Emit error
|
|
116
|
+
*/ emitErrorEvent(error) {
|
|
117
|
+
var _a;
|
|
118
|
+
null === (_a = this.onErrorCallback) || void 0 === _a || _a.call(this, error), this.emitUnifiedMessage({
|
|
119
|
+
type: "error",
|
|
120
|
+
event: error
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Safe JSON parse message content
|
|
125
|
+
*/ parseEventData(rawData) {
|
|
126
|
+
if (rawData instanceof Blob || rawData instanceof ArrayBuffer || "string" == typeof rawData) {
|
|
127
|
+
if ("string" != typeof rawData) return rawData;
|
|
128
|
+
try {
|
|
129
|
+
return JSON.parse(rawData);
|
|
130
|
+
} catch (_a) {
|
|
131
|
+
return rawData;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
this.emitErrorEvent(new ErrorEvent("parse error", {
|
|
135
|
+
message: "Unsupported websocket message data format"
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Attach socket listeners
|
|
140
|
+
*/ attachEventListeners() {
|
|
141
|
+
this.socket && (this.socket.addEventListener("open", this.onOpen), this.socket.addEventListener("message", this.onMessage),
|
|
142
|
+
this.socket.addEventListener("close", this.onClose), this.socket.addEventListener("error", this.onError));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* set keep alive pings
|
|
146
|
+
*/ setKeepAlive() {
|
|
147
|
+
this.socket && this.keepAlive && (this.keepAliveTimer && clearInterval(this.keepAliveTimer),
|
|
148
|
+
this.keepAliveTimer = setInterval(() => {
|
|
149
|
+
var _a;
|
|
150
|
+
(null === (_a = this.socket) || void 0 === _a ? void 0 : _a.readyState) === WebSocket.OPEN && this.socket.send("ping");
|
|
151
|
+
}, this.keepAliveInterval));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Clear keep alive pings
|
|
155
|
+
*/ clearKeepAliveTimer() {
|
|
156
|
+
this.keepAliveTimer && (clearInterval(this.keepAliveTimer), this.keepAliveTimer = null);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Clear reconnect timer
|
|
160
|
+
*/ clearReconnectTimer() {
|
|
161
|
+
this.reconnectIntervalTimer && (clearTimeout(this.reconnectIntervalTimer), this.reconnectIntervalTimer = null);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* detach all event listeners
|
|
165
|
+
*/ detachEventListeners() {
|
|
166
|
+
this.socket && (this.socket.removeEventListener("open", this.onOpen), this.socket.removeEventListener("message", this.onMessage),
|
|
167
|
+
this.socket.removeEventListener("close", this.onClose), this.socket.removeEventListener("error", this.onError));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Connect the socket
|
|
171
|
+
*/ connect() {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
(null === (_a = this.socket) || void 0 === _a ? void 0 : _a.readyState) !== WebSocket.OPEN && (null === (_b = this.socket) || void 0 === _b ? void 0 : _b.readyState) !== WebSocket.CONNECTING && (this.socket = new WebSocket(this.url),
|
|
174
|
+
this.attachEventListeners());
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Reconnect logic
|
|
178
|
+
*/ reconnect() {
|
|
179
|
+
if (!this.autoReconnect || this.manuallyClosed) return;
|
|
180
|
+
if (this.reconnectIntervalTimer) return;
|
|
181
|
+
const nextAttempt = this.reconnectAttemptsCount + 1;
|
|
182
|
+
if (nextAttempt > this.reconnectAttempts) return;
|
|
183
|
+
this.reconnectAttemptsCount = nextAttempt;
|
|
184
|
+
const delay = this.getReconnectDelay(nextAttempt);
|
|
185
|
+
this.reconnectIntervalTimer = setTimeout(() => {
|
|
186
|
+
this.reconnectIntervalTimer = null, this.manuallyClosed || this.connect();
|
|
187
|
+
}, delay);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Calculate reconnect delay with fall off
|
|
191
|
+
*/ getReconnectDelay(attempt) {
|
|
192
|
+
return this.reconnectFalloff ? this.reconnectInterval * Math.pow(2, attempt - 1) : this.reconnectInterval;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Determine if should reconnect based on the close event and props
|
|
196
|
+
*/ shouldReconnect(event) {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
return (null === (_a = this.socket) || void 0 === _a ? void 0 : _a.readyState) !== WebSocket.CONNECTING && (null === (_b = this.socket) || void 0 === _b ? void 0 : _b.readyState) !== WebSocket.OPEN && (this.autoReconnect && !this.manuallyClosed && !event.wasClean);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Internal close socket - does not reset retry logic
|
|
202
|
+
*/ closeSocket(closeEvent) {
|
|
203
|
+
this.socket && (this.clearKeepAliveTimer(), this.detachEventListeners(), this.socket.readyState !== WebSocket.CLOSED && this.socket.readyState !== WebSocket.CLOSING && this.socket.close(closeEvent.code || 1e3, closeEvent.reason || "Clean shutdown"),
|
|
204
|
+
this.socket = null, this.keepAliveTimer = null);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
@@ -12,14 +12,27 @@ styleInject_es.styleInject(".Icon-module_icon__szG-X {\n\tcursor: var(--cursor);
|
|
|
12
12
|
* Static icon registry created once at module load.
|
|
13
13
|
* Each entry stores only icon line content renderers.
|
|
14
14
|
*/
|
|
15
|
-
const STATIC_ICON_REGISTRY = new Map([ [ "video", {
|
|
15
|
+
const STATIC_ICON_REGISTRY = new Map([ [ "video off", {
|
|
16
16
|
line: ({strokeColor: strokeColor}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
17
17
|
children: [ jsxRuntime.jsx("path", {
|
|
18
|
-
d: "
|
|
18
|
+
d: "M10.97,14.75H3.04c-.16,0-.29-.11-.29-.25v-6.79l-1.5-1.29v8.08c0,.96.8,1.75,1.79,1.75h9.68l-1.75-1.5Z",
|
|
19
|
+
fill: strokeColor
|
|
20
|
+
}), jsxRuntime.jsx("path", {
|
|
21
|
+
d: "M18.39,5.86c-.23-.13-.51-.14-.74-.02l-2.9,1.55v-1.38c0-.97-.81-1.76-1.8-1.76H4.87l1.75,1.5h6.33c.17,0,.3.12.3.26v5.43l2.7,2.32,1.69.91c.11.06.23.09.35.09.13,0,.27-.04.39-.11.23-.14.36-.38.36-.64v-7.5c0-.26-.14-.51-.36-.64ZM17.25,12.75l-2.5-1.34v-2.32l2.5-1.34v4.99Z",
|
|
22
|
+
fill: strokeColor
|
|
23
|
+
}), jsxRuntime.jsx("path", {
|
|
24
|
+
d: "M15.21,16.5c-.17,0-.35-.06-.49-.18L1.3,4.82c-.31-.27-.35-.74-.08-1.06.27-.31.74-.35,1.06-.08l13.42,11.5c.31.27.35.74.08,1.06-.15.17-.36.26-.57.26Z",
|
|
25
|
+
fill: strokeColor
|
|
26
|
+
}) ]
|
|
27
|
+
})
|
|
28
|
+
} ], [ "video", {
|
|
29
|
+
line: ({strokeColor: strokeColor}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
30
|
+
children: [ jsxRuntime.jsx("path", {
|
|
31
|
+
d: "M18.39,5.86c-.23-.13-.51-.14-.74-.02l-2.9,1.55v-1.38c0-.97-.81-1.76-1.8-1.76H3.04c-.99,0-1.79.79-1.79,1.75v8.5c0,.96.8,1.75,1.79,1.75h9.91c.99,0,1.79-.79,1.79-1.75v-1.39l2.9,1.55c.11.06.23.09.35.09.13,0,.27-.04.39-.11.23-.14.36-.38.36-.64v-7.5c0-.26-.14-.51-.36-.64ZM13.25,14.5c0,.14-.13.25-.29.25H3.04c-.16,0-.29-.11-.29-.25V6c0-.14.13-.25.29-.25h9.91c.17,0,.3.12.3.26v8.49ZM17.25,12.75l-2.5-1.34v-2.32l2.5-1.34v4.99Z",
|
|
19
32
|
fill: strokeColor
|
|
20
33
|
}), jsxRuntime.jsx("circle", {
|
|
21
|
-
cx: "
|
|
22
|
-
cy: "
|
|
34
|
+
cx: "8",
|
|
35
|
+
cy: "10.25",
|
|
23
36
|
r: "1",
|
|
24
37
|
fill: strokeColor
|
|
25
38
|
}) ]
|
|
@@ -27,49 +40,43 @@ const STATIC_ICON_REGISTRY = new Map([ [ "video", {
|
|
|
27
40
|
} ], [ "mic", {
|
|
28
41
|
line: ({strokeColor: strokeColor}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29
42
|
children: [ jsxRuntime.jsx("path", {
|
|
30
|
-
d: "
|
|
43
|
+
d: "M10.25,11.75c1.65,0,3-1.35,3-3v-4.5c0-1.65-1.35-3-3-3s-3,1.35-3,3v4.5c0,1.65,1.35,3,3,3ZM8.75,4.25c0-.83.67-1.5,1.5-1.5s1.5.67,1.5,1.5v4.5c0,.83-.67,1.5-1.5,1.5s-1.5-.67-1.5-1.5v-4.5Z",
|
|
31
44
|
fill: strokeColor
|
|
32
45
|
}), jsxRuntime.jsx("path", {
|
|
33
|
-
d: "
|
|
46
|
+
d: "M14.75,7.25v1.25c0,2.48-2.02,4.5-4.5,4.5s-4.5-2.02-4.5-4.5v-1.25h-1.5v1.25c0,3.08,2.33,5.62,5.31,5.96v2.79h-3.59v1.5h8.48v-1.5h-3.39v-2.81c2.92-.4,5.19-2.91,5.19-5.94v-1.25h-1.5Z",
|
|
34
47
|
fill: strokeColor
|
|
35
48
|
}) ]
|
|
36
49
|
})
|
|
37
50
|
} ], [ "mic muted", {
|
|
38
|
-
line: ({strokeColor: strokeColor
|
|
51
|
+
line: ({strokeColor: strokeColor}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
39
52
|
children: [ jsxRuntime.jsx("path", {
|
|
40
|
-
d: "
|
|
53
|
+
d: "M8.78,3.95c.14-.68.74-1.2,1.47-1.2.83,0,1.5.67,1.5,1.5v2.67l1.5,1.5v-4.17c0-1.65-1.35-3-3-3-1.13,0-2.1.63-2.61,1.56l1.14,1.14Z",
|
|
41
54
|
fill: strokeColor
|
|
42
55
|
}), jsxRuntime.jsx("path", {
|
|
43
|
-
d: "
|
|
56
|
+
d: "M7.25,8.08v.67c0,1.65,1.35,3,3,3,.21,0,.41-.02.61-.06l-3.61-3.61Z",
|
|
44
57
|
fill: strokeColor
|
|
45
58
|
}), jsxRuntime.jsx("path", {
|
|
46
|
-
d: "
|
|
59
|
+
d: "M14.75,7.25v1.25c0,.43-.08.84-.19,1.23l1.17,1.17c.33-.74.52-1.54.52-2.4v-1.25h-1.5Z",
|
|
47
60
|
fill: strokeColor
|
|
48
61
|
}), jsxRuntime.jsx("path", {
|
|
49
|
-
d: "
|
|
62
|
+
d: "M11.06,14.44c.69-.09,1.33-.31,1.93-.62l-1.13-1.13c-.5.19-1.04.31-1.61.31-2.48,0-4.5-2.02-4.5-4.5v-1.25h-1.5v1.25c0,3.08,2.33,5.62,5.31,5.96v2.79h-3.59v1.5h8.48v-1.5h-3.39v-2.81Z",
|
|
63
|
+
fill: strokeColor
|
|
64
|
+
}), jsxRuntime.jsx("path", {
|
|
65
|
+
d: "M16.75,15.5c-.19,0-.38-.07-.53-.22L3.72,2.78c-.29-.29-.29-.77,0-1.06s.77-.29,1.06,0l12.5,12.5c.29.29.29.77,0,1.06-.15.15-.34.22-.53.22Z",
|
|
50
66
|
fill: strokeColor
|
|
51
|
-
}), jsxRuntime.jsx("line", {
|
|
52
|
-
x1: "3.5",
|
|
53
|
-
y1: "2.5",
|
|
54
|
-
x2: "16",
|
|
55
|
-
y2: "15",
|
|
56
|
-
stroke: strokeColor,
|
|
57
|
-
strokeLinecap: "round",
|
|
58
|
-
strokeLinejoin: "round",
|
|
59
|
-
strokeWidth: stroke
|
|
60
67
|
}) ]
|
|
61
68
|
})
|
|
62
69
|
} ], [ "camera", {
|
|
63
70
|
line: ({strokeColor: strokeColor}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
64
71
|
children: [ jsxRuntime.jsx("path", {
|
|
65
|
-
d: "M16.
|
|
72
|
+
d: "M16.75,16.25H3.25c-.96,0-1.75-.79-1.75-1.75V5.5c0-.96.79-1.75,1.75-1.75h13.5c.96,0,1.75.79,1.75,1.75v9c0,.96-.79,1.75-1.75,1.75ZM3.25,5.25c-.14,0-.25.11-.25.25v9c0,.14.11.25.25.25h13.5c.14,0,.25-.11.25-.25V5.5c0-.14-.11-.25-.25-.25H3.25Z",
|
|
66
73
|
fill: strokeColor
|
|
67
74
|
}), jsxRuntime.jsx("path", {
|
|
68
|
-
d: "
|
|
75
|
+
d: "M11.94,13.75c-2.03,0-3.69-1.65-3.69-3.69s1.65-3.69,3.69-3.69,3.69,1.65,3.69,3.69-1.65,3.69-3.69,3.69ZM11.94,7.88c-1.21,0-2.19.98-2.19,2.19s.98,2.19,2.19,2.19,2.19-.98,2.19-2.19-.98-2.19-2.19-2.19Z",
|
|
69
76
|
fill: strokeColor
|
|
70
77
|
}), jsxRuntime.jsx("circle", {
|
|
71
|
-
cx: "
|
|
72
|
-
cy: "
|
|
78
|
+
cx: "6",
|
|
79
|
+
cy: "8",
|
|
73
80
|
r: "1",
|
|
74
81
|
fill: strokeColor
|
|
75
82
|
}) ]
|
|
@@ -1030,29 +1037,29 @@ var IconNames;
|
|
|
1030
1037
|
|
|
1031
1038
|
Icon.displayName = "Icon", exports.IconNames = void 0, (IconNames = exports.IconNames || (exports.IconNames = {})).video = "video",
|
|
1032
1039
|
IconNames.mic = "mic", IconNames.micMuted = "mic muted", IconNames.camera = "camera",
|
|
1033
|
-
IconNames.
|
|
1034
|
-
IconNames.
|
|
1035
|
-
IconNames.
|
|
1036
|
-
IconNames.
|
|
1037
|
-
IconNames.
|
|
1038
|
-
IconNames.
|
|
1039
|
-
IconNames.
|
|
1040
|
-
IconNames.
|
|
1041
|
-
IconNames.
|
|
1042
|
-
IconNames.
|
|
1043
|
-
IconNames.
|
|
1044
|
-
IconNames.
|
|
1045
|
-
IconNames.
|
|
1046
|
-
IconNames.
|
|
1047
|
-
IconNames.
|
|
1048
|
-
IconNames.
|
|
1049
|
-
IconNames.
|
|
1050
|
-
IconNames.
|
|
1051
|
-
IconNames.
|
|
1052
|
-
IconNames.
|
|
1053
|
-
IconNames.
|
|
1054
|
-
IconNames.
|
|
1055
|
-
IconNames.
|
|
1056
|
-
IconNames.
|
|
1057
|
-
IconNames.
|
|
1058
|
-
exports.Icon = Icon;
|
|
1040
|
+
IconNames.videoOff = "video off", IconNames.home = "home", IconNames.inbox = "inbox",
|
|
1041
|
+
IconNames.sparkle = "sparkle", IconNames.people = "people", IconNames.wallet = "wallet",
|
|
1042
|
+
IconNames.invoice = "invoice", IconNames.payment = "payment", IconNames.heart = "heart",
|
|
1043
|
+
IconNames.clock = "clock", IconNames.book = "book", IconNames.search = "search",
|
|
1044
|
+
IconNames.filter = "filter", IconNames.more = "more", IconNames.checkbox = "checkbox",
|
|
1045
|
+
IconNames.checkboxChecked = "checkbox checked", IconNames.checkboxPartial = "checkbox partial",
|
|
1046
|
+
IconNames.chevronDown = "chevron down", IconNames.chevronUp = "chevron up", IconNames.plus = "plus",
|
|
1047
|
+
IconNames.plusCircle = "plus circle", IconNames.x = "x", IconNames.upload = "upload",
|
|
1048
|
+
IconNames.download = "download", IconNames.share = "share", IconNames.checkCircle = "check circle",
|
|
1049
|
+
IconNames.circle = "circle", IconNames.circleFill = "circle fill", IconNames.person = "person",
|
|
1050
|
+
IconNames.attach = "attach", IconNames.menu = "menu", IconNames.help = "help", IconNames.blank = "blank",
|
|
1051
|
+
IconNames.check = "check", IconNames.message = "message", IconNames.info = "info",
|
|
1052
|
+
IconNames.alert = "alert", IconNames.notification = "notification", IconNames.arrowUp = "arrow up",
|
|
1053
|
+
IconNames.arrowLeft = "arrow left", IconNames.arrowRight = "arrow right", IconNames.navigate = "navigate",
|
|
1054
|
+
IconNames.document = "document", IconNames.refresh = "refresh", IconNames.recentChats = "recent chats",
|
|
1055
|
+
IconNames.trashBin = "trash bin", IconNames.dollar = "dollar", IconNames.apple = "apple",
|
|
1056
|
+
IconNames.view = "view", IconNames.openCircle = "open circle", IconNames.expanded = "expanded",
|
|
1057
|
+
IconNames.concise = "concise", IconNames.moderate = "moderate", IconNames.mail = "mail",
|
|
1058
|
+
IconNames.textDocument = "text document", IconNames.edit = "edit", IconNames.characterBeam = "character beam",
|
|
1059
|
+
IconNames.undo = "undo", IconNames.chat = "chat", IconNames.exclamation = "exclamation",
|
|
1060
|
+
IconNames.chart = "chart", IconNames.lightBulb = "light bulb", IconNames.settings = "settings",
|
|
1061
|
+
IconNames.documentEditor = "document editor", IconNames.chartArrow = "chart arrow",
|
|
1062
|
+
IconNames.focus = "focus", IconNames.briefcase = "briefcase", IconNames.globeLocation = "globe location",
|
|
1063
|
+
IconNames.barChart = "bar chart", IconNames.fontSmaller = "font smaller", IconNames.fontLarger = "font larger",
|
|
1064
|
+
IconNames.copy = "copy", IconNames.stop = "stop", IconNames.like = "like", IconNames.unlike = "unlike",
|
|
1065
|
+
IconNames.highlight = "highlight", exports.Icon = Icon;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a tint value from a hex color
|
|
5
|
+
*/ exports.addOpacity = (color, opacity) => {
|
|
6
|
+
if (!color) return "";
|
|
7
|
+
const alpha = Number.isFinite(opacity) ? Math.max(0, Math.min(1, opacity)) : 1, trimmed = color.trim();
|
|
8
|
+
if (trimmed.startsWith("#")) {
|
|
9
|
+
const normalized = trimmed.slice(1), fullHex = 3 === normalized.length ? normalized.split("").map(char => `${char}${char}`).join("") : normalized;
|
|
10
|
+
if (!/^[0-9a-fA-F]{6}$/.test(fullHex)) return color;
|
|
11
|
+
return `rgba(${Number.parseInt(fullHex.slice(0, 2), 16)}, ${Number.parseInt(fullHex.slice(2, 4), 16)}, ${Number.parseInt(fullHex.slice(4, 6), 16)}, ${alpha})`;
|
|
12
|
+
}
|
|
13
|
+
const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*[\d.]+\s*)?\)$/);
|
|
14
|
+
if (rgbMatch) {
|
|
15
|
+
const [, r, g, b] = rgbMatch;
|
|
16
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
17
|
+
}
|
|
18
|
+
return color;
|
|
19
|
+
}, exports.tintFromColor = (hex, percent) => {
|
|
20
|
+
const normalizedHex = hex.trim().replace("#", "");
|
|
21
|
+
if (!(3 === normalizedHex.length || 6 === normalizedHex.length) || !/^[0-9a-fA-F]+$/.test(normalizedHex)) return hex;
|
|
22
|
+
const fullHex = 3 === normalizedHex.length ? normalizedHex.split("").map(char => `${char}${char}`).join("") : normalizedHex, ratio = Math.max(-1, Math.min(1, Math.abs(percent) > 1 ? percent / 100 : percent)), mixTo = ratio >= 0 ? 255 : 0, mix = Math.abs(ratio);
|
|
23
|
+
return `#${[ 0, 2, 4 ].map(start => Number.parseInt(fullHex.slice(start, start + 2), 16)).map(channel => {
|
|
24
|
+
const next = Math.round(channel + (mixTo - channel) * mix);
|
|
25
|
+
return Math.max(0, Math.min(255, next));
|
|
26
|
+
}).map(channel => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
27
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var zustand = require("zustand");
|
|
4
|
+
|
|
5
|
+
require("./tslib.es6-C8dZW5nY.js");
|
|
6
|
+
|
|
7
|
+
var SSEConnection = require("./SSEConnection-B_yE8cXz.js");
|
|
8
|
+
|
|
9
|
+
const useSSEStore = zustand.create((set, get) => ({
|
|
10
|
+
connections: [],
|
|
11
|
+
message: null,
|
|
12
|
+
closedConnection: null,
|
|
13
|
+
actions: {
|
|
14
|
+
addConnection: (name, options) => {
|
|
15
|
+
const existingConnection = get().connections.find(c => c.name === name);
|
|
16
|
+
null == existingConnection || existingConnection.connection.close();
|
|
17
|
+
const userOnMessageCallback = options.onMessageCallback, connection = new SSEConnection.SSEConnection(Object.assign(Object.assign({}, options), {
|
|
18
|
+
unifiedOnMessage: !0,
|
|
19
|
+
onMessageCallback: message => {
|
|
20
|
+
set({
|
|
21
|
+
message: message
|
|
22
|
+
}), null == userOnMessageCallback || userOnMessageCallback(message), "close" === message.type && (set({
|
|
23
|
+
closedConnection: name
|
|
24
|
+
}), get().actions.removeConnection(name));
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
return set(state => ({
|
|
28
|
+
connections: [ ...state.connections.filter(connection => connection.name !== name), {
|
|
29
|
+
name: name,
|
|
30
|
+
connection: connection
|
|
31
|
+
} ]
|
|
32
|
+
})), {
|
|
33
|
+
name: name,
|
|
34
|
+
connection: connection
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
removeConnection: name => {
|
|
38
|
+
const existingConnection = get().connections.find(c => c.name === name);
|
|
39
|
+
existingConnection && (existingConnection.connection.close(), set(state => ({
|
|
40
|
+
connections: state.connections.filter(connection => connection.name !== name)
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
const useSSEActions = useSSEStore.getState().actions;
|
|
47
|
+
|
|
48
|
+
exports.useConnectionClose = () => useSSEStore(state => state.closedConnection),
|
|
49
|
+
exports.useConnectionMessage = connection => useSSEStore(state => state.connections.some(entry => entry.name === connection) ? state.message : null),
|
|
50
|
+
exports.useIsConnected = connection => useSSEStore(state => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return connection ? null !== (_b = null === (_a = state.connections.find(entry => entry.name === connection)) || void 0 === _a ? void 0 : _a.connection.connected) && void 0 !== _b && _b : state.connections.some(entry => entry.connection.connected);
|
|
53
|
+
}), exports.useLastSSEMessage = () => useSSEStore.getState().message, exports.useMessage = function(type, connection) {
|
|
54
|
+
return useSSEStore(state => {
|
|
55
|
+
const sourceMessage = connection && !state.connections.some(c => c.name === connection) ? null : state.message;
|
|
56
|
+
return type ? (null == sourceMessage ? void 0 : sourceMessage.type) !== type ? null : "open" === type || "error" === type || "close" === type ? "event" in sourceMessage ? sourceMessage.event : null : "data" in sourceMessage ? sourceMessage.data : null : sourceMessage;
|
|
57
|
+
});
|
|
58
|
+
}, exports.useSSE = () => useSSEStore(state => state.actions), exports.useSSEActions = useSSEActions,
|
|
59
|
+
exports.useSSEStore = useSSEStore;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var FormFactor, tslib_es6 = require("./tslib.es6-C8dZW5nY.js"), zustand = require("zustand");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Form factor names
|
|
7
|
+
*/
|
|
8
|
+
exports.FormFactor = void 0, (FormFactor = exports.FormFactor || (exports.FormFactor = {})).Mobile = "mobile",
|
|
9
|
+
FormFactor.Tablet = "tablet", FormFactor.Desktop = "desktop", FormFactor.DesktopL = "desktopL",
|
|
10
|
+
FormFactor.DesktopXL = "desktopXL";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use bootstrap breakpoints
|
|
14
|
+
*/
|
|
15
|
+
const bootstrapBreakPoints = {
|
|
16
|
+
[exports.FormFactor.Mobile]: 576,
|
|
17
|
+
[exports.FormFactor.Tablet]: 768,
|
|
18
|
+
[exports.FormFactor.Desktop]: 992,
|
|
19
|
+
[exports.FormFactor.DesktopL]: 1200,
|
|
20
|
+
[exports.FormFactor.DesktopXL]: 1400
|
|
21
|
+
}, orderedBps = Object.entries(bootstrapBreakPoints).sort((a, b) => -b[1] - a[1]), getFormFactor = width => {
|
|
22
|
+
if (!width || width <= 0) return exports.FormFactor.Mobile;
|
|
23
|
+
for (const [formFactor, breakpoint] of orderedBps) if (width >= breakpoint) return formFactor;
|
|
24
|
+
return exports.FormFactor.Mobile;
|
|
25
|
+
}, isBrowser = "undefined" != typeof globalThis && "undefined" != typeof navigator, initialSize = processWindowSize(), useWindowStore = zustand.create((set, get) => ({
|
|
26
|
+
formFactor: initialSize.formFactor,
|
|
27
|
+
viewportWidth: initialSize.viewportWidth,
|
|
28
|
+
viewportHeight: initialSize.viewportHeight,
|
|
29
|
+
height: initialSize.height,
|
|
30
|
+
isElectron: checkElectron(),
|
|
31
|
+
isAppleDevice: checkAppleDevice(),
|
|
32
|
+
isTouchDevice: checkTouchDevice(),
|
|
33
|
+
dpr: getDpr(),
|
|
34
|
+
locationError: null,
|
|
35
|
+
location: null,
|
|
36
|
+
gettingLocation: !1,
|
|
37
|
+
actions: {
|
|
38
|
+
initialize: () => {
|
|
39
|
+
if (!isBrowser) return () => {};
|
|
40
|
+
const win = getViewportWindow();
|
|
41
|
+
return null == win || win.addEventListener("resize", handleResize), handleResize(),
|
|
42
|
+
() => null == win ? void 0 : win.removeEventListener("resize", handleResize);
|
|
43
|
+
},
|
|
44
|
+
getLocation: () => tslib_es6.__awaiter(void 0, void 0, void 0, function*() {
|
|
45
|
+
if (!isBrowser || !("geolocation" in navigator)) {
|
|
46
|
+
const error = createLocationError("Geolocation is not supported in this browser.", 0);
|
|
47
|
+
throw set({
|
|
48
|
+
locationError: error,
|
|
49
|
+
gettingLocation: !1
|
|
50
|
+
}), error;
|
|
51
|
+
}
|
|
52
|
+
return set({
|
|
53
|
+
gettingLocation: !0,
|
|
54
|
+
locationError: null
|
|
55
|
+
}), yield new Promise((resolve, reject) => {
|
|
56
|
+
navigator.geolocation.getCurrentPosition(position => {
|
|
57
|
+
const location = {
|
|
58
|
+
latitude: position.coords.latitude,
|
|
59
|
+
longitude: position.coords.longitude,
|
|
60
|
+
accuracy: position.coords.accuracy,
|
|
61
|
+
altitude: position.coords.altitude,
|
|
62
|
+
altitudeAccuracy: position.coords.altitudeAccuracy,
|
|
63
|
+
heading: position.coords.heading,
|
|
64
|
+
speed: position.coords.speed,
|
|
65
|
+
timestamp: position.timestamp
|
|
66
|
+
};
|
|
67
|
+
set({
|
|
68
|
+
location: location,
|
|
69
|
+
gettingLocation: !1,
|
|
70
|
+
locationError: null
|
|
71
|
+
}), resolve(location);
|
|
72
|
+
}, err => {
|
|
73
|
+
const error = createLocationError(err.message, err.code);
|
|
74
|
+
set({
|
|
75
|
+
locationError: error,
|
|
76
|
+
gettingLocation: !1,
|
|
77
|
+
location: null
|
|
78
|
+
}), reject(error);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
function checkElectron() {
|
|
86
|
+
if (!isBrowser) return !1;
|
|
87
|
+
return navigator.userAgent.toLowerCase().includes("electron/");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function checkAppleDevice() {
|
|
91
|
+
return !!isBrowser && (navigator.platform.startsWith("Mac") || "iPhone" === navigator.platform);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function checkTouchDevice() {
|
|
95
|
+
return !!isBrowser && ("ontouchstart" in globalThis || navigator.maxTouchPoints > 0);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getDpr() {
|
|
99
|
+
var _a;
|
|
100
|
+
return isBrowser && null !== (_a = Math.min(Math.ceil(window.devicePixelRatio), 3)) && void 0 !== _a ? _a : 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function createLocationError(message, code) {
|
|
104
|
+
return new Error(message, {
|
|
105
|
+
cause: {
|
|
106
|
+
code: code
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getViewportWindow() {
|
|
112
|
+
var _a;
|
|
113
|
+
return isBrowser ? null !== (_a = window.top) && void 0 !== _a ? _a : globalThis : null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handleResize() {
|
|
117
|
+
if (!isBrowser) return;
|
|
118
|
+
const {formFactor: formFactor, viewportWidth: viewportWidth, viewportHeight: viewportHeight, height: height} = processWindowSize();
|
|
119
|
+
useWindowStore.setState({
|
|
120
|
+
formFactor: formFactor,
|
|
121
|
+
viewportWidth: viewportWidth,
|
|
122
|
+
viewportHeight: viewportHeight,
|
|
123
|
+
height: height
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function processWindowSize(top = !0) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (!isBrowser) return {
|
|
130
|
+
formFactor: exports.FormFactor.Mobile,
|
|
131
|
+
viewportWidth: -1,
|
|
132
|
+
viewportHeight: -1,
|
|
133
|
+
height: "100vh"
|
|
134
|
+
};
|
|
135
|
+
const viewport = top ? getViewportWindow() : globalThis, touch = checkTouchDevice(), windowWidth = null !== (_a = null == viewport ? void 0 : viewport.innerWidth) && void 0 !== _a ? _a : -1, windowHeight = null !== (_b = null == viewport ? void 0 : viewport.innerHeight) && void 0 !== _b ? _b : -1;
|
|
136
|
+
return {
|
|
137
|
+
formFactor: getFormFactor(windowWidth),
|
|
138
|
+
viewportWidth: windowWidth,
|
|
139
|
+
viewportHeight: windowHeight,
|
|
140
|
+
height: viewport && touch ? `${windowHeight}px` : "100vh"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
exports.dpr = () => useWindowStore.getState().dpr, exports.formFactor = () => useWindowStore.getState().formFactor,
|
|
145
|
+
exports.gettingLocation = () => useWindowStore.getState().gettingLocation, exports.isAppleDevice = () => useWindowStore.getState().isAppleDevice,
|
|
146
|
+
exports.isElectron = () => useWindowStore.getState().isElectron, exports.isTouchDevice = () => useWindowStore.getState().isTouchDevice,
|
|
147
|
+
exports.location = () => useWindowStore.getState().location, exports.locationError = () => useWindowStore.getState().locationError,
|
|
148
|
+
exports.useDpr = () => useWindowStore(state => state.dpr), exports.useFormFactor = () => useWindowStore(state => state.formFactor),
|
|
149
|
+
exports.useGetLocation = () => useWindowStore(state => state.actions.getLocation),
|
|
150
|
+
exports.useGettingLocation = () => useWindowStore(state => state.gettingLocation),
|
|
151
|
+
exports.useInitializeWindow = () => useWindowStore(state => state.actions.initialize),
|
|
152
|
+
exports.useIsAppleDevice = () => useWindowStore(state => state.isAppleDevice), exports.useIsElectron = () => useWindowStore(state => state.isElectron),
|
|
153
|
+
exports.useIsTouchDevice = () => useWindowStore(state => state.isTouchDevice), exports.useLocation = () => useWindowStore(state => state.location),
|
|
154
|
+
exports.useLocationError = () => useWindowStore(state => state.locationError), exports.useViewportHeight = () => useWindowStore(state => state.viewportHeight),
|
|
155
|
+
exports.useViewportWidth = () => useWindowStore(state => state.viewportWidth), exports.useWindowStore = useWindowStore,
|
|
156
|
+
exports.viewportHeight = () => useWindowStore.getState().viewportHeight, exports.viewportWidth = () => useWindowStore.getState().viewportWidth;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var Button = require("../../chunks/Button-
|
|
3
|
+
var Button = require("../../chunks/Button-krf4dQeL.js");
|
|
4
4
|
|
|
5
5
|
require("../../chunks/tslib.es6-C8dZW5nY.js"), require("react/jsx-runtime"), require("motion/react"),
|
|
6
6
|
require("react"), require("../../chunks/Badge-CY_DG6cD.js"), require("../../chunks/style-inject.es-CMuL-BfJ.js"),
|
|
7
|
-
require("../../chunks/Dot-_HCJ3qxd.js"), require("../../chunks/_types-
|
|
7
|
+
require("../../chunks/Dot-_HCJ3qxd.js"), require("../../chunks/_types-C_zOsCbB.js"),
|
|
8
8
|
require("../../hooks/useTheme.js"), require("../../theme/themes.js"), require("../../theme/colors.js"),
|
|
9
9
|
require("../../theme/corners.js"), require("../../theme/elevations.js"), require("../../theme/motion.js"),
|
|
10
10
|
require("../../theme/type.js"), require("../../hooks/useObserveTheme.js"), require("../../hooks/useWindow.js"),
|
|
11
|
-
require("../../chunks/misc-C-M6KKsH.js"), require("../../chunks/ProgressIndicator-
|
|
11
|
+
require("../../chunks/misc-C-M6KKsH.js"), require("../../chunks/ProgressIndicator-DVD-gD3T.js"),
|
|
12
12
|
require("../../chunks/sharedTypes-gCECyn2N.js"), exports.Button = Button.Button;
|