@linxin666/dsh-client-ui-skin-center 0.4.19 → 0.4.20

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/lib/client.js CHANGED
@@ -84,6 +84,8 @@ window.__ModuleLoader__.load({
84
84
  }
85
85
  };
86
86
  }
87
+ /** Document-relative v2 API base for the browser half and injected hrefs. */
88
+ const CLIENT_API_BASE = "/api/skin-center/v2".slice(1);
87
89
  //#endregion
88
90
  //#region src/client/runtime/semantic-adapter.ts
89
91
  /**
@@ -1253,7 +1255,7 @@ window.__ModuleLoader__.load({
1253
1255
  function createSkinController(deps) {
1254
1256
  const doc = deps.doc;
1255
1257
  const ledger = deps.ledger;
1256
- const apiBase = deps.apiBase ?? "/api/skin-center/v2";
1258
+ const apiBase = deps.apiBase ?? CLIENT_API_BASE;
1257
1259
  const fetchImpl = deps.fetchImpl ?? fetch.bind(doc.defaultView);
1258
1260
  const layers = ensureDecorationLayers(doc);
1259
1261
  const onError = deps.onError ?? (() => {});
@@ -1681,7 +1683,7 @@ window.__ModuleLoader__.load({
1681
1683
  }
1682
1684
  function bootSkinRuntime(options = {}) {
1683
1685
  const doc = options.doc ?? document;
1684
- const apiBase = options.apiBase ?? "/api/skin-center/v2";
1686
+ const apiBase = options.apiBase ?? CLIENT_API_BASE;
1685
1687
  const fetchImpl = options.fetchImpl ?? fetch.bind(doc.defaultView);
1686
1688
  const controller = createSkinController({
1687
1689
  doc,
@@ -2223,8 +2225,8 @@ window.__ModuleLoader__.load({
2223
2225
  * Nothing renders when the probe cannot be reached, so an older host never
2224
2226
  * shows a false "not installed" prompt.
2225
2227
  */
2226
- /** Host base path of the probe (mirrors src/routes-v2.ts). */
2227
- const EXTERNAL_WALLPAPER_API = "/api/skin-center/v2/external-wallpaper";
2228
+ /** Document-relative probe URL (the client base in src/core/api-prefix.ts). */
2229
+ const EXTERNAL_WALLPAPER_API = `${CLIENT_API_BASE}/external-wallpaper`;
2228
2230
  /** Fallbacks used only when the host omits a field. */
