entangled-worlds-orbiters-shared 1.2.0 → 1.2.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.
@@ -20,15 +20,15 @@ export interface PeerIntent {
20
20
  }
21
21
  /** Messages exchanged over the relay seam. */
22
22
  export type SyncMessage = {
23
- kind: 'link:hello';
23
+ kind: 'beat:hello';
24
24
  id: string;
25
25
  } | {
26
- kind: 'link:timeline';
26
+ kind: 'beat:timeline';
27
27
  timeline: BeatTimelineState;
28
28
  ts: TimelineStamp;
29
29
  id: string;
30
30
  } | {
31
- kind: 'link:transport';
31
+ kind: 'beat:transport';
32
32
  id: string;
33
33
  playing: boolean;
34
34
  atSessionMs: number;
@@ -91,7 +91,7 @@ export class BeatTimeline {
91
91
  /** Broadcast presence (peers reply with their timeline). Safe to call periodically as a heartbeat. */
92
92
  announce() {
93
93
  if (this.enabled)
94
- this.relay.send(this.id, { kind: 'link:hello', id: this.id });
94
+ this.relay.send(this.id, { kind: 'beat:hello', id: this.id });
95
95
  }
96
96
  /** Toggle participation. Off = solo (no broadcast, no adoption). On = re-announce + re-adopt. */
97
97
  setEnabled(on) {
@@ -135,7 +135,7 @@ export class BeatTimeline {
135
135
  this.timeline = { ...timeline };
136
136
  this._ts = { time: this.sessionNowMs(), id: this.id };
137
137
  if (this.enabled)
138
- this.relay.send(this.id, { kind: 'link:timeline', timeline: this.timeline, ts: this._ts, id: this.id });
138
+ this.relay.send(this.id, { kind: 'beat:timeline', timeline: this.timeline, ts: this._ts, id: this.id });
139
139
  if (this.onChange)
140
140
  this.onChange();
141
141
  }
@@ -177,7 +177,7 @@ export class BeatTimeline {
177
177
  // ---- start/stop intent (opt-in; never adopted on join) ------------------------------
178
178
  setLocalPlaying(playing) {
179
179
  this.localPlaying = playing;
180
- this.relay.send(this.id, { kind: 'link:transport', id: this.id, playing, atSessionMs: this.sessionNowMs() });
180
+ this.relay.send(this.id, { kind: 'beat:transport', id: this.id, playing, atSessionMs: this.sessionNowMs() });
181
181
  if (this.onChange)
182
182
  this.onChange();
183
183
  }
@@ -186,14 +186,14 @@ export class BeatTimeline {
186
186
  if (!this.enabled)
187
187
  return; // solo: ignore everything from the network
188
188
  switch (msg.kind) {
189
- case 'link:hello':
189
+ case 'beat:hello':
190
190
  this.peers.add(msg.id);
191
191
  // reply with our current timeline (tagged with our id) so the joiner adopts tempo/phase + learns us
192
- this.relay.send(this.id, { kind: 'link:timeline', timeline: this.timeline, ts: this._ts, id: this.id }, msg.id);
192
+ this.relay.send(this.id, { kind: 'beat:timeline', timeline: this.timeline, ts: this._ts, id: this.id }, msg.id);
193
193
  if (this.onChange)
194
194
  this.onChange();
195
195
  break;
196
- case 'link:timeline':
196
+ case 'beat:timeline':
197
197
  if (msg.id)
198
198
  this.peers.add(msg.id);
199
199
  if (newerTs(msg.ts, this._ts)) {
@@ -203,7 +203,7 @@ export class BeatTimeline {
203
203
  if (this.onChange)
204
204
  this.onChange();
205
205
  break;
206
- case 'link:transport':
206
+ case 'beat:transport':
207
207
  // OBSERVE by default (Link v3: never auto-adopt). `onPeerTransport` lets the app opt into
208
208
  // following (the "Sync play" toggle) — it decides whether to launch/stop locally.
209
209
  this.peers.add(msg.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "entangled-worlds-orbiters-shared",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Shared library for entangled worlds orbiters - contains core world rendering, moons system, and UI components",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/clock/sync.ts CHANGED
@@ -38,9 +38,9 @@ export interface PeerIntent {
38
38
 
39
39
  /** Messages exchanged over the relay seam. */
40
40
  export type SyncMessage =
41
- | { kind: 'link:hello'; id: string }
42
- | { kind: 'link:timeline'; timeline: BeatTimelineState; ts: TimelineStamp; id: string }
43
- | { kind: 'link:transport'; id: string; playing: boolean; atSessionMs: number };
41
+ | { kind: 'beat:hello'; id: string }
42
+ | { kind: 'beat:timeline'; timeline: BeatTimelineState; ts: TimelineStamp; id: string }
43
+ | { kind: 'beat:transport'; id: string; playing: boolean; atSessionMs: number };
44
44
 
45
45
  /** A node the relay can register + deliver to. */
46
46
  export interface RelayNode {
@@ -183,7 +183,7 @@ export class BeatTimeline implements RelayNode {
183
183
  }
184
184
  /** Broadcast presence (peers reply with their timeline). Safe to call periodically as a heartbeat. */
185
185
  announce(): void {
186
- if (this.enabled) this.relay.send(this.id, { kind: 'link:hello', id: this.id });
186
+ if (this.enabled) this.relay.send(this.id, { kind: 'beat:hello', id: this.id });
187
187
  }
188
188
 
189
189
  /** Toggle participation. Off = solo (no broadcast, no adoption). On = re-announce + re-adopt. */
@@ -228,7 +228,7 @@ export class BeatTimeline implements RelayNode {
228
228
  this.timeline = { ...timeline };
229
229
  this._ts = { time: this.sessionNowMs(), id: this.id };
230
230
  if (this.enabled)
231
- this.relay.send(this.id, { kind: 'link:timeline', timeline: this.timeline, ts: this._ts, id: this.id });
231
+ this.relay.send(this.id, { kind: 'beat:timeline', timeline: this.timeline, ts: this._ts, id: this.id });
232
232
  if (this.onChange) this.onChange();
233
233
  }
234
234
  /** Propose a tempo. Keeps the beat value continuous at the moment of change (no jump). */
@@ -269,7 +269,7 @@ export class BeatTimeline implements RelayNode {
269
269
  // ---- start/stop intent (opt-in; never adopted on join) ------------------------------
270
270
  setLocalPlaying(playing: boolean): void {
271
271
  this.localPlaying = playing;
272
- this.relay.send(this.id, { kind: 'link:transport', id: this.id, playing, atSessionMs: this.sessionNowMs() });
272
+ this.relay.send(this.id, { kind: 'beat:transport', id: this.id, playing, atSessionMs: this.sessionNowMs() });
273
273
  if (this.onChange) this.onChange();
274
274
  }
275
275
 
@@ -277,17 +277,17 @@ export class BeatTimeline implements RelayNode {
277
277
  receive(msg: SyncMessage): void {
278
278
  if (!this.enabled) return; // solo: ignore everything from the network
279
279
  switch (msg.kind) {
280
- case 'link:hello':
280
+ case 'beat:hello':
281
281
  this.peers.add(msg.id);
282
282
  // reply with our current timeline (tagged with our id) so the joiner adopts tempo/phase + learns us
283
283
  this.relay.send(
284
284
  this.id,
285
- { kind: 'link:timeline', timeline: this.timeline, ts: this._ts, id: this.id },
285
+ { kind: 'beat:timeline', timeline: this.timeline, ts: this._ts, id: this.id },
286
286
  msg.id,
287
287
  );
288
288
  if (this.onChange) this.onChange();
289
289
  break;
290
- case 'link:timeline':
290
+ case 'beat:timeline':
291
291
  if (msg.id) this.peers.add(msg.id);
292
292
  if (newerTs(msg.ts, this._ts)) {
293
293
  this.timeline = { ...msg.timeline };
@@ -295,7 +295,7 @@ export class BeatTimeline implements RelayNode {
295
295
  }
296
296
  if (this.onChange) this.onChange();
297
297
  break;
298
- case 'link:transport':
298
+ case 'beat:transport':
299
299
  // OBSERVE by default (Link v3: never auto-adopt). `onPeerTransport` lets the app opt into
300
300
  // following (the "Sync play" toggle) — it decides whether to launch/stop locally.
301
301
  this.peers.add(msg.id);