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.
Files changed (229) hide show
  1. package/README.md +9 -6
  2. package/dist/adventures/index.d.ts +1 -1
  3. package/dist/adventures/index.js +1 -1
  4. package/dist/adventures/source.d.ts +3 -0
  5. package/dist/adventures/source.js +11 -49
  6. package/dist/campaign/create-campaign.d.ts +1 -1
  7. package/dist/campaign/create-campaign.js +4 -3
  8. package/dist/campaign/find-campaign.d.ts +6 -0
  9. package/dist/campaign/find-campaign.js +7 -1
  10. package/dist/campaign/host-files.js +22 -0
  11. package/dist/campaign/index.d.ts +2 -2
  12. package/dist/campaign/index.js +2 -2
  13. package/dist/campaign/last-choices.d.ts +10 -4
  14. package/dist/campaign/last-choices.js +43 -17
  15. package/dist/campaign/settings.d.ts +10 -2
  16. package/dist/campaign/settings.js +32 -8
  17. package/dist/chats/chat.d.ts +33 -0
  18. package/dist/chats/chat.js +50 -0
  19. package/dist/chats/claude-code.d.ts +5 -0
  20. package/dist/chats/claude-code.js +39 -0
  21. package/dist/chats/codex.d.ts +3 -0
  22. package/dist/chats/codex.js +42 -0
  23. package/dist/chats/index.d.ts +5 -0
  24. package/dist/chats/index.js +12 -0
  25. package/dist/chats/keep.d.ts +10 -0
  26. package/dist/chats/keep.js +50 -0
  27. package/dist/chats/read.d.ts +8 -0
  28. package/dist/chats/read.js +46 -0
  29. package/dist/cli/cli.js +6 -1
  30. package/dist/cli/command-line.js +3 -2
  31. package/dist/commands/book.d.ts +36 -0
  32. package/dist/commands/book.js +129 -0
  33. package/dist/commands/chats.d.ts +38 -0
  34. package/dist/commands/chats.js +93 -0
  35. package/dist/commands/config/config.js +2 -2
  36. package/dist/commands/config/dashboard.d.ts +8 -1
  37. package/dist/commands/config/dashboard.js +70 -16
  38. package/dist/commands/config/words.d.ts +1 -1
  39. package/dist/commands/config/words.js +18 -5
  40. package/dist/commands/find.js +1 -1
  41. package/dist/commands/image.d.ts +14 -0
  42. package/dist/commands/image.js +100 -20
  43. package/dist/commands/index.js +4 -0
  44. package/dist/commands/init.js +3 -3
  45. package/dist/commands/package/data.d.ts +35 -0
  46. package/dist/commands/package/data.js +117 -0
  47. package/dist/commands/package/here.d.ts +7 -2
  48. package/dist/commands/package/here.js +23 -11
  49. package/dist/commands/package/install.js +14 -15
  50. package/dist/commands/package/language.d.ts +15 -0
  51. package/dist/commands/package/language.js +109 -0
  52. package/dist/commands/package/package.js +20 -10
  53. package/dist/commands/package/result.d.ts +19 -0
  54. package/dist/commands/package/theme.d.ts +13 -0
  55. package/dist/commands/package/theme.js +66 -0
  56. package/dist/commands/package/uninstall.d.ts +4 -1
  57. package/dist/commands/package/uninstall.js +29 -9
  58. package/dist/commands/scene/close.d.ts +2 -0
  59. package/dist/commands/scene/close.js +20 -2
  60. package/dist/commands/scene/result.d.ts +2 -0
  61. package/dist/commands/scene/scene.d.ts +2 -0
  62. package/dist/commands/shared/books/adventures.d.ts +0 -4
  63. package/dist/commands/shared/books/adventures.js +2 -31
  64. package/dist/commands/shared/books/words.js +3 -2
  65. package/dist/commands/shared/campaign/book.d.ts +42 -0
  66. package/dist/commands/shared/campaign/book.js +118 -0
  67. package/dist/commands/shared/campaign/chats.d.ts +11 -0
  68. package/dist/commands/shared/campaign/chats.js +29 -0
  69. package/dist/commands/shared/campaign/images.js +7 -1
  70. package/dist/commands/shared/campaign/mode.js +3 -1
  71. package/dist/commands/shared/campaign/saves.js +13 -5
  72. package/dist/commands/shared/campaign/world.js +2 -1
  73. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  74. package/dist/commands/shared/packages/catalog.js +98 -42
  75. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  76. package/dist/commands/shared/packages/unpacked.js +146 -0
  77. package/dist/commands/shared/sheet/sheet.d.ts +7 -0
  78. package/dist/commands/shared/sheet/sheet.js +27 -0
  79. package/dist/commands/status.d.ts +1 -0
  80. package/dist/commands/status.js +4 -0
  81. package/dist/commands/view/page.js +4 -3
  82. package/dist/commands/view/result.d.ts +2 -0
  83. package/dist/commands/view/view.d.ts +1 -0
  84. package/dist/commands/view/view.js +4 -0
  85. package/dist/core/archive.d.ts +13 -0
  86. package/dist/core/archive.js +76 -0
  87. package/dist/core/consents.d.ts +2 -2
  88. package/dist/core/consents.js +3 -3
  89. package/dist/core/context.d.ts +40 -2
  90. package/dist/core/context.js +1 -0
  91. package/dist/core/download.js +1 -1
  92. package/dist/core/store.d.ts +5 -1
  93. package/dist/core/store.js +15 -2
  94. package/dist/dashboard/acts/names.js +10 -5
  95. package/dist/dashboard/acts/sending.js +5 -2
  96. package/dist/dashboard/acts/sheet.js +66 -15
  97. package/dist/dashboard/api.js +27 -4
  98. package/dist/dashboard/app.js +9 -4
  99. package/dist/dashboard/guide/ar.md +16 -15
  100. package/dist/dashboard/guide/cs.md +15 -14
  101. package/dist/dashboard/guide/da.md +17 -16
  102. package/dist/dashboard/guide/de.md +17 -16
  103. package/dist/dashboard/guide/el.md +17 -16
  104. package/dist/dashboard/guide/en.md +14 -13
  105. package/dist/dashboard/guide/es.md +15 -14
  106. package/dist/dashboard/guide/fi.md +15 -14
  107. package/dist/dashboard/guide/fr.md +20 -19
  108. package/dist/dashboard/guide/he.md +15 -14
  109. package/dist/dashboard/guide/hi.md +15 -14
  110. package/dist/dashboard/guide/hu.md +19 -18
  111. package/dist/dashboard/guide/is.md +15 -14
  112. package/dist/dashboard/guide/it.md +18 -17
  113. package/dist/dashboard/guide/ja.md +15 -14
  114. package/dist/dashboard/guide/ko.md +16 -15
  115. package/dist/dashboard/guide/nb.md +17 -16
  116. package/dist/dashboard/guide/nl.md +15 -14
  117. package/dist/dashboard/guide/pl.md +16 -15
  118. package/dist/dashboard/guide/pt.md +16 -15
  119. package/dist/dashboard/guide/ro.md +15 -14
  120. package/dist/dashboard/guide/ru.md +16 -15
  121. package/dist/dashboard/guide/sv.md +15 -14
  122. package/dist/dashboard/guide/tr.md +18 -17
  123. package/dist/dashboard/guide/uk.md +19 -18
  124. package/dist/dashboard/guide/zh.md +16 -15
  125. package/dist/dashboard/i18n/ar.json +63 -9
  126. package/dist/dashboard/i18n/cs.json +63 -9
  127. package/dist/dashboard/i18n/da.json +63 -9
  128. package/dist/dashboard/i18n/de.json +63 -9
  129. package/dist/dashboard/i18n/el.json +63 -9
  130. package/dist/dashboard/i18n/es.json +63 -9
  131. package/dist/dashboard/i18n/fi.json +63 -9
  132. package/dist/dashboard/i18n/fr.json +63 -9
  133. package/dist/dashboard/i18n/he.json +63 -9
  134. package/dist/dashboard/i18n/hi.json +63 -9
  135. package/dist/dashboard/i18n/hu.json +63 -9
  136. package/dist/dashboard/i18n/is.json +63 -9
  137. package/dist/dashboard/i18n/it.json +64 -10
  138. package/dist/dashboard/i18n/ja.json +63 -9
  139. package/dist/dashboard/i18n/ko.json +63 -9
  140. package/dist/dashboard/i18n/nb.json +63 -9
  141. package/dist/dashboard/i18n/nl.json +63 -9
  142. package/dist/dashboard/i18n/pl.json +63 -9
  143. package/dist/dashboard/i18n/pt.json +63 -9
  144. package/dist/dashboard/i18n/ro.json +63 -9
  145. package/dist/dashboard/i18n/ru.json +63 -9
  146. package/dist/dashboard/i18n/sv.json +63 -9
  147. package/dist/dashboard/i18n/tr.json +63 -9
  148. package/dist/dashboard/i18n/uk.json +63 -9
  149. package/dist/dashboard/i18n/zh.json +63 -9
  150. package/dist/dashboard/journal/book.js +107 -0
  151. package/dist/dashboard/journal/journal.js +16 -12
  152. package/dist/dashboard/kit.js +1 -1
  153. package/dist/dashboard/packages/catalog.js +31 -14
  154. package/dist/dashboard/packages/engine.js +46 -2
  155. package/dist/dashboard/packages/installed.js +13 -0
  156. package/dist/dashboard/packages/outcomes.js +21 -0
  157. package/dist/dashboard/packages/packages.js +41 -18
  158. package/dist/dashboard/packages/rows.js +3 -1
  159. package/dist/dashboard/parts/icons.js +3 -0
  160. package/dist/dashboard/parts/labels.js +6 -0
  161. package/dist/dashboard/parts/picture.js +89 -0
  162. package/dist/dashboard/parts/refusals.js +8 -1
  163. package/dist/dashboard/parts/widgets.js +3 -2
  164. package/dist/dashboard/place/view.js +1 -1
  165. package/dist/dashboard/play/scene.js +8 -5
  166. package/dist/dashboard/settings/settings.js +32 -16
  167. package/dist/dashboard/settings/setup.js +5 -3
  168. package/dist/dashboard/sheet/party.js +5 -2
  169. package/dist/dashboard/sheet/sheet.js +10 -6
  170. package/dist/dashboard/shell/notices.js +2 -2
  171. package/dist/dashboard/shell/system-style.js +45 -12
  172. package/dist/dashboard/shell/tooltip.js +223 -0
  173. package/dist/dashboard/style.css +775 -261
  174. package/dist/dashboard/world/calendar.js +1 -1
  175. package/dist/dashboard/world/lore.js +5 -4
  176. package/dist/dashboard/world/place-card.js +2 -1
  177. package/dist/helpers/briefs.d.ts +5 -0
  178. package/dist/helpers/briefs.js +8 -0
  179. package/dist/helpers/chosen.d.ts +8 -2
  180. package/dist/helpers/chosen.js +110 -6
  181. package/dist/helpers/codex.js +2 -1
  182. package/dist/helpers/index.d.ts +2 -2
  183. package/dist/helpers/index.js +2 -2
  184. package/dist/images/images.d.ts +2 -0
  185. package/dist/images/images.js +16 -2
  186. package/dist/images/index.d.ts +1 -1
  187. package/dist/images/index.js +1 -1
  188. package/dist/languages/index.d.ts +1 -1
  189. package/dist/languages/index.js +1 -1
  190. package/dist/languages/pack.d.ts +4 -1
  191. package/dist/languages/pack.js +16 -5
  192. package/dist/packages/engine.d.ts +7 -0
  193. package/dist/packages/engine.js +32 -1
  194. package/dist/packages/index.d.ts +1 -1
  195. package/dist/packages/index.js +1 -1
  196. package/dist/server/approver.d.ts +6 -0
  197. package/dist/server/approver.js +28 -0
  198. package/dist/server/chats.d.ts +3 -0
  199. package/dist/server/chats.js +27 -0
  200. package/dist/server/dashboard/engine.d.ts +18 -0
  201. package/dist/server/dashboard/engine.js +31 -0
  202. package/dist/server/dashboard/files.d.ts +8 -1
  203. package/dist/server/dashboard/files.js +30 -10
  204. package/dist/server/dashboard/index.d.ts +3 -0
  205. package/dist/server/dashboard/index.js +10 -1
  206. package/dist/server/dashboard/news.js +36 -5
  207. package/dist/server/dashboard/pictures.d.ts +7 -0
  208. package/dist/server/dashboard/pictures.js +62 -0
  209. package/dist/server/dashboard/writes.d.ts +5 -3
  210. package/dist/server/dashboard/writes.js +45 -14
  211. package/dist/server/mcp.js +37 -6
  212. package/dist/server/player-acts.d.ts +7 -2
  213. package/dist/server/player-acts.js +10 -3
  214. package/dist/testing/index.js +1 -0
  215. package/dist/themes/index.d.ts +2 -1
  216. package/dist/themes/index.js +4 -2
  217. package/dist/themes/installed.d.ts +14 -0
  218. package/dist/themes/installed.js +28 -0
  219. package/dist/themes/theme.d.ts +7 -0
  220. package/dist/themes/theme.js +22 -0
  221. package/instructions/core.md +3 -3
  222. package/instructions/dashboard-guide.md +1 -0
  223. package/instructions/mentor-hints.md +1 -1
  224. package/instructions/mentor-tutorial.md +1 -1
  225. package/instructions/party.md +1 -1
  226. package/instructions/play.md +2 -2
  227. package/instructions/start.md +1 -1
  228. package/package.json +2 -2
  229. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -1,6 +1,7 @@
