@luckylillia-dev/luckylillia 9.0.6 → 9.0.7

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.
@@ -4126,7 +4126,7 @@ var Hono = class extends Hono$1 {
4126
4126
  //#endregion
4127
4127
  //#region src/version.ts
4128
4128
  var version_exports = /* @__PURE__ */ __exportAll({ version: () => version });
4129
- var version = "9.0.6";
4129
+ var version = "9.0.7";
4130
4130
  //#endregion
4131
4131
  //#region src/main/manager/protocol.ts
4132
4132
  var protocol_exports = /* @__PURE__ */ __exportAll({
@@ -4372,6 +4372,8 @@ var RegistryError = class extends Error {
4372
4372
  this.proxy = proxy;
4373
4373
  }
4374
4374
  };
4375
+ /** An integrity failure must never silently switch to a different publication. */
4376
+ var IntegrityError = class extends RegistryError {};
4375
4377
  var proxyHint = (proxy) => proxy ? `(经代理 ${proxy},请检查代理设置)` : "";
4376
4378
  function proxyOf(error) {
4377
4379
  const proxy = error?.proxy;
@@ -4397,6 +4399,7 @@ var Registry = class {
4397
4399
  verify(data, version);
4398
4400
  return data;
4399
4401
  } catch (e) {
4402
+ if (e instanceof IntegrityError) throw new IntegrityError(`${version.name}@${version.version}: cannot download ${version.dist.tarball}: ${e.message}`);
4400
4403
  if (e instanceof RegistryError) throw e;
4401
4404
  const proxy = proxyOf(e);
4402
4405
  throw new RegistryError(`${version.name}@${version.version}: cannot download ${version.dist.tarball}: ${reasonOf(e)}${proxyHint(proxy)}`, void 0, proxy);
@@ -4462,6 +4465,7 @@ var Registries = class {
4462
4465
  if (!need || need(document)) return document;
4463
4466
  incomplete ??= document;
4464
4467
  } catch (e) {
4468
+ if (e instanceof IntegrityError) throw e;
4465
4469
  errors.push(this.failed(registry, e));
4466
4470
  }
4467
4471
  if (incomplete) return incomplete;
@@ -4543,6 +4547,8 @@ function newerLatest(a, b) {
4543
4547
  }
4544
4548
  }
4545
4549
  function combine(errors) {
4550
+ const integrity = errors.find((error) => error instanceof IntegrityError);
4551
+ if (integrity) return integrity;
4546
4552
  if (errors.length === 1) return errors[0];
4547
4553
  const status = errors.every((error) => error.status === 404) ? 404 : void 0;
4548
4554
  const firstProxy = errors[0]?.proxy;
@@ -4638,11 +4644,11 @@ function verify(data, version) {
4638
4644
  }] : [];
4639
4645
  }).sort((a, b) => STRENGTH.indexOf(b.algorithm) - STRENGTH.indexOf(a.algorithm))[0];
4640
4646
  if (strongest) {
4641
- if (createHash(strongest.algorithm).update(data).digest("base64") !== strongest.digest) throw new Error(`${label}: tarball fails its ${strongest.algorithm} integrity check`);
4647
+ if (createHash(strongest.algorithm).update(data).digest("base64") !== strongest.digest) throw new IntegrityError(`${label}: tarball fails its ${strongest.algorithm} integrity check`);
4642
4648
  return;
4643
4649
  }
4644
- if (!version.dist.shasum) throw new Error(`${label}: the registry gives no checksum for the tarball`);
4645
- if (createHash("sha1").update(data).digest("hex") !== version.dist.shasum.toLowerCase()) throw new Error(`${label}: tarball fails its sha1 check`);
4650
+ if (!version.dist.shasum) throw new IntegrityError(`${label}: the registry gives no checksum for the tarball`);
4651
+ if (createHash("sha1").update(data).digest("hex") !== version.dist.shasum.toLowerCase()) throw new IntegrityError(`${label}: tarball fails its sha1 check`);
4646
4652
  }
