@kubohiroya/turbowarp-extension-security-dialog 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -47,8 +47,27 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
47
47
  | 一覧に載るもの | カタログの拡張。依存先は自動で選ばれる | 作品が使う拡張すべて |
48
48
  | 選ぶ | チェックで選ぶ | 無し。作品が既に名指ししている |
49
49
  | 動かし方 | サンドボックスの中で、またはサンドボックスなしで | 動かさない、サンドボックスの中で、サンドボックスなしで |
50
- | 読み込み元 | 控えを残す、毎回取得する、作品の中から | 控えを残す、毎回取得する。作品に入っているバイト列は他に取得元が無い |
51
- | 一括指定 | 両方 | 両方 |
50
+ | 読み込み元 | 4つの持ち方から選ぶ | `remote-cacheable` の行で控えを残すかだけ。ほかの行は読み込み元を述べる |
51
+ | 一括指定 | 両方 | 動かし方と、断れる控えが1つでもあるときはその控え |
52
+
53
+ ### 4つの持ち方
54
+
55
+ 拡張のバイト列の持ち方は4つです。ローダーの Manifest・SB3 の保存形式・この画面が同じ語で呼ぶので、
56
+ ホストは両端を変換表なしでつなげます。
57
+
58
+ | 名前 | このブラウザー | 作品のファイル | 標準 TurboWarp |
59
+ | --- | --- | --- | --- |
60
+ | `remote-non-cacheable` | 何も残さない | 参照だけ | 開けない |
61
+ | `remote-cacheable` | 検証した控えを残してよい | 参照だけ | 開けない |
62
+ | `embedded-file` | 残すものが無い | バイト列を ZIP の中のファイルとして持つ | 開けない |
63
+ | `embedded-data` | 残すものが無い | バイト列を `data:` の値として持つ | **開ける** |
64
+
65
+ **4つはすべて作者の決定**で、拡張を追加したときに決まります。だから `add` は4つすべてを出し、
66
+ `open` はほとんど何も出しません。開く人に残る問いは「`remote-cacheable` の行の控えを自分の
67
+ ブラウザーに実際に残すか」だけで、しかも**断ることしかできません**。`remote-non-cacheable` は
68
+ 作者が控えを禁じたということで、それを上書きして許可を書く書き方は存在しません。そのため
69
+ `loadingChoices` は行の source から選択肢を読み取り、横に対応表を置く必要がありません。source が
70
+ 持ち方を名指している行はもうそのように読み込まれているので、画面は尋ねるのではなく述べます。
52
71
 
53
72
  ### しないこと
54
73
 
@@ -61,8 +80,8 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
61
80
  扱いで、サンドボックスなしで動き、実行の選択肢を出しません。信頼済みの行だけの作品は止める
62
81
  価値が無いので、`requiresReview` が画面を出さなくてよいと答えます。
63
82
 
64
- **記録された答えは、いまも選択肢である場合だけ尊重します。** 作品が参照から埋め込みに変わった、
65
- 行が信頼済みになった、といった場合に、もう提示しない答えを持ち込みません。
83
+ **記録された答えは、いまも選択肢である場合だけ尊重します。** 作品が `remote-cacheable` から
84
+ 埋め込みに変わった、行が信頼済みになった、といった場合に、もう提示しない答えを持ち込みません。
66
85
 
67
86
  ## 取得を待つあいだ
68
87
 
@@ -113,10 +132,10 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
113
132
 
114
133
  | 内容 | 場所 | 決める人 |
115
134
  | --- | --- | --- |
116
- | 参照か、作品の中のバイト列か | 作品 | 追加した人 |
135
+ | 4つの持ち方のどれか | 作品 | 追加した人 |
117
136
  | 動かし方(追加したとき) | 作品 | 追加した人 |
118
137
  | 動かし方(開いたとき) | このブラウザー、作品ごと | 開く人 |
119
- | 控えを残すか毎回取得するか | このブラウザー、作品ごと | 開く人 |
138
+ | `remote-cacheable` の控えを実際に残すか | このブラウザー、作品ごと | 開く人。断ることだけできる |
120
139
  | プレビュー画像 | このブラウザー | 誰でもない。常に残す |
121
140
 
122
141
  保存が使えないとき(プライベートウィンドウ、サイトデータを止めたブラウザー)も、読み取りは必ず
@@ -128,11 +147,13 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
128
147
  それを未検証の申告として示します。ここでコードを評価することはありません。プレビュー画像は装飾で、
129
148
  何とも照合していません。コードを検証するのは別の場所で、失敗した行にはそう表示されます。
130
149
 
150
+ 先頭コメントは2つの書き方を読みます。TurboWarp 本体の拡張とギャラリーが使う `// Name: ...` の行と、`/** @name ... */` のブロックです。同じ項目を両方が書いていればブロックを採ります。見出しとして読むのは先頭に続くコメント行だけで、`Bundled extensions:` で止めます。バンドルが中身について書いたことは中身のもので、バンドル自身のものではないためです。
151
+
131
152
  ## 開発
132
153
 
133
154
  ```sh
134
155
  pnpm install
135
- pnpm run check # ビルド、テスト36件、pack の dry run
156
+ pnpm run check # ビルド、テスト46件、pack の dry run
136
157
  ```
137
158
 
138
159
  React と React DOM は peerDependencies なので、ホストが用意します。実行時の依存はありません。
@@ -140,3 +161,5 @@ React と React DOM は peerDependencies なので、ホストが用意します
140
161
  ## ライセンス
141
162
 
142
163
  [MPL-2.0](LICENSE)。何が対象で何が対象外かは [NOTICE.md](./NOTICE.md) を参照してください。
164
+
165
+ 0.6.0でMPL-2.0へ書き直したときの設計の記録は [書き直しの設計](docs/mpl-rewrite.ja.md) にあります。
package/README.md CHANGED
@@ -48,8 +48,29 @@ is put, so they are the same component.
48
48
  | What is listed | Catalog entries; dependencies are selected for you | Every extension the project uses |
49
49
  | Picking | Tick to choose | None: the project already names them |
50
50
  | How it runs | In the sandbox, or without it | Do not run, in the sandbox, or without it |
