@automataframework/shell 0.0.0-stage → 0.0.1-preview.18.sha-2a1944d
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 +21 -0
- package/dist/features/error/error.d.ts +5 -0
- package/dist/features/flow/flow.d.ts +37 -0
- package/dist/features/formats/formats.d.ts +193 -0
- package/dist/features/host/host.d.ts +77 -0
- package/dist/features/hud/read-path.d.ts +2 -0
- package/dist/features/remap/pad.d.ts +13 -0
- package/dist/features/remap/remap.d.ts +16 -0
- package/dist/features/saves-screen/saves-screen.d.ts +18 -0
- package/dist/features/settings/settings.d.ts +52 -0
- package/dist/features/start/start.d.ts +14 -0
- package/dist/features/theme/css.d.ts +11 -0
- package/dist/features/theme/default.d.ts +41 -0
- package/dist/features/touch-controls/layout.d.ts +21 -0
- package/dist/features/words/words.d.ts +16 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4985 -0
- package/messages/en.json +80 -0
- package/messages/es.json +80 -0
- package/package.json +51 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Automata Framework
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Screen } from '../formats/formats.ts';
|
|
2
|
+
/** The one screen the shell holds itself: what shows when the game's own code fails. Its words are the shell's. */
|
|
3
|
+
export declare const somethingWentWrong: Screen;
|
|
4
|
+
/** The built-in question the flow asks with `{ ask, yes }`: the question's word is the title, its `Body` the line under it. */
|
|
5
|
+
export declare function questionScreen(word: string, has: (name: string) => boolean): Screen;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Flow } from '../formats/formats.ts';
|
|
2
|
+
/** Where the player is: on a screen, playing, or being asked a question over either. */
|
|
3
|
+
export type Place = {
|
|
4
|
+
/** The flow's name for this state. */
|
|
5
|
+
at: string;
|
|
6
|
+
screen?: string | undefined;
|
|
7
|
+
hud?: string | undefined;
|
|
8
|
+
/** Set while a question is up: the word that asks it. */
|
|
9
|
+
asking?: string | undefined;
|
|
10
|
+
/** Milliseconds until `timeout` happens by itself, when this state says so. */
|
|
11
|
+
after?: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The flow file as a plain machine. An event moves the player from one state to the next by the state's `on`. `back`
|
|
15
|
+
* goes to where the player came from unless the state says otherwise. A target `{ ask, yes }` asks first: `ask-yes`
|
|
16
|
+
* goes on, `ask-no` (or `back`) stays. Built-in events are skip, timeout, new-game, continue, pause, resume, win,
|
|
17
|
+
* lose, retry and back; a flow may add its own.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createFlow(flow: Flow, options?: {
|
|
20
|
+
startPlaying?: boolean;
|
|
21
|
+
}): {
|
|
22
|
+
place: () => Place;
|
|
23
|
+
/** True when the event changed where the player is. */
|
|
24
|
+
send(event: string): boolean;
|
|
25
|
+
/** Goes straight to a named state, forgetting the way back. */
|
|
26
|
+
to(name: string): void;
|
|
27
|
+
/** Goes straight to the state that plays the game (a saved game being continued). */
|
|
28
|
+
play(): boolean;
|
|
29
|
+
/** True when the state handles this event. */
|
|
30
|
+
handles: (event: string) => boolean;
|
|
31
|
+
};
|
|
32
|
+
/** What is wrong with the flow's links to the other files, one plain sentence each. */
|
|
33
|
+
export declare function flowProblems(flow: Flow, screens: Set<string>, huds: Set<string>): {
|
|
34
|
+
name: string;
|
|
35
|
+
message: string;
|
|
36
|
+
fix: string;
|
|
37
|
+
}[];
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The settings a slider, steps or switch may change. Each is a key of `Settings`. */
|
|
3
|
+
export declare const settingNames: readonly ['language', 'master', 'music', 'effects', 'mute', 'textSize', 'contrast', 'motion', 'frameCounter'];
|
|
4
|
+
/** The `screen` content kind. Formats may change. */
|
|
5
|
+
export declare const screenSchema: z.ZodObject<{
|
|
6
|
+
format: z.ZodLiteral<1>;
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
kind: z.ZodLiteral<"screen">;
|
|
9
|
+
title: z.ZodOptional<z.ZodString>;
|
|
10
|
+
above: z.ZodOptional<z.ZodString>;
|
|
11
|
+
layout: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
card: "card";
|
|
13
|
+
panel: "panel";
|
|
14
|
+
splash: "splash";
|
|
15
|
+
}>>;
|
|
16
|
+
back: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
items: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"button">;
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
label: z.ZodString;
|
|
21
|
+
does: z.ZodString;
|
|
22
|
+
main: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
opens: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
shows: z.ZodOptional<z.ZodLiteral<"language">>;
|
|
25
|
+
when: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
"has-save": "has-save";
|
|
27
|
+
"no-save": "no-save";
|
|
28
|
+
}>>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"text">;
|
|
31
|
+
words: z.ZodString;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"image">;
|
|
34
|
+
asset: z.ZodString;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"slider">;
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
label: z.ZodString;
|
|
39
|
+
setting: z.ZodEnum<{
|
|
40
|
+
contrast: "contrast";
|
|
41
|
+
effects: "effects";
|
|
42
|
+
frameCounter: "frameCounter";
|
|
43
|
+
language: "language";
|
|
44
|
+
master: "master";
|
|
45
|
+
motion: "motion";
|
|
46
|
+
music: "music";
|
|
47
|
+
mute: "mute";
|
|
48
|
+
textSize: "textSize";
|
|
49
|
+
}>;
|
|
50
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
51
|
+
type: z.ZodLiteral<"steps">;
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
label: z.ZodString;
|
|
54
|
+
setting: z.ZodEnum<{
|
|
55
|
+
contrast: "contrast";
|
|
56
|
+
effects: "effects";
|
|
57
|
+
frameCounter: "frameCounter";
|
|
58
|
+
language: "language";
|
|
59
|
+
master: "master";
|
|
60
|
+
motion: "motion";
|
|
61
|
+
music: "music";
|
|
62
|
+
mute: "mute";
|
|
63
|
+
textSize: "textSize";
|
|
64
|
+
}>;
|
|
65
|
+
levels: z.ZodArray<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"switch">;
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
label: z.ZodString;
|
|
70
|
+
setting: z.ZodEnum<{
|
|
71
|
+
contrast: "contrast";
|
|
72
|
+
effects: "effects";
|
|
73
|
+
frameCounter: "frameCounter";
|
|
74
|
+
language: "language";
|
|
75
|
+
master: "master";
|
|
76
|
+
motion: "motion";
|
|
77
|
+
music: "music";
|
|
78
|
+
mute: "mute";
|
|
79
|
+
textSize: "textSize";
|
|
80
|
+
}>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
type: z.ZodLiteral<"list">;
|
|
83
|
+
from: z.ZodEnum<{
|
|
84
|
+
controls: "controls";
|
|
85
|
+
credits: "credits";
|
|
86
|
+
languages: "languages";
|
|
87
|
+
saves: "saves";
|
|
88
|
+
touch: "touch";
|
|
89
|
+
}>;
|
|
90
|
+
details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
shows: z.ZodString;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
94
|
+
}, z.core.$strip>], "type">>;
|
|
95
|
+
}, z.core.$loose>;
|
|
96
|
+
/** The `hud` content kind. Formats may change. */
|
|
97
|
+
export declare const hudSchema: z.ZodObject<{
|
|
98
|
+
format: z.ZodLiteral<1>;
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
kind: z.ZodLiteral<"hud">;
|
|
101
|
+
items: z.ZodArray<z.ZodObject<{
|
|
102
|
+
type: z.ZodEnum<{
|
|
103
|
+
bar: "bar";
|
|
104
|
+
icon: "icon";
|
|
105
|
+
text: "text";
|
|
106
|
+
}>;
|
|
107
|
+
shows: z.ZodString;
|
|
108
|
+
label: z.ZodString;
|
|
109
|
+
where: z.ZodEnum<{
|
|
110
|
+
bottom: "bottom";
|
|
111
|
+
"bottom-left": "bottom-left";
|
|
112
|
+
"bottom-right": "bottom-right";
|
|
113
|
+
top: "top";
|
|
114
|
+
"top-left": "top-left";
|
|
115
|
+
"top-right": "top-right";
|
|
116
|
+
}>;
|
|
117
|
+
player: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
}, z.core.$loose>;
|
|
120
|
+
/** The `flow` content kind. A state shows a screen, or plays the game and shows a HUD. Formats may change. */
|
|
121
|
+
export declare const flowSchema: z.ZodObject<{
|
|
122
|
+
format: z.ZodLiteral<1>;
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
kind: z.ZodLiteral<"flow">;
|
|
125
|
+
start: z.ZodString;
|
|
126
|
+
screens: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
127
|
+
screen: z.ZodOptional<z.ZodString>;
|
|
128
|
+
hud: z.ZodOptional<z.ZodString>;
|
|
129
|
+
after: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
on: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
131
|
+
ask: z.ZodString;
|
|
132
|
+
yes: z.ZodString;
|
|
133
|
+
}, z.core.$strip>]>>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
}, z.core.$loose>;
|
|
136
|
+
/** The `theme` content kind. Every key is optional: a missing one takes the shell's own look. Formats may change. */
|
|
137
|
+
export declare const themeSchema: z.ZodObject<{
|
|
138
|
+
format: z.ZodLiteral<1>;
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
kind: z.ZodLiteral<"theme">;
|
|
141
|
+
colours: z.ZodOptional<z.ZodObject<{
|
|
142
|
+
page: z.ZodOptional<z.ZodString>;
|
|
143
|
+
words: z.ZodOptional<z.ZodString>;
|
|
144
|
+
muted: z.ZodOptional<z.ZodString>;
|
|
145
|
+
button: z.ZodOptional<z.ZodString>;
|
|
146
|
+
buttonWords: z.ZodOptional<z.ZodString>;
|
|
147
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
148
|
+
primaryWords: z.ZodOptional<z.ZodString>;
|
|
149
|
+
line: z.ZodOptional<z.ZodString>;
|
|
150
|
+
focus: z.ZodOptional<z.ZodString>;
|
|
151
|
+
player: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
fonts: z.ZodOptional<z.ZodObject<{
|
|
154
|
+
title: z.ZodOptional<z.ZodString>;
|
|
155
|
+
main: z.ZodOptional<z.ZodString>;
|
|
156
|
+
plain: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
corners: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
card: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
size: z.ZodNumber;
|
|
161
|
+
steep: z.ZodNumber;
|
|
162
|
+
}, z.core.$strip>>;
|
|
163
|
+
button: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
size: z.ZodNumber;
|
|
165
|
+
steep: z.ZodNumber;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
small: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
size: z.ZodNumber;
|
|
169
|
+
steep: z.ZodNumber;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
outline: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
pixelArt: z.ZodOptional<z.ZodBoolean>;
|
|
174
|
+
playerMarks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
175
|
+
}, z.core.$loose>;
|
|
176
|
+
/** The `credits` content kind. Formats may change. */
|
|
177
|
+
export declare const creditsSchema: z.ZodObject<{
|
|
178
|
+
format: z.ZodLiteral<1>;
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
kind: z.ZodLiteral<"credits">;
|
|
181
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
182
|
+
role: z.ZodString;
|
|
183
|
+
names: z.ZodArray<z.ZodString>;
|
|
184
|
+
}, z.core.$strip>>;
|
|
185
|
+
}, z.core.$loose>;
|
|
186
|
+
export type Screen = z.infer<typeof screenSchema>;
|
|
187
|
+
export type Item = Screen['items'][number];
|
|
188
|
+
export type Hud = z.infer<typeof hudSchema>;
|
|
189
|
+
export type Flow = z.infer<typeof flowSchema>;
|
|
190
|
+
export type Theme = z.infer<typeof themeSchema>;
|
|
191
|
+
export type Credits = z.infer<typeof creditsSchema>;
|
|
192
|
+
/** Teaches `/core` the shell's content kinds, so a mistake in one of its files is named with its file and line. */
|
|
193
|
+
export declare function defineShellKinds(): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'svelte/store';
|
|
2
|
+
import type { Credits, Screen } from '../formats/formats.ts';
|
|
3
|
+
import type { Look } from '../theme/default.ts';
|
|
4
|
+
import type { SettingName, Settings, TouchPlace } from '../settings/settings.ts';
|
|
5
|
+
import type { SaveRow } from '../saves-screen/saves-screen.ts';
|
|
6
|
+
/** One row of the controls list: what it does, and the key that does it now. */
|
|
7
|
+
type ControlRow = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
kind: 'button' | 'stick';
|
|
11
|
+
key: string;
|
|
12
|
+
pad: string;
|
|
13
|
+
canTap: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** One on-screen control: the action it does, and where it sits. */
|
|
16
|
+
type TouchControl = {
|
|
17
|
+
action: string;
|
|
18
|
+
label: string;
|
|
19
|
+
kind: 'button' | 'stick';
|
|
20
|
+
place: TouchPlace;
|
|
21
|
+
};
|
|
22
|
+
/** Everything a screen's parts need from the game around them. Handed down with Svelte's context under `host`. */
|
|
23
|
+
export type Host = {
|
|
24
|
+
/** A word by its message name, in the language now chosen. A new function whenever the language changes. */
|
|
25
|
+
t: Readable<(name: string, inputs?: Record<string, unknown>) => string>;
|
|
26
|
+
settings: Readable<Settings>;
|
|
27
|
+
set<K extends SettingName>(name: K, value: Settings[K]): void;
|
|
28
|
+
send(event: string): void;
|
|
29
|
+
hasSave: Readable<boolean>;
|
|
30
|
+
languages: string[];
|
|
31
|
+
look: Look;
|
|
32
|
+
/** The width of the stage, in px: under 600 the card is a sheet. */
|
|
33
|
+
stageWidth: Readable<number>;
|
|
34
|
+
setStageWidth(width: number): void;
|
|
35
|
+
/** Keys or a pad were used (or, with `false`, a finger or mouse): a screen takes focus only for those. */
|
|
36
|
+
noteKeyboard(on?: boolean): void;
|
|
37
|
+
/** One plain sentence about what just happened (a save brought in, a controller gone), or empty. */
|
|
38
|
+
notice: Readable<string>;
|
|
39
|
+
/** Changes whenever a save is written or brought in, so the saves list draws again. */
|
|
40
|
+
savesChanged: Readable<number>;
|
|
41
|
+
/** The four save slots, each with what the saved game holds at `paths`. */
|
|
42
|
+
saves(paths: string[]): SaveRow[];
|
|
43
|
+
controls: Readable<ControlRow[]>;
|
|
44
|
+
/** True once a pad has been used on the screens (and until a key is pressed): the key caps show pad buttons. */
|
|
45
|
+
usingPad: Readable<boolean>;
|
|
46
|
+
/** The action waiting for its new key ("Press a key…"), or null. */
|
|
47
|
+
capturing: Readable<string | null>;
|
|
48
|
+
capture(action: string | null): void;
|
|
49
|
+
/** True when the actions that may be tapped instead of held are set to tap. */
|
|
50
|
+
tapping: Readable<boolean>;
|
|
51
|
+
setTapping(on: boolean): void;
|
|
52
|
+
/** The on-screen controls, where they sit now. */
|
|
53
|
+
touchControls: Readable<TouchControl[]>;
|
|
54
|
+
/** Which on-screen control the move-and-resize panel works on. */
|
|
55
|
+
touchPick: Writable<number>;
|
|
56
|
+
moveTouch(index: number, x: number, y: number): void;
|
|
57
|
+
resizeTouch(index: number, by: number): void;
|
|
58
|
+
resetTouch(): void;
|
|
59
|
+
/** Hands an on-screen control's push to the game: a button held or let go, a stick's direction. */
|
|
60
|
+
touchInput(action: string, value: boolean | [number, number]): void;
|
|
61
|
+
credits(): Credits | undefined;
|
|
62
|
+
assetUrl(id: string): string | undefined;
|
|
63
|
+
};
|
|
64
|
+
/** What the shell shows right now. */
|
|
65
|
+
export type View = {
|
|
66
|
+
kind: 'none';
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'screen';
|
|
69
|
+
screen: Screen;
|
|
70
|
+
asking?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
kind: 'ask';
|
|
73
|
+
word: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'play';
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What a pad press means on a screen. */
|
|
2
|
+
export type PadCommand = 'up' | 'down' | 'left' | 'right' | 'press' | 'back' | 'start';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the first pad for the screens: each press counts once, when it starts, and the left stick counts as the d-pad.
|
|
5
|
+
* `poll` is called once a frame. While the game is being remapped, `poll` also says which button went down, so it can be
|
|
6
|
+
* given to an action.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createPadReader(pads: () => (Gamepad | null)[]): {
|
|
9
|
+
poll(): {
|
|
10
|
+
commands: PadCommand[];
|
|
11
|
+
button: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Action, Bindings } from '@automataframework/core';
|
|
2
|
+
/** A key's code as a person reads it on a key cap: `KeyJ` is "J", `Digit1` is "1", `ArrowUp` is "↑". */
|
|
3
|
+
export declare function keyName(code: string): string;
|
|
4
|
+
/** A pad input as a person reads it: `button:0` is "Pad 1". */
|
|
5
|
+
export declare const padName: (id: string) => string;
|
|
6
|
+
/** True when `code` may be given to an action. */
|
|
7
|
+
export declare const canTake: (code: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* One player's bindings with `action` on `code` alone. Another action of the same player that had `code` loses it, so
|
|
10
|
+
* one key never does two things.
|
|
11
|
+
*/
|
|
12
|
+
export declare function bindKey(all: Bindings[], player: number, action: string, code: string): Bindings[];
|
|
13
|
+
/** One player's bindings with `action` on the pad input `input` alone, taken from any other action that had it. */
|
|
14
|
+
export declare function bindPad(all: Bindings[], player: number, action: string, input: string): Bindings[];
|
|
15
|
+
/** Every player's bindings with each action that may be tapped set to tap (or to hold). */
|
|
16
|
+
export declare function setTap(all: Bindings[], actions: Action[], on: boolean): Bindings[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One row of the saves list: the slot, whether it is empty, when it was saved, and what its details read. */
|
|
2
|
+
export type SaveRow = {
|
|
3
|
+
slot: string;
|
|
4
|
+
empty: boolean;
|
|
5
|
+
savedAt: number;
|
|
6
|
+
values: string[];
|
|
7
|
+
};
|
|
8
|
+
/** The order the saves screen shows: every save, the newest first, then the empty slots in slot order. */
|
|
9
|
+
export declare function savesInOrder(rows: SaveRow[]): SaveRow[];
|
|
10
|
+
/** When a save was made, in plain words: "Today 14:05" today, the date and time on any other day. */
|
|
11
|
+
export declare function savedWhen(at: number, now: number, language: string, today: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The slot a save brought in goes to: the first empty one of Save 1 to 3, or, when all three are full, the one saved
|
|
14
|
+
* longest ago. The autosave slot is the game's own and is never written by hand.
|
|
15
|
+
*/
|
|
16
|
+
export declare function importSlot(rows: SaveRow[]): string;
|
|
17
|
+
/** The name a saved copy gets on the device: the game, the slot and the day, such as `my-game-save-1-2026-11-27.json`. */
|
|
18
|
+
export declare function exportName(gameId: string, slot: string, at: number): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Bindings, KeyValue } from '@automataframework/core';
|
|
2
|
+
/** Where one on-screen control sits: its middle as a share of the stage (0 to 1 across, 0 to 1 down), and its size. */
|
|
3
|
+
export type TouchPlace = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
size: number;
|
|
7
|
+
};
|
|
8
|
+
/** What a player can change. Each `setting` a screen file names is one of these keys. */
|
|
9
|
+
export type Settings = {
|
|
10
|
+
language: string;
|
|
11
|
+
master: number;
|
|
12
|
+
music: number;
|
|
13
|
+
effects: number;
|
|
14
|
+
mute: boolean;
|
|
15
|
+
textSize: 0 | 1 | 2 | 3;
|
|
16
|
+
contrast: 0 | 1 | 2;
|
|
17
|
+
motion: 0 | 1 | 2;
|
|
18
|
+
bindings: Bindings[];
|
|
19
|
+
touch: TouchPlace[];
|
|
20
|
+
frameCounter: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type SettingName = keyof Settings;
|
|
23
|
+
/** What the device asks for on a first visit. The browser's own by default; a test hands in its own. */
|
|
24
|
+
export type Asks = {
|
|
25
|
+
languages: readonly string[];
|
|
26
|
+
lessMotion: boolean;
|
|
27
|
+
moreContrast: boolean;
|
|
28
|
+
fontPx: number;
|
|
29
|
+
};
|
|
30
|
+
/** The on-screen controls' sizes, from the smallest. Level 1 is the size the controls file draws. */
|
|
31
|
+
export declare const touchSizes: readonly [0.75, 1, 1.25, 1.5];
|
|
32
|
+
/** The browser's own answers: language, `prefers-reduced-motion`, `prefers-contrast` and the page's font size. */
|
|
33
|
+
export declare function browserAsks(): Asks;
|
|
34
|
+
/**
|
|
35
|
+
* The player's settings, kept in the browser under `automata:<game id>:settings`. A first visit follows the device: the
|
|
36
|
+
* language it asks for (when the game has it), Less motion at level 2 when it asks for less motion, More contrast at
|
|
37
|
+
* level 1 when it asks for more, and Bigger text at level 1 over 16 px and level 2 over 20 px. `bindings` start as the
|
|
38
|
+
* controls file's own, one per player.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createSettings(store: KeyValue, gameId: string, languages: string[], asks: Asks, bindings?: Bindings[]): {
|
|
41
|
+
all: () => Settings;
|
|
42
|
+
get: <K extends SettingName>(name: K) => Settings[K];
|
|
43
|
+
set<K extends SettingName>(name: K, value: Settings[K]): void;
|
|
44
|
+
/** The controls file's own bindings again. */
|
|
45
|
+
defaultBindings: () => Bindings[];
|
|
46
|
+
subscribe(listener: (settings: Settings) => void): () => void;
|
|
47
|
+
};
|
|
48
|
+
/** The classes and numbers the levels put on the shell root. Every part reads these; none has a branch of its own. */
|
|
49
|
+
export declare function levelStyle(settings: Pick<Settings, 'textSize' | 'contrast' | 'motion'>): {
|
|
50
|
+
classes: string;
|
|
51
|
+
vars: string;
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Game } from '@automataframework/core';
|
|
2
|
+
import { type Messages } from '../words/words.ts';
|
|
3
|
+
export type StartOptions = {
|
|
4
|
+
/** Where the game goes. The whole page by default. */
|
|
5
|
+
root?: HTMLElement;
|
|
6
|
+
/** The game's own words, compiled by Paraglide: `import * as messages from './paraglide/messages.js'`. */
|
|
7
|
+
messages?: Messages;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The whole of a game's main file: loads the game's files, draws its screens from them over the canvas, and plays it.
|
|
11
|
+
* A mistake in a file is written on the page and no game starts. `window.__automata` is there from the start, and
|
|
12
|
+
* `ready` is true once the first frame is on the screen.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startGame<G>(game: Game<G>, options?: StartOptions): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Look } from './default.ts';
|
|
2
|
+
/** The theme as CSS custom properties for the shell's root. No component holds a colour or a font of its own. */
|
|
3
|
+
export declare function cssVars(look: Look): Record<string, string>;
|
|
4
|
+
/** Registers each font asset under its asset id, so a theme may name it in `fonts`. */
|
|
5
|
+
export declare function registerFonts(assets: {
|
|
6
|
+
id: string;
|
|
7
|
+
kind: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}[], fonts: {
|
|
10
|
+
add(face: FontFace): void;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Theme } from '../formats/formats.ts';
|
|
2
|
+
/** What a game with no theme file looks like: the light Soft look with crisp corners. Code, not a content file. */
|
|
3
|
+
export declare const softLook: {
|
|
4
|
+
colours: {
|
|
5
|
+
page: string;
|
|
6
|
+
words: string;
|
|
7
|
+
muted: string;
|
|
8
|
+
button: string;
|
|
9
|
+
buttonWords: string;
|
|
10
|
+
primary: string;
|
|
11
|
+
primaryWords: string;
|
|
12
|
+
line: string;
|
|
13
|
+
focus: string;
|
|
14
|
+
player: string[];
|
|
15
|
+
};
|
|
16
|
+
fonts: {
|
|
17
|
+
title: string;
|
|
18
|
+
main: string;
|
|
19
|
+
plain: string;
|
|
20
|
+
};
|
|
21
|
+
corners: {
|
|
22
|
+
card: {
|
|
23
|
+
size: number;
|
|
24
|
+
steep: number;
|
|
25
|
+
};
|
|
26
|
+
button: {
|
|
27
|
+
size: number;
|
|
28
|
+
steep: number;
|
|
29
|
+
};
|
|
30
|
+
small: {
|
|
31
|
+
size: number;
|
|
32
|
+
steep: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
outline: number;
|
|
36
|
+
pixelArt: boolean;
|
|
37
|
+
playerMarks: string[];
|
|
38
|
+
};
|
|
39
|
+
export type Look = typeof softLook;
|
|
40
|
+
/** A theme file laid over the Soft look: every key it leaves out stays as it was. */
|
|
41
|
+
export declare function lookOf(theme: Theme | undefined): Look;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Action } from '@automataframework/core';
|
|
2
|
+
import { type TouchPlace } from '../settings/settings.ts';
|
|
3
|
+
/** A stick and a button, in px across, at size level 1. Both stay over 44 px at the smallest size. */
|
|
4
|
+
export declare const stickPx = 104;
|
|
5
|
+
export declare const buttonPx = 80;
|
|
6
|
+
/** One push of a move button: this share of the stage. */
|
|
7
|
+
export declare const nudge = 0.04;
|
|
8
|
+
/** The actions that get an on-screen control: the first stick and the first four buttons in the controls file. */
|
|
9
|
+
export declare function touchActions(actions: Action[]): Action[];
|
|
10
|
+
/** Where the controls sit at first: the stick low on the left, the buttons in a curve low on the right. */
|
|
11
|
+
export declare function firstPlaces(actions: Action[]): TouchPlace[];
|
|
12
|
+
/** The places kept in settings when there is one for each control, else the first places. */
|
|
13
|
+
export declare function placesFor(actions: Action[], kept: TouchPlace[]): TouchPlace[];
|
|
14
|
+
/** A place moved to `x`, `y` (shares of the stage), kept on the stage. */
|
|
15
|
+
export declare const moved: (place: TouchPlace, x: number, y: number) => TouchPlace;
|
|
16
|
+
/** A place one size bigger (`by` 1) or smaller (`by` -1), never past the ends. */
|
|
17
|
+
export declare function resized(place: TouchPlace, by: number): TouchPlace;
|
|
18
|
+
/** The size's level, 0 for the smallest, for its name. */
|
|
19
|
+
export declare const sizeLevel: (place: TouchPlace) => number;
|
|
20
|
+
/** A stick's push from where a finger is: `dx`, `dy` from the stick's middle, as a share of its radius, at most 1 long. */
|
|
21
|
+
export declare function stickPush(dx: number, dy: number, radius: number): [number, number];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Messages = Record<string, unknown>;
|
|
2
|
+
/** A language written in its own words: "English", "Español". */
|
|
3
|
+
export declare function languageName(code: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Looks a word up by its message name in the language now chosen: first in the game's own words, then in the shell's.
|
|
6
|
+
* Paraglide gives the English words wherever a language has none, so a missing word is never blank. A name nobody wrote
|
|
7
|
+
* comes back as the name itself (or the plain text the game gave for it, such as its name); `automata check` names that file and word before a game ships.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createWords(sources: {
|
|
10
|
+
game?: Messages | undefined;
|
|
11
|
+
shell: Messages;
|
|
12
|
+
plain?: Record<string, string>;
|
|
13
|
+
}, language: () => string): {
|
|
14
|
+
word(name: string, inputs?: Record<string, unknown>): string;
|
|
15
|
+
has: (name: string) => boolean;
|
|
16
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { startGame } from './features/start/start.ts';
|
|
2
|
+
export type { StartOptions } from './features/start/start.ts';
|
|
3
|
+
export { creditsSchema, flowSchema, hudSchema, screenSchema, themeSchema } from './features/formats/formats.ts';
|
|
4
|
+
export type { Credits, Flow, Hud, Screen, Theme } from './features/formats/formats.ts';
|
|
5
|
+
export { softLook } from './features/theme/default.ts';
|
|
6
|
+
export type { Settings } from './features/settings/settings.ts';
|