@kubohiroya/turbowarp-extension-security-dialog 0.9.0 → 0.9.1

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 (46) hide show
  1. package/EDITOR-MIGRATION.md +5 -0
  2. package/README.ja.md +5 -0
  3. package/dist/build-info.json +2 -2
  4. package/dist/catalog-library.cjs +400 -0
  5. package/dist/catalog-library.d.ts +108 -0
  6. package/dist/catalog-library.mjs +372 -0
  7. package/dist/embedded-extension-name.d.ts +2 -0
  8. package/dist/load-errors.cjs +56 -0
  9. package/dist/load-errors.d.ts +10 -0
  10. package/dist/load-errors.mjs +35 -0
  11. package/dist/permission-ui.cjs +373 -0
  12. package/dist/permission-ui.d.ts +29 -0
  13. package/dist/permission-ui.mjs +350 -0
  14. package/dist/project-review-channel.cjs +38 -0
  15. package/dist/project-review-channel.d.ts +13 -0
  16. package/dist/project-review-channel.mjs +17 -0
  17. package/dist/project-review.cjs +6622 -0
  18. package/dist/project-review.d.ts +65 -0
  19. package/dist/project-review.mjs +6597 -0
  20. package/package.json +38 -5
  21. package/src/catalog-library.css +76 -0
  22. package/src/catalog-library.tsx +227 -0
  23. package/src/catalog.ts +175 -0
  24. package/src/decisions.ts +128 -0
  25. package/src/display-urls.ts +39 -0
  26. package/src/embedded-extension-name.ts +76 -0
  27. package/src/extension-row.tsx +137 -0
  28. package/src/index.ts +9 -0
  29. package/src/inline-name.ts +56 -0
  30. package/src/linked-text.tsx +49 -0
  31. package/src/load-errors.ts +38 -0
  32. package/src/messages.ts +123 -0
  33. package/src/metadata.ts +178 -0
  34. package/src/permission-ui.ts +163 -0
  35. package/src/preview.tsx +94 -0
  36. package/src/project-review-channel.ts +40 -0
  37. package/src/project-review.css +19 -0
  38. package/src/project-review.tsx +232 -0
  39. package/src/react.tsx +40 -0
  40. package/src/review-types.ts +100 -0
  41. package/src/review.css +90 -0
  42. package/src/review.tsx +455 -0
  43. package/src/selection.ts +78 -0
  44. package/src/storage.ts +157 -0
  45. package/src/turbowarp.ts +256 -0
  46. package/src/wait-dialog.ts +135 -0
@@ -0,0 +1,5 @@
1
+ # Editor 独自実装の移管
2
+
3
+ 元: kubohiroya/turbowarp-plus-editor `fd11930fa10eaad70b8332eb76b34f9888a59157`。
4
+ 2026-11-19 に著作権者から、対象の Editor 独自コードを MPL-2.0 でも提供する承認を得た。
5
+ 本家 GUI のソース・コンポーネント・CSS モジュールは移していない。ホスト固有の値は接続口から受け取る。
package/README.ja.md CHANGED
@@ -274,3 +274,8 @@ React と React DOM は peerDependencies なので、ホストが用意します
274
274
  0.6.0でMPL-2.0へ書き直したときの設計の記録は [書き直しの設計](docs/mpl-rewrite.ja.md) にあります。
275
275
 
276
276
  npmが固定したGitHubアーカイブを`.git`なしでビルドする場合、インストーラーはlockfileと同じ完全SHAを`TWEXTSEC_SOURCE_REVISION`で渡します。`sourceState: "git-archive"`として記録し、完全SHAがなければビルドを拒否します。ホストはインストール後の記録をmanifest・lockfileと照合します。
277
+
278
+ ## Editor の実装との責務分担
279
+
280
+ Editor 独自実装の移管元とライセンス確認は [EDITOR-MIGRATION.md](EDITOR-MIGRATION.md) に記録しています。
281
+ 追加した公開 API は GUI モジュールを import せず、ホストから必要な値・データ・コールバックを受け取ります。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.9.0",
4
- "revision": "3b5531912d7999a85c96f2cfcfdc9d3fb2e222fb",
3
+ "version": "0.9.1",
4
+ "revision": "213ca71969be75943f2e775e29e89193e910181f",
5
5
  "sourceState": "commit"
