playhtml 2.5.0 → 2.6.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;
@@ -35,6 +37,8 @@ declare class CursorClientAwareness {
35
37
  private chat;
36
38
  private currentMessage;
37
39
  private otherUsersWithMessages;
40
+ private cursorPresenceChangeCallbacks;
41
+ private coordinateMode;
38
42
  constructor(provider: default_2, options?: CursorOptions);
39
43
  private initialize;
40
44
  private setupAwarenessHandling;
@@ -77,14 +81,22 @@ declare class CursorClientAwareness {
77
81
  on<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
78
82
  off<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
79
83
  getSnapshot(): CursorEvents;
84
+ getMyPlayerIdentity(): PlayerIdentity_2;
85
+ getProvider(): default_2;
86
+ getCursorPresences(): Map<string, CursorPresenceView>;
87
+ onCursorPresencesChange(callback: (presences: Map<string, CursorPresenceView>) => void): () => void;
88
+ private notifyCursorPresenceListeners;
80
89
  }
81
90
 
91
+ export declare type CursorCoordinateMode = "relative" | "absolute";
92
+
82
93
  export declare interface CursorOptions {
83
94
  enabled?: boolean;
84
95
  playerIdentity?: PlayerIdentity;
85
96
  proximityThreshold?: number;
86
97
  visibilityThreshold?: number;
87
98
  cursorStyle?: string;
99
+ coordinateMode?: CursorCoordinateMode;
88
100
  onProximityEntered?: (playerIdentity?: PlayerIdentity, positions?: {
89
101
  ours: {
90
102
  x: number;
@@ -98,20 +110,46 @@ export declare interface CursorOptions {
98
110
  onProximityLeft?: (connectionId: string) => void;
99
111
  onCustomCursorRender?: (connectionId: string, element: HTMLElement) => HTMLElement | null;
100
112
  enableChat?: boolean;
113
+ room?: CursorRoom;
114
+ shouldRenderCursor?: (presence: CursorPresence) => boolean;
115
+ getCursorStyle?: (presence: CursorPresence) => Partial<CSSStyleDeclaration> | Record<string, string>;
101
116
  }
102
117
 
103
118
  export { CursorPresence }
104
119
 
120
+ export declare type CursorRoom = "page" | "domain" | "section" | ((context: {
121
+ domain: string;
122
+ pathname: string;
123
+ search: string;
124
+ }) => string);
125
+
105
126
  declare interface DefaultRoomOptions {
106
127
  includeSearch?: boolean;
107
128
  }
108
129
 
130
+ /**
131
+ * Completely deletes all shared collaborative data for an element.
132
+ * This is a destructive operation that removes data across all clients.
133
+ * This includes:
134
+ * - SyncedStore data (store.play[tag][elementId])
135
+ * - Observer subscriptions
136
+ * - Element handlers
137
+ *
138
+ * Use this when you want to permanently delete an element's data.
139
+ * For just removing a DOM element while keeping data, use removePlayElement instead.
140
+ *
141
+ * @param tag - The capability tag (e.g., "can-move", "can-toggle")
142
+ * @param elementId - The element ID
143
+ */
144
+ declare function deleteElementData(tag: string, elementId: string): void;
145
+
109
146
  declare function dispatchPlayEvent(message: EventMessage): void;
110
147
 
111
148
  declare class ElementHandler<T = any, U = any, V = any> {
112
149
  defaultData: T;
113
150
  localData: U;
114
151
  awareness: V[];
152
+ awarenessByStableId: Map<string, V>;
115
153
  selfAwareness?: V;
116
154
  element: HTMLElement;
117
155
  _data: T;
@@ -137,7 +175,7 @@ declare class ElementHandler<T = any, U = any, V = any> {
137
175
  * (e.g. calling `updateElement` and `onChange`)
138
176
  */
139
177
  set __data(data: T);
140
- set __awareness(data: V[]);
178
+ updateAwareness(data: V[], byStableId: Map<string, V>): void;
141
179
  getEventHandlerData(): ElementEventHandlerData<T, U, V>;
142
180
  getAwarenessEventHandlerData(): ElementAwarenessEventHandlerData<T, U, V>;
143
181
  getSetupData(): ElementSetupData<T, U>;
@@ -173,8 +211,6 @@ declare class ElementHandler<T = any, U = any, V = any> {
173
211
  reset(): void;
174
212
  }
175
213
 
176
- declare let globalData: Y.Map<any>;
177
-
178
214
  export declare interface InitOptions<T = unknown> {
179
215
  /**
180
216
  * The room to connect users to (this should be a string that matches the other users
@@ -229,9 +265,9 @@ export declare interface PlayHTMLComponents {
229
265
  setupPlayElements: typeof setupElements;
230
266
  setupPlayElement: typeof setupPlayElement;
231
267
  removePlayElement: typeof removePlayElement;
268
+ deleteElementData: typeof deleteElementData;
232
269
  setupPlayElementForTag: typeof setupPlayElementForTag;
233
270
  syncedStore: (typeof store)["play"];
234
- globalData: typeof globalData;
235
271
  elementHandlers: Map<string, Map<string, ElementHandler>>;
236
272
  eventHandlers: Map<string, Array<RegisteredPlayEvent>>;
237
273
  dispatchPlayEvent: typeof dispatchPlayEvent;
@@ -256,6 +292,13 @@ export declare interface PlayHTMLComponents {
256
292
  */
257
293
  declare function registerPlayEventListener(type: string, event: Omit<PlayEvent, "type">): string;
258
294
 
295
+ /**
296
+ * Removes the element handler for a DOM element from local state.
297
+ * This unregisters the element but preserves all shared collaborative data.
298
+ * Use this when a DOM element is removed/unmounted but you want to keep the data.
299
+ *
300
+ * @param element - The DOM element to unregister
301
+ */
259
302
  declare function removePlayElement(element: Element | null): void;
260
303
 
261
304
  /**