@yz-social/civildefense.io 4.5.21 → 4.5.22

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yz-social/civildefense.io",
3
3
  "description": "Browser app to safely share live sightings on a map.",
4
- "version": "4.5.21",
4
+ "version": "4.5.22",
5
5
  "keywords": [
6
6
  "map",
7
7
  "browser",
@@ -5,6 +5,7 @@ import { agentTopic, agentPersistKey } from './versions.js';
5
5
  import { Int } from './translations.js';
6
6
  import { consume, openDisplay } from './display.js';
7
7
  import { networkPromise, resetInactivityTimer, clickTip, tooltip } from './main.js';
8
+ import { dht } from './protocol.js';
8
9
  import { P2PWebNetwork } from './p2pWebNetwork.js';
9
10
 
10
11
  export class Agent {
@@ -292,7 +293,7 @@ export class Agent {
292
293
  static tag = null;
293
294
  static identity = null;
294
295
  // Keep user separate between dht=1 or empty (Axona) vs dht=0 or -1 (no Axona, for testing).
295
- static usertagKey = `usertag${parseInt(new URL(location).searchParams.get('dht')) < 1 ? '0' : ''}`;
296
+ static usertagKey = `usertag${(dht <= 0) ? '0' : ''}`;
296
297
  static switchUser(tag, identity) { // Set/persist/ensure the current user, return Agent
297
298
  this.tag = tag; // Before the ensure().
298
299
  this.identity = P2PWebNetwork.currentPublishIdentity = identity;
@@ -133,7 +133,8 @@ export const Hashtags = {
133
133
  return `<md-filter-chip label="${label}" elevated removable
134
134
  ${active === 'pub' ? 'class="pub"' : ''}
135
135
  ${active ? ' selected' : ''}
136
- >${this.firstEmoji(label) ? '' : this.identicon(label, 'selected-icon')}
136
+ >${this.firstEmoji(label) ? '' :
137
+ `<div slot="selected-icon" class="identicon"><md-icon class="material-icons">checkmark</md-icon> ${this.identicon(label)}</div>`}
137
138
  <md-icon-button slot="remove-trailing-icon"><md-icon class="material-icons"></md-icon></md-icon-button>
138
139
  </md-filter-chip>`;
139
140
  },
@@ -83,7 +83,7 @@ export var trackMap;
83
83
  export function initMap(lat, lng, zoom, positionLabel) { // Set up appropriate zoomed initial map and handlers for this position.
84
84
  // Then show initial message and updateSubscriptions.
85
85
 
86
- P2PWebNetwork.setSessionRegion({lat, lng});
86
+ P2PWebNetwork.setSessionLocation({lat, lng});
87
87
 
88
88
  // Map will be centered at the given current location marker, unless overriden by query parameters.
89
89
  let center = {lat, lng};
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { connect, createAuthorIdentity, geoCellId, geoCellCenter, WIRE_VERSION, KERNEL_VERSION } from './protocol.js';
2
+ import { connect, createAuthorIdentity, geoCellId, geoCellCenter, WIRE_VERSION, KERNEL_VERSION, dht } from './protocol.js';
3
3
  import { stringToBytes, bytesToString, publishChunkedBytes, receiveChunkedBytes } from './protocol.js';
4
4
 
5
5
  if (!Uint8Array.prototype.toBase64) { // NodeJS < 24
@@ -16,37 +16,38 @@ const { BigInt, URL, File, pica } = globalThis;
16
16
  await network.disconnect();
17
17
  */
18
18
 
19
- const {promise:sessionRegionPromise, resolve:resolveSessionRegion} = Promise.withResolvers();
19
+ const {promise:sessionLocationPromise, resolve:resolveSessionLocation} = Promise.withResolvers();
20
20
 
21
21
  export class P2PWebNetwork {
22
22
  static wireVersion = WIRE_VERSION;
23
23
  static kernelVersion = KERNEL_VERSION;
24
24
  static createAuthorIdentity = createAuthorIdentity;
25
- static setSessionRegion = resolveSessionRegion;
26
- static sessionRegion = sessionRegionPromise;
25
+ static setSessionLocation = resolveSessionLocation;
26
+ static sessionLocation = sessionLocationPromise;
27
27
  static async create({infoLogger = console.log, debugLogger,
28
- region = this.sessionRegion,
28
+ location = this.sessionLocation,
29
29
  bridgeUrl = (globalThis.location && new URL(globalThis.location).searchParams.get('bridge')) ||
30
30
  globalThis.process?.env.BRIDGE_URL ||
31
- (parseInt(new URL(globalThis.location || 'file://').searchParams.get('dht')) <= 0 && // fixme remove when we host bridges
32
- globalThis.location?.origin.replace(/^http/, 'ws')) ||
31
+ ((dht <= 0) && // fixme remove when we host bridges
32
+ (globalThis.location?.origin.replace(/^http/, 'ws') ||
33
+ 'ws://localhost:3000')) ||
33
34
  'wss://bridge.axona.net',
34
35
  } = {}) {
35
36
  // Promise a ready-to-use network peer.
36
- region = await region;
37
+ location = await location;
37
38
 
38
39
  const network = new this();
39
40
  network.resetStatePromises();
40
41
 
41
42
  const { peer, nodeIdentity, transport, status, disconnect } = await connect({
42
43
  bridge: bridgeUrl,
43
- location: region,
44
+ location,
44
45
  onDisconnect: network.detached,
45
46
  author: false
46
47
  });
47
48
  Object.assign(network, {infoLogger, debugLogger, disconnector: disconnect, transport, nodeIdentity, peer});
48
49
 
49
- network.info(`Created network node for kernel ${this.kernelVersion} region 0x${this.regionCode(region.lat, region.lng).toString(16)}.`);
50
+ network.info(`Created network node for kernel ${this.kernelVersion} region 0x${this.regionCode(location.lat, location.lng).toString(16)}.`);
50
51
  peer.onError(error => {
51
52
  network.info(`error: ${error.message || error}`);
52
53
  throw error;
@@ -3,10 +3,13 @@ const { TextEncoder, TextDecoder, BigInt, URL, WebSocket, Buffer } = globalThis;
3
3
 
4
4
  let connect, createAuthorIdentity, geoCellId, geoCellCenter, WIRE_VERSION, KERNEL_VERSION, stringToBytes, bytesToString, publishChunkedBytes, receiveChunkedBytes;
5
5
 
6
- // dht 1 -> Axona (default)
6
+ // dht 1 -> Axona
7
7
  // dht 0 -> server
8
8
  // dht -1 -> in-memory on client only
9
- const dht = parseInt(globalThis.process ? globalThis.process.env.DHT : new URL(globalThis.location).searchParams.get('dht'));
9
+ const defaultDHT = 1;
10
+ export const dht = parseInt((globalThis.process ?
11
+ globalThis.process.env.DHT :
12
+ new URL(globalThis.location).searchParams.get('dht')) ?? defaultDHT);
10
13
 
11
14
  if (dht < 1) {
12
15
 
@@ -93,9 +96,11 @@ if (dht < 1) {
93
96
  const [tag, ...rest] = JSON.parse(event.data);
94
97
  const subHandler = handlers[tag];
95
98
  const inFlightResolver = inFlight[tag];
96
- if ((!subHandler && !inFlightResolver) ||
99
+
100
+ if ((!subHandler && !inFlightResolver) || // debug
97
101
  ((typeof(subHandler) !== 'function') && (typeof(inFlightResolver) !== 'function')))
98
102
  console.log({tag, rest, subHandler, inFlightResolver, handlers, inFlight});
103
+
99
104
  if (subHandler) return subHandler(...rest);
100
105
  delete inFlight[tag];
101
106
  return inFlightResolver?.(...rest);
@@ -1,6 +1,6 @@
1
1
  const { Request, Response, URL, clients} = self;
2
2
  // Little point in trying to automatically pull this through package.json, as we need a byte change in THIS file to trigger a new worker.
3
- const serviceVersion = '4.5.21';
3
+ const serviceVersion = '4.5.22';
4
4
 
5
5
  const cacheList = [ // The files we need.
6
6
  "/",
@@ -303,9 +303,29 @@ button, .leaflet-control-zoom > a, .leaflet-popup-close-button, md-outlined-icon
303
303
  md-filter-chip {
304
304
  --md-sys-color-surface-container-low: #B8C2D7; /* non-selected elevated filter chip */
305
305
  }
306
- md-filter-chip minidenticon-svg + md-icon-button {
306
+ md-filter-chip minidenticon-svg + md-icon-button,
307
+ md-filter-chip .identicon + md-icon-button {
307
308
  bottom: 10px;
308
309
  }
310
+ md-filter-chip .identicon md-icon {
311
+ font-size: 18px;
312
+ width: 20px;
313
+ position: relative;
314
+ bottom: 3px;
315
+ }
316
+ md-filter-chip .identicon {
317
+ width: 43px;
318
+ }
319
+ md-filter-chip .identicon minidenticon-svg {
320
+ width: 18px;
321
+ display: inline-block;
322
+ position: relative;
323
+ bottom: 5px;
324
+ left: -3px;
325
+ }
326
+ md-filter-chip minidenticon-svg {
327
+ background: white;
328
+ }
309
329
  md-filter-chip md-icon-button {
310
330
  position: relative;
311
331
  bottom: 3px;
@@ -323,9 +343,6 @@ md-filter-chip:not([selected]) md-icon::after {
323
343
  md-filter-chip.pub md-icon {
324
344
  color: var(--md-sys-color-secondary);
325
345
  }
326
- md-filter-chip minidenticon-svg {
327
- background: white;
328
- }
329
346
  md-outlined-icon-button minidenticon-svg, md-outlined-icon-button img {
330
347
  height: 40px;
331
348
  width: 40px;
package/server/app.js CHANGED
@@ -119,7 +119,7 @@ if (cluster.isPrimary) { // Parent process with portal webserver through which c
119
119
  process.title = 'axona-starting';
120
120
  const { P2PWebNetwork, location } = await import('../index.js');
121
121
  const network = await P2PWebNetwork.create({
122
- region: location,
122
+ location,
123
123
  infoLogger: log,
124
124
  debugLogger: debug
125
125
  });