rpg-engine 0.21.0 → 0.22.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/dist/campaign/host-files.js +4 -1
- package/dist/campaign/index.d.ts +2 -1
- package/dist/campaign/index.js +2 -1
- package/dist/campaign/port.d.ts +6 -0
- package/dist/campaign/port.js +24 -0
- package/dist/campaign/settings.d.ts +17 -0
- package/dist/campaign/settings.js +24 -1
- package/dist/cli/cli.js +15 -0
- package/dist/commands/config/config.js +15 -1
- package/dist/commands/config/dashboard.d.ts +4 -0
- package/dist/commands/config/dashboard.js +37 -6
- package/dist/commands/config/shown.js +4 -0
- package/dist/commands/config/words.d.ts +3 -1
- package/dist/commands/config/words.js +28 -1
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package/data.js +27 -0
- package/dist/commands/package/theme.js +2 -1
- package/dist/commands/scene/scene.js +6 -1
- package/dist/commands/shared/books/adventures.d.ts +1 -0
- package/dist/commands/shared/books/adventures.js +1 -1
- package/dist/commands/shared/campaign/git.d.ts +25 -0
- package/dist/commands/shared/campaign/git.js +104 -0
- package/dist/commands/shared/campaign/saves.js +5 -1
- package/dist/commands/shared/packages/catalog.js +24 -5
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +8 -4
- package/dist/core/context.d.ts +2 -0
- package/dist/core/version.d.ts +2 -0
- package/dist/core/version.js +5 -0
- package/dist/dashboard/guide/ar.md +6 -4
- package/dist/dashboard/guide/cs.md +6 -4
- package/dist/dashboard/guide/da.md +6 -4
- package/dist/dashboard/guide/de.md +8 -6
- package/dist/dashboard/guide/el.md +6 -4
- package/dist/dashboard/guide/en.md +5 -3
- package/dist/dashboard/guide/es.md +6 -4
- package/dist/dashboard/guide/fi.md +6 -4
- package/dist/dashboard/guide/fr.md +6 -4
- package/dist/dashboard/guide/he.md +6 -4
- package/dist/dashboard/guide/hi.md +6 -4
- package/dist/dashboard/guide/hu.md +6 -4
- package/dist/dashboard/guide/is.md +6 -4
- package/dist/dashboard/guide/it.md +6 -4
- package/dist/dashboard/guide/ja.md +7 -5
- package/dist/dashboard/guide/ko.md +6 -4
- package/dist/dashboard/guide/nb.md +7 -5
- package/dist/dashboard/guide/nl.md +6 -4
- package/dist/dashboard/guide/pl.md +6 -4
- package/dist/dashboard/guide/pt.md +6 -4
- package/dist/dashboard/guide/ro.md +6 -4
- package/dist/dashboard/guide/ru.md +6 -4
- package/dist/dashboard/guide/sv.md +6 -4
- package/dist/dashboard/guide/tr.md +6 -4
- package/dist/dashboard/guide/uk.md +6 -4
- package/dist/dashboard/guide/zh.md +6 -4
- package/dist/dashboard/i18n/ar.json +25 -0
- package/dist/dashboard/i18n/cs.json +25 -0
- package/dist/dashboard/i18n/da.json +25 -0
- package/dist/dashboard/i18n/de.json +25 -0
- package/dist/dashboard/i18n/el.json +25 -0
- package/dist/dashboard/i18n/es.json +25 -0
- package/dist/dashboard/i18n/fi.json +25 -0
- package/dist/dashboard/i18n/fr.json +25 -0
- package/dist/dashboard/i18n/he.json +25 -0
- package/dist/dashboard/i18n/hi.json +25 -0
- package/dist/dashboard/i18n/hu.json +25 -0
- package/dist/dashboard/i18n/is.json +25 -0
- package/dist/dashboard/i18n/it.json +25 -0
- package/dist/dashboard/i18n/ja.json +25 -0
- package/dist/dashboard/i18n/ko.json +25 -0
- package/dist/dashboard/i18n/nb.json +25 -0
- package/dist/dashboard/i18n/nl.json +25 -0
- package/dist/dashboard/i18n/pl.json +25 -0
- package/dist/dashboard/i18n/pt.json +25 -0
- package/dist/dashboard/i18n/ro.json +25 -0
- package/dist/dashboard/i18n/ru.json +25 -0
- package/dist/dashboard/i18n/sv.json +25 -0
- package/dist/dashboard/i18n/tr.json +25 -0
- package/dist/dashboard/i18n/uk.json +25 -0
- package/dist/dashboard/i18n/zh.json +25 -0
- package/dist/dashboard/packages/installed.js +2 -2
- package/dist/dashboard/packages/packages.js +1 -1
- package/dist/dashboard/parts/labels.js +7 -0
- package/dist/dashboard/settings/settings.js +33 -6
- package/dist/dashboard/shell/system-style.js +89 -5
- package/dist/dashboard/shell/tooltip.js +5 -4
- package/dist/dashboard/style.css +234 -81
- package/dist/git/git.d.ts +12 -0
- package/dist/git/git.js +175 -0
- package/dist/git/ignore.d.ts +2 -0
- package/dist/git/ignore.js +16 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +2 -0
- package/dist/importer/index.d.ts +1 -1
- package/dist/importer/index.js +1 -1
- package/dist/languages/pack.js +2 -1
- package/dist/server/bell-listener.d.ts +2 -1
- package/dist/server/bell-listener.js +10 -41
- package/dist/server/dashboard/files.d.ts +3 -2
- package/dist/server/dashboard/files.js +44 -15
- package/dist/server/dashboard/index.d.ts +15 -2
- package/dist/server/dashboard/index.js +52 -22
- package/dist/server/dashboard/news.d.ts +3 -2
- package/dist/server/dashboard/news.js +19 -5
- package/dist/server/dashboard/ports.d.ts +17 -2
- package/dist/server/dashboard/ports.js +60 -4
- package/dist/server/mcp.d.ts +3 -2
- package/dist/server/mcp.js +55 -11
- package/dist/themes/css.d.ts +1 -1
- package/dist/themes/css.js +101 -2
- package/dist/themes/index.d.ts +1 -1
- package/dist/themes/index.js +1 -1
- package/dist/themes/theme.d.ts +34 -3
- package/dist/themes/theme.js +176 -19
- package/instructions/core.md +1 -0
- package/instructions/dashboard-guide.md +1 -1
- package/package.json +1 -1
package/dist/themes/theme.d.ts
CHANGED
|
@@ -34,6 +34,25 @@ export interface Theme {
|
|
|
34
34
|
innerLine?: "none" | "solid" | "dashed" | "dotted";
|
|
35
35
|
/** The picture in a card's lower corner, a file of the folder drawn in one colour. */
|
|
36
36
|
ornament?: string;
|
|
37
|
+
/** The cards' corners cut, notched or scooped instead of round, as far as `corners` says. */
|
|
38
|
+
cardCorner?: "round" | "cut" | "notch" | "scoop";
|
|
39
|
+
/** A texture under the cards, an SVG drawn in each mode's grain colour, faint under the card's own colour. */
|
|
40
|
+
cardTexture?: ThemeTexture;
|
|
41
|
+
/** The shape of the buttons of words, and of the chosen tab. */
|
|
42
|
+
buttonShape?: Shape;
|
|
43
|
+
tabShape?: "underline" | Shape;
|
|
44
|
+
/** The shadows of whatever lifts: soft as the page's, sharp, none, or a glow. */
|
|
45
|
+
shadows?: "soft" | "sharp" | "none" | "glow";
|
|
46
|
+
/** The paper of the maps and of the documents found, the same in both modes. */
|
|
47
|
+
papers: {
|
|
48
|
+
maps?: string;
|
|
49
|
+
documents?: string;
|
|
50
|
+
};
|
|
51
|
+
/** The portraits' shape and a frame drawn inside their edge. */
|
|
52
|
+
portraitShape?: "round" | "rounded" | "square" | "cut";
|
|
53
|
+
portraitFrame?: "none" | "thin" | "thick" | "double";
|
|
54
|
+
/** A style sheet of its own, a file of the folder, which the page adds over its rules in a layer of its own, unchecked. */
|
|
55
|
+
style?: string;
|
|
37
56
|
/** The lines of each icon it draws, by name: the d of its paths, on a grid of 24. */
|
|
38
57
|
icons: Record<string, string>;
|
|
39
58
|
modes: Record<ThemeModeName, ThemeMode>;
|
|
@@ -53,7 +72,17 @@ export interface ThemeMode {
|
|
|
53
72
|
barEdge?: string;
|
|
54
73
|
pageTexture?: ThemeTexture;
|
|
55
74
|
barTexture?: ThemeTexture;
|
|
75
|
+
/** A picture at the end of the top, beside the campaign's name, under no words. */
|
|
76
|
+
headPicture?: ThemeTexture;
|
|
77
|
+
/** The colour the cards' texture is drawn in. */
|
|
78
|
+
cardGrain: string;
|
|
79
|
+
/** The colour of the shadows, when not the page's. */
|
|
80
|
+
shadow?: string;
|
|
81
|
+
/** The colour of the portraits' frame. */
|
|
82
|
+
portraitFrame: string;
|
|
56
83
|
}
|
|
84
|
+
/** The shapes of a button or a tab: the page's rounded corners, square, a pill, or cut. */
|
|
85
|
+
type Shape = "rounded" | "square" | "pill" | "cut";
|
|
57
86
|
/** A picture under the page or the top, repeated or covering it. */
|
|
58
87
|
export interface ThemeTexture {
|
|
59
88
|
picture: string;
|
|
@@ -69,10 +98,12 @@ export declare function readTheme(folder: string): ThemeReading;
|
|
|
69
98
|
/** The real path of a file of a theme's folder, only when it is one and inside it, links resolved: what the dashboard serves. */
|
|
70
99
|
export declare function themeFile(folder: string, name: string): string | undefined;
|
|
71
100
|
/**
|
|
72
|
-
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons
|
|
73
|
-
* it does not read: its checks say why.
|
|
101
|
+
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons, textures and pictures,
|
|
102
|
+
* its style sheet and the pictures that names, read by `read`. None when it does not read: its checks say why.
|
|
74
103
|
*/
|
|
75
|
-
export declare function themeFilesNamed(text: string): string[];
|
|
104
|
+
export declare function themeFilesNamed(text: string, read?: (name: string) => string | undefined): string[];
|
|
76
105
|
/** An ornament drawn in one colour, turned for a page that reads right to left: the theme gives one drawing for both modes and both directions. */
|
|
77
106
|
export declare function drawnOrnament(svg: string, ink: string, mirrored: boolean): string;
|
|
107
|
+
/** The cards' texture drawn in one colour: what it draws in currentColor, and what it fills without saying how, in that colour. */
|
|
108
|
+
export declare function drawnTexture(svg: string, ink: string): string;
|
|
78
109
|
export {};
|
package/dist/themes/theme.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A theme of the dashboard (D-527, D-528): a folder of data, theme.yaml with its fonts, pictures and icons, read and checked as the engine reads its game
|
|
2
2
|
// system. It gives values alone, colours, corners, fonts and the hooks the page documents; the page's own rules read them, so no part is the theme's to redraw.
|
|
3
3
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
4
|
-
import { extname, isAbsolute, join, relative, sep } from "node:path";
|
|
4
|
+
import { extname, isAbsolute, join, posix, relative, sep } from "node:path";
|
|
5
5
|
import { parse } from "yaml";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { contrast, distance, isLight, mix } from "./contrast.js";
|
|
@@ -39,12 +39,12 @@ export function readTheme(folder) {
|
|
|
39
39
|
if (problem !== undefined) {
|
|
40
40
|
problems.push(`${place}: ${problem}`);
|
|
41
41
|
}
|
|
42
|
-
return name
|
|
42
|
+
return written(name);
|
|
43
43
|
};
|
|
44
44
|
const fonts = (given.fonts ?? []).map((font, index) => {
|
|
45
45
|
file(`fonts.${index}.file`, font.file, fontFiles);
|
|
46
46
|
file(`fonts.${index}.license`, font.license, licenseFiles);
|
|
47
|
-
return { family: font.family, file: font.file
|
|
47
|
+
return { family: font.family, file: written(font.file), weight: String(font.weight ?? 400) };
|
|
48
48
|
});
|
|
49
49
|
const family = (key) => {
|
|
50
50
|
const name = given[key];
|
|
@@ -74,20 +74,35 @@ export function readTheme(folder) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
const ornament = given.cards?.ornament === undefined ? undefined : file("cards.ornament", given.cards.ornament, [".svg"]);
|
|
77
|
+
const cardTexture = given.cards?.texture === undefined ? undefined : { picture: file("cards.texture.picture", given.cards.texture.picture, [".svg"]), fit: given.cards.texture.fit ?? "tile" };
|
|
78
|
+
if (cardTexture !== undefined && fileProblem(folder, cardTexture.picture, [".svg"]) === undefined) {
|
|
79
|
+
problems.push(...oneColourProblems(readFileSync(join(folder, cardTexture.picture), "utf8")).map((problem) => `cards.texture.picture: ${cardTexture.picture} ${problem}`));
|
|
80
|
+
}
|
|
81
|
+
const style = given.style === undefined ? undefined : file("style", given.style, [".css"]);
|
|
82
|
+
if (style !== undefined && fileProblem(folder, style, [".css"]) === undefined) {
|
|
83
|
+
problems.push(...styleProblems(folder, style));
|
|
84
|
+
}
|
|
85
|
+
const hooks = { tabs: given.tabs?.shape ?? "underline", grain: cardTexture !== undefined, frame: (given.portraits?.frame ?? "none") !== "none" };
|
|
77
86
|
const modes = {};
|
|
78
87
|
for (const mode of themeModes) {
|
|
79
88
|
const asked = given[mode];
|
|
80
89
|
const colours = derived(asked);
|
|
90
|
+
const cardEdge = asked["card-edge"] ?? colours.rule;
|
|
81
91
|
modes[mode] = {
|
|
82
92
|
colours,
|
|
83
|
-
cardEdge
|
|
93
|
+
cardEdge,
|
|
84
94
|
...(asked["title-glow"] === undefined || asked["title-glow"] === "none" ? {} : { titleGlow: asked["title-glow"] }),
|
|
85
95
|
...(asked["bar-edge"] === undefined || asked["bar-edge"] === "none" ? {} : { barEdge: asked["bar-edge"] }),
|
|
86
96
|
...(asked["page-texture"] === undefined ? {} : { pageTexture: { picture: file(`${mode}.page-texture.picture`, asked["page-texture"].picture, pictureFiles), fit: asked["page-texture"].fit ?? "tile" } }),
|
|
87
97
|
...(asked["bar-texture"] === undefined ? {} : { barTexture: { picture: file(`${mode}.bar-texture.picture`, asked["bar-texture"].picture, pictureFiles), fit: asked["bar-texture"].fit ?? "tile" } }),
|
|
98
|
+
...(asked["head-picture"] === undefined ? {} : { headPicture: { picture: file(`${mode}.head-picture.picture`, asked["head-picture"].picture, pictureFiles), fit: asked["head-picture"].fit ?? "cover" } }),
|
|
99
|
+
cardGrain: asked["card-grain"] ?? cardEdge,
|
|
100
|
+
...optional("shadow", asked.shadow),
|
|
101
|
+
portraitFrame: asked["portrait-frame"] ?? colours.gold,
|
|
88
102
|
};
|
|
89
|
-
problems.push(...legibilityProblems(mode, modes[mode]));
|
|
103
|
+
problems.push(...legibilityProblems(mode, modes[mode], hooks));
|
|
90
104
|
}
|
|
105
|
+
problems.push(...paperProblems(given.papers ?? {}));
|
|
91
106
|
const theme = {
|
|
92
107
|
name: given.name,
|
|
93
108
|
...optional("version", given.version),
|
|
@@ -102,6 +117,15 @@ export function readTheme(folder) {
|
|
|
102
117
|
...optional("titleSpacing", given.titles?.spacing),
|
|
103
118
|
...optional("innerLine", given.cards?.["inner-line"]),
|
|
104
119
|
...optional("ornament", ornament),
|
|
120
|
+
...optional("cardCorner", given.cards?.corner),
|
|
121
|
+
...optional("cardTexture", cardTexture),
|
|
122
|
+
...optional("buttonShape", given.buttons?.shape),
|
|
123
|
+
...optional("tabShape", given.tabs?.shape),
|
|
124
|
+
...optional("shadows", given.shadows),
|
|
125
|
+
papers: given.papers ?? {},
|
|
126
|
+
...optional("portraitShape", given.portraits?.shape),
|
|
127
|
+
...optional("portraitFrame", given.portraits?.frame),
|
|
128
|
+
...optional("style", style),
|
|
105
129
|
icons,
|
|
106
130
|
modes,
|
|
107
131
|
};
|
|
@@ -120,10 +144,10 @@ export function themeFile(folder, name) {
|
|
|
120
144
|
}
|
|
121
145
|
}
|
|
122
146
|
/**
|
|
123
|
-
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons
|
|
124
|
-
* it does not read: its checks say why.
|
|
147
|
+
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons, textures and pictures,
|
|
148
|
+
* its style sheet and the pictures that names, read by `read`. None when it does not read: its checks say why.
|
|
125
149
|
*/
|
|
126
|
-
export function themeFilesNamed(text) {
|
|
150
|
+
export function themeFilesNamed(text, read = () => undefined) {
|
|
127
151
|
let data;
|
|
128
152
|
try {
|
|
129
153
|
data = parse(text);
|
|
@@ -135,9 +159,39 @@ export function themeFilesNamed(text) {
|
|
|
135
159
|
const field = (value, key) => (typeof value === "object" && value !== null ? value[key] : undefined);
|
|
136
160
|
const fonts = Array.isArray(given.fonts) ? given.fonts.flatMap((font) => [field(font, "file"), field(font, "license")]) : [];
|
|
137
161
|
const icons = typeof given.icons === "object" && given.icons !== null ? Object.values(given.icons) : [];
|
|
138
|
-
const textures = ["light", "dark"].flatMap((mode) => ["page-texture", "bar-texture"].map((texture) => field(field(given[mode], texture), "picture")));
|
|
139
|
-
const named = [...fonts, ...icons, ...textures, field(given.cards, "ornament")];
|
|
140
|
-
|
|
162
|
+
const textures = ["light", "dark"].flatMap((mode) => ["page-texture", "bar-texture", "head-picture"].map((texture) => field(field(given[mode], texture), "picture")));
|
|
163
|
+
const named = [...fonts, ...icons, ...textures, field(given.cards, "ornament"), field(field(given.cards, "texture"), "picture"), given.style];
|
|
164
|
+
const files = named.filter((one) => typeof one === "string").map(written);
|
|
165
|
+
const style = typeof given.style === "string" ? written(given.style) : undefined;
|
|
166
|
+
const sheet = style === undefined ? undefined : read(style);
|
|
167
|
+
return sheet === undefined || style === undefined ? files : [...files, ...styleUrls(sheet).filter(namesFile).map((url) => fromStyle(style, url))];
|
|
168
|
+
}
|
|
169
|
+
/** A name as written from a theme's folder, with forward slashes and no ./ before it. */
|
|
170
|
+
function written(name) {
|
|
171
|
+
return name.replaceAll("\\", "/").replace(/^(\.\/)+/, "");
|
|
172
|
+
}
|
|
173
|
+
/** The addresses a style sheet's url() give, as written, without their quotes. */
|
|
174
|
+
function styleUrls(css) {
|
|
175
|
+
return [...withoutComments(css).matchAll(/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)\s]*))\s*\)/gi)].map((match) => (match[1] ?? match[2] ?? match[3]).trim());
|
|
176
|
+
}
|
|
177
|
+
/** Whether a style sheet's url() names a file from the sheet: not an element of the page (#glow), an address with a scheme, nor one from the page's root. */
|
|
178
|
+
function namesFile(url) {
|
|
179
|
+
return !url.startsWith("#") && !url.startsWith("/") && !/^[a-z][a-z\d+.-]*:/i.test(url);
|
|
180
|
+
}
|
|
181
|
+
/** An address of a theme's style sheet as a file of its folder: relative to the sheet, decoded as the browser does, its ./ and ../ resolved; one that climbs out keeps its .. */
|
|
182
|
+
function fromStyle(style, url) {
|
|
183
|
+
const path = url.split(/[?#]/)[0];
|
|
184
|
+
let name = path;
|
|
185
|
+
try {
|
|
186
|
+
name = decodeURIComponent(path);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// No valid escape: the browser asks for it as written, and the check says it is missing.
|
|
190
|
+
}
|
|
191
|
+
return posix.normalize(posix.join(posix.dirname(style), name));
|
|
192
|
+
}
|
|
193
|
+
function withoutComments(css) {
|
|
194
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
141
195
|
}
|
|
142
196
|
/** An ornament drawn in one colour, turned for a page that reads right to left: the theme gives one drawing for both modes and both directions. */
|
|
143
197
|
export function drawnOrnament(svg, ink, mirrored) {
|
|
@@ -155,6 +209,12 @@ export function drawnOrnament(svg, ink, mirrored) {
|
|
|
155
209
|
const end = coloured.lastIndexOf("</svg>");
|
|
156
210
|
return `${coloured.slice(0, start)}<g transform="translate(${across} 0) scale(-1 1)">${coloured.slice(start, end)}</g>${coloured.slice(end)}`;
|
|
157
211
|
}
|
|
212
|
+
/** The cards' texture drawn in one colour: what it draws in currentColor, and what it fills without saying how, in that colour. */
|
|
213
|
+
export function drawnTexture(svg, ink) {
|
|
214
|
+
const coloured = svg.replaceAll("currentColor", ink);
|
|
215
|
+
const opened = /<svg\b[^>]*>/.exec(coloured);
|
|
216
|
+
return opened === null || /\sfill\s*=/.test(opened[0]) ? coloured : `${coloured.slice(0, opened.index + 4)} fill="${ink}"${coloured.slice(opened.index + 4)}`;
|
|
217
|
+
}
|
|
158
218
|
/** Whether each part of a file's name is written as the disk has it, capitals too: Windows finds Images/Corner.SVG, Linux does not. */
|
|
159
219
|
function writtenAsIs(folder, name) {
|
|
160
220
|
let at = folder;
|
|
@@ -182,10 +242,17 @@ const modeSchema = z.object({
|
|
|
182
242
|
"bar-edge": z.union([z.literal("none"), colour]).optional(),
|
|
183
243
|
"page-texture": texture.optional(),
|
|
184
244
|
"bar-texture": texture.optional(),
|
|
245
|
+
"head-picture": texture.optional(),
|
|
246
|
+
"card-grain": colour.optional(),
|
|
247
|
+
shadow: colour.optional(),
|
|
248
|
+
"portrait-frame": colour.optional(),
|
|
185
249
|
}).strict();
|
|
250
|
+
const shapes = ["rounded", "square", "pill", "cut"];
|
|
186
251
|
const themeSchema = z.object({
|
|
187
252
|
name: z.string().min(1),
|
|
188
253
|
version: z.union([z.string().min(1), z.number()]).transform(String).optional(),
|
|
254
|
+
// The lowest rpg-engine that reads it, such as "0.22": checked as it is installed.
|
|
255
|
+
engine: z.string({ error: 'engine is written in quotes, as engine: "0.22": without them YAML reads 0.30 as the number 0.3' }).regex(/^\d+(\.\d+){0,2}$/, 'engine is the lowest rpg-engine version, such as "0.22", not a range').optional(),
|
|
189
256
|
fonts: z.array(z.object({
|
|
190
257
|
family: z.string().regex(/^[\p{L}\p{N} _-]+$/u, { error: "letters, numbers, spaces and hyphens alone" }),
|
|
191
258
|
file: fileName,
|
|
@@ -198,7 +265,18 @@ const themeSchema = z.object({
|
|
|
198
265
|
"number-font": z.enum(["text", "title"]).optional(),
|
|
199
266
|
corners: z.number().min(0).max(16, { error: "a card's corner in pixels, from 0 to 16" }).optional(),
|
|
200
267
|
titles: z.object({ case: z.enum(["as-written", "capitals", "small-capitals"]).optional(), spacing: z.number().min(-0.02).max(0.15).optional() }).strict().optional(),
|
|
201
|
-
cards: z.object({
|
|
268
|
+
cards: z.object({
|
|
269
|
+
"inner-line": z.enum(["none", "solid", "dashed", "dotted"]).optional(),
|
|
270
|
+
ornament: fileName.optional(),
|
|
271
|
+
corner: z.enum(["round", "cut", "notch", "scoop"]).optional(),
|
|
272
|
+
texture: texture.optional(),
|
|
273
|
+
}).strict().optional(),
|
|
274
|
+
buttons: z.object({ shape: z.enum(shapes).optional() }).strict().optional(),
|
|
275
|
+
tabs: z.object({ shape: z.enum(["underline", ...shapes]).optional() }).strict().optional(),
|
|
276
|
+
shadows: z.enum(["soft", "sharp", "none", "glow"]).optional(),
|
|
277
|
+
papers: z.object({ maps: colour.optional(), documents: colour.optional() }).strict().optional(),
|
|
278
|
+
portraits: z.object({ shape: z.enum(["round", "rounded", "square", "cut"]).optional(), frame: z.enum(["none", "thin", "thick", "double"]).optional() }).strict().optional(),
|
|
279
|
+
style: fileName.optional(),
|
|
202
280
|
icons: z.record(z.string(), fileName).optional(),
|
|
203
281
|
light: modeSchema,
|
|
204
282
|
dark: modeSchema,
|
|
@@ -227,33 +305,67 @@ const pairs = [
|
|
|
227
305
|
// The last button of a confirm that loses something.
|
|
228
306
|
{ ink: "on-low", ground: "low", least: 4.5, change: "on-low" },
|
|
229
307
|
];
|
|
308
|
+
// The pairs a hook adds when a theme uses it: the chosen tab's accent on its tint, and the words of a card on its texture where it is thickest, whose grain
|
|
309
|
+
// colour is the one to change.
|
|
310
|
+
const tabPairs = [{ ink: "accent", ground: "tab", least: 4.5, change: "accent" }];
|
|
311
|
+
const grainPairs = ["ink", "muted", "accent", "gold-ink", "ally", "low", "warn"].map((ink) => ({ ink, ground: "grain", least: 4.5, change: "card-grain" }));
|
|
312
|
+
/** The pairs a theme's colours must pass, with those of the hooks it uses. */
|
|
313
|
+
function pairsOf(hooks) {
|
|
314
|
+
return [...pairs, ...(hooks.tabs === "underline" ? [] : tabPairs), ...(hooks.grain ? grainPairs : [])];
|
|
315
|
+
}
|
|
230
316
|
/**
|
|
231
317
|
* What does not read in a mode: by colour of the theme to change, the pairs it fails, and the nearest colour that makes them all read without making another
|
|
232
318
|
* pair fail; or, when none does, that one of the colours it sits on or under must change.
|
|
233
319
|
*/
|
|
234
|
-
function legibilityProblems(mode, given) {
|
|
235
|
-
const
|
|
320
|
+
function legibilityProblems(mode, given, hooks) {
|
|
321
|
+
const all = pairsOf(hooks);
|
|
322
|
+
const written = { ...given.colours, "card-edge": given.cardEdge, "card-grain": given.cardGrain };
|
|
236
323
|
const shown = measured(written);
|
|
237
|
-
const failing =
|
|
324
|
+
const failing = all.filter((pair) => !reads(pair, shown));
|
|
238
325
|
const problems = [...new Set(failing.map((pair) => pair.change))].map((change) => {
|
|
239
326
|
const own = failing.filter((pair) => pair.change === change);
|
|
240
327
|
const fails = own.map((pair) => `${pair.ink === change ? "" : `${pair.ink} `}on ${pair.ground} ${shown[pair.ground]} is ${ratioText(shown[pair.ink], shown[pair.ground])}:1`);
|
|
241
328
|
const said = `${mode}: ${change} ${written[change]} does not read: ${fails.join(", ")}, the page needs ${own[0].least}:1`;
|
|
242
|
-
const offered = readingColour(written, change);
|
|
243
|
-
const others = [...new Set(
|
|
329
|
+
const offered = readingColour(written, change, all);
|
|
330
|
+
const others = [...new Set(all.filter((pair) => pair.change === change).flatMap((pair) => madeOf(pair.ground === change ? pair.ink : pair.ground)))].filter((name) => name !== change);
|
|
244
331
|
return offered === undefined ? `${said}; no one colour reads on ${others.join(" and ")} as they are: change one of those` : `${said}; ${offered} would do`;
|
|
245
332
|
});
|
|
246
333
|
if (!apart(written)) {
|
|
247
334
|
problems.push(`${mode}: ally ${written.ally} and low ${written.low} are too alike; friends and foes must not look the same`);
|
|
248
335
|
}
|
|
336
|
+
if (hooks.frame && distance(given.portraitFrame, written.low) < 60) {
|
|
337
|
+
problems.push(`${mode}: portrait-frame ${given.portraitFrame} and low ${written.low} are too alike; a foe is ringed in low, and every portrait would look like one`);
|
|
338
|
+
}
|
|
249
339
|
return problems;
|
|
250
340
|
}
|
|
251
|
-
// The
|
|
341
|
+
// The inks the page writes on the paper of the documents and of the maps, copied from tokens.css and world.css, and the contrast each needs: words 4.5:1,
|
|
342
|
+
// a mark 3:1. The documents' ruled lines are faint, a texture, and need none.
|
|
343
|
+
const paperInks = {
|
|
344
|
+
documents: [["the documents' ink", "#2f261b", 4.5], ["their notes", "#5c4a30", 4.5], ["their links", "#7a3b16", 4.5], ["their seals", "#9b2f24", 3]],
|
|
345
|
+
maps: [["the maps' ink", "#3f2f1f", 4.5], ["the regions' names", "#5a3f4f", 4.5], ["their marks", "#6b4a5c", 3], ["the rivers", "#3a6d96", 3], ["the party's trail", "#b2361f", 3]],
|
|
346
|
+
};
|
|
347
|
+
/** What does not read on the paper a theme gives the documents or the maps, the same in both modes, and the nearest paper that reads. */
|
|
348
|
+
function paperProblems(papers) {
|
|
349
|
+
return ["documents", "maps"].flatMap((kind) => {
|
|
350
|
+
const paper = papers[kind];
|
|
351
|
+
const failing = paper === undefined ? [] : paperInks[kind].filter(([, ink, least]) => contrast(ink, paper) < least);
|
|
352
|
+
if (paper === undefined || failing.length === 0) {
|
|
353
|
+
return [];
|
|
354
|
+
}
|
|
355
|
+
const fails = failing.map(([name, ink, least]) => `${name} ${ink} on it is ${ratioText(ink, paper)}:1, the page needs ${least}:1`).join(", ");
|
|
356
|
+
const offered = [...Array(100).keys()].map((step) => mix("#ffffff", paper, (step + 1) / 100)).find((tried) => paperInks[kind].every(([, ink, least]) => contrast(ink, tried) >= least));
|
|
357
|
+
return [`papers.${kind} ${paper} does not read: ${fails}; the page writes dark on it in both modes, ${offered ?? "#ffffff"} would do`];
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
// The colours the page mixes of the theme's: the two each mixes, and how much of the first. The chosen tab's tint over the page; a card's texture where it
|
|
361
|
+
// is thickest, its grain at 30% over the card.
|
|
252
362
|
const mixes = {
|
|
253
363
|
cell: ["ink", "panel", 0.06],
|
|
254
364
|
chip: ["accent", "panel-2", 0.16],
|
|
255
365
|
"chip-muted": ["muted", "ink", 0.7],
|
|
256
366
|
"on-gold-soft": ["on-gold", "gold", 0.75],
|
|
367
|
+
tab: ["accent", "paper", 0.16],
|
|
368
|
+
grain: ["card-grain", "panel", 0.3],
|
|
257
369
|
};
|
|
258
370
|
/** The colours as the page shows them, those it mixes included. */
|
|
259
371
|
function measured(written) {
|
|
@@ -279,7 +391,7 @@ function ratioText(first, second) {
|
|
|
279
391
|
* The colour nearest to the one written, toward white or toward black, that makes every pair it is in read, no pair that read stop reading, and friends and foes
|
|
280
392
|
* that looked apart still look so; undefined when there is none.
|
|
281
393
|
*/
|
|
282
|
-
function readingColour(written, change) {
|
|
394
|
+
function readingColour(written, change, pairs) {
|
|
283
395
|
const before = measured(written);
|
|
284
396
|
const readBefore = pairs.filter((pair) => reads(pair, before));
|
|
285
397
|
const apartBefore = apart(written);
|
|
@@ -330,6 +442,51 @@ function fileProblem(folder, name, kinds) {
|
|
|
330
442
|
const size = statSync(path).size;
|
|
331
443
|
return size > mostBytes ? `"${name}" weighs ${Math.round(size / 1000)} KB; a theme's file weighs at most ${mostBytes / 1000} KB` : undefined;
|
|
332
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* What keeps an SVG from being drawn in one colour, as the cards' texture is, so that the page knows the colour under every word: a paint other than
|
|
447
|
+
* currentColor, or what brings colours of its own, a style, a picture, foreign content, a filter, an animation that changes them.
|
|
448
|
+
*/
|
|
449
|
+
function oneColourProblems(svg) {
|
|
450
|
+
const paints = [...svg.matchAll(/\b(fill|stroke|stop-color|flood-color|lighting-color|color)\s*(?:=\s*(["'])(.*?)\2|:\s*([^;"'}>]+))/gi)]
|
|
451
|
+
.map((match) => (match[3] ?? match[4]).trim())
|
|
452
|
+
.filter((paint) => !/^(currentcolor|none|inherit|transparent|url\(\s*['"]?#[^)]*\))$/i.test(paint));
|
|
453
|
+
const elements = [...new Set([...svg.matchAll(/<(style|image|foreignObject|script|filter|set|animateColor|animate)\b/gi)].map((match) => match[1]))];
|
|
454
|
+
return [
|
|
455
|
+
...(paints.length === 0 ? [] : [`must draw in currentColor alone, which the page paints in card-grain; it paints ${[...new Set(paints)].slice(0, 4).join(", ")}`]),
|
|
456
|
+
...(elements.length === 0 ? [] : [`must draw with shapes alone; it has ${elements.map((element) => `<${element}>`).join(", ")}`]),
|
|
457
|
+
];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* What a theme's own style sheet must not do: import another sheet, or name in url() what is not a picture of its folder. A help to its author, not a wall:
|
|
461
|
+
* the page's content security policy keeps the sheet from reaching the web.
|
|
462
|
+
*/
|
|
463
|
+
function styleProblems(folder, style) {
|
|
464
|
+
const css = withoutComments(readFileSync(join(folder, style), "utf8"));
|
|
465
|
+
const imports = /@import\b/i.test(css) ? [`style: ${style} must not @import: write its rules in it, and name its pictures with url()`] : [];
|
|
466
|
+
const urls = styleUrls(css).flatMap((url) => {
|
|
467
|
+
const problem = urlProblem(folder, style, url);
|
|
468
|
+
return problem === undefined ? [] : [`style: url(${url}) in ${style}: ${problem}`];
|
|
469
|
+
});
|
|
470
|
+
return [...imports, ...urls];
|
|
471
|
+
}
|
|
472
|
+
/** What is wrong with a url() of a theme's style sheet, if anything: an element of the page, as url(#glow), is fine; a file is a picture of its folder. */
|
|
473
|
+
function urlProblem(folder, style, url) {
|
|
474
|
+
const instead = "put the picture in the theme's folder and name it from the sheet, such as images/ruled.svg";
|
|
475
|
+
if (url.startsWith("#")) {
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
if (/^data:/i.test(url)) {
|
|
479
|
+
return `the page blocks a data: address; ${instead}`;
|
|
480
|
+
}
|
|
481
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(url) || url.startsWith("//")) {
|
|
482
|
+
return `a theme never reaches the web, and the page blocks it; ${instead}`;
|
|
483
|
+
}
|
|
484
|
+
if (url.startsWith("/")) {
|
|
485
|
+
return "an address from / is the page's, not the theme's folder; write it from the sheet, such as images/ruled.svg";
|
|
486
|
+
}
|
|
487
|
+
const problem = fileProblem(folder, fromStyle(style, url), pictureFiles);
|
|
488
|
+
return problem === undefined ? undefined : `${problem}; its url() name pictures of the theme's folder, written from the sheet`;
|
|
489
|
+
}
|
|
333
490
|
/** The files of the same folder, to say which one was meant. */
|
|
334
491
|
function similar(folder, name) {
|
|
335
492
|
const place = join(folder, name.split(/[\\/]/).slice(0, -1).join(sep));
|
package/instructions/core.md
CHANGED
|
@@ -41,6 +41,7 @@ You are the game master of this table. It is a craft, and you inhabit it as an a
|
|
|
41
41
|
|
|
42
42
|
- `mode`: when status says nothing is missing for the next mode and the player confirms.
|
|
43
43
|
- `config`: whenever the player sets or changes a setting, in any mode.
|
|
44
|
+
- Git or GitHub for the campaign: `config git` commit or push, and the engine commits by itself at each session start, save and scene end; you make only the private repository and its remote, when asked, never a hook.
|
|
44
45
|
- `find`, `show`: read a page before describing anything that already exists.
|
|
45
46
|
- `rules`: whenever you are unsure how a rule works, before you rule and say what is at stake, and when the player questions a ruling.
|
|
46
47
|
- `write`: record every new fact at once.
|
|
@@ -5,5 +5,5 @@ How the player uses their dashboard, to answer in a few words, as part of the ga
|
|
|
5
5
|
- Journal: the quests, those followed with their star beside the page; the story by scenes; the companions' diaries; their own notes, which they may share with you.
|
|
6
6
|
- World: what their character knows of the world, in four tabs: Map, the places they know with distances; Lore, the pages they know; Documents, what they have read; Calendar, the days and what is set on them.
|
|
7
7
|
- On a page they see, as a character, a place or a quest, a button gives it a picture of their own in place of the one it has; your next call says so.
|
|
8
|
-
- The icons at the row's end: Saves, to save or go back as the campaign's saves setting allows; Help, how to play with the chat and the page; Settings, the same as `config` (difficulty, dice digital or physical, units, language, pictures, lines and veils, mentor); Packages, the game systems, extensions and languages on this computer, and RPG Engine's own update, which the player makes there, never you, and in its menu the pages a game system or extension adds; About.
|
|
8
|
+
- The icons at the row's end: Saves, to save or go back as the campaign's saves setting allows; Help, how to play with the chat and the page; Settings, the same as `config` (difficulty, dice digital or physical, units, language, pictures, lines and veils, mentor, git where the campaign is a git repository); Packages, the game systems, extensions and languages on this computer, and RPG Engine's own update, which the player makes there, never you, and in its menu the pages a game system or extension adds; About.
|
|
9
9
|
- When you call `ask`, the buttons appear on the page too: a click rolls the dice of a check, or with "By hand" a click on the lit row of their sheet or a throw of the tray's dice, and they may write their own words instead; their own dice are the physical setting, and then they give you the faces in the chat. They may also propose changes to their character's story there, which reach you to write with their yes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Play a tabletop role-playing game with an AI as your game master: the AI tells the story; RPG Engine remembers the world, rolls the dice and keeps the accounts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|