playhtml 2.0.1 → 2.0.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/CHANGELOG.md +4 -0
- package/dist/playhtml.es.js +1 -1
- package/dist/playhtml.umd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
|
|
4
4
|
|
|
5
|
+
## 2.0.2 - 2023-08-23
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
5
9
|
## 2.0.0 - 2023-08-23
|
|
6
10
|
|
|
7
11
|
- **BREAKING CHANGE**: Changed the initializing of playhtml to be an explicit call of `playhtml.init()` from just a normal import. You can still use the old code if you pin the import to any version 1.3.1 (e.g. use `https://unpkg.com/playhtml@1.3.1` as the import source).
|
package/dist/playhtml.es.js
CHANGED
|
@@ -9249,7 +9249,7 @@ function ci({
|
|
|
9249
9249
|
});
|
|
9250
9250
|
}
|
|
9251
9251
|
setTimeout(() => {
|
|
9252
|
-
se || (console.
|
|
9252
|
+
se || (console.error(
|
|
9253
9253
|
"You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."
|
|
9254
9254
|
), ci());
|
|
9255
9255
|
}, 3e3);
|
package/dist/playhtml.umd.js
CHANGED
|
@@ -9,4 +9,4 @@ ${e}`)}function Xn(s,e,t){const n=Z(e),i=L(),r=k(n),o=s.messageHandlers[r];retur
|
|
|
9
9
|
࿂࿂࿂࿂ booting up playhtml... ࿂࿂࿂࿂
|
|
10
10
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
11
11
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
12
|
-
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),ie=new tc(t,s,bs),$=bs.getMap("playhtml-global"),re=new Map,new kc(s,bs),Et.globalData=$,Et.elementHandlers=re,ie.on("sync",n=>{n||console.error("Issue connecting to yjs..."),Mc()})}setTimeout(()=>{ie||(console.
|
|
12
|
+
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),ie=new tc(t,s,bs),$=bs.getMap("playhtml-global"),re=new Map,new kc(s,bs),Et.globalData=$,Et.elementHandlers=re,ie.on("sync",n=>{n||console.error("Issue connecting to yjs..."),Mc()})}setTimeout(()=>{ie||(console.error("You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."),ys())},3e3);function Ac(s,e){const t=ie.awareness.getLocalState();return((t==null?void 0:t[s])??{})[e]}function _s(s){return s instanceof HTMLElement}function Ic(s,e,t,n){const i=$.get(e),r={...t,data:i.get(n)??t.defaultData,awareness:Ac(e,n)??t.myDefaultAwareness!==void 0?[t.myDefaultAwareness]:void 0,element:s,onChange:o=>{i.get(n)!==o&&i.set(n,o)},onAwarenessChange:o=>{var a;const c=((a=ie.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,ie.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{ci()}};return new Cc(r)}function Lc(s){return s.defaultData!==void 0&&s.updateElement!==void 0}function jc(s,e){if(s===E.CanPlay){const t=e;return{defaultData:t.defaultData,defaultLocalData:t.defaultLocalData,myDefaultAwareness:t.myDefaultAwareness,updateElement:t.updateElement,updateElementAwareness:t.updateElementAwareness,onDrag:t.onDrag,onDragStart:t.onDragStart,onClick:t.onClick,additionalSetup:t.additionalSetup,resetShortcut:t.resetShortcut,debounceMs:t.debounceMs}}return ri[s]}function ci(){const s=new Map;function e(t,n,i,r){s.has(t)||s.set(t,new Map);const o=s.get(t);o.has(n)||o.set(n,new Map),o.get(n).set(i,r)}ie.awareness.getStates().forEach((t,n)=>{var i;for(const[r,o]of Object.entries(t)){const c=re.get(r);if(c)for(const[a,l]of c){if(!(a in o))continue;const h=o[a];e(r,a,n,h)}}for(const[r,o]of s){const c=re.get(r);if(c)for(const[a,l]of c){const h=(i=o.get(a))==null?void 0:i.values();if(!h)continue;let u=Array.from(h);l.__awareness=u}}})}function Mc(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const s of Object.values(E)){const e=Array.from(document.querySelectorAll(`[${s}]`)).filter(_s);if(e.length)for(let t=0;t<e.length;t++){const n=e[t];Ct(n,s)}}ws&&($.observe(s=>{s.changes.keys.forEach((e,t)=>{e.action==="add"&&$.set(t,$.get(t))})}),ie.awareness.on("change",()=>ci()),ws=!1)}const Et={init:ys,setupPlayElement:ai,globalData:void 0,elementHandlers:void 0};window.playhtml=Et;function Tc(s){if(re.has(s))return;re.set(s,new Map),s!==E.CanPlay&&ri[s],$.get(s)||$.set(s,new de);const e=$.get(s);e.observe(t=>{t.changes.keys.forEach((n,i)=>{const r=re.get(s);if(n.action==="add"){const o=si(i);if(!_s(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}Ct(o,s)}else if(n.action==="update"){const o=r.get(i);o.__data=e.get(i)}else n.action==="delete"?r.delete(i):console.log(`Unhandled action: ${n.action}`)})})}function Uc(s,e){const t=s.getAttribute(e);switch(e){case E.CanPlay:case E.CanMove:case E.CanSpin:case E.CanGrow:case E.CanToggle:case E.CanPost:return!0;case E.CanDuplicate:return t?(document.getElementById(t)||console.warn(`${E.CanDuplicate} element (${s.id}) duplicate element ("${t}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function Ct(s,e){var c;if(!Uc(s,e))return;if(!s.id){const a=s.getAttribute("selector-id");if(a){const l=oi.get(a)??0;s.id=btoa(`${e}-${a}-${l}`),oi.set(a,l+1)}else s.id=btoa(`${e}-${s.innerHTML}}`)}const t=wc(s);if(!t){console.error(`Element ${s} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}Tc(e);const n=re.get(e);if(n.has(t))return;const i=jc(e,s);if(!Lc(i)){console.error(`Element ${t} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`);return}const r=$.get(e),o=Ic(s,e,i,t);n.set(t,o),r.get(t)===void 0&&i.defaultData!==void 0&&r.set(t,i.defaultData),(c=o.triggerAwarenessUpdate)==null||c.call(o),s.classList.add("__playhtml-element"),s.classList.add(`__playhtml-${e}`),s.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function ai(s){if(!_s(s)){console.log(`Element ${s.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(E))s.hasAttribute(e)&&Ct(s,e)}M.initPlayHTML=ys,M.playhtml=Et,M.setupPlayElement=ai,M.setupPlayElementForTag=Ct,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|