@kubohiroya/turbowarp-extension-security-dialog 0.7.1 → 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
@@ -153,7 +180,7 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
153
180
 
154
181
  ```sh
155
182
  pnpm install
156
- pnpm run check # ビルド、テスト46件、pack の dry run
183
+ pnpm run check # ビルド、テスト56件、pack の dry run
157
184
  ```
158
185
 
159
186
  React と React DOM は peerDependencies なので、ホストが用意します。実行時の依存はありません。
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
@@ -163,7 +190,7 @@ what a bundle says about its members is theirs, not its own.
163
190
 
164
191
  ```sh
165
192
  pnpm install
166
- pnpm run check # build, 46 tests, and a packing dry run
193
+ pnpm run check # build, 56 tests, and a packing dry run
167
194
  ```
168
195
 
169
196
  React and React DOM are peer dependencies, so the host supplies them. There are no runtime
package/dist/index.cjs CHANGED
@@ -561,6 +561,8 @@ var messages = {
561
561
  digest: "SHA-256",
562
562
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
563
563
  failed: "Could not be loaded",
564
+ retryNote: "This may be a network problem.",
565
+ retry: "Try again",
564
566
  ok: "OK",
565
567
  cancel: "Cancel",
566
568
  add: "Add",
@@ -607,6 +609,8 @@ var messages = {
607
609
  digest: "SHA-256",
608
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",
609
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",
610
614
  ok: "OK",
611
615
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
612
616
  add: "\u8FFD\u52A0",
package/dist/index.mjs CHANGED
@@ -518,6 +518,8 @@ var messages = {
518
518
  digest: "SHA-256",
519
519
  unverified: "The creator\u2019s name is the extension\u2019s own claim and is not verified.",
520
520
  failed: "Could not be loaded",
521
+ retryNote: "This may be a network problem.",
522
+ retry: "Try again",
521
523
  ok: "OK",
522
524
  cancel: "Cancel",
523
525
  add: "Add",
@@ -564,6 +566,8 @@ var messages = {
564
566
  digest: "SHA-256",
565
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",
566
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",
567
571
  ok: "OK",
568
572
  cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
569
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",
@@ -432,6 +436,28 @@ var sourceLabel = (entry, t) => {
432
436
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
433
437
  return entry.source.url;
434
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
+ };
435
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(
436
462
  "input",
437
463
  {
@@ -586,16 +612,12 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
586
612
  /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-claim" }, t("creator"), ": ", metadata.author || t("creatorUnknown"), " \u2014 ", t("unverified")),
587
613
  state && /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-state" }, required ? t("state-dependency", { names: roots.join(", ") }) : t(`state-${state}`)),
588
614
  failure && /* @__PURE__ */ import_react2.default.createElement(
589
- "p",
615
+ Failure,
590
616
  {
591
- className: "twextsec-failed",
592
- role: "alert"
593
- },
594
- t("failed"),
595
- ": ",
596
- failure.code,
597
- " ",
598
- failure.message
617
+ failure,
618
+ onRetry: this.props.onRetry,
619
+ t
620
+ }
599
621
  ),
600
622
  isTrusted(entry) ? /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-trusted" }, t("trusted")) : /* @__PURE__ */ import_react2.default.createElement(
601
623
  Choices,
@@ -632,12 +654,19 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
632
654
  );
633
655
  }
634
656
  render() {
635
- const { mode, entries, DialogFrame } = this.props;
657
+ const { mode, entries, DialogFrame, failure, onRetry } = this.props;
636
658
  const t = this.t.bind(this);
637
659
  const selection = this.selection();
638
660
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
639
661
  const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
640
- 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(
641
670
  Choices,
642
671
  {
643
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",
@@ -399,6 +403,28 @@ var sourceLabel = (entry, t) => {
399
403
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
400
404
  return entry.source.url;
401
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
+ };
402
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(
403
429
  "input",
404
430
  {
@@ -553,16 +579,12 @@ var ExtensionReview = class extends React2.PureComponent {
553
579
  /* @__PURE__ */ React2.createElement("p", { className: "twextsec-claim" }, t("creator"), ": ", metadata.author || t("creatorUnknown"), " \u2014 ", t("unverified")),
554
580
  state && /* @__PURE__ */ React2.createElement("p", { className: "twextsec-state" }, required ? t("state-dependency", { names: roots.join(", ") }) : t(`state-${state}`)),
555
581
  failure && /* @__PURE__ */ React2.createElement(
556
- "p",
582
+ Failure,
557
583
  {
558
- className: "twextsec-failed",
559
- role: "alert"
560
- },
561
- t("failed"),
562
- ": ",
563
- failure.code,
564
- " ",
565
- failure.message
584
+ failure,
585
+ onRetry: this.props.onRetry,
586
+ t
587
+ }
566
588
  ),
567
589
  isTrusted(entry) ? /* @__PURE__ */ React2.createElement("p", { className: "twextsec-trusted" }, t("trusted")) : /* @__PURE__ */ React2.createElement(
568
590
  Choices,
@@ -599,12 +621,19 @@ var ExtensionReview = class extends React2.PureComponent {
599
621
  );
600
622
  }
601
623
  render() {
602
- const { mode, entries, DialogFrame } = this.props;
624
+ const { mode, entries, DialogFrame, failure, onRetry } = this.props;
603
625
  const t = this.t.bind(this);
604
626
  const selection = this.selection();
605
627
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
606
628
  const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
607
- 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(
608
637
  Choices,
609
638
  {
610
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.1",
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; }