1
- // The catalog of the packages one may add (D-485, D-486): what npm has for this rpg-engine, extensions, game systems and languages, and the adventures
2
- // GitHub has by their topic, each with what the player needs to trust it and whether it is here already.
1
+ // The catalog of the packages one may add (D-485, D-486): what npm has for this rpg-engine, extensions, game systems and languages, and the packages of data
2
+ // alone GitHub has by their topic, adventures, themes and languages, each with what the player needs to trust it and whether it is here already.
3
3
  import { join } from "node:path";
4
+ import { parse } from "yaml";
4
5
  import { readManifest } from "../../../adventures/index.js";
5
6
  import { ourSystems, readsApi } from "../../../core/packages/declarations.js";
6
7
  import { files } from "../../../core/store.js";
@@ -11,6 +12,7 @@ import { installedLanguages } from "../../../languages/index.js";
11
12
  import { isVerified } from "../../../packages/index.js";
12
13
  import { systemFolders } from "../../../systems/index.js";
13
14
  import { installedAdventures } from "../books/adventures.js";
15
+ import { isDataLanguage, isSameSource, languageFolders, themesHere, unpackedSource } from "./unpacked.js";
14
16
  // How long the setup waits for npm before it offers ours alone.
15
17
  const systemsWait = 5000;
