@scp-dev/broker 0.4.0 → 0.4.1

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/dist/index.js CHANGED
@@ -1805,7 +1805,8 @@ async function startBroker(options) {
1805
1805
  if (typeof key === "string") s.data.process = key;
1806
1806
  const was2 = before2.get(endpoint2.id)?.address;
1807
1807
  if (join5 !== void 0) membership(endpoint2, core.sessionOf(endpoint2.id), true, was2?.slice(was2.lastIndexOf("/") + 1));
1808
- if (under !== void 0 && before2.get(endpoint2.id)?.parent !== endpoint2.parent) bridge?.resync();
1808
+ const tookOver = join5 !== void 0 && [...before2.values()].some((view) => view.id !== endpoint2.id && view.address === endpoint2.address);
1809
+ if (tookOver || under !== void 0 && before2.get(endpoint2.id)?.parent !== endpoint2.parent) bridge?.resync();
1809
1810
  else if ((before2.get(endpoint2.id)?.presence ?? "offline") !== endpoint2.presence) presenceChanged(endpoint2);
1810
1811
  return {
1811
1812
  endpoint: endpoint2,
@@ -1966,8 +1967,13 @@ async function startBroker(options) {
1966
1967
  return { changed };
1967
1968
  }
1968
1969
  case "rename": {
1969
- const renamed = core.rename(actorOf(s), { ...params.endpoint !== void 0 ? { endpoint: params.endpoint } : {}, handle: params.handle });
1970
+ const renamed = core.rename(actorOf(s), {
1971
+ ...params.endpoint !== void 0 ? { endpoint: params.endpoint } : {},
1972
+ handle: params.handle,
1973
+ ...params.take_over !== void 0 ? { take_over: params.take_over } : {}
1974
+ });
1970
1975
  membership(renamed.endpoint, renamed.session, true, renamed.from);
1976
+ if (renamed.retired) bridge?.resync();
1971
1977
  return renamed.endpoint;
1972
1978
  }
1973
1979
  case "adopt": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scp-dev/broker",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Swarm Communication Protocol local broker: a unix socket JSON-RPC daemon over the relay core, its client and the bridge to an account hub.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://scp.dev",
@@ -37,8 +37,8 @@
37
37
  "typecheck": "tsc -p ."
38
38
  },
39
39
  "dependencies": {
40
- "@scp-dev/core": "0.3.0",
41
- "@scp-dev/hub": "0.6.1"
40
+ "@scp-dev/core": "0.3.1",
41
+ "@scp-dev/hub": "0.6.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.1"
package/src/server.ts CHANGED
@@ -795,7 +795,8 @@ export async function startBroker(options: BrokerOptions): Promise<Broker> {
795
795
  if (typeof key === "string") s.data.process = key
796
796
  const was = before.get(endpoint.id)?.address
797
797
  if (join !== undefined) membership(endpoint, core.sessionOf(endpoint.id), true, was?.slice(was.lastIndexOf("/") + 1))
798
- if (under !== undefined && before.get(endpoint.id)?.parent !== endpoint.parent) bridge?.resync()
798
+ const tookOver = join !== undefined && [...before.values()].some((view) => view.id !== endpoint.id && view.address === endpoint.address)
799
+ if (tookOver || (under !== undefined && before.get(endpoint.id)?.parent !== endpoint.parent)) bridge?.resync()
799
800
  else if ((before.get(endpoint.id)?.presence ?? "offline") !== endpoint.presence) presenceChanged(endpoint)
800
801
  return {
801
802
  endpoint,
@@ -956,8 +957,13 @@ export async function startBroker(options: BrokerOptions): Promise<Broker> {
956
957
  return { changed }
957
958
  }
958
959
  case "rename": {
959
- const renamed = core.rename(actorOf(s), { ...(params.endpoint !== undefined ? { endpoint: params.endpoint } : {}), handle: params.handle })
960
+ const renamed = core.rename(actorOf(s), {
961
+ ...(params.endpoint !== undefined ? { endpoint: params.endpoint } : {}),
962
+ handle: params.handle,
963
+ ...(params.take_over !== undefined ? { take_over: params.take_over } : {}),
964
+ })
960
965
  membership(renamed.endpoint, renamed.session, true, renamed.from)
966
+ if (renamed.retired) bridge?.resync()
961
967
  return renamed.endpoint
962
968
  }
963
969
  case "adopt": {