@iasiv5/dsh-skins 1.5.22 → 1.5.23
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 +8 -56
- package/lib/index.js +12 -51
- package/package.json +1 -2
- package/assets/manifest.json +0 -61
- package/assets/meirenzhi/b_meirenzhi_mupeiling.webp +0 -0
- package/assets/meirenzhi/b_meirenzhi_nangongque.webp +0 -0
- package/assets/meirenzhi/b_meirenzhi_nangongwan.webp +0 -0
- package/assets/meirenzhi/b_meirenzhi_yinyue.webp +0 -0
- package/assets/meirenzhi/b_meirenzhi_yuntai.webp +0 -0
- package/assets/meirenzhi/b_meirenzhi_ziling.webp +0 -0
- package/assets/uefi-harness/b_uefi-harness_art.webp +0 -0
package/lib/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// src/index.js
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { cpSync, existsSync as existsSync2, mkdtempSync,
|
|
4
|
-
import { dirname as dirname2, join as
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { cpSync, existsSync as existsSync2, mkdtempSync, readdirSync as readdirSync2, renameSync as renameSync3, rmSync } from "node:fs";
|
|
4
|
+
import { dirname as dirname2, join as join2, resolve } from "node:path";
|
|
6
5
|
|
|
7
6
|
// src/host/personalization/store.js
|
|
8
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -1133,7 +1132,7 @@ function decodeDisplayName(request) {
|
|
|
1133
1132
|
}
|
|
1134
1133
|
}
|
|
1135
1134
|
function mountPersonalizationRoutes(host, options) {
|
|
1136
|
-
const { store, assetsBasePath = "/dsh-skins/assets", trustedHosts = []
|
|
1135
|
+
const { store, assetsBasePath = "/dsh-skins/assets", trustedHosts = [] } = options;
|
|
1137
1136
|
const disposers = [];
|
|
1138
1137
|
const fence = (request, response) => {
|
|
1139
1138
|
if (isTrustedRequest(request, typeof trustedHosts === "function" ? trustedHosts() : trustedHosts)) return true;
|
|
@@ -1220,8 +1219,7 @@ function mountPersonalizationRoutes(host, options) {
|
|
|
1220
1219
|
if (!fence(request, response)) return;
|
|
1221
1220
|
if (!method(request, response, "GET")) return;
|
|
1222
1221
|
try {
|
|
1223
|
-
const
|
|
1224
|
-
const blob = store.serveAsset(requestUrl) ?? serveBuiltinAsset?.(requestUrl) ?? null;
|
|
1222
|
+
const blob = store.serveAsset(String(request.url ?? ""));
|
|
1225
1223
|
if (blob === null) {
|
|
1226
1224
|
return sendJson(response, 404, { error: "asset not found", code: "ASSET_NOT_FOUND" });
|
|
1227
1225
|
}
|
|
@@ -1254,35 +1252,6 @@ function mountPersonalizationRoutes(host, options) {
|
|
|
1254
1252
|
};
|
|
1255
1253
|
}
|
|
1256
1254
|
|
|
1257
|
-
// src/host/builtin-assets.js
|
|
1258
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
1259
|
-
import { join as join2 } from "node:path";
|
|
1260
|
-
var BUILTIN_FILE_PATTERN = /^b_([a-z0-9][a-z0-9-]*)_([a-z0-9][a-z0-9-]*)\.webp$/;
|
|
1261
|
-
var ASSETS_PREFIX_PATTERN = /\/dsh-skins\/assets\/([^/]+)$/;
|
|
1262
|
-
function createBuiltinAssetServer({ assetsDir, manifest }) {
|
|
1263
|
-
const byName = /* @__PURE__ */ new Map();
|
|
1264
|
-
for (const entry of manifest?.entries ?? []) {
|
|
1265
|
-
const name2 = `b_${entry.skinId}_${entry.assetKey}.webp`;
|
|
1266
|
-
if (BUILTIN_FILE_PATTERN.test(name2)) byName.set(name2, entry);
|
|
1267
|
-
}
|
|
1268
|
-
return {
|
|
1269
|
-
serveBuiltinAsset(url) {
|
|
1270
|
-
if (typeof url !== "string") return null;
|
|
1271
|
-
const prefixMatch = ASSETS_PREFIX_PATTERN.exec(url.split("?")[0]);
|
|
1272
|
-
if (prefixMatch === null) return null;
|
|
1273
|
-
const entry = byName.get(prefixMatch[1]);
|
|
1274
|
-
if (entry === void 0) return null;
|
|
1275
|
-
if (entry.file.split("/").pop() !== prefixMatch[1]) return null;
|
|
1276
|
-
try {
|
|
1277
|
-
const buffer = readFileSync2(join2(assetsDir, entry.file));
|
|
1278
|
-
return { buffer, meta: { mime: entry.mime, byteLength: buffer.length, sha256: entry.sha256 } };
|
|
1279
|
-
} catch {
|
|
1280
|
-
return null;
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
1255
|
// src/host/trusted-hosts.js
|
|
1287
1256
|
function resolveTrustedHosts(ctx) {
|
|
1288
1257
|
let startup, runtime;
|
|
@@ -1301,27 +1270,27 @@ function resolveTrustedHosts(ctx) {
|
|
|
1301
1270
|
var name = "@iasiv5/dsh-skins";
|
|
1302
1271
|
function expandHomePath(path) {
|
|
1303
1272
|
if (path === "~") return homedir();
|
|
1304
|
-
if (path.startsWith("~/") || path.startsWith("~\\")) return
|
|
1273
|
+
if (path.startsWith("~/") || path.startsWith("~\\")) return join2(homedir(), path.slice(2));
|
|
1305
1274
|
return path;
|
|
1306
1275
|
}
|
|
1307
1276
|
function dshHome() {
|
|
1308
1277
|
const configured = process.env.DSH_HOME?.trim();
|
|
1309
|
-
return resolve(expandHomePath(configured ||
|
|
1278
|
+
return resolve(expandHomePath(configured || join2(homedir(), ".dsh")));
|
|
1310
1279
|
}
|
|
1311
1280
|
function hostProfileFor(root, cwd = process.cwd()) {
|
|
1312
1281
|
const normalized = (path) => process.platform === "win32" ? resolve(path).toLowerCase() : resolve(path);
|
|
1313
|
-
return normalized(cwd) === normalized(
|
|
1282
|
+
return normalized(cwd) === normalized(join2(expandHomePath(root), "profiles", "desktop")) ? "desktop" : "web";
|
|
1314
1283
|
}
|
|
1315
1284
|
function dataDirForProfile(root, profile) {
|
|
1316
1285
|
root = resolve(expandHomePath(root));
|
|
1317
|
-
const legacy =
|
|
1286
|
+
const legacy = join2(root, "dsh-skins");
|
|
1318
1287
|
if (profile !== "desktop") return legacy;
|
|
1319
|
-
const desktop =
|
|
1288
|
+
const desktop = join2(root, "dsh-skins-desktop");
|
|
1320
1289
|
if (existsSync2(desktop) || !existsSync2(legacy)) return desktop;
|
|
1321
|
-
const stage = mkdtempSync(
|
|
1290
|
+
const stage = mkdtempSync(join2(root, ".dsh-skins-desktop-migrate-"));
|
|
1322
1291
|
try {
|
|
1323
1292
|
for (const name2 of readdirSync2(legacy)) {
|
|
1324
|
-
cpSync(
|
|
1293
|
+
cpSync(join2(legacy, name2), join2(stage, name2), { recursive: true, force: false, errorOnExist: true });
|
|
1325
1294
|
}
|
|
1326
1295
|
renameSync3(stage, desktop);
|
|
1327
1296
|
} catch (error) {
|
|
@@ -1341,17 +1310,9 @@ function apply(ctx) {
|
|
|
1341
1310
|
profile
|
|
1342
1311
|
});
|
|
1343
1312
|
hostContext.effect(() => {
|
|
1344
|
-
let serveBuiltinAsset;
|
|
1345
|
-
try {
|
|
1346
|
-
const assetsDir = join3(dirname2(fileURLToPath(import.meta.url)), "..", "assets");
|
|
1347
|
-
const manifest = JSON.parse(readFileSync3(join3(assetsDir, "manifest.json"), "utf8"));
|
|
1348
|
-
serveBuiltinAsset = createBuiltinAssetServer({ assetsDir, manifest }).serveBuiltinAsset;
|
|
1349
|
-
} catch {
|
|
1350
|
-
}
|
|
1351
1313
|
return mountPersonalizationRoutes(hostContext, {
|
|
1352
1314
|
store: personalization,
|
|
1353
|
-
trustedHosts: () => resolveTrustedHosts(ctx)
|
|
1354
|
-
serveBuiltinAsset
|
|
1315
|
+
trustedHosts: () => resolveTrustedHosts(ctx)
|
|
1355
1316
|
});
|
|
1356
1317
|
}, "dsh-skins: personalization routes");
|
|
1357
1318
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@iasiv5/dsh-skins",
|
|
3
3
|
"description": "DSH Web 皮肤插件:多套品牌皮肤侧栏热切换。",
|
|
4
4
|
"icon": "./icon.svg",
|
|
5
|
-
"version": "1.5.
|
|
5
|
+
"version": "1.5.23",
|
|
6
6
|
"homepage": "https://github.com/iasiv5/dsh-skins#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"lib",
|
|
37
|
-
"assets",
|
|
38
37
|
"cordis.patch.yml",
|
|
39
38
|
"locale",
|
|
40
39
|
"README.md",
|
package/assets/manifest.json
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"generator": "scripts/build-builtin-manifest.mjs",
|
|
3
|
-
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"skinId": "meirenzhi",
|
|
6
|
-
"assetKey": "mupeiling",
|
|
7
|
-
"file": "meirenzhi/b_meirenzhi_mupeiling.webp",
|
|
8
|
-
"mime": "image/webp",
|
|
9
|
-
"bytes": 315928,
|
|
10
|
-
"sha256": "461d05d22ddf2b764094f5b7217e91c4c6941b01be34f7557cc2bced909fece8"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"skinId": "meirenzhi",
|
|
14
|
-
"assetKey": "nangongque",
|
|
15
|
-
"file": "meirenzhi/b_meirenzhi_nangongque.webp",
|
|
16
|
-
"mime": "image/webp",
|
|
17
|
-
"bytes": 495218,
|
|
18
|
-
"sha256": "f856964e66704d8e5f440558e3b224ae5c11a4da5fcdeb8516002c08de8bd45b"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"skinId": "meirenzhi",
|
|
22
|
-
"assetKey": "nangongwan",
|
|
23
|
-
"file": "meirenzhi/b_meirenzhi_nangongwan.webp",
|
|
24
|
-
"mime": "image/webp",
|
|
25
|
-
"bytes": 283616,
|
|
26
|
-
"sha256": "8a0d7c4bd18984e0a4235c88f678794d089f44d4469a8c7ccf051ad34b7ab805"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"skinId": "meirenzhi",
|
|
30
|
-
"assetKey": "yinyue",
|
|
31
|
-
"file": "meirenzhi/b_meirenzhi_yinyue.webp",
|
|
32
|
-
"mime": "image/webp",
|
|
33
|
-
"bytes": 417198,
|
|
34
|
-
"sha256": "d1e3d02014e07fc1b715ab30388ca617fae73fb442a6b177bc68ccc8a50103a0"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"skinId": "meirenzhi",
|
|
38
|
-
"assetKey": "yuntai",
|
|
39
|
-
"file": "meirenzhi/b_meirenzhi_yuntai.webp",
|
|
40
|
-
"mime": "image/webp",
|
|
41
|
-
"bytes": 283460,
|
|
42
|
-
"sha256": "7c3a833ca0d0d6c2f6449b750b34faf1700eb1d0beabfbf7d0d5f71584386282"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"skinId": "meirenzhi",
|
|
46
|
-
"assetKey": "ziling",
|
|
47
|
-
"file": "meirenzhi/b_meirenzhi_ziling.webp",
|
|
48
|
-
"mime": "image/webp",
|
|
49
|
-
"bytes": 415498,
|
|
50
|
-
"sha256": "009425f493e41e6370153251ac7f52c8c83e02ede0f42172ae503a562a6c889e"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"skinId": "uefi-harness",
|
|
54
|
-
"assetKey": "art",
|
|
55
|
-
"file": "uefi-harness/b_uefi-harness_art.webp",
|
|
56
|
-
"mime": "image/webp",
|
|
57
|
-
"bytes": 70110,
|
|
58
|
-
"sha256": "5b4509ce32e5f7b90a1e8456ed1f8aee257c1b629d23b05b6d8d3129b97ce006"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|