playhtml 2.5.1 → 2.7.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.
package/dist/main.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Cursor } from '../../common/src';
2
2
  import { CursorEvents } from '../../../common/src';
3
3
  import { CursorPresence } from '../../common/src';
4
+ import { CursorPresenceView } from '../../../common/src';
4
5
  import { default as default_2 } from 'y-partykit/provider';
5
6
  import { ElementAwarenessEventHandlerData } from '../../common/src';
6
7
  import { ElementData } from '../../common/src';
@@ -11,10 +12,10 @@ import { EventMessage } from '../../common/src';
11
12
  import { MappedTypeDescription } from '@syncedstore/core/types/doc';
12
13
  import { ModifierKey } from '../../common/src';
13
14
  import { PlayerIdentity } from '../../common/src';
15
+ import { PlayerIdentity as PlayerIdentity_2 } from '../../../common/src';
14
16
  import { PlayEvent } from '../../common/src';
15
17
  import { RegisteredPlayEvent } from '../../common/src';
16
18
  import { TagType } from '../../common/src';
17
- import * as Y from 'yjs';
18
19
 
19
20
  export { Cursor }
20
21
 
@@ -22,6 +23,7 @@ declare class CursorClientAwareness {
22
23
  private provider;
23
24
  private options;
24
25
  private cursors;
26
+ private cursorAnimators;
25
27
  private spatialGrid;
26
28
  private proximityUsers;
27
29
  private currentCursor;
@@ -31,10 +33,13 @@ declare class CursorClientAwareness {
31
33
  private visibilityThreshold;
32
34
  private isStylesAdded;
33
35
  private globalApiListeners;
36
+ private activeAnimationCleanups;
34
37
  private allPlayerColors;
35
38
  private chat;
36
39
  private currentMessage;
37
40
  private otherUsersWithMessages;
41
+ private cursorPresenceChangeCallbacks;
42
+ private coordinateMode;
38
43
  constructor(provider: default_2, options?: CursorOptions);
39
44
  private initialize;
40
45
  private setupAwarenessHandling;
@@ -44,6 +49,7 @@ declare class CursorClientAwareness {
44
49
  private checkProximityOptimized;
45
50
  private addCursorStyles;
46
51
  private setupCursorTracking;
52
+ private repositionAllCursors;
47
53
  private throttledUpdateCursorAwareness;
48
54
  private updateCursorAwareness;
49
55
  private updateCursor;
@@ -77,14 +83,29 @@ declare class CursorClientAwareness {
77
83
  on<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
78
84
  off<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
79
85
  getSnapshot(): CursorEvents;
86
+ getMyPlayerIdentity(): PlayerIdentity_2;
87
+ getProvider(): default_2;
88
+ getCursorPresences(): Map<string, CursorPresenceView>;
89
+ onCursorPresencesChange(callback: (presences: Map<string, CursorPresenceView>) => void): () => void;
90
+ private notifyCursorPresenceListeners;
91
+ /**
92
+ * Apply a CSS class to a specific cursor element identified by the player's stableId (publicKey).
93
+ * The class is added to the actual rendered cursor DOM element and removed after `durationMs`.
94
+ * Returns true if the cursor element was found and the animation was applied.
95
+ */
96
+ triggerCursorAnimation(stableId: string, animationClass: string, durationMs?: number): boolean;
97
+ private triggerSelfCursorAnimation;
80
98
  }
81
99
 
100
+ export declare type CursorCoordinateMode = "relative" | "absolute";
101
+
82
102
  export declare interface CursorOptions {
83
103
  enabled?: boolean;
84
104
  playerIdentity?: PlayerIdentity;
85
105
  proximityThreshold?: number;
86
106
  visibilityThreshold?: number;
87
107
  cursorStyle?: string;
108
+ coordinateMode?: CursorCoordinateMode;
88
109
  onProximityEntered?: (playerIdentity?: PlayerIdentity, positions?: {
89
110
  ours: {
90
111
  x: number;
@@ -115,12 +136,29 @@ declare interface DefaultRoomOptions {
115
136
  includeSearch?: boolean;
116
137
  }
117
138
 
139
+ /**
140
+ * Completely deletes all shared collaborative data for an element.
141
+ * This is a destructive operation that removes data across all clients.
142
+ * This includes:
143
+ * - SyncedStore data (store.play[tag][elementId])
144
+ * - Observer subscriptions
145
+ * - Element handlers
146
+ *
147
+ * Use this when you want to permanently delete an element's data.
148
+ * For just removing a DOM element while keeping data, use removePlayElement instead.
149
+ *
150
+ * @param tag - The capability tag (e.g., "can-move", "can-toggle")
151
+ * @param elementId - The element ID
152
+ */
153
+ declare function deleteElementData(tag: string, elementId: string): void;
154
+
118
155
  declare function dispatchPlayEvent(message: EventMessage): void;
119
156
 
120
157
  declare class ElementHandler<T = any, U = any, V = any> {
121
158
  defaultData: T;
122
159
  localData: U;
123
160
  awareness: V[];
161
+ awarenessByStableId: Map<string, V>;
124
162
  selfAwareness?: V;
125
163
  element: HTMLElement;
126
164
  _data: T;
@@ -146,7 +184,7 @@ declare class ElementHandler<T = any, U = any, V = any> {
146
184
  * (e.g. calling `updateElement` and `onChange`)
147
185
  */
148
186
  set __data(data: T);
149
- set __awareness(data: V[]);
187
+ updateAwareness(data: V[], byStableId: Map<string, V>): void;
150
188
  getEventHandlerData(): ElementEventHandlerData<T, U, V>;
151
189
  getAwarenessEventHandlerData(): ElementAwarenessEventHandlerData<T, U, V>;
152
190
  getSetupData(): ElementSetupData<T, U>;
@@ -182,8 +220,6 @@ declare class ElementHandler<T = any, U = any, V = any> {
182
220
  reset(): void;
183
221
  }
184
222
 
185
- declare let globalData: Y.Map<any>;
186
-
187
223
  export declare interface InitOptions<T = unknown> {
188
224
  /**
189
225
  * The room to connect users to (this should be a string that matches the other users
@@ -238,9 +274,9 @@ export declare interface PlayHTMLComponents {
238
274
  setupPlayElements: typeof setupElements;
239
275
  setupPlayElement: typeof setupPlayElement;
240
276
  removePlayElement: typeof removePlayElement;
277
+ deleteElementData: typeof deleteElementData;
241
278
  setupPlayElementForTag: typeof setupPlayElementForTag;
242
279
  syncedStore: (typeof store)["play"];
243
- globalData: typeof globalData;
244
280
  elementHandlers: Map<string, Map<string, ElementHandler>>;
245
281
  eventHandlers: Map<string, Array<RegisteredPlayEvent>>;
246
282
  dispatchPlayEvent: typeof dispatchPlayEvent;
@@ -265,6 +301,13 @@ export declare interface PlayHTMLComponents {
265
301
  */
266
302
  declare function registerPlayEventListener(type: string, event: Omit<PlayEvent, "type">): string;
267
303
 
304
+ /**
305
+ * Removes the element handler for a DOM element from local state.
306
+ * This unregisters the element but preserves all shared collaborative data.
307
+ * Use this when a DOM element is removed/unmounted but you want to keep the data.
308
+ *
309
+ * @param element - The DOM element to unregister
310
+ */
268
311
  declare function removePlayElement(element: Element | null): void;
269
312
 
270
313
  /**