@noya-app/noya-multiplayer-react 0.1.40 → 0.1.41
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 +6 -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 +14 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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",
|
|
@@ -1098,8 +1093,7 @@ function pathToString(extendedPath) {
|
|
|
1098
1093
|
).join("");
|
|
1099
1094
|
}
|
|
1100
1095
|
function ellipsis(str, maxLength, position = "end") {
|
|
1101
|
-
if (str.length <= maxLength)
|
|
1102
|
-
return str;
|
|
1096
|
+
if (str.length <= maxLength) return str;
|
|
1103
1097
|
switch (position) {
|
|
1104
1098
|
case "start":
|
|
1105
1099
|
return `\u2026${str.slice(str.length - maxLength)}`;
|
|
@@ -1172,8 +1166,7 @@ function useStateInspector({
|
|
|
1172
1166
|
}) {
|
|
1173
1167
|
const [root, setRoot] = React5.useState(null);
|
|
1174
1168
|
useLayoutEffect2(() => {
|
|
1175
|
-
if (disabled)
|
|
1176
|
-
return;
|
|
1169
|
+
if (disabled) return;
|
|
1177
1170
|
const { host, container } = createShadowRootElement();
|
|
1178
1171
|
const root2 = createRoot(container);
|
|
1179
1172
|
document.body.appendChild(host);
|
|
@@ -1183,8 +1176,7 @@ function useStateInspector({
|
|
|
1183
1176
|
};
|
|
1184
1177
|
}, [disabled]);
|
|
1185
1178
|
useLayoutEffect2(() => {
|
|
1186
|
-
if (!root)
|
|
1187
|
-
return;
|
|
1179
|
+
if (!root) return;
|
|
1188
1180
|
root.render(
|
|
1189
1181
|
/* @__PURE__ */ React5.createElement(
|
|
1190
1182
|
StateInspector,
|
|
@@ -1291,8 +1283,7 @@ function throttle(fn, ms) {
|
|
|
1291
1283
|
return (...args) => {
|
|
1292
1284
|
const now = Date.now();
|
|
1293
1285
|
if (now - lastCall < ms) {
|
|
1294
|
-
if (timeoutId)
|
|
1295
|
-
clearTimeout(timeoutId);
|
|
1286
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1296
1287
|
timeoutId = setTimeout(
|
|
1297
1288
|
() => {
|
|
1298
1289
|
lastCall = now;
|
|
@@ -1431,8 +1422,7 @@ function useMultiplayerState(initialState, options) {
|
|
|
1431
1422
|
});
|
|
1432
1423
|
}, [multiplayerStateManager]);
|
|
1433
1424
|
useEffect3(() => {
|
|
1434
|
-
if (!unrecoverableError)
|
|
1435
|
-
return;
|
|
1425
|
+
if (!unrecoverableError) return;
|
|
1436
1426
|
const el = document.createElement("div");
|
|
1437
1427
|
el.id = "noya-multiplayer-react-error-overlay";
|
|
1438
1428
|
document.body.appendChild(el);
|
|
@@ -1487,13 +1477,11 @@ function enforceSchema(initialState, schema) {
|
|
|
1487
1477
|
function parseAppDataParameter(options) {
|
|
1488
1478
|
const window2 = options?.window ?? globalThis;
|
|
1489
1479
|
const location = window2.location;
|
|
1490
|
-
if (!location)
|
|
1491
|
-
return null;
|
|
1480
|
+
if (!location) return null;
|
|
1492
1481
|
const urlHash = (location.hash || "").replace(/^#/, "");
|
|
1493
1482
|
const params = new URLSearchParams(urlHash);
|
|
1494
1483
|
const data = params.get("data");
|
|
1495
|
-
if (!data)
|
|
1496
|
-
return null;
|
|
1484
|
+
if (!data) return null;
|
|
1497
1485
|
try {
|
|
1498
1486
|
return JSON.parse(data);
|
|
1499
1487
|
} catch (e) {
|
|
@@ -1511,8 +1499,7 @@ function getAppData(initialState, schema, options) {
|
|
|
1511
1499
|
}
|
|
1512
1500
|
function useBroadcastConnectedUsers(connectedUsers) {
|
|
1513
1501
|
useEffect4(() => {
|
|
1514
|
-
if (!isEmbeddedApp())
|
|
1515
|
-
return;
|
|
1502
|
+
if (!isEmbeddedApp()) return;
|
|
1516
1503
|
const message = {
|
|
1517
1504
|
type: "multiplayer.setUsers",
|
|
1518
1505
|
payload: { users: connectedUsers }
|
|
@@ -1522,8 +1509,7 @@ function useBroadcastConnectedUsers(connectedUsers) {
|
|
|
1522
1509
|
}
|
|
1523
1510
|
function useBroadcastMenuItems(menuItems, handleSelectMenuItem) {
|
|
1524
1511
|
useEffect4(() => {
|
|
1525
|
-
if (!isEmbeddedApp())
|
|
1526
|
-
return;
|
|
1512
|
+
if (!isEmbeddedApp()) return;
|
|
1527
1513
|
const message = {
|
|
1528
1514
|
type: "application.setMenuItems",
|
|
1529
1515
|
payload: { menuItems }
|