@arcanejs/toolkit 6.0.1 → 7.0.0
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 +156 -12
- package/dist/backend/components/base.d.mts +1 -1
- package/dist/backend/components/base.d.ts +1 -1
- package/dist/backend/components/button.d.mts +1 -1
- package/dist/backend/components/button.d.ts +1 -1
- package/dist/backend/components/button.js +2 -2
- package/dist/backend/components/button.mjs +1 -1
- package/dist/backend/components/group.d.mts +1 -1
- package/dist/backend/components/group.d.ts +1 -1
- package/dist/backend/components/group.js +2 -2
- package/dist/backend/components/group.mjs +1 -1
- package/dist/backend/components/label.d.mts +2 -2
- package/dist/backend/components/label.d.ts +2 -2
- package/dist/backend/components/label.js +2 -2
- package/dist/backend/components/label.mjs +1 -1
- package/dist/backend/components/rect.d.mts +2 -2
- package/dist/backend/components/rect.d.ts +2 -2
- package/dist/backend/components/rect.js +2 -2
- package/dist/backend/components/rect.mjs +1 -1
- package/dist/backend/components/slider-button.d.mts +2 -2
- package/dist/backend/components/slider-button.d.ts +2 -2
- package/dist/backend/components/slider-button.js +2 -2
- package/dist/backend/components/slider-button.mjs +1 -1
- package/dist/backend/components/switch.d.mts +2 -2
- package/dist/backend/components/switch.d.ts +2 -2
- package/dist/backend/components/switch.js +2 -2
- package/dist/backend/components/switch.mjs +1 -1
- package/dist/backend/components/tabs.d.mts +3 -3
- package/dist/backend/components/tabs.d.ts +3 -3
- package/dist/backend/components/tabs.js +2 -2
- package/dist/backend/components/tabs.mjs +1 -1
- package/dist/backend/components/text-input.d.mts +2 -2
- package/dist/backend/components/text-input.d.ts +2 -2
- package/dist/backend/components/text-input.js +2 -2
- package/dist/backend/components/text-input.mjs +1 -1
- package/dist/backend/components/timeline.d.mts +2 -2
- package/dist/backend/components/timeline.d.ts +2 -2
- package/dist/backend/components/timeline.js +2 -2
- package/dist/backend/components/timeline.mjs +1 -1
- package/dist/{chunk-53EOA4UE.js → chunk-2K4UT5QB.js} +1 -1
- package/dist/{chunk-4OCRZD4F.js → chunk-4AGKM5NT.js} +1 -1
- package/dist/{chunk-QAH2OSHR.js → chunk-5B65Q7RL.js} +1 -1
- package/dist/{chunk-3TXBS2UN.mjs → chunk-6PS3Q66F.mjs} +1 -1
- package/dist/{chunk-LK6MGXYC.mjs → chunk-7MQHRTBE.mjs} +1 -1
- package/dist/{chunk-U6FSQBQ3.js → chunk-A3RWE7HZ.js} +6 -4
- package/dist/{chunk-NL3W4M7J.js → chunk-CVY55KAR.js} +1 -1
- package/dist/{chunk-WDB3IMOP.mjs → chunk-GXJ3JRRK.mjs} +1 -1
- package/dist/{chunk-HTCWMJUA.js → chunk-IV3AE3CW.js} +1 -1
- package/dist/{chunk-UQWCTVMC.mjs → chunk-JHWFQLLE.mjs} +1 -1
- package/dist/{chunk-QB2WPBWV.mjs → chunk-K6V55JTG.mjs} +1 -1
- package/dist/{chunk-PG5EAV5X.mjs → chunk-MHSAHTVN.mjs} +1 -1
- package/dist/{chunk-KMEDXCBI.mjs → chunk-R5OA7LLZ.mjs} +6 -4
- package/dist/{chunk-6ELB27LK.mjs → chunk-RJLYYTZ6.mjs} +1 -1
- package/dist/{chunk-3GTEUTFT.js → chunk-TF7N4O5G.js} +1 -1
- package/dist/{chunk-E6FGU7DA.mjs → chunk-TULW7CRV.mjs} +4 -4
- package/dist/{chunk-6QWYIJLM.js → chunk-UHEZQR2Q.js} +1 -1
- package/dist/{chunk-7JIC2XBC.js → chunk-XSKWLJOQ.js} +4 -4
- package/dist/frontend/entrypoint.css +836 -0
- package/dist/frontend/entrypoint.css.map +7 -0
- package/dist/frontend/entrypoint.js +26048 -26682
- package/dist/frontend/entrypoint.js.map +4 -4
- package/dist/frontend/index.d.mts +4 -6
- package/dist/frontend/index.d.ts +4 -6
- package/dist/frontend/index.js +82 -300
- package/dist/frontend/index.mjs +89 -307
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +280 -98
- package/dist/index.mjs +250 -68
- package/dist/{toolkit-CohVRj6u.d.mts → toolkit-BPqxbDbk.d.mts} +82 -19
- package/dist/{toolkit-C_2Y8N9R.d.ts → toolkit-Bglbv3ix.d.ts} +82 -19
- package/package.json +15 -20
package/dist/frontend/index.mjs
CHANGED
|
@@ -5,311 +5,38 @@ import { initialiseListeners } from "@arcanejs/toolkit-frontend/util";
|
|
|
5
5
|
// src/frontend/stage.tsx
|
|
6
6
|
import { patchJson } from "@arcanejs/diff";
|
|
7
7
|
import {
|
|
8
|
-
useState
|
|
8
|
+
useState,
|
|
9
9
|
useRef,
|
|
10
10
|
useCallback,
|
|
11
|
-
useEffect
|
|
11
|
+
useEffect,
|
|
12
12
|
useMemo
|
|
13
13
|
} from "react";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
BaseStyle as BaseStyle2,
|
|
17
|
-
GlobalStyle as GlobalStyle2,
|
|
18
|
-
DARK_THEME as DARK_THEME2,
|
|
19
|
-
LIGHT_THEME as LIGHT_THEME2
|
|
20
|
-
} from "@arcanejs/toolkit-frontend/styling";
|
|
14
|
+
import { ThemeRoot } from "@arcanejs/toolkit-frontend/styling";
|
|
21
15
|
import {
|
|
22
16
|
GroupStateWrapper,
|
|
23
17
|
StageContext
|
|
24
18
|
} from "@arcanejs/toolkit-frontend";
|
|
25
|
-
|
|
26
|
-
// ../toolkit-frontend/src/styling.tsx
|
|
27
|
-
import {
|
|
28
|
-
createGlobalStyle,
|
|
29
|
-
css,
|
|
30
|
-
ThemeProvider
|
|
31
|
-
} from "styled-components";
|
|
32
|
-
|
|
33
|
-
// ../toolkit-frontend/src/util/index.ts
|
|
34
|
-
import { useEffect, useState as useState2 } from "react";
|
|
35
|
-
|
|
36
|
-
// ../toolkit-frontend/src/util/touch.ts
|
|
37
|
-
import { useState } from "react";
|
|
38
|
-
|
|
39
|
-
// ../toolkit-frontend/src/util/index.ts
|
|
40
|
-
var COLOR_SCHEME_SETTINGS = "arcane-color-scheme-preference";
|
|
41
|
-
var VALID_COLOR_SCHEME_PREFS = ["auto", "dark", "light"];
|
|
42
|
-
var isValidColorSchemePreference = (value) => {
|
|
43
|
-
return VALID_COLOR_SCHEME_PREFS.includes(value);
|
|
44
|
-
};
|
|
45
|
-
var useColorSchemePreferences = () => {
|
|
46
|
-
if (typeof window === "undefined") {
|
|
47
|
-
return {
|
|
48
|
-
colorSchemePreference: "auto",
|
|
49
|
-
setColorSchemePreference: () => {
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const [preference, setPreference] = useState2(
|
|
54
|
-
window.localStorage.getItem(
|
|
55
|
-
COLOR_SCHEME_SETTINGS
|
|
56
|
-
) || "auto"
|
|
57
|
-
);
|
|
58
|
-
const setColorSchemePreference = (newPreference) => {
|
|
59
|
-
if (!isValidColorSchemePreference(newPreference)) {
|
|
60
|
-
throw new Error(`Invalid color scheme preference: ${newPreference}`);
|
|
61
|
-
}
|
|
62
|
-
window.localStorage.setItem(COLOR_SCHEME_SETTINGS, newPreference);
|
|
63
|
-
window.dispatchEvent(
|
|
64
|
-
new StorageEvent("storage", {
|
|
65
|
-
key: COLOR_SCHEME_SETTINGS,
|
|
66
|
-
newValue: newPreference
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
const onStorageChange = (event) => {
|
|
72
|
-
if (event.key === COLOR_SCHEME_SETTINGS) {
|
|
73
|
-
const newValue = event.newValue;
|
|
74
|
-
if (isValidColorSchemePreference(newValue)) {
|
|
75
|
-
setPreference(newValue);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
window.addEventListener("storage", onStorageChange);
|
|
80
|
-
return () => {
|
|
81
|
-
window.removeEventListener("storage", onStorageChange);
|
|
82
|
-
};
|
|
83
|
-
}, []);
|
|
84
|
-
return {
|
|
85
|
-
colorSchemePreference: isValidColorSchemePreference(preference) ? preference : "auto",
|
|
86
|
-
setColorSchemePreference
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
var usePreferredColorScheme = () => {
|
|
90
|
-
const { colorSchemePreference } = useColorSchemePreferences();
|
|
91
|
-
const [theme, setTheme] = useState2("light");
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (typeof window !== "undefined") {
|
|
94
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
95
|
-
setTheme(mediaQuery.matches ? "dark" : "light");
|
|
96
|
-
const handleChange = (event) => {
|
|
97
|
-
setTheme(event.matches ? "dark" : "light");
|
|
98
|
-
};
|
|
99
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
100
|
-
return () => {
|
|
101
|
-
mediaQuery.removeEventListener("change", handleChange);
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}, []);
|
|
105
|
-
return colorSchemePreference === "auto" ? theme : colorSchemePreference;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// ../toolkit-frontend/src/styling.tsx
|
|
19
|
+
import { calculateClass } from "@arcanejs/toolkit-frontend/util";
|
|
109
20
|
import { jsx } from "react/jsx-runtime";
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
&.touch-mode * {
|
|
113
|
-
cursor: none !important;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
`;
|
|
117
|
-
var DARK_THEME = {
|
|
118
|
-
pageBg: "#333",
|
|
119
|
-
colorGreen: "#98c379",
|
|
120
|
-
colorRed: "#e06c75",
|
|
121
|
-
colorAmber: "#d19a66",
|
|
122
|
-
bgDark1: "#252524",
|
|
123
|
-
bg: "#2a2a2b",
|
|
124
|
-
bgLight1: "#353638",
|
|
125
|
-
borderDark: "#151516",
|
|
126
|
-
borderLight: "#1c1d1d",
|
|
127
|
-
borderLighter: "#252524",
|
|
128
|
-
borderLighterer: "#6b6b67",
|
|
129
|
-
hint: "#4286f4",
|
|
130
|
-
hintRGB: "66, 134, 244",
|
|
131
|
-
hintDark1: "#2a77f3",
|
|
132
|
-
textNormal: "#F3F3F5",
|
|
133
|
-
textActive: "#ffffff",
|
|
134
|
-
textMuted: "#777777",
|
|
135
|
-
shadows: {
|
|
136
|
-
boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.3)",
|
|
137
|
-
textShadow: "0 -1px rgba(0, 0, 0, 0.7)",
|
|
138
|
-
textShadowActive: "0 -1px rgba(0, 0, 0, 0.4)"
|
|
139
|
-
},
|
|
140
|
-
gradients: {
|
|
141
|
-
button: "linear-gradient(to bottom, #4f5053, #343436)",
|
|
142
|
-
buttonHover: "linear-gradient(to bottom, #5e6064, #393a3b)",
|
|
143
|
-
buttonActive: "linear-gradient(to bottom, #242525, #37383a)",
|
|
144
|
-
buttonPressedHover: "linear-gradient(to bottom, #282929, #414243)",
|
|
145
|
-
hintPressed: "linear-gradient(to bottom,#2a77f3,#4286f4)"
|
|
146
|
-
},
|
|
147
|
-
sizingPx: {
|
|
148
|
-
spacing: 15,
|
|
149
|
-
unitHeight: 40
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
var LIGHT_THEME = {
|
|
153
|
-
pageBg: "#f8f9fa",
|
|
154
|
-
colorGreen: "#22863a",
|
|
155
|
-
colorRed: "#d73a49",
|
|
156
|
-
colorAmber: "#b08800",
|
|
157
|
-
bgDark1: "#e9ecef",
|
|
158
|
-
bg: "#ffffff",
|
|
159
|
-
bgLight1: "#f5f5f5",
|
|
160
|
-
borderDark: "#c7c7c7",
|
|
161
|
-
borderLight: "#d7d7d7",
|
|
162
|
-
borderLighter: "#eaecef",
|
|
163
|
-
borderLighterer: "#f6f8fa",
|
|
164
|
-
hint: "#4286f4",
|
|
165
|
-
hintRGB: "0, 92, 197",
|
|
166
|
-
hintDark1: "#2a77f3",
|
|
167
|
-
textNormal: "#24292e",
|
|
168
|
-
textActive: "#202020",
|
|
169
|
-
textMuted: "#6a737d",
|
|
170
|
-
shadows: {
|
|
171
|
-
boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.05)",
|
|
172
|
-
textShadow: "0 1px rgba(255, 255, 255, 0.7)",
|
|
173
|
-
textShadowActive: "0 1px rgba(255, 255, 255, 0.4)"
|
|
174
|
-
},
|
|
175
|
-
gradients: {
|
|
176
|
-
button: "linear-gradient(to bottom, #e1e4e8, #d1d5da)",
|
|
177
|
-
buttonHover: "linear-gradient(to bottom, #d1d5da, #c1c6cc)",
|
|
178
|
-
buttonActive: "linear-gradient(to bottom, #b1b6bc, #d2d6da)",
|
|
179
|
-
buttonPressedHover: "linear-gradient(to bottom, #a1a6ac, #91969c)",
|
|
180
|
-
hintPressed: "linear-gradient(to bottom, #438bff, #85b3ff)"
|
|
181
|
-
},
|
|
182
|
-
sizingPx: DARK_THEME.sizingPx
|
|
183
|
-
};
|
|
184
|
-
var BaseStyle = createGlobalStyle`
|
|
185
|
-
* {
|
|
186
|
-
box-sizing: border-box;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
body {
|
|
190
|
-
background: ${(p) => p.theme.pageBg};
|
|
191
|
-
margin: 0;
|
|
192
|
-
padding: 0;
|
|
193
|
-
font-size: 14px;
|
|
194
|
-
font-family: sans-serif;
|
|
195
|
-
}
|
|
196
|
-
`;
|
|
197
|
-
var buttonStateNormal = css`
|
|
198
|
-
color: ${(p) => p.theme.textNormal};
|
|
199
|
-
background: ${(p) => p.theme.gradients.button};
|
|
200
|
-
text-shadow: ${(p) => p.theme.shadows.textShadow};
|
|
201
|
-
box-shadow:
|
|
202
|
-
inset 0 1px 0 rgba(255, 255, 255, 0.15),
|
|
203
|
-
0 1px 0 0 rgba(0, 0, 0, 0.25);
|
|
204
|
-
`;
|
|
205
|
-
var buttonStateNormalHover = css`
|
|
206
|
-
color: ${(p) => p.theme.textNormal};
|
|
207
|
-
outline-color: rgba(243, 243, 245, 0.3);
|
|
208
|
-
background: ${(p) => p.theme.gradients.buttonHover};
|
|
209
|
-
text-shadow: ${(p) => p.theme.shadows.textShadow};
|
|
210
|
-
`;
|
|
211
|
-
var buttonStateNormalActive = css`
|
|
212
|
-
color: ${(p) => p.theme.textNormal};
|
|
213
|
-
outline-color: rgba(255, 255, 255, 0.3);
|
|
214
|
-
background: ${(p) => p.theme.gradients.buttonActive};
|
|
215
|
-
text-shadow: ${(p) => p.theme.shadows.textShadowActive};
|
|
216
|
-
box-shadow:
|
|
217
|
-
inset 0 1px 2px rgba(0, 0, 0, 0.2),
|
|
218
|
-
0 1px 0 0 rgba(255, 255, 255, 0.15);
|
|
219
|
-
transition-duration: 50ms;
|
|
220
|
-
`;
|
|
221
|
-
var buttonStatePressed = css`
|
|
222
|
-
${buttonStateNormalActive}
|
|
223
|
-
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
224
|
-
`;
|
|
225
|
-
var buttonStatePressedHover = css`
|
|
226
|
-
${buttonStateNormalActive}
|
|
227
|
-
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
228
|
-
background: ${(p) => p.theme.gradients.buttonPressedHover};
|
|
229
|
-
`;
|
|
230
|
-
var buttonStatePressedActive = buttonStateNormalActive;
|
|
231
|
-
var buttonStateDisabled = css`
|
|
232
|
-
${buttonStateNormal}
|
|
233
|
-
|
|
234
|
-
cursor: default;
|
|
235
|
-
background: ${(p) => p.theme.bg} !important;
|
|
236
|
-
color: rgba(${(p) => p.theme.textNormal}, 0.4);
|
|
237
|
-
`;
|
|
238
|
-
var button = css`
|
|
239
|
-
position: relative;
|
|
240
|
-
box-sizing: border-box;
|
|
241
|
-
cursor: pointer;
|
|
242
|
-
transition: all 200ms;
|
|
243
|
-
border-radius: 3px;
|
|
244
|
-
border: 1px solid ${(p) => p.theme.borderDark};
|
|
245
|
-
overflow: hidden;
|
|
246
|
-
display: flex;
|
|
247
|
-
justify-content: center;
|
|
248
|
-
align-items: center;
|
|
249
|
-
outline-color: transparent;
|
|
250
|
-
${buttonStateNormal}
|
|
251
|
-
|
|
252
|
-
&:hover {
|
|
253
|
-
${buttonStateNormalHover}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
&:active {
|
|
257
|
-
${buttonStateNormalActive}
|
|
258
|
-
}
|
|
259
|
-
`;
|
|
260
|
-
var buttonPressed = css`
|
|
261
|
-
${buttonStatePressed}
|
|
262
|
-
|
|
263
|
-
&:hover {
|
|
264
|
-
${buttonStatePressedHover}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
&:active {
|
|
268
|
-
${buttonStatePressedActive}
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
var buttonDisabled = css`
|
|
272
|
-
${buttonStateDisabled}
|
|
273
|
-
|
|
274
|
-
&:hover, &:active {
|
|
275
|
-
${buttonStateDisabled}
|
|
276
|
-
}
|
|
277
|
-
`;
|
|
278
|
-
var touchIndicatorNormal = css`
|
|
279
|
-
position: absolute;
|
|
280
|
-
top: -6px;
|
|
281
|
-
right: -6px;
|
|
282
|
-
left: -6px;
|
|
283
|
-
bottom: -6px;
|
|
284
|
-
border-radius: 6px;
|
|
285
|
-
border: 2px solid rgba(0, 0, 0, 0);
|
|
286
|
-
background-color: none;
|
|
287
|
-
transition: border-color 300ms;
|
|
288
|
-
`;
|
|
289
|
-
var touchIndicatorTouching = css`
|
|
290
|
-
border-color: ${(p) => p.theme.hint};
|
|
291
|
-
background-color: rgba(${(p) => p.theme.hintRGB}, 0.2);
|
|
292
|
-
transition: border-color 0s;
|
|
293
|
-
`;
|
|
294
|
-
var PreferredThemeProvider = ({ dark, light, children }) => {
|
|
295
|
-
const theme = usePreferredColorScheme();
|
|
296
|
-
return /* @__PURE__ */ jsx(ThemeProvider, { theme: theme === "dark" ? dark : light, children });
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// src/frontend/stage.tsx
|
|
300
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
301
|
-
var Stage = ({ className, renderers }) => {
|
|
302
|
-
const [root, setRoot] = useState3(
|
|
21
|
+
var Stage = ({ className, renderers, loadingState }) => {
|
|
22
|
+
const [root, setRoot] = useState(
|
|
303
23
|
void 0
|
|
304
24
|
);
|
|
305
25
|
const socket = useRef(null);
|
|
306
|
-
const [connection, setConnection] =
|
|
26
|
+
const [connection, setConnection] = useState({
|
|
307
27
|
state: "connecting"
|
|
308
28
|
});
|
|
29
|
+
const [clockSync, setClockSync] = useState(null);
|
|
30
|
+
const [lastPingMs, setLastPingMs] = useState(null);
|
|
31
|
+
const [bestPing, setBestPing] = useState(null);
|
|
309
32
|
const calls = useRef({
|
|
310
33
|
nextId: 1,
|
|
311
34
|
calls: /* @__PURE__ */ new Map()
|
|
312
35
|
});
|
|
36
|
+
const pings = useRef({
|
|
37
|
+
nextId: 1,
|
|
38
|
+
pings: /* @__PURE__ */ new Map()
|
|
39
|
+
});
|
|
313
40
|
const preparedRenderers = useMemo(() => {
|
|
314
41
|
const prepared = {};
|
|
315
42
|
for (const renderer of renderers) {
|
|
@@ -331,6 +58,7 @@ var Stage = ({ className, renderers }) => {
|
|
|
331
58
|
switch (msg.type) {
|
|
332
59
|
case "metadata":
|
|
333
60
|
setConnection({ state: "connected", uuid: msg.connectionUuid });
|
|
61
|
+
setClockSync(msg.clockSync);
|
|
334
62
|
return;
|
|
335
63
|
case "tree-full":
|
|
336
64
|
setRoot(msg.root);
|
|
@@ -354,6 +82,32 @@ var Stage = ({ className, renderers }) => {
|
|
|
354
82
|
}
|
|
355
83
|
return;
|
|
356
84
|
}
|
|
85
|
+
case "pong": {
|
|
86
|
+
const ping = pings.current.pings.get(msg.pingId);
|
|
87
|
+
if (!ping) {
|
|
88
|
+
console.warn(
|
|
89
|
+
`Received pong response for unknown ping ID ${msg.pingId}`
|
|
90
|
+
);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
pings.current.pings.delete(msg.pingId);
|
|
94
|
+
const roundTripMs = performance.now() - ping.sentAtPerfMs;
|
|
95
|
+
const estimatedClientMidpointMs = ping.sentAtUnixMs + roundTripMs / 2;
|
|
96
|
+
const nextTimeDifferenceMs = estimatedClientMidpointMs - msg.serverTimeMillis;
|
|
97
|
+
setLastPingMs(roundTripMs);
|
|
98
|
+
setBestPing(
|
|
99
|
+
(current) => (
|
|
100
|
+
// No best ping yet
|
|
101
|
+
current === null || // Better ping than current best, so this will likely be more precise
|
|
102
|
+
roundTripMs < current.pingMs || // Time difference has changed significantly, so this is likely more accurate even if ping isn't better
|
|
103
|
+
Math.abs(nextTimeDifferenceMs - current.timeDifferenceMs) > roundTripMs ? {
|
|
104
|
+
pingMs: roundTripMs,
|
|
105
|
+
timeDifferenceMs: nextTimeDifferenceMs
|
|
106
|
+
} : current
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
357
111
|
}
|
|
358
112
|
}, []);
|
|
359
113
|
const initializeWebsocket = useCallback(async () => {
|
|
@@ -417,9 +171,39 @@ var Stage = ({ className, renderers }) => {
|
|
|
417
171
|
},
|
|
418
172
|
[]
|
|
419
173
|
);
|
|
420
|
-
|
|
174
|
+
useEffect(() => {
|
|
421
175
|
initializeWebsocket();
|
|
422
176
|
}, [initializeWebsocket]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (connection.state !== "connected" && clockSync !== null) {
|
|
179
|
+
setClockSync(null);
|
|
180
|
+
}
|
|
181
|
+
setLastPingMs(null);
|
|
182
|
+
setBestPing(null);
|
|
183
|
+
pings.current.pings.clear();
|
|
184
|
+
if (connection.state !== "connected" || clockSync === null) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const sendPing = () => {
|
|
188
|
+
const pingId = pings.current.nextId++;
|
|
189
|
+
pings.current.pings.set(pingId, {
|
|
190
|
+
sentAtUnixMs: Date.now(),
|
|
191
|
+
sentAtPerfMs: performance.now()
|
|
192
|
+
});
|
|
193
|
+
sendMessage({
|
|
194
|
+
type: "ping",
|
|
195
|
+
pingId
|
|
196
|
+
}).catch((error) => {
|
|
197
|
+
pings.current.pings.delete(pingId);
|
|
198
|
+
console.error("Unable to send ping", error);
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
sendPing();
|
|
202
|
+
const interval = window.setInterval(sendPing, clockSync.pingIntervalMs);
|
|
203
|
+
return () => {
|
|
204
|
+
window.clearInterval(interval);
|
|
205
|
+
};
|
|
206
|
+
}, [clockSync, connection.state, sendMessage]);
|
|
423
207
|
const stageContext = useMemo(
|
|
424
208
|
() => ({
|
|
425
209
|
sendMessage,
|
|
@@ -427,32 +211,30 @@ var Stage = ({ className, renderers }) => {
|
|
|
427
211
|
call,
|
|
428
212
|
connectionUuid: connection.state === "connected" ? connection.uuid : null,
|
|
429
213
|
connection,
|
|
214
|
+
timeDifferenceMs: bestPing?.timeDifferenceMs ?? null,
|
|
215
|
+
lastPingMs,
|
|
430
216
|
reconnect: () => void initializeWebsocket()
|
|
431
217
|
}),
|
|
432
|
-
[
|
|
218
|
+
[
|
|
219
|
+
sendMessage,
|
|
220
|
+
renderComponent,
|
|
221
|
+
call,
|
|
222
|
+
initializeWebsocket,
|
|
223
|
+
connection,
|
|
224
|
+
bestPing,
|
|
225
|
+
lastPingMs
|
|
226
|
+
]
|
|
433
227
|
);
|
|
434
|
-
return /* @__PURE__ */
|
|
228
|
+
return /* @__PURE__ */ jsx(StageContext.Provider, { value: stageContext, children: /* @__PURE__ */ jsx(GroupStateWrapper, { openByDefault: false, children: /* @__PURE__ */ jsx("div", { className, children: root ? renderComponent(root) : loadingState?.() ?? /* @__PURE__ */ jsx("div", { className: "arcane-stage__no-root", children: "No root has been added to the light desk" }) }) }) });
|
|
435
229
|
};
|
|
436
|
-
var StyledStage = styled(Stage)`
|
|
437
|
-
width: 100%;
|
|
438
|
-
height: 100%;
|
|
439
|
-
background-color: ${(p) => p.theme.pageBg};
|
|
440
|
-
color: ${(p) => p.theme.textNormal};
|
|
441
|
-
padding: ${(p) => p.theme.sizingPx.spacing}px;
|
|
442
|
-
`;
|
|
443
230
|
function rootComponent(props) {
|
|
444
|
-
return /* @__PURE__ */
|
|
445
|
-
|
|
231
|
+
return /* @__PURE__ */ jsx(ThemeRoot, { rootProps: props.themeRootProps, children: /* @__PURE__ */ jsx(
|
|
232
|
+
Stage,
|
|
446
233
|
{
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
children: [
|
|
450
|
-
/* @__PURE__ */ jsx2(BaseStyle2, {}),
|
|
451
|
-
/* @__PURE__ */ jsx2(GlobalStyle2, {}),
|
|
452
|
-
/* @__PURE__ */ jsx2(StyledStage, { ...props })
|
|
453
|
-
]
|
|
234
|
+
...props,
|
|
235
|
+
className: calculateClass("arcane-stage", props.className)
|
|
454
236
|
}
|
|
455
|
-
);
|
|
237
|
+
) });
|
|
456
238
|
}
|
|
457
239
|
|
|
458
240
|
// src/frontend/index.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyComponent, B as Button, G as Group,
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, l as GroupHeader, T as Toolkit, e as ToolkitAdditionalFiles, f as ToolkitClockSyncOptions, a as ToolkitConnection, g as ToolkitCoreAssetRelativePath, h as ToolkitHtmlPageContext, i as ToolkitOptions, b as ToolkitRenderContext, d as ToolkitServerListener, c as ToolkitServerListenerOptions, j as ToolkitStaticFile, k as ToolkitStaticFileResolver } from './toolkit-BPqxbDbk.mjs';
|
|
2
2
|
export { Label } from './backend/components/label.mjs';
|
|
3
3
|
export { Rect } from './backend/components/rect.mjs';
|
|
4
4
|
export { SliderButton } from './backend/components/slider-button.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyComponent, B as Button, G as Group,
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, l as GroupHeader, T as Toolkit, e as ToolkitAdditionalFiles, f as ToolkitClockSyncOptions, a as ToolkitConnection, g as ToolkitCoreAssetRelativePath, h as ToolkitHtmlPageContext, i as ToolkitOptions, b as ToolkitRenderContext, d as ToolkitServerListener, c as ToolkitServerListenerOptions, j as ToolkitStaticFile, k as ToolkitStaticFileResolver } from './toolkit-Bglbv3ix.js';
|
|
2
2
|
export { Label } from './backend/components/label.js';
|
|
3
3
|
export { Rect } from './backend/components/rect.js';
|
|
4
4
|
export { SliderButton } from './backend/components/slider-button.js';
|