6
6
  }
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/catalog-library.tsx
48
+ var catalog_library_exports = {};
49
+ __export(catalog_library_exports, {
50
+ createCatalogLibrary: () => createCatalogLibrary,
51
+ reviewRows: () => reviewRows
52
+ });
53
+ module.exports = __toCommonJS(catalog_library_exports);
54
+ var import_react = require("@kubohiroya/turbowarp-extension-security-dialog/react");
55
+
56
+ // src/display-urls.ts
57
+ var displayURL = (value, allowMail = false) => {
58
+ if (typeof value !== "string" || !value || /[\u0000-\u0020\u007f]/.test(value)) return null;
59
+ try {
60
+ const url = new URL(value);
61
+ if (url.username || url.password) return null;
62
+ if (url.protocol === "http:" || url.protocol === "https:") return value;
63
+ if (allowMail && url.protocol === "mailto:" && /^[^\s@]+@[^\s@]+$/.test(decodeURIComponent(url.pathname))) return value;
64
+ } catch (error) {
65
+ }
66
+ return null;
67
+ };
68
+ var contactURL = (value) => {
69
+ const address = displayURL(value, true);
70
+ if (!address || address.length > 2048 || new URL(address).hash) {
71
+ throw new Error("authorURL must be HTTP(S) or mailto without credentials or a fragment");
72
+ }
73
+ return address;
74
+ };
75
+
76
+ // src/catalog.ts
77
+ var ID = /^[A-Za-z0-9]+$/;
78
+ function fail(message) {
79
+ throw new Error(message);
80
+ }
81
+ var object = (value, what) => {
82
+ if (value === null || typeof value !== "object" || Array.isArray(value)) fail(`${what} must be an object`);
83
+ return value;
84
+ };
85
+ var string = (value, what, limit = 2048) => {
86
+ if (typeof value !== "string" || value.length === 0 || value.length > limit) fail(`${what} must be text`);
87
+ return value;
88
+ };
89
+ var reviewURL = (value, what = "URL", allowHTTP = false) => {
90
+ const text2 = string(value, what);
91
+ let url;
92
+ try {
93
+ url = new URL(text2);
94
+ } catch (error) {
95
+ fail(`${what} must be an absolute URL`);
96
+ }
97
+ const schemes = allowHTTP ? ["https:", "http:"] : ["https:"];
98
+ if (!schemes.includes(url.protocol) || url.username || url.password || url.hash) {
99
+ fail(`${what} must be ${allowHTTP ? "HTTP(S)" : "HTTPS"} without credentials or a fragment`);
100
+ }
101
+ return text2;
102
+ };
103
+ var metadataOf = (value) => {
104
+ const source = object(value, "metadata");
105
+ const result = {};
106
+ for (const key of [
107
+ "name",
108
+ "id",
109
+ "description",
110
+ "author",
111
+ "version",
112
+ "license",
113
+ "package",
114
+ "banner",
115
+ "unsandboxed",
116
+ "updatedAt"
117
+ ]) {
118
+ if (source[key] !== void 0) result[key] = string(source[key], key, 4096);
119
+ }
120
+ for (const key of ["repository", "docsURL"]) {
121
+ if (source[key] !== void 0) result[key] = reviewURL(source[key], key);
122
+ }
123
+ if (source.authorURL !== void 0) result.authorURL = contactURL(source.authorURL);
124
+ if (source.descriptions !== void 0) {
125
+ const descriptions = object(source.descriptions, "descriptions");
126
+ result.descriptions = {};
127
+ for (const [tag, text2] of Object.entries(descriptions)) {
128
+ if (!/^[a-z]{2}(-[A-Za-z0-9]+)*$/.test(tag)) fail("descriptions keys must be language tags");
129
+ result.descriptions[tag] = string(text2, "description", 4096);
130
+ }
131
+ }
132
+ return result;
133
+ };
134
+ var categoriesOf = (value) => {
135
+ const list = value === void 0 ? [] : value;
136
+ if (!Array.isArray(list)) fail("categories must be a list");
137
+ const byId = /* @__PURE__ */ new Map();
138
+ list.forEach((item, order) => {
139
+ const category = object(item, "category");
140
+ const id = string(category.id, "category id", 128);
141
+ if (byId.has(id)) fail(`Duplicate category ${id}`);
142
+ const resolved = { id, title: string(category.title, "category title", 256), order };
143
+ if (category.titleJa !== void 0) resolved.titleJa = string(category.titleJa, "category titleJa", 256);
144
+ byId.set(id, Object.freeze(resolved));
145
+ });
146
+ return byId;
147
+ };
148
+ function parseExtensionCatalog(data) {
149
+ const document = object(data, "catalog");
150
+ if (document.schemaVersion !== void 0 && document.schemaVersion !== 1) {
151
+ fail(`Unsupported catalog schema ${document.schemaVersion}`);
152
+ }
153
+ const categories = categoriesOf(document.categories);
154
+ const list = document.extensions;
155
+ if (!Array.isArray(list)) fail("catalog extensions must be a list");
156
+ const byId = /* @__PURE__ */ new Map();
157
+ const urls = /* @__PURE__ */ new Set();
158
+ const entries = list.map((item) => {
159
+ const source = object(item, "extension");
160
+ const id = string(source.id, "extension id", 128);
161
+ if (!ID.test(id)) fail(`Invalid extension id ${id}`);
162
+ if (byId.has(id)) fail(`Duplicate extension ${id}`);
163
+ const url = reviewURL(source.url, `${id} url`);
164
+ if (urls.has(url)) fail(`Duplicate extension URL ${url}`);
165
+ urls.add(url);
166
+ const dependencies = source.dependencies === void 0 ? [] : source.dependencies;
167
+ if (!Array.isArray(dependencies)) fail(`${id} dependencies must be a list`);
168
+ const entry = {
169
+ key: id,
170
+ id,
171
+ ids: [id],
172
+ url,
173
+ dependencies: Object.freeze(dependencies.map((value) => string(value, "dependency", 128))),
174
+ // The dashboard catalog states name, description, creator and banner beside the URL.
175
+ // A nested `metadata` object, the older shape, still wins where it says something.
176
+ metadata: Object.freeze(metadataOf(__spreadValues(__spreadValues({}, source), source.metadata === void 0 ? {} : object(source.metadata, "metadata"))))
177
+ };
178
+ if (source.sha256 !== void 0) {
179
+ entry.sha256 = string(source.sha256, "sha256", 64);
180
+ if (!/^[0-9a-f]{64}$/.test(entry.sha256)) fail(`Invalid sha256 for ${id}`);
181
+ }
182
+ if (source.category !== void 0) {
183
+ const category = string(source.category, "category", 128);
184
+ if (!categories.has(category)) fail(`Unknown category ${category}`);
185
+ entry.category = categories.get(category);
186
+ }
187
+ byId.set(id, entry);
188
+ return entry;
189
+ });
190
+ for (const entry of entries) {
191
+ for (const dependency of entry.dependencies) {
192
+ if (!byId.has(dependency)) fail(`${entry.id} depends on missing ${dependency}`);
193
+ }
194
+ }
195
+ const state = /* @__PURE__ */ new Map();
196
+ const walk = (id) => {
197
+ const mark = state.get(id);
198
+ if (mark === "done") return;
199
+ if (mark === "open") fail(`Dependency cycle at ${id}`);
200
+ state.set(id, "open");
201
+ for (const dependency of byId.get(id).dependencies) walk(dependency);
202
+ state.set(id, "done");
203
+ };
204
+ for (const entry of entries) walk(entry.id);
205
+ return entries.map((entry) => Object.freeze(entry));
206
+ }
207
+
208
+ // src/catalog-library.tsx
209
+ var import_react2 = __toESM(require("react"), 1);
210
+ var text = {
211
+ en: {
212
+ loading: "Loading TurboWarp Plus extensions\u2026",
213
+ failed: "The extension catalog could not be loaded.",
214
+ denied: "No extensions were loaded. Review the selected extensions and their permissions.",
215
+ retry: "Retry"
216
+ },
217
+ ja: {
218
+ loading: "TurboWarp Plus\u306E\u6A5F\u80FD\u62E1\u5F35\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059\u2026",
219
+ failed: "\u6A5F\u80FD\u62E1\u5F35\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
220
+ denied: "\u6A5F\u80FD\u62E1\u5F35\u306F\u8AAD\u307F\u8FBC\u307E\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u9078\u629E\u3068\u8AAD\u307F\u8FBC\u307F\u8A31\u53EF\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
221
+ retry: "\u518D\u8A66\u884C"
222
+ }
223
+ };
224
+ var reviewRows = (entries, vm, loader = true) => entries.map((entry) => ({
225
+ key: entry.id,
226
+ ids: [entry.id],
227
+ metadata: entry.metadata,
228
+ source: { kind: loader ? "catalog" : "legacy", url: entry.url },
229
+ dependencies: [...entry.dependencies || []],
230
+ state: { trusted: true, loaded: vm.extensionManager.isExtensionLoaded(entry.id) }
231
+ }));
232
+ function createCatalogLibrary({
233
+ catalog: plusCatalog,
234
+ readSettings: readPlusCatalogSettings,
235
+ applySettings: applyPlusCatalogSettings,
236
+ loadExtensions: loadPlusExtensions,
237
+ loaderEnabled: PLUS_EXTENSION_LOADER_ENABLED,
238
+ isRetryable: isWorthAskingAgain,
239
+ styles
240
+ }) {
241
+ class PlusLibrary extends import_react2.default.PureComponent {
242
+ constructor(props) {
243
+ super(props);
244
+ this.handleFetchCatalog = this.handleFetchCatalog.bind(this);
245
+ this.handleComplete = this.handleComplete.bind(this);
246
+ this.handleRetry = this.handleRetry.bind(this);
247
+ this.state = {
248
+ entries: null,
249
+ fetchError: false,
250
+ denied: false,
251
+ failure: null,
252
+ busy: false,
253
+ decisions: /* @__PURE__ */ new Map()
254
+ };
255
+ this.answered = null;
256
+ }
257
+ componentDidMount() {
258
+ this.alive = true;
259
+ this.handleFetchCatalog();
260
+ }
261
+ componentWillUnmount() {
262
+ this.alive = false;
263
+ if (this.controller) this.controller.abort();
264
+ }
265
+ async handleFetchCatalog() {
266
+ var _a, _b;
267
+ if (this.controller) this.controller.abort();
268
+ this.controller = new AbortController();
269
+ this.setState({ fetchError: false });
270
+ const timeout = setTimeout(() => {
271
+ var _a2;
272
+ return (_a2 = this.controller) == null ? void 0 : _a2.abort();
273
+ }, 15e3);
274
+ try {
275
+ const read = await plusCatalog.read((_b = (_a = this.controller) == null ? void 0 : _a.signal) != null ? _b : new AbortController().signal);
276
+ const entries = read.catalog ? parseExtensionCatalog(read.catalog) : [];
277
+ const icons = read.icons || {};
278
+ for (const entry of entries) {
279
+ if (Object.hasOwn(icons, entry.id)) {
280
+ entry.metadata = __spreadProps(__spreadValues({}, entry.metadata), { banner: icons[entry.id] });
281
+ }
282
+ }
283
+ const { decisions } = await readPlusCatalogSettings(this.props.vm, entries);
284
+ if (this.alive) this.setState({ entries, decisions });
285
+ } catch (error) {
286
+ if (this.alive) {
287
+ console.error(error);
288
+ this.setState({ fetchError: true });
289
+ }
290
+ } finally {
291
+ clearTimeout(timeout);
292
+ }
293
+ }
294
+ /**
295
+ * Act on the screen's answer: every chosen row, with how it runs and how it loads.
296
+ * @param {Map<string, object>|null} decisions The answer by extension ID, or null for no.
297
+ */
298
+ async handleComplete(decisions) {
299
+ if (decisions === null) {
300
+ this.props.onRequestClose();
301
+ return;
302
+ }
303
+ this.answered = decisions;
304
+ await this.apply(decisions);
305
+ }
306
+ /**
307
+ * Ask again with the answer that just failed, as the screen's "Try again" requests.
308
+ */
309
+ async handleRetry() {
310
+ if (this.answered && !this.state.busy) await this.apply(this.answered);
311
+ }
312
+ /**
313
+ * Load the chosen rows as answered, and keep how it failed for the screen to state.
314
+ * @param {Map<string, object>} decisions The answer by extension ID.
315
+ */
316
+ async apply(decisions) {
317
+ var _a, _b, _c;
318
+ const chosen = ((_a = this.state.entries) != null ? _a : []).filter((entry) => decisions.has(entry.id));
319
+ this.setState({ busy: true, denied: false, failure: null });
320
+ this.props.onBusyChange(true);
321
+ try {
322
+ const loaded = PLUS_EXTENSION_LOADER_ENABLED ? await applyPlusCatalogSettings(
323
+ this.props.vm,
324
+ { entries: chosen, decisions },
325
+ { signal: (_c = (_b = this.controller) == null ? void 0 : _b.signal) != null ? _c : new AbortController().signal }
326
+ ) : await loadPlusExtensions(
327
+ this.props.vm,
328
+ chosen,
329
+ new Map(chosen.map((entry) => {
330
+ var _a2, _b2;
331
+ return [entry.url, (_b2 = (_a2 = decisions.get(entry.id)) == null ? void 0 : _a2.execution) != null ? _b2 : "deny"];
332
+ })),
333
+ this.props.permissions
334
+ );
335
+ if (!this.alive) return;
336
+ if (loaded.length) {
337
+ this.props.onCategorySelected(loaded[loaded.length - 1]);
338
+ this.props.onRequestClose();
339
+ } else this.setState({ denied: true });
340
+ } catch (error) {
341
+ console.error(error);
342
+ if (this.alive) {
343
+ const failure = error;
344
+ this.setState({ failure: {
345
+ code: (failure == null ? void 0 : failure.code) || "LOAD_FAILED",
346
+ message: (failure == null ? void 0 : failure.message) || String(error),
347
+ retryable: isWorthAskingAgain(error)
348
+ } });
349
+ }
350
+ } finally {
351
+ if (this.alive) {
352
+ this.setState({ busy: false });
353
+ this.props.onBusyChange(false);
354
+ }
355
+ }
356
+ }
357
+ render() {
358
+ const t = text[this.props.locale.startsWith("ja") ? "ja" : "en"];
359
+ const { entries, busy, denied, failure, fetchError, decisions } = this.state;
360
+ if (!entries) {
361
+ return /* @__PURE__ */ import_react2.default.createElement(
362
+ "div",
363
+ {
364
+ className: styles.message,
365
+ role: fetchError ? "alert" : "status"
366
+ },
367
+ /* @__PURE__ */ import_react2.default.createElement("p", null, fetchError ? t.failed : t.loading),
368
+ fetchError && /* @__PURE__ */ import_react2.default.createElement(
369
+ "button",
370
+ {
371
+ type: "button",
372
+ onClick: this.handleFetchCatalog
373
+ },
374
+ t.retry
375
+ )
376
+ );
377
+ }
378
+ return /* @__PURE__ */ import_react2.default.createElement("div", { className: styles.root }, denied && /* @__PURE__ */ import_react2.default.createElement(
379
+ "p",
380
+ {
381
+ className: styles.error,
382
+ role: "alert"
383
+ },
384
+ t.denied
385
+ ), /* @__PURE__ */ import_react2.default.createElement("div", { hidden: busy }, /* @__PURE__ */ import_react2.default.createElement(
386
+ import_react.ExtensionReview,
387
+ {
388
+ mode: "add",
389
+ entries: reviewRows(entries, this.props.vm, PLUS_EXTENSION_LOADER_ENABLED),
390
+ initialDecisions: decisions,
391
+ locale: this.props.locale,
392
+ failure,
393
+ onRetry: this.handleRetry,
394
+ onComplete: this.handleComplete
395
+ }
396
+ )), busy && /* @__PURE__ */ import_react2.default.createElement("p", { role: "status" }, t.loading));
397
+ }
398
+ }
399
+ return PlusLibrary;
400
+ }
@@ -0,0 +1,108 @@
1
+ import type { CatalogEntry, ReviewDecision, ReviewEntry, ReviewFailure } from './index.js';
2
+ import React from 'react';
3
+ /**
4
+ * The catalog as rows of the review screen.
5
+ *
6
+ * With the Loader switched off there is nothing to write a form into — the extension loads by its
7
+ * address, as a custom extension does — so the rows say so and the screen offers no form.
8
+ * @param {Array<object>} entries Parsed catalog entries.
9
+ * @param {object} vm The VM, to say which are already running.
10
+ * @param {boolean} [loader] Whether the Loader writes the chosen form into the project.
11
+ * @returns {Array<object>} One `ReviewEntry` per catalog entry, keyed by its extension ID.
12
+ */
13
+ interface LibraryVM {
14
+ extensionManager: {
15
+ isExtensionLoaded(id: string): boolean;
16
+ securityManager: object;
17
+ loadExtensionURL(url: string): Promise<unknown>;
18
+ _loadedExtensions: ReadonlyMap<string, string>;
19
+ };
20
+ }
21
+ type Decisions = Map<string, ReviewDecision>;
22
+ interface LibraryProps {
23
+ vm: LibraryVM;
24
+ locale: string;
25
+ filterQuery?: string;
26
+ permissions: unknown;
27
+ onBusyChange(busy: boolean): void;
28
+ onCategorySelected(id: string): void;
29
+ onRequestClose(): void;
30
+ }
31
+ interface LibraryState {
32
+ entries: CatalogEntry[] | null;
33
+ fetchError: boolean;
34
+ denied: boolean;
35
+ failure: ReviewFailure | null;
36
+ busy: boolean;
37
+ decisions: Decisions;
38
+ }
39
+ export declare const reviewRows: (entries: CatalogEntry[], vm: LibraryVM, loader?: boolean) => ReviewEntry[];
40
+ export interface CatalogLibraryPorts {
41
+ catalog: {
42
+ read(signal: AbortSignal): Promise<{
43
+ catalog?: unknown;
44
+ icons?: Record<string, string>;
45
+ }>;
46
+ };
47
+ readSettings(vm: LibraryVM, entries: CatalogEntry[]): Promise<{
48
+ decisions: Decisions;
49
+ }>;
50
+ applySettings(vm: LibraryVM, selection: {
51
+ entries: CatalogEntry[];
52
+ decisions: Decisions;
53
+ }, options: {
54
+ signal: AbortSignal;
55
+ }): Promise<string[]>;
56
+ loadExtensions(vm: LibraryVM, entries: CatalogEntry[], modes: Map<string, string>, permissions: any): Promise<string[]>;
57
+ loaderEnabled: boolean;
58
+ isRetryable(error: unknown): boolean;
59
+ styles: Record<string, string>;
60
+ }
61
+ /** The host supplies its trusted catalog and loading ports, never GUI components. */
62
+ export declare function createCatalogLibrary({ catalog: plusCatalog, readSettings: readPlusCatalogSettings, applySettings: applyPlusCatalogSettings, loadExtensions: loadPlusExtensions, loaderEnabled: PLUS_EXTENSION_LOADER_ENABLED, isRetryable: isWorthAskingAgain, styles }: CatalogLibraryPorts): {
63
+ new (props: LibraryProps): {
64
+ controller?: AbortController;
65
+ answered: Decisions | null;
66
+ alive: boolean;
67
+ componentDidMount(): void;
68
+ componentWillUnmount(): void;
69
+ handleFetchCatalog(): Promise<void>;
70
+ /**
71
+ * Act on the screen's answer: every chosen row, with how it runs and how it loads.
72
+ * @param {Map<string, object>|null} decisions The answer by extension ID, or null for no.
73
+ */
74
+ handleComplete(decisions: Decisions | null): Promise<void>;
75
+ /**
76
+ * Ask again with the answer that just failed, as the screen's "Try again" requests.
77
+ */
78
+ handleRetry(): Promise<void>;
79
+ /**
80
+ * Load the chosen rows as answered, and keep how it failed for the screen to state.
81
+ * @param {Map<string, object>} decisions The answer by extension ID.
82
+ */
83
+ apply(decisions: Decisions): Promise<void>;
84
+ render(): React.JSX.Element;
85
+ context: any;
86
+ setState<K extends keyof LibraryState>(state: LibraryState | ((prevState: Readonly<LibraryState>, props: Readonly<LibraryProps>) => LibraryState | Pick<LibraryState, K> | null) | Pick<LibraryState, K> | null, callback?: (() => void) | undefined): void;
87
+ forceUpdate(callback?: (() => void) | undefined): void;
88
+ readonly props: Readonly<LibraryProps> & Readonly<{
89
+ children?: React.ReactNode | undefined;
90
+ }>;
91
+ state: Readonly<LibraryState>;
92
+ refs: {
93
+ [key: string]: React.ReactInstance;
94
+ };
95
+ shouldComponentUpdate?(nextProps: Readonly<LibraryProps>, nextState: Readonly<LibraryState>, nextContext: any): boolean;
96
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
97
+ getSnapshotBeforeUpdate?(prevProps: Readonly<LibraryProps>, prevState: Readonly<LibraryState>): any;
98
+ componentDidUpdate?(prevProps: Readonly<LibraryProps>, prevState: Readonly<LibraryState>, snapshot?: any): void;
99
+ componentWillMount?(): void;
100
+ UNSAFE_componentWillMount?(): void;
101
+ componentWillReceiveProps?(nextProps: Readonly<LibraryProps>, nextContext: any): void;
102
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<LibraryProps>, nextContext: any): void;
103
+ componentWillUpdate?(nextProps: Readonly<LibraryProps>, nextState: Readonly<LibraryState>, nextContext: any): void;
104
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<LibraryProps>, nextState: Readonly<LibraryState>, nextContext: any): void;
105
+ };
106
+ contextType?: React.Context<any> | undefined;
107
+ };
108
+ export {};