dsh-folia 2.9.0 → 2.9.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.
Files changed (2) hide show
  1. package/lib/client.js +34 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -16247,17 +16247,16 @@ window.__ModuleLoader__.load({
16247
16247
  */
16248
16248
  async function fetchSkinCss(id) {
16249
16249
  const enc = encodeURIComponent(id);
16250
- const origin = (typeof location !== "undefined" && location.origin) ? location.origin : "";
16251
16250
  const parts = [];
16252
16251
  let source = "";
16253
16252
  for (const part of ["stylesheet", "patches"]) {
16254
16253
  try {
16255
- const r = await apiFetch(origin + "/api/skin-center/v2/skins/" + enc + "/" + part, {
16256
- parse: false,
16257
- cache: "no-store",
16258
- });
16259
- if (r && r.ok && r.response) {
16260
- const text = await r.response.text();
16254
+ // 根相对路径 + 原生请求:桌面壳可能跑在 `dsh-app://` 下(`location.origin` 是 "null"),
16255
+ // 拼绝对 URL 会作废;`/api/...` 交给浏览器按文档解析才可靠
16256
+ //(皮肤中心自己的客户端用的也是这种写法)。
16257
+ const r = await apiRawResponse("/api/skin-center/v2/skins/" + enc + "/" + part);
16258
+ if (r && r.ok) {
16259
+ const text = await r.text();
16261
16260
  if (text && text.trim()) {
16262
16261
  parts.push(text);
16263
16262
  source = "skin-center";
@@ -22886,6 +22885,34 @@ window.__ModuleLoader__.load({
22886
22885
  /** DELETE(多数接口不返回体;需要时传 parse: true)。 */
22887
22886
  const apiDelete = (path, options) => apiFetch(path, Object.assign({ method: 'DELETE', parse: false }, options));
22888
22887
 
22888
+ /**
22889
+ * 根相对路径的**原生**请求(**不补 BASE**),返回原始 `Response`(失败给 null)。
22890
+ *
22891
+ * 用途:访问**同源其它插件**的路由 —— 典型是皮肤中心的 `/api/skin-center/v2/...`
22892
+ *(它把皮肤 CSS 做了强制作用域化,只有那条路由给的版本才能压过应用自身规则)。
22893
+ *
22894
+ * 为什么必须是**根相对路径**而不是 `location.origin + path`:桌面壳里文档可能跑在
22895
+ * 自定义协议下(`dsh-app://…`),此时 `location.origin` 是 `"null"`,拼出来的绝对 URL
22896
+ * 直接作废。`/api/...` 交给浏览器按文档解析,两种协议下都成立 —— 皮肤中心自己的客户端
22897
+ * 用的也正是这种写法。
22898
+ *
22899
+ * @param {string} path 以 `/` 开头的同源路径
22900
+ * @param {{ method?: string, cache?: string, headers?: object, fetch?: Function }} [options]
22901
+ * @returns {Promise<Response|null>}
22902
+ */
22903
+ async function apiRawResponse(path, options) {
22904
+ const o = options || {};
22905
+ const doFetch = pickFetch(o.fetch);
22906
+ if (!doFetch) return null;
22907
+ const init = { method: o.method || 'GET', cache: o.cache || 'no-store' };
22908
+ if (o.headers) init.headers = o.headers;
22909
+ try {
22910
+ return await doFetch(String(path), init);
22911
+ } catch {
22912
+ return null;
22913
+ }
22914
+ }
22915
+
22889
22916
  // ── 内联模块:src/occlusion.js —— 遮挡投递:/occlusion 轮询 + 缩放 + postMessage(1Hz,含退避与可见性暂停)(构建期注入;勿手改本段)──
22890
22917
  /**
22891
22918
  * occlusion.js — Linux 壳窗遮挡的**客户端轮询器**:宿主 `/occlusion` 快照 → 画布局部
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Folia 壁纸引擎:把本机 Wallpaper Engine 壁纸搬进 DSH 界面(场景实时渲染 / 视频 / 网页),内置液态玻璃与 Folia 吉祥物,并可从自建站点拉取壁纸。单包形态(组件已合并)。",
5
5
  "type": "module",
6
6
  "engines": {