@kubohiroya/turbowarp-extension-security-dialog 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -83,6 +83,33 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
83
83
  **記録された答えは、いまも選択肢である場合だけ尊重します。** 作品が `remote-cacheable` から
84
84
  埋め込みに変わった、行が信頼済みになった、といった場合に、もう提示しない答えを持ち込みません。
85
85
 
86
+ ### 読み込みに失敗したとき
87
+
88
+ ```jsx
89
+ <ExtensionReview
90
+ /* ...上と同じ */
91
+ failure={{code: error.code, message: error.message, retryable: isWorthAskingAgain(error)}}
92
+ onRetry={() => loadAgain()}
93
+ />
94
+ ```
95
+
96
+ `failure` は読み込み全体の失敗で、行の一覧の上に出ます。行ごとの失敗は行の `state.error` に入れ、
97
+ こちらも同じ `retryable` を任意で持てます。どちらも同じ規則に従います。
98
+
99
+ | `retryable` | `onRetry` | 画面に出るもの |
100
+ | --- | --- | --- |
101
+ | `true` | 渡されている | コードとメッセージ、「通信の問題の可能性があります」、`onRetry` を呼ぶ **もう一度試す** ボタン |
102
+ | `true` | 渡されていない | コードとメッセージだけ |
103
+ | `false` または無し | どちらでも | コードとメッセージだけ |
104
+
105
+ `failure` を渡さなければ、これらの props が無かったときとまったく同じに描きます。
106
+
107
+ **画面はエラーコードの表を持ちません。** もう一度試して結果が変わりうるかはホストの判断で、
108
+ TurboWarp-Plus Editor ではローダーの `isWorthAskingAgain` が決め、真偽値として渡されます。コード
109
+ では決まりません。`LOAD_FAILED` は、もう一度試せば通るかもしれない通信の切断からも、何度試しても
110
+ 通らない「登録した ID が違う」拡張からも出ます。後者に「もう一度試す」を出すのは、画面が裏付け
111
+ られない助言です。
112
+
86
113
  ## 取得を待つあいだ
87
114
 
88
115
  ```js
@@ -147,11 +174,13 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
147
174
  それを未検証の申告として示します。ここでコードを評価することはありません。プレビュー画像は装飾で、
148
175
  何とも照合していません。コードを検証するのは別の場所で、失敗した行にはそう表示されます。
149
176
 
177
+ 先頭コメントは2つの書き方を読みます。TurboWarp 本体の拡張とギャラリーが使う `// Name: ...` の行と、`/** @name ... */` のブロックです。同じ項目を両方が書いていればブロックを採ります。見出しとして読むのは先頭に続くコメント行だけで、`Bundled extensions:` で止めます。バンドルが中身について書いたことは中身のもので、バンドル自身のものではないためです。
178
+
150
179
  ## 開発
151
180
 
152
181
  ```sh
153
182
  pnpm install
154
- pnpm run check # ビルド、テスト46件、pack の dry run
183
+ pnpm run check # ビルド、テスト56件、pack の dry run
155
184
  ```
156
185
 
157
186
  React と React DOM は peerDependencies なので、ホストが用意します。実行時の依存はありません。
@@ -159,3 +188,5 @@ React と React DOM は peerDependencies なので、ホストが用意します
159
188
  ## ライセンス
160
189
 
161
190
  [MPL-2.0](LICENSE)。何が対象で何が対象外かは [NOTICE.md](./NOTICE.md) を参照してください。
191
+
192
+ 0.6.0でMPL-2.0へ書き直したときの設計の記録は [書き直しの設計](docs/mpl-rewrite.ja.md) にあります。
package/README.md CHANGED
@@ -87,6 +87,33 @@ nothing but trusted rows is not worth stopping, so `requiresReview` says to skip
87
87
  moved from `remote-cacheable` to embedded bytes, or a row that has since become trusted, does not
88
88
  carry a stale answer into a screen that no longer offers it.
89
89
 
