@celljs/ta-sync 4.19.0 → 4.20.0

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.
Files changed (2) hide show
  1. package/host/index.mjs +31 -5
  2. package/package.json +4 -4
package/host/index.mjs CHANGED
@@ -2560,6 +2560,7 @@ var RELAY_HUB_MAX_MEMBERS = 101;
2560
2560
  var RELAY_HUB_MAX_VALUE = 96 * 1024;
2561
2561
  var RELAY_HUB_MAX_KEYS = 4096;
2562
2562
  var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
2563
+ var RELAY_PICTURE_MAX_CHARS = 16 * 1024;
2563
2564
  var RELAY_HUB_IDLE_DAYS = 90;
2564
2565
 
2565
2566
  // ../ta-relay/esm/common/relay-info.js
@@ -3563,12 +3564,14 @@ class SyncIdentity {
3563
3564
  }
3564
3565
  await this.side.setIdentityShared(true);
3565
3566
  base.name = local.identity.name;
3567
+ base.picture = SyncIdentityUtil.picture(local.identity);
3566
3568
  report.sent++;
3567
3569
  } else if (theirs.id !== local.identity.id) {
3568
3570
  await this.side.importIdentity({ identity: theirs, rooms: [], friends: [] }, { shared: true });
3569
3571
  report.switched = true;
3570
3572
  report.received++;
3571
3573
  base.name = theirs.name;
3574
+ base.picture = SyncIdentityUtil.picture(theirs);
3572
3575
  base.rooms = [];
3573
3576
  base.friends = [];
3574
3577
  local = await this.side.exportIdentity();
@@ -3576,18 +3579,37 @@ class SyncIdentity {
3576
3579
  if (!local.identity.shared) {
3577
3580
  await this.side.setIdentityShared(true);
3578
3581
  }
3582
+ const sent = {};
3579
3583
  if (local.identity.name !== theirs.name) {
3580
3584
  if (base.name === theirs.name) {
3581
- const named = { ...theirs, name: local.identity.name };
3582
- if ((await this.room.setState(SyncIdentityKeys.IDENTITY, named, there?.version)).ok) {
3583
- report.sent++;
3584
- }
3585
+ sent.name = local.identity.name;
3585
3586
  } else {
3586
3587
  await this.side.setName(theirs.name);
3587
3588
  report.received++;
3588
3589
  }
3589
3590
  }
3590
- base.name = (await this.side.exportIdentity()).identity.name;
3591
+ const mine = SyncIdentityUtil.picture(local.identity);
3592
+ const shared = SyncIdentityUtil.picture(theirs);
3593
+ if (mine !== shared) {
3594
+ if ((base.picture ?? "") === shared) {
3595
+ sent.picture = mine;
3596
+ } else {
3597
+ await this.side.setPicture(shared || null);
3598
+ report.received++;
3599
+ }
3600
+ }
3601
+ if (Object.keys(sent).length > 0) {
3602
+ const next = { ...theirs, ...sent };
3603
+ if (!next.picture) {
3604
+ delete next.picture;
3605
+ }
3606
+ if ((await this.room.setState(SyncIdentityKeys.IDENTITY, next, there?.version)).ok) {
3607
+ report.sent++;
3608
+ }
3609
+ }
3610
+ const now = (await this.side.exportIdentity()).identity;
3611
+ base.name = now.name;
3612
+ base.picture = SyncIdentityUtil.picture(now);
3591
3613
  }
3592
3614
  await this.rooms(space, base, report);
3593
3615
  await this.friends(space, base, report);
@@ -3692,6 +3714,10 @@ var SyncIdentityUtil;
3692
3714
  return SyncMerge.isObject(value) && typeof friend.id === "string" && typeof friend.seenAt === "number";
3693
3715
  }
3694
3716
  SyncIdentityUtil.isFriend = isFriend;
3717
+ function picture(identity) {
3718
+ return typeof identity.picture === "string" ? identity.picture : "";
3719
+ }
3720
+ SyncIdentityUtil.picture = picture;
3695
3721
  function portable(identity) {
3696
3722
  const { shared: _shared, ...rest } = identity;
3697
3723
  return rest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-sync",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "description": "A pi package for Ta: the user's settings, instructions, skills, extensions and the data extensions declare, the same on each of their computers, through a room of the relay sealed end to end, without an account",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -26,9 +26,9 @@
26
26
  "watch": "tsc -b -w --preserveWatchOutput"
27
27
  },
28
28
  "devDependencies": {
29
- "@celljs/ta-protocol": "4.19.0",
30
- "@celljs/ta-relay": "4.19.0",
31
- "@celljs/ta-web": "4.19.0",
29
+ "@celljs/ta-protocol": "4.20.0",
30
+ "@celljs/ta-relay": "4.20.0",
31
+ "@celljs/ta-web": "4.20.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {