@decentnetwork/beagle 0.1.128 → 0.1.129

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.
@@ -26,10 +26,12 @@
26
26
  exits:
27
27
  # --- China (China-only / GFW-blocked-from-outside sites) ---
28
28
  - name: cn
29
+ label: ea-1
29
30
  userid: 5Aj6uQMd1cNRb9cGT4AwHCN4RdVZjfaGLtgKGhdP1LzN
30
31
  virtual_ip: 10.86.1.15
31
32
  region: china
32
33
  - name: sh
34
+ label: ea-2
33
35
  userid: 6D1PLSVqbSpcxnDMAd8ZXLWycYveeP2hU4g3igDQEqA7
34
36
  virtual_ip: 10.86.1.16
35
37
  region: china
@@ -1,4 +1,4 @@
1
- window.__DK_UI_VERSION="0.1.128";
1
+ window.__DK_UI_VERSION="0.1.129";
2
2
  "use strict";
3
3
  (() => {
4
4
  // packages/beagle-ui/dist/beagle-ui.js
package/dist/exits.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export interface DefaultExit {
2
2
  name: string;
3
+ /** What the panel shows for this exit, when the name is not for users. */
4
+ label?: string;
3
5
  userid: string;
4
6
  virtual_ip?: string;
5
7
  region?: string;
package/dist/server.js CHANGED
@@ -35,6 +35,15 @@ import { globalPrefixOf } from "./global-prefix.js";
35
35
  // Directory holding the built desktop UI bundle (index.html, app.js, vendor/).
36
36
  // scripts/build-ui.mjs emits it next to this compiled module at dist/ui/desktop/.
37
37
  const DESKTOP_DIR = join(dirname(fileURLToPath(import.meta.url)), "desktop");
38
+ /** How an exit region is shown to users. The keys are routing keys (routes.yaml
39
+ * region names, the router's built-in domain lists) and stay as they are; the
40
+ * flag and label are display only. App strings never carry PRC place names
41
+ * (CLAUDE.md), so the "china" region is shown as East Asia. */
42
+ const REGION_META = {
43
+ china: { flag: "EA", label: "East Asia" },
44
+ japan: { flag: "JP", label: "Japan" },
45
+ us: { flag: "US", label: "United States" },
46
+ };
38
47
  /** Set routes.yaml's top-level `default:` to `value`, keeping the rest of the
39
48
  * file as written. False when there is no file or no such line to change. */
40
49
  function writeRoutesDefault(path, value) {
@@ -2116,7 +2125,8 @@ export function startBeagleServer(opts) {
2116
2125
  channel: opts.meExtra?.channel ?? "@next",
2117
2126
  wire: opts.meExtra?.wire ?? "163",
2118
2127
  isExit: !!meExit,
2119
- exitRegion: meExit?.region ?? null,
2128
+ // The display tag, not the routing key (see REGION_META).
2129
+ exitRegion: meExit?.region ? REGION_META[meExit.region]?.flag ?? meExit.region : null,
2120
2130
  // null = backend didn't report it (daemon); the UI then hides the
2121
2131
  // toggle rather than showing a state it cannot know.
2122
2132
  autoAccept: typeof node.autoAccept === "boolean" ? node.autoAccept : null,
@@ -2222,11 +2232,6 @@ export function startBeagleServer(opts) {
2222
2232
  onlineIps.add(ip);
2223
2233
  }
2224
2234
  }
2225
- const regionMeta = {
2226
- china: { flag: "CN", label: "China" },
2227
- japan: { flag: "JP", label: "Japan" },
2228
- us: { flag: "US", label: "United States" },
2229
- };
2230
2235
  const byRegion = new Map();
2231
2236
  for (const e of DEFAULT_EXITS) {
2232
2237
  if (!e.virtual_ip)
@@ -2236,7 +2241,7 @@ export function startBeagleServer(opts) {
2236
2241
  byRegion.set(region, []);
2237
2242
  byRegion.get(region).push({
2238
2243
  ip: e.virtual_ip,
2239
- host: e.name,
2244
+ host: e.label ?? e.name,
2240
2245
  online: onlineUserids.has(e.userid) || onlineIps.has(e.virtual_ip),
2241
2246
  reachable: false,
2242
2247
  ping: null,
@@ -2299,8 +2304,8 @@ export function startBeagleServer(opts) {
2299
2304
  };
2300
2305
  const exits = [...byRegion.entries()].map(([region, nodes]) => ({
2301
2306
  region,
2302
- flag: regionMeta[region]?.flag ?? region.slice(0, 2).toUpperCase(),
2303
- label: regionMeta[region]?.label ?? region,
2307
+ flag: REGION_META[region]?.flag ?? region.slice(0, 2).toUpperCase(),
2308
+ label: REGION_META[region]?.label ?? region,
2304
2309
  nodes,
2305
2310
  reachableCount: nodes.filter((n) => n.reachable).length,
2306
2311
  unreachableCount: nodes.filter((n) => !n.reachable).length,
@@ -2905,8 +2910,8 @@ const PAGE = `<!doctype html>
2905
2910
  <div id="exits"></div>
2906
2911
  <div class="add">
2907
2912
  <input id="exitIp" placeholder="exit virtual IP (e.g. 10.86.1.15)" autocomplete="off" style="flex:2"/>
2908
- <input id="exitRegion" placeholder="region (china/japan/us)" autocomplete="off" list="regionList" style="flex:1"/>
2909
- <datalist id="regionList"><option>china</option><option>japan</option><option>us</option></datalist>
2913
+ <input id="exitRegion" placeholder="region (e.g. japan, us)" autocomplete="off" list="regionList" style="flex:1"/>
2914
+ <datalist id="regionList"><option>japan</option><option>us</option></datalist>
2910
2915
  <button onclick="addExit()">Add exit</button>
2911
2916
  </div>
2912
2917
 
@@ -3023,6 +3028,8 @@ async function sendChat(){
3023
3028
  document.getElementById('chatInput').addEventListener('keydown', e=>{ if(e.key==='Enter') sendChat(); });
3024
3029
 
3025
3030
  // ---- Exit nodes (routes.yaml) ----
3031
+ // Display names for routing keys; the key itself stays in routes.yaml.
3032
+ const REGION_LABEL = { china: 'East Asia' };
3026
3033
  let routesObj = { regions: [], default: 'direct' };
3027
3034
  async function refreshExits(){
3028
3035
  let r; try { r = await api('/api/routes'); } catch(e){ return; }
@@ -3033,7 +3040,7 @@ async function refreshExits(){
3033
3040
  document.getElementById('ecount').textContent = total ? '('+total+')' : '';
3034
3041
  document.getElementById('exits').innerHTML = regions.length ? regions.map((rg)=> \`
3035
3042
  <div class="row" style="flex-direction:column; align-items:stretch; gap:.3rem">
3036
- <div class="name">\${esc(rg.name)} \${(rg.exits||[]).length? '':'<span class="sub">(empty → direct)</span>'}</div>
3043
+ <div class="name">\${esc(REGION_LABEL[rg.name]||rg.name)} \${(rg.exits||[]).length? '':'<span class="sub">(empty → direct)</span>'}</div>
3037
3044
  \${(rg.exits||[]).map(ip=>\`<div class="sub" style="display:flex; gap:.5rem; align-items:center"><span style="flex:1">\${esc(ip)}</span><button class="reject" onclick="removeExit('\${esc(rg.name)}','\${esc(ip)}')">×</button></div>\`).join('')}
3038
3045
  </div>\`).join('') : '<div class="empty">No routes.yaml regions — using auto-discovery.</div>';
3039
3046
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle",
3
- "version": "0.1.128",
3
+ "version": "0.1.129",
4
4
  "description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",