4647
4653
  /**
4648
4654
  * A dependency spec as the package to fetch and the range to pick from: `npm:<name>@<range>` aliases another
@@ -6719,6 +6725,35 @@ function isScreenshot(value) {
6719
6725
  return !Object.hasOwn(item, "caption") || typeof item.caption === "string" && item.caption.length > 0 && item.caption.length <= 200 && item.caption === item.caption.trim() && !/[\u0000-\u001f\u007f]/.test(item.caption);
6720
6726
  }
6721
6727
  //#endregion
6728
+ //#region src/plugin/internal/tool/market/github-source.ts
6729
+ var DEFAULT_GITHUB_MIRRORS = [
6730
+ "https://gh-proxy.com/",
6731
+ "https://ghfast.top/",
6732
+ "https://eo.gh-proxy.cn/github/"
6733
+ ];
6734
+ function isGitHubSource(value) {
6735
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
6736
+ const source = value;
6737
+ const segment = (value) => typeof value === "string" && value.length > 0 && value.length <= 256 && value === value.trim() && !/[\\/\u0000-\u001f\u007f]/.test(value) && value !== "." && value !== "..";
6738
+ return Object.keys(source).every((key) => [
6739
+ "tag",
6740
+ "asset",
6741
+ "integrity"
6742
+ ].includes(key)) && segment(source.tag) && segment(source.asset) && /\.(tgz|tar\.gz)$/.test(source.asset) && typeof source.integrity === "string" && /^sha512-[A-Za-z0-9+/]{86}==$/.test(source.integrity);
6743
+ }
6744
+ function isGitHubMirror(value) {
6745
+ if (typeof value !== "string" || value !== value.trim() || /[\s\\]/.test(value)) return false;
6746
+ try {
6747
+ const url = new URL(value);
6748
+ return url.protocol === "https:" && !!url.hostname && !url.username && !url.password && !url.search && !url.hash;
6749
+ } catch {
6750
+ return false;
6751
+ }
6752
+ }
6753
+ function githubAssetUrl(repository, source) {
6754
+ return `${repository}/releases/download/${encodeURIComponent(source.tag)}/${encodeURIComponent(source.asset)}`;
6755
+ }
6756
+ //#endregion
6722
6757
  //#region src/plugin/internal/tool/market/catalog.ts
6723
6758
  var MARKET_PACKAGE = "@luckylillia-dev/market";
6724
6759
  var gunzipAsync$1 = promisify(gunzip);
@@ -6786,8 +6821,10 @@ function parseCatalog(plugins) {
6786
6821
  "repository",
6787
6822
  "icon",
6788
6823
  "screenshots",
6789
- "examples"
6824
+ "examples",
6825
+ "github"
6790
6826
  ])) fail("插件条目包含无效字段");
6827
+ if (Object.hasOwn(plugin, "github") && !isGitHubSource(plugin.github)) fail("插件 GitHub 来源必须包含有效的 tag、压缩包文件名和 SHA-512 integrity");
6791
6828
  if (!isPackageName(plugin.name)) fail("插件条目的 npm 包名无效");
6792
6829
  const name = plugin.name;
6793
6830
  if (entries.has(name)) fail(`插件重复登记:${name}`);
@@ -6820,7 +6857,8 @@ function parseCatalog(plugins) {
6820
6857
  }),
6821
6858
  ...plugin.icon ? { icon: plugin.icon } : {},
6822
6859
  ...screenshots?.length ? { screenshots: Object.freeze(screenshots.map((item) => typeof item === "string" ? item : Object.freeze({ ...item }))) } : {},
6823
- version
6860
+ version,
6861
+ ...plugin.github ? { github: Object.freeze({ ...plugin.github }) } : {}
6824
6862
  }));
6825
6863
  }
6826
6864
  return entries;
@@ -6889,7 +6927,8 @@ var MarketSchema = Schema.object({
6889
6927
  "https://mirrors.huaweicloud.com/repository/npm",
6890
6928
  "https://mirrors.cloud.tencent.com/npm"
6891
6929
  ]).description("镜像源:下载插件和依赖时按顺序先用它们,哪个有需要的版本就用哪个,都没有再用主源"),
6892
- catalog: Schema.string().default(MARKET_PACKAGE).description("提供插件列表和已审核版本的 npm 目录包,不清楚时保持默认即可")
6930
+ catalog: Schema.string().default(MARKET_PACKAGE).description("提供插件列表和已审核版本的 npm 目录包,不清楚时保持默认即可"),
6931
+ githubMirrors: Schema.array(Schema.string().role("link")).default(DEFAULT_GITHUB_MIRRORS).description("GitHub 下载镜像前缀,按顺序尝试,最后直连 GitHub。支持 /github/ 等路径;留空仅直连")
6893
6932
  });
6894
6933
  /** Every registry to use: the main one first, then the mirrors (Registries orders them per lookup) */
