@nsnanocat/preference-panes 0.9.16 → 1.0.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.
@@ -9,6 +9,6 @@
9
9
  </head>
10
10
  <body>
11
11
  <main id="preferences"></main>
12
- <script type="module" src="/settings/assets/app.mjs?v=0.9.16"></script>
12
+ <script type="module" src="/settings/assets/app.mjs?v=1.0.0"></script>
13
13
  </body>
14
14
  </html>
@@ -275,24 +275,25 @@ class ModuleFrame extends EventTarget {
275
275
  * @typedef {object} ModuleProbeOptions
276
276
  * @property {typeof globalThis.fetch} [fetch] 可注入的 fetch / Injectable fetch.
277
277
  * @property {AbortSignal} [signal] 外部取消信号 / External cancellation signal.
278
+ * @property {string} [json] BoxJS JSON 来源,将随探测请求头传递 / BoxJS JSON source sent in the probe header.
278
279
  * @property {number} [timeout] 超时毫秒数,默认 3500 / Timeout in milliseconds, defaults to 3500.
279
280
  */
280
281
 
281
282
  /**
282
- * 通过模块 JSON Mock 的 HEAD 响应检测安装状态和业务版本。
283
- * Probe installation and business version from the native HEAD response of a module JSON Mock.
284
- * @param {string | URL} url 配置 Mock 地址 / Configuration Mock URL.
283
+ * 通过模块 API 的 HEAD 响应检测安装状态和业务版本。
284
+ * Probe installation and business version from the module API HEAD response.
285
+ * @param {string | URL} url 模块 API 地址 / Module API URL.
285
286
  * @param {ModuleProbeOptions} [options] 请求选项 / Request options.
286
287
  * @returns {Promise<Response>} 原始 HTTP 响应,可直接读取 status 和响应头 / Native HTTP response; read status and headers directly.
287
288
  */
288
- async function probeModule(url, { fetch: request = globalThis.fetch, signal, timeout = 3500 } = {}) {
289
+ async function probeModule(url, { fetch: request = globalThis.fetch, json, signal, timeout = 3500 } = {}) {
289
290
  const controller = new AbortController();
290
291
  const abort = () => controller.abort();
291
292
  if (signal?.aborted) abort();
292
293
  signal?.addEventListener("abort", abort, { once: true });
293
294
  const timer = setTimeout(() => controller.abort(), timeout);
294
295
  try {
295
- return await request(url, { method: "HEAD", cache: "no-store", credentials: "omit", signal: controller.signal });
296
+ return await request(url, { method: "HEAD", cache: "no-store", credentials: "omit", signal: controller.signal, headers: json ? { "X-PreferencePanes-JSON": json } : undefined });
296
297
  } finally {
297
298
  clearTimeout(timer);
298
299
  signal?.removeEventListener("abort", abort);
@@ -330,7 +331,7 @@ class ModuleStatus extends EventTarget {
330
331
  /**
331
332
  * 每次进入重新探测,取消旧请求并忽略其迟到结果。
332
333
  * Reprobe on entry, cancelling old requests and ignoring late results.
333
- * @param {string | URL} url 配置 Mock 地址 / Configuration Mock URL.
334
+ * @param {string | URL} url 模块 API 地址 / Module API URL.
334
335
  * @param {ModuleProbeOptions} [options] 请求选项 / Request options.
335
336
  * @returns {Promise<Response | undefined>} 原始响应;被取消时无返回值 / Native response; undefined when cancelled.
336
337
  */