playhtml 2.0.16 → 2.0.18
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 +6 -4
- package/README.md +26 -25
- package/dist/main.d.ts +4 -4
- package/dist/playhtml.es.js +1268 -1110
- package/dist/playhtml.umd.js +11 -0
- package/package.json +4 -5
- package/dist/init.cjs.js +0 -1
- package/dist/init.d.ts +0 -1
- package/dist/init.es.js +0 -6
- package/dist/playhtml.cjs.js +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## [Unreleased]
|
|
6
6
|
|
|
7
|
-
**BREAKING
|
|
7
|
+
- **BREAKING CHANGE**Changed the hash function used to generate element ids. This will cause all elements without an `id` to be re-created to lose any persistent historical data. This was done to avoid duplicates and to swap to using a standard-length hash function (SHA-1). We still recommend you setting a unique `id` for each element to avoid any potential duplicates in the future, and using `selectorId` will not be affected by this change.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
## 2.0.16 - 2024-01-04
|
|
10
|
+
|
|
11
|
+
- **BREAKING CHANGE** deprecated using non-object values as `defaultData` for elements. If you were using a single value before, instead, use an object with a `value` key. e.g. `defaultData: { value: "my value" }`. This allows for easier extension of the data in the future.
|
|
12
|
+
- **BREAKING CHANGE** deprecated `playhtml.init()` automatically being called to avoid side-effects upon import. This has been replaced with a new `init` file that you can directly import if you'd like to auto-initialize without any settings. See the README for more details.
|
|
11
13
|
- exported `setupPlayElements` to call to look for any new elements to initialize
|
|
12
14
|
|
|
13
15
|
## 2.0.7 - 2023-10-02
|
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@ https://github.com/spencerc99/playhtml/assets/14796580/00e84e15-2c1c-4b4b-8e15-2
|
|
|
12
12
|
|
|
13
13
|
If you enjoy this, please consider [sponsoring the project or sending a small donation](https://github.com/sponsors/spencerc99). This helps ensure that the library is maintained and improved over time and funds the hosting costs for the syncing and persistence services.
|
|
14
14
|
|
|
15
|
+
Join our [Discord community](https://discord.gg/h7sABTv8) to get help and show off what you've built!
|
|
16
|
+
|
|
15
17
|
## Usage
|
|
16
18
|
|
|
17
19
|
Head to the proper section depending on your technology preference:
|
|
@@ -34,19 +36,21 @@ To use this library, you can import the library and the associated styles from a
|
|
|
34
36
|
id="openSign"
|
|
35
37
|
<!-- INVALID EXAMPLE <img src="https://media2.giphy.com/media/lL7A3Li0YtFHq/giphy.gif?cid=ecf05e47ah89o71gzz7ke7inrgb1ai1xcbrjnqdf7o890118&ep=v1_stickers_search&rid=giphy.gif" can-move /> -->
|
|
36
38
|
<!-- import the script -->
|
|
39
|
+
|
|
40
|
+
<!-- Option 1 (simplest, no customization) -->
|
|
41
|
+
<script
|
|
42
|
+
type="module"
|
|
43
|
+
src="https://unpkg.com/playhtml@latest/dist/init.es.js"
|
|
44
|
+
></script>
|
|
45
|
+
|
|
46
|
+
<!-- Option 2 (customize options to use your own partykit provider or specify the room) -->
|
|
37
47
|
<script type="module">
|
|
38
48
|
import "https://unpkg.com/playhtml@latest";
|
|
39
|
-
playhtml.init(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// host: "mypartykit.user.partykit.dev"
|
|
44
|
-
// })
|
|
49
|
+
playhtml.init({
|
|
50
|
+
room: "my-room",
|
|
51
|
+
host: "mypartykit.user.partykit.dev",
|
|
52
|
+
});
|
|
45
53
|
</script>
|
|
46
|
-
<link
|
|
47
|
-
rel="stylesheet"
|
|
48
|
-
href="https://unpkg.com/playhtml@latest/dist/style.css"
|
|
49
|
-
/>
|
|
50
54
|
</body>
|
|
51
55
|
```
|
|
52
56
|
|
|
@@ -159,24 +163,21 @@ https://github.com/spencerc99/playhtml/assets/14796580/fae669b1-b3e2-404e-bd7a-3
|
|
|
159
163
|
<!-- IMPORTANT: this data must be set _before_ importing the playhtml library. -->
|
|
160
164
|
<script>
|
|
161
165
|
let candle = document.getElementById("customCandle");
|
|
162
|
-
candle.defaultData = true;
|
|
166
|
+
candle.defaultData = { on: true };
|
|
163
167
|
candle.onClick = (_e, { data, setData }) => {
|
|
164
|
-
setData(!data);
|
|
168
|
+
setData({ on: !data.on });
|
|
165
169
|
};
|
|
166
|
-
candle.updateElement = ({ data }) => {
|
|
167
|
-
|
|
170
|
+
candle.updateElement = ({ element, data }) => {
|
|
171
|
+
element.src = data.on ? "/candle-gif.gif" : "/candle-off.png";
|
|
168
172
|
};
|
|
169
173
|
candle.resetShortcut = "shiftKey";
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
setData(!data);
|
|
173
|
-
};
|
|
174
|
-
// The above statement could also be done using the `additionalSetup`
|
|
174
|
+
|
|
175
|
+
// If you wanted to trigger this on hover, you could use `additionalSetup`
|
|
175
176
|
// which can initialize several different event listeners and custom logic.
|
|
176
177
|
// customCandle.additionalSetup = ({ getData, setData }) => {
|
|
177
|
-
// customCandle.addEventListener("
|
|
178
|
+
// customCandle.addEventListener("mouseover", (_e) => {
|
|
178
179
|
// const data = getData();
|
|
179
|
-
// setData(!data);
|
|
180
|
+
// setData({on: !data.on}});
|
|
180
181
|
// });
|
|
181
182
|
// };
|
|
182
183
|
</script>
|
|
@@ -186,10 +187,6 @@ https://github.com/spencerc99/playhtml/assets/14796580/fae669b1-b3e2-404e-bd7a-3
|
|
|
186
187
|
import "https://unpkg.com/playhtml@latest";
|
|
187
188
|
playhtml.init();
|
|
188
189
|
</script>
|
|
189
|
-
<link
|
|
190
|
-
rel="stylesheet"
|
|
191
|
-
href="https://unpkg.com/playhtml@latest/dist/style.css"
|
|
192
|
-
/>
|
|
193
190
|
```
|
|
194
191
|
|
|
195
192
|
See all supported properties in the `ElementInitializer` [object in `types.ts`](https://github.com/spencerc99/playhtml/blob/main/src/types.ts#L13).
|
|
@@ -240,6 +237,10 @@ Creates an element that can be resized using a `scale` `transform`. Clicking the
|
|
|
240
237
|
|
|
241
238
|
Creates a rotatable element using a `rotate` `transform` on the element. Dragging the element to the left or right will rotate it counter-clockwise and clockwise respectively.
|
|
242
239
|
|
|
240
|
+
## Help & Community
|
|
241
|
+
|
|
242
|
+
Join our [Discord community](https://discord.gg/h7sABTv8) to get help and show off what you've built!
|
|
243
|
+
|
|
243
244
|
## Data Policy
|
|
244
245
|
|
|
245
246
|
Currently all data is stored by a [Partykit](https://partykit.dev) instance under my account and is not encrypted. This means that anyone with the room name can access the data. In the future, I'd like to enable providing your own custom persistence options via object storage providers (or any generic service that can accept a POST endpoint with a dump of the data).
|
package/dist/main.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { ElementAwarenessEventHandlerData } from '@playhtml/common';
|
|
4
4
|
import { ElementData } from '@playhtml/common';
|
|
5
5
|
import { ElementEventHandlerData } from '@playhtml/common';
|
|
6
|
-
import { ElementInitializer } from '
|
|
6
|
+
import { ElementInitializer } from '../../common/src/index';
|
|
7
7
|
import { ElementSetupData } from '@playhtml/common';
|
|
8
8
|
import { ModifierKey } from '@playhtml/common';
|
|
9
|
-
import { TagType } from '
|
|
9
|
+
import { TagType } from '../../common/src/index';
|
|
10
10
|
import * as Y from 'yjs';
|
|
11
11
|
import YPartyKitProvider from 'y-partykit/provider';
|
|
12
12
|
|
|
@@ -47,7 +47,7 @@ declare class ElementHandler<T = any, U = any, V = any> {
|
|
|
47
47
|
* Public-use setter for data that makes the change to all clients.
|
|
48
48
|
*/
|
|
49
49
|
setData(data: T): void;
|
|
50
|
-
|
|
50
|
+
setMyAwareness(data: V): void;
|
|
51
51
|
setDataDebounced(data: T): void;
|
|
52
52
|
/**
|
|
53
53
|
* Resets the element to its default state.
|
|
@@ -92,6 +92,6 @@ declare function setupPlayElement(element: Element, { ignoreIfAlreadySetup }?: {
|
|
|
92
92
|
/**
|
|
93
93
|
* Sets up a playhtml element to handle the given tag's capabilities.
|
|
94
94
|
*/
|
|
95
|
-
declare function setupPlayElementForTag<T extends TagType | string>(element: HTMLElement, tag: T): void
|
|
95
|
+
declare function setupPlayElementForTag<T extends TagType | string>(element: HTMLElement, tag: T): Promise<void>;
|
|
96
96
|
|
|
97
97
|
export { }
|