6895
6934
  var registriesOf = (settings) => [settings.registry, ...settings.mirrors ?? []];
@@ -6915,10 +6954,12 @@ var marketSettings = {
6915
6954
  mirrors.push(mirror);
6916
6955
  }
6917
6956
  }
6957
+ const githubMirrors = Array.isArray(value.githubMirrors) ? [...new Set(value.githubMirrors.map((raw) => typeof raw === "string" ? raw.trim().replace(/\/+$/, "") + "/" : raw).filter((raw) => raw !== "/"))] : void 0;
6918
6958
  return {
6919
6959
  registry,
6920
6960
  mirrors,
6921
- catalog: value.catalog?.trim()
6961
+ catalog: value.catalog?.trim(),
6962
+ ...githubMirrors === void 0 ? {} : { githubMirrors }
6922
6963
  };
6923
6964
  },
6924
6965
  check(value) {
@@ -6935,6 +6976,10 @@ var marketSettings = {
6935
6976
  path: ["catalog"],
6936
6977
  message: "要填有效的 npm 包名,不能包含版本、URL 或文件路径"
6937
6978
  });
6979
+ for (const [index, mirror] of (value.githubMirrors ?? []).entries()) if (!isGitHubMirror(mirror)) issues.push({
6980
+ path: ["githubMirrors", String(index)],
6981
+ message: "要填不含凭据、查询参数和片段的 HTTPS 镜像前缀,可包含路径"
6982
+ });
6938
6983
  return issues;
6939
6984
  }
6940
6985
  };
