@zaisma/game-server 1.21.0 → 1.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaisma/game-server",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "Run your Zaisma game server: the same rooms on Zaisma or on your own server.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://zaisma.com",
package/sdk/zaisma.d.ts CHANGED
@@ -198,7 +198,7 @@ declare namespace Zaisma {
198
198
  const server: Server;
199
199
 
200
200
  /**
201
- * Invite friends. On Zaisma it opens the page's Share, the same as the game bar's Share button: the
201
+ * Invite friends. On Zaisma it opens Zaisma's invite sheet, the same as the Zaisma overlay's Share: the
202
202
  * room's QR code, link and code, Copy and the share sheet ("opened", or "failed" when the page couldn't
203
203
  * open it). On your own site it opens the share sheet on phones, otherwise copies the room's invite link
204
204
  * (the game's page without a room). Call it from a button in your game, like on a "waiting for players"
@@ -227,16 +227,6 @@ declare namespace Zaisma {
227
227
  */
228
228
  function checkChat(text: string): Promise<ChatCheck>;
229
229
 
230
- /**
231
- * The Players panel, where a player can mute, block and report the others and see their friends. On
232
- * Zaisma it opens the game bar's own Players, the same as its button (leaving full screen if the
233
- * game is in it), so a Players button in your game, in your game's style, does exactly what the bar's
234
- * does. On your own site, where there's no bar, it draws Zaisma's ready-made panel.
235
- * A game with its own netcode offers them in its own menu. Or build your own panel
236
- * with room.mute, room.block and room.report.
237
- */
238
- function openPlayersPanel(room: Room): void;
239
-
240
230
  /**
241
231
  * The signed-in player's Zaisma friends who are playing this game right now, for your own list of
242
232
  * them: to join a friend's match, watch it or invite them ({@link Friends.list}). A game never sees
@@ -605,7 +595,7 @@ declare namespace Zaisma {
605
595
 
606
596
  /**
607
597
  * Whether Zaisma's page covers the game right now, so a game can pause or hold the player's input while it does.
608
- * coveredBy is "sheet" while one of Zaisma's sheets is open over the game (buying, Players, Report: the player is
598
+ * coveredBy is "sheet" while one of Zaisma's sheets is open over the game (buying, the Zaisma overlay, Report: the player is
609
599
  * busy with it), "card" while one of its cards is over the game's corner (Still there?, Keep your progress; the
610
600
  * game stays in view and playable), and null otherwise. Always null outside Zaisma's page (your own site, a
611
601
  * local test). Listen for "coveredBy" to hear each change.
package/sdk/zaisma.js CHANGED
@@ -2574,138 +2574,9 @@
2574
2574
  });
2575
2575
  });
2576
2576
 
2577
- /** Hand a player report to the Zaisma page. If no Zaisma page answers (the game runs somewhere else), use our own form. */
2578
- function handOff(room, reported, opened, fallback) {
2579
- if (!config.site || window.parent === window) return fallback();
2580
- var isAnswered = false;
2581
- function listen(event) {
2582
- if (event.origin === config.site && event.source === window.parent && event.data && event.data.type === "zaisma:report-open") {
2583
- isAnswered = true;
2584
- window.removeEventListener("message", listen);
2585
- opened();
2586
- }
2587
- }
2588
- window.addEventListener("message", listen);
2589
- window.parent.postMessage({ type: "zaisma:report", code: room.roomCode, player: { id: reported.id, name: reported.name } }, config.site);
2590
- setTimeout(function () {
2591
- window.removeEventListener("message", listen);
2592
- if (!isAnswered) fallback();
2593
- }, 800);
2594
- }
2595
-
2596
2577
  // The first four go to Zaisma; the rest to the game's developer.
2597
2578
  var REASONS = [["real_life_threat", "Threatening them in real life"], ["personal_details", "Sharing someone's personal details"], ["following_after_block", "Following me after I blocked them"], ["sexual", "Sexual behavior"], ["harassment", "Harassing or bullying"], ["cheating", "Cheating"], ["other", "Something else"]];
2598
2579
 
2599
- /** A ready-made Players panel: mute, block and report. Games open it from their own menu. */
2600
- function openPlayersPanel(room) {
2601
- // On Zaisma, the page's own Players (the bar's), so a game's Players button opens the same one.
2602
- if (onZaismaPage()) {
2603
- window.parent.postMessage({ type: "zaisma:players-open" }, config.site);
2604
- return;
2605
- }
2606
- var old = document.getElementById("zaisma-safety");
2607
- if (old) old.remove();
2608
- var wrap = document.createElement("div");
2609
- wrap.id = "zaisma-safety";
2610
- wrap.setAttribute("role", "dialog");
2611
- wrap.setAttribute("aria-label", "Players");
2612
- // Zaisma's Steel look: gunmetal plates with the cut corner.
2613
- wrap.style.cssText = "position:fixed;inset:0;z-index:2147483647;background:rgba(4,5,7,.6);display:grid;place-items:center;font:15px/1.4 system-ui,-apple-system,sans-serif;color:#eceef0";
2614
- var box = document.createElement("div");
2615
- box.style.cssText = "background:linear-gradient(180deg,#262a31,#1b1e23);box-shadow:inset 1px 1px 0 rgba(255,255,255,.09),inset -1px -1px 0 rgba(0,0,0,.7),0 14px 32px rgba(0,0,0,.42);clip-path:polygon(0 0,calc(100% - 18px) 0,100% 18px,100% 100%,0 100%);padding:18px;width:min(420px,92vw);max-height:80vh;overflow:auto";
2616
- wrap.appendChild(box);
2617
- var buttonStyle = "font:inherit;font-size:13px;font-weight:600;min-height:36px;padding:0 12px;border:0;background:linear-gradient(180deg,#30353d,#22262c);box-shadow:inset 1px 1px 0 rgba(255,255,255,.13),inset -1px -1px 0 #000;clip-path:polygon(0 0,calc(100% - 7px) 0,100% 7px,100% 100%,0 100%);color:#eceef0;cursor:pointer";
2618
- function close() { wrap.remove(); }
2619
- wrap.addEventListener("click", function (event) { if (event.target === wrap) close(); });
2620
- wrap.addEventListener("keydown", function (event) { if (event.key === "Escape") close(); });
2621
-
2622
- function render(note) {
2623
- box.textContent = "";
2624
- var head = document.createElement("div");
2625
- head.style.cssText = "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px";
2626
- var heading = document.createElement("strong");
2627
- heading.textContent = "Players";
2628
- var closeButton = document.createElement("button");
2629
- closeButton.textContent = "Close";
2630
- closeButton.style.cssText = buttonStyle;
2631
- closeButton.onclick = close;
2632
- head.append(heading, closeButton);
2633
- box.appendChild(head);
2634
- if (note) {
2635
- var noteText = document.createElement("p");
2636
- noteText.textContent = note;
2637
- noteText.style.cssText = "margin:0 0 10px;color:#b9e7a6";
2638
- box.appendChild(noteText);
2639
- }
2640
- var others = room.players.filter(function (each) { return !room.me || each.id !== room.me.id; });
2641
- if (!others.length) {
2642
- var none = document.createElement("p");
2643
- none.textContent = "Nobody else is here.";
2644
- none.style.color = "#969ba4";
2645
- box.appendChild(none);
2646
- }
2647
- others.forEach(function (other) {
2648
- var row = document.createElement("div");
2649
- row.style.cssText = "display:flex;gap:6px;align-items:center;padding:10px 0;box-shadow:inset 0 1px 0 #000,inset 0 2px 0 rgba(255,255,255,.05)";
2650
- // Only what this player did themselves shows: a block someone made of them never does.
2651
- var isBlocked = hasBlocked(other.id);
2652
- var isMuted = Boolean(room._muted && room._muted.has(other.id));
2653
- var name = document.createElement("span");
2654
- name.textContent = other.name + (isBlocked ? " (blocked)" : isMuted ? " (muted)" : "");
2655
- name.style.flex = "1";
2656
- row.appendChild(name);
2657
- function button(text, onclick) {
2658
- var each = document.createElement("button");
2659
- each.textContent = text;
2660
- each.style.cssText = buttonStyle;
2661
- each.onclick = onclick;
2662
- row.appendChild(each);
2663
- }
2664
- // A lasting block is undone on zaisma.com/friends; a session one here.
2665
- if (!lastingBlocked.has(other.id)) button(isBlocked ? "Unblock" : isMuted ? "Unmute" : "Mute", function () { isBlocked || isMuted ? room.unmute(other.id) : room.mute(other.id); render(); });
2666
- if (!isBlocked) {
2667
- button("Block", function () {
2668
- room.block(other.id).then(function (isDone) {
2669
- render(!isDone ? undefined : lastingBlocked.has(other.id) ? other.name + " is blocked. Unblock them on your Zaisma friends page." : other.name + " is blocked for this session.");
2670
- }, function () { render(); });
2671
- });
2672
- }
2673
- button("Report", function () { handOff(room, other, close, function () { reportForm(other); }); });
2674
- box.appendChild(row);
2675
- });
2676
- }
2677
-
2678
- function reportForm(reported) {
2679
- box.textContent = "";
2680
- var heading = document.createElement("strong");
2681
- heading.textContent = "Report " + reported.name;
2682
- var select = document.createElement("select");
2683
- select.style.cssText = "display:block;width:100%;margin:12px 0;min-height:40px;padding:0 10px;background:#0d0f12;color:#eceef0;border:1px solid #000;box-shadow:inset 0 2px 5px rgba(0,0,0,.65),0 1px 0 rgba(255,255,255,.06);font:inherit";
2684
- REASONS.forEach(function (reason) { var option = document.createElement("option"); option.value = reason[0]; option.textContent = reason[1]; select.appendChild(option); });
2685
- var note = document.createElement("p");
2686
- note.textContent = "Zaisma reviews reports. Nothing about you is sent. They'll also be muted for you.";
2687
- note.style.cssText = "margin:0 0 12px;color:#969ba4;font-size:13px";
2688
- var send = document.createElement("button");
2689
- send.textContent = "Send report";
2690
- send.style.cssText = buttonStyle + ";background:linear-gradient(180deg,#eef0f2 0%,#b9bcc1 46%,#7d8086 100%);box-shadow:inset 1px 1px 0 #fff,inset -1px -1px 0 #000;color:#0b0b0c";
2691
- var back = document.createElement("button");
2692
- back.textContent = "Back";
2693
- back.style.cssText = buttonStyle + ";margin-left:6px";
2694
- back.onclick = function () { render(); };
2695
- send.onclick = function () {
2696
- send.disabled = true;
2697
- room.mute(reported.id);
2698
- room.report(reported.id, select.value).then(function () { render("Thanks. Your report was sent."); }, function (error) { render(error.message); });
2699
- };
2700
- box.append(heading, select, note, send, back);
2701
- }
2702
-
2703
- render();
2704
- document.body.appendChild(wrap);
2705
- wrap.tabIndex = -1;
2706
- wrap.focus();
2707
- }
2708
-
2709
2580
  var rooms = { list: listRooms, quickJoin: quickJoin, linkedRoomCode: roomCodeFromPage(), linkedServerUrl: roomCodeFromPage() ? serverUrlFromPage() : null, isLinkedAsSpectator: watchFromPage() };
2710
2581
  /*
2711
2582
  * Friend requests (zaisma.d.ts: Friends.sendRequest): the Zaisma page asks the player before anything is
@@ -2753,5 +2624,5 @@
2753
2624
  });
2754
2625
 
2755
2626
  var friends = { list: listFriends, setRoom: setOwnRoom, sendRequest: sendFriendRequest };
2756
- window.Zaisma = { sdkVersionNumber: 1, gameSlug: config.game || null, player: player, setUpOffZaisma: setUpOffZaisma, joinRoom: joinRoom, rooms: rooms, server: server, invite: invite, checkChat: checkChat, openPlayersPanel: openPlayersPanel, links: links, items: items, friends: friends, saves: saves, versions: versions, page: zaismaPage };
2627
+ window.Zaisma = { sdkVersionNumber: 1, gameSlug: config.game || null, player: player, setUpOffZaisma: setUpOffZaisma, joinRoom: joinRoom, rooms: rooms, server: server, invite: invite, checkChat: checkChat, links: links, items: items, friends: friends, saves: saves, versions: versions, page: zaismaPage };
2757
2628
  })();