2229
2231
  const FALLBACK = {
2230
2232
  packageName: "dsh-plugin-wallpaper-engine",
@@ -3375,7 +3377,7 @@ window.__ModuleLoader__.load({
3375
3377
  setVerifying(true);
3376
3378
  setError(null);
3377
3379
  try {
3378
- const res = await fetch("/api/skin-center/v2/verify", {
3380
+ const res = await fetch(`${CLIENT_API_BASE}/verify`, {
3379
3381
  method: "POST",
3380
3382
  headers: { "content-type": "application/json" },
3381
3383
  body: JSON.stringify({ autoRepair: true })
@@ -3418,7 +3420,7 @@ window.__ModuleLoader__.load({
3418
3420
  });
3419
3421
  let targets;
3420
3422
  try {
3421
- const res = await fetch("/api/skin-center/v2/skins/versions", { cache: "no-store" });
3423
+ const res = await fetch(`${CLIENT_API_BASE}/skins/versions`, { cache: "no-store" });
3422
3424
  const json = await res.json().catch(() => null);
3423
3425
  if (!res.ok || json?.ok !== true || !Array.isArray(json.rows)) throw new Error("versions-unavailable");
3424
3426
  targets = json.rows.filter((row) => row.outdated).map((row) => row.id);
@@ -3451,7 +3453,7 @@ window.__ModuleLoader__.load({
3451
3453
  note: ""
3452
3454
  });
3453
3455
  try {
3454
- if (!(await fetch(`/api/skin-center/v2/skins/${encodeURIComponent(id)}/repair`, { method: "POST" })).ok) failed++;
3456
+ if (!(await fetch(`${CLIENT_API_BASE}/skins/${encodeURIComponent(id)}/repair`, { method: "POST" })).ok) failed++;
3455
3457
  } catch {
3456
3458
  failed++;
3457
3459
  }
@@ -3509,7 +3511,7 @@ window.__ModuleLoader__.load({
3509
3511
  note: ""
3510
3512
  });
3511
3513
  try {
3512
- if (!(await fetch(`/api/skin-center/v2/skins/${encodeURIComponent(skin.manifest.id)}/uninstall`, { method: "POST" })).ok) failed++;
3514
+ if (!(await fetch(`${CLIENT_API_BASE}/skins/${encodeURIComponent(skin.manifest.id)}/uninstall`, { method: "POST" })).ok) failed++;
3513
3515
  } catch {
3514
3516
  failed++;
3515
3517
  }
@@ -3533,7 +3535,7 @@ window.__ModuleLoader__.load({
3533
3535
  try {
3534
3536
  if (tryingId === id) await preview.runSkin(() => runtime.controller.exitTryOn());
3535
3537
  if (activeId === id) await preview.runSkin(restoreOfficialLook);
3536
- const res = await fetch(`/api/skin-center/v2/skins/${encodeURIComponent(id)}/uninstall`, {
3538
+ const res = await fetch(`${CLIENT_API_BASE}/skins/${encodeURIComponent(id)}/uninstall`, {
3537
3539
  method: "POST",
3538
3540
  headers: { "content-type": "application/json" }
3539
3541
  });
@@ -3548,7 +3550,7 @@ window.__ModuleLoader__.load({
3548
3550
  }
3549
3551
  };
3550
3552
  const dark = document.body.hasAttribute("data-ds-dark-theme");
3551
- const apiBase = runtime.apiBase ?? "/api/skin-center/v2";
3553
+ const apiBase = runtime.apiBase ?? CLIENT_API_BASE;
3552
3554
  /** One row: try-on control + apply button + optional uninstall. Shared by the official card and every skin card. */
3553
3555
  const actionButtons = (opts) => {
3554
3556
  const isUser = opts.entry?.origin === "user";
@@ -5760,7 +5762,7 @@ window.__ModuleLoader__.load({
5760
5762
  /** The building package's version, when the bundle carries it. */
5761
5763
  function bakedVersion() {
5762
5764
  try {
5763
- return "0.4.19";
5765
+ return "0.4.20";
5764
5766
  } catch {
5765
5767
  return;
5766
5768
  }
@@ -5981,7 +5983,7 @@ window.__ModuleLoader__.load({
5981
5983
  */
5982
5984
  function beatHeartbeat() {
5983
5985
  reportDailyHeartbeat(SELF_ITEM);
5984
- fetch("/api/skin-center/v2/catalog").then((res) => res.ok ? res.json() : null).then((catalog) => {
5986
+ fetch(`${CLIENT_API_BASE}/catalog`).then((res) => res.ok ? res.json() : null).then((catalog) => {
5985
5987
  if (!catalog || !Array.isArray(catalog.skins)) return;
5986
5988
  const items = [...SELF_ITEM];
5987
5989
  for (const skin of catalog.skins) {
@@ -6020,7 +6022,7 @@ window.__ModuleLoader__.load({
6020
6022
  }, "ui-skin-center: body scope");
6021
6023
  const theme = ctx.get("theme");
6022
6024
  const settings = bindConfigForm(ctx);
6023
- const V2_ACTIVE_URL = "/api/skin-center/v2/active";
6025
+ const V2_ACTIVE_URL = `${CLIENT_API_BASE}/active`;
6024
6026
  let persistTimer = null;
6025
6027
  const postBackground = (next, keepalive = false) => {
6026
6028
  fetch(V2_ACTIVE_URL, {