playhtml 2.5.1 → 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 +39 -5
- package/dist/playhtml.es.js +3238 -2659
- package/package.json +2 -2
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;
|
|
@@ -115,12 +127,29 @@ declare interface DefaultRoomOptions {
|
|
|
115
127
|
includeSearch?: boolean;
|
|
116
128
|
}
|
|
117
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
|
+
|
|
118
146
|
declare function dispatchPlayEvent(message: EventMessage): void;
|
|
119
147
|
|
|
120
148
|
declare class ElementHandler<T = any, U = any, V = any> {
|
|
121
149
|
defaultData: T;
|
|
122
150
|
localData: U;
|
|
123
151
|
awareness: V[];
|
|
152
|
+
awarenessByStableId: Map<string, V>;
|
|
124
153
|
selfAwareness?: V;
|
|
125
154
|
element: HTMLElement;
|
|
126
155
|
_data: T;
|
|
@@ -146,7 +175,7 @@ declare class ElementHandler<T = any, U = any, V = any> {
|
|
|
146
175
|
* (e.g. calling `updateElement` and `onChange`)
|
|
147
176
|
*/
|
|
148
177
|
set __data(data: T);
|
|
149
|
-
|
|
178
|
+
updateAwareness(data: V[], byStableId: Map<string, V>): void;
|
|
150
179
|
getEventHandlerData(): ElementEventHandlerData<T, U, V>;
|
|
151
180
|
getAwarenessEventHandlerData(): ElementAwarenessEventHandlerData<T, U, V>;
|
|
152
181
|
getSetupData(): ElementSetupData<T, U>;
|
|
@@ -182,8 +211,6 @@ declare class ElementHandler<T = any, U = any, V = any> {
|
|
|
182
211
|
reset(): void;
|
|
183
212
|
}
|
|
184
213
|
|
|
185
|
-
declare let globalData: Y.Map<any>;
|
|
186
|
-
|
|
187
214
|
export declare interface InitOptions<T = unknown> {
|
|
188
215
|
/**
|
|
189
216
|
* The room to connect users to (this should be a string that matches the other users
|
|
@@ -238,9 +265,9 @@ export declare interface PlayHTMLComponents {
|
|
|
238
265
|
setupPlayElements: typeof setupElements;
|
|
239
266
|
setupPlayElement: typeof setupPlayElement;
|
|
240
267
|
removePlayElement: typeof removePlayElement;
|
|
268
|
+
deleteElementData: typeof deleteElementData;
|
|
241
269
|
setupPlayElementForTag: typeof setupPlayElementForTag;
|
|
242
270
|
syncedStore: (typeof store)["play"];
|
|
243
|
-
globalData: typeof globalData;
|
|
244
271
|
elementHandlers: Map<string, Map<string, ElementHandler>>;
|
|
245
272
|
eventHandlers: Map<string, Array<RegisteredPlayEvent>>;
|
|
246
273
|
dispatchPlayEvent: typeof dispatchPlayEvent;
|
|
@@ -265,6 +292,13 @@ export declare interface PlayHTMLComponents {
|
|
|
265
292
|
*/
|
|
266
293
|
declare function registerPlayEventListener(type: string, event: Omit<PlayEvent, "type">): string;
|
|
267
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
|
+
*/
|
|
268
302
|
declare function removePlayElement(element: Element | null): void;
|
|
269
303
|
|
|
270
304
|
/**
|