playhtml 2.11.0 → 2.11.2

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,24 +1,41 @@
1
- import { Cursor } from '../../common/src';
2
- import { CursorEvents } from '../../../common/src';
3
- import { CursorPresence } from '../../common/src';
4
- import { CursorPresenceView } from '../../../common/src';
1
+ import { CanDuplicateTo } from "@playhtml/common";
2
+ import { CanMoveBounds } from "@playhtml/common";
3
+ import { CanMoveBoundsMinVisible } from "@playhtml/common";
4
+ import { CanMoveBoundsMinVisiblePx } from "@playhtml/common";
5
+ import { Cursor } from "@playhtml/common";
6
+ import { CursorEvents } from "@playhtml/common";
7
+ import { CursorEvents as CursorEvents_2 } from "@playhtml/common";
8
+ import { CursorPresence } from "@playhtml/common";
9
+ import { CursorPresenceView } from "@playhtml/common";
10
+ import { CursorPresenceView as CursorPresenceView_2 } from "@playhtml/common";
5
11
  import { default as default_2 } from 'y-partyserver/provider';
6
- import { ElementAwarenessEventHandlerData } from '../../common/src';
7
- import { ElementData } from '../../common/src';
8
- import { ElementEventHandlerData } from '../../common/src';
9
- import { ElementInitializer } from '../../common/src';
10
- import { ElementSetupData } from '../../common/src';
11
- import { EventMessage } from '../../common/src';
12
- import { MappedTypeDescription } from 'node_modules/@syncedstore/core/types/doc';
13
- import { ModifierKey } from '../../common/src';
14
- import { PageDataChannel } from '../../common/src';
15
- import { PlayerIdentity } from '../../common/src';
16
- import { PlayerIdentity as PlayerIdentity_2 } from '../../../common/src';
17
- import { PlayEvent } from '../../common/src';
18
- import { PresenceAPI } from '../../common/src';
19
- import { PresenceRoom } from '../../common/src';
20
- import { RegisteredPlayEvent } from '../../common/src';
21
- import { TagType } from '../../common/src';
12
+ import { ElementAwarenessEventHandlerData } from "@playhtml/common";
13
+ import { ElementData } from "@playhtml/common";
14
+ import { ElementEventHandlerData } from "@playhtml/common";
15
+ import { ElementInitializer } from "@playhtml/common";
16
+ import { ElementSetupData } from "@playhtml/common";
17
+ import { EventMessage } from "@playhtml/common";
18
+ import { getIdForElement } from "@playhtml/common";
19
+ import { ModifierKey } from "@playhtml/common";
20
+ import { PageDataChannel } from "@playhtml/common";
21
+ import { PlayerIdentity } from "@playhtml/common";
22
+ import { PlayerIdentity as PlayerIdentity_2 } from "@playhtml/common";
23
+ import { PlayEvent } from "@playhtml/common";
24
+ import { PresenceAPI } from "@playhtml/common";
25
+ import { PresenceRoom } from "@playhtml/common";
26
+ import { PresenceServerMessage } from "@playhtml/common";
27
+ import { PresenceView } from "@playhtml/common";
28
+ import { RegisteredPlayEvent } from "@playhtml/common";
29
+ import { TagType } from "@playhtml/common";
30
+ import { TagTypeToElement } from "@playhtml/common";
31
+
32
+ export { CanDuplicateTo }
33
+
34
+ export { CanMoveBounds }
35
+
36
+ export { CanMoveBoundsMinVisible }
37
+
38
+ export { CanMoveBoundsMinVisiblePx }
22
39
 
23
40
  declare function createPageData<T>(name: string, defaultValue: T): PageDataChannel<T>;
24
41
 
