@kubohiroya/turbowarp-extension-security-dialog 0.3.3 → 0.4.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/NOTICE.md CHANGED
@@ -27,7 +27,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27
27
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  ```
29
29
 
30
- ## Public Editor screenshots
30
+ ## Editor screenshots captured before the TurboWarp-Plus-Editor migration
31
31
 
32
32
  `assets/screenshots/required-modes-{en,ja}-20261025.png` are unmodified browser captures of the public Editor on 25 October 2026, showing Camera Source 0.19.3, Asset Cache 0.3.1 and Bubble 0.13.4. Their origin, Editor revisions and hashes are recorded in `assets/screenshots/capture-20261025.json`. The captured UI, icons and banners retain their respective rights holders and applicable licenses; this package does not relicense those elements.
33
33
 
package/README.ja.md CHANGED
@@ -35,6 +35,31 @@ const list = <ExtensionSelectionList entries={entries} locale="ja"
35
35
  `busy` で選択・フッター操作を無効にします。取得失敗・再試行・カタログの取得中止・VMエラーの表示と、
36
36
  読み込み成功に応じた `loadedIds` 更新はホスト側の担当です。
37
37
 
38
+ ### 配布方法と現在の実行状態を編集する
39
+
40
+ [Editor #11](https://github.com/kubohiroya/turbowarp-plus-editor/issues/11) のホストは、起動時フラグが有効な場合だけ `enableDistribution={true}` を渡します。このpropは既定 `false` で、従来の一覧とcallbackを維持します。
41
+
42
+ ```jsx
43
+ <ExtensionSelectionList entries={entries} loadedIds={loadedExtensionIds}
44
+ enableDistribution={true}
45
+ initialChoices={new Map([[loadedURL, 'sandboxed']])}
46
+ initialDistributions={{loadedExtensionId: 'embedded'}}
47
+ onCancel={closeLibrary}
48
+ onComplete={(newEntries, settings) => host.applySettings(settings)} />
49
+ ```
50
+
51
+ 有効時は実行方法のラジオボタンと、独立したEmbedded/Remoteのラジオボタンを各行へ表示します。配布方法が未指定の行はRemoteです。上部の一括操作は検索で隠れた行を含む全パッケージへ適用し、その後各行で上書きできます。配布方法の変更は実行許可を変えず、実行方法の変更も配布方法を変えません。必要なunsandboxed宣言による既存の制約は維持します。
52
+
53
+ `initialChoices` と `initialDistributions` はMapまたはID/URLをキーとするrecordで、読込済みの実際の状態をホストが渡します。catalogのID指定をURL指定より優先します。`loadedIds` のチェックボックスはchecked・disabledのままですが、その行の実行方法と配布方法は編集できます。新しいoptional/unknownの行には実行許可を推測せず、選択・読込済みの全行で有効な実行方法を選ぶまで適用ボタンを無効にします。
54
+
55
+ `onComplete` の第1引数は従来どおり、新規に選んだ拡張の依存順配列です。第2引数の `settings` は次の情報を返します。
56
+
57
+ - `entries`: 新規選択・依存先・読込済みを含む全対象行。
58
+ - `distributions`: catalog IDをキーとする `Map<string, 'embedded' | 'remote'>`。
59
+ - `choices`: URLをキーとする `Map<string, 'deny' | 'sandboxed' | 'unsandboxed'>`。
60
+
61
+ 読込済みだけの設定変更でも適用できます。`ExtensionSecurityDialog` も同じ配布propsと第2引数を受け付けます。UIはJSを実行せず、SHA-256計算・SB3編集・権限判断・VMへの反映はホストのLoaderに委ねます。保存に失敗した場合の表示・元作品の復旧・実際の状態の再取得もホストが担当します。
62
+
38
63
  各行は「手動で選択」(青)・「依存関係で自動選択」(紫)・「未選択」(中立色)を、背景・左枠・
39
64
  アイコン・状態名で区別します。「読み込み済み」も独立した表示です。一覧の上部には凡例を表示します。
40
65
  自動選択した行には「Bubble、Sprite に必要」のように、必要としている明示選択元すべてを表示します。
@@ -98,11 +123,14 @@ JSON契約は `schemaVersion: 1` と `extensions` 配列です。各要素の必
98
123
  切り戻しはホストの起動時固定・既定OFFのフラグをOFFにして再読み込みするか、カタログ接続差分をrevertします。
99
124
  既存の3つの実行モードを持つセキュリティ確認は、そのまま利用できます。
100
125
 
101
- ## 公開Editorのスクリーンショット
126
+ ## TurboWarp-Plus-Editorとスクリーンショット
102
127
 
103
128
  [英語版](./README.md)と日本語版は、同じダイアログの表示言語を切り替え、ラベルと拡張の説明文を各言語で表示しています。
104
- 全件必須時の自動選択と一括選択欄の非表示に対応した[公開Editor](https://kubohiroya.github.io/turbowarp-extension-data-editor/editor.html?lang=ja)で、
105
- 2026年10月28日にCamera Source 0.19.4・Asset Cache 0.3.2・Bubble 0.13.5を開いた実画面です。
129
+ <p><a class="twpe-edit-button" href="https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=ja"><img src="https://kubohiroya.github.io/turbowarp-plus-editor/assets/icon.svg" width="32" height="32" alt=""> TurboWarp-Plus-Editorで編集</a></p>
130
+
131
+ 統合Editorのビルド・検証・配信は、下流の [TurboWarp-Plus-Editor](https://github.com/kubohiroya/turbowarp-plus-editor) が所有します。ボタンのHTMLとスタイルも同リポジトリのREADMEで説明しています。
132
+
133
+ 以下は移行前のEditorで2026年10月28日にCamera Source 0.19.4・Asset Cache 0.3.2・Bubble 0.13.5を開いた実画面です。全件必須時の自動選択と一括選択欄の非表示を確認した当時の記録であり、現在のUIの撮り直しではありません。
106
134
 
107
135
  ![Camera Source・Asset Cache・Bubbleの説明が日本語で表示された修正後の確認画面。拒否とサンドボックスありは無効、サンドボックスなしを選択済みで動作に必要と表示。一括選択欄は非表示。OKで読み込むかキャンセルで中止できる](https://raw.githubusercontent.com/kubohiroya/turbowarp-extension-security-dialog/main/assets/screenshots/hidden-bulk-required-ja-20261028.png)
108
136
 
@@ -283,10 +311,14 @@ coreとVMアダプターの利用にReact/React DOMは必要ありません。
283
311
 
284
312
  同梱メンバーのnoticeにある説明は親バンドルへ混ぜません。HTMLに見える説明も文字列として表示します。独自の`loadInfo`を使う場合は、任意の`ExtensionMetadata.descriptions`へ小文字の言語タグをキーとした説明を渡せます。`getExtensionDescription(metadata, locale)`でも同じ選択処理を利用できます。
285
313
 
286
- 上の画像は、日本語説明へ対応した公開Editorと公開済みの3拡張を使用しています。英語版では各拡張の従来の`Description`、日本語版では`Description[ja]`を表示します。対応する翻訳がない拡張は元の説明を表示します。説明の言語が変わっても、必要な実行モードや許可の選択は変わりません。パッケージを更新しても、既存SB3に埋め込まれたコードは自動で差し替わりません。
314
+ 上の画像は、日本語説明へ対応した移行前のEditorと公開済みの3拡張を使用した記録です。英語版では各拡張の従来の`Description`、日本語版では`Description[ja]`を表示します。対応する翻訳がない拡張は元の説明を表示します。説明の言語が変わっても、必要な実行モードや許可の選択は変わりません。パッケージを更新しても、既存SB3に埋め込まれたコードは自動で差し替わりません。
287
315
 
288
316
  ## 実行モードの選択
289
317
 
318
+ `ExtensionSelectionList` の追加一覧ではチェックボックスで追加対象を決め、実行方法は「サンドボックスあり/なし」の2択です。一覧に「拒否」は表示せず、未選択行の実行方法と配布方式は個別編集できません。一括設定は未選択行にも次回選択時の設定として反映できます。依存先は自動選択と理由表示を行い、必要としている拡張を外すことで選択を解除します。既存の`deny`初期値は一覧の実行方法として復元せず、有効な方法を選ぶまで適用できません。
319
+
320
+ 以下の3択は作品を開く際の `ExtensionSecurityDialog` に適用します。追加一覧のチェック解除は、恒久的な拒否や実行済みコードの停止を意味しません。
321
+
290
322
  個別選択・一括選択・一覧の見出しは、禁止アイコンの「拒否」、盾の「サンドボックスあり」、
291
323
  警告の「サンドボックスなし」の順です。アイコンと色は文字ラベルを補助し、安全性の認定には使いません。
292
324
 
package/README.md CHANGED
@@ -7,12 +7,14 @@ in **one single list**, instead of one prompt per extension.
7
7
  Related tasks and acceptance criteria are tracked in
8
8
  [scratch-gui #33](https://github.com/kubohiroya/scratch-gui/issues/33).
9
9
 
10
- ## Screenshots from the public Editor
10
+ ## TurboWarp-Plus-Editor and screenshots
11
11
 
12
12
  [English](./README.md) and [Japanese](./README.ja.md) use the same dialog with localized labels and extension descriptions.
13
- This capture shows Camera Source 0.19.4, Asset Cache 0.3.2 and Bubble 0.13.5 in the
14
- [public Editor](https://kubohiroya.github.io/turbowarp-extension-data-editor/editor.html?lang=en)
15
- on 28 October 2026, with **Without sandbox** already selected for all three extensions and the unnecessary bulk selection section hidden.
13
+ <p><a class="twpe-edit-button" href="https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=en"><img src="https://kubohiroya.github.io/turbowarp-plus-editor/assets/icon.svg" width="32" height="32" alt=""> Edit in TurboWarp-Plus-Editor</a></p>
14
+
15
+ The downstream [TurboWarp-Plus-Editor](https://github.com/kubohiroya/turbowarp-plus-editor) owns integrated builds, validation and distribution. Its README also documents the reusable button HTML and stylesheet.
16
+
17
+ The following capture records the Editor before this migration, on 28 October 2026, with Camera Source 0.19.4, Asset Cache 0.3.2 and Bubble 0.13.5. **Without sandbox** is selected for all three extensions and the unnecessary bulk selection section is hidden. This is a historical capture, not a new image of the current UI.
16
18
 
17
19
  ![English descriptions for Camera Source, Asset Cache and Bubble: Deny and With sandbox are disabled for all three extensions; Without sandbox is preselected and marked Required to run. The bulk selection section is hidden. Choose OK to load the project or Cancel to stop.](https://raw.githubusercontent.com/kubohiroya/turbowarp-extension-security-dialog/main/assets/screenshots/hidden-bulk-required-en-20261028.png)
18
20
 
@@ -202,7 +204,7 @@ Only the enclosing header is used; bundled member notices cannot supply its tran
202
204
  HTML-looking text is rendered as text. The optional `ExtensionMetadata.descriptions` record uses
203
205
  lowercase keys, and `getExtensionDescription(metadata, locale)` exposes the same lookup.
204
206
 
205
- The public Editor and the three published bundles shown above support localized descriptions.
207
+ The pre-migration Editor capture and the three published bundles shown above demonstrate localized descriptions.
206
208
  The English capture uses each original `Description`; the Japanese capture uses `Description[ja]`.
207
209
  Extensions without a matching translation retain their original description. The selected language
208
210
  does not change required modes or permission choices. Updating a package does not replace code
package/dist/index.cjs CHANGED
@@ -344,6 +344,15 @@ var preferences_default = preferences;
344
344
  // src/messages.js
345
345
  var messages = {
346
346
  "en": {
347
+ "distribution": "Distribution",
348
+ "executionMode": "Execution mode",
349
+ "executionBulk": "Execution mode for all packages",
350
+ "distributionBulk": "Distribution for all packages",
351
+ "distribution-embedded": "Embedded (include in SB3)",
352
+ "distribution-remote": "Remote (reference URL)",
353
+ "distributionNote": "Distribution and execution permissions are separate. You can override each row after applying a bulk choice.",
354
+ "configuredSummary": "{count} extensions to configure",
355
+ "applySettings": "Apply extension settings",
347
356
  "securityInstruction": "To make extensions marked \u26A0\uFE0F work as their creators intended, choose Without sandbox.",
348
357
  "catalogCancelDestination": "Choose Cancel to return to the selection list.",
349
358
  "selectionIntro": "Choose extensions to add. Required extensions are selected automatically.",
@@ -414,6 +423,15 @@ var messages = {
414
423
  "warning": "Extensions without a sandbox can access your project and browser information."
415
424
  },
416
425
  "ja": {
426
+ "distribution": "\u914D\u5E03\u65B9\u6CD5",
427
+ "executionMode": "\u5B9F\u884C\u65B9\u6CD5",
428
+ "executionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u5B9F\u884C\u65B9\u6CD5",
429
+ "distributionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u914D\u5E03\u65B9\u6CD5",
430
+ "distribution-embedded": "Embedded\uFF08SB3\u306B\u540C\u68B1\uFF09",
431
+ "distribution-remote": "Remote\uFF08URL\u53C2\u7167\uFF09",
432
+ "distributionNote": "\u914D\u5E03\u65B9\u6CD5\u3068\u5B9F\u884C\u8A31\u53EF\u306F\u5225\u306E\u8A2D\u5B9A\u3067\u3059\u3002\u4E00\u62EC\u6307\u5B9A\u3057\u305F\u5F8C\u3001\u5404\u884C\u3067\u5909\u66F4\u3067\u304D\u307E\u3059\u3002",
433
+ "configuredSummary": "\u8A2D\u5B9A\u3059\u308B\u6A5F\u80FD\u62E1\u5F35 {count} \u4EF6",
434
+ "applySettings": "\u62E1\u5F35\u306E\u8A2D\u5B9A\u3092\u9069\u7528",
417
435
  "securityInstruction": "\u300C\u26A0\uFE0F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\uFF1A\u5FC5\u8981\u300D\u304C\u8868\u793A\u3055\u308C\u3066\u3044\u308B\u62E1\u5F35\u3092\u5236\u4F5C\u8005\u306E\u610F\u56F3\u3069\u304A\u308A\u306B\u52D5\u4F5C\u3055\u305B\u308B\u305F\u3081\u306B\u306F\u300E\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u300F\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
418
436
  "catalogCancelDestination": "\u300E\u30AD\u30E3\u30F3\u30BB\u30EB\u300F\u3067\u9078\u629E\u4E00\u89A7\u306B\u623B\u308A\u307E\u3059\u3002",
419
437
  "selectionIntro": "\u8FFD\u52A0\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002\u4F9D\u5B58\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3082\u81EA\u52D5\u3067\u9078\u629E\u3055\u308C\u307E\u3059\u3002",
package/dist/index.mjs CHANGED
@@ -295,6 +295,15 @@ var preferences_default = preferences;
295
295
  // src/messages.js
296
296
  var messages = {
297
297
  "en": {
298
+ "distribution": "Distribution",
299
+ "executionMode": "Execution mode",
300
+ "executionBulk": "Execution mode for all packages",
301
+ "distributionBulk": "Distribution for all packages",
302
+ "distribution-embedded": "Embedded (include in SB3)",
303
+ "distribution-remote": "Remote (reference URL)",
304
+ "distributionNote": "Distribution and execution permissions are separate. You can override each row after applying a bulk choice.",
305
+ "configuredSummary": "{count} extensions to configure",
306
+ "applySettings": "Apply extension settings",
298
307
  "securityInstruction": "To make extensions marked \u26A0\uFE0F work as their creators intended, choose Without sandbox.",
299
308
  "catalogCancelDestination": "Choose Cancel to return to the selection list.",
300
309
  "selectionIntro": "Choose extensions to add. Required extensions are selected automatically.",
@@ -365,6 +374,15 @@ var messages = {
365
374
  "warning": "Extensions without a sandbox can access your project and browser information."
366
375
  },
367
376
  "ja": {
377
+ "distribution": "\u914D\u5E03\u65B9\u6CD5",
378
+ "executionMode": "\u5B9F\u884C\u65B9\u6CD5",
379
+ "executionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u5B9F\u884C\u65B9\u6CD5",
380
+ "distributionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u914D\u5E03\u65B9\u6CD5",
381
+ "distribution-embedded": "Embedded\uFF08SB3\u306B\u540C\u68B1\uFF09",
382
+ "distribution-remote": "Remote\uFF08URL\u53C2\u7167\uFF09",
383
+ "distributionNote": "\u914D\u5E03\u65B9\u6CD5\u3068\u5B9F\u884C\u8A31\u53EF\u306F\u5225\u306E\u8A2D\u5B9A\u3067\u3059\u3002\u4E00\u62EC\u6307\u5B9A\u3057\u305F\u5F8C\u3001\u5404\u884C\u3067\u5909\u66F4\u3067\u304D\u307E\u3059\u3002",
384
+ "configuredSummary": "\u8A2D\u5B9A\u3059\u308B\u6A5F\u80FD\u62E1\u5F35 {count} \u4EF6",
385
+ "applySettings": "\u62E1\u5F35\u306E\u8A2D\u5B9A\u3092\u9069\u7528",
368
386
  "securityInstruction": "\u300C\u26A0\uFE0F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\uFF1A\u5FC5\u8981\u300D\u304C\u8868\u793A\u3055\u308C\u3066\u3044\u308B\u62E1\u5F35\u3092\u5236\u4F5C\u8005\u306E\u610F\u56F3\u3069\u304A\u308A\u306B\u52D5\u4F5C\u3055\u305B\u308B\u305F\u3081\u306B\u306F\u300E\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u300F\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
369
387
  "catalogCancelDestination": "\u300E\u30AD\u30E3\u30F3\u30BB\u30EB\u300F\u3067\u9078\u629E\u4E00\u89A7\u306B\u623B\u308A\u307E\u3059\u3002",
370
388
  "selectionIntro": "\u8FFD\u52A0\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002\u4F9D\u5B58\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3082\u81EA\u52D5\u3067\u9078\u629E\u3055\u308C\u307E\u3059\u3002",
package/dist/react.cjs CHANGED
@@ -231,6 +231,9 @@ var style_names_default = {
231
231
  "footer": "twextsec-footer",
232
232
  "securityFooter": "twextsec-security-footer",
233
233
  "securityModes": "twextsec-security-modes",
234
+ "rowControls": "twextsec-row-controls",
235
+ "distributionModes": "twextsec-distribution-modes",
236
+ "inlineModeLabel": "twextsec-inline-mode-label",
234
237
  "footerControls": "twextsec-footer-controls",
235
238
  "previewColumn": "twextsec-preview-column",
236
239
  "packageHeading": "twextsec-package-heading",
@@ -406,6 +409,15 @@ var banner_preview_default = BannerPreview;
406
409
  // src/messages.js
407
410
  var messages = {
408
411
  "en": {
412
+ "distribution": "Distribution",
413
+ "executionMode": "Execution mode",
414
+ "executionBulk": "Execution mode for all packages",
415
+ "distributionBulk": "Distribution for all packages",
416
+ "distribution-embedded": "Embedded (include in SB3)",
417
+ "distribution-remote": "Remote (reference URL)",
418
+ "distributionNote": "Distribution and execution permissions are separate. You can override each row after applying a bulk choice.",
419
+ "configuredSummary": "{count} extensions to configure",
420
+ "applySettings": "Apply extension settings",
409
421
  "securityInstruction": "To make extensions marked \u26A0\uFE0F work as their creators intended, choose Without sandbox.",
410
422
  "catalogCancelDestination": "Choose Cancel to return to the selection list.",
411
423
  "selectionIntro": "Choose extensions to add. Required extensions are selected automatically.",
@@ -476,6 +488,15 @@ var messages = {
476
488
  "warning": "Extensions without a sandbox can access your project and browser information."
477
489
  },
478
490
  "ja": {
491
+ "distribution": "\u914D\u5E03\u65B9\u6CD5",
492
+ "executionMode": "\u5B9F\u884C\u65B9\u6CD5",
493
+ "executionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u5B9F\u884C\u65B9\u6CD5",
494
+ "distributionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u914D\u5E03\u65B9\u6CD5",
495
+ "distribution-embedded": "Embedded\uFF08SB3\u306B\u540C\u68B1\uFF09",
496
+ "distribution-remote": "Remote\uFF08URL\u53C2\u7167\uFF09",
497
+ "distributionNote": "\u914D\u5E03\u65B9\u6CD5\u3068\u5B9F\u884C\u8A31\u53EF\u306F\u5225\u306E\u8A2D\u5B9A\u3067\u3059\u3002\u4E00\u62EC\u6307\u5B9A\u3057\u305F\u5F8C\u3001\u5404\u884C\u3067\u5909\u66F4\u3067\u304D\u307E\u3059\u3002",
498
+ "configuredSummary": "\u8A2D\u5B9A\u3059\u308B\u6A5F\u80FD\u62E1\u5F35 {count} \u4EF6",
499
+ "applySettings": "\u62E1\u5F35\u306E\u8A2D\u5B9A\u3092\u9069\u7528",
479
500
  "securityInstruction": "\u300C\u26A0\uFE0F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\uFF1A\u5FC5\u8981\u300D\u304C\u8868\u793A\u3055\u308C\u3066\u3044\u308B\u62E1\u5F35\u3092\u5236\u4F5C\u8005\u306E\u610F\u56F3\u3069\u304A\u308A\u306B\u52D5\u4F5C\u3055\u305B\u308B\u305F\u3081\u306B\u306F\u300E\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u300F\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
480
501
  "catalogCancelDestination": "\u300E\u30AD\u30E3\u30F3\u30BB\u30EB\u300F\u3067\u9078\u629E\u4E00\u89A7\u306B\u623B\u308A\u307E\u3059\u3002",
481
502
  "selectionIntro": "\u8FFD\u52A0\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002\u4F9D\u5B58\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3082\u81EA\u52D5\u3067\u9078\u629E\u3055\u308C\u307E\u3059\u3002",
@@ -740,6 +761,16 @@ var bindAll = (instance, names) => names.forEach((name) => {
740
761
  instance[name] = instance[name].bind(instance);
741
762
  });
742
763
  var MODES = ["deny", "sandboxed", "unsandboxed"];
764
+ var EXECUTION_MODES = ["sandboxed", "unsandboxed"];
765
+ var DISTRIBUTIONS = ["embedded", "remote"];
766
+ var entryIds = (entry) => entry.id ? [entry.id] : entry.ids || [];
767
+ var initialValue = (values, entry) => {
768
+ for (const key of [...entry.id ? [entry.id] : [], entry.url, ...entry.ids || []]) {
769
+ const value = values instanceof Map ? values.get(key) : values && Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
770
+ if (value !== void 0) return value;
771
+ }
772
+ return void 0;
773
+ };
743
774
  var isModeAllowed = (mode, metadata) => MODES.includes(mode) && (!requiresUnsandboxed(metadata) || mode === "unsandboxed");
744
775
  var allRequireUnsandboxed = (entries, rows) => entries.length > 0 && entries.every((entry) => {
745
776
  const row = rows[entry.url];
@@ -784,11 +815,14 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
784
815
  constructor(props) {
785
816
  super(props);
786
817
  const choices = {};
818
+ const distributions = {};
787
819
  for (const entry of props.entries) {
788
- const mode = props.initialChoices.get(entry.url);
820
+ const mode = initialValue(props.initialChoices, entry);
789
821
  if (isModeAllowed(mode, resolveSharedPackageMetadata(entry))) choices[entry.url] = mode;
822
+ const distribution = initialValue(props.initialDistributions, entry);
823
+ distributions[entry.url] = DISTRIBUTIONS.includes(distribution) ? distribution : "remote";
790
824
  }
791
- this.state = { choices, rows: {}, confirmation: null, ready: false };
825
+ this.state = { choices, distributions, rows: {}, confirmation: null, ready: false };
792
826
  this.requests = /* @__PURE__ */ new Map();
793
827
  this.controllers = /* @__PURE__ */ new Set();
794
828
  this.timeouts = /* @__PURE__ */ new Set();
@@ -802,7 +836,9 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
802
836
  "handleNo",
803
837
  "handleYes",
804
838
  "handleRequestClose",
805
- "focusNo"
839
+ "focusNo",
840
+ "handleDistribution",
841
+ "handleBulkDistribution"
806
842
  ]);
807
843
  }
808
844
  componentDidMount() {
@@ -810,7 +846,8 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
810
846
  this.delay(() => this.setState({ ready: true }));
811
847
  this.startRequests();
812
848
  }
813
- componentDidUpdate() {
849
+ componentDidUpdate(previousProps) {
850
+ this.initializeEntries(previousProps);
814
851
  this.startRequests();
815
852
  const { entries } = this.props;
816
853
  if (allRequireUnsandboxed(entries, this.state.rows) && entries.some((entry) => this.state.choices[entry.url] !== "unsandboxed")) {
@@ -874,10 +911,36 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
874
911
  t(key, values) {
875
912
  return formatMessage(this.props.locale, key, values);
876
913
  }
914
+ initializeEntries(previousProps) {
915
+ if (previousProps.entries === this.props.entries) return;
916
+ const previousURLs = new Set(previousProps.entries.map((entry) => entry.url));
917
+ const added = this.props.entries.filter((entry) => !previousURLs.has(entry.url));
918
+ if (!added.length) return;
919
+ this.setState((previous) => {
920
+ const choices = __spreadValues({}, previous.choices);
921
+ const distributions = __spreadValues({}, previous.distributions);
922
+ for (const entry of added) {
923
+ const restored = initialValue(this.props.initialChoices, entry);
924
+ const actualLoadedMode = this.props.enableDistribution && this instanceof ExtensionSelectionList && this.props.loadedIds.includes(entry.id) && this.executionModes().includes(restored);
925
+ if (actualLoadedMode || this.canChoose(entry, restored, previous)) choices[entry.url] = restored;
926
+ else if (this.props.enableDistribution && this instanceof ExtensionSelectionList && requiresUnsandboxed(resolveSharedPackageMetadata(entry))) choices[entry.url] = "unsandboxed";
927
+ const distribution = initialValue(this.props.initialDistributions, entry);
928
+ distributions[entry.url] = DISTRIBUTIONS.includes(distribution) ? distribution : "remote";
929
+ }
930
+ return { choices, distributions };
931
+ });
932
+ }
877
933
  entryForEvent(event) {
878
934
  return this.props.entries[Number(event.currentTarget.dataset.index)];
879
935
  }
936
+ executionModes() {
937
+ return MODES;
938
+ }
939
+ canConfigureEntry() {
940
+ return true;
941
+ }
880
942
  canChoose(entry, mode, state = this.state) {
943
+ if (this.props.enableDistribution && mode === "deny" && (this.props.loadedIds || []).includes(entry.id)) return false;
881
944
  return isModeAllowed(mode, resolveSharedPackageMetadata(entry, (state.rows[entry.url] || {}).metadata));
882
945
  }
883
946
  selectionReady() {
@@ -888,20 +951,62 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
888
951
  });
889
952
  }
890
953
  handleChoice(event) {
954
+ if (this.props.busy) return;
891
955
  const entry = this.entryForEvent(event);
892
956
  const mode = event.currentTarget.value;
893
- if (!entry) return;
957
+ if (!entry || !this.canConfigureEntry(entry)) return;
894
958
  this.setState((previous) => this.canChoose(entry, mode, previous) ? { choices: __spreadProps(__spreadValues({}, previous.choices), { [entry.url]: mode }) } : null);
895
959
  }
896
960
  handleBulk(event) {
961
+ if (this.props.busy) return;
897
962
  const mode = event.currentTarget.value;
898
- if (!MODES.includes(mode)) return;
963
+ if (!this.executionModes().includes(mode)) return;
899
964
  this.setState((previous) => ({ choices: Object.assign(
900
965
  {},
901
966
  previous.choices,
902
967
  Object.fromEntries(this.props.entries.filter((entry) => this.canChoose(entry, mode, previous)).map((entry) => [entry.url, mode]))
903
968
  ) }));
904
969
  }
970
+ handleDistribution(event) {
971
+ if (this.props.busy) return;
972
+ const entry = this.entryForEvent(event);
973
+ const distribution = event.currentTarget.value;
974
+ if (entry && this.canConfigureEntry(entry) && DISTRIBUTIONS.includes(distribution)) {
975
+ this.setState((previous) => ({ distributions: __spreadProps(__spreadValues({}, previous.distributions), { [entry.url]: distribution }) }));
976
+ }
977
+ }
978
+ handleBulkDistribution(event) {
979
+ if (this.props.busy) return;
980
+ const distribution = event.currentTarget.value;
981
+ if (!DISTRIBUTIONS.includes(distribution)) return;
982
+ this.setState((previous) => ({ distributions: Object.assign(
983
+ {},
984
+ previous.distributions,
985
+ Object.fromEntries(this.props.entries.map((entry) => [entry.url, distribution]))
986
+ ) }));
987
+ }
988
+ settings(entries = this.props.entries) {
989
+ const distributions = /* @__PURE__ */ new Map();
990
+ for (const entry of entries) {
991
+ for (const id of entryIds(entry)) distributions.set(id, this.state.distributions[entry.url] || "remote");
992
+ }
993
+ return { entries, distributions, choices: new Map(entries.filter((entry) => this.executionModes().includes(this.state.choices[entry.url])).map((entry) => [entry.url, this.state.choices[entry.url]])) };
994
+ }
995
+ renderDistributionBulk() {
996
+ if (!this.props.enableDistribution) return null;
997
+ return /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulk, "data-testid": "extension-distribution-bulk" }, /* @__PURE__ */ import_react4.default.createElement("span", null, this.t("distributionBulk")), DISTRIBUTIONS.map((distribution) => /* @__PURE__ */ import_react4.default.createElement(
998
+ "button",
999
+ {
1000
+ type: "button",
1001
+ key: distribution,
1002
+ value: distribution,
1003
+ "data-distribution": distribution,
1004
+ disabled: this.props.busy,
1005
+ onClick: this.handleBulkDistribution
1006
+ },
1007
+ this.t(`distribution-${distribution}`)
1008
+ )), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulkNote }, this.t("distributionNote")));
1009
+ }
905
1010
  handleImageError(event) {
906
1011
  const entry = this.entryForEvent(event);
907
1012
  const failedURL = event.currentTarget.getAttribute("src");
@@ -942,12 +1047,15 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
942
1047
  this.setState({ confirmation: null });
943
1048
  return;
944
1049
  }
945
- this.props.onComplete(new Map(this.props.entries.map((entry) => [entry.url, this.state.choices[entry.url]])));
1050
+ const decisions = new Map(this.props.entries.map((entry) => [entry.url, this.state.choices[entry.url]]));
1051
+ if (this.props.enableDistribution) this.props.onComplete(decisions, this.settings());
1052
+ else this.props.onComplete(decisions);
946
1053
  }
947
1054
  focusNo(element) {
948
1055
  if (element) element.focus();
949
1056
  }
950
1057
  renderRow(entry, index, selection) {
1058
+ const controlsDisabled = this.props.busy || Boolean(selection && !selection.checked);
951
1059
  const row = selection ? __spreadProps(__spreadValues({}, this.state.rows[entry.url]), { metadata: entry.metadata, status: "ready" }) : this.state.rows[entry.url] || {};
952
1060
  const metadata = row.metadata || {};
953
1061
  const sharedMetadata = resolveSharedPackageMetadata(entry, row.metadata);
@@ -980,6 +1088,8 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
980
1088
  {
981
1089
  className: style_names_default.row,
982
1090
  key: entry.url,
1091
+ "data-extension-id": entryIds(entry).join(","),
1092
+ "data-distribution": this.props.enableDistribution ? this.state.distributions[entry.url] || "remote" : void 0,
983
1093
  "data-selection-state": selection ? selection.state : void 0
984
1094
  },
985
1095
  /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.rowMain }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.packageColumn }, /* @__PURE__ */ import_react4.default.createElement(
@@ -1009,33 +1119,62 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
1009
1119
  },
1010
1120
  selection.dependencyReason
1011
1121
  ))
1012
- ), !selection && row.invalidated && !this.state.choices[entry.url] && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.packageNotices }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.warningText, role: "status" }, this.t("choiceReset")))), !selection && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.securityModes }, /* @__PURE__ */ import_react4.default.createElement(PackageRequirement, { metadata: sharedMetadata, locale: this.props.locale, id: reasonId }), MODES.map((mode) => /* @__PURE__ */ import_react4.default.createElement(
1013
- "label",
1122
+ ), !selection && row.invalidated && !this.state.choices[entry.url] && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.packageNotices }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.warningText, role: "status" }, this.t("choiceReset")))), (!selection || this.props.enableDistribution) && /* @__PURE__ */ import_react4.default.createElement(
1123
+ "div",
1014
1124
  {
1015
- className: style_names_default.choice,
1016
- key: mode,
1017
- "data-mode": mode,
1018
- "aria-disabled": !this.canChoose(entry, mode),
1019
- title: !this.canChoose(entry, mode) ? this.t("requiredToRun") : void 0
1125
+ className: style_names_default.rowControls,
1126
+ "aria-disabled": controlsDisabled
1020
1127
  },
1021
- /* @__PURE__ */ import_react4.default.createElement("span", { className: style_names_default.choiceControl }, /* @__PURE__ */ import_react4.default.createElement(
1022
- "input",
1128
+ /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.securityModes, role: "group", "aria-label": this.t("executionMode") }, !selection && /* @__PURE__ */ import_react4.default.createElement(PackageRequirement, { metadata: sharedMetadata, locale: this.props.locale, id: reasonId }), this.executionModes().map((mode) => /* @__PURE__ */ import_react4.default.createElement(
1129
+ "label",
1023
1130
  {
1024
- type: "radio",
1025
- name: `extension-security-${index}`,
1026
- value: mode,
1027
- checked: this.state.choices[entry.url] === mode,
1028
- "aria-label": `${name}: ${this.t(mode)}`,
1029
- "aria-describedby": !this.canChoose(entry, mode) ? reasonId : required && mode === "unsandboxed" ? requiredId : void 0,
1030
- disabled: !this.canChoose(entry, mode),
1031
- "data-index": index,
1032
- onChange: this.handleChoice
1033
- }
1034
- ), /* @__PURE__ */ import_react4.default.createElement(ModeIcon, { mode })),
1035
- /* @__PURE__ */ import_react4.default.createElement("span", { className: style_names_default.mobileLabel }, this.t(mode)),
1036
- !this.canChoose(entry, mode) && /* @__PURE__ */ import_react4.default.createElement("span", { className: style_names_default.modeNote }, this.t("unsupported")),
1037
- required && mode === "unsandboxed" && /* @__PURE__ */ import_react4.default.createElement("span", { id: requiredId, className: style_names_default.requiredMode }, this.t("requiredToRun"))
1038
- ))), selection && /* @__PURE__ */ import_react4.default.createElement("label", { className: style_names_default.choice, "aria-disabled": selection.disabled }, /* @__PURE__ */ import_react4.default.createElement(
1131
+ className: style_names_default.choice,
1132
+ key: mode,
1133
+ "data-mode": mode,
1134
+ "aria-disabled": controlsDisabled || !this.canChoose(entry, mode),
1135
+ title: !this.canChoose(entry, mode) ? this.t("requiredToRun") : void 0
1136
+ },
1137
+ /* @__PURE__ */ import_react4.default.createElement("span", { className: style_names_default.choiceControl }, /* @__PURE__ */ import_react4.default.createElement(
1138
+ "input",
1139
+ {
1140
+ type: "radio",
1141
+ name: `${selection ? "selection-" : ""}extension-security-${index}`,
1142
+ value: mode,
1143
+ checked: this.state.choices[entry.url] === mode,
1144
+ "aria-label": `${name}: ${this.t(mode)}`,
1145
+ "aria-describedby": !this.canChoose(entry, mode) ? reasonId : required && mode === "unsandboxed" ? requiredId : void 0,
1146
+ disabled: controlsDisabled || !this.canChoose(entry, mode),
1147
+ "data-index": index,
1148
+ onChange: this.handleChoice
1149
+ }
1150
+ ), /* @__PURE__ */ import_react4.default.createElement(ModeIcon, { mode })),
1151
+ /* @__PURE__ */ import_react4.default.createElement("span", { className: this.props.enableDistribution ? style_names_default.inlineModeLabel : style_names_default.mobileLabel }, this.t(mode)),
1152
+ !this.canChoose(entry, mode) && /* @__PURE__ */ import_react4.default.createElement("span", { className: style_names_default.modeNote }, this.t("unsupported")),
1153
+ required && mode === "unsandboxed" && /* @__PURE__ */ import_react4.default.createElement("span", { id: requiredId, className: style_names_default.requiredMode }, this.t("requiredToRun"))
1154
+ ))),
1155
+ this.props.enableDistribution && /* @__PURE__ */ import_react4.default.createElement(
1156
+ "fieldset",
1157
+ {
1158
+ className: style_names_default.distributionModes,
1159
+ disabled: controlsDisabled
1160
+ },
1161
+ /* @__PURE__ */ import_react4.default.createElement("legend", null, this.t("distribution")),
1162
+ DISTRIBUTIONS.map((distribution) => /* @__PURE__ */ import_react4.default.createElement("label", { key: distribution, className: style_names_default.choice }, /* @__PURE__ */ import_react4.default.createElement(
1163
+ "input",
1164
+ {
1165
+ type: "radio",
1166
+ name: `${idPrefix}-distribution-${index}`,
1167
+ value: distribution,
1168
+ "data-index": index,
1169
+ "data-distribution": distribution,
1170
+ checked: (this.state.distributions[entry.url] || "remote") === distribution,
1171
+ disabled: controlsDisabled,
1172
+ "aria-label": `${name}: ${this.t(`distribution-${distribution}`)}`,
1173
+ onChange: this.handleDistribution
1174
+ }
1175
+ ), /* @__PURE__ */ import_react4.default.createElement("span", null, this.t(`distribution-${distribution}`))))
1176
+ )
1177
+ ), selection && /* @__PURE__ */ import_react4.default.createElement("label", { className: style_names_default.choice, "aria-disabled": selection.disabled }, /* @__PURE__ */ import_react4.default.createElement(
1039
1178
  "input",
1040
1179
  {
1041
1180
  type: "checkbox",
@@ -1096,14 +1235,14 @@ var ExtensionSecurityDialog = class extends import_react4.default.Component {
1096
1235
  },
1097
1236
  this.t("yes")
1098
1237
  ))
1099
- ) : /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.body }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ import_react4.default.createElement("p", null, this.t("securityInstruction")), /* @__PURE__ */ import_react4.default.createElement(
1238
+ ) : /* @__PURE__ */ import_react4.default.createElement("div", { className: `${style_names_default.body}${this.props.enableDistribution ? " twextsec-with-distribution" : ""}` }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ import_react4.default.createElement("p", null, this.t("securityInstruction")), /* @__PURE__ */ import_react4.default.createElement(
1100
1239
  "div",
1101
1240
  {
1102
1241
  className: style_names_default.secondary,
1103
1242
  "aria-live": "polite"
1104
1243
  },
1105
1244
  this.t("progress", { done, total: entries.length })
1106
- )), !allRequired && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ import_react4.default.createElement("span", null, this.t("bulk")), MODES.map((mode) => /* @__PURE__ */ import_react4.default.createElement(
1245
+ )), this.renderDistributionBulk(), !allRequired && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ import_react4.default.createElement("span", null, this.t("bulk")), MODES.map((mode) => /* @__PURE__ */ import_react4.default.createElement(
1107
1246
  "button",
1108
1247
  {
1109
1248
  type: "button",
@@ -1163,6 +1302,8 @@ var DefaultFrame = ({ children, contentLabel, className }) => /* @__PURE__ */ im
1163
1302
  ExtensionSecurityDialog.defaultProps = {
1164
1303
  loadInfo: loadExtensionInfo,
1165
1304
  initialChoices: /* @__PURE__ */ new Map(),
1305
+ initialDistributions: /* @__PURE__ */ new Map(),
1306
+ enableDistribution: false,
1166
1307
  locale: "en",
1167
1308
  context: "project",
1168
1309
  DialogFrame: DefaultFrame
@@ -1172,11 +1313,22 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1172
1313
  constructor(props) {
1173
1314
  super(props);
1174
1315
  this.state.explicitIds = /* @__PURE__ */ new Set();
1316
+ if (props.enableDistribution) {
1317
+ for (const entry of props.entries) {
1318
+ if (!EXECUTION_MODES.includes(this.state.choices[entry.url])) delete this.state.choices[entry.url];
1319
+ const actual = initialValue(props.initialChoices, entry);
1320
+ if (props.loadedIds.includes(entry.id) && EXECUTION_MODES.includes(actual)) this.state.choices[entry.url] = actual;
1321
+ if (!this.state.choices[entry.url] && requiresUnsandboxed(resolveSharedPackageMetadata(entry))) {
1322
+ this.state.choices[entry.url] = "unsandboxed";
1323
+ }
1324
+ }
1325
+ }
1175
1326
  }
1176
1327
  componentDidMount() {
1177
1328
  this.alive = true;
1178
1329
  }
1179
- componentDidUpdate() {
1330
+ componentDidUpdate(previousProps) {
1331
+ this.initializeEntries(previousProps);
1180
1332
  const available = new Set(this.props.entries.map((entry) => entry.id));
1181
1333
  if ([...this.state.explicitIds].some((id) => !available.has(id))) {
1182
1334
  this.setState((previous) => ({ explicitIds: new Set([...previous.explicitIds].filter((id) => available.has(id))) }));
@@ -1184,6 +1336,16 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1184
1336
  }
1185
1337
  startRequests() {
1186
1338
  }
1339
+ executionModes() {
1340
+ return EXECUTION_MODES;
1341
+ }
1342
+ canChoose(entry, mode, state = this.state) {
1343
+ return EXECUTION_MODES.includes(mode) && super.canChoose(entry, mode, state);
1344
+ }
1345
+ canConfigureEntry(entry) {
1346
+ const selection = this.selection();
1347
+ return selection.selected.has(entry.id) || selection.loaded.has(entry.id);
1348
+ }
1187
1349
  selection() {
1188
1350
  return resolveExtensionSelection(this.props.entries, this.state.explicitIds, this.props.loadedIds);
1189
1351
  }
@@ -1198,6 +1360,16 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1198
1360
  return { explicitIds };
1199
1361
  });
1200
1362
  }
1363
+ completeSelection() {
1364
+ const selection = this.selection();
1365
+ if (!this.props.enableDistribution) {
1366
+ this.props.onComplete(selection.ordered);
1367
+ return;
1368
+ }
1369
+ const included = this.props.entries.filter((entry) => selection.selected.has(entry.id) || selection.loaded.has(entry.id));
1370
+ if (included.some((entry) => !this.canChoose(entry, this.state.choices[entry.url]))) return;
1371
+ this.props.onComplete(selection.ordered, this.settings(included));
1372
+ }
1201
1373
  render() {
1202
1374
  const selection = this.selection();
1203
1375
  const query = (this.props.filterQuery || "").trim().toLowerCase();
@@ -1215,7 +1387,22 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1215
1387
  dependencyReason: !loaded && rootNames.length ? this.t("requiredBy", { names: rootNames.join(separator) }) : null
1216
1388
  });
1217
1389
  };
1218
- return /* @__PURE__ */ import_react4.default.createElement("div", { className: `${style_names_default.body} twextsec-selection`, "aria-busy": this.props.busy }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ import_react4.default.createElement("p", null, this.t("selectionIntro")), /* @__PURE__ */ import_react4.default.createElement("ul", { className: style_names_default.selectionLegend, "aria-label": this.t("selectionLegend") }, ["selected", "dependency", "unselected", "loaded"].map((state) => /* @__PURE__ */ import_react4.default.createElement("li", { key: state, "data-selection-state": state }, /* @__PURE__ */ import_react4.default.createElement(SelectionIcon, { state }), this.t(`${state}State`))))), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.list }, /* @__PURE__ */ import_react4.default.createElement(
1390
+ const configured = this.props.entries.filter((entry) => selection.selected.has(entry.id) || selection.loaded.has(entry.id));
1391
+ const configuredCount = configured.length;
1392
+ const choicesReady = configured.every((entry) => this.canChoose(entry, this.state.choices[entry.url]));
1393
+ return /* @__PURE__ */ import_react4.default.createElement("div", { className: `${style_names_default.body} twextsec-selection${this.props.enableDistribution ? " twextsec-with-distribution" : ""}`, "aria-busy": this.props.busy }, /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ import_react4.default.createElement("p", null, this.t("selectionIntro")), /* @__PURE__ */ import_react4.default.createElement("ul", { className: style_names_default.selectionLegend, "aria-label": this.t("selectionLegend") }, ["selected", "dependency", "unselected", "loaded"].map((state) => /* @__PURE__ */ import_react4.default.createElement("li", { key: state, "data-selection-state": state }, /* @__PURE__ */ import_react4.default.createElement(SelectionIcon, { state }), this.t(`${state}State`))))), this.props.enableDistribution && !this.props.entries.every((entry) => requiresUnsandboxed(resolveSharedPackageMetadata(entry))) && /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ import_react4.default.createElement("span", null, this.t("executionBulk")), this.executionModes().map((mode) => /* @__PURE__ */ import_react4.default.createElement(
1394
+ "button",
1395
+ {
1396
+ type: "button",
1397
+ key: mode,
1398
+ value: mode,
1399
+ "data-execution": mode,
1400
+ disabled: this.props.busy || this.props.entries.every((entry) => !this.canChoose(entry, mode)),
1401
+ onClick: this.handleBulk
1402
+ },
1403
+ /* @__PURE__ */ import_react4.default.createElement(ModeIcon, { mode }),
1404
+ this.t(mode)
1405
+ )), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.bulkNote }, this.t("bulkNote"))), this.renderDistributionBulk(), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.list }, /* @__PURE__ */ import_react4.default.createElement(
1219
1406
  package_sections_default,
1220
1407
  {
1221
1408
  entries: this.props.entries,
@@ -1224,15 +1411,18 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1224
1411
  idPrefix: "selection-extension",
1225
1412
  renderItem: renderSelectionRow
1226
1413
  }
1227
- ), !visible.length && /* @__PURE__ */ import_react4.default.createElement("p", { role: "status" }, this.t("noResults"))), /* @__PURE__ */ import_react4.default.createElement("footer", { className: style_names_default.footer }, /* @__PURE__ */ import_react4.default.createElement("span", { "aria-live": "polite" }, this.t("selectedSummary", { count: selection.ordered.length })), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.buttons }, /* @__PURE__ */ import_react4.default.createElement("button", { type: "button", disabled: this.props.busy, onClick: this.props.onCancel }, this.t("cancel")), /* @__PURE__ */ import_react4.default.createElement(
1414
+ ), !visible.length && /* @__PURE__ */ import_react4.default.createElement("p", { role: "status" }, this.t("noResults"))), /* @__PURE__ */ import_react4.default.createElement("footer", { className: style_names_default.footer }, /* @__PURE__ */ import_react4.default.createElement("span", { "aria-live": "polite" }, this.t(
1415
+ this.props.enableDistribution ? "configuredSummary" : "selectedSummary",
1416
+ { count: this.props.enableDistribution ? configuredCount : selection.ordered.length }
1417
+ )), /* @__PURE__ */ import_react4.default.createElement("div", { className: style_names_default.buttons }, /* @__PURE__ */ import_react4.default.createElement("button", { type: "button", disabled: this.props.busy, onClick: this.props.onCancel }, this.t("cancel")), /* @__PURE__ */ import_react4.default.createElement(
1228
1418
  "button",
1229
1419
  {
1230
1420
  type: "button",
1231
1421
  className: style_names_default.primary,
1232
- disabled: this.props.busy || !selection.ordered.length,
1233
- onClick: () => this.props.onComplete(this.selection().ordered)
1422
+ disabled: this.props.busy || !(this.props.enableDistribution ? configuredCount && choicesReady : selection.ordered.length),
1423
+ onClick: () => this.completeSelection()
1234
1424
  },
1235
- this.t(this.props.busy ? "loadingExtensions" : "loadSelected")
1425
+ this.t(this.props.busy ? "loadingExtensions" : this.props.enableDistribution ? "applySettings" : "loadSelected")
1236
1426
  ))));
1237
1427
  }
1238
1428
  };
package/dist/react.d.ts CHANGED
@@ -1,25 +1,41 @@
1
1
  import * as React from 'react';
2
2
  import {Decision, ExtensionEntry, ExtensionInfo, SelectableExtension} from './index.js';
3
+ export type DistributionMode = 'embedded' | 'remote';
4
+ export type ExecutionMode = 'sandboxed' | 'unsandboxed';
5
+ export type InitialExtensionValues<T> = ReadonlyMap<string, T | undefined> | Readonly<Record<string, T | undefined>>;
6
+ export interface ExtensionDistributionSettings<T extends ExtensionEntry = ExtensionEntry> {
7
+ /** Includes selected dependencies and already-loaded entries; keyed maps use catalog IDs. */
8
+ entries: T[];
9
+ distributions: Map<string, DistributionMode>;
10
+ /** Execution choices remain keyed by URL for compatibility with the security review API. */
11
+ choices: Map<string, Decision>;
12
+ }
3
13
  export interface DialogFrameProps {
4
14
  children: React.ReactNode; id: string; className: string; contentLabel: string;
5
15
  hideCloseButton: boolean; onRequestClose(): void;
6
16
  }
7
17
  export interface ExtensionSecurityDialogProps {
8
18
  entries: ExtensionEntry[];
9
- initialChoices?: Map<string, Decision | undefined>;
19
+ initialChoices?: InitialExtensionValues<Decision>;
20
+ enableDistribution?: boolean;
21
+ initialDistributions?: InitialExtensionValues<DistributionMode>;
10
22
  locale?: string;
11
23
  context?: 'project' | 'catalog';
12
24
  DialogFrame?: React.ComponentType<DialogFrameProps>;
13
25
  loadInfo?: (url: string, signal: AbortSignal) => Promise<ExtensionInfo>;
14
- onComplete(decisions: Map<string, Decision> | null): void;
26
+ onComplete(decisions: Map<string, Decision> | null, settings?: ExtensionDistributionSettings): void;
15
27
  }
16
28
  export class ExtensionSecurityDialog extends React.Component<ExtensionSecurityDialogProps> {}
17
29
  export default ExtensionSecurityDialog;
18
30
 
19
31
  export interface ExtensionSelectionListProps {
20
32
  entries: SelectableExtension[]; loadedIds?: string[]; locale?: string; filterQuery?: string; busy?: boolean;
33
+ /** Selection checkboxes exclude packages; execution choices never contain deny. */
34
+ initialChoices?: InitialExtensionValues<ExecutionMode>;
35
+ enableDistribution?: boolean;
36
+ initialDistributions?: InitialExtensionValues<DistributionMode>;
21
37
  loadInfo?: (url: string, signal: AbortSignal) => Promise<ExtensionInfo>;
22
- onComplete(entries: SelectableExtension[]): void;
38
+ onComplete(entries: SelectableExtension[], settings?: ExtensionDistributionSettings<SelectableExtension>): void;
23
39
  onCancel(): void;
24
40
  }
25
41
  export class ExtensionSelectionList extends React.Component<ExtensionSelectionListProps> {}
package/dist/react.mjs CHANGED
@@ -199,6 +199,9 @@ var style_names_default = {
199
199
  "footer": "twextsec-footer",
200
200
  "securityFooter": "twextsec-security-footer",
201
201
  "securityModes": "twextsec-security-modes",
202
+ "rowControls": "twextsec-row-controls",
203
+ "distributionModes": "twextsec-distribution-modes",
204
+ "inlineModeLabel": "twextsec-inline-mode-label",
202
205
  "footerControls": "twextsec-footer-controls",
203
206
  "previewColumn": "twextsec-preview-column",
204
207
  "packageHeading": "twextsec-package-heading",
@@ -374,6 +377,15 @@ var banner_preview_default = BannerPreview;
374
377
  // src/messages.js
375
378
  var messages = {
376
379
  "en": {
380
+ "distribution": "Distribution",
381
+ "executionMode": "Execution mode",
382
+ "executionBulk": "Execution mode for all packages",
383
+ "distributionBulk": "Distribution for all packages",
384
+ "distribution-embedded": "Embedded (include in SB3)",
385
+ "distribution-remote": "Remote (reference URL)",
386
+ "distributionNote": "Distribution and execution permissions are separate. You can override each row after applying a bulk choice.",
387
+ "configuredSummary": "{count} extensions to configure",
388
+ "applySettings": "Apply extension settings",
377
389
  "securityInstruction": "To make extensions marked \u26A0\uFE0F work as their creators intended, choose Without sandbox.",
378
390
  "catalogCancelDestination": "Choose Cancel to return to the selection list.",
379
391
  "selectionIntro": "Choose extensions to add. Required extensions are selected automatically.",
@@ -444,6 +456,15 @@ var messages = {
444
456
  "warning": "Extensions without a sandbox can access your project and browser information."
445
457
  },
446
458
  "ja": {
459
+ "distribution": "\u914D\u5E03\u65B9\u6CD5",
460
+ "executionMode": "\u5B9F\u884C\u65B9\u6CD5",
461
+ "executionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u5B9F\u884C\u65B9\u6CD5",
462
+ "distributionBulk": "\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u914D\u5E03\u65B9\u6CD5",
463
+ "distribution-embedded": "Embedded\uFF08SB3\u306B\u540C\u68B1\uFF09",
464
+ "distribution-remote": "Remote\uFF08URL\u53C2\u7167\uFF09",
465
+ "distributionNote": "\u914D\u5E03\u65B9\u6CD5\u3068\u5B9F\u884C\u8A31\u53EF\u306F\u5225\u306E\u8A2D\u5B9A\u3067\u3059\u3002\u4E00\u62EC\u6307\u5B9A\u3057\u305F\u5F8C\u3001\u5404\u884C\u3067\u5909\u66F4\u3067\u304D\u307E\u3059\u3002",
466
+ "configuredSummary": "\u8A2D\u5B9A\u3059\u308B\u6A5F\u80FD\u62E1\u5F35 {count} \u4EF6",
467
+ "applySettings": "\u62E1\u5F35\u306E\u8A2D\u5B9A\u3092\u9069\u7528",
447
468
  "securityInstruction": "\u300C\u26A0\uFE0F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\uFF1A\u5FC5\u8981\u300D\u304C\u8868\u793A\u3055\u308C\u3066\u3044\u308B\u62E1\u5F35\u3092\u5236\u4F5C\u8005\u306E\u610F\u56F3\u3069\u304A\u308A\u306B\u52D5\u4F5C\u3055\u305B\u308B\u305F\u3081\u306B\u306F\u300E\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u300F\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
448
469
  "catalogCancelDestination": "\u300E\u30AD\u30E3\u30F3\u30BB\u30EB\u300F\u3067\u9078\u629E\u4E00\u89A7\u306B\u623B\u308A\u307E\u3059\u3002",
449
470
  "selectionIntro": "\u8FFD\u52A0\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002\u4F9D\u5B58\u3059\u308B\u6A5F\u80FD\u62E1\u5F35\u3082\u81EA\u52D5\u3067\u9078\u629E\u3055\u308C\u307E\u3059\u3002",
@@ -708,6 +729,16 @@ var bindAll = (instance, names) => names.forEach((name) => {
708
729
  instance[name] = instance[name].bind(instance);
709
730
  });
710
731
  var MODES = ["deny", "sandboxed", "unsandboxed"];
732
+ var EXECUTION_MODES = ["sandboxed", "unsandboxed"];
733
+ var DISTRIBUTIONS = ["embedded", "remote"];
734
+ var entryIds = (entry) => entry.id ? [entry.id] : entry.ids || [];
735
+ var initialValue = (values, entry) => {
736
+ for (const key of [...entry.id ? [entry.id] : [], entry.url, ...entry.ids || []]) {
737
+ const value = values instanceof Map ? values.get(key) : values && Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
738
+ if (value !== void 0) return value;
739
+ }
740
+ return void 0;
741
+ };
711
742
  var isModeAllowed = (mode, metadata) => MODES.includes(mode) && (!requiresUnsandboxed(metadata) || mode === "unsandboxed");
712
743
  var allRequireUnsandboxed = (entries, rows) => entries.length > 0 && entries.every((entry) => {
713
744
  const row = rows[entry.url];
@@ -752,11 +783,14 @@ var ExtensionSecurityDialog = class extends React4.Component {
752
783
  constructor(props) {
753
784
  super(props);
754
785
  const choices = {};
786
+ const distributions = {};
755
787
  for (const entry of props.entries) {
756
- const mode = props.initialChoices.get(entry.url);
788
+ const mode = initialValue(props.initialChoices, entry);
757
789
  if (isModeAllowed(mode, resolveSharedPackageMetadata(entry))) choices[entry.url] = mode;
790
+ const distribution = initialValue(props.initialDistributions, entry);
791
+ distributions[entry.url] = DISTRIBUTIONS.includes(distribution) ? distribution : "remote";
758
792
  }
759
- this.state = { choices, rows: {}, confirmation: null, ready: false };
793
+ this.state = { choices, distributions, rows: {}, confirmation: null, ready: false };
760
794
  this.requests = /* @__PURE__ */ new Map();
761
795
  this.controllers = /* @__PURE__ */ new Set();
762
796
  this.timeouts = /* @__PURE__ */ new Set();
@@ -770,7 +804,9 @@ var ExtensionSecurityDialog = class extends React4.Component {
770
804
  "handleNo",
771
805
  "handleYes",
772
806
  "handleRequestClose",
773
- "focusNo"
807
+ "focusNo",
808
+ "handleDistribution",
809
+ "handleBulkDistribution"
774
810
  ]);
775
811
  }
776
812
  componentDidMount() {
@@ -778,7 +814,8 @@ var ExtensionSecurityDialog = class extends React4.Component {
778
814
  this.delay(() => this.setState({ ready: true }));
779
815
  this.startRequests();
780
816
  }
781
- componentDidUpdate() {
817
+ componentDidUpdate(previousProps) {
818
+ this.initializeEntries(previousProps);
782
819
  this.startRequests();
783
820
  const { entries } = this.props;
784
821
  if (allRequireUnsandboxed(entries, this.state.rows) && entries.some((entry) => this.state.choices[entry.url] !== "unsandboxed")) {
@@ -842,10 +879,36 @@ var ExtensionSecurityDialog = class extends React4.Component {
842
879
  t(key, values) {
843
880
  return formatMessage(this.props.locale, key, values);
844
881
  }
882
+ initializeEntries(previousProps) {
883
+ if (previousProps.entries === this.props.entries) return;
884
+ const previousURLs = new Set(previousProps.entries.map((entry) => entry.url));
885
+ const added = this.props.entries.filter((entry) => !previousURLs.has(entry.url));
886
+ if (!added.length) return;
887
+ this.setState((previous) => {
888
+ const choices = __spreadValues({}, previous.choices);
889
+ const distributions = __spreadValues({}, previous.distributions);
890
+ for (const entry of added) {
891
+ const restored = initialValue(this.props.initialChoices, entry);
892
+ const actualLoadedMode = this.props.enableDistribution && this instanceof ExtensionSelectionList && this.props.loadedIds.includes(entry.id) && this.executionModes().includes(restored);
893
+ if (actualLoadedMode || this.canChoose(entry, restored, previous)) choices[entry.url] = restored;
894
+ else if (this.props.enableDistribution && this instanceof ExtensionSelectionList && requiresUnsandboxed(resolveSharedPackageMetadata(entry))) choices[entry.url] = "unsandboxed";
895
+ const distribution = initialValue(this.props.initialDistributions, entry);
896
+ distributions[entry.url] = DISTRIBUTIONS.includes(distribution) ? distribution : "remote";
897
+ }
898
+ return { choices, distributions };
899
+ });
900
+ }
845
901
  entryForEvent(event) {
846
902
  return this.props.entries[Number(event.currentTarget.dataset.index)];
847
903
  }
904
+ executionModes() {
905
+ return MODES;
906
+ }
907
+ canConfigureEntry() {
908
+ return true;
909
+ }
848
910
  canChoose(entry, mode, state = this.state) {
911
+ if (this.props.enableDistribution && mode === "deny" && (this.props.loadedIds || []).includes(entry.id)) return false;
849
912
  return isModeAllowed(mode, resolveSharedPackageMetadata(entry, (state.rows[entry.url] || {}).metadata));
850
913
  }
851
914
  selectionReady() {
@@ -856,20 +919,62 @@ var ExtensionSecurityDialog = class extends React4.Component {
856
919
  });
857
920
  }
858
921
  handleChoice(event) {
922
+ if (this.props.busy) return;
859
923
  const entry = this.entryForEvent(event);
860
924
  const mode = event.currentTarget.value;
861
- if (!entry) return;
925
+ if (!entry || !this.canConfigureEntry(entry)) return;
862
926
  this.setState((previous) => this.canChoose(entry, mode, previous) ? { choices: __spreadProps(__spreadValues({}, previous.choices), { [entry.url]: mode }) } : null);
863
927
  }
864
928
  handleBulk(event) {
929
+ if (this.props.busy) return;
865
930
  const mode = event.currentTarget.value;
866
- if (!MODES.includes(mode)) return;
931
+ if (!this.executionModes().includes(mode)) return;
867
932
  this.setState((previous) => ({ choices: Object.assign(
868
933
  {},
869
934
  previous.choices,
870
935
  Object.fromEntries(this.props.entries.filter((entry) => this.canChoose(entry, mode, previous)).map((entry) => [entry.url, mode]))
871
936
  ) }));
872
937
  }
938
+ handleDistribution(event) {
939
+ if (this.props.busy) return;
940
+ const entry = this.entryForEvent(event);
941
+ const distribution = event.currentTarget.value;
942
+ if (entry && this.canConfigureEntry(entry) && DISTRIBUTIONS.includes(distribution)) {
943
+ this.setState((previous) => ({ distributions: __spreadProps(__spreadValues({}, previous.distributions), { [entry.url]: distribution }) }));
944
+ }
945
+ }
946
+ handleBulkDistribution(event) {
947
+ if (this.props.busy) return;
948
+ const distribution = event.currentTarget.value;
949
+ if (!DISTRIBUTIONS.includes(distribution)) return;
950
+ this.setState((previous) => ({ distributions: Object.assign(
951
+ {},
952
+ previous.distributions,
953
+ Object.fromEntries(this.props.entries.map((entry) => [entry.url, distribution]))
954
+ ) }));
955
+ }
956
+ settings(entries = this.props.entries) {
957
+ const distributions = /* @__PURE__ */ new Map();
958
+ for (const entry of entries) {
959
+ for (const id of entryIds(entry)) distributions.set(id, this.state.distributions[entry.url] || "remote");
960
+ }
961
+ return { entries, distributions, choices: new Map(entries.filter((entry) => this.executionModes().includes(this.state.choices[entry.url])).map((entry) => [entry.url, this.state.choices[entry.url]])) };
962
+ }
963
+ renderDistributionBulk() {
964
+ if (!this.props.enableDistribution) return null;
965
+ return /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulk, "data-testid": "extension-distribution-bulk" }, /* @__PURE__ */ React4.createElement("span", null, this.t("distributionBulk")), DISTRIBUTIONS.map((distribution) => /* @__PURE__ */ React4.createElement(
966
+ "button",
967
+ {
968
+ type: "button",
969
+ key: distribution,
970
+ value: distribution,
971
+ "data-distribution": distribution,
972
+ disabled: this.props.busy,
973
+ onClick: this.handleBulkDistribution
974
+ },
975
+ this.t(`distribution-${distribution}`)
976
+ )), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulkNote }, this.t("distributionNote")));
977
+ }
873
978
  handleImageError(event) {
874
979
  const entry = this.entryForEvent(event);
875
980
  const failedURL = event.currentTarget.getAttribute("src");
@@ -910,12 +1015,15 @@ var ExtensionSecurityDialog = class extends React4.Component {
910
1015
  this.setState({ confirmation: null });
911
1016
  return;
912
1017
  }
913
- this.props.onComplete(new Map(this.props.entries.map((entry) => [entry.url, this.state.choices[entry.url]])));
1018
+ const decisions = new Map(this.props.entries.map((entry) => [entry.url, this.state.choices[entry.url]]));
1019
+ if (this.props.enableDistribution) this.props.onComplete(decisions, this.settings());
1020
+ else this.props.onComplete(decisions);
914
1021
  }
915
1022
  focusNo(element) {
916
1023
  if (element) element.focus();
917
1024
  }
918
1025
  renderRow(entry, index, selection) {
1026
+ const controlsDisabled = this.props.busy || Boolean(selection && !selection.checked);
919
1027
  const row = selection ? __spreadProps(__spreadValues({}, this.state.rows[entry.url]), { metadata: entry.metadata, status: "ready" }) : this.state.rows[entry.url] || {};
920
1028
  const metadata = row.metadata || {};
921
1029
  const sharedMetadata = resolveSharedPackageMetadata(entry, row.metadata);
@@ -948,6 +1056,8 @@ var ExtensionSecurityDialog = class extends React4.Component {
948
1056
  {
949
1057
  className: style_names_default.row,
950
1058
  key: entry.url,
1059
+ "data-extension-id": entryIds(entry).join(","),
1060
+ "data-distribution": this.props.enableDistribution ? this.state.distributions[entry.url] || "remote" : void 0,
951
1061
  "data-selection-state": selection ? selection.state : void 0
952
1062
  },
953
1063
  /* @__PURE__ */ React4.createElement("div", { className: style_names_default.rowMain }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.packageColumn }, /* @__PURE__ */ React4.createElement(
@@ -977,33 +1087,62 @@ var ExtensionSecurityDialog = class extends React4.Component {
977
1087
  },
978
1088
  selection.dependencyReason
979
1089
  ))
980
- ), !selection && row.invalidated && !this.state.choices[entry.url] && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.packageNotices }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.warningText, role: "status" }, this.t("choiceReset")))), !selection && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.securityModes }, /* @__PURE__ */ React4.createElement(PackageRequirement, { metadata: sharedMetadata, locale: this.props.locale, id: reasonId }), MODES.map((mode) => /* @__PURE__ */ React4.createElement(
981
- "label",
1090
+ ), !selection && row.invalidated && !this.state.choices[entry.url] && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.packageNotices }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.warningText, role: "status" }, this.t("choiceReset")))), (!selection || this.props.enableDistribution) && /* @__PURE__ */ React4.createElement(
1091
+ "div",
982
1092
  {
983
- className: style_names_default.choice,
984
- key: mode,
985
- "data-mode": mode,
986
- "aria-disabled": !this.canChoose(entry, mode),
987
- title: !this.canChoose(entry, mode) ? this.t("requiredToRun") : void 0
1093
+ className: style_names_default.rowControls,
1094
+ "aria-disabled": controlsDisabled
988
1095
  },
989
- /* @__PURE__ */ React4.createElement("span", { className: style_names_default.choiceControl }, /* @__PURE__ */ React4.createElement(
990
- "input",
1096
+ /* @__PURE__ */ React4.createElement("div", { className: style_names_default.securityModes, role: "group", "aria-label": this.t("executionMode") }, !selection && /* @__PURE__ */ React4.createElement(PackageRequirement, { metadata: sharedMetadata, locale: this.props.locale, id: reasonId }), this.executionModes().map((mode) => /* @__PURE__ */ React4.createElement(
1097
+ "label",
991
1098
  {
992
- type: "radio",
993
- name: `extension-security-${index}`,
994
- value: mode,
995
- checked: this.state.choices[entry.url] === mode,
996
- "aria-label": `${name}: ${this.t(mode)}`,
997
- "aria-describedby": !this.canChoose(entry, mode) ? reasonId : required && mode === "unsandboxed" ? requiredId : void 0,
998
- disabled: !this.canChoose(entry, mode),
999
- "data-index": index,
1000
- onChange: this.handleChoice
1001
- }
1002
- ), /* @__PURE__ */ React4.createElement(ModeIcon, { mode })),
1003
- /* @__PURE__ */ React4.createElement("span", { className: style_names_default.mobileLabel }, this.t(mode)),
1004
- !this.canChoose(entry, mode) && /* @__PURE__ */ React4.createElement("span", { className: style_names_default.modeNote }, this.t("unsupported")),
1005
- required && mode === "unsandboxed" && /* @__PURE__ */ React4.createElement("span", { id: requiredId, className: style_names_default.requiredMode }, this.t("requiredToRun"))
1006
- ))), selection && /* @__PURE__ */ React4.createElement("label", { className: style_names_default.choice, "aria-disabled": selection.disabled }, /* @__PURE__ */ React4.createElement(
1099
+ className: style_names_default.choice,
1100
+ key: mode,
1101
+ "data-mode": mode,
1102
+ "aria-disabled": controlsDisabled || !this.canChoose(entry, mode),
1103
+ title: !this.canChoose(entry, mode) ? this.t("requiredToRun") : void 0
1104
+ },
1105
+ /* @__PURE__ */ React4.createElement("span", { className: style_names_default.choiceControl }, /* @__PURE__ */ React4.createElement(
1106
+ "input",
1107
+ {
1108
+ type: "radio",
1109
+ name: `${selection ? "selection-" : ""}extension-security-${index}`,
1110
+ value: mode,
1111
+ checked: this.state.choices[entry.url] === mode,
1112
+ "aria-label": `${name}: ${this.t(mode)}`,
1113
+ "aria-describedby": !this.canChoose(entry, mode) ? reasonId : required && mode === "unsandboxed" ? requiredId : void 0,
1114
+ disabled: controlsDisabled || !this.canChoose(entry, mode),
1115
+ "data-index": index,
1116
+ onChange: this.handleChoice
1117
+ }
1118
+ ), /* @__PURE__ */ React4.createElement(ModeIcon, { mode })),
1119
+ /* @__PURE__ */ React4.createElement("span", { className: this.props.enableDistribution ? style_names_default.inlineModeLabel : style_names_default.mobileLabel }, this.t(mode)),
1120
+ !this.canChoose(entry, mode) && /* @__PURE__ */ React4.createElement("span", { className: style_names_default.modeNote }, this.t("unsupported")),
1121
+ required && mode === "unsandboxed" && /* @__PURE__ */ React4.createElement("span", { id: requiredId, className: style_names_default.requiredMode }, this.t("requiredToRun"))
1122
+ ))),
1123
+ this.props.enableDistribution && /* @__PURE__ */ React4.createElement(
1124
+ "fieldset",
1125
+ {
1126
+ className: style_names_default.distributionModes,
1127
+ disabled: controlsDisabled
1128
+ },
1129
+ /* @__PURE__ */ React4.createElement("legend", null, this.t("distribution")),
1130
+ DISTRIBUTIONS.map((distribution) => /* @__PURE__ */ React4.createElement("label", { key: distribution, className: style_names_default.choice }, /* @__PURE__ */ React4.createElement(
1131
+ "input",
1132
+ {
1133
+ type: "radio",
1134
+ name: `${idPrefix}-distribution-${index}`,
1135
+ value: distribution,
1136
+ "data-index": index,
1137
+ "data-distribution": distribution,
1138
+ checked: (this.state.distributions[entry.url] || "remote") === distribution,
1139
+ disabled: controlsDisabled,
1140
+ "aria-label": `${name}: ${this.t(`distribution-${distribution}`)}`,
1141
+ onChange: this.handleDistribution
1142
+ }
1143
+ ), /* @__PURE__ */ React4.createElement("span", null, this.t(`distribution-${distribution}`))))
1144
+ )
1145
+ ), selection && /* @__PURE__ */ React4.createElement("label", { className: style_names_default.choice, "aria-disabled": selection.disabled }, /* @__PURE__ */ React4.createElement(
1007
1146
  "input",
1008
1147
  {
1009
1148
  type: "checkbox",
@@ -1064,14 +1203,14 @@ var ExtensionSecurityDialog = class extends React4.Component {
1064
1203
  },
1065
1204
  this.t("yes")
1066
1205
  ))
1067
- ) : /* @__PURE__ */ React4.createElement("div", { className: style_names_default.body }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ React4.createElement("p", null, this.t("securityInstruction")), /* @__PURE__ */ React4.createElement(
1206
+ ) : /* @__PURE__ */ React4.createElement("div", { className: `${style_names_default.body}${this.props.enableDistribution ? " twextsec-with-distribution" : ""}` }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ React4.createElement("p", null, this.t("securityInstruction")), /* @__PURE__ */ React4.createElement(
1068
1207
  "div",
1069
1208
  {
1070
1209
  className: style_names_default.secondary,
1071
1210
  "aria-live": "polite"
1072
1211
  },
1073
1212
  this.t("progress", { done, total: entries.length })
1074
- )), !allRequired && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ React4.createElement("span", null, this.t("bulk")), MODES.map((mode) => /* @__PURE__ */ React4.createElement(
1213
+ )), this.renderDistributionBulk(), !allRequired && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ React4.createElement("span", null, this.t("bulk")), MODES.map((mode) => /* @__PURE__ */ React4.createElement(
1075
1214
  "button",
1076
1215
  {
1077
1216
  type: "button",
@@ -1131,6 +1270,8 @@ var DefaultFrame = ({ children, contentLabel, className }) => /* @__PURE__ */ Re
1131
1270
  ExtensionSecurityDialog.defaultProps = {
1132
1271
  loadInfo: loadExtensionInfo,
1133
1272
  initialChoices: /* @__PURE__ */ new Map(),
1273
+ initialDistributions: /* @__PURE__ */ new Map(),
1274
+ enableDistribution: false,
1134
1275
  locale: "en",
1135
1276
  context: "project",
1136
1277
  DialogFrame: DefaultFrame
@@ -1140,11 +1281,22 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1140
1281
  constructor(props) {
1141
1282
  super(props);
1142
1283
  this.state.explicitIds = /* @__PURE__ */ new Set();
1284
+ if (props.enableDistribution) {
1285
+ for (const entry of props.entries) {
1286
+ if (!EXECUTION_MODES.includes(this.state.choices[entry.url])) delete this.state.choices[entry.url];
1287
+ const actual = initialValue(props.initialChoices, entry);
1288
+ if (props.loadedIds.includes(entry.id) && EXECUTION_MODES.includes(actual)) this.state.choices[entry.url] = actual;
1289
+ if (!this.state.choices[entry.url] && requiresUnsandboxed(resolveSharedPackageMetadata(entry))) {
1290
+ this.state.choices[entry.url] = "unsandboxed";
1291
+ }
1292
+ }
1293
+ }
1143
1294
  }
1144
1295
  componentDidMount() {
1145
1296
  this.alive = true;
1146
1297
  }
1147
- componentDidUpdate() {
1298
+ componentDidUpdate(previousProps) {
1299
+ this.initializeEntries(previousProps);
1148
1300
  const available = new Set(this.props.entries.map((entry) => entry.id));
1149
1301
  if ([...this.state.explicitIds].some((id) => !available.has(id))) {
1150
1302
  this.setState((previous) => ({ explicitIds: new Set([...previous.explicitIds].filter((id) => available.has(id))) }));
@@ -1152,6 +1304,16 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1152
1304
  }
1153
1305
  startRequests() {
1154
1306
  }
1307
+ executionModes() {
1308
+ return EXECUTION_MODES;
1309
+ }
1310
+ canChoose(entry, mode, state = this.state) {
1311
+ return EXECUTION_MODES.includes(mode) && super.canChoose(entry, mode, state);
1312
+ }
1313
+ canConfigureEntry(entry) {
1314
+ const selection = this.selection();
1315
+ return selection.selected.has(entry.id) || selection.loaded.has(entry.id);
1316
+ }
1155
1317
  selection() {
1156
1318
  return resolveExtensionSelection(this.props.entries, this.state.explicitIds, this.props.loadedIds);
1157
1319
  }
@@ -1166,6 +1328,16 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1166
1328
  return { explicitIds };
1167
1329
  });
1168
1330
  }
1331
+ completeSelection() {
1332
+ const selection = this.selection();
1333
+ if (!this.props.enableDistribution) {
1334
+ this.props.onComplete(selection.ordered);
1335
+ return;
1336
+ }
1337
+ const included = this.props.entries.filter((entry) => selection.selected.has(entry.id) || selection.loaded.has(entry.id));
1338
+ if (included.some((entry) => !this.canChoose(entry, this.state.choices[entry.url]))) return;
1339
+ this.props.onComplete(selection.ordered, this.settings(included));
1340
+ }
1169
1341
  render() {
1170
1342
  const selection = this.selection();
1171
1343
  const query = (this.props.filterQuery || "").trim().toLowerCase();
@@ -1183,7 +1355,22 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1183
1355
  dependencyReason: !loaded && rootNames.length ? this.t("requiredBy", { names: rootNames.join(separator) }) : null
1184
1356
  });
1185
1357
  };
1186
- return /* @__PURE__ */ React4.createElement("div", { className: `${style_names_default.body} twextsec-selection`, "aria-busy": this.props.busy }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ React4.createElement("p", null, this.t("selectionIntro")), /* @__PURE__ */ React4.createElement("ul", { className: style_names_default.selectionLegend, "aria-label": this.t("selectionLegend") }, ["selected", "dependency", "unselected", "loaded"].map((state) => /* @__PURE__ */ React4.createElement("li", { key: state, "data-selection-state": state }, /* @__PURE__ */ React4.createElement(SelectionIcon, { state }), this.t(`${state}State`))))), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.list }, /* @__PURE__ */ React4.createElement(
1358
+ const configured = this.props.entries.filter((entry) => selection.selected.has(entry.id) || selection.loaded.has(entry.id));
1359
+ const configuredCount = configured.length;
1360
+ const choicesReady = configured.every((entry) => this.canChoose(entry, this.state.choices[entry.url]));
1361
+ return /* @__PURE__ */ React4.createElement("div", { className: `${style_names_default.body} twextsec-selection${this.props.enableDistribution ? " twextsec-with-distribution" : ""}`, "aria-busy": this.props.busy }, /* @__PURE__ */ React4.createElement("div", { className: style_names_default.intro }, /* @__PURE__ */ React4.createElement("p", null, this.t("selectionIntro")), /* @__PURE__ */ React4.createElement("ul", { className: style_names_default.selectionLegend, "aria-label": this.t("selectionLegend") }, ["selected", "dependency", "unselected", "loaded"].map((state) => /* @__PURE__ */ React4.createElement("li", { key: state, "data-selection-state": state }, /* @__PURE__ */ React4.createElement(SelectionIcon, { state }), this.t(`${state}State`))))), this.props.enableDistribution && !this.props.entries.every((entry) => requiresUnsandboxed(resolveSharedPackageMetadata(entry))) && /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulk }, /* @__PURE__ */ React4.createElement("span", null, this.t("executionBulk")), this.executionModes().map((mode) => /* @__PURE__ */ React4.createElement(
1362
+ "button",
1363
+ {
1364
+ type: "button",
1365
+ key: mode,
1366
+ value: mode,
1367
+ "data-execution": mode,
1368
+ disabled: this.props.busy || this.props.entries.every((entry) => !this.canChoose(entry, mode)),
1369
+ onClick: this.handleBulk
1370
+ },
1371
+ /* @__PURE__ */ React4.createElement(ModeIcon, { mode }),
1372
+ this.t(mode)
1373
+ )), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.bulkNote }, this.t("bulkNote"))), this.renderDistributionBulk(), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.list }, /* @__PURE__ */ React4.createElement(
1187
1374
  package_sections_default,
1188
1375
  {
1189
1376
  entries: this.props.entries,
@@ -1192,15 +1379,18 @@ var ExtensionSelectionList = class extends ExtensionSecurityDialog {
1192
1379
  idPrefix: "selection-extension",
1193
1380
  renderItem: renderSelectionRow
1194
1381
  }
1195
- ), !visible.length && /* @__PURE__ */ React4.createElement("p", { role: "status" }, this.t("noResults"))), /* @__PURE__ */ React4.createElement("footer", { className: style_names_default.footer }, /* @__PURE__ */ React4.createElement("span", { "aria-live": "polite" }, this.t("selectedSummary", { count: selection.ordered.length })), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.buttons }, /* @__PURE__ */ React4.createElement("button", { type: "button", disabled: this.props.busy, onClick: this.props.onCancel }, this.t("cancel")), /* @__PURE__ */ React4.createElement(
1382
+ ), !visible.length && /* @__PURE__ */ React4.createElement("p", { role: "status" }, this.t("noResults"))), /* @__PURE__ */ React4.createElement("footer", { className: style_names_default.footer }, /* @__PURE__ */ React4.createElement("span", { "aria-live": "polite" }, this.t(
1383
+ this.props.enableDistribution ? "configuredSummary" : "selectedSummary",
1384
+ { count: this.props.enableDistribution ? configuredCount : selection.ordered.length }
1385
+ )), /* @__PURE__ */ React4.createElement("div", { className: style_names_default.buttons }, /* @__PURE__ */ React4.createElement("button", { type: "button", disabled: this.props.busy, onClick: this.props.onCancel }, this.t("cancel")), /* @__PURE__ */ React4.createElement(
1196
1386
  "button",
1197
1387
  {
1198
1388
  type: "button",
1199
1389
  className: style_names_default.primary,
1200
- disabled: this.props.busy || !selection.ordered.length,
1201
- onClick: () => this.props.onComplete(this.selection().ordered)
1390
+ disabled: this.props.busy || !(this.props.enableDistribution ? configuredCount && choicesReady : selection.ordered.length),
1391
+ onClick: () => this.completeSelection()
1202
1392
  },
1203
- this.t(this.props.busy ? "loadingExtensions" : "loadSelected")
1393
+ this.t(this.props.busy ? "loadingExtensions" : this.props.enableDistribution ? "applySettings" : "loadSelected")
1204
1394
  ))));
1205
1395
  }
1206
1396
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.3.3",
3
+ "version": "0.4.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
@@ -30,6 +30,12 @@
30
30
  .twextsec-row-main { padding: 16px 0; grid-template-columns: minmax(0, 1fr) auto; }
31
31
  .twextsec-security-modes { display: grid; grid-template-columns: 52px 94px 94px; gap: 8px; align-items: center; min-width: 0; }
32
32
  .twextsec-security-modes > .twextsec-requirement { grid-column: 1 / -1; justify-self: start; }
33
+ .twextsec-row-controls { min-width: 0; }
34
+ .twextsec-with-distribution .twextsec-row-controls { display: flex; flex-direction: column; gap: 12px; }
35
+ .twextsec-inline-mode-label { font-size: 11px; text-align: center; }
36
+ .twextsec-distribution-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 8px 0 0; min-width: 0; border: 0; border-top: 1px solid var(--ui-black-transparent, #dce1eb); }
37
+ .twextsec-distribution-modes legend { font-size: 12px; padding-inline-end: 6px; }
38
+ .twextsec-distribution-modes .twextsec-choice { font-size: 11px; text-align: center; padding: 6px; }
33
39
  .twextsec-package-column { min-width: 0; }
34
40
  .twextsec-package-notices { margin-top: 6px; font-size: 12px; overflow-wrap: anywhere; }
35
41
  .twextsec-metadata { display: grid; grid-template-columns: 128px minmax(0,1fr); gap: 12px; align-items: start; min-width: 0; }
@@ -122,6 +128,9 @@
122
128
  /* The catalog uses the same metadata row with one checkbox at the far right. */
123
129
  .twextsec-selection { height: 100%; width: 100%; }
124
130
  .twextsec-selection .twextsec-row-main { grid-template-columns: minmax(0, 1fr) 48px; }
131
+ .twextsec-selection.twextsec-with-distribution .twextsec-row-main { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 10px; }
132
+ .twextsec-selection.twextsec-with-distribution .twextsec-security-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
133
+ .twextsec-selection [data-selection-state="unselected"] .twextsec-row-controls { opacity: 0.55; }
125
134
  .twextsec-package-links { display: inline-flex; align-items: center; justify-content: flex-start; gap: 4px; }
126
135
  .twextsec-package-link { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; font: inherit; color: inherit; border-radius: 6px; }
127
136
  .twextsec-package-link svg { width: 1.5em; height: auto; }
@@ -162,4 +171,9 @@
162
171
  .twextsec-list > section:first-child .twextsec-category-heading { margin-top: 12px; }
163
172
  @media (max-width: 580px) {
164
173
  .twextsec-selection .twextsec-row-main { grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; }
174
+ .twextsec-selection.twextsec-with-distribution .twextsec-row-main { grid-template-columns: minmax(0, 1fr) 36px; }
175
+ .twextsec-selection.twextsec-with-distribution .twextsec-package-column { grid-column: 1; grid-row: 1; }
176
+ .twextsec-selection.twextsec-with-distribution .twextsec-row-main > .twextsec-choice { grid-column: 2; grid-row: 1; }
177
+ .twextsec-selection.twextsec-with-distribution .twextsec-row-controls { grid-column: 1 / -1; grid-row: 2; }
178
+ .twextsec-selection.twextsec-with-distribution .twextsec-security-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
165
179
  }
package/webpack4.css CHANGED
@@ -30,6 +30,12 @@
30
30
  :global(.twextsec-row-main) { padding: 16px 0; grid-template-columns: minmax(0, 1fr) auto; }
31
31
  :global(.twextsec-security-modes) { display: grid; grid-template-columns: 52px 94px 94px; gap: 8px; align-items: center; min-width: 0; }
32
32
  :global(.twextsec-security-modes) > :global(.twextsec-requirement) { grid-column: 1 / -1; justify-self: start; }
33
+ :global(.twextsec-row-controls) { min-width: 0; }
34
+ :global(.twextsec-with-distribution) :global(.twextsec-row-controls) { display: flex; flex-direction: column; gap: 12px; }
35
+ :global(.twextsec-inline-mode-label) { font-size: 11px; text-align: center; }
36
+ :global(.twextsec-distribution-modes) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 8px 0 0; min-width: 0; border: 0; border-top: 1px solid var(--ui-black-transparent, #dce1eb); }
37
+ :global(.twextsec-distribution-modes) legend { font-size: 12px; padding-inline-end: 6px; }
38
+ :global(.twextsec-distribution-modes) :global(.twextsec-choice) { font-size: 11px; text-align: center; padding: 6px; }
33
39
  :global(.twextsec-package-column) { min-width: 0; }
34
40
  :global(.twextsec-package-notices) { margin-top: 6px; font-size: 12px; overflow-wrap: anywhere; }
35
41
  :global(.twextsec-metadata) { display: grid; grid-template-columns: 128px minmax(0,1fr); gap: 12px; align-items: start; min-width: 0; }
@@ -122,6 +128,9 @@
122
128
  /* The catalog uses the same metadata row with one checkbox at the far right. */
123
129
  :global(.twextsec-selection) { height: 100%; width: 100%; }
124
130
  :global(.twextsec-selection) :global(.twextsec-row-main) { grid-template-columns: minmax(0, 1fr) 48px; }
131
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-row-main) { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 10px; }
132
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-security-modes) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
133
+ :global(.twextsec-selection) [data-selection-state="unselected"] :global(.twextsec-row-controls) { opacity: 0.55; }
125
134
  :global(.twextsec-package-links) { display: inline-flex; align-items: center; justify-content: flex-start; gap: 4px; }
126
135
  :global(.twextsec-package-link) { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; font: inherit; color: inherit; border-radius: 6px; }
127
136
  :global(.twextsec-package-link) svg { width: 1.5em; height: auto; }
@@ -162,4 +171,9 @@
162
171
  :global(.twextsec-list) > section:first-child :global(.twextsec-category-heading) { margin-top: 12px; }
163
172
  @media (max-width: 580px) {
164
173
  :global(.twextsec-selection) :global(.twextsec-row-main) { grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; }
174
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-row-main) { grid-template-columns: minmax(0, 1fr) 36px; }
175
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-package-column) { grid-column: 1; grid-row: 1; }
176
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-row-main) > :global(.twextsec-choice) { grid-column: 2; grid-row: 1; }
177
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-row-controls) { grid-column: 1 / -1; grid-row: 2; }
178
+ :global(.twextsec-selection):global(.twextsec-with-distribution) :global(.twextsec-security-modes) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
165
179
  }