51
- | Where it loads from | Keep a copy, fetch each time, or in the project | Keep a copy or fetch each time; embedded bytes have nowhere else to come from |
52
- | All at once | Both choices | Both choices |
51
+ | Where it loads from | Any of the four forms | Only whether a `remote-cacheable` row keeps its copy; every other row states how it loads |
52
+ | All at once | Both choices | How they all run, and the copy where at least one row has one to decline |
53
+
54
+ ### The four loading forms
55
+
56
+ An extension's bytes are held in one of four ways, spelled the same by the Loader's manifest, by
57
+ the SB3 save format and by this screen, so a host wires the two ends together without a
58
+ translation table.
59
+
60
+ | Form | This browser | The project file | Standard TurboWarp |
61
+ | --- | --- | --- | --- |
62
+ | `remote-non-cacheable` | Keeps nothing | A reference | Cannot open it |
63
+ | `remote-cacheable` | May keep a verified copy | A reference | Cannot open it |
64
+ | `embedded-file` | Nothing to keep | The bytes, as a file in the archive | Cannot open it |
65
+ | `embedded-data` | Nothing to keep | The bytes, as a `data:` value | **Can open it** |
66
+
67
+ **All four are the author's decision**, made when the extension was added, which is why `add`
68
+ offers all of them and `open` offers almost none. The one thing left to the person opening a
69
+ project is whether a `remote-cacheable` row actually leaves its copy in this browser, and that can
70
+ only be declined: `remote-non-cacheable` is the author forbidding the copy, and there is no way to
71
+ write permission back over it. So `loadingChoices` reads the choices off the row's own source and
72
+ needs no table beside it — a row whose source names a form is already loading that way, and the
73
+ screen states it instead of asking.
53
74
 
54
75
  ### What it will not do
55
76
 
@@ -63,8 +84,8 @@ host's own gallery: it runs without the sandbox and offers no execution choice.
63
84
  nothing but trusted rows is not worth stopping, so `requiresReview` says to skip the screen.
64
85
 
65
86
  **A remembered answer is honoured only where it is still one of the choices.** A project that
66
- moved from a reference to embedded bytes, or a row that has since become trusted, does not carry
67
- a stale answer into a screen that no longer offers it.
87
+ moved from `remote-cacheable` to embedded bytes, or a row that has since become trusted, does not
88
+ carry a stale answer into a screen that no longer offers it.
68
89
 
69
90
  ## While a fetch is waiting
70
91
 
@@ -117,10 +138,10 @@ Saying no resolves `onComplete` with `null`, and the load rejects with an error
117
138
 
118
139
  | What | Where | Who decides |
119
140
  | --- | --- | --- |
120
- | Reference or embedded bytes | The project | Whoever added the extension |
141
+ | Which of the four loading forms | The project | Whoever added the extension |
121
142
  | How it runs, when added | The project | Whoever added it |
122
143
  | How it runs, when opened | This browser, per project | Whoever opens it |
123
- | Keep a copy or fetch each time | This browser, per project | Whoever opens it |
144
+ | Whether a `remote-cacheable` copy is kept | This browser, per project | Whoever opens it, and only to decline |
124
145
  | Preview pictures | This browser | Nobody; always kept |
125
146
 
126
147
  Every read answers with something usable even when storage is unavailable — a private window, a
@@ -133,11 +154,16 @@ of its leading comment, and the screen labels them as unverified. Nothing here e
133
154
  extension. A preview picture is decoration and is checked against nothing; whatever verifies the
134
155
  code does so elsewhere, and a row says so when it failed.
135
156
 
157
+ Two forms of leading comment are read: the `// Name: ...` lines TurboWarp's own extensions and its
158
+ gallery open with, and a `/** @name ... */` block. Where both name a field, the block wins. Only the
159
+ leading run of comment lines counts as a header, and reading stops at `Bundled extensions:`, because
160
+ what a bundle says about its members is theirs, not its own.
161
+
136
162
  ## Development
137
163
 
138
164
  ```sh
139
165
  pnpm install
140
- pnpm run check # build, 36 tests, and a packing dry run
166
+ pnpm run check # build, 46 tests, and a packing dry run
141
167
  ```
142
168
 
143
169
  React and React DOM are peer dependencies, so the host supplies them. There are no runtime
@@ -146,3 +172,5 @@ dependencies.
146
172
  ## License
147
173
 
148
174
  [MPL-2.0](LICENSE). See [NOTICE.md](./NOTICE.md) for what is and is not covered.
