rpg-engine 0.4.1 → 0.6.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 +1 -1
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +37 -2
- package/dist/commands/ask.js +106 -35
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +69 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +94 -6
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +42 -8
- package/dist/commands/game-widgets.js +182 -31
- package/dist/commands/game-world.d.ts +32 -3
- package/dist/commands/game-world.js +113 -24
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +15 -1
- package/dist/commands/package.js +96 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +2 -2
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +12 -4
- package/dist/commands/view.js +11 -8
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +68 -27
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +10 -1
- package/dist/core/package-api.d.ts +388 -0
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +4 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +65 -3
- package/dist/dashboard/app.js +222 -98
- package/dist/dashboard/ask-card.js +169 -0
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +6 -4
- package/dist/dashboard/extension-widgets.js +136 -16
- package/dist/dashboard/faces.js +6 -4
- package/dist/dashboard/help.js +10 -3
- package/dist/dashboard/i18n/ar.json +34 -29
- package/dist/dashboard/i18n/cs.json +34 -29
- package/dist/dashboard/i18n/da.json +34 -29
- package/dist/dashboard/i18n/de.json +34 -29
- package/dist/dashboard/i18n/el.json +34 -29
- package/dist/dashboard/i18n/es.json +34 -29
- package/dist/dashboard/i18n/fi.json +34 -29
- package/dist/dashboard/i18n/fr.json +34 -29
- package/dist/dashboard/i18n/he.json +34 -29
- package/dist/dashboard/i18n/hi.json +34 -29
- package/dist/dashboard/i18n/hu.json +34 -29
- package/dist/dashboard/i18n/is.json +34 -29
- package/dist/dashboard/i18n/it.json +34 -29
- package/dist/dashboard/i18n/ja.json +34 -29
- package/dist/dashboard/i18n/ko.json +34 -29
- package/dist/dashboard/i18n/nb.json +34 -29
- package/dist/dashboard/i18n/nl.json +34 -29
- package/dist/dashboard/i18n/pl.json +34 -29
- package/dist/dashboard/i18n/pt.json +34 -29
- package/dist/dashboard/i18n/ro.json +34 -29
- package/dist/dashboard/i18n/ru.json +34 -29
- package/dist/dashboard/i18n/sv.json +34 -29
- package/dist/dashboard/i18n/tr.json +34 -29
- package/dist/dashboard/i18n/uk.json +34 -29
- package/dist/dashboard/i18n/zh.json +34 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +97 -0
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +180 -24
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/rolls.js +2 -2
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +859 -574
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +246 -11
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +28 -33
- package/dist/extensions/extension.js +37 -46
- package/dist/extensions/index.d.ts +4 -3
- package/dist/extensions/index.js +5 -2
- package/dist/extensions/packages.d.ts +14 -0
- package/dist/extensions/packages.js +148 -12
- package/dist/extensions/words.d.ts +2 -1
- package/dist/extensions/words.js +5 -4
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +52 -15
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/standard-fields.d.ts +2 -0
- package/dist/pages/standard-fields.js +8 -1
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +61 -30
- package/dist/systems/game-system.js +159 -50
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +76 -0
- package/dist/testing.js +197 -0
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/setup.md +1 -1
- package/package.json +15 -2
- package/systems/5e/LICENSE.md +13 -3
- package/systems/5e/dist/dying.js +83 -16
- package/systems/5e/dist/index.js +2 -2
- package/systems/5e/dist/page-style.js +634 -0
- package/systems/5e/dist/page.js +166 -0
- package/systems/5e/dist/shown.js +23 -0
- package/systems/5e/instructions/combat.md +1 -0
- package/systems/5e/package.json +4 -2
- package/systems/5e/system.yaml +35 -7
- package/systems/5e/versions/srd-5.1/system.yaml +2 -0
- package/systems/5e/words/ar.yaml +30 -0
- package/systems/5e/words/cs.yaml +30 -0
- package/systems/5e/words/da.yaml +30 -0
- package/systems/5e/words/de.yaml +30 -0
- package/systems/5e/words/el.yaml +30 -0
- package/systems/5e/words/es.yaml +30 -0
- package/systems/5e/words/fi.yaml +30 -0
- package/systems/5e/words/fr.yaml +30 -0
- package/systems/5e/words/he.yaml +30 -0
- package/systems/5e/words/hi.yaml +30 -0
- package/systems/5e/words/hu.yaml +30 -0
- package/systems/5e/words/is.yaml +30 -0
- package/systems/5e/words/it.yaml +30 -0
- package/systems/5e/words/ja.yaml +30 -0
- package/systems/5e/words/ko.yaml +30 -0
- package/systems/5e/words/nb.yaml +30 -0
- package/systems/5e/words/nl.yaml +30 -0
- package/systems/5e/words/pl.yaml +30 -0
- package/systems/5e/words/pt.yaml +30 -0
- package/systems/5e/words/ro.yaml +30 -0
- package/systems/5e/words/ru.yaml +30 -0
- package/systems/5e/words/sv.yaml +30 -0
- package/systems/5e/words/tr.yaml +30 -0
- package/systems/5e/words/uk.yaml +30 -0
- package/systems/5e/words/zh.yaml +30 -0
- package/dist/commands/game-extensions.d.ts +0 -34
- package/dist/commands/game-extensions.js +0 -182
- package/dist/commands/game-system-code.d.ts +0 -25
- package/dist/commands/game-system-code.js +0 -172
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- package/dist/extensions/api.d.ts +0 -155
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
|
@@ -1,17 +1,51 @@
|
|
|
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
3
|
import { sectionAddress } from "./address.js";
|
|
4
|
-
import { addFile, addSource, changeLibrary, changePackage, exportCampaign, readCatalog, readLibrary, readPackages, } from "./api.js";
|
|
4
|
+
import { addFile, addSource, changeLibrary, changePackage, exportCampaign, readCatalog, readEngine, readLibrary, readPackages, updateEngine, } from "./api.js";
|
|
5
5
|
import { CardHead, useMedia } from "./card.js";
|
|
6
6
|
import { gameDateLabel, sinceDateLabel } from "./game-words.js";
|
|
7
7
|
import { Icon, iconPath } from "./icons.js";
|
|
8
8
|
import { phraseLabel, systemTitleLabel } from "./labels.js";
|
|
9
9
|
import { languageName } from "./languages.js";
|
|
10
|
+
import { OwnPageLinks } from "./package-page.js";
|
|
10
11
|
import { PageHead } from "./pages.js";
|
|
11
12
|
import { Confirm } from "./saves.js";
|
|
12
13
|
import { Command } from "./settings.js";
|
|
13
14
|
import { PageTabs } from "./tabs.js";
|
|
14
15
|
import { arrowStep, foldedText, isolated, pageDirection, t } from "./text.js";
|
|
16
|
+
// The engine's own name, never translated.
|
|
17
|
+
const engineName = "RPG Engine";
|
|
18
|
+
// Where the engine installed from this page is kept while the chat goes on with the one before it: in this tab, through a reload.
|
|
19
|
+
const updatedKey = "rpg-engine-updated";
|
|
20
|
+
/** The engine installed from this page in this tab, if any. */
|
|
21
|
+
function keptUpdate() {
|
|
22
|
+
try {
|
|
23
|
+
const kept = JSON.parse(sessionStorage.getItem(updatedKey) ?? "null");
|
|
24
|
+
return kept !== null && typeof kept.to === "string" && typeof kept.from === "string" ? { from: kept.from, to: kept.to, restart: kept.restart === "app" ? "app" : "chat" } : undefined;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function keepUpdate(updated) {
|
|
31
|
+
try {
|
|
32
|
+
if (updated === undefined) {
|
|
33
|
+
sessionStorage.removeItem(updatedKey);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
sessionStorage.setItem(updatedKey, JSON.stringify(updated));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// A browser that keeps nothing says it until the page is drawn again.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The focus to the engine's card: its Update, else its title. */
|
|
44
|
+
function focusEngine() {
|
|
45
|
+
const target = document.getElementById("engine-update") ?? document.getElementById("packages-engine");
|
|
46
|
+
target?.focus({ preventScroll: true });
|
|
47
|
+
target?.scrollIntoView({ block: "center" });
|
|
48
|
+
}
|
|
15
49
|
// The rows of the catalog shown before "Show more": fewer on a phone, where the installed come after it.
|
|
16
50
|
const shownWide = 5;
|
|
17
51
|
const shownNarrow = 3;
|
|
@@ -33,6 +67,10 @@ export function PackagesPage({ version, tab }) {
|
|
|
33
67
|
const [library, setLibrary] = useState();
|
|
34
68
|
const [libraryProblem, setLibraryProblem] = useState();
|
|
35
69
|
const libraryBusy = library?.entries.some((entry) => entry.reading > 0) ?? false;
|
|
70
|
+
const [engine, setEngine] = useState({ asking: true });
|
|
71
|
+
const [updated, setUpdated] = useState(keptUpdate);
|
|
72
|
+
// Asked from a row whose package needs a newer engine: the focus goes to the engine's card once Installed shows.
|
|
73
|
+
const toEngine = useRef(false);
|
|
36
74
|
// Only the last reading counts, as after a change made here and the one the game sends.
|
|
37
75
|
const read = () => {
|
|
38
76
|
const reading = ++reads.current;
|
|
@@ -55,9 +93,21 @@ export function PackagesPage({ version, tab }) {
|
|
|
55
93
|
setLibraryProblem(undefined);
|
|
56
94
|
}, (error) => setLibraryProblem(error instanceof Error ? error.message : String(error)));
|
|
57
95
|
};
|
|
96
|
+
// The engine and npm's latest, once: npm is asked each time. Only the game's own server has it; elsewhere its card is not shown.
|
|
97
|
+
const askEngine = () => {
|
|
98
|
+
void readEngine().then((read) => {
|
|
99
|
+
setEngine({ asking: false, ...(read === undefined ? { hidden: true } : { read }) });
|
|
100
|
+
// A new chat brought the engine installed here: the way to it is said no more.
|
|
101
|
+
if (read !== undefined && read.version === updated?.to) {
|
|
102
|
+
keepUpdate(undefined);
|
|
103
|
+
setUpdated(undefined);
|
|
104
|
+
}
|
|
105
|
+
}, () => setEngine({ asking: false, hidden: true }));
|
|
106
|
+
};
|
|
58
107
|
useEffect(read, [version]);
|
|
59
108
|
useEffect(readShelves, [version]);
|
|
60
109
|
useEffect(() => askCatalog(false), []);
|
|
110
|
+
useEffect(askEngine, []);
|
|
61
111
|
// While books are being read in their own process, their counts are read again now and then.
|
|
62
112
|
useEffect(() => {
|
|
63
113
|
if (!libraryBusy) {
|
|
@@ -77,6 +127,11 @@ export function PackagesPage({ version, tab }) {
|
|
|
77
127
|
// Seen from Add, what was added gets the focus among the installed: its new row, else its card.
|
|
78
128
|
useEffect(() => {
|
|
79
129
|
const kind = seeing.current;
|
|
130
|
+
if (shownTab === "installed" && toEngine.current) {
|
|
131
|
+
toEngine.current = false;
|
|
132
|
+
focusEngine();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
80
135
|
if (shownTab !== "installed" || kind === undefined) {
|
|
81
136
|
return;
|
|
82
137
|
}
|
|
@@ -94,6 +149,15 @@ export function PackagesPage({ version, tab }) {
|
|
|
94
149
|
seeing.current = kind;
|
|
95
150
|
choose("installed");
|
|
96
151
|
};
|
|
152
|
+
// From a package that needs a newer engine, to the engine's card, in Installed.
|
|
153
|
+
const goEngine = () => {
|
|
154
|
+
if (shownTab === "installed") {
|
|
155
|
+
focusEngine();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
toEngine.current = true;
|
|
159
|
+
choose("installed");
|
|
160
|
+
};
|
|
97
161
|
const rowState = (at) => ({ ...(work?.at === at ? { work } : {}), ...(said?.at === at ? { said } : {}), busy, ...(tabOf(at) === "add" ? { onSee: see } : {}) });
|
|
98
162
|
/** One change, from where it was asked: the work shown there while it lasts, then what came of it; what is here read again, and the catalog when it changed. */
|
|
99
163
|
const run = async (at, action, name, call, done, after) => {
|
|
@@ -114,6 +178,36 @@ export function PackagesPage({ version, tab }) {
|
|
|
114
178
|
askCatalog(true);
|
|
115
179
|
}
|
|
116
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* npm's latest engine installed, as it was installed: the work said in its card while it lasts; then how a new chat, or the app opened again, takes it, kept
|
|
183
|
+
* in this tab until the engine the page is served by is that one.
|
|
184
|
+
*/
|
|
185
|
+
const updateTheEngine = async () => {
|
|
186
|
+
const from = engine.read?.version;
|
|
187
|
+
if (busy || from === undefined) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
setSaid(undefined);
|
|
191
|
+
setSending({ name: "rpg-engine", action: "engine", phase: "working", at: "engine" });
|
|
192
|
+
const outcome = await updateEngine();
|
|
193
|
+
setSending(undefined);
|
|
194
|
+
if (outcome.done) {
|
|
195
|
+
const done = { from, to: outcome.version, restart: outcome.restart };
|
|
196
|
+
keepUpdate(done);
|
|
197
|
+
setUpdated({ ...done, now: true });
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
setSaid({
|
|
201
|
+
at: "engine",
|
|
202
|
+
problem: true,
|
|
203
|
+
...(outcome.code === "busy"
|
|
204
|
+
? { text: t("One package at a time: wait for the one under way, then try again.") }
|
|
205
|
+
: { text: t("RPG Engine was not updated."), why: outcome.error }),
|
|
206
|
+
});
|
|
207
|
+
askEngine();
|
|
208
|
+
}
|
|
209
|
+
read();
|
|
210
|
+
};
|
|
117
211
|
const add = (at, source) => run(at, "add", source, () => addSource(source), addedText);
|
|
118
212
|
const addTheFile = (file) => run("add", "add", file.name, () => addFile(file), addedText);
|
|
119
213
|
const change = (at, action, name, label, after) => run(at, action, name, () => changePackage(action, name), () => doneText(action, label), after);
|
|
@@ -135,7 +229,10 @@ export function PackagesPage({ version, tab }) {
|
|
|
135
229
|
const systems = view?.systems ?? [];
|
|
136
230
|
const adventures = view?.adventures ?? [];
|
|
137
231
|
const languages = view?.languages ?? [];
|
|
138
|
-
|
|
232
|
+
// The engine npm has that this page may install: one more update on the Installed tab, and the way for a package that needs it.
|
|
233
|
+
const engineNew = engine.read?.update === true && engine.read.install === "global" && updated === undefined ? engine.read.latest : undefined;
|
|
234
|
+
const updates = (view === undefined ? 0 : updateCount(view, catalog.read)) + (engineNew === undefined ? 0 : 1);
|
|
235
|
+
const needs = (newer) => newer === undefined ? null : _jsx(NeedsEngine, { newer: newer, canUpdate: engineNew !== undefined, onGo: goEngine });
|
|
139
236
|
const missing = view?.missing.length ?? 0;
|
|
140
237
|
const away = library?.entries.filter((entry) => !entry.onComputer).length ?? 0;
|
|
141
238
|
const elsewhere = work !== undefined && tabOf(work.at) !== shownTab ? work : undefined;
|
|
@@ -144,9 +241,9 @@ export function PackagesPage({ version, tab }) {
|
|
|
144
241
|
{ key: "installed", name: t("Installed"), label: [t("Installed"), ...marksText(updates, missing)].join(", "), marks: _jsx(TabMarks, { updates: updates, missing: missing }) },
|
|
145
242
|
{ key: "add", name: t("Add") },
|
|
146
243
|
{ key: "library", name: t("Library"), label: [t("Library"), ...marksText(0, away)].join(", "), marks: _jsx(TabMarks, { updates: 0, missing: away }) },
|
|
147
|
-
] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void change(`catalog:${entry.source}`, "update", entry.source, entryTitle(entry)), onRetry: () => askCatalog(true) }), _jsx(AddField, { state: rowState("add"), onAdd: (source) => void add("add", source), onFile: (file) => void addTheFile(file) })] }) })), shownTab === "installed" && (_jsxs(_Fragment, { children: [_jsxs("section", { class: "card", "aria-labelledby": "packages-systems", children: [_jsx(CardHead, { icon: iconPath("dice"), title: _jsx("h3", { id: "packages-systems", tabIndex: -1, children: t("Game system") }) }), _jsxs("div", { class: "card-body package-body", children: [_jsx("ul", { class: "package-list", children: systems.map((system) => (_jsx(SystemRow, { system: system, newer: system.package === undefined ? undefined : newerOf(system.package, "system", catalog.read), fresh: fresh.includes(`system:${system.name}`), state: rowState(`system:${system.name}`), onUpdate: (target) => void change(`system:${system.name}`, "update", target, system.name), onUninstall: (target) => setAsking({ kind: "uninstall", what: "system", name: system.name, target, at: `system:${system.name}` }) }, system.name))) }), _jsx(CardSaid, { said: said, at: "systems" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-adventures", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "packages-adventures", tabIndex: -1, children: t("Adventures") }), ...(adventures.length === 0 ? {} : { note: String(adventures.length) }) }), _jsxs("div", { class: "card-body package-body", children: [adventures.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add one in Add, from the catalog, a .zip or a link.") }), adventures.length > 0 && (_jsx("ul", { class: "package-list", children: adventures.map((adventure) => (_jsx(AdventureRow, { adventure: adventure, fresh: fresh.includes(`adventure:${adventure.title}`), state: rowState(`adventure:${adventure.title}`), onTakeOut: () => setAsking({ kind: "adventure", title: adventure.title }) }, adventure.title))) })), _jsx(CardSaid, { said: said, at: "adventures" }), _jsx(ShareCampaign, {})] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-extensions", children: [_jsx(CardHead, { icon: iconPath("packages"), title: _jsx("h3", { id: "packages-extensions", tabIndex: -1, children: t("Extensions") }), ...(view.installed.length + view.missing.length === 0 ? {} : { note: t("{count} in use", { count: usedCount(view) }) }) }), _jsxs("div", { class: "card-body package-body", children: [view.installed.length + view.missing.length === 0 && _jsx("p", { class: "package-note", children: t("None: an extension adds rules and tools to the game; you find them in Add, in the catalog.") }), view.installed.length + view.missing.length > 0 && (_jsxs("ul", { class: "package-list", children: [view.installed.map((extension) => (_jsx(ExtensionRow, { extension: extension, newer: newerOf(extension.package, "extension", catalog.read), fresh: fresh.includes(`extension:${extension.package}`), state: rowState(`extension:${extension.package}`), onUse: (use) => void (use
|
|
244
|
+
] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), needs: (entry) => needs(entry.newer), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void change(`catalog:${entry.source}`, "update", entry.source, entryTitle(entry)), onRetry: () => askCatalog(true) }), _jsx(AddField, { state: rowState("add"), onAdd: (source) => void add("add", source), onFile: (file) => void addTheFile(file) })] }) })), shownTab === "installed" && (_jsxs(_Fragment, { children: [!engine.hidden && _jsx(EngineCard, { engine: engine.read, updated: updated, newer: engineNew, state: rowState("engine"), onUpdate: () => void updateTheEngine() }), _jsxs("section", { class: "card", "aria-labelledby": "packages-systems", children: [_jsx(CardHead, { icon: iconPath("dice"), title: _jsx("h3", { id: "packages-systems", tabIndex: -1, children: t("Game system") }) }), _jsxs("div", { class: "card-body package-body", children: [_jsx("ul", { class: "package-list", children: systems.map((system) => (_jsx(SystemRow, { system: system, newer: system.package === undefined ? undefined : newerOf(system.package, "system", catalog.read), needs: system.package === undefined ? null : needs(entryOf(system.package, "system", catalog.read)?.newer), fresh: fresh.includes(`system:${system.name}`), state: rowState(`system:${system.name}`), onUpdate: (target) => void change(`system:${system.name}`, "update", target, system.name), onUninstall: (target) => setAsking({ kind: "uninstall", what: "system", name: system.name, target, at: `system:${system.name}` }) }, system.name))) }), _jsx(CardSaid, { said: said, at: "systems" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-adventures", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "packages-adventures", tabIndex: -1, children: t("Adventures") }), ...(adventures.length === 0 ? {} : { note: String(adventures.length) }) }), _jsxs("div", { class: "card-body package-body", children: [adventures.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add one in Add, from the catalog, a .zip or a link.") }), adventures.length > 0 && (_jsx("ul", { class: "package-list", children: adventures.map((adventure) => (_jsx(AdventureRow, { adventure: adventure, fresh: fresh.includes(`adventure:${adventure.title}`), state: rowState(`adventure:${adventure.title}`), onTakeOut: () => setAsking({ kind: "adventure", title: adventure.title }) }, adventure.title))) })), _jsx(CardSaid, { said: said, at: "adventures" }), _jsx(ShareCampaign, {})] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-extensions", children: [_jsx(CardHead, { icon: iconPath("packages"), title: _jsx("h3", { id: "packages-extensions", tabIndex: -1, children: t("Extensions") }), ...(view.installed.length + view.missing.length === 0 ? {} : { note: t("{count} in use", { count: usedCount(view) }) }) }), _jsxs("div", { class: "card-body package-body", children: [view.installed.length + view.missing.length === 0 && _jsx("p", { class: "package-note", children: t("None: an extension adds rules and tools to the game; you find them in Add, in the catalog.") }), view.installed.length + view.missing.length > 0 && (_jsxs("ul", { class: "package-list", children: [view.installed.map((extension) => (_jsx(ExtensionRow, { extension: extension, newer: newerOf(extension.package, "extension", catalog.read), needs: needs(entryOf(extension.package, "extension", catalog.read)?.newer), fresh: fresh.includes(`extension:${extension.package}`), state: rowState(`extension:${extension.package}`), onUse: (use) => void (use
|
|
148
245
|
? add(`extension:${extension.package}`, extension.package)
|
|
149
|
-
: change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => (_jsx(LanguageRow, { language: language, newer: newerOf(language.package, "language", catalog.read), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void change(`language:${language.code}`, "update", language.package, languageTitle(language)), onUninstall: () => setAsking({ kind: "uninstall", what: "language", name: languageTitle(language), target: language.package, at: `language:${language.code}` }) }, language.package))) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
|
|
246
|
+
: change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => (_jsx(LanguageRow, { language: language, newer: newerOf(language.package, "language", catalog.read), needs: needs(entryOf(language.package, "language", catalog.read)?.newer), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void change(`language:${language.code}`, "update", language.package, languageTitle(language)), onUninstall: () => setAsking({ kind: "uninstall", what: "language", name: languageTitle(language), target: language.package, at: `language:${language.code}` }) }, language.package))) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
|
|
150
247
|
}
|
|
151
248
|
// How often the library is read again while its books are being read, for their counts.
|
|
152
249
|
const libraryReading = 5000;
|
|
@@ -237,7 +334,7 @@ function LibraryField({ state, onAdd }) {
|
|
|
237
334
|
return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
|
|
238
335
|
event.preventDefault();
|
|
239
336
|
submit();
|
|
240
|
-
}, children: [_jsx("label", { class: "package-label", for: "library-path", children: t("A folder or a book of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "library-path", dir: "ltr", type: "text", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 1000, value: path, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "library-path-about", placeholder: "D:\\Books\\
|
|
337
|
+
}, children: [_jsx("label", { class: "package-label", for: "library-path", children: t("A folder or a book of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "library-path", dir: "ltr", type: "text", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 1000, value: path, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "library-path-about", placeholder: "D:\\Books\\RPG", onInput: (event) => setPath(event.currentTarget.value) }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": state.busy, children: [_jsx(Icon, { name: "plus" }), t("Add")] })] }), _jsxs("p", { class: "package-note", id: "library-path-about", children: [t("Write or paste its full path: the browser does not give a folder's. Your computer asks your yes in a window, once, and nothing in the folder is ever changed."), " ", t("Text, or PDFs whose text can be selected, read best; a scanned PDF is read from the pictures of its pages, on Windows only, in a few minutes.")] }), empty && state.work === undefined && _jsx("p", { class: "package-said problem", role: "status", children: t("Write the path of a folder or a book first.") }), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
241
338
|
}
|
|
242
339
|
/** On the Installed tab, what asks for the player: the updates npm has, with their count, and a mark when the campaign lists what this computer lacks. */
|
|
243
340
|
function TabMarks({ updates, missing }) {
|
|
@@ -293,7 +390,7 @@ function AddField({ state, onAdd, onFile }) {
|
|
|
293
390
|
* The catalog (D-486), always open: a search, chips for the kinds with how many each has, wrapping on a phone; the first rows, five or three on a phone, then
|
|
294
391
|
* the others on asking. A source that does not answer is said in the page's words, with its own under them.
|
|
295
392
|
*/
|
|
296
|
-
function CatalogList({ catalog, view, state, onAdd, onUpdate, onRetry }) {
|
|
393
|
+
function CatalogList({ catalog, view, state, needs, onAdd, onUpdate, onRetry }) {
|
|
297
394
|
const [kind, setKind] = useState("all");
|
|
298
395
|
const [query, setQuery] = useState("");
|
|
299
396
|
const [all, setAll] = useState(false);
|
|
@@ -327,7 +424,7 @@ function CatalogList({ catalog, view, state, onAdd, onUpdate, onRetry }) {
|
|
|
327
424
|
}
|
|
328
425
|
};
|
|
329
426
|
const chip = (one, count) => (_jsxs("button", { type: "button", "aria-pressed": chosen === one, tabIndex: chosen === one ? 0 : -1, onClick: () => setKind(one), children: [one === "all" ? t("All") : kindsLabel(one), _jsx("span", { class: "package-count", children: count })] }, one));
|
|
330
|
-
return (_jsxs("div", { class: "package-catalog", children: [_jsxs("div", { class: "package-catalog-head", children: [_jsx("h4", { class: "eyebrow package-sub", id: "package-catalog-title", children: t("Catalog") }), entries.length > 0 && (_jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: query, placeholder: t("Search"), "aria-label": t("Search the catalog"), onInput: (event) => setQuery(event.currentTarget.value) })] }))] }), kinds.length > 1 && (_jsxs("div", { class: "filter-chips", role: "group", "aria-label": t("Kind"), ref: chips, onKeyDown: chipKey, children: [chip("all", found.length), kinds.map((one) => chip(one, found.filter((entry) => entry.kind === one).length))] })), (failed.npm !== undefined || failed.github !== undefined) && _jsx(CatalogAway, { failed: failed, asking: catalog.asking, onRetry: onRetry }), catalog.asking && catalog.read === undefined && catalog.error === undefined && _jsx("p", { class: "package-note", role: "status", children: t("Asking npm and GitHub…") }), !catalog.asking && entries.length === 0 && failed.npm === undefined && failed.github === undefined && _jsx("p", { class: "package-note", children: t("Nothing to add for now.") }), entries.length > 0 && shown.length === 0 && _jsx("p", { class: "package-note", children: t("Nothing matches “{query}”.", { query: query.trim() }) }), visible.length > 0 && (_jsx("ul", { class: "package-list", ref: list, "aria-labelledby": "package-catalog-title", children: visible.map((entry) => (_jsx(CatalogRow, { entry: entry, named: chosen === "all", view: view, state: state(entry), onAdd: () => onAdd(entry), onUpdate: () => onUpdate(entry) }, `${entry.kind}:${entry.source}`))) })), shown.length > visible.length && (_jsxs("button", { type: "button", class: "package-show", onClick: showAll, children: [t("Show the other {count}", { count: shown.length - visible.length }), _jsx(Icon, { name: "more" })] }))] }));
|
|
427
|
+
return (_jsxs("div", { class: "package-catalog", children: [_jsxs("div", { class: "package-catalog-head", children: [_jsx("h4", { class: "eyebrow package-sub", id: "package-catalog-title", children: t("Catalog") }), entries.length > 0 && (_jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: query, placeholder: t("Search"), "aria-label": t("Search the catalog"), onInput: (event) => setQuery(event.currentTarget.value) })] }))] }), kinds.length > 1 && (_jsxs("div", { class: "filter-chips", role: "group", "aria-label": t("Kind"), ref: chips, onKeyDown: chipKey, children: [chip("all", found.length), kinds.map((one) => chip(one, found.filter((entry) => entry.kind === one).length))] })), (failed.npm !== undefined || failed.github !== undefined) && _jsx(CatalogAway, { failed: failed, asking: catalog.asking, onRetry: onRetry }), catalog.asking && catalog.read === undefined && catalog.error === undefined && _jsx("p", { class: "package-note", role: "status", children: t("Asking npm and GitHub…") }), !catalog.asking && entries.length === 0 && failed.npm === undefined && failed.github === undefined && _jsx("p", { class: "package-note", children: t("Nothing to add for now.") }), entries.length > 0 && shown.length === 0 && _jsx("p", { class: "package-note", children: t("Nothing matches “{query}”.", { query: query.trim() }) }), visible.length > 0 && (_jsx("ul", { class: "package-list", ref: list, "aria-labelledby": "package-catalog-title", children: visible.map((entry) => (_jsx(CatalogRow, { entry: entry, named: chosen === "all", view: view, state: state(entry), needs: needs(entry), onAdd: () => onAdd(entry), onUpdate: () => onUpdate(entry) }, `${entry.kind}:${entry.source}`))) })), shown.length > visible.length && (_jsxs("button", { type: "button", class: "package-show", onClick: showAll, children: [t("Show the other {count}", { count: shown.length - visible.length }), _jsx(Icon, { name: "more" })] }))] }));
|
|
331
428
|
}
|
|
332
429
|
/** npm or GitHub away, or both: the rest is added all the same; the engine's words under the page's, and Try again. */
|
|
333
430
|
function CatalogAway({ failed, asking, onRetry }) {
|
|
@@ -344,7 +441,7 @@ function CatalogAway({ failed, asking, onRetry }) {
|
|
|
344
441
|
* A row of the catalog (D-486 (4)): its tile, its title with its kind in All and whose it is, a line of what it is, its facts; then what can be done: add it,
|
|
345
442
|
* with "…" when a window will ask the player's yes; update it; download a game system for a new campaign; or where it is already.
|
|
346
443
|
*/
|
|
347
|
-
function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
|
|
444
|
+
function CatalogRow({ entry, named, view, state, needs, onAdd, onUpdate }) {
|
|
348
445
|
const here = hereState(entry, view);
|
|
349
446
|
const asksYes = !entry.verified && entry.code;
|
|
350
447
|
const facts = [
|
|
@@ -360,7 +457,7 @@ function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
|
|
|
360
457
|
? (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), `${isolated(entry.installed)} ${pageDirection() === "rtl" ? "←" : "→"} ${isolated(entry.version)}`] }))
|
|
361
458
|
: entry.version;
|
|
362
459
|
const action = (word, label, icon, onClick, accent = false) => (_jsxs("button", { type: "button", class: accent ? "button package-button accent" : "button package-button", "aria-label": label, "aria-disabled": state.busy, onClick: () => !state.busy && onClick(), children: [_jsx(Icon, { name: icon }), word] }));
|
|
363
|
-
return (_jsxs(PackageRow, { tile: kindIcon[entry.kind], tone: entry.kind === "adventure" ? "cover" : undefined, name: entryTitle(entry), badges: _jsxs(_Fragment, { children: [named && _jsx("span", { class: "package-kind", children: kindLabel(entry.kind) }), _jsx(Trust, { verified: entry.verified, code: entry.code, author: entry.author })] }), about: entry.description === undefined || entry.kind === "adventure" ? entry.description : phraseLabel(entry.description), meta: (version !== undefined || facts.length > 0) && (_jsxs(_Fragment, { children: [version, version !== undefined && facts.length > 0 && " · ", facts.map(isolated).join(" · ")] })), focusable: true, actions: entry.update && entry.kind !== "adventure"
|
|
460
|
+
return (_jsxs(PackageRow, { tile: kindIcon[entry.kind], tone: entry.kind === "adventure" ? "cover" : undefined, name: entryTitle(entry), badges: _jsxs(_Fragment, { children: [named && _jsx("span", { class: "package-kind", children: kindLabel(entry.kind) }), _jsx(Trust, { verified: entry.verified, code: entry.code, author: entry.author })] }), about: entry.description === undefined || entry.kind === "adventure" ? entry.description : phraseLabel(entry.description), meta: (version !== undefined || facts.length > 0) && (_jsxs(_Fragment, { children: [version, version !== undefined && facts.length > 0 && " · ", facts.map(isolated).join(" · ")] })), needs: needs, focusable: true, actions: entry.update && entry.kind !== "adventure"
|
|
364
461
|
? action(t("Update"), t("Update {name} to {version}", { name: entryTitle(entry), version: entry.version ?? "" }), "update", onUpdate, true)
|
|
365
462
|
: here === "used" || (here === "here" && entry.kind !== "extension")
|
|
366
463
|
? (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), entry.kind === "adventure" || entry.kind === "extension" ? t("In the campaign") : t("On this computer")] }))
|
|
@@ -368,13 +465,60 @@ function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
|
|
|
368
465
|
? action(t("Download"), t("Download {name}", { name: entryTitle(entry) }), "download", onAdd)
|
|
369
466
|
: action(asksYes ? t("Add…") : t("Add"), t("Add {name}", { name: entryTitle(entry) }), "plus", onAdd), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said, onSee: state.onSee })] }));
|
|
370
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* RPG Engine itself (D-515 (3)), first among the installed: its version and npm's newer one, with Update when npm installed it globally; installed another way,
|
|
470
|
+
* why the page does not update it; once updated, how a new chat, or the app opened again, brings it, as the chat and this page go on with this one.
|
|
471
|
+
*/
|
|
472
|
+
function EngineCard({ engine, updated, newer, state, onUpdate }) {
|
|
473
|
+
const folder = engine?.folder ?? "";
|
|
474
|
+
const why = engine === undefined
|
|
475
|
+
? t("Asking npm for the newest version…")
|
|
476
|
+
: engine.install === "link"
|
|
477
|
+
? t("Installed with npm link from {folder}, for its development: update it there, with git pull and npm run build.", { folder })
|
|
478
|
+
: engine.install === "other"
|
|
479
|
+
? t("Installed another way, in {folder}: update it the way you installed it.", { folder })
|
|
480
|
+
: engine.failed !== undefined
|
|
481
|
+
? t("npm does not answer: a newer version cannot be checked now.")
|
|
482
|
+
: undefined;
|
|
483
|
+
// A newer one this page does not install is still said, by its version.
|
|
484
|
+
const shownNewer = updated === undefined && engine?.update === true ? engine.latest : undefined;
|
|
485
|
+
return (_jsxs("section", { class: "card", "aria-labelledby": "packages-engine", children: [_jsx(CardHead, { icon: iconPath("engine"), title: _jsx("h3", { id: "packages-engine", tabIndex: -1, children: t("Engine") }) }), _jsx("div", { class: "card-body package-body", children: _jsx("ul", { class: "package-list", children: _jsxs(PackageRow, { tile: "engine", name: engineName, about: t("What runs the game: the master's tools and this page."), meta: engine !== undefined && _jsx(VersionMeta, { version: engine.version, newer: shownNewer }), needs: why === undefined ? undefined : _jsx("span", { class: "package-needs", children: why }), actions: newer !== undefined
|
|
486
|
+
? _jsx(UpdateButton, { id: "engine-update", name: engineName, version: newer, busy: state.busy, onClick: onUpdate })
|
|
487
|
+
: engine?.update === false && engine.install === "global" && updated === undefined && (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), t("Up to date")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said }), updated !== undefined && _jsx(RestartNote, { updated: updated })] }) }) })] }));
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* The engine installed, and how the master comes to use it, in the player's words: this chat goes on with the one it started with; a new chat, or the app
|
|
491
|
+
* opened again, takes the new one, and this page is read again after it, never by itself, as the running game would serve it the new one's files.
|
|
492
|
+
*/
|
|
493
|
+
function RestartNote({ updated }) {
|
|
494
|
+
const note = useRef(null);
|
|
495
|
+
// Just updated, the focus Update had comes here; kept from before a reload, it stays where the page puts it.
|
|
496
|
+
useEffect(() => {
|
|
497
|
+
if (updated.now) {
|
|
498
|
+
note.current?.focus({ preventScroll: true });
|
|
499
|
+
note.current?.scrollIntoView({ block: "nearest" });
|
|
500
|
+
}
|
|
501
|
+
}, []);
|
|
502
|
+
const steps = updated.restart === "app"
|
|
503
|
+
? [t("Quit the app you play in completely, not just its window, then open it again."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")]
|
|
504
|
+
: [t("Close this chat."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")];
|
|
505
|
+
return (_jsxs("div", { ref: note, class: "package-said package-restart", role: "status", tabIndex: -1, children: [_jsx("p", { children: `✓ ${t("RPG Engine {version} is installed.", { version: updated.to })}` }), _jsx("p", { children: t("The master goes on with {version} in this chat. To play with {next}:", { version: updated.from, next: updated.to }) }), _jsx("ol", { children: steps.map((step) => _jsx("li", { children: step }, step)) })] }));
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* What a package's latest needs of the engine (D-515 (2)), under its meta: which version of it, and the way to the engine's card, to update it first; the
|
|
509
|
+
* version offered meanwhile is the newest this engine reads.
|
|
510
|
+
*/
|
|
511
|
+
function NeedsEngine({ newer, canUpdate, onGo }) {
|
|
512
|
+
const { version, engine } = newer;
|
|
513
|
+
return (_jsxs("span", { class: "package-needs", children: [_jsx("span", { children: engine === undefined ? t("Version {version} needs a newer RPG Engine.", { version }) : t("Version {version} needs RPG Engine {engine}.", { version, engine }) }), _jsxs("button", { type: "button", class: "package-see", onClick: onGo, children: [canUpdate ? t("Update RPG Engine first") : t("See RPG Engine"), _jsx(Icon, { name: "fold" })] })] }));
|
|
514
|
+
}
|
|
371
515
|
/**
|
|
372
516
|
* A game system here: the campaign's, chosen in its setup and locked; another, for a new campaign, which can go off this computer when npm installed it; npm's
|
|
373
517
|
* newer version, to update it.
|
|
374
518
|
*/
|
|
375
|
-
function SystemRow({ system, newer, fresh, state, onUpdate, onUninstall }) {
|
|
519
|
+
function SystemRow({ system, newer, needs, fresh, state, onUpdate, onUninstall }) {
|
|
376
520
|
const target = system.package ?? system.name;
|
|
377
|
-
return (_jsxs(PackageRow, { tile: "dice", tone: system.used ? undefined : "dim", name: _jsx("span", { class: "system-chip", children: system.name }), badges: _jsx(Trust, { verified: system.verified, code: system.code }), about: systemTitleLabel(system.title), meta: _jsx(VersionMeta, { version: system.version, newer: newer }), row: `system:${system.name}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: system.name, version: newer, busy: state.busy, onClick: () => onUpdate(target) }), system.used
|
|
521
|
+
return (_jsxs(PackageRow, { tile: "dice", tone: system.used ? undefined : "dim", name: _jsx("span", { class: "system-chip", children: system.name }), badges: _jsx(Trust, { verified: system.verified, code: system.code }), about: systemTitleLabel(system.title), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: system.version, newer: newer }), _jsx(ReportLink, { issues: system.issues, name: system.name, after: system.version !== undefined || newer !== undefined }), _jsx(OwnPageLinks, { name: system.package })] }), needs: needs, row: `system:${system.name}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: system.name, version: newer, busy: state.busy, onClick: () => onUpdate(target) }), system.used
|
|
378
522
|
? (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("In use · chosen in the setup")] }))
|
|
379
523
|
: (_jsxs(_Fragment, { children: [_jsx("span", { class: "package-quiet", children: t("Not in this campaign") }), system.package !== undefined && _jsx(UninstallButton, { name: system.name, busy: state.busy, onClick: () => onUninstall(target) })] }))] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
380
524
|
}
|
|
@@ -386,12 +530,12 @@ function AdventureRow({ adventure, fresh, state, onTakeOut }) {
|
|
|
386
530
|
: (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("Part of the story")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
387
531
|
}
|
|
388
532
|
/** An extension here: whose it is, what it is, its version and npm's newer one; whether the campaign uses it, as a switch; one that does not read, in red. */
|
|
389
|
-
function ExtensionRow({ extension, newer, fresh, state, onUse, onUpdate, onUninstall }) {
|
|
533
|
+
function ExtensionRow({ extension, newer, needs, fresh, state, onUse, onUpdate, onUninstall }) {
|
|
390
534
|
const name = phraseLabel(extension.name);
|
|
391
535
|
if ("broken" in extension) {
|
|
392
|
-
return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not read: install it again.") }), meta: _jsx("bdi", { class: "package-why", children: extension.broken }), actions: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name} again", { name }), "aria-disabled": state.busy, onClick: () => !state.busy && onUpdate(), children: [_jsx(Icon, { name: "update" }), t("Install it again")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
536
|
+
return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not read: install it again.") }), meta: _jsxs(_Fragment, { children: [_jsx("bdi", { class: "package-why", children: extension.broken }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true })] }), actions: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name} again", { name }), "aria-disabled": state.busy, onClick: () => !state.busy && onUpdate(), children: [_jsx(Icon, { name: "update" }), t("Install it again")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
393
537
|
}
|
|
394
|
-
return (_jsxs(PackageRow, { tile: "packages", name: name, badges: _jsx(Trust, { verified: extension.verified, code: false }), about: `${phraseLabel(extension.about.replace(/\.$/, ""))}.`, meta: _jsx(VersionMeta, { version: extension.version, newer: newer }), row: `extension:${extension.package}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: extension.used, "aria-label": t("{name}: in use", { name }), "aria-disabled": state.busy, onClick: (event) => {
|
|
538
|
+
return (_jsxs(PackageRow, { tile: "packages", name: name, badges: _jsx(Trust, { verified: extension.verified, code: false }), about: `${phraseLabel(extension.about.replace(/\.$/, ""))}.`, meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: extension.version, newer: newer }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true }), _jsx(OwnPageLinks, { name: extension.package })] }), needs: needs, row: `extension:${extension.package}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: extension.used, "aria-label": t("{name}: in use", { name }), "aria-disabled": state.busy, onClick: (event) => {
|
|
395
539
|
event.preventDefault();
|
|
396
540
|
if (!state.busy) {
|
|
397
541
|
onUse(!extension.used);
|
|
@@ -404,14 +548,14 @@ function MissingRow({ name, state, onInstall }) {
|
|
|
404
548
|
return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: shown, about: _jsx("span", { class: "package-red", children: t("Missing on this computer: the master does not use it until you install it.") }), actions: _jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name}", { name: shown }), "aria-disabled": state.busy, onClick: () => !state.busy && onInstall(), children: [_jsx(Icon, { name: "download" }), t("Install")] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
405
549
|
}
|
|
406
550
|
/** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
|
|
407
|
-
function LanguageRow({ language, newer, fresh, state, onUpdate, onUninstall }) {
|
|
551
|
+
function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
|
|
408
552
|
const page = pageLanguage().toLowerCase().split("-")[0] === language.code.toLowerCase().split("-")[0];
|
|
409
553
|
const name = languageTitle(language);
|
|
410
|
-
return (_jsxs(PackageRow, { tile: "language", name: name, badges: _jsx(Trust, { verified: language.verified, code: false }), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: language.version, newer: newer }), page && ` · ${t("the language of this page")}
|
|
554
|
+
return (_jsxs(PackageRow, { tile: "language", name: name, badges: _jsx(Trust, { verified: language.verified, code: false }), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: language.version, newer: newer }), page && ` · ${t("the language of this page")}`, _jsx(ReportLink, { issues: language.issues, name: name, after: true })] }), needs: needs, row: `language:${language.code}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
411
555
|
}
|
|
412
556
|
/** A row of the page: the tile, the words, what can be done at the end; under them, the work going on and what happened. */
|
|
413
|
-
function PackageRow({ tile, tone, name, badges, about, meta, actions, focusable, row, fresh, children }) {
|
|
414
|
-
return (_jsxs("li", { class: fresh ? "package-row fresh" : "package-row", ...(focusable || fresh ? { tabIndex: -1 } : {}), ...(row === undefined ? {} : { "data-row": row }), children: [_jsx("span", { class: tone === undefined ? "package-tile" : `package-tile ${tone}`, "aria-hidden": "true", children: _jsx(Icon, { name: tile }) }), _jsxs("span", { class: "package-text", children: [_jsxs("span", { class: "package-name", children: [_jsx("strong", { class: "package-title", children: name }), badges] }), about !== undefined && about !== "" && _jsx("span", { class: "package-about", children: typeof about === "string" ? _jsx("bdi", { children: about }) : about }), meta !== undefined && meta !== false && _jsx("span", { class: "package-meta", children: meta })] }), actions !== undefined && _jsx("span", { class: "package-actions", children: actions }), children] }));
|
|
557
|
+
function PackageRow({ tile, tone, name, badges, about, meta, needs, actions, focusable, row, fresh, children }) {
|
|
558
|
+
return (_jsxs("li", { class: fresh ? "package-row fresh" : "package-row", ...(focusable || fresh ? { tabIndex: -1 } : {}), ...(row === undefined ? {} : { "data-row": row }), children: [_jsx("span", { class: tone === undefined ? "package-tile" : `package-tile ${tone}`, "aria-hidden": "true", children: _jsx(Icon, { name: tile }) }), _jsxs("span", { class: "package-text", children: [_jsxs("span", { class: "package-name", children: [_jsx("strong", { class: "package-title", children: name }), badges] }), about !== undefined && about !== "" && _jsx("span", { class: "package-about", children: typeof about === "string" ? _jsx("bdi", { children: about }) : about }), meta !== undefined && meta !== false && _jsx("span", { class: "package-meta", children: meta }), needs] }), actions !== undefined && _jsx("span", { class: "package-actions", children: actions }), children] }));
|
|
415
559
|
}
|
|
416
560
|
/** Whose a package is: ours, a shield with its tick; someone else's with code, in red with the shield's mark and the word, never the colour alone. */
|
|
417
561
|
function Trust({ verified, code, author }) {
|
|
@@ -428,9 +572,16 @@ function Trust({ verified, code, author }) {
|
|
|
428
572
|
function VersionMeta({ version, newer }) {
|
|
429
573
|
return (_jsxs(_Fragment, { children: [version, version !== undefined && newer !== undefined && " · ", newer !== undefined && (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), t("new {version}", { version: newer })] }))] }));
|
|
430
574
|
}
|
|
575
|
+
/** Where the package's problems are reported, as its package.json says: after what its meta says before it, on a line of its own on a phone; nothing when it says nowhere. */
|
|
576
|
+
export function ReportLink({ issues, name, after }) {
|
|
577
|
+
if (issues === undefined) {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
return (_jsxs(_Fragment, { children: [after && _jsx("span", { class: "package-report-gap", children: " · " }), _jsx("a", { class: "package-report", href: issues, target: "_blank", rel: "noreferrer", "aria-label": t("Report a problem with {name}", { name }), children: t("Report a problem") })] }));
|
|
581
|
+
}
|
|
431
582
|
/** Update, for a row npm has a newer version of. */
|
|
432
|
-
function UpdateButton({ name, version, busy, onClick }) {
|
|
433
|
-
return (_jsxs("button", { type: "button", class: "button package-button accent", "aria-label": t("Update {name} to {version}", { name, version }), "aria-disabled": busy, onClick: () => !busy && onClick(), children: [_jsx(Icon, { name: "update" }), t("Update")] }));
|
|
583
|
+
function UpdateButton({ id, name, version, busy, onClick }) {
|
|
584
|
+
return (_jsxs("button", { type: "button", id: id, class: "button package-button accent", "aria-label": t("Update {name} to {version}", { name, version }), "aria-disabled": busy, onClick: () => !busy && onClick(), children: [_jsx(Icon, { name: "update" }), t("Update")] }));
|
|
434
585
|
}
|
|
435
586
|
/** The bin that takes a package off this computer, after asking. */
|
|
436
587
|
function UninstallButton({ name, busy, onClick }) {
|
|
@@ -542,9 +693,13 @@ function samePackage(entry, name) {
|
|
|
542
693
|
}
|
|
543
694
|
/** npm's newer version of a package here, as the catalog says it. */
|
|
544
695
|
function newerOf(name, kind, catalog) {
|
|
545
|
-
const entry =
|
|
696
|
+
const entry = entryOf(name, kind, catalog);
|
|
546
697
|
return entry?.update === true ? entry.version : undefined;
|
|
547
698
|
}
|
|
699
|
+
/** A package here as the catalog has it. */
|
|
700
|
+
function entryOf(name, kind, catalog) {
|
|
701
|
+
return catalog?.entries.find((one) => one.kind === kind && samePackage(one, name));
|
|
702
|
+
}
|
|
548
703
|
/** How many packages here npm has a newer version of: the count on the Installed tab. */
|
|
549
704
|
function updateCount(view, catalog) {
|
|
550
705
|
const systems = (view.systems ?? []).filter((one) => one.package !== undefined && newerOf(one.package, "system", catalog) !== undefined);
|
|
@@ -564,7 +719,7 @@ function rowKeys(view) {
|
|
|
564
719
|
/** Whose a work is, said away from its row: a catalog's package by its title, else as it was asked. */
|
|
565
720
|
function workTitle(work, catalog) {
|
|
566
721
|
const entry = catalog?.entries.find((one) => `catalog:${one.source}` === work.at);
|
|
567
|
-
return entry === undefined ? work.name.replace(/^npm:/, "") : entryTitle(entry);
|
|
722
|
+
return work.action === "engine" ? engineName : entry === undefined ? work.name.replace(/^npm:/, "") : entryTitle(entry);
|
|
568
723
|
}
|
|
569
724
|
/** The tab of a place of the page: the field and the catalog are Add's, the library's field and folders the Library's, the rest Installed's. */
|
|
570
725
|
function tabOf(at) {
|
|
@@ -585,8 +740,8 @@ function workPlace(work, view, catalog) {
|
|
|
585
740
|
const system = view.systems?.find((one) => same(one.name, one.package));
|
|
586
741
|
const language = view.languages?.find((one) => same(one.code, one.package));
|
|
587
742
|
const entry = catalog?.entries.find((one) => same(one.source));
|
|
588
|
-
if (work.action === "library") {
|
|
589
|
-
return
|
|
743
|
+
if (work.action === "library" || work.action === "engine") {
|
|
744
|
+
return work.action;
|
|
590
745
|
}
|
|
591
746
|
if (work.action === "add") {
|
|
592
747
|
return entry !== undefined ? `catalog:${entry.source}` : extension !== undefined ? `extension:${extension}` : "add";
|
|
@@ -644,6 +799,7 @@ function workingText(action) {
|
|
|
644
799
|
remove: t("Taking it out of the campaign…"),
|
|
645
800
|
uninstall: t("Uninstalling…"),
|
|
646
801
|
library: t("Changing the library…"),
|
|
802
|
+
engine: t("Updating RPG Engine…"),
|
|
647
803
|
};
|
|
648
804
|
return texts[action];
|
|
649
805
|
}
|