dsh-pocket-relay 1.0.0 → 1.0.2

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/client/build.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // dsh-pocket 网页客户端打包:client/index.jsx → client/client.js
2
- import { mkdir, writeFile } from 'node:fs/promises';
1
+ // dsh-pocket-relay 网页客户端打包:client/index.jsx → client/client.js
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
3
  import { dirname, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { build } from 'esbuild';
@@ -7,7 +7,18 @@ import { build } from 'esbuild';
7
7
  const sourceDir = dirname(fileURLToPath(import.meta.url));
8
8
  const packageRoot = resolve(sourceDir, '..');
9
9
  const outputPath = resolve(packageRoot, 'client/client.js');
10
- const loaderId = process.env.DSH_POCKET_CLIENT_ID ?? 'dsh-pocket';
10
+
11
+ // loader id 必须与 package.json 的 name 一致:DSH 按包名去 __ModuleLoader__
12
+ // 里找这个前端模块,对不上就会加载了文件却报
13
+ // "loaded without registering <包名> via __ModuleLoader__.load",整个客户端
14
+ // 插件加载失败。这里直接读 package.json,避免再出现「改了包名但这里没跟着改」
15
+ // 的脱节——曾经硬编码 'dsh-pocket',包名改成 dsh-pocket-relay 后就踩了这个坑。
16
+ //
17
+ // 注意与 cordis.patch.yml 的 id 区分:那个 id 是市场「启用/禁用」开关的身份键,
18
+ // 沿用历史值 dsh-pocket,与这里的 loader id 无关(参照 dshmarket:它的 patch id
19
+ // 是 dsh-market,而 loader id 与包名一致,都是 dshmarket)。
20
+ const pkg = JSON.parse(await readFile(resolve(packageRoot, 'package.json'), 'utf8'));
21
+ const loaderId = process.env.DSH_POCKET_CLIENT_ID ?? pkg.name;
11
22
 
12
23
  const result = await build({
13
24
  entryPoints: [resolve(sourceDir, 'index.jsx')],
package/client/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: "dsh-pocket",
2
+ id: "dsh-pocket-relay",
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
package/package.json CHANGED
@@ -85,5 +85,5 @@
85
85
  "access": "public",
86
86
  "registry": "https://registry.npmjs.org/"
87
87
  },
88
- "version": "1.0.0"
88
+ "version": "1.0.2"
89
89
  }