rpg-engine 0.19.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.d.ts +3 -0
- package/dist/adventures/source.js +11 -49
- package/dist/campaign/create-campaign.d.ts +1 -1
- package/dist/campaign/create-campaign.js +4 -3
- package/dist/campaign/find-campaign.d.ts +6 -0
- package/dist/campaign/find-campaign.js +7 -1
- package/dist/campaign/host-files.js +22 -0
- package/dist/campaign/index.d.ts +2 -2
- package/dist/campaign/index.js +2 -2
- package/dist/campaign/last-choices.d.ts +10 -4
- package/dist/campaign/last-choices.js +43 -17
- package/dist/campaign/settings.d.ts +10 -2
- package/dist/campaign/settings.js +32 -8
- package/dist/chats/chat.d.ts +33 -0
- package/dist/chats/chat.js +50 -0
- package/dist/chats/claude-code.d.ts +5 -0
- package/dist/chats/claude-code.js +39 -0
- package/dist/chats/codex.d.ts +3 -0
- package/dist/chats/codex.js +42 -0
- package/dist/chats/index.d.ts +5 -0
- package/dist/chats/index.js +12 -0
- package/dist/chats/keep.d.ts +10 -0
- package/dist/chats/keep.js +50 -0
- package/dist/chats/read.d.ts +8 -0
- package/dist/chats/read.js +46 -0
- package/dist/cli/cli.js +6 -1
- package/dist/cli/command-line.js +3 -2
- package/dist/commands/book.d.ts +36 -0
- package/dist/commands/book.js +129 -0
- package/dist/commands/chats.d.ts +38 -0
- package/dist/commands/chats.js +93 -0
- package/dist/commands/config/config.js +2 -2
- package/dist/commands/config/dashboard.d.ts +8 -1
- package/dist/commands/config/dashboard.js +70 -16
- package/dist/commands/config/words.d.ts +1 -1
- package/dist/commands/config/words.js +18 -5
- package/dist/commands/find.js +1 -1
- package/dist/commands/image.d.ts +14 -0
- package/dist/commands/image.js +100 -20
- package/dist/commands/index.js +4 -0
- package/dist/commands/init.js +3 -3
- package/dist/commands/package/data.d.ts +35 -0
- package/dist/commands/package/data.js +117 -0
- package/dist/commands/package/here.d.ts +7 -2
- package/dist/commands/package/here.js +23 -11
- package/dist/commands/package/install.js +14 -15
- package/dist/commands/package/language.d.ts +15 -0
- package/dist/commands/package/language.js +109 -0
- package/dist/commands/package/package.js +20 -10
- package/dist/commands/package/result.d.ts +19 -0
- package/dist/commands/package/theme.d.ts +13 -0
- package/dist/commands/package/theme.js +66 -0
- package/dist/commands/package/uninstall.d.ts +4 -1
- package/dist/commands/package/uninstall.js +29 -9
- package/dist/commands/scene/close.d.ts +2 -0
- package/dist/commands/scene/close.js +20 -2
- package/dist/commands/scene/result.d.ts +2 -0
- package/dist/commands/scene/scene.d.ts +2 -0
- package/dist/commands/shared/books/adventures.d.ts +0 -4
- package/dist/commands/shared/books/adventures.js +2 -31
- package/dist/commands/shared/books/words.js +3 -2
- package/dist/commands/shared/campaign/book.d.ts +42 -0
- package/dist/commands/shared/campaign/book.js +118 -0
- package/dist/commands/shared/campaign/chats.d.ts +11 -0
- package/dist/commands/shared/campaign/chats.js +29 -0
- package/dist/commands/shared/campaign/images.js +7 -1
- package/dist/commands/shared/campaign/mode.js +3 -1
- package/dist/commands/shared/campaign/saves.js +13 -5
- package/dist/commands/shared/campaign/world.js +2 -1
- package/dist/commands/shared/packages/catalog.d.ts +3 -3
- package/dist/commands/shared/packages/catalog.js +98 -42
- package/dist/commands/shared/packages/unpacked.d.ts +50 -0
- package/dist/commands/shared/packages/unpacked.js +146 -0
- package/dist/commands/shared/sheet/sheet.d.ts +7 -0
- package/dist/commands/shared/sheet/sheet.js +27 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +4 -0
- package/dist/commands/view/page.js +4 -3
- package/dist/commands/view/result.d.ts +2 -0
- package/dist/commands/view/view.d.ts +1 -0
- package/dist/commands/view/view.js +4 -0
- package/dist/core/archive.d.ts +13 -0
- package/dist/core/archive.js +76 -0
- package/dist/core/consents.d.ts +2 -2
- package/dist/core/consents.js +3 -3
- package/dist/core/context.d.ts +40 -2
- package/dist/core/context.js +1 -0
- package/dist/core/download.js +1 -1
- package/dist/core/store.d.ts +5 -1
- package/dist/core/store.js +15 -2
- package/dist/dashboard/acts/names.js +10 -5
- package/dist/dashboard/acts/sending.js +5 -2
- package/dist/dashboard/acts/sheet.js +66 -15
- package/dist/dashboard/api.js +27 -4
- package/dist/dashboard/app.js +9 -4
- package/dist/dashboard/guide/ar.md +16 -15
- package/dist/dashboard/guide/cs.md +15 -14
- package/dist/dashboard/guide/da.md +17 -16
- package/dist/dashboard/guide/de.md +17 -16
- package/dist/dashboard/guide/el.md +17 -16
- package/dist/dashboard/guide/en.md +14 -13
- package/dist/dashboard/guide/es.md +15 -14
- package/dist/dashboard/guide/fi.md +15 -14
- package/dist/dashboard/guide/fr.md +20 -19
- package/dist/dashboard/guide/he.md +15 -14
- package/dist/dashboard/guide/hi.md +15 -14
- package/dist/dashboard/guide/hu.md +19 -18
- package/dist/dashboard/guide/is.md +15 -14
- package/dist/dashboard/guide/it.md +18 -17
- package/dist/dashboard/guide/ja.md +15 -14
- package/dist/dashboard/guide/ko.md +16 -15
- package/dist/dashboard/guide/nb.md +17 -16
- package/dist/dashboard/guide/nl.md +15 -14
- package/dist/dashboard/guide/pl.md +16 -15
- package/dist/dashboard/guide/pt.md +16 -15
- package/dist/dashboard/guide/ro.md +15 -14
- package/dist/dashboard/guide/ru.md +16 -15
- package/dist/dashboard/guide/sv.md +15 -14
- package/dist/dashboard/guide/tr.md +18 -17
- package/dist/dashboard/guide/uk.md +19 -18
- package/dist/dashboard/guide/zh.md +16 -15
- package/dist/dashboard/i18n/ar.json +63 -9
- package/dist/dashboard/i18n/cs.json +63 -9
- package/dist/dashboard/i18n/da.json +63 -9
- package/dist/dashboard/i18n/de.json +63 -9
- package/dist/dashboard/i18n/el.json +63 -9
- package/dist/dashboard/i18n/es.json +63 -9
- package/dist/dashboard/i18n/fi.json +63 -9
- package/dist/dashboard/i18n/fr.json +63 -9
- package/dist/dashboard/i18n/he.json +63 -9
- package/dist/dashboard/i18n/hi.json +63 -9
- package/dist/dashboard/i18n/hu.json +63 -9
- package/dist/dashboard/i18n/is.json +63 -9
- package/dist/dashboard/i18n/it.json +64 -10
- package/dist/dashboard/i18n/ja.json +63 -9
- package/dist/dashboard/i18n/ko.json +63 -9
- package/dist/dashboard/i18n/nb.json +63 -9
- package/dist/dashboard/i18n/nl.json +63 -9
- package/dist/dashboard/i18n/pl.json +63 -9
- package/dist/dashboard/i18n/pt.json +63 -9
- package/dist/dashboard/i18n/ro.json +63 -9
- package/dist/dashboard/i18n/ru.json +63 -9
- package/dist/dashboard/i18n/sv.json +63 -9
- package/dist/dashboard/i18n/tr.json +63 -9
- package/dist/dashboard/i18n/uk.json +63 -9
- package/dist/dashboard/i18n/zh.json +63 -9
- package/dist/dashboard/journal/book.js +107 -0
- package/dist/dashboard/journal/journal.js +16 -12
- package/dist/dashboard/kit.js +1 -1
- package/dist/dashboard/packages/catalog.js +31 -14
- package/dist/dashboard/packages/engine.js +46 -2
- package/dist/dashboard/packages/installed.js +13 -0
- package/dist/dashboard/packages/outcomes.js +21 -0
- package/dist/dashboard/packages/packages.js +41 -18
- package/dist/dashboard/packages/rows.js +3 -1
- package/dist/dashboard/parts/icons.js +3 -0
- package/dist/dashboard/parts/labels.js +6 -0
- package/dist/dashboard/parts/picture.js +89 -0
- package/dist/dashboard/parts/refusals.js +8 -1
- package/dist/dashboard/parts/widgets.js +3 -2
- package/dist/dashboard/place/view.js +1 -1
- package/dist/dashboard/play/scene.js +8 -5
- package/dist/dashboard/settings/settings.js +32 -16
- package/dist/dashboard/settings/setup.js +5 -3
- package/dist/dashboard/sheet/party.js +5 -2
- package/dist/dashboard/sheet/sheet.js +10 -6
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/shell/system-style.js +45 -12
- package/dist/dashboard/shell/tooltip.js +223 -0
- package/dist/dashboard/style.css +775 -261
- package/dist/dashboard/world/calendar.js +1 -1
- package/dist/dashboard/world/lore.js +5 -4
- package/dist/dashboard/world/place-card.js +2 -1
- package/dist/helpers/briefs.d.ts +5 -0
- package/dist/helpers/briefs.js +8 -0
- package/dist/helpers/chosen.d.ts +8 -2
- package/dist/helpers/chosen.js +110 -6
- package/dist/helpers/codex.js +2 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/index.js +2 -2
- package/dist/images/images.d.ts +2 -0
- package/dist/images/images.js +16 -2
- package/dist/images/index.d.ts +1 -1
- package/dist/images/index.js +1 -1
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/pack.d.ts +4 -1
- package/dist/languages/pack.js +16 -5
- package/dist/packages/engine.d.ts +7 -0
- package/dist/packages/engine.js +32 -1
- package/dist/packages/index.d.ts +1 -1
- package/dist/packages/index.js +1 -1
- package/dist/server/approver.d.ts +6 -0
- package/dist/server/approver.js +28 -0
- package/dist/server/chats.d.ts +3 -0
- package/dist/server/chats.js +27 -0
- package/dist/server/dashboard/engine.d.ts +18 -0
- package/dist/server/dashboard/engine.js +31 -0
- package/dist/server/dashboard/files.d.ts +8 -1
- package/dist/server/dashboard/files.js +30 -10
- package/dist/server/dashboard/index.d.ts +3 -0
- package/dist/server/dashboard/index.js +10 -1
- package/dist/server/dashboard/news.js +36 -5
- package/dist/server/dashboard/pictures.d.ts +7 -0
- package/dist/server/dashboard/pictures.js +62 -0
- package/dist/server/dashboard/writes.d.ts +5 -3
- package/dist/server/dashboard/writes.js +45 -14
- package/dist/server/mcp.js +37 -6
- package/dist/server/player-acts.d.ts +7 -2
- package/dist/server/player-acts.js +10 -3
- package/dist/testing/index.js +1 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +4 -2
- package/dist/themes/installed.d.ts +14 -0
- package/dist/themes/installed.js +28 -0
- package/dist/themes/theme.d.ts +7 -0
- package/dist/themes/theme.js +22 -0
- package/instructions/core.md +3 -3
- package/instructions/dashboard-guide.md +1 -0
- package/instructions/mentor-hints.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/party.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/start.md +1 -1
- package/package.json +2 -2
- package/systems/free/instructions/outcomes-told.md +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// A package of data someone else made, read whole into memory (ADV-1): a .zip unpacked with its size capped and its names read as UTF-8, then each path
|
|
2
|
+
// checked, what a computer leaves beside files dropped, and the one folder GitHub zips a repository in taken away.
|
|
3
|
+
import { unzipSync } from "fflate";
|
|
4
|
+
import { archivePathParts } from "./archive-paths.js";
|
|
5
|
+
import { Refusal } from "./refusal.js";
|
|
6
|
+
// What a computer leaves beside files, which no one put in the package.
|
|
7
|
+
const litter = /^(\..*|__macosx|thumbs\.db|desktop\.ini)$/i;
|
|
8
|
+
/** The files a .zip holds, by their names as written, unpacking to at most `most` bytes; it throws, saying why, when it does not read. `what` names the package: an adventure. */
|
|
9
|
+
export function unzipFiles(bytes, label, most, what) {
|
|
10
|
+
let declared = 0;
|
|
11
|
+
let read;
|
|
12
|
+
try {
|
|
13
|
+
read = unzipSync(bytes, {
|
|
14
|
+
filter: (file) => {
|
|
15
|
+
declared += file.originalSize;
|
|
16
|
+
if (declared > most) {
|
|
17
|
+
throw new Error(`it unpacks to more than ${most / 1024 / 1024} MB, more than ${what} may`);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new Refusal(`${label} is not a .zip that reads: ${error instanceof Error ? error.message : String(error)}. Nothing changed.`, "archive-unread", { name: label });
|
|
25
|
+
}
|
|
26
|
+
return Object.entries(read).filter(([name]) => !/[\\/]$/.test(name)).map(([name, data]) => [utf8Name(label, name), data]);
|
|
27
|
+
}
|
|
28
|
+
/** The files a .zip holds, by their names as written, with what each unpacks to, none of them unpacked: to tell what it is before reading it. */
|
|
29
|
+
export function zipListing(bytes, label) {
|
|
30
|
+
const listed = [];
|
|
31
|
+
try {
|
|
32
|
+
unzipSync(bytes, {
|
|
33
|
+
filter: (file) => {
|
|
34
|
+
listed.push([file.name, file.originalSize]);
|
|
35
|
+
return false;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Refusal(`${label} is not a .zip that reads: ${error instanceof Error ? error.message : String(error)}. Nothing changed.`, "archive-unread", { name: label });
|
|
41
|
+
}
|
|
42
|
+
return listed.filter(([name]) => !/[\\/]$/.test(name)).map(([name, size]) => [utf8Name(label, name), size]);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A package's files: each path checked, what a computer leaves beside them dropped, and the one folder at its top that holds them all taken away while none of
|
|
46
|
+
* `tops`, the files that tell what it is, lies at its top. `what` names it in a refusal: the adventure.
|
|
47
|
+
*/
|
|
48
|
+
export function packageEntries(label, entries, what, tops) {
|
|
49
|
+
// What a computer leaves beside the files, as macOS's __MACOSX, goes before the folder at the top is looked for.
|
|
50
|
+
const checked = entries.map(([name, data]) => [archivePathParts(label, name, what), data]).filter(([parts]) => parts.length > 0 && !parts.some((part) => litter.test(part)));
|
|
51
|
+
const atTop = checked.some(([parts]) => parts.length === 1 && tops.includes(parts[0].toLowerCase()));
|
|
52
|
+
const folders = new Set(checked.map(([parts]) => parts[0]));
|
|
53
|
+
return !atTop && folders.size === 1 ? checked.map(([parts, data]) => [parts.slice(1), data]).filter(([parts]) => parts.length > 0) : checked;
|
|
54
|
+
}
|
|
55
|
+
/** The file at a package's top named so, in any case; undefined when there is none. */
|
|
56
|
+
export function topFile(entries, name) {
|
|
57
|
+
return entries.find(([parts]) => parts.length === 1 && parts[0].toLowerCase() === name);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A file's name in a .zip as it was written: one without the zip's UTF-8 mark reads byte by byte, so its UTF-8 is read again, as macOS writes it; one in an old
|
|
61
|
+
* code page, as Windows' own tar writes it, is refused with what to do.
|
|
62
|
+
*/
|
|
63
|
+
function utf8Name(label, name) {
|
|
64
|
+
if (/^[\u0000-ÿ]*$/.test(name) && /[\u0080-ÿ]/.test(name)) {
|
|
65
|
+
try {
|
|
66
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(name, (character) => character.charCodeAt(0))).normalize("NFC");
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Not UTF-8 byte by byte: a name the zip marked as UTF-8 already, or one in an old code page.
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (/[\u0080-\u009f]/.test(name)) {
|
|
73
|
+
throw new Refusal(`${label} names a file with accents not written in UTF-8 (${name}): make the zip again with 7-Zip, or Compress-Archive in PowerShell. Nothing changed.`, "archive-accents", { name: label });
|
|
74
|
+
}
|
|
75
|
+
return name.normalize("NFC");
|
|
76
|
+
}
|
package/dist/core/consents.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export declare const ourScope = "@rpgengine/";
|
|
|
7
7
|
export declare function packageCodeMayRun(folder: string): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* The fingerprint of a package's files as installed, and of its dependencies' as npm resolved them: every file but those npm or git keep beside them, by its
|
|
10
|
-
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or
|
|
11
|
-
* at each load of the package's code.
|
|
10
|
+
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or times changed (ctime too,
|
|
11
|
+
* since npm installs every file with one fixed mtime): it is asked at each load of the package's code.
|
|
12
12
|
*/
|
|
13
13
|
export declare function packageFingerprint(folder: string): string;
|
|
14
14
|
/** Records the player's yes to a package installed in a folder of npm's packages: its version and its files as they are now. */
|
package/dist/core/consents.js
CHANGED
|
@@ -29,14 +29,14 @@ export function packageCodeMayRun(folder) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* The fingerprint of a package's files as installed, and of its dependencies' as npm resolved them: every file but those npm or git keep beside them, by its
|
|
32
|
-
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or
|
|
33
|
-
* at each load of the package's code.
|
|
32
|
+
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or times changed (ctime too,
|
|
33
|
+
* since npm installs every file with one fixed mtime): it is asked at each load of the package's code.
|
|
34
34
|
*/
|
|
35
35
|
export function packageFingerprint(folder) {
|
|
36
36
|
const paths = withDependencies(folder).flatMap(packageFiles);
|
|
37
37
|
const signature = paths.map((path) => {
|
|
38
38
|
const stat = statSync(path);
|
|
39
|
-
return `${path}|${stat.size}|${stat.mtimeMs}`;
|
|
39
|
+
return `${path}|${stat.size}|${stat.mtimeMs}|${stat.ctimeMs}`;
|
|
40
40
|
}).join("\n");
|
|
41
41
|
const known = fingerprints.get(folder);
|
|
42
42
|
if (known?.signature === signature) {
|
package/dist/core/context.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface Context {
|
|
|
39
39
|
}>;
|
|
40
40
|
/** The folders that hold the installed extensions, each a package folder or npm's node_modules (D-436); none where missing. */
|
|
41
41
|
extensionFolders?: string[];
|
|
42
|
+
/** Where the packages of data alone are unpacked, for every campaign on this computer: themes/<id>/ and languages/<code>/; none where nothing installs them. */
|
|
43
|
+
unpacked?: string;
|
|
42
44
|
/** The AI app the MCP server serves, by the name it gives itself, such as claude-code; missing on the command line. */
|
|
43
45
|
host?: () => string | undefined;
|
|
44
46
|
/** The packages the player said no to in a window in this session, by the name npm describes: never asked again until the server starts again (D-510). */
|
|
@@ -73,6 +75,8 @@ export interface Context {
|
|
|
73
75
|
};
|
|
74
76
|
/** What makes pictures from words on this computer (D-308), as Codex with the player's login; missing where none can, as in tests. */
|
|
75
77
|
pictures?: PictureMaker;
|
|
78
|
+
/** Lines for the master's next call, as of a picture that came after its call answered (D-572); MCP only. */
|
|
79
|
+
later?: LaterLines;
|
|
76
80
|
/** What writes text from a brief on this computer, outside the chat, as Codex or Claude Code with the player's login (D-406); missing where none can. */
|
|
77
81
|
writer?: TextWriter;
|
|
78
82
|
/** A game system's pages translated on this computer as a player first reads them, where the system has no translation of its own (D-539); missing elsewhere. */
|
|
@@ -96,6 +100,19 @@ export interface Context {
|
|
|
96
100
|
pageFolder?: string;
|
|
97
101
|
/** Codex and Claude Code on this computer, installed and signed in with the player's yes (D-424); missing outside the MCP server, as in tests. */
|
|
98
102
|
helpers?: Helpers;
|
|
103
|
+
/** Where the AI hosts keep their chats on this computer, which the MCP server copies into the campaign (T-225); missing elsewhere, as in tests. */
|
|
104
|
+
chatFolders?: ChatFolders;
|
|
105
|
+
}
|
|
106
|
+
/** The folders where Claude Code and Codex keep their chats, each in its own way (T-225). */
|
|
107
|
+
export interface ChatFolders {
|
|
108
|
+
claudeCode: string;
|
|
109
|
+
codex: string;
|
|
110
|
+
}
|
|
111
|
+
/** Lines for the master at the head of their next call: added as they come, taken by the call, given back by one whose answer never goes. */
|
|
112
|
+
export interface LaterLines {
|
|
113
|
+
add(line: string): void;
|
|
114
|
+
take(): string[];
|
|
115
|
+
giveBack(lines: string[]): void;
|
|
99
116
|
}
|
|
100
117
|
/** A game system's pages a player reads, translated into the campaign's language in the background where they lack it (D-539). */
|
|
101
118
|
export interface SystemTexts {
|
|
@@ -239,16 +256,31 @@ export interface DocumentReader {
|
|
|
239
256
|
}
|
|
240
257
|
/**
|
|
241
258
|
* Whether pictures can be made here, or why not, in words the master can tell the player, and in the player's own with the steps to have them, one a line,
|
|
242
|
-
* numbered, with the commands between backticks (D-341).
|
|
259
|
+
* numbered, with the commands between backticks (D-341). Ready, who makes them, as Codex, Claude or Antigravity, and the master's own image tool it names, as
|
|
260
|
+
* ElevenLabs, or that the player is to name it (D-572).
|
|
243
261
|
*/
|
|
244
262
|
export type PicturesReady = {
|
|
245
263
|
ready: true;
|
|
246
|
-
maker?:
|
|
264
|
+
maker?: string;
|
|
265
|
+
tool?: string;
|
|
266
|
+
askTool?: true;
|
|
267
|
+
instead?: PictureFallback;
|
|
247
268
|
} | {
|
|
248
269
|
ready: false;
|
|
249
270
|
why: string;
|
|
250
271
|
fix?: string;
|
|
251
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* Why the maker the player chose made no picture and the chat in use makes it (D-572): its name, who makes it in its place, its reason, how the player has
|
|
275
|
+
* it, and whether it refused a picture.
|
|
276
|
+
*/
|
|
277
|
+
export interface PictureFallback {
|
|
278
|
+
maker: string;
|
|
279
|
+
by: string;
|
|
280
|
+
why: string;
|
|
281
|
+
fix?: string;
|
|
282
|
+
refused?: true;
|
|
283
|
+
}
|
|
252
284
|
/**
|
|
253
285
|
* What a picture shows (D-308, D-388, D-408): a place as the party sees it arriving, a quest as the character knows it, or the portrait of one of the party as
|
|
254
286
|
* the player sees them; never what the table keeps out.
|
|
@@ -265,14 +297,20 @@ export interface PictureSubject {
|
|
|
265
297
|
export interface MadePicture {
|
|
266
298
|
file: string;
|
|
267
299
|
done(): void;
|
|
300
|
+
/** Made by the chat in use in place of the maker the player chose, and why (D-572). */
|
|
301
|
+
instead?: PictureFallback;
|
|
268
302
|
}
|
|
269
303
|
/** What makes a picture from a brief: whether it can, and the picture, or why none came. */
|
|
270
304
|
export interface PictureMaker {
|
|
271
305
|
/** Asked once; with again, a no a minute old or more is asked once more, as after the player logs in. */
|
|
272
306
|
ready(again?: boolean): PicturesReady;
|
|
307
|
+
/** A picture, or why none came; onlyThis when the next may come, as after a safety check or a timeout (D-572). */
|
|
273
308
|
make(subject: PictureSubject): Promise<MadePicture | {
|
|
274
309
|
refused: string;
|
|
310
|
+
onlyThis?: true;
|
|
275
311
|
}>;
|
|
312
|
+
/** Where the chat makes the picture itself with its own tool (D-390), as Antigravity: the brief it follows; the engine then starts nothing. */
|
|
313
|
+
brief?(subject: PictureSubject): string | undefined;
|
|
276
314
|
}
|
|
277
315
|
/** The player's own words in place of a button, as the dashboard's page lets them write (ASK-10). */
|
|
278
316
|
export interface Said {
|
package/dist/core/context.js
CHANGED
|
@@ -16,6 +16,7 @@ export function defaultContext(folder = process.cwd()) {
|
|
|
16
16
|
// From src/core/ and from dist/core/ alike, the package's systems/ folder is two levels up; then those npm installed (D-485).
|
|
17
17
|
systemFolders: [engineSystemsFolder, join(packagesFolder(), "node_modules")],
|
|
18
18
|
extensionFolders: [join(packagesFolder(), "node_modules")],
|
|
19
|
+
unpacked: join(packagesFolder(), "unpacked"),
|
|
19
20
|
home: userDataFolder(),
|
|
20
21
|
bookIndex: join(dirname(packagesFolder()), "library"),
|
|
21
22
|
// The built page is in dist/dashboard, two levels up from src/core/ and from dist/core/ alike.
|
package/dist/core/download.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function downloadBytes(url, most, signal) {
|
|
|
30
30
|
throw new Error(`${url} stopped half way (${error instanceof Error ? error.message : String(error)}): check the address, or download it and give the file.`);
|
|
31
31
|
}
|
|
32
32
|
if (size > most) {
|
|
33
|
-
throw new Error(`${url} is more than ${most / 1024 / 1024} MB, more than
|
|
33
|
+
throw new Error(`${url} is more than ${most / 1024 / 1024} MB, more than may be taken from it.`);
|
|
34
34
|
}
|
|
35
35
|
const bytes = new Uint8Array(size);
|
|
36
36
|
let at = 0;
|
package/dist/core/store.d.ts
CHANGED
|
@@ -58,10 +58,14 @@ export declare class FileStore {
|
|
|
58
58
|
makeFolder(path: string): void;
|
|
59
59
|
/** How many bytes a file has, as the disk says now, without reading it; undefined when there is none. */
|
|
60
60
|
size(path: string): number | undefined;
|
|
61
|
-
/** When a file last changed, in milliseconds, as the disk says now; undefined when there is none. */
|
|
61
|
+
/** When a file or a folder last changed, in milliseconds, as the disk says now; undefined when there is none. */
|
|
62
62
|
modified(path: string): number | undefined;
|
|
63
63
|
/** Removes a file. */
|
|
64
64
|
remove(path: string): void;
|
|
65
|
+
/** Removes a folder with all it holds, if it is there: what the store kept of it goes too. */
|
|
66
|
+
removeFolder(path: string): void;
|
|
67
|
+
/** Moves a file or a folder to a path of the same disk where nothing is, in one step: no one reads it half there. */
|
|
68
|
+
move(from: string, to: string): void;
|
|
65
69
|
protected entry(path: string): Kept;
|
|
66
70
|
/**
|
|
67
71
|
* A file of an installed game system as the process last read it, while it has not changed since, nor in the two seconds before; undefined for any other
|
package/dist/core/store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The files as a command sees them (D-137, D-194): each read at most once in a call, kept as its text and as what it reads as, frozen; what the command writes
|
|
2
2
|
// updates what is kept. A command runs inside its store, and the modules reach it with files(): the MCP server will keep one for a whole session.
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
import { appendFileSync, closeSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { appendFileSync, closeSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { fileOrder, filesIn } from "./files.js";
|
|
7
7
|
import { frozen } from "./frozen.js";
|
|
@@ -143,7 +143,7 @@ export class FileStore {
|
|
|
143
143
|
size(path) {
|
|
144
144
|
return existsSync(path) && statSync(path).isFile() ? statSync(path).size : undefined;
|
|
145
145
|
}
|
|
146
|
-
/** When a file last changed, in milliseconds, as the disk says now; undefined when there is none. */
|
|
146
|
+
/** When a file or a folder last changed, in milliseconds, as the disk says now; undefined when there is none. */
|
|
147
147
|
modified(path) {
|
|
148
148
|
return existsSync(path) ? statSync(path).mtimeMs : undefined;
|
|
149
149
|
}
|
|
@@ -153,6 +153,19 @@ export class FileStore {
|
|
|
153
153
|
this.changed(path, { text: undefined }, false);
|
|
154
154
|
markWritten();
|
|
155
155
|
}
|
|
156
|
+
/** Removes a folder with all it holds, if it is there: what the store kept of it goes too. */
|
|
157
|
+
removeFolder(path) {
|
|
158
|
+
rmSync(path, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
159
|
+
this.refresh(path);
|
|
160
|
+
markWritten();
|
|
161
|
+
}
|
|
162
|
+
/** Moves a file or a folder to a path of the same disk where nothing is, in one step: no one reads it half there. */
|
|
163
|
+
move(from, to) {
|
|
164
|
+
renameSync(from, to);
|
|
165
|
+
this.refresh(from);
|
|
166
|
+
this.refresh(to);
|
|
167
|
+
markWritten();
|
|
168
|
+
}
|
|
156
169
|
entry(path) {
|
|
157
170
|
const key = resolve(path);
|
|
158
171
|
let entry = this.kept.get(key);
|
|
@@ -3,18 +3,23 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
|
|
|
3
3
|
import { createContext } from "preact";
|
|
4
4
|
import { useContext } from "preact/hooks";
|
|
5
5
|
import { t } from "../text.js";
|
|
6
|
-
import {
|
|
6
|
+
import { verbLabel } from "./acts.js";
|
|
7
7
|
/** The player's actions where the page has them: none for a system that names none, and the page is as it was. */
|
|
8
8
|
export const PlayerActsContext = createContext(undefined);
|
|
9
9
|
/** The player's actions, when the page has them. */
|
|
10
10
|
export function usePlayerActs() {
|
|
11
11
|
return useContext(PlayerActsContext);
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A thing's name that opens its card (D-495): what it is, then its verbs; with none, only what it is. Its tooltip names its verbs; `page`, the thing's page
|
|
15
|
+
* when the name shown is another; `facts`, what the sheet says of it; `said`, what a screen reader hears after it.
|
|
16
|
+
*/
|
|
17
|
+
export function ActName({ verbs, item, page, facts, document, said = "", children }) {
|
|
15
18
|
const acts = usePlayerActs();
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
// The click opens the card: the tooltip names what can be done there, a screen reader the thing and what the sheet says of it.
|
|
20
|
+
const title = verbs.length === 0 ? undefined : verbs.map(verbLabel).join(" · ");
|
|
21
|
+
const start = { verbs, item, ...(page === undefined ? {} : { page }), ...(facts === undefined ? {} : { facts }), ...(document === undefined ? {} : { document }) };
|
|
22
|
+
return (_jsxs("button", { type: "button", class: verbs.length === 0 ? "act reads" : "act", "data-tip": title, "aria-label": `${item}${said}`, onClick: (event) => acts?.start(start, event.currentTarget), children: [children, verbs.length > 0 && _jsx("span", { class: "act-mark", "aria-hidden": "true", children: "\u203A" })] }));
|
|
18
23
|
}
|
|
19
24
|
/** Someone's name that starts talking to them (D-495), where the page has the player's actions; else the name as it is. */
|
|
20
25
|
export function TalkName({ name, children }) {
|
|
@@ -55,6 +55,7 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
55
55
|
// With a question of the master's open, the sentence answers it (ASK-10); else it rings the master, or, in a chat that hears nothing by itself, is copied.
|
|
56
56
|
const question = asked !== undefined && asked.spend === undefined && asked.forced !== true ? asked : undefined;
|
|
57
57
|
const reply = question !== undefined ? "answer" : acts?.bell === true ? "tell" : "copy";
|
|
58
|
+
const answering = question === undefined ? undefined : { question: question.question, buttons: question.labels.length > 0 };
|
|
58
59
|
const sendAct = async (text) => {
|
|
59
60
|
setActProblem(undefined);
|
|
60
61
|
if (reply === "answer" && question !== undefined) {
|
|
@@ -65,7 +66,9 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
65
66
|
if (reply === "copy") {
|
|
66
67
|
return await copyAct(text) ? undefined : t("Copy did not work: select the words and copy them yourself.");
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
// The thing it starts from, for the master to hear what the character already knows of it (T-218).
|
|
70
|
+
const item = acting !== undefined && "verbs" in acting.start ? acting.start.page ?? acting.start.item : undefined;
|
|
71
|
+
const result = await sayAct(text, item);
|
|
69
72
|
if ("error" in result) {
|
|
70
73
|
return result.error;
|
|
71
74
|
}
|
|
@@ -106,5 +109,5 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
106
109
|
requestAnimationFrame(() => opener?.isConnected === true && opener.focus());
|
|
107
110
|
};
|
|
108
111
|
const playerActs = actions === undefined || players.length === 0 ? undefined : { actions, start: (start, opener) => setActing({ start, opener }) };
|
|
109
|
-
return { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct };
|
|
112
|
+
return { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, answering, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct };
|
|
110
113
|
}
|
|
@@ -1,52 +1,100 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
|
+
import { sectionAddress } from "../address.js";
|
|
4
|
+
import { readView } from "../api.js";
|
|
3
5
|
import { Icon } from "../parts/icons.js";
|
|
6
|
+
import { fieldLabel, phraseLabel, shownText } from "../parts/labels.js";
|
|
7
|
+
import { Markdown } from "../parts/markdown.js";
|
|
4
8
|
import { PlaceMap } from "../place/view.js";
|
|
5
9
|
import { t } from "../text.js";
|
|
6
10
|
import { actPeople, actSentence, actTitle, spokenBy, talkSentence, targetMode, verbLabel } from "./acts.js";
|
|
7
11
|
// How many characters a sentence may have, as the server takes them.
|
|
8
12
|
const mostWords = 500;
|
|
9
13
|
/**
|
|
10
|
-
* The
|
|
11
|
-
* sends and Escape closes
|
|
14
|
+
* The card of an action (D-495, D-573): a thing first, its page's text and its verbs; a verb chosen, on whom as chips and on the place's map,
|
|
15
|
+
* then the sentence in a field, which Enter sends and Escape closes. A card in the middle, wider with the map; a sheet from the foot on a phone.
|
|
12
16
|
*/
|
|
13
|
-
export function ActSheet({ start, self, place, scene, companions, reply, onSend, onClose }) {
|
|
17
|
+
export function ActSheet({ start, self, place, scene, companions, reply, asked, onSend, onClose }) {
|
|
14
18
|
const dialog = useRef(null);
|
|
15
19
|
const field = useRef(null);
|
|
16
20
|
const list = useRef(null);
|
|
17
|
-
const
|
|
21
|
+
const verbsBar = useRef(null);
|
|
22
|
+
const closer = useRef(null);
|
|
23
|
+
const thing = "verbs" in start;
|
|
24
|
+
// A thing opens on itself until a verb is chosen; talking goes straight to the words.
|
|
25
|
+
const [verb, setVerb] = useState();
|
|
26
|
+
const acting = !thing || verb !== undefined;
|
|
18
27
|
const mode = verb === undefined ? "none" : targetMode(verb);
|
|
19
|
-
const [target, setTarget] = useState(
|
|
28
|
+
const [target, setTarget] = useState();
|
|
20
29
|
const [square, setSquare] = useState("");
|
|
21
30
|
const map = place?.map;
|
|
31
|
+
// With a map at the place, on whom is chosen on it too, by a click.
|
|
32
|
+
const mapShown = map !== undefined && place !== undefined && mode !== "none";
|
|
22
33
|
const people = actPeople(place, scene, companions, self);
|
|
23
34
|
const shownTarget = target === undefined ? "none" : target === "square" ? (square.trim() === "" ? "none" : { square: square.trim().toUpperCase() }) : target;
|
|
24
35
|
// With more than one player character the sentence starts with who acts (D-480 (8)).
|
|
25
36
|
const composed = spokenBy("talk" in start ? talkSentence(start.talk) : actSentence(verb ?? "use", start.item, shownTarget), self);
|
|
26
37
|
const [text, setText] = useState(composed);
|
|
27
|
-
// What the page wrote last: changed by the player, the sentence is theirs and a new
|
|
38
|
+
// What the page wrote last: changed by the player, the sentence is theirs and a new target leaves it as it is; a new verb writes it again.
|
|
28
39
|
const written = useRef(composed);
|
|
40
|
+
const writtenFor = useRef(verb);
|
|
29
41
|
const [problem, setProblem] = useState();
|
|
30
42
|
const [sending, setSending] = useState(false);
|
|
31
|
-
|
|
32
|
-
const
|
|
43
|
+
// The text of the thing's page: undefined while it is read, empty for a page of data alone, null when the character knows no page of it.
|
|
44
|
+
const [about, setAbout] = useState();
|
|
45
|
+
// What the page says of the thing as data, as damage and weight (D-573).
|
|
46
|
+
const [data, setData] = useState([]);
|
|
47
|
+
const title = "talk" in start ? t("Talk to {name}", { name: start.talk }) : verb === undefined ? start.item : actTitle(verb, start.item);
|
|
33
48
|
useEffect(() => {
|
|
34
|
-
if (text === written.current) {
|
|
49
|
+
if (text === written.current || writtenFor.current !== verb) {
|
|
35
50
|
setText(composed);
|
|
36
51
|
}
|
|
37
52
|
written.current = composed;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
53
|
+
writtenFor.current = verb;
|
|
54
|
+
}, [composed, verb]);
|
|
55
|
+
// A modal dialog lies over everything on the page and closes with Escape by itself; a thing's page is read once, when it opens.
|
|
41
56
|
useEffect(() => {
|
|
42
57
|
dialog.current?.showModal();
|
|
58
|
+
if (!thing) {
|
|
59
|
+
focusEnd(field.current);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
(verbsBar.current?.querySelector("a, button") ?? closer.current)?.focus();
|
|
63
|
+
let live = true;
|
|
64
|
+
readView(start.page ?? start.item).then((page) => {
|
|
65
|
+
if (live) {
|
|
66
|
+
setAbout(page.kind === "page" ? page.text.trim() : null);
|
|
67
|
+
setData(page.kind === "page" ? page.sheet.flatMap((group) => group.values) : []);
|
|
68
|
+
}
|
|
69
|
+
}, () => live && setAbout(null));
|
|
70
|
+
return () => {
|
|
71
|
+
live = false;
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
// The focus goes where the player chooses next: on whom, for a verb that needs someone; else the sentence, the cursor at its end.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (verb === undefined) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
43
79
|
if (mode === "asks") {
|
|
44
80
|
list.current?.querySelector("input[type=radio]")?.focus();
|
|
45
81
|
}
|
|
46
82
|
else {
|
|
47
83
|
focusEnd(field.current);
|
|
48
84
|
}
|
|
49
|
-
}, []);
|
|
85
|
+
}, [verb]);
|
|
86
|
+
const pick = (chosen) => {
|
|
87
|
+
setVerb(chosen);
|
|
88
|
+
setTarget(targetMode(chosen) === "lets" ? "none" : undefined);
|
|
89
|
+
setProblem(undefined);
|
|
90
|
+
};
|
|
91
|
+
// Back to the thing, the focus on the verb that was chosen.
|
|
92
|
+
const back = () => {
|
|
93
|
+
const was = verb;
|
|
94
|
+
setVerb(undefined);
|
|
95
|
+
setProblem(undefined);
|
|
96
|
+
requestAnimationFrame(() => verbsBar.current?.querySelector(`button[data-verb="${was ?? ""}"]`)?.focus());
|
|
97
|
+
};
|
|
50
98
|
const choose = (chosen) => {
|
|
51
99
|
setTarget(chosen);
|
|
52
100
|
setProblem(undefined);
|
|
@@ -80,11 +128,14 @@ export function ActSheet({ start, self, place, scene, companions, reply, onSend,
|
|
|
80
128
|
focusEnd(field.current);
|
|
81
129
|
}
|
|
82
130
|
};
|
|
131
|
+
const close = () => dialog.current?.close();
|
|
83
132
|
const personChosen = typeof target === "object" && "person" in target ? target.person : undefined;
|
|
84
133
|
const option = (key, chosen, label, kind = "") => (_jsxs("label", { class: ["act-who-one", kind].filter((name) => name !== "").join(" "), children: [_jsx("input", { type: "radio", name: "act-who", checked: sameTarget(target, chosen), onChange: () => choose(chosen), onKeyDown: toSentence }), label] }, key));
|
|
85
|
-
const full = choosing && map !== undefined;
|
|
86
134
|
const button = reply === "copy" ? t("Copy") : reply === "answer" ? t("Answer the master") : t("Tell the master");
|
|
87
|
-
|
|
135
|
+
const facts = thing ? start.facts ?? [] : [];
|
|
136
|
+
return (_jsxs("dialog", { ref: dialog, class: mapShown ? "map-sheet act-sheet wide" : "map-sheet act-sheet", "aria-labelledby": "act-sheet-title", "aria-describedby": !acting && facts.length > 0 ? "act-facts" : undefined, onClose: onClose, children: [_jsxs("header", { class: "map-sheet-head act-head", children: [thing && acting && (_jsx("button", { type: "button", class: "icon-button tip-right act-back", "aria-label": t("Back"), "data-tip": t("Back"), onClick: back, children: _jsx(Icon, { name: "fold" }) })), _jsxs("div", { class: "act-heading", children: [_jsx("h2", { id: "act-sheet-title", children: title }), !acting && facts.length > 0 && _jsx("p", { id: "act-facts", class: "act-facts", children: facts.join(" · ") })] }), _jsx("button", { ref: closer, type: "button", class: "icon-button tip-left", "aria-label": t("Close"), "data-tip": t("Close"), onClick: close, children: _jsx(Icon, { name: "close" }) })] }), thing && !acting && (_jsxs(_Fragment, { children: [data.length > 0 && (_jsx("dl", { class: "act-data", children: data.map((value) => (_jsxs("div", { children: [_jsx("dt", { children: phraseLabel(fieldLabel(value.field)) }), _jsx("dd", { children: shownText(value.text, value.kind) })] }, value.field))) })), about !== undefined && about !== "" && (about !== null || data.length === 0) && (_jsx("div", { class: "act-about", children: about === null ? _jsx("p", { class: "browse-none", children: t("Your character knows its name, and nothing more yet.") }) : _jsx(Markdown, { text: about }) })), (start.verbs.length > 0 || start.document === true) && (_jsxs("div", { ref: verbsBar, class: "act-buttons act-verbs", role: "group", "aria-label": t("What you do"), children: [start.document === true && (_jsx("a", { class: "map-sheet-go act-go", href: sectionAddress("world", "documents", start.page ?? start.item), onClick: close, children: t("Read it") })), start.verbs.map((one, index) => (_jsx("button", { type: "button", "data-verb": one, class: index === 0 && start.document !== true ? "map-sheet-go act-go" : "act-cancel", onClick: () => pick(one), children: verbLabel(one) }, one)))] }))] })), acting && mode !== "none" && (_jsxs("div", { class: "act-body", children: [_jsxs("fieldset", { ref: list, class: "act-who", children: [_jsx("legend", { class: "eyebrow", children: t("On whom") }), people.map((person, index) => option(`person ${index}`, { person: person.name }, _jsxs(_Fragment, { children: [_jsxs("span", { class: "act-who-name", children: [person.name, person.count !== undefined && _jsx("span", { class: "count", children: ` ×${person.count}` })] }), person.square !== undefined && _jsx("span", { class: "lm-key-square", children: person.square })] }), [person.role, person.hostile === true ? "hostile" : ""].filter((name) => name !== "").join(" "))), option("self", "self", _jsx("span", { class: "act-who-name", children: t("Myself") }), "plain"), option("none", "none", _jsx("span", { class: "act-who-name", children: t("No one in particular") }), "plain"), mapShown && option("square", "square", _jsx("span", { class: "act-who-name", children: t("A square…") }), "plain"), target === "square" && mapShown && (_jsx("input", { type: "text", class: "act-square", value: square, maxLength: 5, placeholder: "E4", "aria-label": t("The square, such as E4"), onInput: (event) => setSquare(event.currentTarget.value), onKeyDown: toSentence }))] }), mapShown && (_jsx(PlaceMap, { map: map, place: place.name, bare: true, self: self, choosing: { selected: personChosen, onChoose: (name) => choose(name === undefined ? "self" : { person: name }) }, ...(target === "square" ? { picking: { selected: square.trim().toUpperCase(), onSelect: setSquare } } : {}) }))] })), acting && (_jsxs("form", { class: "act-bar", onSubmit: (event) => void send(event), children: [reply === "answer" && (_jsxs("p", { id: "act-note", class: "act-note act-answer", children: [_jsx(Icon, { name: "bell" }), asked?.buttons === true
|
|
137
|
+
? t("These words answer the master instead of a roll or a button: {question}", { question: asked.question })
|
|
138
|
+
: t("These words answer the master's question: {question}", { question: asked?.question ?? "" })] })), _jsxs("label", { for: "act-words", class: "eyebrow act-words-label", children: [_jsx(Icon, { name: "chat" }), t("Your words to the master")] }), _jsx("textarea", { ref: field, id: "act-words", class: "act-words", value: text, rows: 2, maxLength: mostWords, "aria-describedby": reply === "tell" ? undefined : "act-note", onInput: (event) => setText(event.currentTarget.value), onKeyDown: keys }), reply === "copy" && (_jsxs("p", { id: "act-note", class: "act-note", children: [_jsx(Icon, { name: "info" }), t("This chat does not hear it by itself: copy it, then paste it in the chat.")] })), problem && _jsx("p", { class: "act-problem", role: "alert", children: problem }), _jsxs("div", { class: "act-buttons", children: [_jsx("button", { type: "button", class: "act-cancel", onClick: close, children: t("Cancel") }), _jsxs("button", { type: "submit", class: "map-sheet-go act-go", disabled: sending || text.trim() === "", children: [button, _jsx(Icon, { name: reply === "copy" ? "copy" : "send" })] })] })] }))] }));
|
|
88
139
|
}
|
|
89
140
|
/** Whether two choices of the list are the same. */
|
|
90
141
|
function sameTarget(target, other) {
|
package/dist/dashboard/api.js
CHANGED
|
@@ -135,7 +135,8 @@ export async function updateEngine() {
|
|
|
135
135
|
if (response.status === 202 && body.version !== undefined) {
|
|
136
136
|
return { done: true, version: body.version, restart: body.restart === "app" ? "app" : "chat" };
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
const code = body.code === "busy" || body.code === "declined" || body.code === "no-window" || body.code === "engine-failed" ? body.code : undefined;
|
|
139
|
+
return { done: false, error: refusalText(body, t("It did not reach the game: try again.")), ...(code === undefined ? {} : { code }) };
|
|
139
140
|
}
|
|
140
141
|
catch {
|
|
141
142
|
return { done: false, error: t("It did not reach the game: try again.") };
|
|
@@ -226,6 +227,28 @@ export async function putPageBack(page, shown) {
|
|
|
226
227
|
return { done: false, error: t("It did not reach the game: try again.") };
|
|
227
228
|
}
|
|
228
229
|
}
|
|
230
|
+
/** The largest picture the page sends, as the engine takes it: 5 MB. */
|
|
231
|
+
export const largestPicture = 5 * 1024 * 1024;
|
|
232
|
+
/** Gives a page the player's own picture (D-572 (3)): undefined when it is the page's now, else why not, in the page's words. */
|
|
233
|
+
export async function givePicture(page, file) {
|
|
234
|
+
if (file.size > largestPicture) {
|
|
235
|
+
return refusalText({ code: "picture-big", values: { size: String(largestPicture / 1024 / 1024) } }, "");
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
const response = await fetch(`/api/picture?${new URLSearchParams({ page })}`, {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers: { "Content-Type": file.type || "application/octet-stream", "X-File-Name": encodeURIComponent(file.name) },
|
|
241
|
+
body: file,
|
|
242
|
+
});
|
|
243
|
+
if (response.ok) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
return refusalText(await response.json().catch(() => ({})), t("It did not reach the game: try again."));
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return t("It did not reach the game: try again.");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
229
252
|
/** Exports the campaign as an adventure, as it was at its start (ADV-7): the address to download its .zip from, or what went wrong. */
|
|
230
253
|
export async function exportCampaign(credits) {
|
|
231
254
|
try {
|
|
@@ -318,10 +341,10 @@ export async function readActs() {
|
|
|
318
341
|
}
|
|
319
342
|
return await response.json();
|
|
320
343
|
}
|
|
321
|
-
/** Says a sentence to the master (D-495): its id, with how the sentences stand now; else what went wrong. */
|
|
322
|
-
export async function sayAct(text) {
|
|
344
|
+
/** Says a sentence to the master (D-495), with the thing of the sheet it starts from (T-218): its id, with how the sentences stand now; else what went wrong. */
|
|
345
|
+
export async function sayAct(text, item) {
|
|
323
346
|
try {
|
|
324
|
-
const response = await fetch("/api/act", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text }) });
|
|
347
|
+
const response = await fetch("/api/act", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(item === undefined ? { text } : { text, item }) });
|
|
325
348
|
const body = await response.json().catch(() => ({}));
|
|
326
349
|
return response.status === 202 && body.id !== undefined ? { id: body.id, shown: body } : { error: body.error ?? t("It did not reach the game: try again.") };
|
|
327
350
|
}
|
package/dist/dashboard/app.js
CHANGED
|
@@ -16,6 +16,7 @@ import { Help } from "./help/help.js";
|
|
|
16
16
|
import { FollowedQuests, JournalView, QuestEndings } from "./journal/journal.js";
|
|
17
17
|
import { AskCard } from "./packages/ask-card.js";
|
|
18
18
|
import { inCard, nextPackCard } from "./packages/card.js";
|
|
19
|
+
import { useEngineNotice } from "./packages/engine.js";
|
|
19
20
|
import { PackagesPage } from "./packages/packages.js";
|
|
20
21
|
import { codeOfModule, ModulesContext, ownKey, preloadModules, systemPageStyle, useNavPages } from "./packages/page-code.js";
|
|
21
22
|
import { PackagePage } from "./packages/page.js";
|
|
@@ -46,6 +47,7 @@ import { calledOf, playerNamed, turnKey, withHeld } from "./shell/shown.js";
|
|
|
46
47
|
import { gameStyleChanged, takeSystemStyle } from "./shell/system-style.js";
|
|
47
48
|
import { PlayTable, tableBeside, TableTab, useTableAway } from "./shell/table.js";
|
|
48
49
|
import { restoreTheme } from "./shell/theme.js";
|
|
50
|
+
import { startTooltips } from "./shell/tooltip.js";
|
|
49
51
|
import { SetupCorner, Top } from "./shell/top.js";
|
|
50
52
|
import { browserLanguage, pageDirection, pageLocale, setLanguage, setSystemWords, t } from "./text.js";
|
|
51
53
|
import { WorldView } from "./world/world.js";
|
|
@@ -459,7 +461,7 @@ function App() {
|
|
|
459
461
|
const lead = playerNamed(shown.party, shown.foreground) ?? players[0];
|
|
460
462
|
const actor = member?.role === "pc" ? member : lead;
|
|
461
463
|
// The player's sentences to the master (D-495); read() sets the acts and the verbs it reads, by setters that never change.
|
|
462
|
-
const { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct } = useActs({
|
|
464
|
+
const { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, answering: answeringQuestion, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct } = useActs({
|
|
463
465
|
read,
|
|
464
466
|
live,
|
|
465
467
|
asked: shown.asked,
|
|
@@ -517,7 +519,8 @@ function App() {
|
|
|
517
519
|
const pageWidgets = useMemo(() => (packWidget === undefined ? widgets : widgets.filter((widget) => widget.id !== packWidget)), [widgets, packWidget]);
|
|
518
520
|
// While the campaign is in its setup, the page is its first configuration, as a portal's (D-370).
|
|
519
521
|
const inSetup = setup?.mode === "setup";
|
|
520
|
-
|
|
522
|
+
const engineNotice = useEngineNotice(address.section);
|
|
523
|
+
// The page's own messages, over it (D-298): a problem, the game away, a word to know; a newer RPG Engine last (T-219).
|
|
521
524
|
const notices = [
|
|
522
525
|
...(shown.problem === undefined ? [] : [{ kind: "problem", text: shown.problem }]),
|
|
523
526
|
...(!live && shown.readAt !== undefined
|
|
@@ -527,6 +530,7 @@ function App() {
|
|
|
527
530
|
...gameNotices(shown.problems, shown.textsTranslating),
|
|
528
531
|
// In the setup an import under way is with the page's other notices, in the column of its card (D-491 (11)).
|
|
529
532
|
...(inSetup ? importNotices(shown.importing) : []),
|
|
533
|
+
...engineNotice,
|
|
530
534
|
];
|
|
531
535
|
// In play, under the player's turn, which counts more in a fight.
|
|
532
536
|
const importing = inSetup ? [] : importNotices(shown.importing);
|
|
@@ -575,10 +579,11 @@ function App() {
|
|
|
575
579
|
}, onFree: (roll) => {
|
|
576
580
|
setFree((before) => withFree(shown.campaign, before, roll));
|
|
577
581
|
setFresh((before) => new Set([...before, roll.id]));
|
|
578
|
-
} }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: copyFromStrip, onDismiss: dismissAct })] }) }) }) }) }) }));
|
|
582
|
+
} }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, asked: answeringQuestion, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: copyFromStrip, onDismiss: dismissAct })] }) }) }) }) }) }));
|
|
579
583
|
}
|
|
580
|
-
// The theme the player picked before, from the start (D-300).
|
|
584
|
+
// The theme the player picked before, from the start (D-300); the tooltips over everything (T-228).
|
|
581
585
|
restoreTheme();
|
|
586
|
+
startTooltips();
|
|
582
587
|
const root = document.getElementById("app");
|
|
583
588
|
if (root !== null) {
|
|
584
589
|
render(_jsx(App, {}), root);
|