@zaisma/cli 0.19.0 → 0.21.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/check.d.mts +1 -0
- package/check.mjs +11 -4
- package/package.json +1 -1
- package/zaisma.mjs +10 -4
package/check.d.mts
CHANGED
|
@@ -71,4 +71,5 @@ export const CHECK_PROBLEM_CODES: Record<CheckProblemCode, { problemKind: Proble
|
|
|
71
71
|
export function extensionOf(path: string): string;
|
|
72
72
|
export function isEngineOutput(path: string, lowercasePaths: Set<string>): boolean;
|
|
73
73
|
export function findOutsideReferences(text: string, fileKind: "html" | "css" | "module", options?: { baseUrl?: string | null }): OutsideReference[];
|
|
74
|
+
export function buildHasThreads(files: Pick<CheckedFile, "path" | "contentText">[]): boolean;
|
|
74
75
|
export function checkGameFiles(files: CheckedFile[], options?: { slug?: string | null; ownServerUrls?: readonly string[] | null }): GameCheck;
|
package/check.mjs
CHANGED
|
@@ -41,7 +41,7 @@ export const CHECK_PROBLEM_CODES = {
|
|
|
41
41
|
outside_file: { problemKind: "broken", isFixedByUploadCommand: true, meaning: "The page, a stylesheet or a module loads a file from another site; the upload command downloads it into the game." },
|
|
42
42
|
outside_address: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "The code connects to or loads from another site while it runs." },
|
|
43
43
|
address_not_allowed: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "The code connects to an address no game can use: plain ws:// or http://, localhost, or an IP address." },
|
|
44
|
-
needs_threads: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "The build needs threads (SharedArrayBuffer), which games on Zaisma
|
|
44
|
+
needs_threads: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "The build needs threads (SharedArrayBuffer), which games on Zaisma have only in Chrome and Edge." },
|
|
45
45
|
browser_dialog: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "alert, confirm or prompt, which never show in the game's frame." },
|
|
46
46
|
form_submission: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "A form, which never submits in the game's frame." },
|
|
47
47
|
file_download: { problemKind: "broken", isFixedByUploadCommand: false, meaning: "A file download, which the game's frame doesn't allow." },
|
|
@@ -301,6 +301,12 @@ function dialogOf(code) {
|
|
|
301
301
|
return null;
|
|
302
302
|
}
|
|
303
303
|
const THREADS_PATTERNS = [/\bGODOT_THREADS_ENABLED\s*=\s*true\b/, /\bENVIRONMENT_IS_PTHREAD\b/, /coi-serviceworker/i, /\b__wbindgen_thread_destroy\b/, /\binitThreadPool\b/];
|
|
304
|
+
const COI_SERVICE_WORKER_PATTERN = /coi-serviceworker/i;
|
|
305
|
+
|
|
306
|
+
/** Whether a game's files ({ path, contentText }, as checkGameFiles takes them) are a build that needs threads (SharedArrayBuffer). */
|
|
307
|
+
export function buildHasThreads(files) {
|
|
308
|
+
return files.some(({ path, contentText }) => (typeof contentText === "string" ? THREADS_PATTERNS.some((pattern) => pattern.test(contentText)) : COI_SERVICE_WORKER_PATTERN.test(path)));
|
|
309
|
+
}
|
|
304
310
|
|
|
305
311
|
/**
|
|
306
312
|
* Checks a game's files: [{ path, sizeBytes, contentText, headBytes }], contentText a string for the checked text
|
|
@@ -366,7 +372,8 @@ export function checkGameFiles(files, { slug = null, ownServerUrls = null } = {}
|
|
|
366
372
|
if (files.length > UPLOAD_LIMITS.maximumFileCount) add("too_many_files", { message: `The game has ${files.length} files; the limit is 20,000.`, fix: "Leave out files the game doesn't load, or pack small ones together (like sprites into an atlas)." });
|
|
367
373
|
if (sizeBytes > UPLOAD_LIMITS.maximumGameSizeBytes) add("game_too_big", { message: `The game is ${(sizeBytes / 1024 ** 3).toFixed(1)} GB; the limit is 2 GB.`, fix: "Leave out files the game doesn't load, or ask Zaisma (message_zaisma, kind gap) for more." });
|
|
368
374
|
|
|
369
|
-
const threadsFix = "
|
|
375
|
+
const threadsFix = "Threads run in Chrome and Edge on computers and Android. Firefox, Safari and every browser on iPhone and iPad can't start this build, and the game page tells their players it needs Chrome or Edge. To reach every browser, export without threads: in Godot 4.3 or newer, turn Thread Support off in the Web export preset; in Unity, leave Native C/C++ Multithreading off (the default); in Rust, build without the `atomics` target feature and without wasm-bindgen-rayon.";
|
|
376
|
+
const coiServiceWorkerMessage = (path) => `${path} is there to turn on threads (SharedArrayBuffer). Zaisma doesn't need it: the game is already isolated in Chrome and Edge, and it can't turn threads on in other browsers.`;
|
|
370
377
|
let hasThreadsProblem = false;
|
|
371
378
|
const addThreads = (message, quote, path) => {
|
|
372
379
|
if (!hasThreadsProblem) add("needs_threads", { message, quote, path, fix: threadsFix });
|
|
@@ -375,7 +382,7 @@ export function checkGameFiles(files, { slug = null, ownServerUrls = null } = {}
|
|
|
375
382
|
for (const file of files) {
|
|
376
383
|
const { path, contentText: text } = file;
|
|
377
384
|
if (typeof text !== "string") {
|
|
378
|
-
if (
|
|
385
|
+
if (buildHasThreads([file])) addThreads(coiServiceWorkerMessage(path), null, path);
|
|
379
386
|
continue;
|
|
380
387
|
}
|
|
381
388
|
const extension = extensionOf(path);
|
|
@@ -406,7 +413,7 @@ export function checkGameFiles(files, { slug = null, ownServerUrls = null } = {}
|
|
|
406
413
|
}
|
|
407
414
|
|
|
408
415
|
const threadsMatch = THREADS_PATTERNS.map((pattern) => pattern.exec(text)).find(Boolean);
|
|
409
|
-
if (threadsMatch) addThreads(`${path} is from a build that needs threads (SharedArrayBuffer), which
|
|
416
|
+
if (threadsMatch) addThreads(COI_SERVICE_WORKER_PATTERN.test(path) ? coiServiceWorkerMessage(path) : `${path} is from a build that needs threads (SharedArrayBuffer), which only Chrome and Edge give games on Zaisma.`, lineAround(text, threadsMatch.index), path);
|
|
410
417
|
|
|
411
418
|
if (isEngineOutput(path, lowercasePaths)) continue;
|
|
412
419
|
// What the code does, not what its comments say: a library's docs mention alert() and window.open.
|
package/package.json
CHANGED
package/zaisma.mjs
CHANGED
|
@@ -102,13 +102,17 @@ const COMMANDS = {
|
|
|
102
102
|
game: { hasValue: true, isRequired: true, placeholder: "<slug>", about: "The game to upload to" },
|
|
103
103
|
"patch-notes": { hasValue: true, placeholder: '"…"', about: "What changed, shown with the update" },
|
|
104
104
|
"publish-when-approved": { hasValue: false, about: "Go live as soon as it passes review" },
|
|
105
|
+
"match-update-mode": { hasValue: true, placeholder: "<next_match|now>", about: "With --publish-when-approved: when running matches get it: next_match (they finish on the version they started; the default) or now (every live match switches within seconds, in the same room)" },
|
|
105
106
|
},
|
|
106
107
|
},
|
|
107
108
|
versions: { about: "List a game's versions and preview links", arguments: [{ name: "slug" }], flags: {} },
|
|
108
109
|
publish: {
|
|
109
110
|
about: "Publish a version that passed, or roll back to an older one",
|
|
110
111
|
arguments: [{ name: "slug" }, { name: "version_id" }],
|
|
111
|
-
flags: {
|
|
112
|
+
flags: {
|
|
113
|
+
"scheduled-publish-at": { hasValue: true, placeholder: "<time>", about: 'Publish later instead: an ISO 8601 time with Z or an offset, like "2026-11-01T17:00:00Z" or "2026-11-01T17:00+01:00"' },
|
|
114
|
+
"match-update-mode": { hasValue: true, placeholder: "<next_match|now>", about: "When running matches get it: next_match (they finish on the version they started; the default) or now (every live match switches within seconds, in the same room)" },
|
|
115
|
+
},
|
|
112
116
|
},
|
|
113
117
|
unschedule: { about: "Cancel a publish-later", arguments: [{ name: "slug" }, { name: "version_id" }], flags: {} },
|
|
114
118
|
visibility: { about: "Set who can see a game: everyone (listed), people with the link (unlisted), or only you and tester links (private, draft)", arguments: [{ name: "slug" }, { name: "visibility", choices: VISIBILITIES }], flags: {} },
|
|
@@ -790,7 +794,7 @@ async function sendVersion(slug, fixedFiles, flags) {
|
|
|
790
794
|
);
|
|
791
795
|
if (todo.length && !isJson) process.stdout.write("\n");
|
|
792
796
|
|
|
793
|
-
let answer = await api("POST", `/games/${slug}/versions`, { files: list, patch_notes: flags["patch-notes"] ?? "", publish_when_approved: flags["publish-when-approved"] === true });
|
|
797
|
+
let answer = await api("POST", `/games/${slug}/versions`, { files: list, patch_notes: flags["patch-notes"] ?? "", publish_when_approved: flags["publish-when-approved"] === true, ...(flags["match-update-mode"] !== undefined ? { match_update_mode: flags["match-update-mode"] } : {}) });
|
|
794
798
|
const versionId = answer.version.id;
|
|
795
799
|
say(`Version ${versionId} is being scanned. This usually takes under a minute…`);
|
|
796
800
|
|
|
@@ -1641,12 +1645,14 @@ async function run({ command, values, flags, globalFlags, rest }) {
|
|
|
1641
1645
|
if (command === "publish") {
|
|
1642
1646
|
const { slug, version_id: versionId } = values;
|
|
1643
1647
|
const scheduledPublishAt = flags["scheduled-publish-at"] === undefined ? undefined : checkPublishTime(flags["scheduled-publish-at"]);
|
|
1644
|
-
const
|
|
1648
|
+
const matchUpdateMode = flags["match-update-mode"];
|
|
1649
|
+
const publishBody = { ...(scheduledPublishAt ? { scheduled_publish_at: scheduledPublishAt } : {}), ...(matchUpdateMode !== undefined ? { match_update_mode: matchUpdateMode } : {}) };
|
|
1650
|
+
const answer = await api("POST", `/games/${slug}/versions/${versionId}/publish`, Object.keys(publishBody).length ? publishBody : undefined);
|
|
1645
1651
|
if (isJson) return printAnswer(answer);
|
|
1646
1652
|
const { game, version } = answer;
|
|
1647
1653
|
if (scheduledPublishAt) console.log(`Version ${versionId} will go live at ${when(version.scheduled_publish_at)}${version.scan_status === "scanning" ? ", if it has passed the scan by then" : ""}.`);
|
|
1648
1654
|
else {
|
|
1649
|
-
console.log(`Version ${versionId} is live at ${game.page_url}`);
|
|
1655
|
+
console.log(`Version ${versionId} is live at ${game.page_url}${matchUpdateMode === "now" ? "; running matches switch to it within seconds" : ""}`);
|
|
1650
1656
|
if (game.visibility === "draft") console.log(`The game is still a draft, so only you can see it. Show it to everyone with: zaisma visibility ${slug} listed`);
|
|
1651
1657
|
}
|
|
1652
1658
|
return EXIT_CODES.done;
|