@@ -7016,7 +7061,7 @@ var CoreUpdater = class {
7016
7061
  current;
7017
7062
  constructor(options) {
7018
7063
  this.options = options;
7019
- this.current = options.current ?? "9.0.6";
7064
+ this.current = options.current ?? "9.0.7";
7020
7065
  }
7021
7066
  status() {
7022
7067
  const latest = this.latest;
@@ -7428,6 +7473,6 @@ function createCoreUpdateRoutes(updater) {
7428
7473
  return router;
7429
7474
  }
7430
7475
  //#endregion
7431
- export { Hono as $, Registries as A, require_dist as At, installHostLifecycle as B, getPluginDirs as Bt, scanPluginRoots as C, normalizeScope as Ct, removeScannedPackage as D, deepMerge as Dt, cleanupRemovedPackages as E, platform_exports as Et, parseSpec as F, resolveInstance as Ft, GATEWAY_SECRET_HEADER as G, LOG_DIR as Gt, GATEWAY_INSTANCE_HEADER as H, isDockerEnvironment as Ht, pickVersion as I, DEFAULT_INSTANCE as It, isManaged as J, globalVars_exports as Jt, MANAGED_ENV as K, STATE_DIR as Kt, lockInstance as L, INVALID_INSTANCE_NAME as Lt, isExactVersion as M, configPaths_exports as Mt, isPackageName as N, currentInstance as Nt, scannedPackagePath as O, mergeNewProperties as Ot, matches as P, instance_exports as Pt, version_exports as Q, __toESM as Qt, lockManager as R, isValidInstanceName as Rt, resolveMain as S, acceptsScope as St, sdkRangeOf as T, normalizePlatformId as Tt, GATEWAY_PREFIX_HEADER as U, isPluginHmr as Ut, GATEWAY_AUTH_HEADER as V, isDevMode as Vt, GATEWAY_SECRET_ENV as W, DATA_DIR as Wt, protocol_exports as X, __exportAll as Xt, isManagerMessage as Y, __commonJSMin as Yt, version as Z, __require as Zt, manifest_exports as _, templateSection as _t, scheduleAutoCheck as a, migrateRenamedPackages as at, parsePluginDependencies as b, newEntryId as bt, marketSettings as c, renameNativeQQSettings as ct, extractPackage as d, renamed_exports as dt, HtmlEscapedCallbackPhase as et, readTarStream as f, withCurrentNames as ft, isInside as g, templateConfig as gt, isImagePath as h, DEPRECATED_KEYS as ht, installDirOf as i, migrateNTQQMessaging as it, RegistryError as j, configPaths as jt, require_semver as k, JsonFile as kt, registriesOf as l, RENAMED_PACKAGES as lt, SDK_PACKAGE as m, ADAPTER_KEYS as mt, CoreUpdater as n, liftBuiltinSettings as nt, updateBlocker as o, migrateToInstances as ot, PLUGIN_CATEGORIES as p, ADAPTER_ENTRIES as pt, isInstanceMessage as q, TEMP_DIR as qt, coreUpdate_exports as r, migrateExtractedPlugins as rt, MarketSchema as s, migrateWebuiToken as st, CoreUpdateError as t, resolveCallback as tt, Catalog as u, currentPackageName as ut, matchesPluginVersion as v, upgradeConfig as vt, sdkIncompatibility as w, normalizePlatform as wt, readPluginPackage as x, normalizeUi as xt, normalizeService as y, PluginStore as yt, runningInstances as z, environment_exports as zt };
7476
+ export { isManaged as $, globalVars_exports as $t, removeScannedPackage as A, normalizePlatformId as At, parseSpec as B, resolveInstance as Bt, parsePluginDependencies as C, upgradeConfig as Ct, sdkIncompatibility as D, acceptsScope as Dt, scanPluginRoots as E, normalizeUi as Et, Registry as F, require_dist as Ft, installHostLifecycle as G, getPluginDirs as Gt, lockInstance as H, INVALID_INSTANCE_NAME as Ht, RegistryError as I, configPaths as It, GATEWAY_PREFIX_HEADER as J, isPluginHmr as Jt, GATEWAY_AUTH_HEADER as K, isDevMode as Kt, isExactVersion as L, configPaths_exports as Lt, require_semver as M, deepMerge as Mt, IntegrityError as N, mergeNewProperties as Nt, sdkRangeOf as O, normalizeScope as Ot, Registries as P, JsonFile as Pt, isInstanceMessage as Q, TEMP_DIR as Qt, isPackageName as R, currentInstance as Rt, normalizeService as S, templateSection as St, resolveMain as T, newEntryId as Tt, lockManager as U, isValidInstanceName as Ut, pickVersion as V, DEFAULT_INSTANCE as Vt, runningInstances as W, environment_exports as Wt, GATEWAY_SECRET_HEADER as X, LOG_DIR as Xt, GATEWAY_SECRET_ENV as Y, DATA_DIR as Yt, MANAGED_ENV as Z, STATE_DIR as Zt, SDK_PACKAGE as _, withCurrentNames as _t, scheduleAutoCheck as a, HtmlEscapedCallbackPhase as at, manifest_exports as b, DEPRECATED_KEYS as bt, marketSettings as c, migrateExtractedPlugins as ct, DEFAULT_GITHUB_MIRRORS as d, migrateToInstances as dt, __commonJSMin as en, isManagerMessage as et, githubAssetUrl as f, migrateWebuiToken as ft, PLUGIN_CATEGORIES as g, renamed_exports as gt, readTarStream as h, currentPackageName as ht, installDirOf as i, Hono as it, scannedPackagePath as j, platform_exports as jt, cleanupRemovedPackages as k, normalizePlatform as kt, registriesOf as l, migrateNTQQMessaging as lt, extractPackage as m, RENAMED_PACKAGES as mt, CoreUpdater as n, __require as nn, version as nt, updateBlocker as o, resolveCallback as ot, isGitHubMirror as p, renameNativeQQSettings as pt, GATEWAY_INSTANCE_HEADER as q, isDockerEnvironment as qt, coreUpdate_exports as r, __toESM as rn, version_exports as rt, MarketSchema as s, liftBuiltinSettings as st, CoreUpdateError as t, __exportAll as tn, protocol_exports as tt, Catalog as u, migrateRenamedPackages as ut, isImagePath as v, ADAPTER_ENTRIES as vt, readPluginPackage as w, PluginStore as wt, matchesPluginVersion as x, templateConfig as xt, isInside as y, ADAPTER_KEYS as yt, matches as z, instance_exports as zt };
7432
7477
 
7433
- //# sourceMappingURL=coreUpdate-CEtHqh6r.js.map
7478
+ //# sourceMappingURL=coreUpdate-Bhae6JrK.js.map