@kubohiroya/turbowarp-extension-security-dialog 0.13.1 → 0.14.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.
- package/README.ja.md +16 -0
- package/README.md +18 -0
- package/dist/build-info.json +2 -2
- package/dist/catalog-library.cjs +168 -26
- package/dist/catalog-library.d.ts +8 -1
- package/dist/catalog-library.mjs +166 -24
- package/dist/catalog-match.d.ts +17 -1
- package/dist/catalog.d.ts +12 -0
- package/dist/embedded-extension-name.d.ts +15 -1
- package/dist/index.cjs +34 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +34 -2
- package/dist/project-review.cjs +45 -12
- package/dist/project-review.mjs +45 -12
- package/dist/published-extension.d.ts +32 -0
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/package.json +4 -4
- package/src/catalog-library.tsx +30 -15
- package/src/catalog-match.ts +20 -4
- package/src/catalog.ts +24 -0
- package/src/embedded-extension-name.ts +32 -4
- package/src/index.ts +1 -0
- package/src/project-review.tsx +8 -7
- package/src/published-extension.tsx +103 -0
package/README.ja.md
CHANGED
|
@@ -153,6 +153,12 @@ HTTP(S)のソースから説明を読み取り、相対バナーURLは取得後
|
|
|
153
153
|
そのバイト列の SHA-256 をカタログと照合します。一致した行は、カタログに載った拡張と同じ扱い
|
|
154
154
|
(信頼済み・Plus マーク・カタログの画像)になり、読み込み元の欄にカタログ上の提供元のアドレスを添えます
|
|
155
155
|
(`entry.state.listedURL`)。Plus マニフェストの埋め込み行も同じです。一致しない行は従来どおり確認します。
|
|
156
|
+
Plus マニフェストの `embedded-file` 行は、固定された SHA-256 と一致したバイト列のヘッダーから、名前に加えて
|
|
157
|
+
画像(`Banner`)・製作者(`By` / `Author URL`)・説明を表示します。ヘッダーの `ID` が行と違う場合は名前だけを使い、
|
|
158
|
+
マニフェストの `version` / `publisher` はヘッダーより優先します。いずれも自己申告で、実行許可やリソース利用の申告にはなりません。
|
|
159
|
+
1つの版で同じ拡張を複数の形(制作用と再生用など)で配る場合、カタログの項目は `variants: [{url, sha256}]` に
|
|
160
|
+
ほかのビルドを並べられます。どのビルドのバイト列でも同じ拡張として照合し、`listedURL` は一致したビルドのアドレスになります。
|
|
161
|
+
ライブラリーから追加するときは常に `url` のビルドを使います。`catalogDigests(entries)` は本体と全ビルドのダイジェストを返します。
|
|
156
162
|
|
|
157
163
|
TurboWarp ギャラリーの拡張は、公式メタデータとコードの完全な URL を照合して画像を取得します。
|
|
158
164
|
画像取得とソースの説明取得は並行して進み、操作や実行許可を待たせません。
|
|
@@ -301,10 +307,20 @@ node --test test/wait.browser.ts test/review.browser.ts # 取得待ち・選択
|
|
|
301
307
|
|
|
302
308
|
React と React DOM は peerDependencies なので、ホストが用意します。実行時の依存はありません。
|
|
303
309
|
|
|
310
|
+
`test/load-errors.test.cts` は [Editor #741](https://github.com/kubohiroya/turbowarp-plus-editor/issues/741) のエラー説明・キャンセル分類3件を引き継ぎます。既存の `pnpm test` と CI からビルド済みの `./load-errors` を検証し、GUI checkout とブラウザーは不要です。拡張名と入れ子の原因、循環を含む集約エラー、拒否とキャンセルの判定を確認します。移管先の CI 成功とマージを確認するまで Editor の元テストは残し、GUI へのエラー受け渡しとレビュー内のキー入力の結線確認は Editor に保持します。移管を取り消す場合は追加テストと文書を revert します。製品ソース・依存・パッケージの版の変更は不要です。
|
|
311
|
+
|
|
312
|
+
`test/permission-ui.test.cts` も Editor #741 の承認画面・診断ログ・再試行表示の8件を引き継ぎます。既存の `pnpm test` と CI がビルド済みの `./permission-ui` を GUI checkout・VM なしで実行します。import と DOM 照会の型専用記法だけを変更し、検証本体は維持します。Editor には実 VM と承認画面の結線確認を残し、移管先の CI 成功とマージまでは元テストも保持します。切り戻しは追加テストと文書を revert し、Editor 側で削除済みなら元テストを先に復元します。
|
|
313
|
+
|
|
314
|
+
`test/editor-batch-review.test.cts` は Editor #741 のキャンセル判定 API の基本契約、揮発性メタデータを除いた作品識別、画面を開く必要がない信頼済み行の判定の3件を引き継ぎます。ビルド済み `./project-review` にホストの接続口を明示して渡し、GUI checkout・VM なしで既存の `pnpm test` と CI から実行します。`identifyProject` を factory から得る1行以外の検証本体は維持します。Editor には実 VM で拒否した拡張のブロック保持と GUI モーダルの結線確認を残し、上流 CI 成功とマージまでは元テストも保持します。切り戻しは追加テストと文書を revert し、Editor で削除済みなら元テストを先に復元します。
|
|
315
|
+
|
|
316
|
+
`test/editor-verified-review-names.test.cts` は Editor #741 の統合レビューから、検証済み ZIP の表示名を判定する4パターン(header・literal・dynamic・digest 不一致)を切り出します。元の source fixture と4件の期待値を保持し、公開 `plusReviewRows` に ZIP reader と正規化済みの依存配列を渡します。実行の検出用に一時的な Scratch オブジェクトを置き、コードが実行されないことも確認します。GUI と VM は不要で、既存の `pnpm test` と CI が実行します。Editor には表示名の接続確認1パターンと、Plus/legacy の統合レビュー・承認・拒否・キャッシュ・キャンセルの連携確認を残します。元の GPL-3.0-or-later(`test/LICENSE.GPL-3.0`)を保持し、テストは npm 配布対象外です。切り戻しは Editor の詳細ケースを復元してから、このテストと文書を revert します。
|
|
317
|
+
|
|
304
318
|
## ライセンス
|
|
305
319
|
|
|
306
320
|
[MPL-2.0](LICENSE)。何が対象で何が対象外かは [NOTICE.md](./NOTICE.md) を参照してください。
|
|
307
321
|
|
|
322
|
+
移管した `test/load-errors.test.cts`・`test/permission-ui.test.cts`・`test/editor-batch-review.test.cts` は元の GPL-3.0-or-later を保持し、本文を `test/LICENSE.GPL-3.0` に置きます。テストとそのライセンスは npm アーカイブに含めません。ライブラリ本体は MPL-2.0 のままです。
|
|
323
|
+
|
|
308
324
|
0.6.0でMPL-2.0へ書き直したときの設計の記録は [書き直しの設計](docs/mpl-rewrite.ja.md) にあります。
|
|
309
325
|
|
|
310
326
|
npmが固定したGitHubアーカイブを`.git`なしでビルドする場合、インストーラーはlockfileと同じ完全SHAを`TWEXTSEC_SOURCE_REVISION`で渡します。`sourceState: "git-archive"`として記録し、完全SHAがなければビルドを拒否します。ホストはインストール後の記録をmanifest・lockfileと照合します。
|
package/README.md
CHANGED
|
@@ -151,6 +151,14 @@ When a project opens, an extension the project carries as a `data:` address is m
|
|
|
151
151
|
SHA-256 of its bytes. A listed digest makes the row trusted, family-marked and pictured like the
|
|
152
152
|
catalog's own, and its source line names the catalog's address for the same code
|
|
153
153
|
(`entry.state.listedURL`); embedded Plus manifest rows do the same. Unlisted bytes are asked about.
|
|
154
|
+
An `embedded-file` row of a Plus manifest also shows the picture (`Banner`), creator (`By` / `Author URL`) and
|
|
155
|
+
description from the header of its bytes, once they match the pinned SHA-256. A header naming another `ID` lends only
|
|
156
|
+
its name, and the manifest's `version` and `publisher` win over the header. These are claims, never permissions or a
|
|
157
|
+
resource declaration.
|
|
158
|
+
When one release ships an extension in more than one build (an authoring and a playback build, say), its catalog item
|
|
159
|
+
can list the others as `variants: [{url, sha256}]`. Bytes of any listed build match that extension, and `listedURL` is
|
|
160
|
+
the address of the build that matched. Adding from the library always uses `url`. `catalogDigests(entries)` returns the
|
|
161
|
+
digests of every listed build.
|
|
154
162
|
|
|
155
163
|
### Using one row of the list
|
|
156
164
|
|
|
@@ -294,10 +302,20 @@ node --test test/wait.browser.ts test/review.browser.ts
|
|
|
294
302
|
React and React DOM are peer dependencies, so the host supplies them. There are no runtime
|
|
295
303
|
dependencies.
|
|
296
304
|
|
|
305
|
+
`test/load-errors.test.cts` carries the three error-description and cancellation-classification cases from [Editor #741](https://github.com/kubohiroya/turbowarp-plus-editor/issues/741). It tests the built `./load-errors` entry through the existing `pnpm test` and CI commands, without a GUI checkout or browser. It covers a named nested cause, aggregate errors with cycles, and refusal versus cancellation. The Editor originals stay until this migration is merged with successful CI; Editor keeps its tests of GUI error forwarding and review keyboard ownership. Revert the added test and its documentation to undo the migration. No production source, dependencies, or package version change is needed.
|
|
306
|
+
|
|
307
|
+
`test/permission-ui.test.cts` also carries the eight permission-dialog, diagnostic-log and retry-display cases from Editor #741. The existing `pnpm test` and CI run the built `./permission-ui` entry without a GUI checkout or VM. Test bodies are preserved; only imports and DOM query type annotations change. Editor keeps its real-VM consent wiring tests. Its originals stay until this migration is merged with successful CI. Revert the added tests and documentation to undo this migration, restoring the Editor originals first if they were removed.
|
|
308
|
+
|
|
309
|
+
`test/editor-batch-review.test.cts` carries three more Editor #741 cases: the review cancellation API contract, project identity with volatile metadata excluded, and trusted rows that need no screen. It uses the built `./project-review` entry with explicit host ports; no GUI checkout or VM is needed. Test bodies stay the same except for obtaining `identifyProject` from that factory. The existing `pnpm test` and CI run these cases. Editor keeps its real-VM declined-extension and GUI modal wiring tests; the originals stay until this migration is merged with successful CI. Revert the added tests and documentation to undo the migration, restoring the Editor originals first if removed.
|
|
310
|
+
|
|
311
|
+
`test/editor-verified-review-names.test.cts` extracts four verified-ZIP name patterns from Editor #741's unified review: header, literal, dynamic and digest mismatch. It retains the source fixtures and all four expected names, passing a ZIP reader and normalized dependency arrays to the public `plusReviewRows` API. A temporary Scratch object detects execution and confirms that no code runs. No GUI or VM is needed; the existing `pnpm test` and CI run the test. Editor retains one name-wiring pattern and the Plus/legacy review, approval, refusal, cache and cancellation integration checks. The migrated test retains GPL-3.0-or-later (`test/LICENSE.GPL-3.0`) and stays outside the npm archive. Restore the detailed Editor cases before reverting the new test and documentation to roll back.
|
|
312
|
+
|
|
297
313
|
## License
|
|
298
314
|
|
|
299
315
|
[MPL-2.0](LICENSE). See [NOTICE.md](./NOTICE.md) for what is and is not covered.
|
|
300
316
|
|
|
317
|
+
The migrated `test/load-errors.test.cts`, `test/permission-ui.test.cts` and `test/editor-batch-review.test.cts` retain their original GPL-3.0-or-later license; its text is in `test/LICENSE.GPL-3.0`. Tests and this test-only license are excluded from the npm archive. The library remains MPL-2.0.
|
|
318
|
+
|
|
301
319
|
The design record of the MPL-2.0 rewrite in 0.6.0 is in [the rewrite design (Japanese)](docs/mpl-rewrite.ja.md).
|
|
302
320
|
|
|
303
321
|
When npm prepares a pinned GitHub archive without `.git`, the installer must pass its locked full SHA as `TWEXTSEC_SOURCE_REVISION`. The build records `sourceState: "git-archive"` and fails without a full SHA; the host verifies it against its manifest and lockfile.
|
package/dist/build-info.json
CHANGED
package/dist/catalog-library.cjs
CHANGED
|
@@ -51,9 +51,9 @@ __export(catalog_library_exports, {
|
|
|
51
51
|
reviewRows: () => reviewRows
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(catalog_library_exports);
|
|
54
|
-
var
|
|
54
|
+
var import_react3 = require("@kubohiroya/turbowarp-extension-security-dialog/react");
|
|
55
55
|
|
|
56
|
-
// node_modules/.pnpm/@kubohiroya+turbowarp-extension-manifest@0.
|
|
56
|
+
// node_modules/.pnpm/@kubohiroya+turbowarp-extension-manifest@0.8.0/node_modules/@kubohiroya/turbowarp-extension-manifest/dist/resources.js
|
|
57
57
|
var RESOURCE_TYPES = [
|
|
58
58
|
"camera",
|
|
59
59
|
"microphone",
|
|
@@ -64,6 +64,26 @@ var RESOURCE_TYPES = [
|
|
|
64
64
|
"files",
|
|
65
65
|
"audio-output"
|
|
66
66
|
];
|
|
67
|
+
var RESOURCE_LABELS = {
|
|
68
|
+
camera: { en: "Camera", ja: "\u30AB\u30E1\u30E9" },
|
|
69
|
+
microphone: { en: "Microphone", ja: "\u30DE\u30A4\u30AF" },
|
|
70
|
+
network: { en: "Network", ja: "\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF" },
|
|
71
|
+
bluetooth: { en: "Bluetooth", ja: "Bluetooth" },
|
|
72
|
+
usb: { en: "USB", ja: "USB" },
|
|
73
|
+
storage: { en: "Browser storage", ja: "\u30D6\u30E9\u30A6\u30B6\u5185\u306E\u4FDD\u5B58\u9818\u57DF" },
|
|
74
|
+
files: { en: "Selected files", ja: "\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB" },
|
|
75
|
+
"audio-output": { en: "Audio output", ja: "\u97F3\u58F0\u51FA\u529B" }
|
|
76
|
+
};
|
|
77
|
+
var RESOURCE_ICON_PATHS = {
|
|
78
|
+
camera: "M3 7h4l2-3h6l2 3h4v13H3z M16 13a4 4 0 1 1-8 0 4 4 0 0 1 8 0",
|
|
79
|
+
microphone: "M9 4a3 3 0 0 1 6 0v8a3 3 0 0 1-6 0z M6 10v2a6 6 0 0 0 12 0v-2 M12 18v4 M8 22h8",
|
|
80
|
+
network: "M5 11h14v10H5z M8 15h8 M8 18h2 M14 18h2 M8 7a6 6 0 0 1 8 0 M4 4a12 12 0 0 1 16 0",
|
|
81
|
+
bluetooth: "M7 7l10 10-5 5V2l5 5L7 17",
|
|
82
|
+
usb: "M12 22V3 M9 6l3-3 3 3 M12 17l-6-4V8 M12 13l6-4V5 M4 5h4v3H4z M16 2h4v3h-4z",
|
|
83
|
+
storage: "M3 5h18v14H3z M3 14h18 M16 17h2 M7 8h10 M7 11h7",
|
|
84
|
+
files: "M5 2h9l5 5v15H5z M14 2v6h5 M8 12h8 M8 16h8",
|
|
85
|
+
"audio-output": "M3 9h5l6-5v16l-6-5H3z M17 8a6 6 0 0 1 0 8 M20 5a10 10 0 0 1 0 14"
|
|
86
|
+
};
|
|
67
87
|
function fail(message) {
|
|
68
88
|
throw new TypeError(`Resource declaration: ${message}`);
|
|
69
89
|
}
|
|
@@ -137,6 +157,11 @@ function parseResourceDeclaration(value) {
|
|
|
137
157
|
});
|
|
138
158
|
return Object.freeze({ schemaVersion: 1, resources: Object.freeze(resources) });
|
|
139
159
|
}
|
|
160
|
+
function resourceText(value, locale = "en") {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
const tag = locale.replace("_", "-");
|
|
163
|
+
return (_b = (_a = value[tag]) != null ? _a : value[tag.split("-")[0]]) != null ? _b : value.en;
|
|
164
|
+
}
|
|
140
165
|
|
|
141
166
|
// src/display-urls.ts
|
|
142
167
|
var displayURL = (value, allowMail = false) => {
|
|
@@ -266,6 +291,18 @@ function parseExtensionCatalog(data) {
|
|
|
266
291
|
entry.sha256 = string(source.sha256, "sha256", 64);
|
|
267
292
|
if (!/^[0-9a-f]{64}$/.test(entry.sha256)) fail2(`Invalid sha256 for ${id}`);
|
|
268
293
|
}
|
|
294
|
+
if (source.variants !== void 0) {
|
|
295
|
+
if (!Array.isArray(source.variants) || source.variants.length > 64) fail2(`${id} variants must be a list`);
|
|
296
|
+
entry.variants = Object.freeze(source.variants.map((value) => {
|
|
297
|
+
const variant = object(value, `${id} variant`);
|
|
298
|
+
const variantURL = reviewURL(variant.url, `${id} variant url`);
|
|
299
|
+
if (urls.has(variantURL)) fail2(`Duplicate extension URL ${variantURL}`);
|
|
300
|
+
urls.add(variantURL);
|
|
301
|
+
const sha256 = string(variant.sha256, "sha256", 64);
|
|
302
|
+
if (!/^[0-9a-f]{64}$/.test(sha256)) fail2(`Invalid variant sha256 for ${id}`);
|
|
303
|
+
return Object.freeze({ url: variantURL, sha256 });
|
|
304
|
+
}));
|
|
305
|
+
}
|
|
269
306
|
if (source.category !== void 0) {
|
|
270
307
|
const category = string(source.category, "category", 128);
|
|
271
308
|
if (!categories.has(category)) fail2(`Unknown category ${category}`);
|
|
@@ -293,7 +330,108 @@ function parseExtensionCatalog(data) {
|
|
|
293
330
|
}
|
|
294
331
|
|
|
295
332
|
// src/catalog-library.tsx
|
|
333
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
334
|
+
|
|
335
|
+
// src/published-extension.tsx
|
|
296
336
|
var import_react2 = __toESM(require("react"), 1);
|
|
337
|
+
|
|
338
|
+
// src/resources.tsx
|
|
339
|
+
var import_react = __toESM(require("react"), 1);
|
|
340
|
+
function ResourceDisclosure({ declaration, locale = "en" }) {
|
|
341
|
+
const ja = /^ja(?:-|$)/i.test(locale);
|
|
342
|
+
const t = (en, japanese) => ja ? japanese : en;
|
|
343
|
+
let parsed;
|
|
344
|
+
try {
|
|
345
|
+
parsed = parseResourceDeclaration(declaration);
|
|
346
|
+
} catch (e) {
|
|
347
|
+
return /* @__PURE__ */ import_react.default.createElement("p", { className: "twextsec-resource-status" }, t("Resource declaration unavailable", "\u30EA\u30BD\u30FC\u30B9\u5229\u7528\u306E\u7533\u544A\u3092\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093"));
|
|
348
|
+
}
|
|
349
|
+
if (!parsed) return /* @__PURE__ */ import_react.default.createElement("p", { className: "twextsec-resource-status" }, t("Resource use: not declared", "\u30EA\u30BD\u30FC\u30B9\u5229\u7528\uFF1A\u672A\u7533\u544A"));
|
|
350
|
+
if (!parsed.resources.length) return /* @__PURE__ */ import_react.default.createElement("p", { className: "twextsec-resource-status" }, t("Resource use: none declared", "\u30EA\u30BD\u30FC\u30B9\u5229\u7528\u306E\u7533\u544A\uFF1A\u306A\u3057"));
|
|
351
|
+
const direction = {
|
|
352
|
+
download: t("Download", "\u53D6\u5F97"),
|
|
353
|
+
upload: t("Upload", "\u9001\u4FE1"),
|
|
354
|
+
bidirectional: t("Send and receive", "\u9001\u53D7\u4FE1")
|
|
355
|
+
};
|
|
356
|
+
return /* @__PURE__ */ import_react.default.createElement("details", { className: "twextsec-resources" }, /* @__PURE__ */ import_react.default.createElement("summary", { title: t("Click or press Enter to show resource details", "\u30AF\u30EA\u30C3\u30AF\u307E\u305F\u306FEnter\u30AD\u30FC\u3067\u5229\u7528\u5185\u5BB9\u3092\u8868\u793A") }, /* @__PURE__ */ import_react.default.createElement("span", { className: "twextsec-resource-heading" }, t("Resource use (author declaration)", "\u30EA\u30BD\u30FC\u30B9\u306E\u5229\u7528\uFF08\u88FD\u4F5C\u8005\u306E\u7533\u544A\uFF09")), /* @__PURE__ */ import_react.default.createElement("span", { className: "twextsec-resource-chips" }, parsed.resources.map((item) => /* @__PURE__ */ import_react.default.createElement(
|
|
357
|
+
"span",
|
|
358
|
+
{
|
|
359
|
+
className: "twextsec-resource-chip",
|
|
360
|
+
key: item.type,
|
|
361
|
+
title: resourceText(RESOURCE_LABELS[item.type], locale)
|
|
362
|
+
},
|
|
363
|
+
/* @__PURE__ */ import_react.default.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false" }, /* @__PURE__ */ import_react.default.createElement("path", { d: RESOURCE_ICON_PATHS[item.type] })),
|
|
364
|
+
/* @__PURE__ */ import_react.default.createElement("span", { className: "twextsec-resource-label" }, resourceText(RESOURCE_LABELS[item.type], locale), item.data && ` \xB7 ${direction[item.data.direction]}`, item.access === "permission-request" && t(" \xB7 permission request", "\u30FB\u8A31\u53EF\u8981\u6C42\u306E\u307F"), item.usage === "conditional" && t(" (conditional)", "\uFF08\u6761\u4EF6\u4ED8\u304D\uFF09"))
|
|
365
|
+
)))), /* @__PURE__ */ import_react.default.createElement("dl", null, parsed.resources.map((item) => /* @__PURE__ */ import_react.default.createElement("div", { key: item.type }, /* @__PURE__ */ import_react.default.createElement("dt", null, resourceText(RESOURCE_LABELS[item.type], locale), " \xB7 ", item.usage === "required" ? t("Used by the main feature", "\u4E3B\u8981\u6A5F\u80FD\u3067\u5229\u7528") : t("Conditional use", "\u6761\u4EF6\u4ED8\u304D\u3067\u5229\u7528")), /* @__PURE__ */ import_react.default.createElement("dd", null, resourceText(item.purpose, locale)), item.condition && /* @__PURE__ */ import_react.default.createElement("dd", null, t("When: ", "\u5229\u7528\u6761\u4EF6\uFF1A"), resourceText(item.condition, locale)), item.access === "permission-request" && /* @__PURE__ */ import_react.default.createElement("dd", null, t("Permission request only; see the purpose above.", "\u8A31\u53EF\u8981\u6C42\u306E\u3042\u308B\u7D4C\u8DEF\u3067\u3059\u3002\u53D6\u5F97\u5F8C\u306E\u6271\u3044\u306F\u4E0A\u8A18\u306E\u7528\u9014\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")), item.data && /* @__PURE__ */ import_react.default.createElement("dd", null, direction[item.data.direction], "\uFF1A", resourceText(item.data.content, locale)), item.via && /* @__PURE__ */ import_react.default.createElement("dd", null, t("Through: ", "\u9023\u643A\u5148\uFF1A"), item.via.join(", "))))), /* @__PURE__ */ import_react.default.createElement("p", null, t("This declaration describes use; it does not grant browser permissions.", "\u5229\u7528\u5185\u5BB9\u306E\u7533\u544A\u3067\u3059\u3002\u30D6\u30E9\u30A6\u30B6\u306E\u4F7F\u7528\u8A31\u53EF\u3092\u4E0E\u3048\u308B\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002")));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/published-extension.tsx
|
|
369
|
+
function PublishedExtension({ locale, resolve, add, blocked, onBusyChange, onAdded }) {
|
|
370
|
+
const t = (english, japanese) => locale.startsWith("ja") ? japanese : english;
|
|
371
|
+
const [reference, setReference] = import_react2.default.useState("");
|
|
372
|
+
const [candidate, setCandidate] = import_react2.default.useState();
|
|
373
|
+
const [error, setError] = import_react2.default.useState("");
|
|
374
|
+
const [pending, setPending] = import_react2.default.useState(false);
|
|
375
|
+
const operation = import_react2.default.useRef(null);
|
|
376
|
+
import_react2.default.useEffect(() => () => {
|
|
377
|
+
var _a;
|
|
378
|
+
return (_a = operation.current) == null ? void 0 : _a.abort();
|
|
379
|
+
}, []);
|
|
380
|
+
async function run(task, authoring = false) {
|
|
381
|
+
if (operation.current || blocked) return false;
|
|
382
|
+
const controller = operation.current = new AbortController();
|
|
383
|
+
setPending(true);
|
|
384
|
+
setError("");
|
|
385
|
+
if (authoring) onBusyChange(true);
|
|
386
|
+
try {
|
|
387
|
+
await task(controller.signal);
|
|
388
|
+
return !controller.signal.aborted;
|
|
389
|
+
} catch (failure) {
|
|
390
|
+
if (!controller.signal.aborted) {
|
|
391
|
+
const code = failure == null ? void 0 : failure.code;
|
|
392
|
+
const invalid = t(
|
|
393
|
+
"Enter an exact npm version or a GitHub Release tag URL.",
|
|
394
|
+
"npm \u306E\u6B63\u78BA\u306A\u7248\u3001\u307E\u305F\u306F GitHub Release \u306E\u30BF\u30B0 URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
|
|
395
|
+
);
|
|
396
|
+
const failed = authoring ? t("The extension was not added.", "\u62E1\u5F35\u6A5F\u80FD\u3092\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002") : t("The published files could not be verified.", "\u516C\u958B\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u8A3C\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
397
|
+
setError(code === "INVALID_REFERENCE" ? invalid : code ? failed + " (" + code + ")" : failed);
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
} finally {
|
|
401
|
+
operation.current = null;
|
|
402
|
+
if (!controller.signal.aborted) {
|
|
403
|
+
setPending(false);
|
|
404
|
+
if (authoring) onBusyChange(false);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return /* @__PURE__ */ import_react2.default.createElement("section", { "aria-label": t("Published extension", "\u516C\u958B\u6E08\u307F\u306E\u62E1\u5F35\u6A5F\u80FD") }, /* @__PURE__ */ import_react2.default.createElement("form", { onSubmit: (event) => {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
setCandidate(void 0);
|
|
411
|
+
void run(async (signal) => {
|
|
412
|
+
const resolved = await resolve(reference, { signal });
|
|
413
|
+
if (!signal.aborted) setCandidate(resolved);
|
|
414
|
+
});
|
|
415
|
+
} }, /* @__PURE__ */ import_react2.default.createElement("label", null, t("npm package or GitHub Release", "npm \u30D1\u30C3\u30B1\u30FC\u30B8\u307E\u305F\u306F GitHub Release"), /* @__PURE__ */ import_react2.default.createElement(
|
|
416
|
+
"input",
|
|
417
|
+
{
|
|
418
|
+
type: "text",
|
|
419
|
+
placeholder: "@scope/package@1.2.3",
|
|
420
|
+
value: reference,
|
|
421
|
+
maxLength: 512,
|
|
422
|
+
disabled: pending || blocked,
|
|
423
|
+
onChange: (event) => {
|
|
424
|
+
setReference(event.target.value);
|
|
425
|
+
setCandidate(void 0);
|
|
426
|
+
setError("");
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
)), /* @__PURE__ */ import_react2.default.createElement("button", { type: "submit", disabled: pending || blocked || !reference.trim() }, t("Inspect", "\u78BA\u8A8D"))), error && /* @__PURE__ */ import_react2.default.createElement("p", { role: "alert" }, error), candidate && /* @__PURE__ */ import_react2.default.createElement("div", null, /* @__PURE__ */ import_react2.default.createElement("p", null, /* @__PURE__ */ import_react2.default.createElement("strong", null, candidate.distribution.name), " \xB7 ", candidate.distribution.package, "@", candidate.distribution.version), /* @__PURE__ */ import_react2.default.createElement("p", null, candidate.distribution.description), /* @__PURE__ */ import_react2.default.createElement("p", null, candidate.distribution.license, " \xB7 ", candidate.distribution.execution === "sandboxed" ? t("Sandboxed", "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u5185") : t("Runs outside the sandbox", "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u5916\u3067\u5B9F\u884C")), /* @__PURE__ */ import_react2.default.createElement(ResourceDisclosure, { declaration: candidate.distribution.resources, locale }), /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", disabled: pending || blocked, onClick: () => void run((signal) => add(candidate, { signal }), true).then((added) => {
|
|
430
|
+
if (added) onAdded(candidate.distribution.id);
|
|
431
|
+
}) }, t("Add published extension", "\u516C\u958B\u62E1\u5F35\u3092\u8FFD\u52A0"))), pending && /* @__PURE__ */ import_react2.default.createElement("p", { role: "status" }, t("Working\u2026", "\u51E6\u7406\u4E2D\u2026")));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// src/catalog-library.tsx
|
|
297
435
|
var text2 = {
|
|
298
436
|
en: {
|
|
299
437
|
loading: "Loading TurboWarp Plus extensions\u2026",
|
|
@@ -321,11 +459,12 @@ function createCatalogLibrary({
|
|
|
321
459
|
readSettings: readPlusCatalogSettings,
|
|
322
460
|
applySettings: applyPlusCatalogSettings,
|
|
323
461
|
loadExtensions: loadPlusExtensions,
|
|
462
|
+
published,
|
|
324
463
|
loaderEnabled: PLUS_EXTENSION_LOADER_ENABLED,
|
|
325
464
|
isRetryable: isWorthAskingAgain,
|
|
326
465
|
styles
|
|
327
466
|
}) {
|
|
328
|
-
class PlusLibrary extends
|
|
467
|
+
class PlusLibrary extends import_react4.default.PureComponent {
|
|
329
468
|
constructor(props) {
|
|
330
469
|
super(props);
|
|
331
470
|
this.handleFetchCatalog = this.handleFetchCatalog.bind(this);
|
|
@@ -337,6 +476,7 @@ function createCatalogLibrary({
|
|
|
337
476
|
denied: false,
|
|
338
477
|
failure: null,
|
|
339
478
|
busy: false,
|
|
479
|
+
publishedBusy: false,
|
|
340
480
|
decisions: /* @__PURE__ */ new Map()
|
|
341
481
|
};
|
|
342
482
|
this.answered = null;
|
|
@@ -441,36 +581,38 @@ function createCatalogLibrary({
|
|
|
441
581
|
}
|
|
442
582
|
}
|
|
443
583
|
}
|
|
584
|
+
renderPublished() {
|
|
585
|
+
if (!published || !PLUS_EXTENSION_LOADER_ENABLED) return null;
|
|
586
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
587
|
+
PublishedExtension,
|
|
588
|
+
{
|
|
589
|
+
locale: this.props.locale,
|
|
590
|
+
resolve: published.resolve,
|
|
591
|
+
add: (candidate, options) => published.add(this.props.vm, candidate, options),
|
|
592
|
+
blocked: this.state.busy,
|
|
593
|
+
onBusyChange: (publishedBusy) => {
|
|
594
|
+
this.setState({ publishedBusy });
|
|
595
|
+
this.props.onBusyChange(publishedBusy);
|
|
596
|
+
},
|
|
597
|
+
onAdded: (id) => {
|
|
598
|
+
this.props.onCategorySelected(id);
|
|
599
|
+
this.props.onRequestClose();
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
}
|
|
444
604
|
render() {
|
|
445
605
|
const t = text2[this.props.locale.startsWith("ja") ? "ja" : "en"];
|
|
446
|
-
const { entries, busy, denied, failure, fetchError, decisions } = this.state;
|
|
447
|
-
|
|
448
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
449
|
-
"div",
|
|
450
|
-
{
|
|
451
|
-
className: styles.message,
|
|
452
|
-
role: fetchError ? "alert" : "status"
|
|
453
|
-
},
|
|
454
|
-
/* @__PURE__ */ import_react2.default.createElement("p", null, fetchError ? t.failed : t.loading),
|
|
455
|
-
fetchError && /* @__PURE__ */ import_react2.default.createElement(
|
|
456
|
-
"button",
|
|
457
|
-
{
|
|
458
|
-
type: "button",
|
|
459
|
-
onClick: this.handleFetchCatalog
|
|
460
|
-
},
|
|
461
|
-
t.retry
|
|
462
|
-
)
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", { className: styles.root }, denied && /* @__PURE__ */ import_react2.default.createElement(
|
|
606
|
+
const { entries, busy, publishedBusy, denied, failure, fetchError, decisions } = this.state;
|
|
607
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { className: styles.root }, this.renderPublished(), !entries ? /* @__PURE__ */ import_react4.default.createElement("div", { className: styles.message, role: fetchError ? "alert" : "status" }, /* @__PURE__ */ import_react4.default.createElement("p", null, fetchError ? t.failed : t.loading), fetchError && /* @__PURE__ */ import_react4.default.createElement("button", { type: "button", onClick: this.handleFetchCatalog }, t.retry)) : /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, denied && /* @__PURE__ */ import_react4.default.createElement(
|
|
466
608
|
"p",
|
|
467
609
|
{
|
|
468
610
|
className: styles.error,
|
|
469
611
|
role: "alert"
|
|
470
612
|
},
|
|
471
613
|
t.denied
|
|
472
|
-
), /* @__PURE__ */
|
|
473
|
-
|
|
614
|
+
), /* @__PURE__ */ import_react4.default.createElement("div", { hidden: busy || publishedBusy }, /* @__PURE__ */ import_react4.default.createElement(
|
|
615
|
+
import_react3.ExtensionReview,
|
|
474
616
|
{
|
|
475
617
|
mode: "add",
|
|
476
618
|
entries: reviewRows(entries, this.props.vm, PLUS_EXTENSION_LOADER_ENABLED),
|
|
@@ -480,7 +622,7 @@ function createCatalogLibrary({
|
|
|
480
622
|
onRetry: this.handleRetry,
|
|
481
623
|
onComplete: this.handleComplete
|
|
482
624
|
}
|
|
483
|
-
)), busy && /* @__PURE__ */
|
|
625
|
+
)), busy && /* @__PURE__ */ import_react4.default.createElement("p", { role: "status" }, t.loading)));
|
|
484
626
|
}
|
|
485
627
|
}
|
|
486
628
|
return PlusLibrary;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CatalogEntry, ReviewDecision, ReviewEntry, ReviewFailure } from './index.js';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { type PublishedExtensionPorts } from './published-extension.js';
|
|
3
4
|
/**
|
|
4
5
|
* The catalog as rows of the review screen.
|
|
5
6
|
*
|
|
@@ -34,6 +35,7 @@ interface LibraryState {
|
|
|
34
35
|
denied: boolean;
|
|
35
36
|
failure: ReviewFailure | null;
|
|
36
37
|
busy: boolean;
|
|
38
|
+
publishedBusy: boolean;
|
|
37
39
|
decisions: Decisions;
|
|
38
40
|
}
|
|
39
41
|
export declare const reviewRows: (entries: CatalogEntry[], vm: LibraryVM, loader?: boolean) => ReviewEntry[];
|
|
@@ -54,12 +56,16 @@ export interface CatalogLibraryPorts {
|
|
|
54
56
|
signal: AbortSignal;
|
|
55
57
|
}): Promise<string[]>;
|
|
56
58
|
loadExtensions(vm: LibraryVM, entries: CatalogEntry[], modes: Map<string, string>, permissions: any): Promise<string[]>;
|
|
59
|
+
published?: {
|
|
60
|
+
resolve: PublishedExtensionPorts['resolve'];
|
|
61
|
+
add(vm: LibraryVM, ...args: Parameters<PublishedExtensionPorts['add']>): Promise<void>;
|
|
62
|
+
};
|
|
57
63
|
loaderEnabled: boolean;
|
|
58
64
|
isRetryable(error: unknown): boolean;
|
|
59
65
|
styles: Record<string, string>;
|
|
60
66
|
}
|
|
61
67
|
/** 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): {
|
|
68
|
+
export declare function createCatalogLibrary({ catalog: plusCatalog, readSettings: readPlusCatalogSettings, applySettings: applyPlusCatalogSettings, loadExtensions: loadPlusExtensions, published, loaderEnabled: PLUS_EXTENSION_LOADER_ENABLED, isRetryable: isWorthAskingAgain, styles }: CatalogLibraryPorts): {
|
|
63
69
|
new (props: LibraryProps): {
|
|
64
70
|
controller?: AbortController;
|
|
65
71
|
answered: Decisions | null;
|
|
@@ -81,6 +87,7 @@ export declare function createCatalogLibrary({ catalog: plusCatalog, readSetting
|
|
|
81
87
|
* @param {Map<string, object>} decisions The answer by extension ID.
|
|
82
88
|
*/
|
|
83
89
|
apply(decisions: Decisions): Promise<void>;
|
|
90
|
+
renderPublished(): React.JSX.Element | null;
|
|
84
91
|
render(): React.JSX.Element;
|
|
85
92
|
context: any;
|
|
86
93
|
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;
|