@moku-labs/game 0.15.57 → 0.15.59
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 -0
- package/dist/app/page.d.mts +3 -2
- package/dist/app/page.mjs +56 -2
- package/dist/app/system.d.mts +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +1 -1
- package/dist/cli.mjs +104 -26
- package/dist/{commands-B208rrQE.d.mts → commands-OYwZDclg.d.mts} +1 -1
- package/dist/{config-B87aFTW-.mjs → config-HpC-p8Ow.mjs} +35 -6
- package/dist/control.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/inspect.d.mts +1 -1
- package/dist/{src-CJtaTza4.mjs → src-BIiNB7Fz.mjs} +49 -16
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/{types-DuqbyY_j.d.mts → types-CuFoPhWD.d.mts} +40 -3
- package/dist/{visual-CpTnNnas.d.mts → visual-mPbBWlEz.d.mts} +1 -1
- package/dist/visual.d.mts +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,6 +118,8 @@ import type { GameConfig } from "@moku-labs/game/app";
|
|
|
118
118
|
export default { page: { title: "Dice" } } satisfies GameConfig;
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
`page.boot: { image: "assets/boot.png" }` shows a picture from the first paint until the first scene drew, then fades it out. Every key of `config.ts`: [docs/shell.md](./docs/shell.md).
|
|
122
|
+
|
|
121
123
|
Tests make the app with `game.headless()` or `game.screen()`, not started, on a fake clock and an in-memory save:
|
|
122
124
|
|
|
123
125
|
```ts
|
package/dist/app/page.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as StartedPage, r as GameConfig, t as AnyGameApp, u as PageOptions } from "../types-
|
|
1
|
+
import { m as StartedPage, r as GameConfig, t as AnyGameApp, u as PageOptions } from "../types-CuFoPhWD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/app/page.d.ts
|
|
4
4
|
/**
|
|
@@ -6,7 +6,8 @@ import { m as StartedPage, r as GameConfig, t as AnyGameApp, u as PageOptions }
|
|
|
6
6
|
* fresh memory save, never on the stored one), builds the system shell when the page has one,
|
|
7
7
|
* picks the save, makes the screen app on `#game` over the device clock and the manifest next to
|
|
8
8
|
* the page, sets `globalThis.game`, `system` and `doors`, follows reduced motion, starts the shell,
|
|
9
|
-
* then the app,
|
|
9
|
+
* then the app, follows the boot picture of `page.boot` (it fades once the first scene drew, and
|
|
10
|
+
* is removed), and runs the graph. A graph that stops is logged, never thrown. In dev and in a
|
|
10
11
|
* debug build it then logs `page:build` (the build id, the engine id, the control profile),
|
|
11
12
|
* starts the agents and shows the overlay as `config.ts` `debug.overlay` asks. Every problem goes
|
|
12
13
|
* to the app's log. On `pagehide` it flushes the save, and stops the app when the page is really
|
package/dist/app/page.mjs
CHANGED
|
@@ -3,7 +3,44 @@ import { t as applyTo } from "../drafts-BawpSaVp.mjs";
|
|
|
3
3
|
import { i as isControl } from "../dev-BNndV-hU.mjs";
|
|
4
4
|
import { n as fakeClock, t as VISUAL_CLOCK } from "../fake-hnJcJeYf.mjs";
|
|
5
5
|
import { n as read, r as watch, t as sources } from "../sources-Bp9xmX3f.mjs";
|
|
6
|
-
import { t as resolveConfig } from "../config-
|
|
6
|
+
import { t as resolveConfig } from "../config-HpC-p8Ow.mjs";
|
|
7
|
+
//#region src/app/boot.ts
|
|
8
|
+
/** How long after the fade the timer removes a picture whose transition never ended, ms. */
|
|
9
|
+
const FALLBACK_MS = 100;
|
|
10
|
+
/**
|
|
11
|
+
* Fades the boot picture out after the first scene drew. It adds one render callback: in the
|
|
12
|
+
* first render frame with a mounted scene it sets the opacity to 0, so the page's CSS transition
|
|
13
|
+
* fades it over `fadeMs`, and unsubscribes. The picture is removed on `transitionend`, or by a
|
|
14
|
+
* timer `fadeMs + 100` ms later for a page in the background, where no transition ends: whichever
|
|
15
|
+
* comes first removes it and clears the other, and a second removal does nothing. `fadeMs` 0
|
|
16
|
+
* removes it in that frame. Before the first scene the callback is one `current()` read a frame.
|
|
17
|
+
*
|
|
18
|
+
* @param time - `app.time`: the render phase runs after the frame's draw.
|
|
19
|
+
* @param scenes - `app.scenes`: `current()` is set before the frame that first draws the scene.
|
|
20
|
+
* @param element - The `<img id="moku-boot">` of the page.
|
|
21
|
+
* @param fadeMs - The fade of `page.boot`, ms.
|
|
22
|
+
*/
|
|
23
|
+
function fadeBoot(time, scenes, element, fadeMs) {
|
|
24
|
+
const off = time.onFrame("render", () => {
|
|
25
|
+
if (scenes.current() === void 0) return;
|
|
26
|
+
off();
|
|
27
|
+
if (fadeMs === 0) {
|
|
28
|
+
element.remove();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let removed = false;
|
|
32
|
+
const remove = () => {
|
|
33
|
+
if (removed) return;
|
|
34
|
+
removed = true;
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
element.remove();
|
|
37
|
+
};
|
|
38
|
+
const timer = setTimeout(remove, fadeMs + FALLBACK_MS);
|
|
39
|
+
element.addEventListener("transitionend", remove, { once: true });
|
|
40
|
+
element.style.opacity = "0";
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
7
44
|
//#region src/app/save.ts
|
|
8
45
|
/**
|
|
9
46
|
* @file The saves of the page: `localSave` keeps the player in `localStorage`, `pageSave` picks
|
|
@@ -319,6 +356,21 @@ function followPageHide(app) {
|
|
|
319
356
|
addEventListener("pagehide", listener);
|
|
320
357
|
}
|
|
321
358
|
/**
|
|
359
|
+
* Fades the boot picture once the first scene drew, when the page has one: a page with a
|
|
360
|
+
* document and an `<img id="moku-boot">`. Without a document (a test) or the element, nothing is
|
|
361
|
+
* added. A picture the config no longer names, on a page written before, goes without a fade in the
|
|
362
|
+
* first scene frame.
|
|
363
|
+
*
|
|
364
|
+
* @param app - The started screen app: its renderer registered its render callback first.
|
|
365
|
+
* @param boot - `page.boot` of the resolved config, or `undefined`.
|
|
366
|
+
*/
|
|
367
|
+
function followBoot(app, boot) {
|
|
368
|
+
if (typeof document === "undefined") return;
|
|
369
|
+
const element = document.querySelector("#moku-boot");
|
|
370
|
+
if (element === null) return;
|
|
371
|
+
fadeBoot(app.time, app.scenes, element, boot?.fadeMs ?? 0);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
322
374
|
* Starts the agents, in order, after the app, in dev and in a debug build: each gets the app, the
|
|
323
375
|
* page title and the game's `.dev` modules. A throwing agent is logged and the page keeps running.
|
|
324
376
|
*
|
|
@@ -354,7 +406,8 @@ function openStartOverlay(app, overlay) {
|
|
|
354
406
|
* fresh memory save, never on the stored one), builds the system shell when the page has one,
|
|
355
407
|
* picks the save, makes the screen app on `#game` over the device clock and the manifest next to
|
|
356
408
|
* the page, sets `globalThis.game`, `system` and `doors`, follows reduced motion, starts the shell,
|
|
357
|
-
* then the app,
|
|
409
|
+
* then the app, follows the boot picture of `page.boot` (it fades once the first scene drew, and
|
|
410
|
+
* is removed), and runs the graph. A graph that stops is logged, never thrown. In dev and in a
|
|
358
411
|
* debug build it then logs `page:build` (the build id, the engine id, the control profile),
|
|
359
412
|
* starts the agents and shows the overlay as `config.ts` `debug.overlay` asks. Every problem goes
|
|
360
413
|
* to the app's log. On `pagehide` it flushes the save, and stops the app when the page is really
|
|
@@ -418,6 +471,7 @@ async function startPage(game, config, options = {}) {
|
|
|
418
471
|
followReducedMotion(app);
|
|
419
472
|
await shell?.start();
|
|
420
473
|
await app.start();
|
|
474
|
+
followBoot(app, settings.page.boot);
|
|
421
475
|
app.flow.run().catch((error) => {
|
|
422
476
|
app.log.error("[game] The graph stopped.", void 0, toError(error));
|
|
423
477
|
});
|
package/dist/app/system.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr as PlayerStateProvider } from "../types-C6PML3Il.mjs";
|
|
2
2
|
import { ht as PlatformProvider } from "../index-m2g9-8_E.mjs";
|
|
3
|
-
import { _ as SystemShellFactory, g as SystemName, h as SystemModules } from "../types-
|
|
3
|
+
import { _ as SystemShellFactory, g as SystemName, h as SystemModules } from "../types-CuFoPhWD.mjs";
|
|
4
4
|
import { Back, Haptics, KeepAwake, Lifecycle, Store } from "@moku-labs/system";
|
|
5
5
|
|
|
6
6
|
//#region src/app/system.d.ts
|
package/dist/app.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ar as Json } from "./types-C6PML3Il.mjs";
|
|
2
2
|
import { U as StringTable } from "./types-FtzEwwWY.mjs";
|
|
3
|
-
import { a as GameHandle, c as MemoryProvider, d as SaveKind, f as Scenario, g as SystemName, i as GameDefinition, l as PageAgent, n as GameApp, o as GamePluginConfigs, p as ScreenSeams, r as GameConfig, s as HeadlessSeams, v as WithGameState } from "./types-
|
|
3
|
+
import { a as GameHandle, c as MemoryProvider, d as SaveKind, f as Scenario, g as SystemName, i as GameDefinition, l as PageAgent, n as GameApp, o as GamePluginConfigs, p as ScreenSeams, r as GameConfig, s as HeadlessSeams, v as WithGameState } from "./types-CuFoPhWD.mjs";
|
|
4
4
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
5
5
|
|
|
6
6
|
//#region src/app/define.d.ts
|
package/dist/app.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-
|
|
1
|
+
import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-BIiNB7Fz.mjs";
|
|
2
2
|
import { t as memory } from "./memory-CWlqhS7l.mjs";
|
|
3
3
|
import { n as fakeClock, r as isFakeClock } from "./fake-hnJcJeYf.mjs";
|
|
4
4
|
//#region src/app/define.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as resolveConfig } from "./config-
|
|
1
|
+
import { t as resolveConfig } from "./config-HpC-p8Ow.mjs";
|
|
2
2
|
import { t as findFeatureOwners } from "./features-DowEilZm.mjs";
|
|
3
3
|
import { r as watchTree, t as createBatcher, x as isSkippedFolder$1 } from "./watch-BSgptowj.mjs";
|
|
4
4
|
import { a as runCli$1, i as compileStrings, n as importStrings, t as exportStrings } from "./assets-BRTUagOC.mjs";
|
|
@@ -239,7 +239,7 @@ const DEBUG_AGENT = "@moku-labs/editor/agent/page";
|
|
|
239
239
|
* of `moku-game visual` import the same one.
|
|
240
240
|
*/
|
|
241
241
|
const ASSETS_STAMP = "assets-stamp.ts";
|
|
242
|
-
/** A colour or a
|
|
242
|
+
/** A colour, a language tag or a CSS length: it lands in a `<style>` and in attributes, so nothing else passes. */
|
|
243
243
|
const SAFE_VALUE = /^[#\w(),.%\s-]+$/;
|
|
244
244
|
/** The files of `tests/scenarios/` that are not scenarios. */
|
|
245
245
|
const NOT_SCENARIO = /\.(?:test|spec|d)\.ts$|^index\.ts$/;
|
|
@@ -270,10 +270,10 @@ function escapeHtml(text) {
|
|
|
270
270
|
/**
|
|
271
271
|
* Checks a value of the page that lands in the style and in attributes.
|
|
272
272
|
*
|
|
273
|
-
* @param value - The background or the
|
|
273
|
+
* @param value - The background, the lang or the width of the boot picture.
|
|
274
274
|
* @param problem - The error when the value has another character.
|
|
275
275
|
* @returns The value.
|
|
276
|
-
* @throws {Error} The problem, when the value is not a plain colour or
|
|
276
|
+
* @throws {Error} The problem, when the value is not a plain colour, tag or length.
|
|
277
277
|
* @example
|
|
278
278
|
* ```ts
|
|
279
279
|
* safeValue("#10161d", "not a colour"); // "#10161d"
|
|
@@ -284,20 +284,21 @@ function safeValue(value, problem) {
|
|
|
284
284
|
return value;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
* The link of one icon: a path inside the game folder,
|
|
287
|
+
* The link of one file of the page, an icon or the boot picture: a path inside the game folder,
|
|
288
|
+
* never above it.
|
|
288
289
|
*
|
|
289
|
-
* @param
|
|
290
|
+
* @param field - The config field, such as `page.icons.favicon` or `page.boot.image`.
|
|
290
291
|
* @param file - The path the config gives, relative to the game folder.
|
|
291
292
|
* @returns The path with `/` separators.
|
|
292
293
|
* @throws {Error} When the path is absolute or climbs out of the game folder.
|
|
293
294
|
* @example
|
|
294
295
|
* ```ts
|
|
295
|
-
*
|
|
296
|
+
* gamePath("page.boot.image", "assets\\boot.png"); // "assets/boot.png"
|
|
296
297
|
* ```
|
|
297
298
|
*/
|
|
298
|
-
function
|
|
299
|
+
function gamePath(field, file) {
|
|
299
300
|
const slashed = file.replaceAll("\\", "/");
|
|
300
|
-
if (slashed.startsWith("/") || /^[a-z]:/i.test(slashed) || slashed.split("/").includes("..") || slashed === "") throw new Error(`[game] moku-game:
|
|
301
|
+
if (slashed.startsWith("/") || /^[a-z]:/i.test(slashed) || slashed.split("/").includes("..") || slashed === "") throw new Error(`[game] moku-game: ${field} "${file}" is not a file in the game.`);
|
|
301
302
|
return slashed;
|
|
302
303
|
}
|
|
303
304
|
/**
|
|
@@ -315,19 +316,71 @@ function iconLinks(icons, toRoot) {
|
|
|
315
316
|
return [["favicon", "icon"], ["appleTouch", "apple-touch-icon"]].flatMap(([name, relation]) => {
|
|
316
317
|
const file = icons[name];
|
|
317
318
|
if (file === void 0) return [];
|
|
318
|
-
return [` <link rel="${relation}" href="${escapeHtml(toRoot +
|
|
319
|
+
return [` <link rel="${relation}" href="${escapeHtml(toRoot + gamePath(`page.icons.${name}`, file))}" />`];
|
|
319
320
|
});
|
|
320
321
|
}
|
|
321
322
|
/**
|
|
323
|
+
* The files of the game the page links, each with its config field, in a fixed order: the favicon,
|
|
324
|
+
* the apple touch icon, the boot picture. The build copies the ones Bun left as links; the dev
|
|
325
|
+
* server checks that each is a file.
|
|
326
|
+
*
|
|
327
|
+
* @param page - The page of the resolved `config.ts`.
|
|
328
|
+
* @returns The field and the path, as the config gives it, of each file the page names.
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* linkedFiles(resolveConfig({ page: { title: "T", icons: { favicon: "icon.png" }, boot: { image: "boot.png" } } }).page); // [["page.icons.favicon", "icon.png"], ["page.boot.image", "boot.png"]]
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
function linkedFiles(page) {
|
|
335
|
+
const { favicon, appleTouch } = page.icons;
|
|
336
|
+
return [
|
|
337
|
+
...favicon === void 0 ? [] : [["page.icons.favicon", favicon]],
|
|
338
|
+
...appleTouch === void 0 ? [] : [["page.icons.appleTouch", appleTouch]],
|
|
339
|
+
...page.boot === void 0 ? [] : [["page.boot.image", page.boot.image]]
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* The style rule of the boot picture: centred, above the canvas, deaf to the pointer, fading
|
|
344
|
+
* over `fadeMs` once the page sets its opacity to 0.
|
|
345
|
+
*
|
|
346
|
+
* @param boot - The boot picture of the page.
|
|
347
|
+
* @returns The rule, with a space before it.
|
|
348
|
+
* @throws {Error} When the width is not a CSS length.
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* bootRule({ image: "boot.png", width: "52vmin", fadeMs: 0 }).includes("width: 52vmin;"); // true
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
function bootRule(boot) {
|
|
355
|
+
return ` #moku-boot { position: fixed; left: 50%; top: 50%; width: ${safeValue(boot.width, `[game] moku-game: page.boot.width "${boot.width}" is not a CSS length.`)}; height: auto; transform: translate(-50%, -50%); z-index: 1; pointer-events: none; transition: opacity ${String(boot.fadeMs)}ms linear; }`;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The `<img>` of the boot picture, the first element of the body.
|
|
359
|
+
*
|
|
360
|
+
* @param boot - The boot picture of the page.
|
|
361
|
+
* @param toRoot - The path from the page to the game folder.
|
|
362
|
+
* @returns The line.
|
|
363
|
+
* @throws {Error} When the picture is not a file in the game.
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* bootImage({ image: "assets/boot.png", width: "40vmin", fadeMs: 300 }, "../"); // ' <img id="moku-boot" src="../assets/boot.png" alt="" />'
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
function bootImage(boot, toRoot) {
|
|
370
|
+
return ` <img id="moku-boot" src="${escapeHtml(toRoot + gamePath("page.boot.image", boot.image))}" alt="" />`;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
322
373
|
* The page a game runs in: the title, the language, the background (also the theme colour), the
|
|
323
374
|
* icons as links (never `url()` in the style: `Bun.build` does not rewrite it), the `head` tags
|
|
324
|
-
* verbatim after the style,
|
|
375
|
+
* verbatim after the style, then the body: the boot picture first when the page has one (an
|
|
376
|
+
* `<img id="moku-boot">`, its rule in the style), `<div id="game">` and the module script. A page
|
|
377
|
+
* without a boot is the same HTML as before `page.boot`.
|
|
325
378
|
*
|
|
326
379
|
* @param page - The page of the resolved `config.ts`.
|
|
327
380
|
* @param links - The path to the game folder and the script.
|
|
328
381
|
* @returns The HTML.
|
|
329
|
-
* @throws {Error} When the background is not a CSS colour, the lang not a language tag,
|
|
330
|
-
*
|
|
382
|
+
* @throws {Error} When the background is not a CSS colour, the lang not a language tag, an icon
|
|
383
|
+
* path or the boot picture leaves the game folder, or the boot width is not a CSS length.
|
|
331
384
|
* @example
|
|
332
385
|
* ```ts
|
|
333
386
|
* pageHtml(resolveConfig({ page: { title: "mini-game" } }).page, { toRoot: "../", script: "./main.ts" }).includes("<title>mini-game</title>"); // true
|
|
@@ -336,7 +389,7 @@ function iconLinks(icons, toRoot) {
|
|
|
336
389
|
function pageHtml(page, links) {
|
|
337
390
|
const background = safeValue(page.background, `[game] moku-game: page.background "${page.background}" is not a CSS color.`);
|
|
338
391
|
const lang = safeValue(page.lang, `[game] moku-game: page.lang "${page.lang}" is not a language tag.`);
|
|
339
|
-
const style = `html, body { margin: 0; height: 100%; background: ${background}; } #game { width: 100%; height: 100%; touch-action: none; }
|
|
392
|
+
const style = `html, body { margin: 0; height: 100%; background: ${background}; } #game { width: 100%; height: 100%; touch-action: none; }` + (page.boot === void 0 ? "" : bootRule(page.boot));
|
|
340
393
|
return [
|
|
341
394
|
"<!doctype html>",
|
|
342
395
|
`<html lang="${lang}">`,
|
|
@@ -350,6 +403,7 @@ function pageHtml(page, links) {
|
|
|
350
403
|
...page.head.map((tag) => ` ${tag}`),
|
|
351
404
|
" </head>",
|
|
352
405
|
" <body>",
|
|
406
|
+
...page.boot === void 0 ? [] : [bootImage(page.boot, links.toRoot)],
|
|
353
407
|
" <div id=\"game\"></div>",
|
|
354
408
|
` <script type="module" src="${escapeHtml(links.script)}"><\/script>`,
|
|
355
409
|
" </body>",
|
|
@@ -974,29 +1028,30 @@ async function loadSettings(root) {
|
|
|
974
1028
|
return resolveConfig(loaded.default);
|
|
975
1029
|
}
|
|
976
1030
|
/**
|
|
977
|
-
* Checks that every
|
|
1031
|
+
* Checks that every file the page links, the icons and the boot picture, is a file of the game.
|
|
978
1032
|
*
|
|
979
1033
|
* @param root - The game folder.
|
|
980
1034
|
* @param page - The resolved page.
|
|
981
|
-
* @throws {Error} When an icon is not a file in the game.
|
|
1035
|
+
* @throws {Error} When an icon or the boot picture is not a file in the game.
|
|
982
1036
|
*/
|
|
983
|
-
function
|
|
984
|
-
for (const [
|
|
1037
|
+
function checkPageFiles(root, page) {
|
|
1038
|
+
for (const [field, file] of linkedFiles(page)) if (!isFile(path.join(root, file))) throw new Error(`[game] moku-game: ${field} "${file}" is not a file in the game.`);
|
|
985
1039
|
}
|
|
986
1040
|
/**
|
|
987
1041
|
* Reads and checks a game folder for a page: `config.ts` and `index.ts` exist, the config
|
|
988
|
-
* resolves
|
|
1042
|
+
* resolves (a bad `page.boot.fadeMs` is refused here, before any page is made) and the files the
|
|
1043
|
+
* page links, its icons and its boot picture, are files of the game.
|
|
989
1044
|
*
|
|
990
1045
|
* @param root - The game folder, absolute.
|
|
991
1046
|
* @returns The resolved config.
|
|
992
1047
|
* @throws {Error} When `config.ts` or `index.ts` is missing, a config value is refused, or an icon
|
|
993
|
-
* is not a file in the game.
|
|
1048
|
+
* or the boot picture is not a file in the game.
|
|
994
1049
|
*/
|
|
995
1050
|
async function loadGame(root) {
|
|
996
1051
|
configFileOf(root);
|
|
997
1052
|
if (!isFile(path.join(root, "index.ts"))) throw new Error(`[game] moku-game: no index.ts in "${root}".\n It default-exports defineGameApp({ ... }).`);
|
|
998
1053
|
const settings = await loadSettings(root);
|
|
999
|
-
|
|
1054
|
+
checkPageFiles(root, settings.page);
|
|
1000
1055
|
return settings;
|
|
1001
1056
|
}
|
|
1002
1057
|
/**
|
|
@@ -1760,19 +1815,42 @@ async function bundlePage(run, settings, page) {
|
|
|
1760
1815
|
if (!result.success) throw new Error(["[game] build: the page did not bundle.", ...result.logs.map(String)].join("\n"));
|
|
1761
1816
|
}
|
|
1762
1817
|
/**
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1818
|
+
* Refuses the boot picture when its copy would share one name beside the page with another file left in the game. One
|
|
1819
|
+
* file linked twice (the favicon also the boot picture) is one copy, not a clash. Two icons of one name build as
|
|
1820
|
+
* before: the boot picture is the only new file the copy can lose.
|
|
1821
|
+
*
|
|
1822
|
+
* @param left - The field and the `/` path of each file Bun left as a link, in page order.
|
|
1823
|
+
* @throws {Error} When the boot picture and another file have one base name.
|
|
1824
|
+
*/
|
|
1825
|
+
function refuseNameClash(left) {
|
|
1826
|
+
const byName = /* @__PURE__ */ new Map();
|
|
1827
|
+
for (const entry of left) {
|
|
1828
|
+
const [field, linked] = entry;
|
|
1829
|
+
const name = path.basename(linked);
|
|
1830
|
+
const earlier = byName.get(name);
|
|
1831
|
+
const involvesBoot = field === "page.boot.image" || earlier?.[0] === "page.boot.image";
|
|
1832
|
+
if (earlier !== void 0 && earlier[1] !== linked && involvesBoot) throw new Error(`[game] build: ${field} and ${earlier[0]} share the name "${name}" beside the page.`);
|
|
1833
|
+
byName.set(name, entry);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* The fallback for page files Bun left as links into the game, the icons and the boot picture:
|
|
1838
|
+
* copies each beside the page and links it as `./<name>`. Two such files with one name are
|
|
1839
|
+
* refused before anything is copied when one is the boot picture; a file Bun already linked is never copied, so it cannot
|
|
1840
|
+
* clash.
|
|
1765
1841
|
*
|
|
1766
1842
|
* @param run - The flags of the run.
|
|
1767
1843
|
* @param settings - The resolved config.
|
|
1844
|
+
* @throws {Error} When two files left in the game share a name beside the page.
|
|
1768
1845
|
*/
|
|
1769
1846
|
function relinkIcons(run, settings) {
|
|
1770
1847
|
const file = path.join(run.out, "index.html");
|
|
1771
1848
|
let html = readFileSync(file, "utf8");
|
|
1772
1849
|
if (!html.includes(`"${TO_ROOT}`)) return;
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1850
|
+
const left = linkedFiles(settings.page).map(([field, linkedFile]) => [field, linkedFile.replaceAll("\\", "/")]).filter(([, linked]) => html.includes(`"${TO_ROOT}${linked}"`));
|
|
1851
|
+
refuseNameClash(left);
|
|
1852
|
+
for (const [, linked] of left) {
|
|
1853
|
+
if (!html.includes(`"${TO_ROOT}${linked}"`)) continue;
|
|
1776
1854
|
const name = path.basename(linked);
|
|
1777
1855
|
copyFileSync(path.join(run.root, linked), path.join(run.out, name));
|
|
1778
1856
|
html = html.replaceAll(`"${TO_ROOT}${linked}"`, `"./${name}"`);
|
|
@@ -137,8 +137,8 @@ declare const commands: Readonly<{
|
|
|
137
137
|
readonly ui: Pick<UiApi, "fill">;
|
|
138
138
|
}>;
|
|
139
139
|
scroll: Command<{
|
|
140
|
-
readonly to: "number";
|
|
141
140
|
readonly key: "string";
|
|
141
|
+
readonly to: "number";
|
|
142
142
|
}, boolean, HeadlessApp & {
|
|
143
143
|
readonly log: import("@moku-labs/common/browser").LogApi;
|
|
144
144
|
} & {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
//#region src/app/config.ts
|
|
2
|
+
/** The CSS width of a boot picture whose config names none. */
|
|
3
|
+
const BOOT_WIDTH = "40vmin";
|
|
4
|
+
/** The fade of a boot picture whose config names none, ms. */
|
|
5
|
+
const BOOT_FADE_MS = 300;
|
|
2
6
|
/**
|
|
3
7
|
* The save kinds a config may name.
|
|
4
8
|
*
|
|
@@ -54,8 +58,9 @@ function overlayStarts() {
|
|
|
54
58
|
* Throws for the first value of a config that TypeScript would have refused.
|
|
55
59
|
*
|
|
56
60
|
* @param config - The default export of `config.ts`.
|
|
57
|
-
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
58
|
-
* `debug.overlay` is not a start mode.
|
|
61
|
+
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
62
|
+
* `debug.overlay` is not a start mode, `page.boot` has no image, or `page.boot.fadeMs` is not a finite number of 0
|
|
63
|
+
* or more.
|
|
59
64
|
*/
|
|
60
65
|
function checkConfig(config) {
|
|
61
66
|
if (config.save !== void 0 && !saveKinds().has(config.save)) throw new Error(`[game] config.save is "${config.save}".\n Use "memory", "local" or "store".`);
|
|
@@ -65,16 +70,39 @@ function checkConfig(config) {
|
|
|
65
70
|
if (config.page.title.trim() === "") throw new Error("[game] config.page.title is empty.\n Give the page a title in config.ts.");
|
|
66
71
|
const overlay = config.debug?.overlay;
|
|
67
72
|
if (overlay !== void 0 && !overlayStarts().has(overlay)) throw new Error(`[game] config.ts: debug.overlay must be "closed", "pill" or "open", got "${String(overlay)}".`);
|
|
73
|
+
const image = config.page.boot?.image;
|
|
74
|
+
if (config.page.boot !== void 0 && (typeof image !== "string" || image === "")) throw new Error("[game] config.page.boot has no image.\n Name a picture file of the game in page.boot.image.");
|
|
75
|
+
const fadeMs = config.page.boot?.fadeMs;
|
|
76
|
+
if (fadeMs !== void 0 && !(Number.isFinite(fadeMs) && fadeMs >= 0)) throw new Error(`[game] config.page.boot.fadeMs is ${String(fadeMs)}.\n Use a number of milliseconds, 0 or more.`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Fills the defaults of `page.boot`: the width `"40vmin"`, the fade 300 ms.
|
|
80
|
+
*
|
|
81
|
+
* @param boot - `page.boot` of the config.
|
|
82
|
+
* @returns The boot with every field set.
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* resolveBoot({ image: "assets/boot.png", fadeMs: 0 }); // { image: "assets/boot.png", width: "40vmin", fadeMs: 0 }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
function resolveBoot(boot) {
|
|
89
|
+
return {
|
|
90
|
+
image: boot.image,
|
|
91
|
+
width: boot.width ?? BOOT_WIDTH,
|
|
92
|
+
fadeMs: boot.fadeMs ?? BOOT_FADE_MS
|
|
93
|
+
};
|
|
68
94
|
}
|
|
69
95
|
/**
|
|
70
96
|
* Fills every default of a game's `config.ts`: `lang` `"en"`, `background` `"#000000"`,
|
|
71
97
|
* `orientation` `"portrait"`, no icons, no head tags, no system plugin, the memory save, no asset
|
|
72
|
-
* layers, the overlay of a debug page closed at its start.
|
|
98
|
+
* layers, the overlay of a debug page closed at its start. A `page.boot` gets the width
|
|
99
|
+
* `"40vmin"` and the fade 300 ms; without one the page has no `boot` key.
|
|
73
100
|
*
|
|
74
101
|
* @param config - The default export of `config.ts`.
|
|
75
102
|
* @returns The config with every field set.
|
|
76
|
-
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
77
|
-
* `debug.overlay` is not a start mode.
|
|
103
|
+
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
104
|
+
* `debug.overlay` is not a start mode, `page.boot` has no image, or `page.boot.fadeMs` is not a finite number of 0
|
|
105
|
+
* or more.
|
|
78
106
|
* @example
|
|
79
107
|
* ```ts
|
|
80
108
|
* resolveConfig({ page: { title: "T" } }).save; // "memory"
|
|
@@ -89,7 +117,8 @@ function resolveConfig(config) {
|
|
|
89
117
|
background: config.page.background ?? "#000000",
|
|
90
118
|
orientation: config.page.orientation ?? "portrait",
|
|
91
119
|
icons: config.page.icons ?? {},
|
|
92
|
-
head: config.page.head ?? []
|
|
120
|
+
head: config.page.head ?? [],
|
|
121
|
+
...config.page.boot === void 0 ? {} : { boot: resolveBoot(config.page.boot) }
|
|
93
122
|
},
|
|
94
123
|
native: config.native,
|
|
95
124
|
system: config.system ?? [],
|
package/dist/control.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as HeadlessApp } from "./headless-7IBMNGda.mjs";
|
|
2
2
|
import { i as InputArguments, n as Command, o as InputSchema, s as Ran } from "./types-BEW2Y3au.mjs";
|
|
3
|
-
import { t as commands } from "./commands-
|
|
3
|
+
import { t as commands } from "./commands-OYwZDclg.mjs";
|
|
4
4
|
import { t as defineCommand } from "./define-U9QpSza7.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/plugins/flow/doors/dev.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as sfx, $t as flowPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as worldPlugin, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as DEMAND_REASONS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as type, at as use, b as types_exports$17, bt as Traced, c as hint, cn as lifecyclePlugin, ct as Draggable, d as defineScene, dt as Hovered, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as to, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as timePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as exit, nt as stagger, o as defineEffect, on as modelPlugin, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as slot, rt as stopSfx, s as guide, sn as SaveUnreadableError, st as inputPlugin, t as createApp, tn as contribution, tt as spawned, u as projection, un as clockPlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-
|
|
1
|
+
import { $ as sfx, $t as flowPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as worldPlugin, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as DEMAND_REASONS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as type, at as use, b as types_exports$17, bt as Traced, c as hint, cn as lifecyclePlugin, ct as Draggable, d as defineScene, dt as Hovered, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as to, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as timePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as exit, nt as stagger, o as defineEffect, on as modelPlugin, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as slot, rt as stopSfx, s as guide, sn as SaveUnreadableError, st as inputPlugin, t as createApp, tn as contribution, tt as spawned, u as projection, un as clockPlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-BIiNB7Fz.mjs";
|
|
2
2
|
import { $ as Tree, B as Overlay, C as bind, E as label, G as Transform, H as Parent, J as sprite, L as Display, Q as Order, R as HudPart, S as Text, T as defineTextStyles, U as Shape, W as Sprite, X as Layer, Y as Exiting, Z as Now, _ as popup, at as tag, b as defineStyle, c as Box, et as component, f as LocalWrite, m as ScrollState, nt as resource, rt as system, tt as mut, u as DebugTrigger, x as Countdown, y as defineTokens, z as NineSlice } from "./visual-ciZa6Rza.mjs";
|
|
3
3
|
import { t as defineComponent } from "./component-DGg5DqKK.mjs";
|
|
4
4
|
export { Alpha, types_exports as Anim, AnimPlayer, Animation, types_exports$1 as Assets, types_exports$2 as Audio, Blur, Box, types_exports$3 as Clock, ColorMatrix, Countdown, DEMAND_REASONS, types_exports$4 as Debug, DebugTrigger, Displacement, Display, Draggable, DropTarget, types_exports$5 as Effects, Emitter, Exiting, types_exports$6 as Flow, Frames, Glow, HAPTIC_KINDS, Held, Hovered, HudPart, types_exports$7 as I18n, types_exports$8 as Input, Layer, types_exports$9 as Lifecycle, LocalWrite, MONITOR_SECTIONS, types_exports$10 as Model, NineSlice, Noise, Now, Order, Outline, Overlay, PASS_KINDS, PERF_CAUSES, PERF_GAP_BUCKETS, PERF_LOG_VERSION, PROBLEM_RULES, Parent, types_exports$11 as Platform, Pointer, PointerOver, Pressable, Pressed, types_exports$12 as Renderer, SHADER_WHATS, SaveUnreadableError, types_exports$13 as Scenes, ScrollState, Shape, Sprite, Swipeable, Tappable, Text, types_exports$14 as TextTypes, types_exports$15 as Time, Touchable, Traceable, Traced, Transform, Tree, types_exports$16 as Ui, types_exports$17 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, contribution, createApp, createPlugin, cubicBezier, debugPlugin, defineAnimation, defineBundles, defineComponent, defineEffect, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextStyles, defineTokens, effectsPlugin, exit, external, flattenFeatures, flowPlugin, frameAt, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, messageArgument, messageDuration, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, ready, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, stopSfx, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
|
package/dist/inspect.d.mts
CHANGED
|
@@ -18395,13 +18395,16 @@ function topDrawn(sync, view) {
|
|
|
18395
18395
|
return !(hiddenBy(view, "empty") && view.wrapper === void 0);
|
|
18396
18396
|
}
|
|
18397
18397
|
/**
|
|
18398
|
-
* Tells whether an ancestor draws what is under it
|
|
18398
|
+
* Tells whether an ancestor draws what is under it as a picture would: visible, untinted, blending normally. Its alpha
|
|
18399
|
+
* is not read (F113): the quad hangs in the top's parent and Pixi multiplies it by the ancestors' alpha, while stage 1
|
|
18400
|
+
* renders the top as a root without them. A fading ancestor so draws the picture at `A·F(x)`, live draws `F(A·x)`: the
|
|
18401
|
+
* same for an alpha-linear filter, the whole picture faded for one that is not.
|
|
18399
18402
|
*
|
|
18400
18403
|
* @param node - The ancestor.
|
|
18401
18404
|
* @returns True when it does.
|
|
18402
18405
|
*/
|
|
18403
18406
|
function drawsPlain(node) {
|
|
18404
|
-
return node.visible && node.
|
|
18407
|
+
return node.visible && node.tint === WHITE$2 && plainBlend(node.blendMode);
|
|
18405
18408
|
}
|
|
18406
18409
|
/**
|
|
18407
18410
|
* Tells whether an ancestor is drawn: renderable, or hidden only by an overlay's range or a kept ancestor's picture,
|
|
@@ -18427,8 +18430,8 @@ function filtersPlaced(kctx, record, node) {
|
|
|
18427
18430
|
return record.category === "placed" && (holdsFilters(node) || kctx.state.byTop.get(node)?.mode === "kept");
|
|
18428
18431
|
}
|
|
18429
18432
|
/**
|
|
18430
|
-
* Tells whether every ancestor up to the stage draws the view as a picture would: visible,
|
|
18431
|
-
* normally, drawn (an overlay's range and a kept ancestor's picture count), and for a placed filter without a filter
|
|
18433
|
+
* Tells whether every ancestor up to the stage draws the view as a picture would: visible, untinted (its alpha is not
|
|
18434
|
+
* read, F113), blending normally, drawn (an overlay's range and a kept ancestor's picture count), and for a placed filter without a filter
|
|
18432
18435
|
* above it (its canvas position would not be the canvas pixel live).
|
|
18433
18436
|
*
|
|
18434
18437
|
* @param kctx - The kept context.
|
|
@@ -18763,7 +18766,8 @@ function writeTakeKeys(record, now, box) {
|
|
|
18763
18766
|
* Takes or retakes the picture of a record: stages 1, 2 (when its first filter has inputs) and 3, at the phase of this
|
|
18764
18767
|
* frame. The bounds are cut to the filter area of the top when it holds one (F43). Refused, and the view drawn live,
|
|
18765
18768
|
* for a `Display` in the subtree without `onDemand`, a node under the top that blends otherwise (F68, warned once per
|
|
18766
|
-
* top), empty bounds, a picture over 4096 device pixels,
|
|
18769
|
+
* top), empty bounds, a picture over 4096 device pixels, a picture cut to the canvas while its linear part moves (it
|
|
18770
|
+
* is never drawn scaled, F113), or a budget that has no room (P6.3, warned once).
|
|
18767
18771
|
*
|
|
18768
18772
|
* @param kctx - The kept context.
|
|
18769
18773
|
* @param pixi - The module that draws.
|
|
@@ -18771,9 +18775,10 @@ function writeTakeKeys(record, now, box) {
|
|
|
18771
18775
|
* @param record - The record.
|
|
18772
18776
|
* @param view - Its view.
|
|
18773
18777
|
* @param now - This frame's numbers.
|
|
18778
|
+
* @param turned - True when the linear part moved since the last frame: a first take under a zoom.
|
|
18774
18779
|
* @returns True when every stage rendered.
|
|
18775
18780
|
*/
|
|
18776
|
-
function takePicture(kctx, pixi, matrices, record, view, now) {
|
|
18781
|
+
function takePicture(kctx, pixi, matrices, record, view, now, turned = false) {
|
|
18777
18782
|
const { top } = record;
|
|
18778
18783
|
if (!kctx.ctx.config.onDemand && holdsDisplay(kctx, top)) return false;
|
|
18779
18784
|
if (blendedBelow(kctx, record)) return false;
|
|
@@ -18789,6 +18794,11 @@ function takePicture(kctx, pixi, matrices, record, view, now) {
|
|
|
18789
18794
|
const across = cutSpan(now.tx + box.x0, now.tx + box.x1, width, Ps);
|
|
18790
18795
|
const down = cutSpan(now.ty + box.y0, now.ty + box.y1, height, Ps);
|
|
18791
18796
|
if (isEmptySpan(across) || isEmptySpan(down)) return false;
|
|
18797
|
+
const cut = across.start > now.tx + box.x0 || across.end < now.tx + box.x1 || down.start > now.ty + box.y0 || down.end < now.ty + box.y1;
|
|
18798
|
+
if (cut && turned) {
|
|
18799
|
+
record.cut = true;
|
|
18800
|
+
return false;
|
|
18801
|
+
}
|
|
18792
18802
|
const x = gridSpan(across.start, across.end, now.rs);
|
|
18793
18803
|
const y = gridSpan(down.start, down.end, now.rs);
|
|
18794
18804
|
const w1 = x.texels / now.rs;
|
|
@@ -18805,9 +18815,7 @@ function takePicture(kctx, pixi, matrices, record, view, now) {
|
|
|
18805
18815
|
return false;
|
|
18806
18816
|
}
|
|
18807
18817
|
record.refused = 0;
|
|
18808
|
-
|
|
18809
|
-
const cutDown = down.start > now.ty + box.y0 || down.end < now.ty + box.y1;
|
|
18810
|
-
record.cut = cutAcross || cutDown;
|
|
18818
|
+
record.cut = cut;
|
|
18811
18819
|
record.key[KEY.sw] = width;
|
|
18812
18820
|
record.key[KEY.sh] = height;
|
|
18813
18821
|
writeTakeKeys(record, now, {
|
|
@@ -19115,9 +19123,21 @@ function wrapBare(kctx, record, view) {
|
|
|
19115
19123
|
writeSeen(record, NOW);
|
|
19116
19124
|
}
|
|
19117
19125
|
/**
|
|
19118
|
-
*
|
|
19119
|
-
*
|
|
19120
|
-
*
|
|
19126
|
+
* Tells whether a move of a live record's linear part or stack resolution resets its still frames (F113): a zoom or a
|
|
19127
|
+
* turn of an ancestor does not, the picture is taken at it and drawn scaled (F67). It does for a new stack resolution,
|
|
19128
|
+
* a `"placed"` record (never drawn scaled), a calm one (a picture that churned waits for real rest) and one cut to the
|
|
19129
|
+
* canvas at its last take or refusal (never drawn scaled either).
|
|
19130
|
+
*
|
|
19131
|
+
* @param record - The record, live, whose linear part or stack resolution moved since the last frame.
|
|
19132
|
+
* @returns True when the move resets its still frames.
|
|
19133
|
+
*/
|
|
19134
|
+
function linearResets(record) {
|
|
19135
|
+
return record.key[KEY.seenRs] !== NOW.rs || record.category === "placed" || record.calm || record.cut;
|
|
19136
|
+
}
|
|
19137
|
+
/**
|
|
19138
|
+
* A live record's frame (P4.2): still frames are counted, and a zoom or turn of an ancestor counts as still (F113); at
|
|
19139
|
+
* two (eight after churning) the record is taken, a bare view in a wrapper of its own (D4). A record with a node under
|
|
19140
|
+
* its top that blends otherwise stays live, before any wrap (F68).
|
|
19121
19141
|
*
|
|
19122
19142
|
* @param kctx - The kept context.
|
|
19123
19143
|
* @param pixi - The module that draws.
|
|
@@ -19127,14 +19147,15 @@ function wrapBare(kctx, record, view) {
|
|
|
19127
19147
|
*/
|
|
19128
19148
|
function stepLive(kctx, pixi, matrices, record, view) {
|
|
19129
19149
|
const { state } = kctx;
|
|
19130
|
-
const
|
|
19150
|
+
const turned = linearDiffers(record.key, NOW, KEY.seenA, KEY.seenRs);
|
|
19151
|
+
const changed = record.dirtyS1 || turned && linearResets(record);
|
|
19131
19152
|
writeSeen(record, NOW);
|
|
19132
19153
|
record.still = changed ? 0 : record.still + 1;
|
|
19133
19154
|
if (record.still < (record.calm ? 8 : 2)) return;
|
|
19134
19155
|
if (record.refused > 0 && state.bytes + record.refused - record.bytes > state.budget) return;
|
|
19135
19156
|
if (blendedBelow(kctx, record)) return;
|
|
19136
19157
|
wrapBare(kctx, record, view);
|
|
19137
|
-
if (takePicture(kctx, pixi, matrices, record, view, NOW)) toKept(kctx, record, view);
|
|
19158
|
+
if (takePicture(kctx, pixi, matrices, record, view, NOW, turned)) toKept(kctx, record, view);
|
|
19138
19159
|
else record.still = 0;
|
|
19139
19160
|
}
|
|
19140
19161
|
/**
|
|
@@ -19446,6 +19467,17 @@ function offGrid(kctx, record) {
|
|
|
19446
19467
|
return world.a !== key[KEY.a] || world.b !== key[KEY.b] || world.c !== key[KEY.c] || world.d !== key[KEY.d] || !onGrid(world.tx - (key[KEY.tx] ?? 0), rs, r) || !onGrid(world.ty - (key[KEY.ty] ?? 0), rs, r);
|
|
19447
19468
|
}
|
|
19448
19469
|
/**
|
|
19470
|
+
* Tells whether a kept record hangs under a translucent ancestor (F113): its quad draws `A·F(x)` where live draws
|
|
19471
|
+
* `F(A·x)`, which differ by design for a filter that is not alpha-linear, not by a stale picture.
|
|
19472
|
+
*
|
|
19473
|
+
* @param record - The record, kept.
|
|
19474
|
+
* @returns True when an ancestor's alpha is under 1.
|
|
19475
|
+
*/
|
|
19476
|
+
function fadedAbove(record) {
|
|
19477
|
+
for (let node = record.top.parent; node !== null; node = node.parent) if (node.alpha < 1) return true;
|
|
19478
|
+
return false;
|
|
19479
|
+
}
|
|
19480
|
+
/**
|
|
19449
19481
|
* Tells whether the padded picture of a kept record reaches past the canvas edge, where Pixi clips the live filter.
|
|
19450
19482
|
*
|
|
19451
19483
|
* @param record - The record, kept.
|
|
@@ -19534,7 +19566,8 @@ function logStale(kctx, pixels, records, ranges) {
|
|
|
19534
19566
|
}
|
|
19535
19567
|
/**
|
|
19536
19568
|
* The pixel leg after a drawn frame: the picture as drawn against the same frame with every picture live. Frames in
|
|
19537
|
-
* which a picture moves off its grid are skipped and counted; at rest
|
|
19569
|
+
* which a picture moves off its grid or hangs under a translucent ancestor (F113) are skipped and counted; at rest
|
|
19570
|
+
* under opaque ancestors every picture is compared.
|
|
19538
19571
|
*
|
|
19539
19572
|
* @param kctx - The kept context.
|
|
19540
19573
|
* @param bypass - Draws every kept record live (true) or as its picture again (false).
|
|
@@ -19545,7 +19578,7 @@ function verifyPictures(kctx, bypass, recover) {
|
|
|
19545
19578
|
const records = shownRecords(kctx);
|
|
19546
19579
|
const ranges = [...state.ranges.values()].filter((range) => range.sprite !== void 0);
|
|
19547
19580
|
if (records.length === 0 && ranges.length === 0) return;
|
|
19548
|
-
if (records.some((record) => offGrid(kctx, record))) {
|
|
19581
|
+
if (records.some((record) => offGrid(kctx, record) || fadedAbove(record))) {
|
|
19549
19582
|
state.verifySkipped += 1;
|
|
19550
19583
|
return;
|
|
19551
19584
|
}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ar as Json, Dn as NodeTable, Fn as Hint, In as NodeFx, Sr as ClockSource, jn as Descriptor, wr as FakeClock, xn as AnyFlow, yn as FeaturePlugin } from "./types-C6PML3Il.mjs";
|
|
2
2
|
import { t as createApp } from "./index-m2g9-8_E.mjs";
|
|
3
|
-
import { b as saveOf, v as WithGameState, y as memory } from "./types-
|
|
3
|
+
import { b as saveOf, v as WithGameState, y as memory } from "./types-CuFoPhWD.mjs";
|
|
4
4
|
import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-7IBMNGda.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
package/dist/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { an as type, en as refuseStart, m as flattenFeatures, nn as exit, t as createApp } from "./src-
|
|
1
|
+
import { an as type, en as refuseStart, m as flattenFeatures, nn as exit, t as createApp } from "./src-BIiNB7Fz.mjs";
|
|
2
2
|
import { n as saveOf, t as memory } from "./memory-CWlqhS7l.mjs";
|
|
3
3
|
import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
|
|
4
4
|
import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";
|
|
@@ -81,7 +81,7 @@ type SaveKind = "memory" | "local" | "store";
|
|
|
81
81
|
* // config.ts of a game
|
|
82
82
|
* import type { GameConfig } from "@moku-labs/game/app";
|
|
83
83
|
* export default {
|
|
84
|
-
* page: { title: "Лесной городок", lang: "ru", background: "#10161d", orientation: "portrait", icons: { favicon: "assets/icon.png" } },
|
|
84
|
+
* page: { title: "Лесной городок", lang: "ru", background: "#10161d", orientation: "portrait", icons: { favicon: "assets/icon.png" }, boot: { image: "assets/boot.png" } },
|
|
85
85
|
* native: { name: "Лесной городок", identifier: "com.mokulabs.timber", icon: "assets/icon.png" },
|
|
86
86
|
* system: ["lifecycle", "back", "haptics", "keepAwake"],
|
|
87
87
|
* save: "memory",
|
|
@@ -100,6 +100,26 @@ type GameConfig = {
|
|
|
100
100
|
appleTouch?: string;
|
|
101
101
|
}; /** Raw tags written into `<head>`, verbatim, in order. None by default. */
|
|
102
102
|
head?: readonly string[];
|
|
103
|
+
/**
|
|
104
|
+
* The boot picture: an `<img>` centred over the canvas from the first paint, faded out after
|
|
105
|
+
* the first scene drew, then removed. Absent by default: the page shows only `background`
|
|
106
|
+
* until the first scene. `image` is a file relative to the game folder, never absolute, never
|
|
107
|
+
* `..`; `width` is its CSS width, default `"40vmin"`; `fadeMs` the fade, default `300`, `0`
|
|
108
|
+
* removes the picture in that frame.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* // config.ts of A Memory Missing: the logo from the icon tap to the splash scene's first frame.
|
|
113
|
+
* export default {
|
|
114
|
+
* page: { title: "A Memory Missing", background: "#F4E6CA", boot: { image: "assets/boot.png", width: "52vmin" } }
|
|
115
|
+
* } satisfies GameConfig; // the logo fades over 300 ms, the default
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
boot?: {
|
|
119
|
+
image: string;
|
|
120
|
+
width?: string;
|
|
121
|
+
fadeMs?: number;
|
|
122
|
+
};
|
|
103
123
|
}; /** The native app. Left out, the game has no native build. */
|
|
104
124
|
native?: {
|
|
105
125
|
/** The app name under the icon. */name: string; /** The bundle identifier, reverse DNS. */
|
|
@@ -120,6 +140,19 @@ type GameConfig = {
|
|
|
120
140
|
overlay?: OverlayStart;
|
|
121
141
|
};
|
|
122
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* `page.boot` of `config.ts` with every default filled, as `resolveConfig` returns it.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* resolveConfig({ page: { title: "T", boot: { image: "assets/boot.png" } } }).page.boot; // { image: "assets/boot.png", width: "40vmin", fadeMs: 300 }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
type ResolvedPageBoot = {
|
|
152
|
+
/** The picture file, relative to the game folder. */image: string; /** The CSS width of the picture. */
|
|
153
|
+
width: string; /** The fade-out after the first scene drew, ms. */
|
|
154
|
+
fadeMs: number;
|
|
155
|
+
};
|
|
123
156
|
/**
|
|
124
157
|
* How the editor's overlay shows when a debug page starts, `config.ts` `debug.overlay`.
|
|
125
158
|
*
|
|
@@ -132,7 +165,8 @@ type GameConfig = {
|
|
|
132
165
|
type OverlayStart = "closed" | "pill" | "open";
|
|
133
166
|
/**
|
|
134
167
|
* `GameConfig` with every default filled, as `resolveConfig` returns it. The page, the CLI and the
|
|
135
|
-
* shell read this one, never the raw config.
|
|
168
|
+
* shell read this one, never the raw config. `page.boot` is the one key left out when the game
|
|
169
|
+
* names no boot picture.
|
|
136
170
|
*
|
|
137
171
|
* @example
|
|
138
172
|
* ```ts
|
|
@@ -140,10 +174,13 @@ type OverlayStart = "closed" | "pill" | "open";
|
|
|
140
174
|
* page: { title: "mini-game", lang: "en", background: "#000000", orientation: "portrait", icons: {}, head: [] },
|
|
141
175
|
* native: undefined, system: [], save: "memory", assets: { layers: {} }, debug: { overlay: "closed" }
|
|
142
176
|
* };
|
|
177
|
+
* settings.page.boot; // undefined: no boot picture, the page as before
|
|
143
178
|
* ```
|
|
144
179
|
*/
|
|
145
180
|
type ResolvedGameConfig = {
|
|
146
|
-
/** The page, every field set. */page: Required<GameConfig["page"]
|
|
181
|
+
/** The page, every field set; `boot` only when the game names a boot picture. */page: Required<Omit<GameConfig["page"], "boot">> & {
|
|
182
|
+
boot?: ResolvedPageBoot;
|
|
183
|
+
}; /** The native app, or `undefined` for a game with no native build. */
|
|
147
184
|
native: GameConfig["native"]; /** The system plugins the shell wires. */
|
|
148
185
|
system: readonly SystemName[]; /** Where the save lives. */
|
|
149
186
|
save: SaveKind; /** The asset build. */
|
|
@@ -3,7 +3,7 @@ import { P as AnimApi, r as UiApi } from "./types-C0As3dEe.mjs";
|
|
|
3
3
|
import { N as InputApi } from "./types-FtzEwwWY.mjs";
|
|
4
4
|
import { r as Repro } from "./headless-7IBMNGda.mjs";
|
|
5
5
|
import { a as InputOf, r as ControlApp } from "./types-BEW2Y3au.mjs";
|
|
6
|
-
import { t as commands } from "./commands-
|
|
6
|
+
import { t as commands } from "./commands-OYwZDclg.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/visual/types.d.ts
|
|
9
9
|
/** The base commands of the `/control` door, keyed by their short names. */
|
package/dist/visual.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-
|
|
1
|
+
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-mPbBWlEz.mjs";
|
|
2
2
|
export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
|
package/llms.txt
CHANGED
|
@@ -302,7 +302,7 @@ app.model.store.snapshot().session; // { rolls: 2 }
|
|
|
302
302
|
await run.stop();
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `native: { name, identifier, icon?, targets? }` (absent: no native build), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
305
|
+
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets? }` (absent: no native build), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
308
|
// config.ts of a game in a native shell
|