175
+
176
+ The design record of the MPL-2.0 rewrite in 0.6.0 is in [the rewrite design (Japanese)](docs/mpl-rewrite.ja.md).
package/dist/index.cjs CHANGED
@@ -47,6 +47,7 @@ __export(index_exports, {
47
47
  loadExtensionCatalog: () => loadExtensionCatalog,
48
48
  loadExtensionInfo: () => loadExtensionInfo,
49
49
  loadingChoices: () => loadingChoices,
50
+ loadingModes: () => loadingModes,
50
51
  messages: () => messages,
51
52
  parseExtensionCatalog: () => parseExtensionCatalog,
52
53
  parseExtensionMetadata: () => parseExtensionMetadata,
@@ -210,36 +211,82 @@ function decodeExtensionDataURL(url) {
210
211
  }
211
212
  function parseExtensionMetadata(source) {
212
213
  if (typeof source !== "string") return {};
213
- const block = BLOCK.exec(source.slice(0, 64 * 1024));
214
- if (block === null) return {};
214
+ const text2 = source.slice(0, 64 * 1024);
215
215
  const metadata = {};
216
216
  const descriptions = {};
217
- for (const line of block[1].split("\n")) {
218
- const field = FIELD.exec(line);
219
- if (field === null) continue;
220
- const [, name, raw] = field;
217
+ const record = (name, raw, locale) => {
221
218
  const value = trimmed(raw);
222
- if (value.length === 0 || value.length > LIMIT) continue;
219
+ if (value.length === 0 || value.length > LIMIT) return;
223
220
  if (name === "description") {
224
- const localized = /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(value);
225
- if (localized === null) metadata.description = value;
226
- else descriptions[localized[1].toLowerCase()] = trimmed(localized[2]);
227
- continue;
221
+ if (locale) descriptions[locale.toLowerCase()] = value;
222
+ else metadata.description = value;
223
+ return;
228
224
  }
229
225
  if (["repository", "docsURL", "authorURL"].includes(name)) {
230
226
  try {
231
227
  metadata[name] = reviewURL(value, name, name === "authorURL");
232
228
  } catch (error) {
233
229
  }
234
- continue;
230
+ return;
235
231
  }
236
232
  if (["name", "id", "author", "version", "license", "banner", "package", "unsandboxed"].includes(name)) {
237
233
  metadata[name] = value;
238
234
  }
235
+ };
236
+ for (const [name, raw, locale] of headerFields(text2)) record(name, raw, locale);
237
+ const block = BLOCK.exec(text2);
238
+ if (block !== null) {
239
+ for (const line of block[1].split("\n")) {
240
+ const field = FIELD.exec(line);
241
+ if (field === null) continue;
242
+ const [, name, raw] = field;
243
+ const localized = name === "description" ? /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(trimmed(raw)) : null;
244
+ if (localized === null) record(name, raw);
245
+ else record(name, localized[2], localized[1]);
246
+ }
239
247
  }
240
248
  if (Object.keys(descriptions).length > 0) metadata.descriptions = descriptions;
241
249
  return metadata;
242
250
  }
251
+ var HEADER_FIELDS = Object.freeze({
252
+ name: "name",
253
+ id: "id",
254
+ description: "description",
255
+ by: "author",
256
+ author: "author",
257
+ version: "version",
258
+ license: "license",
259
+ unsandboxed: "unsandboxed",
260
+ repository: "repository",
261
+ source: "repository",
262
+ "docs url": "docsURL",
263
+ docsurl: "docsURL",
264
+ "author url": "authorURL",
265
+ authorurl: "authorURL",
266
+ banner: "banner",
267
+ package: "package"
268
+ });
269
+ function headerFields(text2) {
270
+ const fields = [];
271
+ const seen = /* @__PURE__ */ new Set();
272
+ for (const line of text2.split("\n")) {
273
+ const comment = /^[ \t]*\/\/(.*)$/.exec(line);
274
+ if (comment === null) {
275
+ if (line.trim() === "") continue;
276
+ break;
277
+ }
278
+ const body = comment[1];
279
+ if (/^\s*Bundled extensions:\s*$/i.test(body)) break;
280
+ const field = /^ ?([A-Za-z][A-Za-z -]*?)(?:\[([a-z]{2,8}(?:-[A-Za-z0-9]{1,8})*)\])?:[ \t]*(.*)$/.exec(body);
281
+ if (field === null) continue;
282
+ const name = HEADER_FIELDS[field[1].trim().toLowerCase()];
283
+ const key = `${name}:${field[2] || ""}`;
284
+ if (!name || seen.has(key)) continue;
285
+ seen.add(key);
286
+ fields.push(field[2] ? [name, field[3], field[2]] : [name, field[3]]);
287
+ }
288
+ return fields;
289
+ }
243
290
  function getExtensionDescription(metadata, locale = "en") {
244
291
  const declared = metadata && metadata.descriptions;
245
292
  if (!declared) return metadata && metadata.description || "";
@@ -356,7 +403,7 @@ var run = async (store, mode, work) => {
356
403
  db.close();
357
404
  }
358
405
  };
359
- function createDecisionStorage({ fallbackLoading = "cached" } = {}) {
406
+ function createDecisionStorage({ fallbackLoading = "remote-cacheable" } = {}) {
360
407
  return Object.freeze({
361
408
  fallbackLoading,
362
409
  /**
@@ -440,17 +487,26 @@ function createPreviewCache() {
440
487
 
441
488
  // src/decisions.js
442
489
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
443
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
490
+ var loadingModes = Object.freeze([
491
+ "remote-cacheable",
492
+ "remote-non-cacheable",
493
+ "embedded-file",
494
+ "embedded-data"
495
+ ]);
496
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
444
497
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
445
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
498
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
446
499
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
447
500
  const choices = loadingChoices(entry);
448
501
  if (choices.length === 0) {
449
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
502
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
450
503
  }
451
504
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
452
505
  }
453
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
506
+ function initialDecisions(entries, mode, {
507
+ recorded = /* @__PURE__ */ new Map(),
508
+ fallbackLoading = "remote-cacheable"
509
+ } = {}) {
454
510
  return new Map(entries.map((entry) => {
455
511
  const base = defaultDecision(entry, mode, fallbackLoading);
456
512
  const previous = recorded.get(entry.key);
@@ -477,9 +533,12 @@ var messages = {
477
533
  "execution-deny": "Do not run",
478
534
  "execution-sandboxed": "In the sandbox",
479
535
  "execution-unsandboxed": "Without the sandbox",
480
- "loading-cached": "Keep a copy (default)",
481
- "loading-remote": "Fetch each time",
482
- "loading-embedded": "In the project",
536
+ "loading-remote-cacheable": "Keep a copy (default)",
537
+ "loading-remote-non-cacheable": "Fetch each time",
538
+ // The two embedded forms differ only in the carrier, which is what decides who else can
539
+ // open the project, so the wording names the carrier and nothing else.
540
+ "loading-embedded-file": "In the project",
541
+ "loading-embedded-data": "In the project, as a data address",
483
542
  loadingNote: "A kept copy is verified and reused, so the project opens without the network. Fetching each time leaves nothing in this browser.",
484
543
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
485
544
  "requirement-required": "Says it needs to run without the sandbox",
@@ -522,9 +581,10 @@ var messages = {
522
581
  "execution-deny": "\u52D5\u304B\u3055\u306A\u3044",
523
582
  "execution-sandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u4E2D\u3067",
524
583
  "execution-unsandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067",
525
- "loading-cached": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
526
- "loading-remote": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
527
- "loading-embedded": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
584
+ "loading-remote-cacheable": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
585
+ "loading-remote-non-cacheable": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
586
+ "loading-embedded-file": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
587
+ "loading-embedded-data": "\u4F5C\u54C1\u306E\u4E2D\u306E data: \u30A2\u30C9\u30EC\u30B9\u304B\u3089",
528
588
  loadingNote: "\u63A7\u3048\u306F\u691C\u8A3C\u3057\u305F\u3046\u3048\u3067\u4F7F\u3044\u56DE\u3059\u306E\u3067\u3001\u901A\u4FE1\u306A\u3057\u3067\u3082\u4F5C\u54C1\u304C\u958B\u304D\u307E\u3059\u3002\u6BCE\u56DE\u53D6\u5F97\u3059\u308B\u5834\u5408\u306F\u3001\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u30FC\u306B\u4F55\u3082\u6B8B\u308A\u307E\u305B\u3093\u3002",
529
589
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
530
590
  "requirement-required": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981\u3068\u7533\u544A\u3057\u3066\u3044\u307E\u3059",
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ export function createPreviewCache(): PreviewCache;
46
46
 
47
47
  export type ReviewMode = 'add' | 'open';
48
48
  export function isTrusted(entry: ReviewEntry): boolean;
49
+ export const loadingModes: readonly LoadingMode[];
49
50
  export function loadingChoices(entry: ReviewEntry): LoadingMode[];
50
51
  export function executionChoices(entry: ReviewEntry, mode: ReviewMode): ExecutionDecision[];
51
52
  export function defaultDecision(entry: ReviewEntry, mode: ReviewMode, fallbackLoading?: LoadingMode): ReviewDecision;
package/dist/index.mjs CHANGED
@@ -168,36 +168,82 @@ function decodeExtensionDataURL(url) {
168
168
  }
169
169
  function parseExtensionMetadata(source) {
170
170
  if (typeof source !== "string") return {};
171
- const block = BLOCK.exec(source.slice(0, 64 * 1024));
172
- if (block === null) return {};
171
+ const text2 = source.slice(0, 64 * 1024);
173
172
  const metadata = {};
174
173
  const descriptions = {};
175
- for (const line of block[1].split("\n")) {
176
- const field = FIELD.exec(line);
177
- if (field === null) continue;
178
- const [, name, raw] = field;
174
+ const record = (name, raw, locale) => {
179
175
  const value = trimmed(raw);
180
- if (value.length === 0 || value.length > LIMIT) continue;
176
+ if (value.length === 0 || value.length > LIMIT) return;
181
177
  if (name === "description") {
182
- const localized = /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(value);
183
- if (localized === null) metadata.description = value;
184
- else descriptions[localized[1].toLowerCase()] = trimmed(localized[2]);
185
- continue;
178
+ if (locale) descriptions[locale.toLowerCase()] = value;
179
+ else metadata.description = value;
180
+ return;
186
181
  }
187
182
  if (["repository", "docsURL", "authorURL"].includes(name)) {
188
183
  try {
189
184
  metadata[name] = reviewURL(value, name, name === "authorURL");
190
185
  } catch (error) {
191
186
  }
192
- continue;
187
+ return;
193
188
  }
194
189
  if (["name", "id", "author", "version", "license", "banner", "package", "unsandboxed"].includes(name)) {
195
190
  metadata[name] = value;
196
191
  }
192
+ };
193
+ for (const [name, raw, locale] of headerFields(text2)) record(name, raw, locale);
194
+ const block = BLOCK.exec(text2);
195
+ if (block !== null) {
196
+ for (const line of block[1].split("\n")) {
197
+ const field = FIELD.exec(line);
198
+ if (field === null) continue;
199
+ const [, name, raw] = field;
200
+ const localized = name === "description" ? /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(trimmed(raw)) : null;
201
+ if (localized === null) record(name, raw);
202
+ else record(name, localized[2], localized[1]);
203
+ }
197
204
  }
198
205
  if (Object.keys(descriptions).length > 0) metadata.descriptions = descriptions;
199
206
  return metadata;
200
207
  }
208
+ var HEADER_FIELDS = Object.freeze({
209
+ name: "name",
210
+ id: "id",
211
+ description: "description",
212
+ by: "author",
213
+ author: "author",
214
+ version: "version",
215
+ license: "license",
216
+ unsandboxed: "unsandboxed",
217
+ repository: "repository",
218
+ source: "repository",
219
+ "docs url": "docsURL",
220
+ docsurl: "docsURL",
221
+ "author url": "authorURL",
222
+ authorurl: "authorURL",
223
+ banner: "banner",
224
+ package: "package"
225
+ });
226
+ function headerFields(text2) {
227
+ const fields = [];
228
+ const seen = /* @__PURE__ */ new Set();
229
+ for (const line of text2.split("\n")) {
230
+ const comment = /^[ \t]*\/\/(.*)$/.exec(line);
231
+ if (comment === null) {
232
+ if (line.trim() === "") continue;
233
+ break;
234
+ }
235
+ const body = comment[1];
236
+ if (/^\s*Bundled extensions:\s*$/i.test(body)) break;
237
+ const field = /^ ?([A-Za-z][A-Za-z -]*?)(?:\[([a-z]{2,8}(?:-[A-Za-z0-9]{1,8})*)\])?:[ \t]*(.*)$/.exec(body);
238
+ if (field === null) continue;
239
+ const name = HEADER_FIELDS[field[1].trim().toLowerCase()];
240
+ const key = `${name}:${field[2] || ""}`;
241
+ if (!name || seen.has(key)) continue;
242
+ seen.add(key);
243
+ fields.push(field[2] ? [name, field[3], field[2]] : [name, field[3]]);
244
+ }
245
+ return fields;
246
+ }
201
247
  function getExtensionDescription(metadata, locale = "en") {
202
248
  const declared = metadata && metadata.descriptions;
203
249
  if (!declared) return metadata && metadata.description || "";
@@ -314,7 +360,7 @@ var run = async (store, mode, work) => {
314
360
  db.close();
315
361
  }
316
362
  };
317
- function createDecisionStorage({ fallbackLoading = "cached" } = {}) {
363
+ function createDecisionStorage({ fallbackLoading = "remote-cacheable" } = {}) {
318
364
  return Object.freeze({
319
365
  fallbackLoading,
320
366
  /**
@@ -398,17 +444,26 @@ function createPreviewCache() {
398
444
 
399
445
  // src/decisions.js
400
446
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
401
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
447
+ var loadingModes = Object.freeze([
448
+ "remote-cacheable",
449
+ "remote-non-cacheable",
450
+ "embedded-file",
451
+ "embedded-data"
452
+ ]);
453
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
402
454
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
403
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
455
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
404
456
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
405
457
  const choices = loadingChoices(entry);
406
458
  if (choices.length === 0) {
407
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
459
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
408
460
  }
409
461
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
410
462
  }
411
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
463
+ function initialDecisions(entries, mode, {
464
+ recorded = /* @__PURE__ */ new Map(),
465
+ fallbackLoading = "remote-cacheable"
466
+ } = {}) {
412
467
  return new Map(entries.map((entry) => {
413
468
  const base = defaultDecision(entry, mode, fallbackLoading);
414
469
  const previous = recorded.get(entry.key);
@@ -435,9 +490,12 @@ var messages = {
435
490
  "execution-deny": "Do not run",
436
491
  "execution-sandboxed": "In the sandbox",
437
492
  "execution-unsandboxed": "Without the sandbox",
438
- "loading-cached": "Keep a copy (default)",
439
- "loading-remote": "Fetch each time",
440
- "loading-embedded": "In the project",
493
+ "loading-remote-cacheable": "Keep a copy (default)",
494
+ "loading-remote-non-cacheable": "Fetch each time",
495
+ // The two embedded forms differ only in the carrier, which is what decides who else can
496
+ // open the project, so the wording names the carrier and nothing else.
497
+ "loading-embedded-file": "In the project",
498
+ "loading-embedded-data": "In the project, as a data address",
441
499
  loadingNote: "A kept copy is verified and reused, so the project opens without the network. Fetching each time leaves nothing in this browser.",
442
500
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
443
501
  "requirement-required": "Says it needs to run without the sandbox",
@@ -480,9 +538,10 @@ var messages = {
480
538
  "execution-deny": "\u52D5\u304B\u3055\u306A\u3044",
481
539
  "execution-sandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u4E2D\u3067",
482
540
  "execution-unsandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067",
483
- "loading-cached": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
484
- "loading-remote": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
485
- "loading-embedded": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
541
+ "loading-remote-cacheable": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
542
+ "loading-remote-non-cacheable": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
543
+ "loading-embedded-file": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
544
+ "loading-embedded-data": "\u4F5C\u54C1\u306E\u4E2D\u306E data: \u30A2\u30C9\u30EC\u30B9\u304B\u3089",
486
545
  loadingNote: "\u63A7\u3048\u306F\u691C\u8A3C\u3057\u305F\u3046\u3048\u3067\u4F7F\u3044\u56DE\u3059\u306E\u3067\u3001\u901A\u4FE1\u306A\u3057\u3067\u3082\u4F5C\u54C1\u304C\u958B\u304D\u307E\u3059\u3002\u6BCE\u56DE\u53D6\u5F97\u3059\u308B\u5834\u5408\u306F\u3001\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u30FC\u306B\u4F55\u3082\u6B8B\u308A\u307E\u305B\u3093\u3002",
487
546
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
488
547
  "requirement-required": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981\u3068\u7533\u544A\u3057\u3066\u3044\u307E\u3059",
@@ -623,6 +682,7 @@ export {
623
682
  loadExtensionCatalog,
624
683
  loadExtensionInfo,
625
684
  loadingChoices,
685
+ loadingModes,
626
686
  messages,
627
687
  parseExtensionCatalog,
628
688
  parseExtensionMetadata,
package/dist/react.cjs CHANGED
@@ -68,9 +68,12 @@ var messages = {
68
68
  "execution-deny": "Do not run",
69
69
  "execution-sandboxed": "In the sandbox",
70
70
  "execution-unsandboxed": "Without the sandbox",
71
- "loading-cached": "Keep a copy (default)",
72
- "loading-remote": "Fetch each time",
73
- "loading-embedded": "In the project",
71
+ "loading-remote-cacheable": "Keep a copy (default)",
72
+ "loading-remote-non-cacheable": "Fetch each time",
73
+ // The two embedded forms differ only in the carrier, which is what decides who else can
74
+ // open the project, so the wording names the carrier and nothing else.
75
+ "loading-embedded-file": "In the project",
76
+ "loading-embedded-data": "In the project, as a data address",
74
77
  loadingNote: "A kept copy is verified and reused, so the project opens without the network. Fetching each time leaves nothing in this browser.",
75
78
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
76
79
  "requirement-required": "Says it needs to run without the sandbox",
@@ -113,9 +116,10 @@ var messages = {
113
116
  "execution-deny": "\u52D5\u304B\u3055\u306A\u3044",
114
117
  "execution-sandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u4E2D\u3067",
115
118
  "execution-unsandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067",
116
- "loading-cached": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
117
- "loading-remote": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
118
- "loading-embedded": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
119
+ "loading-remote-cacheable": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
120
+ "loading-remote-non-cacheable": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
121
+ "loading-embedded-file": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
122
+ "loading-embedded-data": "\u4F5C\u54C1\u306E\u4E2D\u306E data: \u30A2\u30C9\u30EC\u30B9\u304B\u3089",
119
123
  loadingNote: "\u63A7\u3048\u306F\u691C\u8A3C\u3057\u305F\u3046\u3048\u3067\u4F7F\u3044\u56DE\u3059\u306E\u3067\u3001\u901A\u4FE1\u306A\u3057\u3067\u3082\u4F5C\u54C1\u304C\u958B\u304D\u307E\u3059\u3002\u6BCE\u56DE\u53D6\u5F97\u3059\u308B\u5834\u5408\u306F\u3001\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u30FC\u306B\u4F55\u3082\u6B8B\u308A\u307E\u305B\u3093\u3002",
120
124
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
121
125
  "requirement-required": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981\u3068\u7533\u544A\u3057\u3066\u3044\u307E\u3059",
@@ -154,6 +158,24 @@ var formatMessage = (locale, key, values = {}) => {
154
158
  };
155
159
 
156
160
  // src/metadata.js
161
+ var HEADER_FIELDS = Object.freeze({
162
+ name: "name",
163
+ id: "id",
164
+ description: "description",
165
+ by: "author",
166
+ author: "author",
167
+ version: "version",
168
+ license: "license",
169
+ unsandboxed: "unsandboxed",
170
+ repository: "repository",
171
+ source: "repository",
172
+ "docs url": "docsURL",
173
+ docsurl: "docsURL",
174
+ "author url": "authorURL",
175
+ authorurl: "authorURL",
176
+ banner: "banner",
177
+ package: "package"
178
+ });
157
179
  function getExtensionDescription(metadata, locale = "en") {
158
180
  const declared = metadata && metadata.descriptions;
159
181
  if (!declared) return metadata && metadata.description || "";
@@ -365,17 +387,26 @@ var ExtensionPreview = class extends import_react.default.PureComponent {
365
387
 
366
388
  // src/decisions.js
367
389
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
368
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
390
+ var loadingModes = Object.freeze([
391
+ "remote-cacheable",
392
+ "remote-non-cacheable",
393
+ "embedded-file",
394
+ "embedded-data"
395
+ ]);
396
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
369
397
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
370
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
398
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
371
399
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
372
400
  const choices = loadingChoices(entry);
373
401
  if (choices.length === 0) {
374
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
402
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
375
403
  }
376
404
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
377
405
  }
378
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
406
+ function initialDecisions(entries, mode, {
407
+ recorded = /* @__PURE__ */ new Map(),
408
+ fallbackLoading = "remote-cacheable"
409
+ } = {}) {
379
410
  return new Map(entries.map((entry) => {
380
411
  const base = defaultDecision(entry, mode, fallbackLoading);
381
412
  const previous = recorded.get(entry.key);
@@ -392,9 +423,12 @@ var fallbackBanner = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53
392
423
  var bind = (instance, names) => names.forEach((name) => {
393
424
  instance[name] = instance[name].bind(instance);
394
425
  });
426
+ var isEmbedded = (source) => source.kind === "embedded-file" || source.kind === "embedded-data";
395
427
  var sourceLabel = (entry, t) => {
396
- if (entry.source.kind === "embedded") return t("sourceEmbedded");
397
- if (String(entry.source.url).startsWith("data:")) return t("sourceInline");
428
+ if (entry.source.kind === "embedded-file") return t("sourceEmbedded");
429
+ if (entry.source.kind === "embedded-data" || String(entry.source.url).startsWith("data:")) {
430
+ return t("sourceInline");
431
+ }
398
432
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
399
433
  return entry.source.url;
400
434
  };
@@ -434,7 +468,7 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
434
468
  const { loadInfo, entries } = this.props;
435
469
  if (!loadInfo) return;
436
470
  for (const entry of entries) {
437
- if (entry.metadata || entry.source.kind === "embedded") continue;
471
+ if (entry.metadata || isEmbedded(entry.source)) continue;
438
472
  try {
439
473
  const info = await loadInfo(entry.source.url, this.controller.signal);
440
474
  if (this.controller.signal.aborted) return;
@@ -586,7 +620,7 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
586
620
  t
587
621
  }
588
622
  ),
589
- loadings.length === 0 && decision.loading === "embedded" && /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-loading-fixed" }, t("loading-embedded")),
623
+ loadings.length === 0 && decision.loading !== void 0 && /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-loading-fixed" }, t(`loading-${decision.loading}`)),
590
624
  contradictsDeclaration(entry, decision) && /* @__PURE__ */ import_react2.default.createElement(
591
625
  "p",
592
626
  {
@@ -602,6 +636,7 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
602
636
  const t = this.t.bind(this);
603
637
  const selection = this.selection();
604
638
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
639
+ const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
605
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(
606
641
  Choices,
607
642
  {
@@ -612,17 +647,17 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
612
647
  onChange: this.handleBulkExecution,
613
648
  t
614
649
  }
615
- ), /* @__PURE__ */ import_react2.default.createElement(
650
+ ), bulkLoadings.length > 0 && /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
616
651
  Choices,
617
652
  {
618
653
  name: "loading-all",
619
654
  label: t("loadingBulk"),
620
655
  value: null,
621
- options: ["cached", "remote"],
656
+ options: bulkLoadings,
622
657
  onChange: this.handleBulkLoading,
623
658
  t
624
659
  }
625
- ), /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-note" }, t("loadingNote"))), anyUnsandboxed && /* @__PURE__ */ import_react2.default.createElement(
660
+ ), /* @__PURE__ */ import_react2.default.createElement("p", { className: "twextsec-note" }, t("loadingNote")))), anyUnsandboxed && /* @__PURE__ */ import_react2.default.createElement(
626
661
  "p",
627
662
  {
628
663
  className: "twextsec-warning",
@@ -659,5 +694,9 @@ var ExtensionReview = class extends import_react2.default.PureComponent {
659
694
  return body;
660
695
  }
661
696
  };
662
- ExtensionReview.defaultProps = { locale: "en", fallbackLoading: "cached", previewCache: createPreviewCache() };
697
+ ExtensionReview.defaultProps = {
698
+ locale: "en",
699
+ fallbackLoading: "remote-cacheable",
700
+ previewCache: createPreviewCache()
701
+ };
663
702
  var review_default = ExtensionReview;
package/dist/react.mjs CHANGED
@@ -35,9 +35,12 @@ var messages = {
35
35
  "execution-deny": "Do not run",
36
36
  "execution-sandboxed": "In the sandbox",
37
37
  "execution-unsandboxed": "Without the sandbox",
38
- "loading-cached": "Keep a copy (default)",
39
- "loading-remote": "Fetch each time",
40
- "loading-embedded": "In the project",
38
+ "loading-remote-cacheable": "Keep a copy (default)",
39
+ "loading-remote-non-cacheable": "Fetch each time",
40
+ // The two embedded forms differ only in the carrier, which is what decides who else can
41
+ // open the project, so the wording names the carrier and nothing else.
42
+ "loading-embedded-file": "In the project",
43
+ "loading-embedded-data": "In the project, as a data address",
41
44
  loadingNote: "A kept copy is verified and reused, so the project opens without the network. Fetching each time leaves nothing in this browser.",
42
45
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
43
46
  "requirement-required": "Says it needs to run without the sandbox",
@@ -80,9 +83,10 @@ var messages = {
80
83
  "execution-deny": "\u52D5\u304B\u3055\u306A\u3044",
81
84
  "execution-sandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u4E2D\u3067",
82
85
  "execution-unsandboxed": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067",
83
- "loading-cached": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
84
- "loading-remote": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
85
- "loading-embedded": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
86
+ "loading-remote-cacheable": "\u63A7\u3048\u3092\u6B8B\u3059\uFF08\u65E2\u5B9A\uFF09",
87
+ "loading-remote-non-cacheable": "\u6BCE\u56DE\u53D6\u5F97\u3059\u308B",
88
+ "loading-embedded-file": "\u4F5C\u54C1\u306E\u4E2D\u304B\u3089",
89
+ "loading-embedded-data": "\u4F5C\u54C1\u306E\u4E2D\u306E data: \u30A2\u30C9\u30EC\u30B9\u304B\u3089",
86
90
  loadingNote: "\u63A7\u3048\u306F\u691C\u8A3C\u3057\u305F\u3046\u3048\u3067\u4F7F\u3044\u56DE\u3059\u306E\u3067\u3001\u901A\u4FE1\u306A\u3057\u3067\u3082\u4F5C\u54C1\u304C\u958B\u304D\u307E\u3059\u3002\u6BCE\u56DE\u53D6\u5F97\u3059\u308B\u5834\u5408\u306F\u3001\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u30FC\u306B\u4F55\u3082\u6B8B\u308A\u307E\u305B\u3093\u3002",
87
91
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
88
92
  "requirement-required": "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981\u3068\u7533\u544A\u3057\u3066\u3044\u307E\u3059",
@@ -121,6 +125,24 @@ var formatMessage = (locale, key, values = {}) => {
121
125
  };
122
126
 
123
127
  // src/metadata.js
128
+ var HEADER_FIELDS = Object.freeze({
129
+ name: "name",
130
+ id: "id",
131
+ description: "description",
132
+ by: "author",
133
+ author: "author",
134
+ version: "version",
135
+ license: "license",
136
+ unsandboxed: "unsandboxed",
137
+ repository: "repository",
138
+ source: "repository",
139
+ "docs url": "docsURL",
140
+ docsurl: "docsURL",
141
+ "author url": "authorURL",
142
+ authorurl: "authorURL",
143
+ banner: "banner",
144
+ package: "package"
145
+ });
124
146
  function getExtensionDescription(metadata, locale = "en") {
125
147
  const declared = metadata && metadata.descriptions;
126
148
  if (!declared) return metadata && metadata.description || "";
@@ -332,17 +354,26 @@ var ExtensionPreview = class extends React.PureComponent {
332
354
 
333
355
  // src/decisions.js
334
356
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
335
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
357
+ var loadingModes = Object.freeze([
358
+ "remote-cacheable",
359
+ "remote-non-cacheable",
360
+ "embedded-file",
361
+ "embedded-data"
362
+ ]);
363
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
336
364
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
337
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
365
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
338
366
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
339
367
  const choices = loadingChoices(entry);
340
368
  if (choices.length === 0) {
341
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
369
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
342
370
  }
343
371
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
344
372
  }
345
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
373
+ function initialDecisions(entries, mode, {
374
+ recorded = /* @__PURE__ */ new Map(),
375
+ fallbackLoading = "remote-cacheable"
376
+ } = {}) {
346
377
  return new Map(entries.map((entry) => {
347
378
  const base = defaultDecision(entry, mode, fallbackLoading);
348
379
  const previous = recorded.get(entry.key);
@@ -359,9 +390,12 @@ var fallbackBanner = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53
359
390
  var bind = (instance, names) => names.forEach((name) => {
360
391
  instance[name] = instance[name].bind(instance);
361
392
  });
393
+ var isEmbedded = (source) => source.kind === "embedded-file" || source.kind === "embedded-data";
362
394
  var sourceLabel = (entry, t) => {
363
- if (entry.source.kind === "embedded") return t("sourceEmbedded");
364
- if (String(entry.source.url).startsWith("data:")) return t("sourceInline");
395
+ if (entry.source.kind === "embedded-file") return t("sourceEmbedded");
396
+ if (entry.source.kind === "embedded-data" || String(entry.source.url).startsWith("data:")) {
397
+ return t("sourceInline");
398
+ }
365
399
  if (entry.source.kind === "legacy") return `${t("sourceLegacy")}: ${entry.source.url}`;
366
400
  return entry.source.url;
367
401
  };
@@ -401,7 +435,7 @@ var ExtensionReview = class extends React2.PureComponent {
401
435
  const { loadInfo, entries } = this.props;
402
436
  if (!loadInfo) return;
403
437
  for (const entry of entries) {
404
- if (entry.metadata || entry.source.kind === "embedded") continue;
438
+ if (entry.metadata || isEmbedded(entry.source)) continue;
405
439
  try {
406
440
  const info = await loadInfo(entry.source.url, this.controller.signal);
407
441
  if (this.controller.signal.aborted) return;
@@ -553,7 +587,7 @@ var ExtensionReview = class extends React2.PureComponent {
553
587
  t
554
588
  }
555
589
  ),
556
- loadings.length === 0 && decision.loading === "embedded" && /* @__PURE__ */ React2.createElement("p", { className: "twextsec-loading-fixed" }, t("loading-embedded")),
590
+ loadings.length === 0 && decision.loading !== void 0 && /* @__PURE__ */ React2.createElement("p", { className: "twextsec-loading-fixed" }, t(`loading-${decision.loading}`)),
557
591
  contradictsDeclaration(entry, decision) && /* @__PURE__ */ React2.createElement(
558
592
  "p",
559
593
  {
@@ -569,6 +603,7 @@ var ExtensionReview = class extends React2.PureComponent {
569
603
  const t = this.t.bind(this);
570
604
  const selection = this.selection();
571
605
  const anyUnsandboxed = [...this.included()].some((key) => this.state.decisions.get(key).execution === "unsandboxed");
606
+ const bulkLoadings = loadingModes.filter((mode2) => entries.some((entry) => loadingChoices(entry).includes(mode2)));
572
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(
573
608
  Choices,
574
609
  {
@@ -579,17 +614,17 @@ var ExtensionReview = class extends React2.PureComponent {
579
614
  onChange: this.handleBulkExecution,
580
615
  t
581
616
  }
582
- ), /* @__PURE__ */ React2.createElement(
617
+ ), bulkLoadings.length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
583
618
  Choices,
584
619
  {
585
620
  name: "loading-all",
586
621
  label: t("loadingBulk"),
587
622
  value: null,
588
- options: ["cached", "remote"],
623
+ options: bulkLoadings,
589
624
  onChange: this.handleBulkLoading,
590
625
  t
591
626
  }
592
- ), /* @__PURE__ */ React2.createElement("p", { className: "twextsec-note" }, t("loadingNote"))), anyUnsandboxed && /* @__PURE__ */ React2.createElement(
627
+ ), /* @__PURE__ */ React2.createElement("p", { className: "twextsec-note" }, t("loadingNote")))), anyUnsandboxed && /* @__PURE__ */ React2.createElement(
593
628
  "p",
594
629
  {
595
630
  className: "twextsec-warning",
@@ -626,7 +661,11 @@ var ExtensionReview = class extends React2.PureComponent {
626
661
  return body;
627
662
  }
628
663
  };
629
- ExtensionReview.defaultProps = { locale: "en", fallbackLoading: "cached", previewCache: createPreviewCache() };
664
+ ExtensionReview.defaultProps = {
665
+ locale: "en",
666
+ fallbackLoading: "remote-cacheable",
667
+ previewCache: createPreviewCache()
668
+ };
630
669
  var review_default = ExtensionReview;
631
670
  export {
632
671
  ExtensionReview,
@@ -1,10 +1,15 @@
1
1
  /**
2
2
  * The vocabulary the review screen and its hosts share.
3
3
  *
4
- * Nothing here names the Loader's own types. A host that reads a Plus manifest turns it into
4
+ * Nothing here imports the Loader's own types. A host that reads a Plus manifest turns it into
5
5
  * `ReviewEntry` rows before this package sees it, and turns `ReviewDecision` back into whatever
6
6
  * the Loader wants. That keeps the dependency pointing one way: this package defines the port,
7
7
  * the hosts implement it.
8
+ *
9
+ * The four loading forms are nevertheless spelled exactly as the manifest and the SB3 save format
10
+ * spell them. Sharing the words costs nothing and buys a lot: a host wires the two ends together
11
+ * without a translation table, and a translation table is where one layer quietly comes to
12
+ * disagree with the one above it.
8
13
  */
9
14
 
10
15
  /** What the person allows a row to do. `deny` means it does not run at all. */
@@ -13,18 +18,19 @@ export type ExecutionDecision = 'deny' | 'sandboxed' | 'unsandboxed';
13
18
  /**
14
19
  * Where a row's bytes come from when the project runs.
15
20
  *
16
- * The family settled on three ways to hold anything, extensions included. `remote` fetches every
17
- * time: nothing is kept in the browser and nothing is kept in the project. `cached` keeps
18
- * verified bytes in the browser and reuses them, so opening again costs no network while the
19
- * project still holds only a reference. `embedded` is the project carrying the bytes itself, and
20
- * it has two forms: `embedded-file`, a file inside the archive, and `embedded-data`, a `data:`
21
- * value inside the project document.
21
+ * Four forms, two holding a reference and two holding the bytes. `remote-non-cacheable` fetches
22
+ * every time and keeps nothing anywhere. `remote-cacheable` fetches too, but a verified copy may
23
+ * be kept in this browser, so opening again costs no network while the project still holds only a
24
+ * reference. `embedded-file` is a file inside the archive. `embedded-data` is a `data:` value in
25
+ * the project document, which is also what lets a standard TurboWarp host open the project at all.
22
26
  *
23
- * Choosing between the two embedded forms is about how the project is written, not about how it
24
- * runs, so it belongs to whatever saves the project rather than to this screen. Adding an
25
- * extension here records `embedded`; the writer decides which form that becomes.
27
+ * All four are the author's decision, recorded when the extension was added, so the only question
28
+ * these leave the person opening a project is whether a `remote-cacheable` row may keep its copy
29
+ * here. That one can only ever be declined: `remote-non-cacheable` is the author forbidding the
30
+ * copy, and there is no way to write permission back over it.
26
31
  */
27
- export type LoadingMode = 'cached' | 'remote' | 'embedded';
32
+ export type LoadingMode =
33
+ 'remote-non-cacheable' | 'remote-cacheable' | 'embedded-file' | 'embedded-data';
28
34
 
29
35
  export interface ExtensionMetadata {
30
36
  name?: string; id?: string; description?: string; descriptions?: Record<string, string>;
@@ -33,11 +39,21 @@ export interface ExtensionMetadata {
33
39
  unsandboxed?: string; updatedAt?: string;
34
40
  }
35
41
 
36
- /** Where a row's code comes from, and what can be checked about it. */
42
+ /**
43
+ * Where a row's code comes from, and what can be checked about it.
44
+ *
45
+ * A row some project already names carries the author's chosen form as its own `kind`, which is
46
+ * why `loadingChoices` can read the choices off the source and needs no table. The two kinds that
47
+ * are not forms are the two cases where there is no author's decision to read: `catalog` is a row
48
+ * that is in no project yet, so whoever is looking at it is the author and picks the form, and
49
+ * `legacy` is an ordinary custom extension, which has no form to pick.
50
+ */
37
51
  export type ReviewSource =
38
52
  | {kind: 'catalog'; url: string; sha256?: string}
39
- | {kind: 'reference'; url: string; sha256: string}
40
- | {kind: 'embedded'; sha256: string}
53
+ | {kind: 'remote-non-cacheable'; url: string; sha256: string}
54
+ | {kind: 'remote-cacheable'; url: string; sha256: string}
55
+ | {kind: 'embedded-file'; sha256: string}
56
+ | {kind: 'embedded-data'; sha256: string}
41
57
  | {kind: 'legacy'; url: string};
42
58
 
43
59
  export interface ReviewEntryState {
@@ -26,17 +26,26 @@ module.exports = __toCommonJS(turbowarp_exports);
26
26
 
27
27
  // src/decisions.js
28
28
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
29
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
29
+ var loadingModes = Object.freeze([
30
+ "remote-cacheable",
31
+ "remote-non-cacheable",
32
+ "embedded-file",
33
+ "embedded-data"
34
+ ]);
35
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
30
36
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
31
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
37
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
32
38
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
33
39
  const choices = loadingChoices(entry);
34
40
  if (choices.length === 0) {
35
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
41
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
36
42
  }
37
43
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
38
44
  }
39
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
45
+ function initialDecisions(entries, mode, {
46
+ recorded = /* @__PURE__ */ new Map(),
47
+ fallbackLoading = "remote-cacheable"
48
+ } = {}) {
40
49
  return new Map(entries.map((entry) => {
41
50
  const base = defaultDecision(entry, mode, fallbackLoading);
42
51
  const previous = recorded.get(entry.key);
@@ -109,7 +118,7 @@ function installBatchExtensionLoader(vm, review, defaultURLs = {}, storage = nul
109
118
  const recorded = project && project.key && storage ? await storage.read(project.key) : /* @__PURE__ */ new Map();
110
119
  const starting = initialDecisions(entries, "open", {
111
120
  recorded,
112
- fallbackLoading: storage ? storage.fallbackLoading : "cached"
121
+ fallbackLoading: storage ? storage.fallbackLoading : "remote-cacheable"
113
122
  });
114
123
  if (!requiresReview(entries)) return starting;
115
124
  const answer = await review(entries, starting);
@@ -1,16 +1,25 @@
1
1
  // src/decisions.js
2
2
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
3
- var loadingChoices = (entry) => entry.source.kind === "catalog" ? ["cached", "remote", "embedded"] : entry.source.kind === "reference" ? ["cached", "remote"] : [];
3
+ var loadingModes = Object.freeze([
4
+ "remote-cacheable",
5
+ "remote-non-cacheable",
6
+ "embedded-file",
7
+ "embedded-data"
8
+ ]);
9
+ var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
4
10
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
5
- function defaultDecision(entry, mode, fallbackLoading = "cached") {
11
+ function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
6
12
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
7
13
  const choices = loadingChoices(entry);
8
14
  if (choices.length === 0) {
9
- return entry.source.kind === "embedded" ? { execution, loading: "embedded" } : { execution };
15
+ return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
10
16
  }
11
17
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
12
18
  }
13
- function initialDecisions(entries, mode, { recorded = /* @__PURE__ */ new Map(), fallbackLoading = "cached" } = {}) {
19
+ function initialDecisions(entries, mode, {
20
+ recorded = /* @__PURE__ */ new Map(),
21
+ fallbackLoading = "remote-cacheable"
22
+ } = {}) {
14
23
  return new Map(entries.map((entry) => {
15
24
  const base = defaultDecision(entry, mode, fallbackLoading);
16
25
  const previous = recorded.get(entry.key);
@@ -83,7 +92,7 @@ function installBatchExtensionLoader(vm, review, defaultURLs = {}, storage = nul
83
92
  const recorded = project && project.key && storage ? await storage.read(project.key) : /* @__PURE__ */ new Map();
84
93
  const starting = initialDecisions(entries, "open", {
85
94
  recorded,
86
- fallbackLoading: storage ? storage.fallbackLoading : "cached"
95
+ fallbackLoading: storage ? storage.fallbackLoading : "remote-cacheable"
87
96
  });
88
97
  if (!requiresReview(entries)) return starting;
89
98
  const answer = await review(entries, starting);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Batch extension security review, previews and per-project defaults for TurboWarp hosts",
5
5
  "type": "module",
6
6
  "author": {