js-game-zero 0.0.0-stage → 0.4.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/LICENSE +22 -0
- package/README.md +138 -2
- package/dist/active-service.d.ts +21 -0
- package/dist/actor.d.ts +182 -0
- package/dist/animation.d.ts +61 -0
- package/dist/assets.d.ts +148 -0
- package/dist/audio.d.ts +150 -0
- package/dist/browser-asset-backends.d.ts +8 -0
- package/dist/browser.d.ts +10 -0
- package/dist/chunk-q9m20c2h.js +7972 -0
- package/dist/clock.d.ts +29 -0
- package/dist/color.d.ts +15 -0
- package/dist/events.d.ts +145 -0
- package/dist/friendly-names.d.ts +43 -0
- package/dist/geometry.d.ts +125 -0
- package/dist/helpers.d.ts +28 -0
- package/dist/host.d.ts +58 -0
- package/dist/host.js +435 -0
- package/dist/index.d.ts +340 -0
- package/dist/index.js +258 -0
- package/dist/input.d.ts +200 -0
- package/dist/inspection.d.ts +58 -0
- package/dist/jgz.js +8545 -0
- package/dist/node.d.ts +14 -0
- package/dist/node.js +145 -0
- package/dist/pixel-density.d.ts +23 -0
- package/dist/random.d.ts +31 -0
- package/dist/reference/actor.md +197 -0
- package/dist/reference/audio.md +128 -0
- package/dist/reference/clock.md +150 -0
- package/dist/reference/helpers.md +46 -0
- package/dist/reference/hooks.md +379 -0
- package/dist/reference/index.d.ts +2 -0
- package/dist/reference/index.js +39 -0
- package/dist/reference/loaders.md +164 -0
- package/dist/reference/rect.md +129 -0
- package/dist/reference/runtime.md +478 -0
- package/dist/reference/screen.md +392 -0
- package/dist/reference/storage.md +90 -0
- package/dist/rendering.d.ts +216 -0
- package/dist/runtime-contracts.d.ts +117 -0
- package/dist/runtime-diagnostics.d.ts +37 -0
- package/dist/runtime-persistence.d.ts +32 -0
- package/dist/runtime-source.d.ts +82 -0
- package/dist/runtime.d.ts +81 -0
- package/dist/source-scan.d.ts +49 -0
- package/dist/storage-path.d.ts +3 -0
- package/dist/storage.d.ts +88 -0
- package/dist/tone.d.ts +81 -0
- package/dist/touch-controls.d.ts +24 -0
- package/dist/touch-pointer.d.ts +11 -0
- package/dist/util.d.ts +62 -0
- package/package.json +69 -4
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export declare const keys: Readonly<{
|
|
2
|
+
ENTER: 13;
|
|
3
|
+
BACKSPACE: 8;
|
|
4
|
+
TAB: 9;
|
|
5
|
+
CLEAR: 12;
|
|
6
|
+
RETURN: 13;
|
|
7
|
+
PAUSE: 19;
|
|
8
|
+
ESCAPE: 27;
|
|
9
|
+
SPACE: 32;
|
|
10
|
+
EXCLAIM: 33;
|
|
11
|
+
QUOTEDBL: 34;
|
|
12
|
+
HASH: 35;
|
|
13
|
+
DOLLAR: 36;
|
|
14
|
+
AMPERSAND: 38;
|
|
15
|
+
QUOTE: 39;
|
|
16
|
+
LEFTPAREN: 40;
|
|
17
|
+
RIGHTPAREN: 41;
|
|
18
|
+
ASTERISK: 42;
|
|
19
|
+
PLUS: 43;
|
|
20
|
+
COMMA: 44;
|
|
21
|
+
MINUS: 45;
|
|
22
|
+
PERIOD: 46;
|
|
23
|
+
SLASH: 47;
|
|
24
|
+
K_0: 48;
|
|
25
|
+
K_1: 49;
|
|
26
|
+
K_2: 50;
|
|
27
|
+
K_3: 51;
|
|
28
|
+
K_4: 52;
|
|
29
|
+
K_5: 53;
|
|
30
|
+
K_6: 54;
|
|
31
|
+
K_7: 55;
|
|
32
|
+
K_8: 56;
|
|
33
|
+
K_9: 57;
|
|
34
|
+
COLON: 58;
|
|
35
|
+
SEMICOLON: 59;
|
|
36
|
+
LESS: 60;
|
|
37
|
+
EQUALS: 61;
|
|
38
|
+
GREATER: 62;
|
|
39
|
+
QUESTION: 63;
|
|
40
|
+
AT: 64;
|
|
41
|
+
LEFTBRACKET: 91;
|
|
42
|
+
BACKSLASH: 92;
|
|
43
|
+
RIGHTBRACKET: 93;
|
|
44
|
+
CARET: 94;
|
|
45
|
+
UNDERSCORE: 95;
|
|
46
|
+
BACKQUOTE: 96;
|
|
47
|
+
A: 97;
|
|
48
|
+
B: 98;
|
|
49
|
+
C: 99;
|
|
50
|
+
D: 100;
|
|
51
|
+
E: 101;
|
|
52
|
+
F: 102;
|
|
53
|
+
G: 103;
|
|
54
|
+
H: 104;
|
|
55
|
+
I: 105;
|
|
56
|
+
J: 106;
|
|
57
|
+
K: 107;
|
|
58
|
+
L: 108;
|
|
59
|
+
M: 109;
|
|
60
|
+
N: 110;
|
|
61
|
+
O: 111;
|
|
62
|
+
P: 112;
|
|
63
|
+
Q: 113;
|
|
64
|
+
R: 114;
|
|
65
|
+
S: 115;
|
|
66
|
+
T: 116;
|
|
67
|
+
U: 117;
|
|
68
|
+
V: 118;
|
|
69
|
+
W: 119;
|
|
70
|
+
X: 120;
|
|
71
|
+
Y: 121;
|
|
72
|
+
Z: 122;
|
|
73
|
+
DELETE: 127;
|
|
74
|
+
KP0: 1073741922;
|
|
75
|
+
KP1: 1073741913;
|
|
76
|
+
KP2: 1073741914;
|
|
77
|
+
KP3: 1073741915;
|
|
78
|
+
KP4: 1073741916;
|
|
79
|
+
KP5: 1073741917;
|
|
80
|
+
KP6: 1073741918;
|
|
81
|
+
KP7: 1073741919;
|
|
82
|
+
KP8: 1073741920;
|
|
83
|
+
KP9: 1073741921;
|
|
84
|
+
KP_PERIOD: 1073741923;
|
|
85
|
+
KP_DIVIDE: 1073741908;
|
|
86
|
+
KP_MULTIPLY: 1073741909;
|
|
87
|
+
KP_MINUS: 1073741910;
|
|
88
|
+
KP_PLUS: 1073741911;
|
|
89
|
+
KP_ENTER: 1073741912;
|
|
90
|
+
KP_EQUALS: 1073741927;
|
|
91
|
+
UP: 1073741906;
|
|
92
|
+
DOWN: 1073741905;
|
|
93
|
+
RIGHT: 1073741903;
|
|
94
|
+
LEFT: 1073741904;
|
|
95
|
+
INSERT: 1073741897;
|
|
96
|
+
HOME: 1073741898;
|
|
97
|
+
END: 1073741901;
|
|
98
|
+
PAGEUP: 1073741899;
|
|
99
|
+
PAGEDOWN: 1073741902;
|
|
100
|
+
F1: 1073741882;
|
|
101
|
+
F2: 1073741883;
|
|
102
|
+
F3: 1073741884;
|
|
103
|
+
F4: 1073741885;
|
|
104
|
+
F5: 1073741886;
|
|
105
|
+
F6: 1073741887;
|
|
106
|
+
F7: 1073741888;
|
|
107
|
+
F8: 1073741889;
|
|
108
|
+
F9: 1073741890;
|
|
109
|
+
F10: 1073741891;
|
|
110
|
+
F11: 1073741892;
|
|
111
|
+
F12: 1073741893;
|
|
112
|
+
F13: 1073741928;
|
|
113
|
+
F14: 1073741929;
|
|
114
|
+
F15: 1073741930;
|
|
115
|
+
NUMLOCK: 1073741907;
|
|
116
|
+
CAPSLOCK: 1073741881;
|
|
117
|
+
SCROLLOCK: 1073741895;
|
|
118
|
+
RSHIFT: 1073742053;
|
|
119
|
+
LSHIFT: 1073742049;
|
|
120
|
+
RCTRL: 1073742052;
|
|
121
|
+
LCTRL: 1073742048;
|
|
122
|
+
RALT: 1073742054;
|
|
123
|
+
LALT: 1073742050;
|
|
124
|
+
RMETA: 1073742055;
|
|
125
|
+
LMETA: 1073742051;
|
|
126
|
+
LSUPER: 1073742051;
|
|
127
|
+
RSUPER: 1073742055;
|
|
128
|
+
MODE: 1073742081;
|
|
129
|
+
HELP: 1073741941;
|
|
130
|
+
PRINT: 1073741894;
|
|
131
|
+
SYSREQ: 1073741978;
|
|
132
|
+
BREAK: 1073741896;
|
|
133
|
+
MENU: 1073741942;
|
|
134
|
+
POWER: 1073741926;
|
|
135
|
+
EURO: 1073742004;
|
|
136
|
+
LAST: 1073742106;
|
|
137
|
+
}>;
|
|
138
|
+
export declare const keymods: Readonly<{
|
|
139
|
+
NONE: 0;
|
|
140
|
+
LSHIFT: 1;
|
|
141
|
+
RSHIFT: 2;
|
|
142
|
+
SHIFT: 3;
|
|
143
|
+
LCTRL: 64;
|
|
144
|
+
RCTRL: 128;
|
|
145
|
+
CTRL: 192;
|
|
146
|
+
LALT: 256;
|
|
147
|
+
RALT: 512;
|
|
148
|
+
ALT: 768;
|
|
149
|
+
LMETA: 1024;
|
|
150
|
+
RMETA: 2048;
|
|
151
|
+
META: 3072;
|
|
152
|
+
NUM: 4096;
|
|
153
|
+
CAPS: 8192;
|
|
154
|
+
MODE: 16384;
|
|
155
|
+
}>;
|
|
156
|
+
export declare const mouse: Readonly<{
|
|
157
|
+
LEFT: 1;
|
|
158
|
+
MIDDLE: 2;
|
|
159
|
+
RIGHT: 3;
|
|
160
|
+
WHEEL_UP: 4;
|
|
161
|
+
WHEEL_DOWN: 5;
|
|
162
|
+
}>;
|
|
163
|
+
/** Where the mouse (or a touch) last was over the canvas, and what's held. */
|
|
164
|
+
export declare class MouseState {
|
|
165
|
+
pos: readonly [number, number] | null;
|
|
166
|
+
buttons: ReadonlySet<number>;
|
|
167
|
+
clearButtons(): void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The `mouse` a game sees: the button constants, plus where the mouse is now
|
|
171
|
+
* and which buttons are held, for code in `update()` that follows or aims at
|
|
172
|
+
* the mouse. Before the mouse first moves over the game, `pos` is the center
|
|
173
|
+
* of the screen. `down` is true while any button or a finger is down, for
|
|
174
|
+
* code that acts as long as the learner holds on.
|
|
175
|
+
*/
|
|
176
|
+
export type LiveMouse = typeof mouse & {
|
|
177
|
+
readonly pos: [number, number];
|
|
178
|
+
readonly x: number;
|
|
179
|
+
readonly y: number;
|
|
180
|
+
readonly buttons: Set<number>;
|
|
181
|
+
readonly down: boolean;
|
|
182
|
+
};
|
|
183
|
+
export declare function createLiveMouse(state: MouseState, center: () => readonly [number, number]): LiveMouse;
|
|
184
|
+
export declare class KeyboardState {
|
|
185
|
+
[key: string]: unknown;
|
|
186
|
+
[key: number]: unknown;
|
|
187
|
+
readonly _pressed: Set<number>;
|
|
188
|
+
constructor();
|
|
189
|
+
press(key: number): void;
|
|
190
|
+
release(key: number): void;
|
|
191
|
+
clear(): void;
|
|
192
|
+
isPressed(key: number): boolean;
|
|
193
|
+
pressed(): number[];
|
|
194
|
+
}
|
|
195
|
+
export declare function setActiveKeyboard(nextKeyboard: KeyboardState | null): KeyboardState | null;
|
|
196
|
+
export declare function getActiveKeyboard(): KeyboardState;
|
|
197
|
+
export declare const keyboard: KeyboardState;
|
|
198
|
+
export declare function isKeyConstant(value: unknown): value is number;
|
|
199
|
+
export declare function assertKeyConstant(value: unknown): asserts value is number;
|
|
200
|
+
export declare function keyAttributeName(name: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { GameHandle } from "./runtime.js";
|
|
2
|
+
import { type Screen } from "./rendering.js";
|
|
3
|
+
import type { SourceInspector } from "./runtime-source.js";
|
|
4
|
+
/** A value as inspection reports it: JSON, with `$type` tags for the rest. */
|
|
5
|
+
export type JsonSafe = null | boolean | number | string | JsonSafe[] | {
|
|
6
|
+
readonly [key: string]: JsonSafe;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A game value as JSON: numbers, strings, booleans, arrays and plain objects
|
|
10
|
+
* as they are (objects with sorted keys); anything else tagged with `$type`,
|
|
11
|
+
* such as `{ $type: "Actor", x, y, … }`, `{ $type: "Undefined" }` or
|
|
12
|
+
* `{ $type: "Number", value: "NaN" }`. Deep, long or circular values are cut
|
|
13
|
+
* short with `{ $type: "Truncated" }` or `{ $type: "Circular" }`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serializeGameValue(value: unknown): JsonSafe;
|
|
16
|
+
/** A binding and the property names and indexes under it: `fish[0].y`. */
|
|
17
|
+
export type StatePath = {
|
|
18
|
+
readonly source: string;
|
|
19
|
+
readonly binding: string;
|
|
20
|
+
readonly segments: readonly (string | number)[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads a state path: a top-level binding, then `.name` for a property and
|
|
24
|
+
* `[n]` for an index, as in `player.x` or `fish[0].y`. Throws a TypeError for
|
|
25
|
+
* anything else, and for `__proto__`, `prototype` and `constructor`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseStatePath(source: string): StatePath;
|
|
28
|
+
/** Host access to a zero-boilerplate game's live top-level bindings. */
|
|
29
|
+
export type GameInspector = {
|
|
30
|
+
/** Non-function top-level declarations and assignments, in source order. */
|
|
31
|
+
bindings(): readonly string[];
|
|
32
|
+
/** Top-level function declarations and function-valued bindings. */
|
|
33
|
+
functions(): readonly string[];
|
|
34
|
+
/** The live value at a binding or a path (`score`, `fish[0].y`), as it is. */
|
|
35
|
+
read(path: string | StatePath): unknown;
|
|
36
|
+
/**
|
|
37
|
+
* The value at a path as JSON (`serializeGameValue`), as the CLI's `inspect`
|
|
38
|
+
* reports it; with no path, every binding's value by name.
|
|
39
|
+
*/
|
|
40
|
+
inspect(path?: string | StatePath): JsonSafe;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The name a path starts with to read what the game's last `draw()` drew,
|
|
44
|
+
* rather than one of its bindings: `$drawn`, a list of things, each with its
|
|
45
|
+
* `kind` and what it is and where (`{ kind: "actor", image: "robot", x, y }`).
|
|
46
|
+
*/
|
|
47
|
+
export declare const DRAWN = "$drawn";
|
|
48
|
+
/**
|
|
49
|
+
* The host inspector over a game's source bindings, and, given its screen,
|
|
50
|
+
* what it drew (`$drawn`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function createGameInspector(source: SourceInspector, screen?: Screen): GameInspector;
|
|
53
|
+
/**
|
|
54
|
+
* A live inspector for a running zero-boilerplate game, or null for an
|
|
55
|
+
* import-mode game and a stopped one (a failed game keeps its inspector, so a
|
|
56
|
+
* host can read the state at the crash).
|
|
57
|
+
*/
|
|
58
|
+
export declare function getGameInspector(handle: GameHandle): GameInspector | null;
|