@@ -29,14 +46,19 @@ export { Cursor }
29
46
  declare class CursorClientAwareness {
30
47
  private provider;
31
48
  private options;
49
+ private presenceTransport?;
32
50
  private cursors;
33
51
  private cursorAnimators;
34
52
  private spatialGrid;
35
53
  private proximityUsers;
36
54
  private currentCursor;
37
55
  private playerIdentity;
38
- private updateThrottled;
56
+ private awarenessUpdateTimeout;
39
57
  private lastUpdate;
58
+ private pointerFrame;
59
+ private pendingPointerSample;
60
+ private cursorEventCleanups;
61
+ private ownCursorSvgCache;
40
62
  private visibilityThreshold;
41
63
  private isStylesAdded;
42
64
  private globalApiListeners;
@@ -45,8 +67,13 @@ declare class CursorClientAwareness {
45
67
  private chat;
46
68
  private currentMessage;
47
69
  private otherUsersWithMessages;
70
+ private lastSentMessage;
48
71
  private cursorPresenceChangeCallbacks;
49
72
  private coordinateMode;
73
+ private presenceStore;
74
+ private presenceTransportUnsubscribe;
75
+ private presenceExpiryInterval;
76
+ private serverCursorMaxHz;
50
77
  private getContainerMatrix;
51
78
  private clientToStorage;
52
79
  private storageToClient;
@@ -57,12 +84,22 @@ declare class CursorClientAwareness {
57
84
  private lastKnownContainer;
58
85
  private clientIdToStableId;
59
86
  private pendingRemovals;
60
- constructor(provider: default_2, options?: CursorOptions);
87
+ constructor(provider: default_2, options?: CursorOptions, presenceTransport?: CursorPresenceTransport | undefined);
61
88
  private initialize;
62
89
  private setupAwarenessHandling;
90
+ private setupPresenceTransportHandling;
91
+ private handlePresenceTransportMessage;
92
+ private handlePresenceRate;
93
+ private startPresenceExpiryTimer;
94
+ private removeExpiredPresenceCursors;
95
+ private renderPresenceStore;
96
+ private refreshPresenceTransportColors;
63
97
  private syncExistingAwareness;
64
98
  private handleAwarenessChange;
65
99
  private hasOtherClientForStableId;
100
+ private cursorPresenceEntries;
101
+ private activeCursorPresenceEntries;
102
+ private isFreshCursorPresence;
66
103
  private rebuildSpatialGrid;
67
104
  private checkProximityOptimized;
68
105
  private addCursorStyles;
@@ -70,10 +107,19 @@ declare class CursorClientAwareness {
70
107
  private resolveTargetCoords;
71
108
  private applyZoneStyling;
72
109
  private hitTestZones;
110
+ private getOwnCursorSvg;
111
+ private addCursorEventListener;
112
+ private requestPointerFrame;
113
+ private cancelPointerFrame;
114
+ private queuePointerSample;
115
+ private processPointerSample;
73
116
  private setupCursorTracking;
74
117
  private repositionAllCursors;
75
- private throttledUpdateCursorAwareness;
118
+ private snapCursorToPresence;
119
+ private getActiveCursorConnectionCount;
120
+ private scheduleCursorAwarenessUpdate;
76
121
  private updateCursorAwareness;
122
+ private publishPresenceTransportState;
77
123
  private getContainer;
78
124
  refreshContainer(): void;
79
125
  refreshCursorStyles(): void;
@@ -98,6 +144,7 @@ declare class CursorClientAwareness {
98
144
  private updateAllCursorVisibility;
99
145
  private showAllCursors;
100
146
  configure(options: Partial<CursorOptions>): void;
147
+ private publishPlayerIdentity;
101
148
  registerZone(element: HTMLElement, options?: CursorZoneOptions): void;
102
149
  unregisterZone(elementId: string): void;
103
150
  hideCursor(connectionId: string): void;
@@ -108,13 +155,13 @@ declare class CursorClientAwareness {
108
155
  gridCells: number;
109
156
  avgCursorsPerCell: number;
110
157
  };
111
- on<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
112
- off<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
113
- getSnapshot(): CursorEvents;
158
+ on<K extends keyof CursorEvents_2>(event: K, callback: (value: CursorEvents_2[K]) => void): void;
159
+ off<K extends keyof CursorEvents_2>(event: K, callback: (value: CursorEvents_2[K]) => void): void;
160
+ getSnapshot(): CursorEvents_2;
114
161
  getMyPlayerIdentity(): PlayerIdentity_2;
115
162
  getProvider(): default_2;
116
- getCursorPresences(): Map<string, CursorPresenceView>;
117
- onCursorPresencesChange(callback: (presences: Map<string, CursorPresenceView>) => void): () => void;
163
+ getCursorPresences(): Map<string, CursorPresenceView_2>;
164
+ onCursorPresencesChange(callback: (presences: Map<string, CursorPresenceView_2>) => void): () => void;
118
165
  private notifyCursorPresenceListeners;
119
166
  /**
120
167
  * Apply a CSS class to a specific cursor element identified by the player's stableId (publicKey).
@@ -129,6 +176,8 @@ export declare type CursorContainer = HTMLElement | string | (() => HTMLElement
129
176
 
130
177
  export declare type CursorCoordinateMode = "relative" | "absolute";
131
178
 
179
+ export { CursorEvents }
180
+
132
181
  export declare interface CursorOptions {
133
182
  enabled?: boolean;
134
183
  playerIdentity?: PlayerIdentity;
@@ -170,6 +219,19 @@ export declare interface CursorOptions {
170
219
 
171
220
  export { CursorPresence }
172
221
 
222
+ declare type CursorPresenceTransport = {
223
+ join(input: {
224
+ identity: PlayerIdentity_2;
225
+ page?: string;
226
+ }): void;
227
+ update(channel: string, value: unknown): void;
228
+ clear(channel: string): void;
229
+ subscribe(listener: (message: PresenceServerMessage) => void): () => void;
230
+ destroy(): void;
231
+ };
232
+
233
+ export { CursorPresenceView }
234
+
173
235
  export declare type CursorRoom = "page" | "domain" | "section" | ((context: {
174
236
  domain: string;
175
237
  pathname: string;
@@ -207,6 +269,8 @@ declare function deleteElementData(tag: string, elementId: string): void;
207
269
 
208
270
  declare function dispatchPlayEvent(message: EventMessage): void;
209
271
 
272
+ export { ElementAwarenessEventHandlerData }
273
+
210
274
  declare class ElementHandler<T = any, U = any, V = any> {
211
275
  defaultData: T;
212
276
  localData: U;
@@ -273,6 +337,10 @@ declare class ElementHandler<T = any, U = any, V = any> {
273
337
  reset(): void;
274
338
  }
275
339
 
340
+ export { ElementInitializer }
341
+
342
+ export { getIdForElement }
343
+
276
344
  export declare interface InitOptions<T = unknown> {
277
345
  /**
278
346
  * The room to connect users to (this should be a string that matches the other users
@@ -323,6 +391,8 @@ export declare interface InitOptions<T = unknown> {
323
391
 
324
392
  declare function initPlayHTML(options?: InitOptions): Promise<void> | Promise<default_2>;
325
393
 
394
+ export { PageDataChannel }
395
+
326
396
  export { PlayerIdentity }
327
397
 
328
398
  export declare const playhtml: PlayHTMLComponents;
@@ -337,7 +407,7 @@ export declare interface PlayHTMLComponents {
337
407
  removePlayElement: typeof removePlayElement;
338
408
  deleteElementData: typeof deleteElementData;
339
409
  setupPlayElementForTag: typeof setupPlayElementForTag;
340
- syncedStore: ReadOnlyStore<(typeof store)["play"]>;
410
+ syncedStore: ReadOnlyStore<PlayStore["play"]>;
341
411
  elementHandlers: Map<string, Map<string, ElementHandler>>;
342
412
  eventHandlers: Map<string, Array<RegisteredPlayEvent>>;
343
413
  dispatchPlayEvent: typeof dispatchPlayEvent;
@@ -359,6 +429,14 @@ export declare interface PlayHTMLComponents {
359
429
  }>;
360
430
  }
361
431
 
432
+ declare type PlayStore = {
433
+ readonly play: Partial<Record<string, Record<string, unknown>>>;
434
+ };
435
+
436
+ export { PresenceRoom }
437
+
438
+ export { PresenceView }
439
+
362
440
  declare type ReadOnlyStore<T extends object> = DeepReadonlyStore<T>;
363
441
 
364
442
  /**
@@ -408,12 +486,8 @@ declare function setupPlayElementForTag<T extends TagType | string>(element: HTM
408
486
 
409
487
  export declare const sharedPermissions: Map<string, "read-only" | "read-write">;
410
488
 
411
- declare let store: MappedTypeDescription<StoreShape>;
412
-
413
- declare type StoreShape = {
414
- play: Record<string, Record<string, unknown>>;
415
- };
416
-
417
489
  export { TagType }
418
490
 
491
+ export { TagTypeToElement }
492
+
419
493
  export { }