@kubohiroya/turbowarp-extension-security-dialog 0.7.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
@@ -147,6 +147,8 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
147
147
  それを未検証の申告として示します。ここでコードを評価することはありません。プレビュー画像は装飾で、
148
148
  何とも照合していません。コードを検証するのは別の場所で、失敗した行にはそう表示されます。
149
149
 
150
+ 先頭コメントは2つの書き方を読みます。TurboWarp 本体の拡張とギャラリーが使う `// Name: ...` の行と、`/** @name ... */` のブロックです。同じ項目を両方が書いていればブロックを採ります。見出しとして読むのは先頭に続くコメント行だけで、`Bundled extensions:` で止めます。バンドルが中身について書いたことは中身のもので、バンドル自身のものではないためです。
151
+
150
152
  ## 開発
151
153
 
152
154
  ```sh
@@ -159,3 +161,5 @@ React と React DOM は peerDependencies なので、ホストが用意します
159
161
  ## ライセンス
160
162
 
161
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
@@ -154,6 +154,11 @@ of its leading comment, and the screen labels them as unverified. Nothing here e
154
154
  extension. A preview picture is decoration and is checked against nothing; whatever verifies the
155
155
  code does so elsewhere, and a row says so when it failed.
156
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
+
157
162
  ## Development
158
163
 
159
164
  ```sh
@@ -167,3 +172,5 @@ dependencies.
167
172
  ## License
168
173
 
169
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
@@ -211,36 +211,82 @@ function decodeExtensionDataURL(url) {
211
211
  }
212
212
  function parseExtensionMetadata(source) {
213
213
  if (typeof source !== "string") return {};
214
- const block = BLOCK.exec(source.slice(0, 64 * 1024));
215
- if (block === null) return {};
214
+ const text2 = source.slice(0, 64 * 1024);
216
215
  const metadata = {};
217
216
  const descriptions = {};
218
- for (const line of block[1].split("\n")) {
219
- const field = FIELD.exec(line);
220
- if (field === null) continue;
221
- const [, name, raw] = field;
217
+ const record = (name, raw, locale) => {
222
218
  const value = trimmed(raw);
223
- if (value.length === 0 || value.length > LIMIT) continue;
219
+ if (value.length === 0 || value.length > LIMIT) return;
224
220
  if (name === "description") {
225
- const localized = /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(value);
226
- if (localized === null) metadata.description = value;
227
- else descriptions[localized[1].toLowerCase()] = trimmed(localized[2]);
228
- continue;
221
+ if (locale) descriptions[locale.toLowerCase()] = value;
222
+ else metadata.description = value;
223
+ return;
229
224
  }
230
225
  if (["repository", "docsURL", "authorURL"].includes(name)) {
231
226
  try {
232
227
  metadata[name] = reviewURL(value, name, name === "authorURL");
233
228
  } catch (error) {
234
229
  }
235
- continue;
230
+ return;
236
231
  }
237
232
  if (["name", "id", "author", "version", "license", "banner", "package", "unsandboxed"].includes(name)) {
238
233
  metadata[name] = value;
239
234
  }
235
+ };
236
+ for (const [name, raw, locale] of headerFields(text2)) record(name, raw, locale);
237
+ const block = BLOCK.exec(text2);
238
+ if (block !== null) {
239
+ for (const line of block[1].split("\n")) {
240
+ const field = FIELD.exec(line);
241
+ if (field === null) continue;
242
+ const [, name, raw] = field;
243
+ const localized = name === "description" ? /^([a-z]{2}(?:-[A-Za-z0-9]+)*)[ \t]+(.+)$/.exec(trimmed(raw)) : null;
244
+ if (localized === null) record(name, raw);
245
+ else record(name, localized[2], localized[1]);
246
+ }
240
247
  }
241
248
  if (Object.keys(descriptions).length > 0) metadata.descriptions = descriptions;
242
249
  return metadata;
243
250
  }
251
+ var HEADER_FIELDS = Object.freeze({
252
+ name: "name",
253
+ id: "id",
254
+ description: "description",
255
+ by: "author",
256
+ author: "author",
257
+ version: "version",
258
+ license: "license",
259
+ unsandboxed: "unsandboxed",
260
+ repository: "repository",
261
+ source: "repository",
262
+ "docs url": "docsURL",
263
+ docsurl: "docsURL",
264
+ "author url": "authorURL",
265
+ authorurl: "authorURL",
266
+ banner: "banner",
267
+ package: "package"
268
+ });
269
+ function headerFields(text2) {
270
+ const fields = [];
271
+ const seen = /* @__PURE__ */ new Set();
272
+ for (const line of text2.split("\n")) {
273
+ const comment = /^[ \t]*\/\/(.*)$/.exec(line);
274
+ if (comment === null) {
275
+ if (line.trim() === "") continue;
276
+ break;
277
+ }
278
+ const body = comment[1];
279
+ if (/^\s*Bundled extensions:\s*$/i.test(body)) break;
280
+ const field = /^ ?([A-Za-z][A-Za-z -]*?)(?:\[([a-z]{2,8}(?:-[A-Za-z0-9]{1,8})*)\])?:[ \t]*(.*)$/.exec(body);
281
+ if (field === null) continue;
282
+ const name = HEADER_FIELDS[field[1].trim().toLowerCase()];
283
+ const key = `${name}:${field[2] || ""}`;
284
+ if (!name || seen.has(key)) continue;
285
+ seen.add(key);
286
+ fields.push(field[2] ? [name, field[3], field[2]] : [name, field[3]]);
287
+ }
288
+ return fields;
289
+ }
244
290
  function getExtensionDescription(metadata, locale = "en") {
245
291
  const declared = metadata && metadata.descriptions;
246
292
  if (!declared) return metadata && metadata.description || "";
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 || "";
package/dist/react.cjs CHANGED
@@ -158,6 +158,24 @@ var formatMessage = (locale, key, values = {}) => {
158
158
  };
159
159
 
160
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
+ });
161
179
  function getExtensionDescription(metadata, locale = "en") {
162
180
  const declared = metadata && metadata.descriptions;
163
181
  if (!declared) return metadata && metadata.description || "";
package/dist/react.mjs CHANGED
@@ -125,6 +125,24 @@ var formatMessage = (locale, key, values = {}) => {
125
125
  };
126
126
 
127
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
+ });
128
146
  function getExtensionDescription(metadata, locale = "en") {
129
147
  const declared = metadata && metadata.descriptions;
130
148
  if (!declared) return metadata && metadata.description || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Batch extension security review, previews and per-project defaults for TurboWarp hosts",
5
5
  "type": "module",
6
6
  "author": {