90
+ ### When loading fails
91
+
92
+ ```jsx
93
+ <ExtensionReview
94
+ /* ...as above */
95
+ failure={{code: error.code, message: error.message, retryable: isWorthAskingAgain(error)}}
96
+ onRetry={() => loadAgain()}
97
+ />
98
+ ```
99
+
100
+ `failure` is a failure of the whole load, shown above the rows; a row's own failure goes in its
101
+ `state.error`, which takes the same optional `retryable`. Both follow one rule:
102
+
103
+ | `retryable` | `onRetry` given | What the screen shows |
104
+ | --- | --- | --- |
105
+ | `true` | yes | The code and message, "This may be a network problem" and a **Try again** button that calls `onRetry` |
106
+ | `true` | no | The code and message only |
107
+ | `false` or missing | either | The code and message only |
108
+
109
+ With no `failure` the screen renders exactly as it did before these props existed.
110
+
111
+ **The screen keeps no table of error codes.** Whether asking again could change the outcome is the
112
+ host's judgement — the Loader's `isWorthAskingAgain` in the TurboWarp-Plus Editor — passed in as a
113
+ boolean. A code cannot decide it: `LOAD_FAILED` comes both from a dropped connection, where trying
114
+ again may work, and from an extension that registered a different ID, where it never will. Offering
115
+ "try again" for the second would be advice the screen cannot back.
116
+
90
117
  ## While a fetch is waiting
91
118
 
92
119
  ```js
@@ -154,11 +181,16 @@ of its leading comment, and the screen labels them as unverified. Nothing here e
154
181
  extension. A preview picture is decoration and is checked against nothing; whatever verifies the
155
182
  code does so elsewhere, and a row says so when it failed.
156
183
 
184
+ Two forms of leading comment are read: the `// Name: ...` lines TurboWarp's own extensions and its
185
+ gallery open with, and a `/** @name ... */` block. Where both name a field, the block wins. Only the
186
+ leading run of comment lines counts as a header, and reading stops at `Bundled extensions:`, because
187
+ what a bundle says about its members is theirs, not its own.
188
+
157
189
  ## Development
158
190
 
159
191
  ```sh
160
192
  pnpm install
161
- pnpm run check # build, 46 tests, and a packing dry run
193
+ pnpm run check # build, 56 tests, and a packing dry run
162
194
  ```
163
195
 
164
196
  React and React DOM are peer dependencies, so the host supplies them. There are no runtime
@@ -167,3 +199,5 @@ dependencies.
167
199
  ## License
168
200
 
169
201
  [MPL-2.0](LICENSE). See [NOTICE.md](./NOTICE.md) for what is and is not covered.
202
+
203
+ The design record of the MPL-2.0 rewrite in 0.6.0 is in [the rewrite design (Japanese)](docs/mpl-rewrite.ja.md).
package/dist/index.cjs CHANGED
@@ -211,36 +211,82 @@ function decodeExtensionDataURL(url) {
211
211
  }
