@noya-app/noya-multiplayer-react 0.1.40 → 0.1.42
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/.turbo/turbo-build.log +14 -13
- package/CHANGELOG.md +15 -0
- package/dist/index.bundle.js +7 -7
- package/dist/index.d.mts +206 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/inspector/StateInspector.tsx +5 -3
package/dist/index.mjs
CHANGED
|
@@ -78,16 +78,14 @@ var UserPointer_ = function UserPointer({
|
|
|
78
78
|
const [, setForceUpdate] = useState(0);
|
|
79
79
|
const updatedAt = metadata?.updatedAt ?? 0;
|
|
80
80
|
useEffect(() => {
|
|
81
|
-
if (!shouldShow(hideAfter, updatedAt))
|
|
82
|
-
return;
|
|
81
|
+
if (!shouldShow(hideAfter, updatedAt)) return;
|
|
83
82
|
const timeoutId = setTimeout(() => {
|
|
84
83
|
setForceUpdate((prev) => prev + 1);
|
|
85
84
|
}, hideAfter);
|
|
86
85
|
return () => clearTimeout(timeoutId);
|
|
87
86
|
}, [hideAfter, updatedAt]);
|
|
88
87
|
const show = shouldShow(hideAfter, updatedAt);
|
|
89
|
-
if (!data || !data.pointer)
|
|
90
|
-
return null;
|
|
88
|
+
if (!data || !data.pointer) return null;
|
|
91
89
|
return /* @__PURE__ */ React.createElement(UserPointerContainer, { key: user.id, point: data.pointer, show }, /* @__PURE__ */ React.createElement(UserPointerIcon, { color: avatarStyle.backgroundColor }), /* @__PURE__ */ React.createElement(UserNameTag, { background: avatarStyle.backgroundColor }, user.name));
|
|
92
90
|
};
|
|
93
91
|
var UserPointer2 = memo(UserPointer_);
|
|
@@ -143,8 +141,7 @@ var UserNameTag = memo(function UserNameTag2({
|
|
|
143
141
|
var UserPointersOverlay = memo(function UserPointers({ connectedUsers, ephemeralUserData }) {
|
|
144
142
|
const currentUserId = useObservable(ephemeralUserData.currentUserId$);
|
|
145
143
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, connectedUsers.map((user) => {
|
|
146
|
-
if (user.id === currentUserId)
|
|
147
|
-
return null;
|
|
144
|
+
if (user.id === currentUserId) return null;
|
|
148
145
|
return /* @__PURE__ */ React.createElement(
|
|
149
146
|
UserPointer2,
|
|
150
147
|
{
|
|
@@ -586,8 +583,7 @@ var StateInspector = memo2(function StateInspector2({
|
|
|
586
583
|
}
|
|
587
584
|
}, [historySnapshot]);
|
|
588
585
|
useEffect2(() => {
|
|
589
|
-
if (!historyContainerRef.current)
|
|
590
|
-
return;
|
|
586
|
+
if (!historyContainerRef.current) return;
|
|
591
587
|
const historyEntry = historyContainerRef.current.querySelector(
|
|
592
588
|
`#${HISTORY_ELEMENT_PREFIX}${historySnapshot.historyIndex}`
|
|
593
589
|
);
|
|
@@ -619,8 +615,7 @@ var StateInspector = memo2(function StateInspector2({
|
|
|
619
615
|
zIndex: 9999,
|
|
620
616
|
lineHeight: "13px"
|
|
621
617
|
};
|
|
622
|
-
if (!didMount)
|
|
623
|
-
return null;
|
|
618
|
+
if (!didMount) return null;
|
|
624
619
|
if (!showInspector) {
|
|
625
620
|
return /* @__PURE__ */ React4.createElement(
|
|
626
621
|
"div",
|
|
@@ -689,14 +684,14 @@ var StateInspector = memo2(function StateInspector2({
|
|
|
689
684
|
src: user.image,
|
|
690
685
|
alt: user.name,
|
|
691
686
|
style: {
|
|
692
|
-
width: "
|
|
693
|
-
height: "
|
|
687
|
+
width: "13px",
|
|
688
|
+
height: "13px",
|
|
694
689
|
borderRadius: "50%",
|
|
695
690
|
marginRight: "4px",
|
|
696
691
|
display: "inline-block",
|
|
697
692
|
position: "relative",
|
|
698
|
-
|
|
699
|
-
|
|
693
|
+
background: solidBorderColor,
|
|
694
|
+
verticalAlign: "middle"
|
|
700
695
|
}
|
|
701
696
|
}
|
|
702
697
|
),
|
|
@@ -873,7 +868,8 @@ var StateInspector = memo2(function StateInspector2({
|
|
|
873
868
|
style: {
|
|
874
869
|
fontSize: "11px",
|
|
875
870
|
display: "flex",
|
|
876
|
-
flexWrap: "wrap"
|
|
871
|
+
flexWrap: "wrap",
|
|
872
|
+
margin: 0
|
|
877
873
|
}
|
|
878
874
|
},
|
|
879
875
|
entry.metadata.name
|
|
@@ -885,7 +881,8 @@ var StateInspector = memo2(function StateInspector2({
|
|
|
885
881
|
style: {
|
|
886
882
|
fontSize: "11px",
|
|
887
883
|
display: "flex",
|
|
888
|
-
flexWrap: "wrap"
|
|
884
|
+
flexWrap: "wrap",
|
|
885
|
+
margin: 0
|
|
889
886
|
}
|
|
890
887
|
},
|
|
891
888
|
patch.op === "add" && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("span", { style: { fontStyle: "italic" } }, pathToString(patch.path)), " = ", /* @__PURE__ */ React4.createElement(ObjectInspector, { data: patch.value, theme })),
|
|
@@ -1098,8 +1095,7 @@ function pathToString(extendedPath) {
|
|
|
1098
1095
|
).join("");
|
|
1099
1096
|
}
|
|
1100
1097
|
function ellipsis(str, maxLength, position = "end") {
|
|
1101
|
-
if (str.length <= maxLength)
|
|
1102
|
-
return str;
|
|
1098
|
+
if (str.length <= maxLength) return str;
|
|
1103
1099
|
switch (position) {
|
|
1104
1100
|
case "start":
|
|
1105
1101
|
return `\u2026${str.slice(str.length - maxLength)}`;
|
|
@@ -1172,8 +1168,7 @@ function useStateInspector({
|
|
|
1172
1168
|
}) {
|
|
1173
1169
|
const [root, setRoot] = React5.useState(null);
|
|
1174
1170
|
useLayoutEffect2(() => {
|
|
1175
|
-
if (disabled)
|
|
1176
|
-
return;
|
|
1171
|
+
if (disabled) return;
|
|
1177
1172
|
const { host, container } = createShadowRootElement();
|
|
1178
1173
|
const root2 = createRoot(container);
|
|
1179
1174
|
document.body.appendChild(host);
|
|
@@ -1183,8 +1178,7 @@ function useStateInspector({
|
|
|
1183
1178
|
};
|
|
1184
1179
|
}, [disabled]);
|
|
1185
1180
|
useLayoutEffect2(() => {
|
|
1186
|
-
if (!root)
|
|
1187
|
-
return;
|
|
1181
|
+
if (!root) return;
|
|
1188
1182
|
root.render(
|
|
1189
1183
|
/* @__PURE__ */ React5.createElement(
|
|
1190
1184
|
StateInspector,
|
|
@@ -1291,8 +1285,7 @@ function throttle(fn, ms) {
|
|
|
1291
1285
|
return (...args) => {
|
|
1292
1286
|
const now = Date.now();
|
|
1293
1287
|
if (now - lastCall < ms) {
|
|
1294
|
-
if (timeoutId)
|
|
1295
|
-
clearTimeout(timeoutId);
|
|
1288
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1296
1289
|
timeoutId = setTimeout(
|
|
1297
1290
|
() => {
|
|
1298
1291
|
lastCall = now;
|
|
@@ -1431,8 +1424,7 @@ function useMultiplayerState(initialState, options) {
|
|
|
1431
1424
|
});
|
|
1432
1425
|
}, [multiplayerStateManager]);
|
|
1433
1426
|
useEffect3(() => {
|
|
1434
|
-
if (!unrecoverableError)
|
|
1435
|
-
return;
|
|
1427
|
+
if (!unrecoverableError) return;
|
|
1436
1428
|
const el = document.createElement("div");
|
|
1437
1429
|
el.id = "noya-multiplayer-react-error-overlay";
|
|
1438
1430
|
document.body.appendChild(el);
|
|
@@ -1487,13 +1479,11 @@ function enforceSchema(initialState, schema) {
|
|
|
1487
1479
|
function parseAppDataParameter(options) {
|
|
1488
1480
|
const window2 = options?.window ?? globalThis;
|
|
1489
1481
|
const location = window2.location;
|
|
1490
|
-
if (!location)
|
|
1491
|
-
return null;
|
|
1482
|
+
if (!location) return null;
|
|
1492
1483
|
const urlHash = (location.hash || "").replace(/^#/, "");
|
|
1493
1484
|
const params = new URLSearchParams(urlHash);
|
|
1494
1485
|
const data = params.get("data");
|
|
1495
|
-
if (!data)
|
|
1496
|
-
return null;
|
|
1486
|
+
if (!data) return null;
|
|
1497
1487
|
try {
|
|
1498
1488
|
return JSON.parse(data);
|
|
1499
1489
|
} catch (e) {
|
|
@@ -1511,8 +1501,7 @@ function getAppData(initialState, schema, options) {
|
|
|
1511
1501
|
}
|
|
1512
1502
|
function useBroadcastConnectedUsers(connectedUsers) {
|
|
1513
1503
|
useEffect4(() => {
|
|
1514
|
-
if (!isEmbeddedApp())
|
|
1515
|
-
return;
|
|
1504
|
+
if (!isEmbeddedApp()) return;
|
|
1516
1505
|
const message = {
|
|
1517
1506
|
type: "multiplayer.setUsers",
|
|
1518
1507
|
payload: { users: connectedUsers }
|
|
@@ -1522,8 +1511,7 @@ function useBroadcastConnectedUsers(connectedUsers) {
|
|
|
1522
1511
|
}
|
|
1523
1512
|
function useBroadcastMenuItems(menuItems, handleSelectMenuItem) {
|
|
1524
1513
|
useEffect4(() => {
|
|
1525
|
-
if (!isEmbeddedApp())
|
|
1526
|
-
return;
|
|
1514
|
+
if (!isEmbeddedApp()) return;
|
|
1527
1515
|
const message = {
|
|
1528
1516
|
type: "application.setMenuItems",
|
|
1529
1517
|
payload: { menuItems }
|