@zaisma/cli 0.20.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/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.
|