212
212
  function parseExtensionMetadata(source) {
213
213
  if (typeof source !== "string") return {};
214
- const block = BLOCK.exec(source.slice(0, 64 * 1024));
215
- if (block === null) return {};
214
+ const text2 = source.slice(0, 64 * 1024);
216
215
  const metadata = {};
217
216
  const descriptions = {};
218
- for (const line of block[1].split("\n")) {
219
- const field = FIELD.exec(line);
220
- if (field === null) continue;
221
- const [, name, raw] = field;
217
+ const record = (name, raw, locale) => {
222
218
  const value = trimmed(raw);
223
- if (value.length === 0 || value.length > LIMIT) continue;
219
+ if (value.length === 0 || value.length > LIMIT) return;
224
220
  if (name === "description") {
225
- const localized = /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(value);
226
- if (localized === null) metadata.description = value;
227
- else descriptions[localized[1].toLowerCase()] = trimmed(localized[2]);
228
- continue;
221
+ if (locale) descriptions[locale.toLowerCase()] = value;
222
+ else metadata.description = value;
223
+ return;
229
224
  }
230
225
  if (["repository", "docsURL", "authorURL"].includes(name)) {
231
226
  try {
232
227
  metadata[name] = reviewURL(value, name, name === "authorURL");
233
228
  } catch (error) {
234
229
  }
235
- continue;
230
+ return;
236
231
  }
237
232
  if (["name", "id", "author", "version", "license", "banner", "package", "unsandboxed"].includes(name)) {
238
233
  metadata[name] = value;
239
234
  }
235
+ };
236
+ for (const [name, raw, locale] of headerFields(text2)) record(name, raw, locale);
237
+ const block = BLOCK.exec(text2);
238
+ if (block !== null) {
239
+ for (const line of block[1].split("\n")) {
240
+ const field = FIELD.exec(line);
241
+ if (field === null) continue;
242
+ const [, name, raw] = field;
243
+ const localized = name === "description" ? /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(trimmed(raw)) : null;
244
+ if (localized === null) record(name, raw);
245
+ else record(name, localized[2], localized[1]);
246
+ }
240
247
  }
241
248
  if (Object.keys(descriptions).length > 0) metadata.descriptions = descriptions;
242
249
  return metadata;
243
250
  }
251
+ var HEADER_FIELDS = Object.freeze({
252
+ name: "name",
253
+ id: "id",
254
+ description: "description",
255
+ by: "author",
256
+ author: "author",
257
+ version: "version",
258
+ license: "license",
259
+ unsandboxed: "unsandboxed",
260
+ repository: "repository",
261
+ source: "repository",
262
+ "docs url": "docsURL",
263
+ docsurl: "docsURL",
264
+ "author url": "authorURL",
265
+ authorurl: "authorURL",
266
+ banner: "banner",
267
+ package: "package"
268
+ });
269
+ function headerFields(text2) {
270
+ const fields = [];
271
+ const seen = /* @__PURE__ */ new Set();
272
+ for (const line of text2.split("\n")) {
273
+ const comment = /^[ \t]*\/\/(.*)$/.exec(line);
274
+ if (comment === null) {
275
+ if (line.trim() === "") continue;
276
+ break;
277
+ }
278
+ const body = comment[1];
279
+ if (/^\s*Bundled extensions:\s*$/i.test(body)) break;
280
+ const field = /^ ?([A-Za-z][A-Za-z -]*?)(?:\[([a-z]{2,8}(?:-[A-Za-z0-9]{1,8})*)\])?:[ \t]*(.*)$/.exec(body);
281
+ if (field === null) continue;
282
+ const name = HEADER_FIELDS[field[1].trim().toLowerCase()];
283
+ const key = `${name}:${field[2] || ""}`;
284
+ if (!name || seen.has(key)) continue;
285
+ seen.add(key);
286
+ fields.push(field[2] ? [name, field[3], field[2]] : [name, field[3]]);
287
+ }
288
+ return fields;
289
+ }
244
290
  function getExtensionDescription(metadata, locale = "en") {
245
291
  const declared = metadata && metadata.descriptions;
246
292
  if (!declared) return metadata && metadata.description || "";
@@ -515,6 +561,8 @@ var messages = {
515
561
  digest: "SHA-256",
516
562
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
517
563
  failed: "Could not be loaded",
564
+ retryNote: "This may be a network problem.",
565
+ retry: "Try again",
518
566
  ok: "OK",
519
567
  cancel: "Cancel",
520
568
  add: "Add",
@@ -561,6 +609,8 @@ var messages = {
561
609
  digest: "SHA-256",
562
610
  unverified: "\u88FD\u4F5C\u8005\u540D\u306F\u62E1\u5F35\u81EA\u8EAB\u306E\u7533\u544A\u3067\u3001\u691C\u8A3C\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
563
611
  failed: "\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",
612
+ retryNote: "\u901A\u4FE1\u306E\u554F\u984C\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002",
613
+ retry: "\u3082\u3046\u4E00\u5EA6\u8A66\u3059",
564
614
  ok: "OK",
565
615
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
566
616
  add: "\u8FFD\u52A0",
package/dist/index.mjs CHANGED
@@ -168,36 +168,82 @@ function decodeExtensionDataURL(url) {
168
168
  }
169
169
  function parseExtensionMetadata(source) {
170
170
  if (typeof source !== "string") return {};
171
- const block = BLOCK.exec(source.slice(0, 64 * 1024));
172
- if (block === null) return {};
171
+ const text2 = source.slice(0, 64 * 1024);
173
172
  const metadata = {};
174
173
  const descriptions = {};
175
- for (const line of block[1].split("\n")) {
176
- const field = FIELD.exec(line);
177
- if (field === null) continue;
178
- const [, name, raw] = field;
174
+ const record = (name, raw, locale) => {
179
175
  const value = trimmed(raw);
180
- if (value.length === 0 || value.length > LIMIT) continue;
176
+ if (value.length === 0 || value.length > LIMIT) return;
181
177
  if (name === "description") {
182
- const localized = /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(value);
183
- if (localized === null) metadata.description = value;
184
- else descriptions[localized[1].toLowerCase()] = trimmed(localized[2]);
185
- continue;
178
+ if (locale) descriptions[locale.toLowerCase()] = value;
179
+ else metadata.description = value;
180
+ return;
186
181
  }
187
182
  if (["repository", "docsURL", "authorURL"].includes(name)) {
188
183
  try {
189
184
  metadata[name] = reviewURL(value, name, name === "authorURL");
190
185
  } catch (error) {
191
186
  }
192
- continue;
187
+ return;
193
188
  }
194
189
  if (["name", "id", "author", "version", "license", "banner", "package", "unsandboxed"].includes(name)) {
195
190
  metadata[name] = value;
196
191
  }
192
+ };
193
+ for (const [name, raw, locale] of headerFields(text2)) record(name, raw, locale);
194
+ const block = BLOCK.exec(text2);
195
+ if (block !== null) {
196
+ for (const line of block[1].split("\n")) {
197
+ const field = FIELD.exec(line);
198
+ if (field === null) continue;
199
+ const [, name, raw] = field;
200
+ const localized = name === "description" ? /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(trimmed(raw)) : null;
201
+ if (localized === null) record(name, raw);
202
+ else record(name, localized[2], localized[1]);
203
+ }
197
204
  }
198
205
  if (Object.keys(descriptions).length > 0) metadata.descriptions = descriptions;
199
206
  return metadata;
200
207
  }
208
+ var HEADER_FIELDS = Object.freeze({
209
+ name: "name",
210
+ id: "id",
211
+ description: "description",
212
+ by: "author",
213
+ author: "author",
214
+ version: "version",
215
+ license: "license",
216
+ unsandboxed: "unsandboxed",
217
+ repository: "repository",
218
+ source: "repository",
219
+ "docs url": "docsURL",
220
+ docsurl: "docsURL",
221
+ "author url": "authorURL",
222
+ authorurl: "authorURL",
223
+ banner: "banner",
224
+ package: "package"
225
+ });
226
+ function headerFields(text2) {
227
+ const fields = [];
228
+ const seen = /* @__PURE__ */ new Set();
229
+ for (const line of text2.split("\n")) {
230
+ const comment = /^[ \t]*\/\/(.*)$/.exec(line);
231
+ if (comment === null) {
232
+ if (line.trim() === "") continue;
233
+ break;
234
+ }
235
+ const body = comment[1];
236
+ if (/^\s*Bundled extensions:\s*$/i.test(body)) break;
237
+ const field = /^ ?([A-Za-z][A-Za-z -]*?)(?:\[([a-z]{2,8}(?:-[A-Za-z0-9]{1,8})*)\])?:[ \t]*(.*)$/.exec(body);
238
+ if (field === null) continue;
239
+ const name = HEADER_FIELDS[field[1].trim().toLowerCase()];
240
+ const key = `${name}:${field[2] || ""}`;
241
+ if (!name || seen.has(key)) continue;
242
+ seen.add(key);
243
+ fields.push(field[2] ? [name, field[3], field[2]] : [name, field[3]]);
244
+ }
245
+ return fields;
246
+ }
201
247
  function getExtensionDescription(metadata, locale = "en") {
202
248
  const declared = metadata && metadata.descriptions;
203
249
  if (!declared) return metadata && metadata.description || "";
@@ -472,6 +518,8 @@ var messages = {
472
518
  digest: "SHA-256",
473
519
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
474
520
  failed: "Could not be loaded",
521
+ retryNote: "This may be a network problem.",
522
+ retry: "Try again",
475
523
  ok: "OK",
476
524
  cancel: "Cancel",
477
525
  add: "Add",
@@ -518,6 +566,8 @@ var messages = {
518
566
  digest: "SHA-256",
519
567
  unverified: "\u88FD\u4F5C\u8005\u540D\u306F\u62E1\u5F35\u81EA\u8EAB\u306E\u7533\u544A\u3067\u3001\u691C\u8A3C\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
520
568
  failed: "\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",
569
+ retryNote: "\u901A\u4FE1\u306E\u554F\u984C\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002",
570
+ retry: "\u3082\u3046\u4E00\u5EA6\u8A66\u3059",
521
571
  ok: "OK",
522
572
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
523
573
  add: "\u8FFD\u52A0",
package/dist/react.cjs CHANGED
@@ -96,6 +96,8 @@ var messages = {
96
96
  digest: "SHA-256",
97
97
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
98
98
  failed: "Could not be loaded",
99
+ retryNote: "This may be a network problem.",
100
+ retry: "Try again",
99
101
  ok: "OK",
100
102
  cancel: "Cancel",
101
103
  add: "Add",
@@ -142,6 +144,8 @@ var messages = {
142
144
  digest: "SHA-256",
143
145
  unverified: "\u88FD\u4F5C\u8005\u540D\u306F\u62E1\u5F35\u81EA\u8EAB\u306E\u7533\u544A\u3067\u3001\u691C\u8A3C\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
144
146
  failed: "\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",
147
+ retryNote: "\u901A\u4FE1\u306E\u554F\u984C\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002",
148
+ retry: "\u3082\u3046\u4E00\u5EA6\u8A66\u3059",
145
149
  ok: "OK",
146
150
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
147
151
  add: "\u8FFD\u52A0",
@@ -158,6 +162,24 @@ var formatMessage = (locale, key, values = {}) => {
158
162
  };
159
163
 
160
164
  // src/metadata.js
165
+ var HEADER_FIELDS = Object.freeze({
166
+ name: "name",
167
+ id: "id",
168
+ description: "description",
169
+ by: "author",
170
+ author: "author",
171
+ version: "version",
172
+ license: "license",
173
+ unsandboxed: "unsandboxed",
174
+ repository: "repository",
175
+ source: "repository",
176
+ "docs url": "docsURL",
177
+ docsurl: "docsURL",
178
+ "author url": "authorURL",
179
+ authorurl: "authorURL",
180
+ banner: "banner",
181
+ package: "package"
182
+ });
161
183
  function getExtensionDescription(metadata, locale = "en") {
162
184
  const declared = metadata && metadata.descriptions;
163
185
  if (!declared) return metadata && metadata.description || "";
@@ -414,6 +436,28 @@ var sourceLabel = (entry, t) => {
414
436
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
415
437
  return entry.source.url;
416
438
  };
439
+ var Failure = ({ failure, onRetry, t }) => {
440
+ const retry = failure.retryable === true && typeof onRetry === "function";
441
+ return /* @__PURE__ */ import_react2.default.createElement(
442
+ "div",
443
+ {
444
+ className: "twextsec-failed",
445
+ role: "alert"
446
+ },
447
+ /* @__PURE__ */ import_react2.default.createElement("p", null, t("failed"), ": ", failure.code, " ", failure.message),
448
+ retry && /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-retry-note" }, t("retryNote")),
449
+ retry && /* @__PURE__ */ import_react2.default.createElement(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ className: "twextsec-retry",
454
+ "data-testid": "twextsec-retry",
455
+ onClick: () => onRetry()
456
+ },
457
+ t("retry")
458
+ )
459
+ );
460
+ };
417
461
  var Choices = ({ name, value, options, disabled, label, onChange, t }) => /* @__PURE__ */ import_react2.default.createElement("fieldset", { className: "twextsec-choice" }, /* @__PURE__ */ import_react2.default.createElement("legend", null, label), options.map((option) => /* @__PURE__ */ import_react2.default.createElement("label", { key: option }, /* @__PURE__ */ import_react2.default.createElement(
418
462
  "input",
419
463
  {
@@ -568,16 +612,12 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
568
612
  /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-claim" }, t("creator"), ": ", metadata.author || t("creatorUnknown"), " \u2014 ", t("unverified")),
569
613
  state && /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-state" }, required ? t("state-dependency", { names: roots.join(", ") }) : t(`state-${state}`)),
570
614
  failure && /* @__PURE__ */ import_react2.default.createElement(
571
- "p",
615
+ Failure,
572
616
  {
573
- className: "twextsec-failed",
574
- role: "alert"
575
- },
576
- t("failed"),
577
- ": ",
578
- failure.code,
579
- " ",
580
- failure.message
617
+ failure,
618
+ onRetry: this.props.onRetry,
619
+ t
620
+ }
581
621
  ),
582
622
  isTrusted(entry) ? /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-trusted" }, t("trusted")) : /* @__PURE__ */ import_react2.default.createElement(
583
623
  Choices,
@@ -614,12 +654,19 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
614
654
  );
615
655
  }
616
656
  render() {
617
- const { mode, entries, DialogFrame } = this.props;
657
+ const { mode, entries, DialogFrame, failure, onRetry } = this.props;
618
658
  const t = this.t.bind(this);
619
659
  const selection = this.selection();
620
660
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
621
661
  const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
622
- const body = /* @__PURE__ */ import_react2.default.createElement("div", { className: "twextsec-review" }, /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-intro" }, t(mode === "add" ? "addIntro" : "openIntro")), /* @__PURE__ */ import_react2.default.createElement("div", { className: "twextsec-bulk" }, /* @__PURE__ */ import_react2.default.createElement(
662
+ const body = /* @__PURE__ */ import_react2.default.createElement("div", { className: "twextsec-review" }, /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-intro" }, t(mode === "add" ? "addIntro" : "openIntro")), failure && /* @__PURE__ */ import_react2.default.createElement(
663
+ Failure,
664
+ {
665
+ failure,
666
+ onRetry,
667
+ t
668
+ }
669
+ ), /* @__PURE__ */ import_react2.default.createElement("div", { className: "twextsec-bulk" }, /* @__PURE__ */ import_react2.default.createElement(
623
670
  Choices,
624
671
  {
625
672
  name: "execution-all",
package/dist/react.d.ts CHANGED
@@ -19,6 +19,16 @@ export interface ExtensionReviewProps {
19
19
  loadInfo?: (url: string, signal: AbortSignal) => Promise<{source: string; metadata: ExtensionMetadata}>;
20
20
  /** Where previews are kept between visits; null keeps nothing. */
21
21
  previewCache?: PreviewCache | null;
22
+ /**
23
+ * A failure of the whole load, shown above the rows. Absent or null renders exactly as before.
24
+ * `retryable` is the host's judgement, never derived here from `code`.
25
+ */
26
+ failure?: {code: string; message: string; retryable: boolean} | null;
27
+ /**
28
+ * Asks the host to try the load again. "Try again" appears only for a failure — `failure`, or a
29
+ * row's `state.error` — whose `retryable` is `true`, and only when this is given.
30
+ */
31
+ onRetry?: () => void;
22
32
  onComplete(decisions: Map<string, ReviewDecision> | null): void;
23
33
  }
24
34
 
package/dist/react.mjs CHANGED
@@ -63,6 +63,8 @@ var messages = {
63
63
  digest: "SHA-256",
64
64
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
65
65
  failed: "Could not be loaded",
66
+ retryNote: "This may be a network problem.",
67
+ retry: "Try again",
66
68
  ok: "OK",
67
69
  cancel: "Cancel",
68
70
  add: "Add",
@@ -109,6 +111,8 @@ var messages = {
109
111
  digest: "SHA-256",
110
112
  unverified: "\u88FD\u4F5C\u8005\u540D\u306F\u62E1\u5F35\u81EA\u8EAB\u306E\u7533\u544A\u3067\u3001\u691C\u8A3C\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
111
113
  failed: "\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",
114
+ retryNote: "\u901A\u4FE1\u306E\u554F\u984C\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002",
115
+ retry: "\u3082\u3046\u4E00\u5EA6\u8A66\u3059",
112
116
  ok: "OK",
113
117
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
114
118
  add: "\u8FFD\u52A0",
@@ -125,6 +129,24 @@ var formatMessage = (locale, key, values = {}) => {
125
129
  };
126
130
 
127
131
  // src/metadata.js
132
+ var HEADER_FIELDS = Object.freeze({
133
+ name: "name",
134
+ id: "id",
135
+ description: "description",
136
+ by: "author",
137
+ author: "author",
138
+ version: "version",
139
+ license: "license",
140
+ unsandboxed: "unsandboxed",
141
+ repository: "repository",
142
+ source: "repository",
143
+ "docs url": "docsURL",
144
+ docsurl: "docsURL",
145
+ "author url": "authorURL",
146
+ authorurl: "authorURL",
147
+ banner: "banner",
148
+ package: "package"
149
+ });
128
150
  function getExtensionDescription(metadata, locale = "en") {
129
151
  const declared = metadata && metadata.descriptions;
130
152
  if (!declared) return metadata && metadata.description || "";
@@ -381,6 +403,28 @@ var sourceLabel = (entry, t) => {
381
403
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
382
404
  return entry.source.url;
383
405
  };
406
+ var Failure = ({ failure, onRetry, t }) => {
407
+ const retry = failure.retryable === true && typeof onRetry === "function";
408
+ return /* @__PURE__ */ React2.createElement(
409
+ "div",
410
+ {
411
+ className: "twextsec-failed",
412
+ role: "alert"
413
+ },
414
+ /* @__PURE__ */ React2.createElement("p", null, t("failed"), ": ", failure.code, " ", failure.message),
415
+ retry && /* @__PURE__ */ React2.createElement("p", { className: "twextsec-retry-note" }, t("retryNote")),
416
+ retry && /* @__PURE__ */ React2.createElement(
417
+ "button",
418
+ {
419
+ type: "button",
420
+ className: "twextsec-retry",
421
+ "data-testid": "twextsec-retry",
422
+ onClick: () => onRetry()
423
+ },
424
+ t("retry")
425
+ )
426
+ );
427
+ };
384
428
  var Choices = ({ name, value, options, disabled, label, onChange, t }) => /* @__PURE__ */ React2.createElement("fieldset", { className: "twextsec-choice" }, /* @__PURE__ */ React2.createElement("legend", null, label), options.map((option) => /* @__PURE__ */ React2.createElement("label", { key: option }, /* @__PURE__ */ React2.createElement(
385
429
  "input",
386
430
  {
@@ -535,16 +579,12 @@ var ExtensionReview = class extends React2.PureComponent {
535
579
  /* @__PURE__ */ React2.createElement("p", { className: "twextsec-claim" }, t("creator"), ": ", metadata.author || t("creatorUnknown"), " \u2014 ", t("unverified")),
536
580
  state && /* @__PURE__ */ React2.createElement("p", { className: "twextsec-state" }, required ? t("state-dependency", { names: roots.join(", ") }) : t(`state-${state}`)),
537
581
  failure && /* @__PURE__ */ React2.createElement(
538
- "p",
582
+ Failure,
539
583
  {
540
- className: "twextsec-failed",
541
- role: "alert"
542
- },
543
- t("failed"),
544
- ": ",
545
- failure.code,
546
- " ",
547
- failure.message
584
+ failure,
585
+ onRetry: this.props.onRetry,
586
+ t
587
+ }
548
588
  ),
549
589
  isTrusted(entry) ? /* @__PURE__ */ React2.createElement("p", { className: "twextsec-trusted" }, t("trusted")) : /* @__PURE__ */ React2.createElement(
550
590
  Choices,
@@ -581,12 +621,19 @@ var ExtensionReview = class extends React2.PureComponent {
581
621
  );
582
622
  }
583
623
  render() {
584
- const { mode, entries, DialogFrame } = this.props;
624
+ const { mode, entries, DialogFrame, failure, onRetry } = this.props;
585
625
  const t = this.t.bind(this);
586
626
  const selection = this.selection();
587
627
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
588
628
  const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
589
- const body = /* @__PURE__ */ React2.createElement("div", { className: "twextsec-review" }, /* @__PURE__ */ React2.createElement("p", { className: "twextsec-intro" }, t(mode === "add" ? "addIntro" : "openIntro")), /* @__PURE__ */ React2.createElement("div", { className: "twextsec-bulk" }, /* @__PURE__ */ React2.createElement(
629
+ const body = /* @__PURE__ */ React2.createElement("div", { className: "twextsec-review" }, /* @__PURE__ */ React2.createElement("p", { className: "twextsec-intro" }, t(mode === "add" ? "addIntro" : "openIntro")), failure && /* @__PURE__ */ React2.createElement(
630
+ Failure,
631
+ {
632
+ failure,
633
+ onRetry,
634
+ t
635
+ }
636
+ ), /* @__PURE__ */ React2.createElement("div", { className: "twextsec-bulk" }, /* @__PURE__ */ React2.createElement(
590
637
  Choices,
591
638
  {
592
639
  name: "execution-all",
@@ -56,10 +56,24 @@ export type ReviewSource =
56
56
  | {kind: 'embedded-data'; sha256: string}
57
57
  | {kind: 'legacy'; url: string};
58
58
 
59
+ /**
60
+ * A load that failed, as the host reports it.
61
+ *
62
+ * `retryable` is the host's judgement — in the TurboWarp-Plus Editor, the Loader's
63
+ * `isWorthAskingAgain` — and not something this package derives from `code`: one code can come
64
+ * from a dropped connection and from a forged extension alike. Only `true` offers "try again", and
65
+ * only when the screen was also given `onRetry`; missing or `false` states the failure and stops.
66
+ */
67
+ export interface ReviewFailure {
68
+ code: string;
69
+ message: string;
70
+ retryable?: boolean;
71
+ }
72
+
59
73
  export interface ReviewEntryState {
60
74
  loaded?: boolean;
61
75
  trusted?: boolean;
62
- error?: {code: string; message: string};
76
+ error?: ReviewFailure;
63
77
  }
64
78
 
65
79
  export interface ReviewEntry {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Batch extension security review, previews and per-project defaults for TurboWarp hosts",
5
5
  "type": "module",
6
6
  "author": {
package/styles.css CHANGED
@@ -14,6 +14,9 @@
14
14
  .twextsec-claim, .twextsec-requirement { opacity: .8; }
15
15
  .twextsec-trusted { margin: 6px 0 0; font-weight: 500; }
16
16
  .twextsec-failed, .twextsec-contradiction { margin: 6px 0 0; color: var(--ui-danger, #b91c1c); }
17
+ .twextsec-failed p { margin: 0; }
18
+ .twextsec-failed .twextsec-retry-note { margin-top: 4px; font-size: .9em; }
19
+ .twextsec-retry { margin-top: 6px; font: inherit; padding: 4px 12px; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
17
20
  .twextsec-choice { margin: 8px 0 0; padding: 6px 10px; border: 1px solid var(--ui-black-transparent, #0000001a); border-radius: 6px; }
18
21
  .twextsec-choice legend { padding: 0 4px; font-size: .85em; opacity: .8; }
19
22
  .twextsec-choice label { display: inline-flex; align-items: center; gap: 4px; margin-right: 14px; }
package/webpack4.css CHANGED
@@ -14,6 +14,9 @@
14
14
  :global(.twextsec-claim), :global(.twextsec-requirement) { opacity: .8; }
15
15
  :global(.twextsec-trusted) { margin: 6px 0 0; font-weight: 500; }
16
16
  :global(.twextsec-failed), :global(.twextsec-contradiction) { margin: 6px 0 0; color: var(--ui-danger, #b91c1c); }
17
+ :global(.twextsec-failed) p { margin: 0; }
18
+ :global(.twextsec-failed) :global(.twextsec-retry-note) { margin-top: 4px; font-size: .9em; }
19
+ :global(.twextsec-retry) { margin-top: 6px; font: inherit; padding: 4px 12px; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
17
20
  :global(.twextsec-choice) { margin: 8px 0 0; padding: 6px 10px; border: 1px solid var(--ui-black-transparent, #0000001a); border-radius: 6px; }
18
21
  :global(.twextsec-choice) legend { padding: 0 4px; font-size: .85em; opacity: .8; }
19
22
  :global(.twextsec-choice) label { display: inline-flex; align-items: center; gap: 4px; margin-right: 14px; }