playhtml 2.0.3 → 2.0.5
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/CHANGELOG.md +12 -0
- package/README.md +6 -3
- package/dist/main.d.ts +14 -63
- package/dist/playhtml.es.js +1990 -1964
- package/dist/playhtml.umd.js +7 -7
- package/package.json +5 -9
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
|
|
4
4
|
|
|
5
|
+
## 2.0.5 - 2023-09-11
|
|
6
|
+
|
|
7
|
+
- fixed an error with setting up elements before the provider was synced which lead to incorrect initial element states that didn't sync.
|
|
8
|
+
- Removed the `firstSetup` export accordingly to allow for optimistically setting up elements even before `playhtml` is initialized.
|
|
9
|
+
- Added `removePlayElement` to handle removing upon unmounting or removal of an element from the DOM to clear up the state.
|
|
10
|
+
|
|
11
|
+
## 2.0.4 - 2023-09-07
|
|
12
|
+
|
|
13
|
+
- added @playhtml/react library
|
|
14
|
+
- added `firstSetup` export from playhtml for raising error if it hasn't been initialized.
|
|
15
|
+
- cleaned up exports
|
|
16
|
+
|
|
5
17
|
## 2.0.2 - 2023-08-23
|
|
6
18
|
|
|
7
19
|
- handle deprecated import version by using a timeout. This adds a significant delay to the initialization of any client using the old method and logs a warning.
|
package/README.md
CHANGED
|
@@ -123,8 +123,7 @@ IDs are recommended on all elements to uniquely identify them. If you are applyi
|
|
|
123
123
|
These capabilities are common ones that have been designed and created by the community. You should expect that they are relatively well-tested, and they simply build on top of the same API and constructs that `can-play` uses.
|
|
124
124
|
|
|
125
125
|
### `can-move`
|
|
126
|
-
|
|
127
|
-
https://github.com/spencerc99/playhtml/assets/14796580/9c2b9bf6-142c-41e2-8c8f-93a3b121a73e
|
|
126
|
+
https://github.com/spencerc99/playhtml/assets/14796580/215c7631-d71f-40e6-bdda-bd8146a88006
|
|
128
127
|
|
|
129
128
|
Creates a movable element using 2D `translate` on the element. Dragging the element around will move it
|
|
130
129
|
|
|
@@ -134,12 +133,16 @@ Creates a movable element using 2D `translate` on the element. Dragging the elem
|
|
|
134
133
|
- This currently doesn't work on touch screens.
|
|
135
134
|
|
|
136
135
|
### `can-toggle`
|
|
136
|
+
https://github.com/spencerc99/playhtml/assets/14796580/7e667c06-c32e-4369-b250-c9ca321de163
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
_from https://twitter.com/spencerc99/status/1681048824884895744_
|
|
139
139
|
|
|
140
140
|
Creates an element that can be switched on and off. Clicking the element will toggle the `clicked` class on the element.
|
|
141
141
|
|
|
142
142
|
### `can-duplicate`
|
|
143
|
+
https://github.com/spencerc99/playhtml/assets/14796580/6d9f1228-08cf-45a7-987a-8bebfaaefd83
|
|
144
|
+
|
|
145
|
+
_used to programmatically and dynamically create new playhtml elements that aren't included in the initial HTML_
|
|
143
146
|
|
|
144
147
|
Creates an element that duplicates a target element (specified by the value of the `can-duplicate` attribute, which can be an element's ID or custom CSS selector) when clicked. Optionally can specify where the duplicate element is inserted in the DOM via the `can-duplicate-to` setting (default is as a sibling to the original element).
|
|
145
148
|
|
package/dist/main.d.ts
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
|
|
3
|
+
import { ElementAwarenessEventHandlerData } from '../../common/src';
|
|
4
|
+
import { ElementData } from '../../common/src';
|
|
5
|
+
import { ElementEventHandlerData } from '../../common/src';
|
|
6
|
+
import { ElementSetupData } from '../../common/src';
|
|
7
|
+
import { ModifierKey } from '../../common/src';
|
|
8
|
+
import { TagType } from '@playhtml/common';
|
|
3
9
|
import * as Y from 'yjs';
|
|
4
|
-
|
|
5
|
-
declare interface ElementAwarenessEventHandlerData<T = any, U = any, V = any> extends ElementEventHandlerData<T, U, V> {
|
|
6
|
-
myAwareness?: V;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare interface ElementData<T = any, U = any, V = any> extends ElementInitializer<T> {
|
|
10
|
-
data?: T;
|
|
11
|
-
localData?: U;
|
|
12
|
-
awareness?: V;
|
|
13
|
-
element: HTMLElement;
|
|
14
|
-
onChange: (data: T) => void;
|
|
15
|
-
onAwarenessChange: (data: V) => void;
|
|
16
|
-
triggerAwarenessUpdate: () => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare interface ElementEventHandlerData<T = any, U = any, V = any> {
|
|
20
|
-
data: T;
|
|
21
|
-
localData: U;
|
|
22
|
-
awareness: V[];
|
|
23
|
-
element: HTMLElement;
|
|
24
|
-
setData: (data: T) => void;
|
|
25
|
-
setLocalData: (data: U) => void;
|
|
26
|
-
setLocalAwareness: (data: V) => void;
|
|
27
|
-
}
|
|
10
|
+
import YPartyKitProvider from 'y-partykit/provider';
|
|
28
11
|
|
|
29
12
|
declare class ElementHandler<T = any, U = any, V = any> {
|
|
30
13
|
defaultData: T;
|
|
@@ -67,63 +50,31 @@ declare class ElementHandler<T = any, U = any, V = any> {
|
|
|
67
50
|
reset(): void;
|
|
68
51
|
}
|
|
69
52
|
|
|
70
|
-
declare interface ElementInitializer<T = any, U = any, V = any> {
|
|
71
|
-
defaultData: T | ((element: HTMLElement) => T);
|
|
72
|
-
defaultLocalData?: U | ((element: HTMLElement) => U);
|
|
73
|
-
myDefaultAwareness?: V | ((element: HTMLElement) => V);
|
|
74
|
-
updateElement: (data: ElementEventHandlerData<T, U, V>) => void;
|
|
75
|
-
updateElementAwareness?: (data: ElementAwarenessEventHandlerData<T, U, V>) => void;
|
|
76
|
-
onDrag?: (e: MouseEvent | TouchEvent, eventData: ElementEventHandlerData<T, U, V>) => void;
|
|
77
|
-
onClick?: (e: MouseEvent, eventData: ElementEventHandlerData<T, U, V>) => void;
|
|
78
|
-
onDragStart?: (e: MouseEvent | TouchEvent, eventData: ElementEventHandlerData<T, U, V>) => void;
|
|
79
|
-
additionalSetup?: (eventData: ElementSetupData<T, U, V>) => void;
|
|
80
|
-
resetShortcut?: ModifierKey;
|
|
81
|
-
debounceMs?: number;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
declare interface ElementSetupData<T = any, U = any, V = any> {
|
|
85
|
-
getData: () => T;
|
|
86
|
-
getLocalData: () => U;
|
|
87
|
-
getAwareness: () => V[];
|
|
88
|
-
getElement: () => HTMLElement;
|
|
89
|
-
setData: (data: T) => void;
|
|
90
|
-
setLocalData: (data: U) => void;
|
|
91
|
-
setLocalAwareness: (data: V) => void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
53
|
declare interface InitOptions {
|
|
95
54
|
room?: string;
|
|
96
55
|
host?: string;
|
|
97
56
|
}
|
|
98
57
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
declare type ModifierKey = "ctrlKey" | "altKey" | "shiftKey" | "metaKey";
|
|
58
|
+
declare function initPlayHTML({ room, host, }?: InitOptions): YPartyKitProvider | undefined;
|
|
102
59
|
|
|
103
60
|
export declare const playhtml: PlayHTMLComponents;
|
|
104
61
|
|
|
105
62
|
declare interface PlayHTMLComponents {
|
|
106
63
|
init: typeof initPlayHTML;
|
|
107
64
|
setupPlayElement: typeof setupPlayElement;
|
|
65
|
+
removePlayElement: typeof removePlayElement;
|
|
66
|
+
setupPlayElementForTag: typeof setupPlayElementForTag;
|
|
108
67
|
globalData: Y.Map<any> | undefined;
|
|
109
68
|
elementHandlers: Map<string, Map<string, ElementHandler>> | undefined;
|
|
110
69
|
}
|
|
111
70
|
|
|
112
|
-
|
|
71
|
+
declare function removePlayElement(element: Element): void;
|
|
72
|
+
|
|
73
|
+
declare function setupPlayElement(element: Element): void;
|
|
113
74
|
|
|
114
75
|
/**
|
|
115
76
|
* Sets up a playhtml element to handle the given tag's capabilities.
|
|
116
77
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
declare enum TagType {
|
|
120
|
-
"CanPlay" = "can-play",
|
|
121
|
-
"CanMove" = "can-move",
|
|
122
|
-
"CanSpin" = "can-spin",
|
|
123
|
-
"CanGrow" = "can-grow",
|
|
124
|
-
"CanToggle" = "can-toggle",
|
|
125
|
-
"CanDuplicate" = "can-duplicate",
|
|
126
|
-
"CanPost" = "can-post"
|
|
127
|
-
}
|
|
78
|
+
declare function setupPlayElementForTag<T extends TagType>(element: HTMLElement, tag: T): void;
|
|
128
79
|
|
|
129
80
|
export { }
|