@zaisma/game-server 1.38.0 → 1.39.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 +2 -2
- package/bench/glass.js +486 -457
- package/bin/local-play-bench.js +15 -4
- package/bin/local-play.js +4 -1
- package/package.json +3 -3
- package/sdk/saves.js +1 -1
- package/sdk/zaisma.d.ts +4 -2
- package/sdk/zaisma.js +5 -2
- package/bench/brand/README.md +0 -62
package/bin/local-play-bench.js
CHANGED
|
@@ -15,7 +15,11 @@ export const KEPT_SCRIPT_SOURCE = `try { new BroadcastChannel("zaisma").postMess
|
|
|
15
15
|
var keptPlayerNumber = Number(new URL(document.currentScript.src).searchParams.get("player")) || 0;
|
|
16
16
|
setTimeout(function () {
|
|
17
17
|
if (window.opener) window.close();
|
|
18
|
-
else
|
|
18
|
+
else {
|
|
19
|
+
// The dev page's own query (kept by the dev script for this tab) goes back with the player.
|
|
20
|
+
var rest = ""; try { rest = sessionStorage.getItem("zaisma-bench:query") || ""; } catch (error) {}
|
|
21
|
+
location.replace(keptPlayerNumber ? "/?player=" + keptPlayerNumber + (rest ? "&" + rest : "") : "/" + (rest ? "?" + rest : ""));
|
|
22
|
+
}
|
|
19
23
|
}, 800);
|
|
20
24
|
`;
|
|
21
25
|
|
|
@@ -23,10 +27,12 @@ setTimeout(function () {
|
|
|
23
27
|
export const ARRIVE_SCRIPT_SOURCE = `(function () {
|
|
24
28
|
var kept = null;
|
|
25
29
|
try { kept = Number(sessionStorage.getItem("zaisma-bench:player")) || null; } catch (error) {}
|
|
26
|
-
|
|
30
|
+
// The page's own query goes through with the player (a room code only when it's a real one).
|
|
31
|
+
var rest = new URLSearchParams(location.search); rest.delete("player");
|
|
32
|
+
if (!/^[A-Z0-9]{6}$/.test(rest.get("room") || "")) rest.delete("room");
|
|
27
33
|
fetch("/bench/claim", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ keptPlayerNumber: kept }) })
|
|
28
34
|
.then(function (response) { return response.json(); })
|
|
29
|
-
.then(function (answer) { location.replace("/?player=" + answer.playerNumber + (
|
|
35
|
+
.then(function (answer) { location.replace("/?player=" + answer.playerNumber + (rest.toString() ? "&" + rest.toString() : "")); });
|
|
30
36
|
})();
|
|
31
37
|
`;
|
|
32
38
|
|
|
@@ -38,7 +44,12 @@ function devScript() {
|
|
|
38
44
|
try {
|
|
39
45
|
// The Players page a sign-in opened knows its player from the tab (a tab opened by a page starts with a copy of the page's storage).
|
|
40
46
|
if (isPage && !playerNumber) playerNumber = Number(sessionStorage.getItem("zaisma-bench:player")) || 0;
|
|
41
|
-
else
|
|
47
|
+
else {
|
|
48
|
+
sessionStorage.setItem("zaisma-bench:player", String(playerNumber));
|
|
49
|
+
// The page's own query, besides the player, for the way back from a sign-in (KEPT_SCRIPT_SOURCE).
|
|
50
|
+
const rest = new URLSearchParams(location.search); rest.delete("player");
|
|
51
|
+
if (!isPage) sessionStorage.setItem("zaisma-bench:query", rest.toString());
|
|
52
|
+
}
|
|
42
53
|
} catch {
|
|
43
54
|
// Storage off: the tab is a new player each time it comes to /.
|
|
44
55
|
}
|
package/bin/local-play.js
CHANGED
|
@@ -1152,7 +1152,10 @@ export async function startLocalPlay(givenOptions) {
|
|
|
1152
1152
|
// Back from a sign-in that left the page: into the room the player was in, while it's still going.
|
|
1153
1153
|
const lastRoom = lastRoomCodes.get(givenNumber);
|
|
1154
1154
|
if (!room && lastRoom && roomsTracked.has(lastRoom)) room = lastRoom;
|
|
1155
|
-
|
|
1155
|
+
// The page's own query goes on to the player's game page, as it would on zaisma.com.
|
|
1156
|
+
const rest = new URLSearchParams(url.searchParams);
|
|
1157
|
+
for (const name of ["player", "room", "play"]) rest.delete(name);
|
|
1158
|
+
const framePath = `/p/${givenNumber}/g/${gameSlug}${room ? `?room=${room}` : "?play"}${rest.size ? `&${rest}` : ""}`;
|
|
1156
1159
|
return sendPage(response, await glass.devPage(placesFor(request), devViewFor(givenNumber), { path: framePath, allow: FRAME_ALLOW }));
|
|
1157
1160
|
}
|
|
1158
1161
|
if (url.pathname.startsWith("/bench/") && !/^\/bench\/(kept\.js|panel|api)(\/|$)/.test(url.pathname)) return await answerBench(request, response, url);
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zaisma/game-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.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",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/zaisma/zaisma.git",
|
|
9
|
+
"url": "git+https://github.com/zaisma/zaisma-sdk.git",
|
|
10
10
|
"directory": "packages/game-server"
|
|
11
11
|
},
|
|
12
|
-
"bugs": "https://
|
|
12
|
+
"bugs": "https://zaisma.com/forum",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"zaisma",
|
|
15
15
|
"games",
|
package/sdk/saves.js
CHANGED
|
@@ -699,7 +699,7 @@
|
|
|
699
699
|
if (/\/_zaisma\/restore$/.test(location.pathname)) {
|
|
700
700
|
// The game starts at its root, with the query the game page passed (like ?room=ABC234).
|
|
701
701
|
var query = decodeURIComponent(location.hash.slice(1));
|
|
702
|
-
var target = new URL("../" + (/^\?[\w
|
|
702
|
+
var target = new URL("../" + (/^\?[\w=&%+.*~-]*$/.test(query) ? query : ""), location.href).href;
|
|
703
703
|
var go = function () {
|
|
704
704
|
location.replace(target);
|
|
705
705
|
};
|
package/sdk/zaisma.d.ts
CHANGED
|
@@ -1759,8 +1759,9 @@ declare namespace Zaisma {
|
|
|
1759
1759
|
|
|
1760
1760
|
/**
|
|
1761
1761
|
* The codes the SDK's errors have: a room's ({@link RoomErrorCode}), and:
|
|
1762
|
-
* - unchecked: no player pass, because the game isn't played on its zaisma.com page
|
|
1763
|
-
*
|
|
1762
|
+
* - unchecked: no player pass, because the game isn't played on its zaisma.com page or Zaisma couldn't check the browser.
|
|
1763
|
+
* - no_online_play_in_preview: no player pass, because the game is a preview of a version players don't have yet, so a test build never
|
|
1764
|
+
* reaches live rooms. Test online play with `npx @zaisma/cli play-locally`, or publish the version and play it through a tester link.
|
|
1764
1765
|
* - unknown_option, unknown_event: a call the SDK doesn't take; the message lists what it does.
|
|
1765
1766
|
* - slow_down: too many calls; try again in a minute.
|
|
1766
1767
|
* - zaisma_rooms_not_used: the game doesn't use Zaisma rooms.
|
|
@@ -1801,6 +1802,7 @@ declare namespace Zaisma {
|
|
|
1801
1802
|
| "chat_too_fast"
|
|
1802
1803
|
| "chat_not_here"
|
|
1803
1804
|
| "unchecked"
|
|
1805
|
+
| "no_online_play_in_preview"
|
|
1804
1806
|
| "unknown_option"
|
|
1805
1807
|
| "unknown_event"
|
|
1806
1808
|
| "slow_down"
|
package/sdk/zaisma.js
CHANGED
|
@@ -192,6 +192,7 @@
|
|
|
192
192
|
var passPromise = null;
|
|
193
193
|
var keyPromise = null;
|
|
194
194
|
var UNCHECKED = "Zaisma couldn't check this browser, so it can't play online. Reload the game to try again.";
|
|
195
|
+
var NO_ONLINE_PLAY_IN_PREVIEW = "Online play is off in a preview of a version players don't have yet. Test online play with npx @zaisma/cli play-locally, or publish the version and play it through a tester link.";
|
|
195
196
|
|
|
196
197
|
/**
|
|
197
198
|
* The game page's key to player passes, as { key, playerKind }: whose passes it gives, the signed-in
|
|
@@ -202,6 +203,7 @@
|
|
|
202
203
|
if (!keyPromise) {
|
|
203
204
|
keyPromise = new Promise(function (resolve, reject) {
|
|
204
205
|
function fail(message) { reject(codedError("unchecked", message)); }
|
|
206
|
+
function failInPreview(message) { reject(codedError("no_online_play_in_preview", message)); }
|
|
205
207
|
if (!config.site || window.parent === window) return fail("Online play works when the game is played on Zaisma.");
|
|
206
208
|
// The check usually answers in a second or two, or asks the player to tap a box.
|
|
207
209
|
var timer = setTimeout(function () { removeEventListener("message", onMessage); fail(UNCHECKED); }, 30000);
|
|
@@ -210,8 +212,9 @@
|
|
|
210
212
|
removeEventListener("message", onMessage);
|
|
211
213
|
clearTimeout(timer);
|
|
212
214
|
if (typeof event.data.key === "string") resolve({ key: event.data.key, playerKind: event.data.playerKind === "account" ? "account" : "guest" });
|
|
213
|
-
//
|
|
214
|
-
else
|
|
215
|
+
// A preview of a version players don't have yet has no key on purpose, and the page says so, instead of the browser check.
|
|
216
|
+
else if (event.data.code === "no_online_play_in_preview") failInPreview(typeof event.data.message === "string" && event.data.message ? event.data.message.slice(0, 300) : NO_ONLINE_PLAY_IN_PREVIEW);
|
|
217
|
+
else fail(UNCHECKED);
|
|
215
218
|
}
|
|
216
219
|
addEventListener("message", onMessage);
|
|
217
220
|
window.parent.postMessage({ type: "zaisma:room-key" }, config.site);
|
package/bench/brand/README.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# Zaisma brand
|
|
2
|
-
|
|
3
|
-
The Z is the brand: Julius's own drawing, based on Futura, made of glass. `npm run brand` (`scripts/brand.mjs`) makes every glass file here from the drawing, the ones the site's logo shows included; never edit one by hand.
|
|
4
|
-
|
|
5
|
-
## Which file to use
|
|
6
|
-
|
|
7
|
-
| Use | File |
|
|
8
|
-
|---|---|
|
|
9
|
-
| The mark, on light surfaces | `zaisma-mark-glass-black.svg` (`-2048.png`) |
|
|
10
|
-
| The mark, on dark surfaces | `zaisma-mark-glass-white.svg` (`-2048.png`) |
|
|
11
|
-
| The wordmark, on light surfaces | `zaisma-wordmark-glass-black.svg` (`-2400.png`) |
|
|
12
|
-
| The wordmark, on dark surfaces | `zaisma-wordmark-glass-white.svg` (`-2400.png`) |
|
|
13
|
-
| One color (a stamp, a mask, a single-ink print) | `zaisma-mark-black.svg` / `zaisma-mark-white.svg`, `zaisma-wordmark-black.svg` / `zaisma-wordmark-white.svg` (`.png` copies at 2048 and 2400 px) |
|
|
14
|
-
| App icon | `zaisma-icon-light.svg` (the default) and `zaisma-icon-dark.svg`; `app-icon-1024.png`, `app-icon-512.png`, `app-icon-192.png`, `app-icon-dark-512.png` |
|
|
15
|
-
| Home screens | `apple-touch-icon.png` (square: the phone rounds it), `app-icon-maskable-512.png` (the Z inside the middle 80%), `manifest.webmanifest` |
|
|
16
|
-
| Stripe's icon | `stripe-icon.png` (the Z inside the middle 80%, like the maskable icon: Stripe cuts it to a circle) |
|
|
17
|
-
| Browser tab | `favicon.svg` (light and dark in one file), `favicon.ico` (16, 32 and 48 px), `favicon-32.png` |
|
|
18
|
-
| A shared link with no picture of its own | `share-card-light.png` (1200 × 630, from `share-card-light.svg`); `share-card-dark.png` for places that take a dark card |
|
|
19
|
-
| A friend invite link | `share-card-person-light.png` (the share card with the wordmark small at the bottom) and `share-card-letters.png` (a username's letters in Jost): the site draws the inviter's picture between them (`apps/site/src/person-card.ts`) |
|
|
20
|
-
| Loading | `loader/` (see below) |
|
|
21
|
-
| Zaisma Pro | `guild-seal-<px>.webp`, and `design/videos/guild-seal-forging.mp4` and `-resting.mp4`, from `npm run guild-seal`: the one drawing at every size, on its own dark circle |
|
|
22
|
-
|
|
23
|
-
## Rules
|
|
24
|
-
|
|
25
|
-
1. The mark is Julius's Z drawing, its three shards unchanged, made of glass: each shard bevelled and lit from the top left, with shaded walls. Never flat paint, metal or an outline. Black glass on light surfaces, white glass on dark ones.
|
|
26
|
-
2. The wordmark is the glass Z plus the shard letters "aisma" in the same glass, the letters shallower so the Z leads. Never retype it in a font.
|
|
27
|
-
3. The icon is the mark in front of the orange grid: a plane leaning back, rolled 35° along the Z's diagonal, strong near the viewer and gone by two-thirds up. Black Z on white and orange by default; white Z on black and the deeper orange for dark.
|
|
28
|
-
4. The share card is the full wordmark centered over the grid, the Relay far off to the right with its beam and lens flare, and players streaking toward it in orange. A person's card (a friend invite) is the same scene with their picture large in the middle and the wordmark small under it.
|
|
29
|
-
5. One Z at every size: never a second cut of it. The loader stays flat in the words' color. The flat black and white files are for one-color uses.
|
|
30
|
-
6. On pages, orange is only for what you press: the logo's orange lives in its icon and share card, never on the Z.
|
|
31
|
-
7. Leave clear space of at least the z's top-bar height. Don't rotate, stretch, recolor or add effects beyond these files.
|
|
32
|
-
8. The guild seal is Zaisma Pro's mark and nothing else's. Its Z is the one flat Z in brass: the one place the Z is recolored. Never a second drawing of it at another size.
|
|
33
|
-
|
|
34
|
-
The bevel is 125 units in the Z's 4500-unit drawing (30 px in the Affinity file).
|
|
35
|
-
|
|
36
|
-
## Loader
|
|
37
|
-
|
|
38
|
-
`loader/` holds the loading indicator: the Z building itself, one loop per second.
|
|
39
|
-
|
|
40
|
-
- `zaisma-loader.svg` draws in `currentColor`; the site uses it as a CSS mask so it takes the text color. `-black` and `-white` are fixed-color copies.
|
|
41
|
-
- `png/`, `webp/` and `gif/` are 128 px and 512 px exports, black and white, for places that can't run an animated SVG.
|
|
42
|
-
- Use it only while something is actually loading, never as decoration.
|
|
43
|
-
|
|
44
|
-
## Typeface
|
|
45
|
-
|
|
46
|
-
Headings use **Jost** (`fonts/jost.7726a5cd.woff2`, variable weight), a free geometric typeface close to Futura. It's under the SIL Open Font License (`fonts/OFL.txt`). Body text uses the system font. The file is named for its contents (the first 8 hex digits of its SHA-256), so browsers keep it for good (`_headers`): a changed font gets a new name, and `test/node/brand-files.test.ts` checks that every page asks for one that's there.
|
|
47
|
-
|
|
48
|
-
## Flags
|
|
49
|
-
|
|
50
|
-
`flags/` holds a 60×45 PNG of each country's flag, shown beside rooms on game pages (where the room runs). They're rendered from [flag-icons](https://github.com/lipis/flag-icons) 7.5.0, under the MIT License (`flags/LICENSE`). They aren't part of the brand; they live here because this folder is what zaisma.com serves as files.
|
|
51
|
-
|
|
52
|
-
## License
|
|
53
|
-
|
|
54
|
-
The code in this repo is MIT. The Zaisma name and logo are the project's identity: use them to refer to Zaisma, not to brand other products.
|
|
55
|
-
|
|
56
|
-
## The sign-in's pictures
|
|
57
|
-
|
|
58
|
-
`sign-in/` holds the city's stills (`apps/site/src/components/city.ts`): renders of the live city's first frame, by day and by night, wide and for a phone, which stand in where the city can't run.
|
|
59
|
-
|
|
60
|
-
## Cover guide pictures
|
|
61
|
-
|
|
62
|
-
`cover-guide/` holds the pictures zaisma.com/developers/covers shows (`apps/site/src/cover-guide.ts`, `docs/COVERS.md`): good covers made from real captures of the demo games Arena and Four in a Row, and stand-ins for made-up games. They are examples for developers, not Zaisma's brand.
|