@zaisma/game-server 1.32.0 → 1.33.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.32.0",
3
+ "version": "1.33.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
@@ -9,6 +9,11 @@
9
9
  * v1 only gains things: calls, options, fields and values are added, never renamed or removed. Page
10
10
  * messages, storage keys and members whose names start with `_` are not part of v1.
11
11
  *
12
+ * `Zaisma` is locked once the SDK loads: it, every namespace and every call under it can't be replaced,
13
+ * redefined, deleted or added to, so a call by Zaisma's name is always Zaisma's own. Include the SDK once,
14
+ * and never declare a `Zaisma` of your own at the top of a script (`const Zaisma = …`, `function Zaisma`):
15
+ * the browser refuses that script. Use the global `Zaisma` as it is.
16
+ *
12
17
  * For editor and compiler checks, save this file beside your game's folder, not in it, since uploads
13
18
  * take no .ts files. On Zaisma it's served beside the SDK as _zaisma/v1.d.ts; in Zaisma's repository
14
19
  * it's packages/sdk/zaisma.d.ts. Then put `/// <reference path="../zaisma.d.ts" />` (and in JavaScript,
@@ -24,6 +29,12 @@
24
29
  * Within v1, codes and events only grow: handle unknown ones (a `default` branch), and a new code or event
25
30
  * never breaks your game.
26
31
  *
32
+ * The Zaisma button shares your game's screen: while it plays on Zaisma, the button sits in the top right
33
+ * corner of the game's frame, over the game, about 64 by 60 CSS px past the phone's safe area. On phones and
34
+ * touch screens it's always there; with a mouse it slides in when the pointer reaches that corner. Keep your
35
+ * own buttons, score and words out of that corner. The developer API's preview_game_page pictures the game
36
+ * playing with the button in place, on a laptop and a phone.
37
+ *
27
38
  * Player passes, for rooms and your own servers, need the game played on its zaisma.com page, which
28
39
  * checks the browser on Play: joining fails with `error.code` "unchecked" when it couldn't, or when the
29
40
  * game was opened anywhere else. A game played off Zaisma (exported, on another site, wrapped for a store)
package/sdk/zaisma.js CHANGED
@@ -2684,5 +2684,29 @@
2684
2684
  });
2685
2685
 
2686
2686
  var friends = { list: listFriends, setRoom: setOwnRoom, sendRequest: sendFriendRequest };
2687
- 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 };
2687
+ var 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 };
2688
+
2689
+ /**
2690
+ * Locked once loaded: window.Zaisma, every namespace and every call under it can't be replaced, redefined,
2691
+ * deleted or added to, so a call by Zaisma's name is always Zaisma's own. Each object and function is frozen,
2692
+ * through its getters and setters too, without calling them.
2693
+ */
2694
+ function lockDeep(part, lockedParts) {
2695
+ if ((typeof part !== "object" && typeof part !== "function") || part === null || lockedParts.has(part)) return;
2696
+ lockedParts.add(part);
2697
+ Reflect.ownKeys(part).forEach(function (key) {
2698
+ var described = Object.getOwnPropertyDescriptor(part, key);
2699
+ if ("value" in described) lockDeep(described.value, lockedParts);
2700
+ lockDeep(described.get, lockedParts);
2701
+ lockDeep(described.set, lockedParts);
2702
+ });
2703
+ Object.freeze(part);
2704
+ }
2705
+ lockDeep(zaisma, new WeakSet());
2706
+ // Something already holding the name for good (a second copy of the SDK, or the game's own) keeps it, and the console says so.
2707
+ try {
2708
+ Object.defineProperty(window, "Zaisma", { value: zaisma, writable: false, enumerable: true, configurable: false });
2709
+ } catch (refused) {
2710
+ console.warn("Zaisma: window.Zaisma is already locked on this page, so this copy of the SDK isn't set up. Include _zaisma/v1.js once, before any script that uses Zaisma.");
2711
+ }
2688
2712
  })();