16
18
  /** The game systems npm has that this computer has not, ours first, with ours from the engine's list beside them, npm answering in time or not (D-513 (1)). */
@@ -34,10 +36,14 @@ export async function installableSystems(context) {
34
36
  const here = systemFolders(context.systemFolders).map((one) => comparableText(one.name));
35
37
  return listed.filter((system) => !here.includes(installedName(system))).sort((first, second) => Number(second.verified) - Number(first.verified) || first.name.localeCompare(second.name));
36
38
  }
37
- /** The topic a GitHub repository carries to be found as an adventure (D-485 (4)). */
38
- const adventureTopic = "rpg-engine-adventure";
39
- // How many repositories are read, each with its adventure.yaml: GitHub answers without a login only so many times an hour.
40
- const mostAdventures = 30;
39
+ /** The topic a GitHub repository carries to be found, by the kind of package of data alone it is (D-485 (4)), and the file at its top that says what it is. */
40
+ const githubTopics = [
41
+ { kind: "adventure", topic: "rpg-engine-adventure", file: "adventure.yaml" },
42
+ { kind: "theme", topic: "rpg-engine-theme", file: "theme.yaml" },
43
+ { kind: "language", topic: "rpg-engine-language", file: "language.yaml" },
44
+ ];
45
+ // How many repositories of each topic are read, each with the file at its top: GitHub answers a search without a login only so many times an hour.
46
+ const mostRepositories = 20;
41
47
  const kinds = new Set(["system", "extension", "language"]);
42
48
  /** What npm and GitHub offer now, ours first, then by title; each source asked once, side by side. */
43
49
  export async function catalog(root, context) {
@@ -84,7 +90,7 @@ function installedVersion(context, found) {
84
90
  }
85
91
  }
86
92
  if (found.kind === "language") {
87
- return installedLanguages(context.extensionFolders ?? []).find((one) => one.package === found.name)?.version;
93
+ return installedLanguages(languageFolders(context)).find((one) => one.package === found.name)?.version;
88
94
  }
89
95
  // A system npm installed, by its package's own version.
90
96
  const folder = systemFolders(context.systemFolders).find((one) => packageIn(one.folder)?.name === found.name)?.folder;
@@ -98,47 +104,97 @@ function packageIn(folder) {
98
104
  return undefined;
99
105
  }
100
106
  }
