@wenbin_wb/dsh-bridge 1.0.1 → 1.0.3

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,6 @@
1
1
  // dsh-bridge 客户端打包:client/index.js → client/client.js
2
2
  import { mkdir, writeFile } from 'node:fs/promises';
3
+ import { readFileSync } from 'node:fs';
3
4
  import { dirname, resolve } from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
5
6
  import { build } from 'esbuild';
@@ -7,7 +8,8 @@ import { build } from 'esbuild';
7
8
  const sourceDir = dirname(fileURLToPath(import.meta.url));
8
9
  const packageRoot = resolve(sourceDir, '..');
9
10
  const outputPath = resolve(packageRoot, 'client/client.js');
10
- const loaderId = 'dsh-bridge';
11
+ // loaderId 必须与 package.json 的 name 一致(DSH 用它来验证 bundle 注册)
12
+ const loaderId = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8')).name;
11
13
 
12
14
  const result = await build({
13
15
  entryPoints: [resolve(sourceDir, 'index.js')],
package/client/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: "dsh-bridge",
2
+ id: "@wenbin_wb/dsh-bridge",
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
package/lib/index.js CHANGED
@@ -8,7 +8,9 @@
8
8
  import { createServer, request as httpRequest } from 'node:http';
9
9
  import { get as httpsGet } from 'node:https';
10
10
  import { networkInterfaces, homedir } from 'node:os';
11
- import { join } from 'node:path';
11
+ import { join, dirname } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { readFileSync } from 'node:fs';
12
14
  import { readFile, writeFile, mkdir, unlink } from 'node:fs/promises';
13
15
  import QRCode from 'qrcode';
14
16
  import { installBridgeRpc } from './bridge-rpc.js';
@@ -18,7 +20,9 @@ import { CloudflaredManager } from './cloudflared-manager.mjs';
18
20
  const name = 'dsh-bridge';
19
21
  const inject = ['connection', 'webServer'];
20
22
 
21
- const VERSION = '1.0.1';
23
+ // package.json 动态读取版本号,发版只需改 package.json 一处
24
+ const PACKAGE_JSON = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8'));
25
+ const VERSION = PACKAGE_JSON.version ?? '0.0.0';
22
26
 
23
27
  /**
24
28
  * 选择最佳局域网 IP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenbin_wb/dsh-bridge",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "DSH 多渠道接入桥:局域网二维码、自建隧道、机器人集成",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",