playhtml 2.4.1 → 2.5.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.
package/dist/main.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Cursor } from '../../common/src';
2
+ import { CursorEvents } from '../../../common/src';
2
3
  import { CursorPresence } from '../../common/src';
3
4
  import { default as default_2 } from 'y-partykit/provider';
4
5
  import { ElementAwarenessEventHandlerData } from '../../common/src';
@@ -73,15 +74,18 @@ declare class CursorClientAwareness {
73
74
  gridCells: number;
74
75
  avgCursorsPerCell: number;
75
76
  };
77
+ on<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
78
+ off<K extends keyof CursorEvents>(event: K, callback: (value: CursorEvents[K]) => void): void;
79
+ getSnapshot(): CursorEvents;
76
80
  }
77
81
 
78
82
  export declare interface CursorOptions {
79
83
  enabled?: boolean;
80
- playerIdentity?: any;
84
+ playerIdentity?: PlayerIdentity;
81
85
  proximityThreshold?: number;
82
86
  visibilityThreshold?: number;
83
87
  cursorStyle?: string;
84
- onProximityEntered?: (playerIdentity?: any, positions?: {
88
+ onProximityEntered?: (playerIdentity?: PlayerIdentity, positions?: {
85
89
  ours: {
86
90
  x: number;
87
91
  y: number;
@@ -94,10 +98,23 @@ export declare interface CursorOptions {
94
98
  onProximityLeft?: (connectionId: string) => void;
95
99
  onCustomCursorRender?: (connectionId: string, element: HTMLElement) => HTMLElement | null;
96
100
  enableChat?: boolean;
101
+ room?: CursorRoom;
102
+ shouldRenderCursor?: (presence: CursorPresence) => boolean;
103
+ getCursorStyle?: (presence: CursorPresence) => Partial<CSSStyleDeclaration> | Record<string, string>;
97
104
  }
98
105
 
99
106
  export { CursorPresence }
100
107
 
108
+ export declare type CursorRoom = "page" | "domain" | "section" | ((context: {
109
+ domain: string;
110
+ pathname: string;
111
+ search: string;
112
+ }) => string);
113
+
114
+ declare interface DefaultRoomOptions {
115
+ includeSearch?: boolean;
116
+ }
117
+
101
118
  declare function dispatchPlayEvent(message: EventMessage): void;
102
119
 
103
120
  declare class ElementHandler<T = any, U = any, V = any> {
@@ -167,7 +184,7 @@ declare class ElementHandler<T = any, U = any, V = any> {
167
184
 
168
185
  declare let globalData: Y.Map<any>;
169
186
 
170
- export declare interface InitOptions<T = any> {
187
+ export declare interface InitOptions<T = unknown> {
171
188
  /**
172
189
  * The room to connect users to (this should be a string that matches the other users
173
190
  * that you want a given user to connect with).
@@ -195,12 +212,7 @@ export declare interface InitOptions<T = any> {
195
212
  /**
196
213
  * configuration for the default room which is based on the window's url
197
214
  */
198
- defaultRoomOptions?: {
199
- /**
200
- * defaults to false
201
- */
202
- includeSearch?: boolean;
203
- };
215
+ defaultRoomOptions?: DefaultRoomOptions;
204
216
  /**
205
217
  * Runs if playhtml fails to connect. Useful to show error messages and debugging.
206
218
  */
@@ -221,7 +233,7 @@ export { PlayerIdentity }
221
233
 
222
234
  export declare const playhtml: PlayHTMLComponents;
223
235
 
224
- declare interface PlayHTMLComponents {
236
+ export declare interface PlayHTMLComponents {
225
237
  init: typeof initPlayHTML;
226
238
  setupPlayElements: typeof setupElements;
227
239
  setupPlayElement: typeof setupPlayElement;
@@ -229,12 +241,22 @@ declare interface PlayHTMLComponents {
229
241
  setupPlayElementForTag: typeof setupPlayElementForTag;
230
242
  syncedStore: (typeof store)["play"];
231
243
  globalData: typeof globalData;
232
- elementHandlers: Map<string, Map<string, ElementHandler>> | undefined;
233
- eventHandlers: Map<string, Array<RegisteredPlayEvent>> | undefined;
244
+ elementHandlers: Map<string, Map<string, ElementHandler>>;
245
+ eventHandlers: Map<string, Array<RegisteredPlayEvent>>;
234
246
  dispatchPlayEvent: typeof dispatchPlayEvent;
235
247
  registerPlayEventListener: typeof registerPlayEventListener;
236
248
  removePlayEventListener: typeof removePlayEventListener;
237
249
  cursorClient: CursorClientAwareness | null;
250
+ roomId: string;
251
+ host: string;
252
+ listSharedElements: () => Array<{
253
+ type: "source" | "consumer";
254
+ elementId: string;
255
+ dataSource: string;
256
+ normalized: string;
257
+ permissions?: "read-only" | "read-write";
258
+ element: HTMLElement;
259
+ }>;
238
260
  }
239
261
 
240
262
  /**
@@ -267,10 +289,12 @@ declare function setupPlayElement(element: Element, { ignoreIfAlreadySetup }?: {
267
289
  */
268
290
  declare function setupPlayElementForTag<T extends TagType | string>(element: HTMLElement, tag: T): Promise<void>;
269
291
 
292
+ export declare const sharedPermissions: Map<string, "read-only" | "read-write">;
293
+
270
294
  declare const store: MappedTypeDescription<StoreShape>;
271
295
 
272
296
  declare type StoreShape = {
273
- play: Record<string, Record<string, any>>;
297
+ play: Record<string, Record<string, unknown>>;
274
298
  };
275
299
 
276
300
  export { TagType }
@@ -280,11 +304,7 @@ export { }
280
304
 
281
305
  declare global {
282
306
  interface Window {
283
- cursors?: {
284
- color: string;
285
- name: string;
286
- allColors: string[];
287
- count: number;
307
+ cursors?: CursorEvents & {
288
308
  on: CursorEventEmitter["on"];
289
309
  off: CursorEventEmitter["off"];
290
310
  };
@@ -0,0 +1 @@
1
+ [can-move]{cursor:grab;transition:transform .15s;will-change:transform}[can-move].cursordown{cursor:grabbing}[can-spin]{cursor:grab;transition:transform .25s;will-change:transform}[can-spin].cursordown{cursor:grabbing}[can-grow]{cursor:pointer;transition:transform .25s;will-change:transform}[can-toggle]{cursor:pointer}[data-source][data-source-read-only]{cursor:not-allowed!important;opacity:.9}body .__playhtml-element.editing:nth-child(2n){animation-name:jiggle1;animation-iteration-count:infinite;transform-origin:50% 10%;animation-duration:.25s;animation-delay:var(--jiggle-delay)}body .__playhtml-element.editing:nth-child(2n-1){animation-name:jiggle2;animation-iteration-count:infinite;animation-direction:alternate;transform-origin:30% 5%;animation-duration:.45s;animation-delay:var(--jiggle-delay)}@keyframes jiggle1{0%{transform:rotate(-1deg);animation-timing-function:ease-in}50%{transform:rotate(1.5deg);animation-timing-function:ease-out}}@keyframes jiggle2{0%{transform:rotate(1deg);animation-timing-function:ease-in}50%{transform:rotate(-1.5deg);animation-timing-function:ease-out}}.playhtml-loading{pointer-events:none}.playhtml-loading[data-loading-behavior=hidden]{opacity:0;visibility:hidden}.playhtml-loading[data-loading-style=breathing],.playhtml-loading[can-move],.playhtml-loading[can-toggle],.playhtml-loading[can-spin],.playhtml-loading[can-grow],.playhtml-loading[can-duplicate],.playhtml-loading[can-mirror],.playhtml-loading[can-draw],.playhtml-loading [loading-behavior=animate].playhtml-loading{animation:playhtml-breathing 2s infinite ease-in-out}.playhtml-loading[loading-style=fade]{opacity:.4!important;animation:none!important;transform:none!important}.playhtml-loading[loading-style=none],.playhtml-loading[loading-behavior=none]{opacity:1!important;animation:none!important;transform:none!important;visibility:visible!important;pointer-events:auto!important}@keyframes playhtml-breathing{0%,to{opacity:.7;transform:scale(1)}50%{opacity:.4;transform:scale(1.01)}}@keyframes playhtml-pulse{0%,to{opacity:.7;transform:scale(1)}50%{opacity:.3;transform:scale(1)}}