101
- /** The adventures GitHub has by their topic, each read from its adventure.yaml; a repository without one that reads is left out. */
107
+ /**
108
+ * The adventures, themes and languages GitHub has by their topics, the three searches side by side, each repository read from the file at its top; one without
109
+ * one that reads is left out, and a search that fails leaves the others listed.
110
+ */
102
111
  async function githubEntries(root, context) {
103
- if (context.download === undefined) {
104
- return { entries: [], failed: "only the game's server and the command line reach GitHub" };
105
- }
106
112
  const download = context.download;
107
- let repositories;
108
- try {
109
- const found = JSON.parse(new TextDecoder().decode(await download(`https://api.github.com/search/repositories?q=topic:${adventureTopic}&sort=stars&per_page=${mostAdventures}`, 2 * 1024 * 1024, context.signal)));
110
- repositories = found.items ?? [];
111
- }
112
- catch (error) {
113
- return { entries: [], failed: `GitHub could not be asked: ${error instanceof Error ? error.message : String(error)}` };
113
+ if (download === undefined) {
114
+ return { entries: [], failed: "only the game's server and the command line reach GitHub" };
114
115
  }
115
- const here = installedAdventures(root);
116
- const read = await Promise.all(repositories.map(async (repository) => {
116
+ const searched = await Promise.all(githubTopics.map(async (topic) => {
117
+ try {
118
+ const url = `https://api.github.com/search/repositories?q=topic:${topic.topic}&sort=stars&per_page=${mostRepositories}`;
119
+ const found = JSON.parse(new TextDecoder().decode(await download(url, 2 * 1024 * 1024, context.signal)));
120
+ return { topic, repositories: found.items ?? [] };
121
+ }
122
+ catch (error) {
123
+ // The reason without the long address, so that three searches refused alike read as one.
124
+ const why = (error instanceof Error ? error.message : String(error)).replace(/^https:\/\/\S+ /, "").replace(/: check the address.*$/, "");
125
+ return { topic, repositories: [], failed: why };
126
+ }
127
+ }));
128
+ const here = { adventures: installedAdventures(root), themes: themesHere(context), languages: installedLanguages(languageFolders(context)).filter((one) => isDataLanguage(context, one)) };
129
+ const read = await Promise.all(searched.flatMap(({ topic, repositories }) => repositories.map(async (repository) => {
117
130
  try {
118
- const text = new TextDecoder().decode(await download(`https://raw.githubusercontent.com/${repository.full_name}/${repository.default_branch}/adventure.yaml`, 64 * 1024, context.signal));
119
- const manifest = readManifest(text, repository.full_name);
120
- const installed = here.find((one) => comparableText(one.title) === comparableText(manifest.title))?.version;
121
- const levels = manifest.levels === undefined ? undefined : manifest.levels.from === manifest.levels.to ? String(manifest.levels.from) : `${manifest.levels.from}-${manifest.levels.to}`;
122
- return {
123
- kind: "adventure",
124
- title: manifest.title,
125
- description: manifest.about,
126
- author: manifest.author ?? repository.owner?.login,
127
- version: manifest.version,
128
- verified: false,
129
- code: false,
130
- source: repository.html_url,
131
- ...(installed === undefined ? {} : { installed }),
132
- update: installed !== undefined && isNewerVersion(manifest.version, installed),
133
- ...(levels === undefined ? {} : { levels }),
134
- ...(manifest.length === undefined ? {} : { length: manifest.length }),
135
- language: manifest.language,
136
- ...(repository.stargazers_count === undefined ? {} : { stars: repository.stargazers_count }),
137
- };
131
+ const raw = `https://raw.githubusercontent.com/${repository.full_name}/${repository.default_branch}/${topic.file}`;
132
+ const text = new TextDecoder().decode(await download(raw, 64 * 1024, context.signal));
133
+ return topic.kind === "adventure"
134
+ ? adventureEntry(repository, readManifest(text, repository.full_name), here)
135
+ : topic.kind === "theme"
136
+ ? themeEntry(repository, text, here)
137
+ : languageEntry(repository, text, here);
138
138
  }
139
139
  catch {
140
140
  return undefined;
141
141
  }
142
- }));
143
- return { entries: read.filter((one) => one !== undefined) };
142
+ })));
143
+ const reasons = [...new Set(searched.flatMap((one) => (one.failed === undefined ? [] : [one.failed])))];
144
+ const failed = reasons.map((why) => `GitHub could not be asked for its ${searched.filter((one) => one.failed === why).map((one) => `${one.topic.kind}s`).join(" and ")}: ${why}`);
145
+ return { entries: read.filter((one) => one !== undefined), ...(failed.length === 0 ? {} : { failed: failed.join("; ") }) };
146
+ }
147
+ /** An adventure GitHub has, as its adventure.yaml says. */
148
+ function adventureEntry(repository, manifest, here) {
149
+ const installed = here.adventures.find((one) => comparableText(one.title) === comparableText(manifest.title))?.version;
150
+ const levels = manifest.levels === undefined ? undefined : manifest.levels.from === manifest.levels.to ? String(manifest.levels.from) : `${manifest.levels.from}-${manifest.levels.to}`;
151
+ const author = manifest.author ?? repository.owner?.login;
152
+ return {
153
+ ...githubEntry("adventure", repository, manifest.title, manifest.version, installed),
154
+ description: manifest.about,
155
+ ...(author === undefined ? {} : { author }),
156
+ ...(levels === undefined ? {} : { levels }),
157
+ ...(manifest.length === undefined ? {} : { length: manifest.length }),
158
+ language: manifest.language,
159
+ };
160
+ }
161
+ /** A theme GitHub has, by the name and version its theme.yaml gives; here only when it was installed from this repository. Its checks are made as it is installed. */
162
+ function themeEntry(repository, text, here) {
163
+ const read = parse(text);
164
+ if (typeof read?.name !== "string" || read.name.trim() === "") {
165
+ return undefined;
166
+ }
167
+ const name = read.name;
168
+ const found = here.themes.find((one) => isSameSource(unpackedSource(one.folder), repository.html_url));
169
+ return githubEntry("theme", repository, name, versionOf(read.version), found === undefined ? undefined : (found.theme?.version ?? ""));
170
+ }
171
+ /** A language GitHub has, by the code, name and version its language.yaml gives: here only when it was installed from this repository, never npm's. */
172
+ function languageEntry(repository, text, here) {
173
+ const read = parse(text);
174
+ if (typeof read?.code !== "string" || typeof read.name !== "string") {
175
+ return undefined;
176
+ }
177
+ const code = read.code;
178
+ const installed = here.languages.find((one) => isSameSource(unpackedSource(one.folder), repository.html_url))?.version;
179
+ return { ...githubEntry("language", repository, read.name, versionOf(read.version), installed), language: code };
180
+ }
181
+ /** What every package GitHub has gives: never verified, never code, added by its link; its version here, and whether GitHub's is newer: only when both are known. */
182
+ function githubEntry(kind, repository, title, version, installed) {
183
+ return {
184
+ kind,
185
+ title,
186
+ ...(typeof repository.description === "string" ? { description: repository.description } : {}),
187
+ ...(repository.owner?.login === undefined ? {} : { author: repository.owner.login }),
188
+ ...(version === undefined ? {} : { version }),
189
+ verified: false,
190
+ code: false,
191
+ source: repository.html_url,
192
+ ...(installed === undefined ? {} : { installed }),
193
+ update: installed !== undefined && installed !== "" && version !== undefined && isNewerVersion(version, installed),
194
+ ...(repository.stargazers_count === undefined ? {} : { stars: repository.stargazers_count }),
195
+ };
196
+ }
197
+ /** A version as a YAML file may write it, 1.0 a number; undefined when it gives none. */
198
+ function versionOf(value) {
199
+ return typeof value === "string" || typeof value === "number" ? String(value) : undefined;
144
200
  }
@@ -0,0 +1,50 @@
1
+ import type { PackageEntry } from "../../../core/archive.ts";
2
+ import type { Context } from "../../../core/context.ts";
3
+ import { type LanguagePack } from "../../../languages/index.ts";
4
+ import { type InstalledTheme } from "../../../themes/index.ts";
5
+ /** The most the files a theme or a language keeps may weigh, all together: faces and pictures, or phrases and a Guide. */
6
+ export declare const largestUnpacked: number;
7
+ /** The most the .zip of a theme or a language may unpack to, before what it keeps is chosen. */
8
+ export declare const largestDataZip: number;
9
+ /** The folder of the themes installed on their own; undefined where nothing installs them. */
10
+ export declare function themesFolder(context: Context): string | undefined;
11
+ /** The folder of the languages installed as data alone; undefined where nothing installs them. */
12
+ export declare function dataLanguagesFolder(context: Context): string | undefined;
13
+ /** The folders languages are read from: npm's packages first, then those of data alone. */
14
+ export declare function languageFolders(context: Context): string[];
15
+ /** The themes installed on this computer, those refused included with why. */
16
+ export declare function themesHere(context: Context): InstalledTheme[];
17
+ /** An installed theme by its id or its name; undefined when there is none. */
18
+ export declare function findTheme(context: Context, name: string): InstalledTheme | undefined;
19
+ /** A theme or a language of data alone, as a name finds it. */
20
+ export type Unpacked = {
21
+ kind: "theme";
22
+ theme: InstalledTheme;
23
+ } | {
24
+ kind: "language";
25
+ pack: LanguagePack;
26
+ };
27
+ /**
28
+ * The theme or the language of data alone a name finds: theme:<id or name> and language:<code or name> name one kind alone; an npm name, @scope/name or
29
+ * npm:name, none. Without a prefix a theme first, then a language; undefined when none is here.
30
+ */
31
+ export declare function findUnpacked(context: Context, name: string): Unpacked | undefined;
32
+ /** How a theme or a language of data alone is named to be told from an npm package of the same name: theme:<id>, language:<code>. */
33
+ export declare function unpackedName(found: Unpacked): string;
34
+ /** Where a theme or a language of data alone came from, as it was installed: a GitHub repository's link, another link, a .zip's or a folder's path. */
35
+ export declare function unpackedSource(folder: string): string | undefined;
36
+ /** Whether a link a catalog gives is where a package here came from: GitHub's links are the same in any case, with or without a slash at their end. */
37
+ export declare function isSameSource(recorded: string | undefined, link: string): boolean;
38
+ /** Whether a language package is one of data alone, unpacked by the engine rather than installed by npm. */
39
+ export declare function isDataLanguage(context: Context, pack: LanguagePack): boolean;
40
+ /** A language of data alone by its code, its name or its package's name; undefined when there is none. */
41
+ export declare function findDataLanguage(context: Context, name: string): LanguagePack | undefined;
42
+ /** The files of a package of data a theme or a language keeps, those `keep` takes; refused, with `code`, when they weigh more than `what` may, or come twice. */
43
+ export declare function keptFiles(label: string, entries: PackageEntry[], keep: (parts: string[]) => boolean, code: string, what: string): PackageEntry[];
44
+ /**
45
+ * Writes a package's files, with where it came from, into a folder of its own beside those installed, which no list reads, for it to be checked there; the
46
+ * folders an install left behind more than an hour ago go first.
47
+ */
48
+ export declare function writeTrial(folder: string, context: Context, entries: PackageEntry[], source: string): string;
49
+ /** Puts a folder checked in place of the one there, each move in one step: the one before is set aside, then taken away once the new one is there. */
50
+ export declare function placeTrial(trial: string, target: string, context: Context): void;
@@ -0,0 +1,146 @@
1
+ // Where the packages of data alone live on this computer, for every campaign: themes and languages unpacked by the engine, apart from npm's packages.
2
+ import { dirname, join } from "node:path";
3
+ import { refuseTwice } from "../../../core/archive-paths.js";
4
+ import { Refusal } from "../../../core/refusal.js";
5
+ import { files, isInside } from "../../../core/store.js";
6
+ import { comparableText } from "../../../core/text.js";
7
+ import { installedLanguages } from "../../../languages/index.js";
8
+ import { installedThemes } from "../../../themes/index.js";
9
+ /** The most the files a theme or a language keeps may weigh, all together: faces and pictures, or phrases and a Guide. */
10
+ export const largestUnpacked = 20 * 1024 * 1024;
11
+ /** The most the .zip of a theme or a language may unpack to, before what it keeps is chosen. */
12
+ export const largestDataZip = 50 * 1024 * 1024;
13
+ // The file beside a theme's or a language's own where it came from: a dot, so that no package brings one of its own.
14
+ const sourceFileName = ".source";
15
+ // How long a folder being unpacked may lie before it is taken for one an install left behind.
16
+ const staleAfter = 60 * 60 * 1000;
17
+ /** The folder of the themes installed on their own; undefined where nothing installs them. */
18
+ export function themesFolder(context) {
19
+ return context.unpacked === undefined ? undefined : join(context.unpacked, "themes");
20
+ }
21
+ /** The folder of the languages installed as data alone; undefined where nothing installs them. */
22
+ export function dataLanguagesFolder(context) {
23
+ return context.unpacked === undefined ? undefined : join(context.unpacked, "languages");
24
+ }
25
+ /** The folders languages are read from: npm's packages first, then those of data alone. */
26
+ export function languageFolders(context) {
27
+ const data = dataLanguagesFolder(context);
28
+ return [...(context.extensionFolders ?? []), ...(data === undefined ? [] : [data])];
29
+ }
30
+ /** The themes installed on this computer, those refused included with why. */
31
+ export function themesHere(context) {
32
+ const folder = themesFolder(context);
33
+ return folder === undefined ? [] : installedThemes(folder);
34
+ }
35
+ /** An installed theme by its id or its name; undefined when there is none. */
36
+ export function findTheme(context, name) {
37
+ return themesHere(context).find((one) => one.id === name.trim() || (one.theme !== undefined && comparableText(one.theme.name) === comparableText(name)));
38
+ }
39
+ /**
40
+ * The theme or the language of data alone a name finds: theme:<id or name> and language:<code or name> name one kind alone; an npm name, @scope/name or
41
+ * npm:name, none. Without a prefix a theme first, then a language; undefined when none is here.
42
+ */
43
+ export function findUnpacked(context, name) {
44
+ const prefixed = /^(theme|language):(.+)$/i.exec(name.trim());
45
+ const kind = prefixed?.[1].toLowerCase();
46
+ const asked = prefixed?.[2] ?? name;
47
+ if (prefixed === null && /^(@|npm:)/i.test(name.trim())) {
48
+ return undefined;
49
+ }
50
+ const theme = kind === "language" ? undefined : findTheme(context, asked);
51
+ const pack = kind === "theme" || theme !== undefined ? undefined : findDataLanguage(context, asked);
52
+ return theme !== undefined ? { kind: "theme", theme } : pack !== undefined ? { kind: "language", pack } : undefined;
53
+ }
54
+ /** How a theme or a language of data alone is named to be told from an npm package of the same name: theme:<id>, language:<code>. */
55
+ export function unpackedName(found) {
56
+ return found.kind === "theme" ? `theme:${found.theme.id}` : `language:${found.pack.code}`;
57
+ }
58
+ /** Where a theme or a language of data alone came from, as it was installed: a GitHub repository's link, another link, a .zip's or a folder's path. */
59
+ export function unpackedSource(folder) {
60
+ return files().text(join(folder, sourceFileName))?.trim() || undefined;
61
+ }
62
+ /** Whether a link a catalog gives is where a package here came from: GitHub's links are the same in any case, with or without a slash at their end. */
63
+ export function isSameSource(recorded, link) {
64
+ const plain = (text) => text.trim().replace(/(\.git)?\/*$/i, "").toLowerCase();
65
+ return recorded !== undefined && plain(recorded) === plain(link);
66
+ }
67
+ /** Whether a language package is one of data alone, unpacked by the engine rather than installed by npm. */
68
+ export function isDataLanguage(context, pack) {
69
+ const folder = dataLanguagesFolder(context);
70
+ return folder !== undefined && isInside(folder, pack.folder);
71
+ }
72
+ /** A language of data alone by its code, its name or its package's name; undefined when there is none. */
73
+ export function findDataLanguage(context, name) {
74
+ const wanted = comparableText(name);
75
+ return installedLanguages(languageFolders(context)).find((pack) => isDataLanguage(context, pack) && [pack.code, pack.name, pack.package].some((one) => comparableText(one) === wanted));
76
+ }
77
+ /** The files of a package of data a theme or a language keeps, those `keep` takes; refused, with `code`, when they weigh more than `what` may, or come twice. */
78
+ export function keptFiles(label, entries, keep, code, what) {
79
+ const kept = entries.filter(([parts]) => keep(parts));
80
+ refuseTwice(label, kept.map(([parts]) => parts.join("/")));
81
+ const size = kept.reduce((total, [, bytes]) => total + bytes.length, 0);
82
+ if (size > largestUnpacked) {
83
+ const why = `its files weigh ${Math.ceil(size / 1024 / 1024)} MB, more than the ${largestUnpacked / 1024 / 1024} MB ${what} may`;
84
+ throw new Refusal(`${label} cannot be used: ${why}. Nothing changed.`, code, { name: label, why });
85
+ }
86
+ return kept;
87
+ }
88
+ /**
89
+ * Writes a package's files, with where it came from, into a folder of its own beside those installed, which no list reads, for it to be checked there; the
90
+ * folders an install left behind more than an hour ago go first.
91
+ */
92
+ export function writeTrial(folder, context, entries, source) {
93
+ const now = context.now().getTime();
94
+ for (const entry of files().entries(folder)) {
95
+ const path = join(folder, entry.name);
96
+ if (entry.isFolder && /^\.(installing|replaced)-/.test(entry.name) && now - (files().modified(path) ?? now) > staleAfter) {
97
+ files().removeFolder(path);
98
+ }
99
+ }
100
+ const trial = join(folder, `.installing-${context.newId()}`);
101
+ for (const [parts, bytes] of entries) {
102
+ files().writeBytes(join(trial, ...parts), bytes);
103
+ }
104
+ files().write(join(trial, sourceFileName), `${source}\n`);
105
+ return trial;
106
+ }
107
+ /** Puts a folder checked in place of the one there, each move in one step: the one before is set aside, then taken away once the new one is there. */
108
+ export function placeTrial(trial, target, context) {
109
+ const aside = join(dirname(target), `.replaced-${context.newId()}`);
110
+ const before = files().modified(target) !== undefined;
111
+ if (before) {
112
+ moveFolder(target, aside);
113
+ }
114
+ try {
115
+ moveFolder(trial, target);
116
+ }
117
+ catch (error) {
118
+ if (before) {
119
+ moveFolder(aside, target);
120
+ }
121
+ throw error;
122
+ }
123
+ files().removeFolder(aside);
124
+ }
125
+ // How many times a folder is moved before giving up, a tenth of a second apart: an antivirus or an open window may hold it for a moment.
126
+ const moveTries = 10;
127
+ /** Moves a folder, trying again while something holds it; refused, with what to do, when it stays held. */
128
+ function moveFolder(from, to) {
129
+ for (let tried = 1;; tried++) {
130
+ try {
131
+ files().move(from, to);
132
+ return;
133
+ }
134
+ catch (error) {
135
+ const code = error.code;
136
+ if ((code !== "EPERM" && code !== "EBUSY" && code !== "EACCES") || tried === moveTries) {
137
+ const why = error instanceof Error ? error.message : String(error);
138
+ throw new Refusal(`${from} could not be moved: ${why}. Close what is using that folder, such as a window open on it, and install it again. Nothing changed.`, "folder-held", {
139
+ name: from,
140
+ why,
141
+ });
142
+ }
143
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
144
+ }
145
+ }
146
+ }
@@ -114,6 +114,8 @@ export interface SheetItem {
114
114
  bonds?: string[];
115
115
  /** Its page, or one it derives from, is a page of the game system the campaign changed with a layer (SYS-11): the view says so. */
116
116
  layered?: true;
117
+ /** It is a document, as a letter, read again among the World's documents (D-573). */
118
+ document?: true;
117
119
  }
118
120
  /**
119
121
  * The sheet of a player character or a companion as data, a group for each that has a value, as the character reads it, effects and formulas included (DAT-2).
@@ -136,6 +138,11 @@ export declare function sheetHeadline(world: World, system: GameSystem | undefin
136
138
  * by str. None for a page that derives from no creature.
137
139
  */
138
140
  export declare function statBlock(world: World, system: GameSystem | undefined, page: Page): SheetGroupData[];
141
+ /**
142
+ * What a thing's page says of it as data, for its card on the dashboard (D-573): the fields the system declares, of its own and of the pages it derives from,
143
+ * as damage and weight; never the formulas it gives who holds it, as an attack, nor a bonus of 0. None for a page that is not an item.
144
+ */
145
+ export declare function thingBlock(world: World, system: GameSystem | undefined, page: Page): SheetGroupData[];
139
146
  /** "Abilities: str 14 (+2) · dex 12 (+1)…": the sheet as the chat gives it, a line for each group. */
140
147
  export declare function sheetText(groups: SheetGroupData[]): string[];
141
148
  /** The sheet of a player character or a companion as the chat gives it (DAT-2): sheetData as text. */
@@ -187,6 +187,27 @@ export function statBlock(world, system, page) {
187
187
  });
188
188
  return values.length === 0 ? [] : [{ name: creature.name, values }];
189
189
  }
190
+ /**
191
+ * What a thing's page says of it as data, for its card on the dashboard (D-573): the fields the system declares, of its own and of the pages it derives from,
192
+ * as damage and weight; never the formulas it gives who holds it, as an attack, nor a bonus of 0. None for a page that is not an item.
193
+ */
194
+ export function thingBlock(world, system, page) {
195
+ if (system === undefined || page.type !== "item") {
196
+ return [];
197
+ }
198
+ const fields = effectiveFields(world, page);
199
+ const given = new Set(Object.values(system.itemFormulas).flat().map(comparableText));
200
+ const names = [...new Set([...baseChain(world, page)].reverse().concat(page).flatMap((holder) => Object.keys(holder.fields)))];
201
+ const values = names.flatMap((field) => {
202
+ const value = valueNamed(fields, field);
203
+ const kind = declaredKind(world, field);
204
+ if (kind === undefined || isStandardField(page.type, field) || given.has(comparableText(field)) || isEmptyField(value) || (kind === "bonus" && Number(value) === 0)) {
205
+ return [];
206
+ }
207
+ return [sheetValue(world, fields, field, value)];
208
+ });
209
+ return values.length === 0 ? [] : [{ name: page.name, values }];
210
+ }
190
211
  /** "Abilities: str 14 (+2) · dex 12 (+1)…": the sheet as the chat gives it, a line for each group. */
191
212
  export function sheetText(groups) {
192
213
  return groups.map((group) => {
@@ -416,6 +437,11 @@ function groupEntries(world, system, group, fields) {
416
437
  * What a holder carries, as rows of the sheet (D-431): a stack with its count (STK-1), an item with a story of its own, 1, and below it what it holds, one level deeper, and
417
438
  * text as written; marked when equipped. Pages that are elsewhere, or not items, are left out.
418
439
  */
440
+ /** Whether a thing is a document, as a letter: an item with a document field. */
441
+ function isDocument(page) {
442
+ const value = page.fields.document;
443
+ return page.type === "item" && typeof value === "string" && value.trim() !== "";
444
+ }
419
445
  function carriedRows(world, holder, marks, depth = 0, seen = new Set()) {
420
446
  const field = containerFieldOf(holder.type);
421
447
  const stacks = stacksOf(world, holder);
@@ -429,6 +455,7 @@ function carriedRows(world, holder, marks, depth = 0, seen = new Set()) {
429
455
  ...(depth === 0 ? {} : { depth, inside: holder.name }),
430
456
  ...(page !== undefined && marks.equipped.includes(page) ? { equipped: true } : {}),
431
457
  ...(bonds === undefined ? {} : { bonds }),
458
+ ...(page !== undefined && isDocument(page) ? { document: true } : {}),
432
459
  };
433
460
  };
434
461
  return (field === undefined ? [] : textsIn(holder.fields[field])).flatMap((entry) => {
@@ -46,6 +46,7 @@ export declare const status: import("../core/registry.ts").Command<z.ZodObject<{
46
46
  journey: string | undefined;
47
47
  lastScenes: string[];
48
48
  sceneCounts: string;
49
+ book: string | undefined;
49
50
  openQuests: string[];
50
51
  now: string | undefined;
51
52
  betweenSessions: string | undefined;
@@ -8,6 +8,7 @@ import { sceneTypes } from "../scene/index.js";
8
8
  import { rulesetSetting } from "../systems/index.js";
9
9
  import { choicesNotes } from "./choices.js";
10
10
  import { importLine } from "./import/import.js";
11
+ import { bookBehind } from "./shared/campaign/book.js";
11
12
  import { allStateChecks, markStateChecksTold } from "./shared/campaign/checks.js";
12
13
  import { picturesNote } from "./shared/campaign/images.js";
13
14
  import { campaignMode, campaignNote } from "./shared/campaign/mode.js";
@@ -176,6 +177,8 @@ export const status = defineCommand({
176
177
  journey: journeyText(world, roadsOf(world), readJourney(root), measuresOf(root, system)),
177
178
  lastScenes: closed.slice(0, shownNames).map((scene) => `${scene.title} (${scene.type}): ${scene.summary}`),
178
179
  sceneCounts: sceneCounts(closed),
180
+ // The book's chapters left behind, once it has begun (T-227).
181
+ book: bookBehind(root),
179
182
  openQuests: openQuests(world, now),
180
183
  now: now === undefined ? undefined : datedText(root, context, now),
181
184
  // In play, the game time to let pass when the last move is an hour old or more and the time runs between sessions (D-133).
@@ -244,6 +247,7 @@ export const status = defineCommand({
244
247
  result.journey === undefined ? "" : `Journey: ${result.journey}`,
245
248
  result.lastScenes.length === 0 ? "" : `Last scenes: ${result.lastScenes.join(" · ")}`,
246
249
  result.sceneCounts === "" ? "" : `Scenes so far: ${result.sceneCounts}`,
250
+ result.book ?? "",
247
251
  dueLine(result.dueEvents),
248
252
  namesLine("Open quests", result.openQuests, "find text open, type quest"),
249
253
  namesLine("Planned events", result.plannedEvents, "find text planned, type event"),
@@ -11,14 +11,15 @@ import { knownSecretsApart, knownText, knowsPage, pageKnownBy, playerStory } fro
11
11
  import { measuresOf } from "../shared/places/roads.js";
12
12
  import { lineExperience } from "../shared/sheet/counters.js";
13
13
  import { effectiveFields } from "../shared/sheet/effect-layer.js";
14
- import { counterOf, experienceNeed, experienceProgress, sheetData, sheetHeadline, statBlock } from "../shared/sheet/sheet.js";
14
+ import { counterOf, experienceNeed, experienceProgress, sheetData, sheetHeadline, statBlock, thingBlock } from "../shared/sheet/sheet.js";
15
15
  import { hasSheet } from "../shared/sheet/system-fields.js";
16
16
  import { isLayered } from "./layers.js";
17
17
  /** A page as the one whose view it is knows it (VIEW-3): its text, and the whole sheet when it is theirs or of their party. */
18
18
  export function shownPage(root, context, world, knowledge, page, party) {
19
19
  const system = campaignSystem(root, context);
20
- // A companion who keeps no sheet shows the stat block of the creature it derives from (D-275).
21
- const sheet = withItemImages(root, context, world, withCoins(speedInUnits(!party ? [] : hasSheet(world, page) ? sheetData(world, system, page) : statBlock(world, system, page), system, measuresOf(root, system)), campaignCoins(root, context).coins, system));
20
+ // A companion who keeps no sheet shows the stat block of the creature it derives from (D-275); a thing, what its page says of it as data (D-573).
21
+ const groups = !party ? thingBlock(world, system, page) : hasSheet(world, page) ? sheetData(world, system, page) : statBlock(world, system, page);
22
+ const sheet = withItemImages(root, context, world, withCoins(speedInUnits(groups, system, measuresOf(root, system)), campaignCoins(root, context).coins, system));
22
23
  const language = readSettings(root).language;
23
24
  const headline = party ? sheetHeadline(world, system, page, system === undefined || language === undefined ? undefined : systemWordsOf(root, system, language, context)) : undefined;
24
25
  const cards = party && hasSheet(world, page) ? system?.sheetCards : undefined;
@@ -4,6 +4,7 @@ import type { ActVerb, SheetVerb, SystemWords } from "../../systems/index.ts";
4
4
  import type { CalendarDay } from "../../time/index.ts";
5
5
  import type { PlayerSetting } from "../config/dashboard.ts";
6
6
  import type { ShownImport } from "../import/import.ts";
7
+ import type { BookChapter } from "../shared/campaign/book.ts";
7
8
  import type { Mode } from "../shared/campaign/mode.ts";
8
9
  import type { ResetPoint, SaveMode } from "../shared/campaign/saves.ts";
9
10
  import type { MoodMoment } from "../shared/characters/moods.ts";
@@ -152,6 +153,7 @@ export type ViewResult = {
152
153
  quests: ShownQuest[];
153
154
  chapters: ShownChapter[];
154
155
  thoughts: ShownThought[];
156
+ book: BookChapter[];
155
157
  }
156
158
  /** The World section but the map (VIEW-11): the pages the character knows, each as it knows it, the documents it has or read, and the calendar. */
157
159
  | {
@@ -109,6 +109,7 @@ export declare const view: import("../../core/registry.ts").Command<z.ZodObject<
109
109
  quests: import("./journal.ts").ShownQuest[];
110
110
  chapters: import("./journal.ts").ShownChapter[];
111
111
  thoughts: import("./journal.ts").ShownThought[];
112
+ book: import("../shared/campaign/book.ts").BookChapter[];
112
113
  } | {
113
114
  kind: "world";
114
115
  known: import("./world.ts").KnownEntry[];
@@ -11,6 +11,7 @@ import { offeredPages } from "../choices.js";
11
11
  import { setupQuestions, shownPlayerSettings } from "../config/dashboard.js";
12
12
  import { importShown } from "../import/import.js";
13
13
  import { translatingTexts, wantTexts } from "../shared/books/system-texts.js";
14
+ import { campaignBook } from "../shared/campaign/book.js";
14
15
  import { shownImage } from "../shared/campaign/images.js";
15
16
  import { blockingMode, campaignMode, modes } from "../shared/campaign/mode.js";
16
17
  import { campaignCoins } from "../shared/campaign/money.js";
@@ -142,6 +143,8 @@ export const view = defineCommand({
142
143
  ...shownJournal(root, world, knowledge, present, (entry) => storyFact(world, entry, lineNamed(entry)), known, (name) => placeLook(root, context, world, knowledge, name)),
143
144
  // The diaries the player reads, the last line first: never a hidden line, as another character's (DIA-4).
144
145
  thoughts: thoughtsIn(root, world).filter((one) => !one.hidden).reverse().map((one) => ({ who: known(one.page.name) ?? "someone", ...(one.date === undefined ? {} : { date: one.date }), text: one.text })),
146
+ // The story told as a book, the chapters of the scenes the story holds as it stands (T-227).
147
+ book: campaignBook(root),
145
148
  };
146
149
  }
147
150
  if (input.map === true && [input.page, input.diary, input.rolls].some((given) => given !== undefined)) {
@@ -304,6 +307,7 @@ export const view = defineCommand({
304
307
  ...(result.quests.length === 0 ? ["No quests yet."] : result.quests.map(questText)),
305
308
  ...result.chapters.map((chapter) => `${chapter.title ?? "Between scenes"}${chapter.date === undefined ? "" : `, ${chapter.date}`}${chapter.summary === undefined ? "" : `: ${chapter.summary}`}`),
306
309
  ...result.thoughts.map((thought) => `${thought.who}'s diary${thought.date === undefined ? "" : `, ${thought.date}`}: ${thought.text}`),
310
+ ...(result.book.length === 0 ? [] : [`The book: ${result.book.length} ${result.book.length === 1 ? "chapter" : "chapters"} written; book reads one.`]),
307
311
  ].join("\n");
308
312
  case "world":
309
313
  return [
@@ -0,0 +1,13 @@
1
+ /** A file of a package: its path in parts, from the package's top, and its bytes. */
2
+ export type PackageEntry = [string[], Uint8Array];
3
+ /** 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. */
4
+ export declare function unzipFiles(bytes: Uint8Array, label: string, most: number, what: string): [string, Uint8Array][];
5
+ /** 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. */
6
+ export declare function zipListing(bytes: Uint8Array, label: string): [string, number][];
7
+ /**
8
+ * 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
9
+ * `tops`, the files that tell what it is, lies at its top. `what` names it in a refusal: the adventure.
10
+ */
11
+ export declare function packageEntries(label: string, entries: [string, Uint8Array][], what: string, tops: readonly string[]): PackageEntry[];
12
+ /** The file at a package's top named so, in any case; undefined when there is none. */
13
+ export declare function topFile(entries: PackageEntry[], name: string): PackageEntry | undefined;