@petit-kit/scoped 0.0.2 → 0.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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  <br />
7
7
  <br />
8
8
 
9
- # Scoped - 0.0.1
9
+ # Scoped - 0.0.5
10
10
 
11
11
  ### A lightweight, framework-agnostic library for building web components with reactive state, bindings, lifecycle hooks, template-based rendering and plugins.
12
12
 
@@ -179,9 +179,12 @@ return () => `
179
179
  Use `on:eventName="handler"` to bind events, where `handler` is a function from your `actions` object or setup context:
180
180
 
181
181
  ```typescript
182
- return () => `
183
- <button on:click="actions.save">Save</button>
184
- `;
182
+ ({ actions }) => {
183
+ actions.addThing = () => console.log('addThing');
184
+ return () => `
185
+ <button on:click="addThing">Add thing</button>
186
+ `;
187
+ };
185
188
  ```
186
189
 
187
190
  Arrow functions or direct expressions are not supported; you must use named action references.
@@ -241,6 +244,10 @@ You can update state in two main ways:
241
244
  - `host.updateState(partial)`: Merges the partial state and only schedules effects/computed, but does NOT re-render the template.
242
245
 
243
246
  ```typescript
247
+ // Initialize state in setup (no re-render)
248
+ state.count = 0;
249
+ state.status = 'idle';
250
+
244
251
  // Initialize state in setup (optional)
245
252
  host.setState({ count: 0, status: 'idle' });
246
253
 
@@ -479,7 +486,7 @@ Lifecycle hooks let you run code at specific moments in the component's life, su
479
486
 
480
487
  # Plugins
481
488
 
482
- Scoped includes a set of optional plugins to extend or enhance component behavior. You can import any of these plugins and register them via the `plugins` option or the `use()` method.
489
+ Scoped includes a set of optional plugins to extend or enhance component behavior. You can import any of these plugins and register them via the `plugins` option.
483
490
 
484
491
  **Available Plugins:**
485
492
 
@@ -507,6 +514,9 @@ Scoped includes a set of optional plugins to extend or enhance component behavio
507
514
  - **[mousePlugin](src/plugins/mouse/README.md)**
508
515
  Tracks mouse position, mouse events, and allows you to listen to wheel/pointer activity.
509
516
 
517
+ - **[pointerPlugin](src/plugins/pointer/README.md)**
518
+ Lerp mouse position
519
+
510
520
  **Usage Example:**
511
521
 
512
522
  ```javascript
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function t(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:s}=e;if(null==t)return s;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?s:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:try{return"string"==typeof t?JSON.parse(t):t}catch{return s}case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return Array.isArray(s)?s:[]}default:return t}}catch{return s}}function e(t,e,n,s){if(!s||"object"!=typeof s||!s.reflect)return;let i=null;const o=s.type;if(o===Boolean)return n?void t.setAttribute(e,""):void t.removeAttribute(e);if(o===Object||o===Array)try{i=null==n?null:JSON.stringify(n)}catch{i=null}else i=null==n?null:String(n);null==i?t.removeAttribute(e):t.setAttribute(e,i)}const n=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,s=new Set,i={setTimeout:(t,n,...s)=>{let i;return i=setTimeout((...n)=>{e.delete(i),t(...n)},n,...s),e.add(i),i},setInterval:(t,e,...s)=>{const i=setInterval(t,e,...s);return n.add(i),i},raf:(t,e)=>{let n=0,i=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(s.delete(n),i){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),s.add(n)}};return n=requestAnimationFrame(c),s.add(n),()=>{i&&(i=!1,s.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of s)cancelAnimationFrame(t);s.clear()}),{timer:i}}}),s=t=>Array.isArray(t),i=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),o=t=>s(t)?t.slice():i(t)?{...t}:t,r=(t,e)=>{if(s(t)&&s(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(i(t)&&i(e)){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const s of n){if(!(s in e))return!1;if(!Object.is(t[s],e[s]))return!1}return!0}return!(s(t)||s(e)||i(t)||i(e))&&Object.is(t,e)},c=(t,e)=>Array.from({length:e},()=>t),h=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),f=({from:t,to:e,velocity:n,label:o})=>{const r={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},f=t=>{if(null==r.arrayLength){if(null!=r.objectKeys)throw new Error(`${o} value shape mismatch (array vs object).`);r.arrayLength=t,s(r.value)||(r.value=c(r.value,t)),s(r.target)||(r.target=c(r.target,t)),void 0===r.velocity||s(r.velocity)||(r.velocity=c(r.velocity,t))}},u=t=>{if(null==r.objectKeys){if(null!=r.arrayLength)throw new Error(`${o} value shape mismatch (object vs array).`);r.objectKeys=t,i(r.value)||(r.value=h(r.value,t)),i(r.target)||(r.target=h(r.target,t)),void 0===r.velocity||i(r.velocity)||(r.velocity=h(r.velocity,t))}},l=t=>{if(s(t)){if(null!=r.objectKeys)throw new Error(`${o} value shape mismatch (array vs object).`);if(null==r.arrayLength&&f(t.length),t.length!==r.arrayLength)throw new Error(`${o} value length mismatch (expected ${r.arrayLength}, got ${t.length}).`);return t.slice()}if(i(t)){if(null!=r.arrayLength)throw new Error(`${o} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==r.objectKeys&&u(e),r.objectKeys&&e.length!==r.objectKeys.length)throw new Error(`${o} value keys mismatch (expected ${r.objectKeys.length}, got ${e.length}).`);if(r.objectKeys)for(const e of r.objectKeys)if(!(e in t))throw new Error(`${o} value keys mismatch (missing key "${e}").`);return{...t}}return null!=r.arrayLength?c(t,r.arrayLength):null!=r.objectKeys?h(t,r.objectKeys):t};r.normalizeInput=l;const a=s(t)||s(e)||void 0!==n&&s(n),d=i(t)||i(e)||void 0!==n&&i(n);if(a&&d)throw new Error(`${o} value shape mismatch (array vs object).`);if(a){const i=s(t)?t.length:s(e)?e.length:n.length;f(i),r.value=l(t),r.target=l(e),void 0!==r.velocity&&(r.velocity=l(r.velocity))}else if(d){const s=i(t)?Object.keys(t):i(e)?Object.keys(e):Object.keys(n);u(s),r.value=l(t),r.target=l(e),void 0!==r.velocity&&(r.velocity=l(r.velocity))}return r},u="0.0.1",l=/\{([A-Za-z_$][\w$]*)\}/g;exports.SCOPE_VERSION=u,exports.define=function(n,s={},i){const{props:o={},shadow:r=!1,styles:c,plugins:h}=s,f=h??[],a=()=>{};class d extends HTMLElement{constructor(){super(),this.version=u,this.t={};for(const t of Object.keys(o)){const e=o[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.i=null,this.o=null,this.h=!1,this.u=!1,this.l=r,this.p=r?this.attachShadow({mode:"open"}):this,this.m=null,this.v=[],this.S=[],this.j=[],this.O=[],this.M=[],this._=[],this.$=[],this.A=[],this.T=new Map,this.k=!1,this.L=!1,this.F={},this.I=!1,this.R=n,this.V=!1,this.C=new Set,this.H=!1,this.D=new Map,this.U=0,this.q=!1}B(t){const e=this.l?this.p.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(o)}attributeChangedCallback(e,n,s){if(n===s)return;const i=this.t[e],o=this.F[e],r=t(s,i);if(this.props[e]=r,this.k&&o!==r)for(const t of this.A)try{t(e,o,r)}catch(t){a(String(t?.message||t))}this.F[e]=r,this.C.has(e)?this.C.delete(e):this.i&&this.isConnected?this.H?this.V=!0:this.update(!0):this.V=!0}connectedCallback(){for(const e in this.t){if(!this.t.hasOwnProperty(e))continue;const n=t(this.getAttribute(e),this.t[e]);this.props[e]=n,this.F[e]=n}r||this.m||(this.m=this.N());let n=null;try{if(i){const t={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this.M.push(t),onBeforeUpdate:t=>this._.push(t),onFirstUpdate:t=>this.$.push(t),onPropsChanged:t=>this.A.push(t),link:(t,n)=>{const s=n||t;this.state[s]=this.props[t],this.A.push((e,n,i)=>{e===t&&(Object.is(this.state[s],i)||(this.state[s]=i))});const i={fn:()=>{const n=this.state[s];if(Object.is(this.props[t],n))return;this.props[t]=n,this.F[t]=n;const i=this.t[t],o=i?{...i,reflect:!0}:i,r=this.getAttribute(t);this.C.add(t),e(this,t,n,o),r===this.getAttribute(t)&&this.C.delete(t)},deps:()=>[this.state[s]]};this.v.push(i)},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const s={getter:t,deps:e,value:void 0!==e?t(n):t()};this.S.push(s);const i=()=>s.value;return i.W=s,this.J(i),i},effect:(t,e)=>{const n={fn:t,deps:e};return this.v.push(n),()=>this.P(n)},delegate:(t,e,n)=>(this.K(t,e,n),()=>this.Z(t,e,n))};for(const e of f)if(e)try{const n=e.extend(t,this);n&&"object"==typeof n&&Object.assign(t,n)}catch(t){a(String(t?.message||t))}n=i(t)}}catch(t){String(t?.message||t)}if(this.i="function"!=typeof n?()=>"":n,this.H=!0,this.update(!0),this.H=!1,this.V&&(this.V=!1,this.update(!0)),!this.k){this.k=!0;for(const t of this.j)try{t()}catch(t){a(String(t?.message||t))}}}disconnectedCallback(){this.destroy()}remove(){super.remove()}destroy(){for(const t of this.O)try{t()}catch(t){a(String(t?.message||t))}for(const t of this.v)if(t.cleanup){try{t.cleanup()}catch(t){a(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.T)try{this.p.removeEventListener(t.eventType,t.listener)}catch{}this.T.clear(),this.k=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,s){const i=n;t.addEventListener(e,i,s);const o=()=>{try{t.removeEventListener(e,i,s)}catch{}};return this.O.push(o),o}setState(t){let e=!1;const n=t,s=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const i=n[t];Object.is(s[t],i)||(s[t]=i,e=!0)}if(e)if(this.H||!this.k)this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0,requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&this.update(!0)})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.G()}setProps(t){const n=Object.keys(t);if(0===n.length)return;const s=[];for(const i of n){const n=t[i],o=this.F[i];this.props[i]=n,this.k&&o!==n&&s.push(i);const r=this.t[i];r&&r.reflect&&e(this,i,n,r),this.k&&o===n||(this.F[i]=n)}if(this.k&&s.length>0)for(const e of s){const n=this.F[e],s=t[e];for(const t of this.A)try{t(e,n,s)}catch(t){a(String(t?.message||t))}}this.i&&this.isConnected?this.update(!0):this.V=!0}scheduleUpdate(){this.i&&this.isConnected&&this.G()}G(){this.u||this.h||(this.u=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.u=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.k)for(const t of this._)try{t()}catch(t){a(String(t?.message||t))}if(t){this.X();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}if("string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e)=>{const n={...this.props,...e};return t.replace(l,(t,e)=>{const s=n[e];return null==s?"":String(s)})})(t,this.state),!this.l){const e=`data-scope-owner="${this.R}"`;t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot ${e}$1`)}this.q=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.k||(this.l,this.p.innerHTML=t,this.o=t,n=!0),this.H?(this.Y(),("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{this.i&&this.isConnected&&(n&&!r&&this.projectSlots(),n&&this.tt(),this.et(),this.nt())})):(n&&!r&&this.projectSlots(),n&&this.st(),this.et(),this.nt())}else this.q&&this.X(),this.et(),this.k&&this.nt()}}forceRender(){this.o=null,this.i&&this.isConnected?this.H?this.V=!0:this.update(!0):this.V=!0}nt(){if(!this.L){this.L=!0;for(const t of this.$)try{t()}catch(t){a(String(t?.message||t))}}for(const t of this.M)try{t()}catch(t){a(String(t?.message||t))}this.it()}it(){const t=(this.l?this.p:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,s=this.props;this.actions;for(let i=0;i<t.length;i++){const o=t[i];if(this.B(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const i=r[t];if(!i.name.startsWith("bind:"))continue;const c=i.name.slice(5),h=i.value,f=h?h.trim():"";let u,l=!1;if(f){const t=this.D.get(f);if(t){t.W&&(this.q=!0);try{u=t()}catch{}l=!0}}if(!l){const t=f||c,i=e.call(n,t),o=!i&&e.call(s,t);i?u=n[t]:o&&(u=s[t])}if("text"===c){const t=null==u?"":String(u);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==u?"":String(u);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],u))try{o[c]=u}catch{}if("value"===c)try{null==u?o.removeAttribute("value"):o.setAttribute("value",String(u))}catch{}}else if(null!=u)try{o.setAttribute(c,String(u))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ot;t&&o.removeEventListener(t,d),delete o[a]}}}}X(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(s)&&(e=s,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let s=0;s<e.length;s++)if(!Object.is(t.prevDeps[s],e[s])){n=!0;break}}}catch(t){a(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){a(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}et(){for(const t of this.v){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(s)&&(e=s,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let s=0;s<e.length;s++)if(!Object.is(t.prevDeps[s],e[s])){n=!0;break}}}catch(t){a(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}P(t){const e=this.v.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.v.splice(e,1)}}J(t){const e=t.rt;if(e&&"string"==typeof e)return this.D.set(e,t),e;const n=`__scope_bind_${++this.U}__`;this.D.set(n,t);try{t.rt=n,t.toString=()=>n}catch{}return n}Y(){const t=(this.l?this.p:this).querySelectorAll("[ref]"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];if(0!==t.length)for(let n=0;n<t.length;n++){const s=t[n];if(this.B(s))continue;const i=s.getAttribute("ref");i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s)}}tt(){const t=(this.l?this.p:this).querySelectorAll("*");for(let e=0;e<t.length;e++){const n=t[e];if(this.B(n))continue;if(0===n.attributes.length)continue;const s=n.attributes;for(let t=s.length-1;t>=0;t--){const e=s[t];if(!e.name.startsWith("on:"))continue;const i=e.name.slice(3),o=e.value,r=`__tinyHandler_${i}`,c=n[r];c&&n.removeEventListener(i,c),n.removeAttribute(e.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};n[r]=t,n.addEventListener(i,t)}}}}st(){const t=(this.l?this.p:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const s=t[n];if(this.B(s))continue;const i=s.getAttribute("ref");if(i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s),s.attributes.length>0){const t=s.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const i=n.name.slice(3),o=n.value,r=`__tinyHandler_${i}`,c=s[r];c&&s.removeEventListener(i,c),s.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};s[r]=t,s.addEventListener(i,t)}}}}}N(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const s=n[e];let i="";1===s.nodeType&&s.getAttribute&&(i=s.getAttribute("slot")||""),t.has(i)||t.set(i,[]),t.get(i).push(s)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.m||new Map,e=(this.l?this.p:this).querySelectorAll(`slot[data-scope-owner="${this.R}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const s=e[n],i=s.getAttribute("name")||"",o=t.get(i)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let s;if(1===n.nodeType&&n.tagName.includes("-")&&n.m instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const s=t.attributes[n];e.setAttribute(s.name,s.value)}for(const n of t.m.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));s=e}else s=n.cloneNode(!0);t.appendChild(s)}s.replaceWith(t)}else{const t=s.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);s.replaceWith(t)}}}}K(t,e,n){const s=`${t}::${e}`;let i=this.T.get(s);if(!i){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of i.handlers)try{e(t,n)}catch{}};i={eventType:t,selector:e,listener:n,handlers:new Set},this.T.set(s,i),this.p.addEventListener(t,n)}i.handlers.add(n)}Z(t,e,n){const s=`${t}::${e}`,i=this.T.get(s);if(i&&(i.handlers.delete(n),0===i.handlers.size)){try{this.p.removeEventListener(t,i.listener)}catch{}this.T.delete(s)}}}if(!customElements.get(n)){if(c&&"undefined"!=typeof document){const t=`scope-${n}-styles`;if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=c,document.head.appendChild(e)}}try{customElements.define(n,d)}catch(t){String(t?.message||t)}}return d},exports.devicePlugin=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,s={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:i=!0}=s,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),i&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),exports.inViewPlugin=()=>({name:"inview",extend:(t,e)=>{const n=new Set,s=(t,e,s={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:i=!0,...o}=s;let r=!i;const c=new IntersectionObserver(n=>{for(const s of n)s.target===t&&(r?r=!1:e(s.isIntersecting,s))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>s(e,t,n),observeInView:(t,e,n)=>s(t,e,n)}}}),exports.lenisPlugin=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const s=t();if(!s)return()=>{};const i=t=>{e(t)};s.on("scroll",i);const o={lenis:s,handler:i};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof s.off&&s.off("scroll",i))}}}}}),exports.lerpPlugin=()=>({name:"lerp",extend:t=>{const{timer:e}=n().extend(t,t.host),c=new Set;return t.onDestroy(()=>{for(const t of c)t();c.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:c=.001,resumeOnTarget:h=!0}={}){function u(){return o(p)}function l(t){if(w)return u();const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return u();if(1===e)return p=o(m),a.value=p,w=!0,u();const r=t>0?1-Math.pow(1-e,60*t):0;if(s(p)&&s(m)){let t=!0;for(let e=0;e<p.length;e+=1)p[e]+=(m[e]-p[e])*r,Math.abs(m[e]-p[e])>=c&&(t=!1);if(t){for(let t=0;t<p.length;t+=1)p[t]=m[t];w=!0}return a.value=p,o(p)}if(i(p)&&i(m)){const t=a.objectKeys??Object.keys(p);let e=!0;for(const n of t)p[n]+=(m[n]-p[n])*r,Math.abs(m[n]-p[n])>=c&&(e=!1);if(e){for(const e of t)p[e]=m[e];w=!0}return a.value=p,o(p)}const h=m;return p+=(h-p)*r,a.value=p,Math.abs(h-p)<c&&(p=h,a.value=p,w=!0),p}const a=f({from:t,to:e,label:"Lerp"}),d=a.normalizeInput;let p=a.value,m=a.target,y=null,w=!1;const g=new Set;return{setTarget:function(t){const e=d(t),n=!r(e,m);if(m=e,a.target=e,p=a.value,h&&w&&n){w=!1,y=null;for(const t of g)t(m)}},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:s=!1,markDone:i=!1}=e;p=d(t),a.value=p,s&&(m=o(p),a.target=m);const c=w||!r(p,m);if(n&&(y=null),i&&(w=!0),c&&!i){w=!1,y=null;for(const t of g)t(m)}},getValue:u,isDone:function(){return w},onResume:function(t){return g.add(t),()=>{g.delete(t)}},step:l,next:function(t=performance.now()){if(null==y)return y=t,u();const e=(t-y)/1e3;y=t;const n=1/30;let s=e,i=u();for(;s>0&&!w;){const t=Math.min(s,n);i=l(t),s-=t}return i}}}(t),runLerp:(t,n,s={})=>{const{fps:i,immediate:o=!0,stopWhenDone:r=!0}=s;let h=!1,f=null;o&&n(t.getValue(),t);const u=()=>{f||(f=e.raf(e=>{if(h)return;const s=t.next(e);n(s,t),r&&t.isDone()&&l()},i))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&r&&(o&&n(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),c.delete(d))};return c.add(d),d}}}}),exports.morphPlugin=(t,e={})=>({name:"morph",extend:(n,s)=>{const{ignoreActiveValue:i=!0,callbacks:o}=e,r=t(),c=s,h=c.p,f=c.l?ShadowRoot.prototype:HTMLElement.prototype,u=Object.getOwnPropertyDescriptor(f,"innerHTML"),l=t=>{r.morph(h,t,{morphStyle:"innerHTML",ignoreActiveValue:i,callbacks:o})};let a=!0;return Object.defineProperty(h,"innerHTML",{set(t){a?(u.set.call(this,t),a=!1):l(t)},get(){return u.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete h.innerHTML}),{morph:l}}}),exports.mousePlugin=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const s=t=>{const e=t;n(e.clientX,e.clientY,e)};window.addEventListener(t,s);let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(s),()=>{window.removeEventListener(t,s),i?.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{const n=e;t(n.clientX,n.clientY,n.deltaY,n)};window.addEventListener("wheel",n);let s=e.get("wheel");return s||(s=new Set,e.set("wheel",s)),s.add(n),()=>{window.removeEventListener("wheel",n),s?.delete(n)}})(t)}}}),exports.springPlugin=()=>({name:"spring",extend:t=>{const{timer:e}=n().extend(t,t.host),u=new Set;return t.onDestroy(()=>{for(const t of u)t();u.clear()}),{createSpring:t=>function({from:t=0,to:e=1,mass:n=1,stiffness:u=120,damping:l=14,velocity:a=0,tolerance:d=.001,resumeOnTarget:p=!0}={}){function m(){return o(b)}function y(t){if(O)return m();if(s(b)&&s(S)&&s(v)){let e=!0;for(let s=0;s<b.length;s+=1){const i=b[s]-S[s],o=(-u*i-l*v[s])/n;v[s]+=o*t,b[s]+=v[s]*t;const r=b[s]-S[s];(Math.abs(v[s])>=d||Math.abs(r)>=d)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=S[t],v[t]=0;O=!0}return w.value=b,w.velocity=v,o(b)}if(i(b)&&i(S)&&i(v)){const e=w.objectKeys??Object.keys(b);let s=!0;for(const i of e){const e=b[i]-S[i],o=(-u*e-l*v[i])/n;v[i]+=o*t,b[i]+=v[i]*t;const r=b[i]-S[i];(Math.abs(v[i])>=d||Math.abs(r)>=d)&&(s=!1)}if(s){for(const t of e)b[t]=S[t],v[t]=0;O=!0}return w.value=b,w.velocity=v,o(b)}const e=S;let r=v;r+=(-u*(b-e)-l*r)/n*t,b+=r*t,v=r,w.value=b,w.velocity=v;const c=b-e;return Math.abs(r)<d&&Math.abs(c)<d&&(b=e,v=0,w.value=b,w.velocity=v,O=!0),b}const w=f({from:t,to:e,velocity:a,label:"Spring"}),g=w.normalizeInput;let b=w.value,v=w.velocity??a,S=w.target,j=null,O=!1;const M=new Set;return{setTarget:function(t){const e=g(t),n=!r(e,S);if(S=e,w.target=e,b=w.value,p&&O&&n){O=!1,j=null;for(const t of M)t(S)}},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:s=!0,setTarget:i=!1,markDone:f=!1}=e;b=g(t),w.value=b,i&&(S=o(b),w.target=S);const u=O||!r(b,S);if(n&&(v=null!=w.arrayLength?c(0,w.arrayLength):null!=w.objectKeys?h(0,w.objectKeys):0,w.velocity=v),s&&(j=null),f&&(O=!0),u&&!f){O=!1,j=null;for(const t of M)t(S)}},getValue:m,isDone:function(){return O},onResume:function(t){return M.add(t),()=>{M.delete(t)}},step:y,next:function(t=performance.now()){if(null==j)return j=t,m();const e=(t-j)/1e3;j=t;const n=1/30;let s=e,i=m();for(;s>0&&!O;){const t=Math.min(s,n);i=y(t),s-=t}return i}}}(t),runSpring:(t,n,s={})=>{const{fps:i,immediate:o=!0,stopWhenDone:r=!0}=s;let c=!1,h=null;o&&n(t.getValue(),t);const f=()=>{h||(h=e.raf(e=>{if(c)return;const s=t.next(e);n(s,t),r&&t.isDone()&&l()},i))},l=()=>{h&&(h(),h=null)};f();const a=t.onResume(()=>{!c&&r&&(o&&n(t.getValue(),t),f())}),d=()=>{c||(c=!0,a(),l(),u.delete(d))};return u.add(d),d}}}}),exports.timerPlugin=n,exports.windowPlugin=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,s=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=n,i=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",i),e.add(i),s&&i(new UIEvent("resize")),()=>{window.removeEventListener("resize",i),e.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of n)t.disconnect();n.clear()}}),{onViewportResize:s,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return s((e,n,s)=>t(e,n,s),e);const{immediate:i=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:s,height:i}=n.contentRect;t(s,i,n)});if(r.observe(o),n.add(r),i){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),n.delete(r)}}}}});
1
+ "use strict";function t({from:t=0,to:e=1,mass:n=1,stiffness:s=120,damping:i=14,velocity:a=0,tolerance:d=.001,resumeOnTarget:p=!0}={}){function m(){return c(v)}function w(t){if(M)return m();if(o(v)&&o(S)&&o(b)){let e=!0;for(let o=0;o<v.length;o+=1){const r=v[o]-S[o],c=(-s*r-i*b[o])/n;b[o]+=c*t,v[o]+=b[o]*t;const h=v[o]-S[o];(Math.abs(b[o])>=d||Math.abs(h)>=d)&&(e=!1)}if(e){for(let t=0;t<v.length;t+=1)v[t]=S[t],b[t]=0;M=!0}return y.value=v,y.velocity=b,c(v)}if(r(v)&&r(S)&&r(b)){const e=y.objectKeys??Object.keys(v);let o=!0;for(const r of e){const e=v[r]-S[r],c=(-s*e-i*b[r])/n;b[r]+=c*t,v[r]+=b[r]*t;const h=v[r]-S[r];(Math.abs(b[r])>=d||Math.abs(h)>=d)&&(o=!1)}if(o){for(const t of e)v[t]=S[t],b[t]=0;M=!0}return y.value=v,y.velocity=b,c(v)}const e=S;let h=b;h+=(-s*(v-e)-i*h)/n*t,v+=h*t,b=h,y.value=v,y.velocity=b;const f=v-e;return Math.abs(h)<d&&Math.abs(f)<d&&(v=e,b=0,y.value=v,y.velocity=b,M=!0),v}const y=u({from:t,to:e,velocity:a,label:"Spring"}),g=y.normalizeInput;let v=y.value,b=y.velocity??a,S=y.target,j=null,M=!1;const O=new Set;return{setTarget:function(t){const e=g(t),n=!h(e,S);if(S=e,y.target=e,v=y.value,p&&M&&n){M=!1,j=null;for(const t of O)t(S)}},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:s=!0,setTarget:i=!1,markDone:o=!1}=e;v=g(t),y.value=v,i&&(S=c(v),y.target=S);const r=M||!h(v,S);if(n&&(b=null!=y.arrayLength?f(0,y.arrayLength):null!=y.objectKeys?l(0,y.objectKeys):0,y.velocity=b),s&&(j=null),o&&(M=!0),r&&!o){M=!1,j=null;for(const t of O)t(S)}},getValue:m,isDone:function(){return M},onResume:function(t){return O.add(t),()=>{O.delete(t)}},step:w,next:function(t=performance.now()){if(null==j)return j=t,m();const e=(t-j)/1e3;j=t;const n=1/30;let s=e,i=m();for(;s>0&&!M;){const t=Math.min(s,n);i=w(t),s-=t}return i}}}function e(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:s}=e;if(null==t)return s;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?s:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:try{return"string"==typeof t?JSON.parse(t):t}catch{return s}case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return Array.isArray(s)?s:[]}default:return t}}catch{return s}}function n(t,e,n,s){if(!s||"object"!=typeof s||!s.reflect)return;let i=null;const o=s.type;if(o===Boolean)return n?void t.setAttribute(e,""):void t.removeAttribute(e);if(o===Object||o===Array)try{i=null==n?null:JSON.stringify(n)}catch{i=null}else i=null==n?null:String(n);null==i?t.removeAttribute(e):t.setAttribute(e,i)}const s=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,s=new Set,i={setTimeout:(t,n,...s)=>{let i;return i=setTimeout((...n)=>{e.delete(i),t(...n)},n,...s),e.add(i),i},setInterval:(t,e,...s)=>{const i=setInterval(t,e,...s);return n.add(i),i},raf:(t,e)=>{let n=0,i=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(s.delete(n),i){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),s.add(n)}};return n=requestAnimationFrame(c),s.add(n),()=>{i&&(i=!1,s.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of s)cancelAnimationFrame(t);s.clear()}),{timer:i}}}),i=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const s=t=>{const e=t;n(e.clientX,e.clientY,e)};window.addEventListener(t,s);let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(s),()=>{window.removeEventListener(t,s),i?.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{const n=e;t(n.clientX,n.clientY,n.deltaY,n)};window.addEventListener("wheel",n);let s=e.get("wheel");return s||(s=new Set,e.set("wheel",s)),s.add(n),()=>{window.removeEventListener("wheel",n),s?.delete(n)}})(t)}}}),o=t=>Array.isArray(t),r=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),c=t=>o(t)?t.slice():r(t)?{...t}:t,h=(t,e)=>{if(o(t)&&o(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(r(t)&&r(e)){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const s of n){if(!(s in e))return!1;if(!Object.is(t[s],e[s]))return!1}return!0}return!(o(t)||o(e)||r(t)||r(e))&&Object.is(t,e)},f=(t,e)=>Array.from({length:e},()=>t),l=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),u=({from:t,to:e,velocity:n,label:s})=>{const i={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},c=t=>{if(null==i.arrayLength){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);i.arrayLength=t,o(i.value)||(i.value=f(i.value,t)),o(i.target)||(i.target=f(i.target,t)),void 0===i.velocity||o(i.velocity)||(i.velocity=f(i.velocity,t))}},h=t=>{if(null==i.objectKeys){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);i.objectKeys=t,r(i.value)||(i.value=l(i.value,t)),r(i.target)||(i.target=l(i.target,t)),void 0===i.velocity||r(i.velocity)||(i.velocity=l(i.velocity,t))}},u=t=>{if(o(t)){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);if(null==i.arrayLength&&c(t.length),t.length!==i.arrayLength)throw new Error(`${s} value length mismatch (expected ${i.arrayLength}, got ${t.length}).`);return t.slice()}if(r(t)){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==i.objectKeys&&h(e),i.objectKeys&&e.length!==i.objectKeys.length)throw new Error(`${s} value keys mismatch (expected ${i.objectKeys.length}, got ${e.length}).`);if(i.objectKeys)for(const e of i.objectKeys)if(!(e in t))throw new Error(`${s} value keys mismatch (missing key "${e}").`);return{...t}}return null!=i.arrayLength?f(t,i.arrayLength):null!=i.objectKeys?l(t,i.objectKeys):t};i.normalizeInput=u;const a=o(t)||o(e)||void 0!==n&&o(n),d=r(t)||r(e)||void 0!==n&&r(n);if(a&&d)throw new Error(`${s} value shape mismatch (array vs object).`);if(a){const s=o(t)?t.length:o(e)?e.length:n.length;c(s),i.value=u(t),i.target=u(e),void 0!==i.velocity&&(i.velocity=u(i.velocity))}else if(d){const s=r(t)?Object.keys(t):r(e)?Object.keys(e):Object.keys(n);h(s),i.value=u(t),i.target=u(e),void 0!==i.velocity&&(i.velocity=u(i.velocity))}return i};let a={x:-1,y:-1};const d={stiffness:300,damping:30,mass:1},p="0.0.5",m=/\{([A-Za-z_$][\w$]*)\}/g;exports.SCOPE_VERSION=p,exports.define=function(t,s={},i){const{props:o={},shadow:r=!1,styles:c,plugins:h}=s,f=h??[],l=()=>{};class u extends HTMLElement{constructor(){super(),this.version=p,this.t={};for(const t of Object.keys(o)){const e=o[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.i=null,this.o=null,this.h=!1,this.l=!1,this.u=r,this.p=r?this.attachShadow({mode:"open"}):this,this.m=null,this.S=[],this.j=[],this.M=[],this.O=[],this._=[],this.$=[],this.A=[],this.T=[],this.k=new Map,this.L=!1,this.F=!1,this.I={},this.R=!1,this.V=t,this.C=!1,this.H=new Set,this.D=!1,this.U=new Map,this.q=0,this.B=!1}N(t){const e=this.u?this.p.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(o)}attributeChangedCallback(t,n,s){if(n===s)return;const i=this.t[t],o=this.I[t],r=e(s,i);if(this.props[t]=r,this.L&&o!==r)for(const e of this.T)try{e(t,o,r)}catch(t){l(String(t?.message||t))}this.I[t]=r,this.H.has(t)?this.H.delete(t):this.i&&this.isConnected?this.D?this.C=!0:this.update(!0):this.C=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const n=e(this.getAttribute(t),this.t[t]);this.props[t]=n,this.I[t]=n}r||this.m||(this.m=this.W());let t=null;try{if(i){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),host:this,onMount:t=>this.M.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.$.push(t),onFirstUpdate:t=>this.A.push(t),onPropsChanged:t=>this.T.push(t),link:(t,e)=>{const s=e||t;this.state[s]=this.props[t],this.T.push((e,n,i)=>{e===t&&(Object.is(this.state[s],i)||(this.state[s]=i))});const i={fn:()=>{const e=this.state[s];if(Object.is(this.props[t],e))return;this.props[t]=e,this.I[t]=e;const i=this.t[t],o=i?{...i,reflect:!0}:i,r=this.getAttribute(t);this.H.add(t),n(this,t,e,o),r===this.getAttribute(t)&&this.H.delete(t)},deps:()=>[this.state[s]]};this.S.push(i)},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const s={getter:t,deps:e,value:void 0!==e?t(n):t()};this.j.push(s);const i=()=>s.value;return i.P=s,this.J(i),i},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.K(n)},delegate:(t,e,n)=>(this.Z(t,e,n),()=>this.G(t,e,n))};for(const t of f)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=i(e)}}catch(t){String(t?.message||t)}if(this.i="function"!=typeof t?()=>"":t,this.D=!0,this.update(!0),this.D=!1,this.C&&(this.C=!1,this.update(!0)),!this.L){this.L=!0;for(const t of this.M)try{t()}catch(t){l(String(t?.message||t))}}}disconnectedCallback(){this.destroy()}remove(){super.remove()}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.k)try{this.p.removeEventListener(t.eventType,t.listener)}catch{}this.k.clear(),this.L=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,s){const i=n;t.addEventListener(e,i,s);const o=()=>{try{t.removeEventListener(e,i,s)}catch{}};return this.O.push(o),o}setState(t){let e=!1;const n=t,s=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const i=n[t];Object.is(s[t],i)||(s[t]=i,e=!0)}if(e)if(this.D||!this.L)this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0,requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&this.update(!0)})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.X()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const s=[];for(const i of e){const e=t[i],o=this.I[i];this.props[i]=e,this.L&&o!==e&&s.push(i);const r=this.t[i];r&&r.reflect&&n(this,i,e,r),this.L&&o===e||(this.I[i]=e)}if(this.L&&s.length>0)for(const e of s){const n=this.I[e],s=t[e];for(const t of this.T)try{t(e,n,s)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?this.update(!0):this.C=!0}scheduleUpdate(){this.i&&this.isConnected&&this.X()}X(){this.l||this.h||(this.l=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.l=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.L)for(const t of this.$)try{t()}catch(t){l(String(t?.message||t))}if(t){this.Y();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}if("string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e)=>{const n={...this.props,...e};return t.replace(m,(t,e)=>{const s=n[e];return null==s?"":String(s)})})(t,this.state),!this.u){const e=`data-scope-owner="${this.V}"`;t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot ${e}$1`)}this.B=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.L||(this.u,this.p.innerHTML=t,this.o=t,n=!0),this.D?(this.tt(),("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{this.i&&this.isConnected&&(n&&!r&&this.projectSlots(),n&&this.et(),this.nt(),this.st())})):(n&&!r&&this.projectSlots(),n&&this.it(),this.nt(),this.st())}else this.B&&this.Y(),this.nt(),this.L&&this.st()}}forceRender(){this.o=null,this.i&&this.isConnected?this.D?this.C=!0:this.update(!0):this.C=!0}st(){if(!this.F){this.F=!0;for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.ot()}ot(){const t=(this.u?this.p:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,s=this.props;this.actions;for(let i=0;i<t.length;i++){const o=t[i];if(this.N(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const i=r[t];if(!i.name.startsWith("bind:"))continue;const c=i.name.slice(5),h=i.value,f=h?h.trim():"";let l,u=!1;if(f){const t=this.U.get(f);if(t){t.P&&(this.B=!0);try{l=t()}catch{}u=!0}}if(!u){const t=f||c,i=e.call(n,t),o=!i&&e.call(s,t);i?l=n[t]:o&&(l=s[t])}if("text"===c){const t=null==l?"":String(l);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==l?"":String(l);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],l))try{o[c]=l}catch{}if("value"===c)try{null==l?o.removeAttribute("value"):o.setAttribute("value",String(l))}catch{}}else if(null!=l)try{o.setAttribute(c,String(l))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.rt;t&&o.removeEventListener(t,d),delete o[a]}}}}Y(){for(const t of this.j){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(s)&&(e=s,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let s=0;s<e.length;s++)if(!Object.is(t.prevDeps[s],e[s])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}nt(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(s)&&(e=s,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let s=0;s<e.length;s++)if(!Object.is(t.prevDeps[s],e[s])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}K(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}J(t){const e=t.ct;if(e&&"string"==typeof e)return this.U.set(e,t),e;const n=`__scope_bind_${++this.q}__`;this.U.set(n,t);try{t.ct=n,t.toString=()=>n}catch{}return n}tt(){const t=(this.u?this.p:this).querySelectorAll("[ref]"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];if(0!==t.length)for(let n=0;n<t.length;n++){const s=t[n];if(this.N(s))continue;const i=s.getAttribute("ref");i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s)}}et(){const t=(this.u?this.p:this).querySelectorAll("*");for(let e=0;e<t.length;e++){const n=t[e];if(this.N(n))continue;if(0===n.attributes.length)continue;const s=n.attributes;for(let t=s.length-1;t>=0;t--){const e=s[t];if(!e.name.startsWith("on:"))continue;const i=e.name.slice(3),o=e.value,r=`__tinyHandler_${i}`,c=n[r];c&&n.removeEventListener(i,c),n.removeAttribute(e.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};n[r]=t,n.addEventListener(i,t)}}}}it(){const t=(this.u?this.p:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const s=t[n];if(this.N(s))continue;const i=s.getAttribute("ref");if(i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s),s.attributes.length>0){const t=s.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const i=n.name.slice(3),o=n.value,r=`__tinyHandler_${i}`,c=s[r];c&&s.removeEventListener(i,c),s.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};s[r]=t,s.addEventListener(i,t)}}}}}W(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const s=n[e];let i="";1===s.nodeType&&s.getAttribute&&(i=s.getAttribute("slot")||""),t.has(i)||t.set(i,[]),t.get(i).push(s)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.m||new Map,e=(this.u?this.p:this).querySelectorAll(`slot[data-scope-owner="${this.V}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const s=e[n],i=s.getAttribute("name")||"",o=t.get(i)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let s;if(1===n.nodeType&&n.tagName.includes("-")&&n.m instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const s=t.attributes[n];e.setAttribute(s.name,s.value)}for(const n of t.m.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));s=e}else s=n.cloneNode(!0);t.appendChild(s)}s.replaceWith(t)}else{const t=s.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);s.replaceWith(t)}}}}Z(t,e,n){const s=`${t}::${e}`;let i=this.k.get(s);if(!i){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of i.handlers)try{e(t,n)}catch{}};i={eventType:t,selector:e,listener:n,handlers:new Set},this.k.set(s,i),this.p.addEventListener(t,n)}i.handlers.add(n)}G(t,e,n){const s=`${t}::${e}`,i=this.k.get(s);if(i&&(i.handlers.delete(n),0===i.handlers.size)){try{this.p.removeEventListener(t,i.listener)}catch{}this.k.delete(s)}}}if(!customElements.get(t)){if(c&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=c,document.head.appendChild(t)}}try{customElements.define(t,u)}catch(t){String(t?.message||t)}}return u},exports.devicePlugin=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,s={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:i=!0}=s,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),i&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),exports.happy=()=>{console.info("The website is using @petit-kit/scoped v"+p),console.info("https://github.com/petit-kit/scoped")},exports.inViewPlugin=()=>({name:"inview",extend:(t,e)=>{const n=new Set,s=(t,e,s={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:i=!0,...o}=s;let r=!i;const c=new IntersectionObserver(n=>{for(const s of n)s.target===t&&(r?r=!1:e(s.isIntersecting,s))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>s(e,t,n),observeInView:(t,e,n)=>s(t,e,n)}}}),exports.lenisPlugin=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const s=t();if(!s)return()=>{};const i=t=>{e(t)};s.on("scroll",i);const o={lenis:s,handler:i};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof s.off&&s.off("scroll",i))}}}}}),exports.lerpPlugin=()=>({name:"lerp",extend:t=>{const{timer:e}=s().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:s=.001,resumeOnTarget:i=!0}={}){function f(){return c(p)}function l(t){if(y)return f();const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return f();if(1===e)return p=c(m),a.value=p,y=!0,f();const i=t>0?1-Math.pow(1-e,60*t):0;if(o(p)&&o(m)){let t=!0;for(let e=0;e<p.length;e+=1)p[e]+=(m[e]-p[e])*i,Math.abs(m[e]-p[e])>=s&&(t=!1);if(t){for(let t=0;t<p.length;t+=1)p[t]=m[t];y=!0}return a.value=p,c(p)}if(r(p)&&r(m)){const t=a.objectKeys??Object.keys(p);let e=!0;for(const n of t)p[n]+=(m[n]-p[n])*i,Math.abs(m[n]-p[n])>=s&&(e=!1);if(e){for(const e of t)p[e]=m[e];y=!0}return a.value=p,c(p)}const h=m;return p+=(h-p)*i,a.value=p,Math.abs(h-p)<s&&(p=h,a.value=p,y=!0),p}const a=u({from:t,to:e,label:"Lerp"}),d=a.normalizeInput;let p=a.value,m=a.target,w=null,y=!1;const g=new Set;return{setTarget:function(t){const e=d(t),n=!h(e,m);if(m=e,a.target=e,p=a.value,i&&y&&n){y=!1,w=null;for(const t of g)t(m)}},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:s=!1,markDone:i=!1}=e;p=d(t),a.value=p,s&&(m=c(p),a.target=m);const o=y||!h(p,m);if(n&&(w=null),i&&(y=!0),o&&!i){y=!1,w=null;for(const t of g)t(m)}},getValue:f,isDone:function(){return y},onResume:function(t){return g.add(t),()=>{g.delete(t)}},step:l,next:function(t=performance.now()){if(null==w)return w=t,f();const e=(t-w)/1e3;w=t;const n=1/30;let s=e,i=f();for(;s>0&&!y;){const t=Math.min(s,n);i=l(t),s-=t}return i}}}(t),runLerp:(t,s,i={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=i;let h=!1,f=null;r&&s(t.getValue(),t);const l=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);s(n,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&s(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),n.delete(d))};return n.add(d),d}}}}),exports.morphPlugin=(t,e={})=>({name:"morph",extend:(n,s)=>{const{ignoreActiveValue:i=!0,callbacks:o}=e,r=t(),c=s,h=c.p,f=c.u?ShadowRoot.prototype:HTMLElement.prototype,l=Object.getOwnPropertyDescriptor(f,"innerHTML"),u=t=>{r.morph(h,t,{morphStyle:"innerHTML",ignoreActiveValue:i,callbacks:o})};let a=!0;return Object.defineProperty(h,"innerHTML",{set(t){a?(l.set.call(this,t),a=!1):u(t)},get(){return l.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete h.innerHTML}),{morph:u}}}),exports.mousePlugin=i,exports.pointerPlugin=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=i().extend(e,e.host),{timer:o}=s().extend(e,e.host);a.x=window.innerWidth/2,a.y=window.innerHeight/2;const r={x:t({from:a.x,to:a.x,...d}),y:t({from:a.y,to:a.y,...d})};return n((t,e)=>{r.x.setTarget(t),r.y.setTarget(e)}),{onPointerMove:t=>{let e=a.x,n=a.y;o.raf(s=>{const i=r.x.next(s),o=r.y.next(s);var c,h;e===i&&n===o||(t({x:i,y:o,v:(c={x:i,y:o},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=i,n=o)})},onMouseMove:n}}}),exports.springPlugin=()=>({name:"spring",extend:e=>{const{timer:n}=s().extend(e,e.host),i=new Set;return e.onDestroy(()=>{for(const t of i)t();i.clear()}),{createSpring:e=>t(e),runSpring:(t,e,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&e(t.getValue(),t);const l=()=>{f||(f=n.raf(n=>{if(h)return;const s=t.next(n);e(s,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),i.delete(d))};return i.add(d),d}}}}),exports.timerPlugin=s,exports.windowPlugin=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,s=new Set,i=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=n,i=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",i),e.add(i),s&&i(new UIEvent("resize")),()=>{window.removeEventListener("resize",i),e.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of s)t.disconnect();s.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:i,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return i((e,n,s)=>t(e,n,s),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:s,height:i}=n.contentRect;t(s,i,n)});if(r.observe(o),s.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),s.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=e,i=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",i,{passive:!0}),n.add(i),s&&i(new Event("scroll")),()=>{window.removeEventListener("scroll",i),n.delete(i)}}}}});
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -3,8 +3,7 @@ export * from './plugins';
3
3
  * Scope - A lightweight, framework-agnostic library for building web components
4
4
  *
5
5
  * @module scope
6
- * @version 0.0.1
7
- * @since 0.0.1
6
+ * @version 0.0.5
8
7
  * @description Provides a minimal abstraction over Custom Elements API, making it easy
9
8
  * to create reusable, encapsulated components with reactive state, lifecycle hooks,
10
9
  * and a simple template-based rendering system.
@@ -55,14 +54,17 @@ export * from './plugins';
55
54
  * Library version.
56
55
  *
57
56
  * @constant {string}
58
- * @since 0.1.0
59
57
  */
60
- declare const SCOPE_VERSION = "0.0.1";
58
+ declare const SCOPE_VERSION = "0.0.5";
59
+ /**
60
+ * Logs version and repository info for @petit-kit/scoped.
61
+ * Useful for debugging or confirming library presence.
62
+ */
63
+ export declare const happy: () => void;
61
64
  /**
62
65
  * Supported prop types for type checking and parsing
63
66
  *
64
67
  * @typedef {StringConstructor|NumberConstructor|BooleanConstructor|ObjectConstructor|ArrayConstructor} PropType
65
- * @since 0.1.0
66
68
  */
67
69
  export type PropType = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor;
68
70
  /**
@@ -70,7 +72,6 @@ export type PropType = StringConstructor | NumberConstructor | BooleanConstructo
70
72
  *
71
73
  * @template T - The type of the prop value
72
74
  * @interface PropDefinition
73
- * @since 0.1.0
74
75
  *
75
76
  * @example
76
77
  * ```typescript
@@ -103,7 +104,6 @@ export interface PropDefinition<T = any> {
103
104
  * Props definition object mapping prop names to their definitions or default values
104
105
  *
105
106
  * @typedef {Record<string, PropDefinition | any>} PropsDefinition
106
- * @since 0.1.0
107
107
  *
108
108
  * @example
109
109
  * ```typescript
@@ -130,7 +130,6 @@ export type ComponentPlugin<Ext extends Record<string, any> = {}> = {
130
130
  * Options for component definition
131
131
  *
132
132
  * @interface ComponentOptions
133
- * @since 0.1.0
134
133
  *
135
134
  * @example
136
135
  * ```typescript
@@ -168,7 +167,6 @@ export interface ComponentOptions<Plugins extends readonly ComponentPlugin<any>[
168
167
  * Methods available on the component host element
169
168
  *
170
169
  * @interface ComponentHost
171
- * @since 0.1.0
172
170
  *
173
171
  * @example
174
172
  * ```typescript
@@ -279,7 +277,6 @@ export interface ComponentHost {
279
277
  * @template Actions - Type of action methods
280
278
  * @template Refs - Type of DOM refs
281
279
  * @interface ComponentContext
282
- * @since 0.1.0
283
280
  *
284
281
  * @example Basic usage
285
282
  * ```typescript
@@ -391,42 +388,36 @@ export interface ComponentContextBase<Props = Record<string, any>, State = Recor
391
388
  * Register callback to run after component is mounted
392
389
  * @method onMount
393
390
  * @param {function(): void} callback - Callback function
394
- * @since 0.1.0
395
391
  */
396
392
  onMount: (callback: () => void) => void;
397
393
  /**
398
394
  * Register callback to run when component is destroyed
399
395
  * @method onDestroy
400
396
  * @param {function(): void} callback - Callback function
401
- * @since 0.1.0
402
397
  */
403
398
  onDestroy: (callback: () => void) => void;
404
399
  /**
405
400
  * Register callback to run after each update/re-render
406
401
  * @method onUpdate
407
402
  * @param {function(): void} callback - Callback function
408
- * @since 0.3.0
409
403
  */
410
404
  onUpdate: (callback: () => void) => void;
411
405
  /**
412
406
  * Register callback to run before each update/re-render
413
407
  * @method onBeforeUpdate
414
408
  * @param {function(): void} callback - Callback function
415
- * @since 0.3.0
416
409
  */
417
410
  onBeforeUpdate: (callback: () => void) => void;
418
411
  /**
419
412
  * Register callback to run only on the first update (after mount)
420
413
  * @method onFirstUpdate
421
414
  * @param {function(): void} callback - Callback function
422
- * @since 0.3.0
423
415
  */
424
416
  onFirstUpdate: (callback: () => void) => void;
425
417
  /**
426
418
  * Register callback to run when props change
427
419
  * @method onPropsChanged
428
420
  * @param {function(string, any, any): void} callback - Callback function
429
- * @since 0.3.0
430
421
  *
431
422
  * @example
432
423
  * ```typescript
@@ -460,7 +451,6 @@ export interface ComponentContextBase<Props = Record<string, any>, State = Recor
460
451
  * @param {function(any[]): (void|function())} fn - Effect function that can return cleanup
461
452
  * @param {any[] | (() => any[])} [deps] - Optional dependency array or deps getter
462
453
  * @returns {() => void} Cleanup function to remove the effect
463
- * @since 0.2.0
464
454
  *
465
455
  * @example
466
456
  * ```typescript
@@ -478,7 +468,6 @@ export interface ComponentContextBase<Props = Record<string, any>, State = Recor
478
468
  * @param {function(any[]): *} getter - Function that returns the computed value
479
469
  * @param {any[] | (() => any[])} [deps] - Optional dependency array or deps getter
480
470
  * @returns {() => T} Getter for the current computed value
481
- * @since 0.0.1
482
471
  *
483
472
  * @example
484
473
  * ```typescript
@@ -494,7 +483,6 @@ export interface ComponentContextBase<Props = Record<string, any>, State = Recor
494
483
  * @param {string} selector - CSS selector to match target elements
495
484
  * @param {function(Event, Element): void} handler - Handler function
496
485
  * @returns {() => void} Cleanup function to remove the delegation
497
- * @since 0.2.0
498
486
  *
499
487
  * @example
500
488
  * ```typescript
@@ -521,7 +509,6 @@ type PluginExtensions<Plugins extends readonly ComponentPlugin<any>[]> = UnionTo
521
509
  * @typedef {function} SetupFunction
522
510
  * @param {ComponentContext<Props, State, Actions, Refs, Ext>} context - Component context
523
511
  * @returns {() => string} Render function that returns HTML template string
524
- * @since 0.1.0
525
512
  *
526
513
  * @example
527
514
  * ```typescript
@@ -620,7 +607,6 @@ export type ComputedRecord<T = any> = {
620
607
  * @see {@link ComponentContext} for available context properties
621
608
  * @see {@link ComponentOptions} for configuration options
622
609
  * @see {@link SetupFunction} for setup function signature
623
- * @since 0.1.0
624
610
  */
625
611
  declare function define<Props = Record<string, any>, State = Record<string, any>, Actions = Record<string, Function>, Refs = Record<string, HTMLElement | HTMLElement[]>, Plugins extends readonly ComponentPlugin<any>[] = []>(tagName: string, options?: ComponentOptions<Plugins>, setup?: SetupFunction<Props, State, Actions, Refs, PluginExtensions<Plugins>>): typeof HTMLElement;
626
612
  export { define, SCOPE_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH;;;;;GAKG;AACH,QAAA,MAAM,aAAa,UAAU,CAAC;AAuC9B;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,CAAC;AAErB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG,CAAC,CAAC;A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3B,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC,EAClD,OAAO,SAAS,SAAS,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,EAEpD,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAgB,CAAC,OAAO,CAAM,EACvC,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAC5E,OAAO,WAAW,CA0xDpB;AAED,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function t(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:i}=e;if(null==t)return i;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?i:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:try{return"string"==typeof t?JSON.parse(t):t}catch{return i}case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return Array.isArray(i)?i:[]}default:return t}}catch{return i}}function e(t,e,n,i){if(!i||"object"!=typeof i||!i.reflect)return;let s=null;const o=i.type;if(o===Boolean)return n?void t.setAttribute(e,""):void t.removeAttribute(e);if(o===Object||o===Array)try{s=null==n?null:JSON.stringify(n)}catch{s=null}else s=null==n?null:String(n);null==s?t.removeAttribute(e):t.setAttribute(e,s)}function n(n,i={},s){const{props:o={},shadow:r=!1,styles:c,plugins:h}=i,f=h??[],l=()=>{};class u extends HTMLElement{constructor(){super(),this.version=b,this.t={};for(const t of Object.keys(o)){const e=o[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.i=null,this.o=null,this.h=!1,this.l=!1,this.u=r,this.m=r?this.attachShadow({mode:"open"}):this,this.p=null,this.v=[],this.S=[],this.j=[],this.O=[],this.M=[],this._=[],this.$=[],this.A=[],this.T=new Map,this.k=!1,this.L=!1,this.F={},this.I=!1,this.R=n,this.V=!1,this.C=new Set,this.H=!1,this.D=new Map,this.U=0,this.q=!1}B(t){const e=this.u?this.m.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(o)}attributeChangedCallback(e,n,i){if(n===i)return;const s=this.t[e],o=this.F[e],r=t(i,s);if(this.props[e]=r,this.k&&o!==r)for(const t of this.A)try{t(e,o,r)}catch(t){l(String(t?.message||t))}this.F[e]=r,this.C.has(e)?this.C.delete(e):this.i&&this.isConnected?this.H?this.V=!0:this.update(!0):this.V=!0}connectedCallback(){for(const e in this.t){if(!this.t.hasOwnProperty(e))continue;const n=t(this.getAttribute(e),this.t[e]);this.props[e]=n,this.F[e]=n}r||this.p||(this.p=this.N());let n=null;try{if(s){const t={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this.M.push(t),onBeforeUpdate:t=>this._.push(t),onFirstUpdate:t=>this.$.push(t),onPropsChanged:t=>this.A.push(t),link:(t,n)=>{const i=n||t;this.state[i]=this.props[t],this.A.push((e,n,s)=>{e===t&&(Object.is(this.state[i],s)||(this.state[i]=s))});const s={fn:()=>{const n=this.state[i];if(Object.is(this.props[t],n))return;this.props[t]=n,this.F[t]=n;const s=this.t[t],o=s?{...s,reflect:!0}:s,r=this.getAttribute(t);this.C.add(t),e(this,t,n,o),r===this.getAttribute(t)&&this.C.delete(t)},deps:()=>[this.state[i]]};this.v.push(s)},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const i={getter:t,deps:e,value:void 0!==e?t(n):t()};this.S.push(i);const s=()=>i.value;return s.W=i,this.J(s),s},effect:(t,e)=>{const n={fn:t,deps:e};return this.v.push(n),()=>this.P(n)},delegate:(t,e,n)=>(this.K(t,e,n),()=>this.Z(t,e,n))};for(const e of f)if(e)try{const n=e.extend(t,this);n&&"object"==typeof n&&Object.assign(t,n)}catch(t){l(String(t?.message||t))}n=s(t)}}catch(t){String(t?.message||t)}if(this.i="function"!=typeof n?()=>"":n,this.H=!0,this.update(!0),this.H=!1,this.V&&(this.V=!1,this.update(!0)),!this.k){this.k=!0;for(const t of this.j)try{t()}catch(t){l(String(t?.message||t))}}}disconnectedCallback(){this.destroy()}remove(){super.remove()}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.v)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.T)try{this.m.removeEventListener(t.eventType,t.listener)}catch{}this.T.clear(),this.k=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,i){const s=n;t.addEventListener(e,s,i);const o=()=>{try{t.removeEventListener(e,s,i)}catch{}};return this.O.push(o),o}setState(t){let e=!1;const n=t,i=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const s=n[t];Object.is(i[t],s)||(i[t]=s,e=!0)}if(e)if(this.H||!this.k)this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0,requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&this.update(!0)})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.G()}setProps(t){const n=Object.keys(t);if(0===n.length)return;const i=[];for(const s of n){const n=t[s],o=this.F[s];this.props[s]=n,this.k&&o!==n&&i.push(s);const r=this.t[s];r&&r.reflect&&e(this,s,n,r),this.k&&o===n||(this.F[s]=n)}if(this.k&&i.length>0)for(const e of i){const n=this.F[e],i=t[e];for(const t of this.A)try{t(e,n,i)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?this.update(!0):this.V=!0}scheduleUpdate(){this.i&&this.isConnected&&this.G()}G(){this.l||this.h||(this.l=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.l=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.k)for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}if(t){this.X();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}if("string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e)=>{const n={...this.props,...e};return t.replace(v,(t,e)=>{const i=n[e];return null==i?"":String(i)})})(t,this.state),!this.u){const e=`data-scope-owner="${this.R}"`;t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot ${e}$1`)}this.q=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.k||(this.u,this.m.innerHTML=t,this.o=t,n=!0),this.H?(this.Y(),("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{this.i&&this.isConnected&&(n&&!r&&this.projectSlots(),n&&this.tt(),this.et(),this.nt())})):(n&&!r&&this.projectSlots(),n&&this.it(),this.et(),this.nt())}else this.q&&this.X(),this.et(),this.k&&this.nt()}}forceRender(){this.o=null,this.i&&this.isConnected?this.H?this.V=!0:this.update(!0):this.V=!0}nt(){if(!this.L){this.L=!0;for(const t of this.$)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this.M)try{t()}catch(t){l(String(t?.message||t))}this.st()}st(){const t=(this.u?this.m:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,i=this.props;this.actions;for(let s=0;s<t.length;s++){const o=t[s];if(this.B(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const s=r[t];if(!s.name.startsWith(S))continue;const c=s.name.slice(5),h=s.value,f=h?h.trim():"";let l,u=!1;if(f){const t=this.D.get(f);if(t){t.W&&(this.q=!0);try{l=t()}catch{}u=!0}}if(!u){const t=f||c,s=e.call(n,t),o=!s&&e.call(i,t);s?l=n[t]:o&&(l=i[t])}if("text"===c){const t=null==l?"":String(l);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==l?"":String(l);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],l))try{o[c]=l}catch{}if("value"===c)try{null==l?o.removeAttribute("value"):o.setAttribute("value",String(l))}catch{}}else if(null!=l)try{o.setAttribute(c,String(l))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ot;t&&o.removeEventListener(t,d),delete o[a]}}}}X(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(i)&&(e=i,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let i=0;i<e.length;i++)if(!Object.is(t.prevDeps[i],e[i])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}et(){for(const t of this.v){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(i)&&(e=i,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let i=0;i<e.length;i++)if(!Object.is(t.prevDeps[i],e[i])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}P(t){const e=this.v.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.v.splice(e,1)}}J(t){const e=t.rt;if(e&&"string"==typeof e)return this.D.set(e,t),e;const n=`__scope_bind_${++this.U}__`;this.D.set(n,t);try{t.rt=n,t.toString=()=>n}catch{}return n}Y(){const t=(this.u?this.m:this).querySelectorAll("[ref]"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];if(0!==t.length)for(let n=0;n<t.length;n++){const i=t[n];if(this.B(i))continue;const s=i.getAttribute("ref");s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i)}}tt(){const t=(this.u?this.m:this).querySelectorAll("*");for(let e=0;e<t.length;e++){const n=t[e];if(this.B(n))continue;if(0===n.attributes.length)continue;const i=n.attributes;for(let t=i.length-1;t>=0;t--){const e=i[t];if(!e.name.startsWith("on:"))continue;const s=e.name.slice(3),o=e.value,r=`__tinyHandler_${s}`,c=n[r];c&&n.removeEventListener(s,c),n.removeAttribute(e.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};n[r]=t,n.addEventListener(s,t)}}}}it(){const t=(this.u?this.m:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const i=t[n];if(this.B(i))continue;const s=i.getAttribute("ref");if(s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i),i.attributes.length>0){const t=i.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const s=n.name.slice(3),o=n.value,r=`__tinyHandler_${s}`,c=i[r];c&&i.removeEventListener(s,c),i.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};i[r]=t,i.addEventListener(s,t)}}}}}N(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const i=n[e];let s="";1===i.nodeType&&i.getAttribute&&(s=i.getAttribute("slot")||""),t.has(s)||t.set(s,[]),t.get(s).push(i)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.p||new Map,e=(this.u?this.m:this).querySelectorAll(`slot[data-scope-owner="${this.R}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const i=e[n],s=i.getAttribute("name")||"",o=t.get(s)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let i;if(1===n.nodeType&&n.tagName.includes("-")&&n.p instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n];e.setAttribute(i.name,i.value)}for(const n of t.p.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));i=e}else i=n.cloneNode(!0);t.appendChild(i)}i.replaceWith(t)}else{const t=i.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);i.replaceWith(t)}}}}K(t,e,n){const i=`${t}::${e}`;let s=this.T.get(i);if(!s){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of s.handlers)try{e(t,n)}catch{}};s={eventType:t,selector:e,listener:n,handlers:new Set},this.T.set(i,s),this.m.addEventListener(t,n)}s.handlers.add(n)}Z(t,e,n){const i=`${t}::${e}`,s=this.T.get(i);if(s&&(s.handlers.delete(n),0===s.handlers.size)){try{this.m.removeEventListener(t,s.listener)}catch{}this.T.delete(i)}}}if(!customElements.get(n)){if(c&&"undefined"!=typeof document){const t=`scope-${n}-styles`;if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=c,document.head.appendChild(e)}}try{customElements.define(n,u)}catch(t){String(t?.message||t)}}return u}const i=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,i={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:s=!0}=i,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),s&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),s=(t,e={})=>({name:"morph",extend:(n,i)=>{const{ignoreActiveValue:s=!0,callbacks:o}=e,r=t(),c=i,h=c.m,f=c.u?ShadowRoot.prototype:HTMLElement.prototype,l=Object.getOwnPropertyDescriptor(f,"innerHTML"),u=t=>{r.morph(h,t,{morphStyle:"innerHTML",ignoreActiveValue:s,callbacks:o})};let a=!0;return Object.defineProperty(h,"innerHTML",{set(t){a?(l.set.call(this,t),a=!1):u(t)},get(){return l.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete h.innerHTML}),{morph:u}}}),o=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,i=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=n,s=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",s),e.add(s),i&&s(new UIEvent("resize")),()=>{window.removeEventListener("resize",s),e.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of n)t.disconnect();n.clear()}}),{onViewportResize:i,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return i((e,n,i)=>t(e,n,i),e);const{immediate:s=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:i,height:s}=n.contentRect;t(i,s,n)});if(r.observe(o),n.add(r),s){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),n.delete(r)}}}}}),r=()=>({name:"inview",extend:(t,e)=>{const n=new Set,i=(t,e,i={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:s=!0,...o}=i;let r=!s;const c=new IntersectionObserver(n=>{for(const i of n)i.target===t&&(r?r=!1:e(i.isIntersecting,i))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>i(e,t,n),observeInView:(t,e,n)=>i(t,e,n)}}}),c=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const i=t();if(!i)return()=>{};const s=t=>{e(t)};i.on("scroll",s);const o={lenis:i,handler:s};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof i.off&&i.off("scroll",s))}}}}}),h=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,i=new Set,s={setTimeout:(t,n,...i)=>{let s;return s=setTimeout((...n)=>{e.delete(s),t(...n)},n,...i),e.add(s),s},setInterval:(t,e,...i)=>{const s=setInterval(t,e,...i);return n.add(s),s},raf:(t,e)=>{let n=0,s=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(i.delete(n),s){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),i.add(n)}};return n=requestAnimationFrame(c),i.add(n),()=>{s&&(s=!1,i.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of i)cancelAnimationFrame(t);i.clear()}),{timer:s}}}),f=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const i=t=>{const e=t;n(e.clientX,e.clientY,e)};window.addEventListener(t,i);let s=e.get(t);return s||(s=new Set,e.set(t,s)),s.add(i),()=>{window.removeEventListener(t,i),s?.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{const n=e;t(n.clientX,n.clientY,n.deltaY,n)};window.addEventListener("wheel",n);let i=e.get("wheel");return i||(i=new Set,e.set("wheel",i)),i.add(n),()=>{window.removeEventListener("wheel",n),i?.delete(n)}})(t)}}}),l=t=>Array.isArray(t),u=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),a=t=>l(t)?t.slice():u(t)?{...t}:t,d=(t,e)=>{if(l(t)&&l(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(u(t)&&u(e)){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!(i in e))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}return!(l(t)||l(e)||u(t)||u(e))&&Object.is(t,e)},m=(t,e)=>Array.from({length:e},()=>t),p=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),y=({from:t,to:e,velocity:n,label:i})=>{const s={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==s.arrayLength){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);s.arrayLength=t,l(s.value)||(s.value=m(s.value,t)),l(s.target)||(s.target=m(s.target,t)),void 0===s.velocity||l(s.velocity)||(s.velocity=m(s.velocity,t))}},r=t=>{if(null==s.objectKeys){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);s.objectKeys=t,u(s.value)||(s.value=p(s.value,t)),u(s.target)||(s.target=p(s.target,t)),void 0===s.velocity||u(s.velocity)||(s.velocity=p(s.velocity,t))}},c=t=>{if(l(t)){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);if(null==s.arrayLength&&o(t.length),t.length!==s.arrayLength)throw new Error(`${i} value length mismatch (expected ${s.arrayLength}, got ${t.length}).`);return t.slice()}if(u(t)){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==s.objectKeys&&r(e),s.objectKeys&&e.length!==s.objectKeys.length)throw new Error(`${i} value keys mismatch (expected ${s.objectKeys.length}, got ${e.length}).`);if(s.objectKeys)for(const e of s.objectKeys)if(!(e in t))throw new Error(`${i} value keys mismatch (missing key "${e}").`);return{...t}}return null!=s.arrayLength?m(t,s.arrayLength):null!=s.objectKeys?p(t,s.objectKeys):t};s.normalizeInput=c;const h=l(t)||l(e)||void 0!==n&&l(n),f=u(t)||u(e)||void 0!==n&&u(n);if(h&&f)throw new Error(`${i} value shape mismatch (array vs object).`);if(h){const i=l(t)?t.length:l(e)?e.length:n.length;o(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}else if(f){const i=u(t)?Object.keys(t):u(e)?Object.keys(e):Object.keys(n);r(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}return s},w=()=>({name:"lerp",extend:t=>{const{timer:e}=h().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:i=.001,resumeOnTarget:s=!0}={}){function o(){return a(f)}function r(t){if(w)return o();const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return o();if(1===e)return f=a(m),c.value=f,w=!0,o();const s=t>0?1-Math.pow(1-e,60*t):0;if(l(f)&&l(m)){let t=!0;for(let e=0;e<f.length;e+=1)f[e]+=(m[e]-f[e])*s,Math.abs(m[e]-f[e])>=i&&(t=!1);if(t){for(let t=0;t<f.length;t+=1)f[t]=m[t];w=!0}return c.value=f,a(f)}if(u(f)&&u(m)){const t=c.objectKeys??Object.keys(f);let e=!0;for(const n of t)f[n]+=(m[n]-f[n])*s,Math.abs(m[n]-f[n])>=i&&(e=!1);if(e){for(const e of t)f[e]=m[e];w=!0}return c.value=f,a(f)}const r=m;return f+=(r-f)*s,c.value=f,Math.abs(r-f)<i&&(f=r,c.value=f,w=!0),f}const c=y({from:t,to:e,label:"Lerp"}),h=c.normalizeInput;let f=c.value,m=c.target,p=null,w=!1;const g=new Set;return{setTarget:function(t){const e=h(t),n=!d(e,m);if(m=e,c.target=e,f=c.value,s&&w&&n){w=!1,p=null;for(const t of g)t(m)}},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:i=!1,markDone:s=!1}=e;f=h(t),c.value=f,i&&(m=a(f),c.target=m);const o=w||!d(f,m);if(n&&(p=null),s&&(w=!0),o&&!s){w=!1,p=null;for(const t of g)t(m)}},getValue:o,isDone:function(){return w},onResume:function(t){return g.add(t),()=>{g.delete(t)}},step:r,next:function(t=performance.now()){if(null==p)return p=t,o();const e=(t-p)/1e3;p=t;const n=1/30;let i=e,s=o();for(;i>0&&!w;){const t=Math.min(i,n);s=r(t),i-=t}return s}}}(t),runLerp:(t,i,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&i(t.getValue(),t);const l=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);i(n,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&i(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),n.delete(d))};return n.add(d),d}}}}),g=()=>({name:"spring",extend:t=>{const{timer:e}=h().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createSpring:t=>function({from:t=0,to:e=1,mass:n=1,stiffness:i=120,damping:s=14,velocity:o=0,tolerance:r=.001,resumeOnTarget:c=!0}={}){function h(){return a(b)}function f(t){if(O)return h();if(l(b)&&l(S)&&l(v)){let e=!0;for(let o=0;o<b.length;o+=1){const c=b[o]-S[o],h=(-i*c-s*v[o])/n;v[o]+=h*t,b[o]+=v[o]*t;const f=b[o]-S[o];(Math.abs(v[o])>=r||Math.abs(f)>=r)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=S[t],v[t]=0;O=!0}return w.value=b,w.velocity=v,a(b)}if(u(b)&&u(S)&&u(v)){const e=w.objectKeys??Object.keys(b);let o=!0;for(const c of e){const e=b[c]-S[c],h=(-i*e-s*v[c])/n;v[c]+=h*t,b[c]+=v[c]*t;const f=b[c]-S[c];(Math.abs(v[c])>=r||Math.abs(f)>=r)&&(o=!1)}if(o){for(const t of e)b[t]=S[t],v[t]=0;O=!0}return w.value=b,w.velocity=v,a(b)}const e=S;let o=v;o+=(-i*(b-e)-s*o)/n*t,b+=o*t,v=o,w.value=b,w.velocity=v;const c=b-e;return Math.abs(o)<r&&Math.abs(c)<r&&(b=e,v=0,w.value=b,w.velocity=v,O=!0),b}const w=y({from:t,to:e,velocity:o,label:"Spring"}),g=w.normalizeInput;let b=w.value,v=w.velocity??o,S=w.target,j=null,O=!1;const M=new Set;return{setTarget:function(t){const e=g(t),n=!d(e,S);if(S=e,w.target=e,b=w.value,c&&O&&n){O=!1,j=null;for(const t of M)t(S)}},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:i=!0,setTarget:s=!1,markDone:o=!1}=e;b=g(t),w.value=b,s&&(S=a(b),w.target=S);const r=O||!d(b,S);if(n&&(v=null!=w.arrayLength?m(0,w.arrayLength):null!=w.objectKeys?p(0,w.objectKeys):0,w.velocity=v),i&&(j=null),o&&(O=!0),r&&!o){O=!1,j=null;for(const t of M)t(S)}},getValue:h,isDone:function(){return O},onResume:function(t){return M.add(t),()=>{M.delete(t)}},step:f,next:function(t=performance.now()){if(null==j)return j=t,h();const e=(t-j)/1e3;j=t;const n=1/30;let i=e,s=h();for(;i>0&&!O;){const t=Math.min(i,n);s=f(t),i-=t}return s}}}(t),runSpring:(t,i,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&i(t.getValue(),t);const l=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);i(n,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&i(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),n.delete(d))};return n.add(d),d}}}}),b="0.0.1",v=/\{([A-Za-z_$][\w$]*)\}/g,S="bind:";export{b as SCOPE_VERSION,n as define,i as devicePlugin,r as inViewPlugin,c as lenisPlugin,w as lerpPlugin,s as morphPlugin,f as mousePlugin,g as springPlugin,h as timerPlugin,o as windowPlugin};
1
+ function t({from:t=0,to:e=1,mass:n=1,stiffness:i=120,damping:s=14,velocity:o=0,tolerance:r=.001,resumeOnTarget:c=!0}={}){function h(){return d(v)}function f(t){if(M)return h();if(u(v)&&u(S)&&u(b)){let e=!0;for(let o=0;o<v.length;o+=1){const c=v[o]-S[o],h=(-i*c-s*b[o])/n;b[o]+=h*t,v[o]+=b[o]*t;const f=v[o]-S[o];(Math.abs(b[o])>=r||Math.abs(f)>=r)&&(e=!1)}if(e){for(let t=0;t<v.length;t+=1)v[t]=S[t],b[t]=0;M=!0}return l.value=v,l.velocity=b,d(v)}if(a(v)&&a(S)&&a(b)){const e=l.objectKeys??Object.keys(v);let o=!0;for(const c of e){const e=v[c]-S[c],h=(-i*e-s*b[c])/n;b[c]+=h*t,v[c]+=b[c]*t;const f=v[c]-S[c];(Math.abs(b[c])>=r||Math.abs(f)>=r)&&(o=!1)}if(o){for(const t of e)v[t]=S[t],b[t]=0;M=!0}return l.value=v,l.velocity=b,d(v)}const e=S;let o=b;o+=(-i*(v-e)-s*o)/n*t,v+=o*t,b=o,l.value=v,l.velocity=b;const c=v-e;return Math.abs(o)<r&&Math.abs(c)<r&&(v=e,b=0,l.value=v,l.velocity=b,M=!0),v}const l=y({from:t,to:e,velocity:o,label:"Spring"}),g=l.normalizeInput;let v=l.value,b=l.velocity??o,S=l.target,j=null,M=!1;const O=new Set;return{setTarget:function(t){const e=g(t),n=!m(e,S);if(S=e,l.target=e,v=l.value,c&&M&&n){M=!1,j=null;for(const t of O)t(S)}},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:i=!0,setTarget:s=!1,markDone:o=!1}=e;v=g(t),l.value=v,s&&(S=d(v),l.target=S);const r=M||!m(v,S);if(n&&(b=null!=l.arrayLength?p(0,l.arrayLength):null!=l.objectKeys?w(0,l.objectKeys):0,l.velocity=b),i&&(j=null),o&&(M=!0),r&&!o){M=!1,j=null;for(const t of O)t(S)}},getValue:h,isDone:function(){return M},onResume:function(t){return O.add(t),()=>{O.delete(t)}},step:f,next:function(t=performance.now()){if(null==j)return j=t,h();const e=(t-j)/1e3;j=t;const n=1/30;let i=e,s=h();for(;i>0&&!M;){const t=Math.min(i,n);s=f(t),i-=t}return s}}}function e(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:i}=e;if(null==t)return i;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?i:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:try{return"string"==typeof t?JSON.parse(t):t}catch{return i}case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return Array.isArray(i)?i:[]}default:return t}}catch{return i}}function n(t,e,n,i){if(!i||"object"!=typeof i||!i.reflect)return;let s=null;const o=i.type;if(o===Boolean)return n?void t.setAttribute(e,""):void t.removeAttribute(e);if(o===Object||o===Array)try{s=null==n?null:JSON.stringify(n)}catch{s=null}else s=null==n?null:String(n);null==s?t.removeAttribute(e):t.setAttribute(e,s)}function i(t,i={},s){const{props:o={},shadow:r=!1,styles:c,plugins:h}=i,f=h??[],l=()=>{};class u extends HTMLElement{constructor(){super(),this.version=M,this.t={};for(const t of Object.keys(o)){const e=o[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.i=null,this.o=null,this.h=!1,this.l=!1,this.u=r,this.m=r?this.attachShadow({mode:"open"}):this,this.p=null,this.S=[],this.j=[],this.M=[],this.O=[],this._=[],this.$=[],this.A=[],this.T=[],this.k=new Map,this.L=!1,this.F=!1,this.I={},this.R=!1,this.V=t,this.C=!1,this.H=new Set,this.D=!1,this.U=new Map,this.q=0,this.B=!1}N(t){const e=this.u?this.m.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(o)}attributeChangedCallback(t,n,i){if(n===i)return;const s=this.t[t],o=this.I[t],r=e(i,s);if(this.props[t]=r,this.L&&o!==r)for(const e of this.T)try{e(t,o,r)}catch(t){l(String(t?.message||t))}this.I[t]=r,this.H.has(t)?this.H.delete(t):this.i&&this.isConnected?this.D?this.C=!0:this.update(!0):this.C=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const n=e(this.getAttribute(t),this.t[t]);this.props[t]=n,this.I[t]=n}r||this.p||(this.p=this.W());let t=null;try{if(s){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),host:this,onMount:t=>this.M.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.$.push(t),onFirstUpdate:t=>this.A.push(t),onPropsChanged:t=>this.T.push(t),link:(t,e)=>{const i=e||t;this.state[i]=this.props[t],this.T.push((e,n,s)=>{e===t&&(Object.is(this.state[i],s)||(this.state[i]=s))});const s={fn:()=>{const e=this.state[i];if(Object.is(this.props[t],e))return;this.props[t]=e,this.I[t]=e;const s=this.t[t],o=s?{...s,reflect:!0}:s,r=this.getAttribute(t);this.H.add(t),n(this,t,e,o),r===this.getAttribute(t)&&this.H.delete(t)},deps:()=>[this.state[i]]};this.S.push(s)},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const i={getter:t,deps:e,value:void 0!==e?t(n):t()};this.j.push(i);const s=()=>i.value;return s.P=i,this.J(s),s},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.K(n)},delegate:(t,e,n)=>(this.Z(t,e,n),()=>this.G(t,e,n))};for(const t of f)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=s(e)}}catch(t){String(t?.message||t)}if(this.i="function"!=typeof t?()=>"":t,this.D=!0,this.update(!0),this.D=!1,this.C&&(this.C=!1,this.update(!0)),!this.L){this.L=!0;for(const t of this.M)try{t()}catch(t){l(String(t?.message||t))}}}disconnectedCallback(){this.destroy()}remove(){super.remove()}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.k)try{this.m.removeEventListener(t.eventType,t.listener)}catch{}this.k.clear(),this.L=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,i){const s=n;t.addEventListener(e,s,i);const o=()=>{try{t.removeEventListener(e,s,i)}catch{}};return this.O.push(o),o}setState(t){let e=!1;const n=t,i=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const s=n[t];Object.is(i[t],s)||(i[t]=s,e=!0)}if(e)if(this.D||!this.L)this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0,requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&this.update(!0)})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.X()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const i=[];for(const s of e){const e=t[s],o=this.I[s];this.props[s]=e,this.L&&o!==e&&i.push(s);const r=this.t[s];r&&r.reflect&&n(this,s,e,r),this.L&&o===e||(this.I[s]=e)}if(this.L&&i.length>0)for(const e of i){const n=this.I[e],i=t[e];for(const t of this.T)try{t(e,n,i)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?this.update(!0):this.C=!0}scheduleUpdate(){this.i&&this.isConnected&&this.X()}X(){this.l||this.h||(this.l=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.l=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.L)for(const t of this.$)try{t()}catch(t){l(String(t?.message||t))}if(t){this.Y();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}if("string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e)=>{const n={...this.props,...e};return t.replace(_,(t,e)=>{const i=n[e];return null==i?"":String(i)})})(t,this.state),!this.u){const e=`data-scope-owner="${this.V}"`;t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot ${e}$1`)}this.B=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.L||(this.u,this.m.innerHTML=t,this.o=t,n=!0),this.D?(this.tt(),("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{this.i&&this.isConnected&&(n&&!r&&this.projectSlots(),n&&this.et(),this.nt(),this.it())})):(n&&!r&&this.projectSlots(),n&&this.st(),this.nt(),this.it())}else this.B&&this.Y(),this.nt(),this.L&&this.it()}}forceRender(){this.o=null,this.i&&this.isConnected?this.D?this.C=!0:this.update(!0):this.C=!0}it(){if(!this.F){this.F=!0;for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.ot()}ot(){const t=(this.u?this.m:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,i=this.props;this.actions;for(let s=0;s<t.length;s++){const o=t[s];if(this.N(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const s=r[t];if(!s.name.startsWith($))continue;const c=s.name.slice(5),h=s.value,f=h?h.trim():"";let l,u=!1;if(f){const t=this.U.get(f);if(t){t.P&&(this.B=!0);try{l=t()}catch{}u=!0}}if(!u){const t=f||c,s=e.call(n,t),o=!s&&e.call(i,t);s?l=n[t]:o&&(l=i[t])}if("text"===c){const t=null==l?"":String(l);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==l?"":String(l);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],l))try{o[c]=l}catch{}if("value"===c)try{null==l?o.removeAttribute("value"):o.setAttribute("value",String(l))}catch{}}else if(null!=l)try{o.setAttribute(c,String(l))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.rt;t&&o.removeEventListener(t,d),delete o[a]}}}}Y(){for(const t of this.j){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(i)&&(e=i,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let i=0;i<e.length;i++)if(!Object.is(t.prevDeps[i],e[i])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}nt(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;if(Array.isArray(i)&&(e=i,t.prevDeps&&t.prevDeps.length===e.length)){n=!1;for(let i=0;i<e.length;i++)if(!Object.is(t.prevDeps[i],e[i])){n=!0;break}}}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}K(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}J(t){const e=t.ct;if(e&&"string"==typeof e)return this.U.set(e,t),e;const n=`__scope_bind_${++this.q}__`;this.U.set(n,t);try{t.ct=n,t.toString=()=>n}catch{}return n}tt(){const t=(this.u?this.m:this).querySelectorAll("[ref]"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];if(0!==t.length)for(let n=0;n<t.length;n++){const i=t[n];if(this.N(i))continue;const s=i.getAttribute("ref");s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i)}}et(){const t=(this.u?this.m:this).querySelectorAll("*");for(let e=0;e<t.length;e++){const n=t[e];if(this.N(n))continue;if(0===n.attributes.length)continue;const i=n.attributes;for(let t=i.length-1;t>=0;t--){const e=i[t];if(!e.name.startsWith("on:"))continue;const s=e.name.slice(3),o=e.value,r=`__tinyHandler_${s}`,c=n[r];c&&n.removeEventListener(s,c),n.removeAttribute(e.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};n[r]=t,n.addEventListener(s,t)}}}}st(){const t=(this.u?this.m:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const i=t[n];if(this.N(i))continue;const s=i.getAttribute("ref");if(s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i),i.attributes.length>0){const t=i.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const s=n.name.slice(3),o=n.value,r=`__tinyHandler_${s}`,c=i[r];c&&i.removeEventListener(s,c),i.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};i[r]=t,i.addEventListener(s,t)}}}}}W(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const i=n[e];let s="";1===i.nodeType&&i.getAttribute&&(s=i.getAttribute("slot")||""),t.has(s)||t.set(s,[]),t.get(s).push(i)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.p||new Map,e=(this.u?this.m:this).querySelectorAll(`slot[data-scope-owner="${this.V}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const i=e[n],s=i.getAttribute("name")||"",o=t.get(s)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let i;if(1===n.nodeType&&n.tagName.includes("-")&&n.p instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n];e.setAttribute(i.name,i.value)}for(const n of t.p.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));i=e}else i=n.cloneNode(!0);t.appendChild(i)}i.replaceWith(t)}else{const t=i.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);i.replaceWith(t)}}}}Z(t,e,n){const i=`${t}::${e}`;let s=this.k.get(i);if(!s){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of s.handlers)try{e(t,n)}catch{}};s={eventType:t,selector:e,listener:n,handlers:new Set},this.k.set(i,s),this.m.addEventListener(t,n)}s.handlers.add(n)}G(t,e,n){const i=`${t}::${e}`,s=this.k.get(i);if(s&&(s.handlers.delete(n),0===s.handlers.size)){try{this.m.removeEventListener(t,s.listener)}catch{}this.k.delete(i)}}}if(!customElements.get(t)){if(c&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=c,document.head.appendChild(t)}}try{customElements.define(t,u)}catch(t){String(t?.message||t)}}return u}const s=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,i={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:s=!0}=i,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),s&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),o=(t,e={})=>({name:"morph",extend:(n,i)=>{const{ignoreActiveValue:s=!0,callbacks:o}=e,r=t(),c=i,h=c.m,f=c.u?ShadowRoot.prototype:HTMLElement.prototype,l=Object.getOwnPropertyDescriptor(f,"innerHTML"),u=t=>{r.morph(h,t,{morphStyle:"innerHTML",ignoreActiveValue:s,callbacks:o})};let a=!0;return Object.defineProperty(h,"innerHTML",{set(t){a?(l.set.call(this,t),a=!1):u(t)},get(){return l.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete h.innerHTML}),{morph:u}}}),r=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,i=new Set,s=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=n,s=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",s),e.add(s),i&&s(new UIEvent("resize")),()=>{window.removeEventListener("resize",s),e.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of i)t.disconnect();i.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:s,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return s((e,n,i)=>t(e,n,i),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:i,height:s}=n.contentRect;t(i,s,n)});if(r.observe(o),i.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),i.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=e,s=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",s,{passive:!0}),n.add(s),i&&s(new Event("scroll")),()=>{window.removeEventListener("scroll",s),n.delete(s)}}}}}),c=()=>({name:"inview",extend:(t,e)=>{const n=new Set,i=(t,e,i={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:s=!0,...o}=i;let r=!s;const c=new IntersectionObserver(n=>{for(const i of n)i.target===t&&(r?r=!1:e(i.isIntersecting,i))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>i(e,t,n),observeInView:(t,e,n)=>i(t,e,n)}}}),h=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const i=t();if(!i)return()=>{};const s=t=>{e(t)};i.on("scroll",s);const o={lenis:i,handler:s};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof i.off&&i.off("scroll",s))}}}}}),f=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,i=new Set,s={setTimeout:(t,n,...i)=>{let s;return s=setTimeout((...n)=>{e.delete(s),t(...n)},n,...i),e.add(s),s},setInterval:(t,e,...i)=>{const s=setInterval(t,e,...i);return n.add(s),s},raf:(t,e)=>{let n=0,s=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(i.delete(n),s){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),i.add(n)}};return n=requestAnimationFrame(c),i.add(n),()=>{s&&(s=!1,i.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of i)cancelAnimationFrame(t);i.clear()}),{timer:s}}}),l=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const i=t=>{const e=t;n(e.clientX,e.clientY,e)};window.addEventListener(t,i);let s=e.get(t);return s||(s=new Set,e.set(t,s)),s.add(i),()=>{window.removeEventListener(t,i),s?.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{const n=e;t(n.clientX,n.clientY,n.deltaY,n)};window.addEventListener("wheel",n);let i=e.get("wheel");return i||(i=new Set,e.set("wheel",i)),i.add(n),()=>{window.removeEventListener("wheel",n),i?.delete(n)}})(t)}}}),u=t=>Array.isArray(t),a=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),d=t=>u(t)?t.slice():a(t)?{...t}:t,m=(t,e)=>{if(u(t)&&u(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(a(t)&&a(e)){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!(i in e))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}return!(u(t)||u(e)||a(t)||a(e))&&Object.is(t,e)},p=(t,e)=>Array.from({length:e},()=>t),w=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),y=({from:t,to:e,velocity:n,label:i})=>{const s={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==s.arrayLength){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);s.arrayLength=t,u(s.value)||(s.value=p(s.value,t)),u(s.target)||(s.target=p(s.target,t)),void 0===s.velocity||u(s.velocity)||(s.velocity=p(s.velocity,t))}},r=t=>{if(null==s.objectKeys){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);s.objectKeys=t,a(s.value)||(s.value=w(s.value,t)),a(s.target)||(s.target=w(s.target,t)),void 0===s.velocity||a(s.velocity)||(s.velocity=w(s.velocity,t))}},c=t=>{if(u(t)){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);if(null==s.arrayLength&&o(t.length),t.length!==s.arrayLength)throw new Error(`${i} value length mismatch (expected ${s.arrayLength}, got ${t.length}).`);return t.slice()}if(a(t)){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==s.objectKeys&&r(e),s.objectKeys&&e.length!==s.objectKeys.length)throw new Error(`${i} value keys mismatch (expected ${s.objectKeys.length}, got ${e.length}).`);if(s.objectKeys)for(const e of s.objectKeys)if(!(e in t))throw new Error(`${i} value keys mismatch (missing key "${e}").`);return{...t}}return null!=s.arrayLength?p(t,s.arrayLength):null!=s.objectKeys?w(t,s.objectKeys):t};s.normalizeInput=c;const h=u(t)||u(e)||void 0!==n&&u(n),f=a(t)||a(e)||void 0!==n&&a(n);if(h&&f)throw new Error(`${i} value shape mismatch (array vs object).`);if(h){const i=u(t)?t.length:u(e)?e.length:n.length;o(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}else if(f){const i=a(t)?Object.keys(t):a(e)?Object.keys(e):Object.keys(n);r(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}return s};let g={x:-1,y:-1};const v={stiffness:300,damping:30,mass:1},b=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=l().extend(e,e.host),{timer:i}=f().extend(e,e.host);g.x=window.innerWidth/2,g.y=window.innerHeight/2;const s={x:t({from:g.x,to:g.x,...v}),y:t({from:g.y,to:g.y,...v})};return n((t,e)=>{s.x.setTarget(t),s.y.setTarget(e)}),{onPointerMove:t=>{let e=g.x,n=g.y;i.raf(i=>{const o=s.x.next(i),r=s.y.next(i);var c,h;e===o&&n===r||(t({x:o,y:r,v:(c={x:o,y:r},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=o,n=r)})},onMouseMove:n}}}),S=()=>({name:"lerp",extend:t=>{const{timer:e}=f().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:i=.001,resumeOnTarget:s=!0}={}){function o(){return d(f)}function r(t){if(w)return o();const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return o();if(1===e)return f=d(l),c.value=f,w=!0,o();const s=t>0?1-Math.pow(1-e,60*t):0;if(u(f)&&u(l)){let t=!0;for(let e=0;e<f.length;e+=1)f[e]+=(l[e]-f[e])*s,Math.abs(l[e]-f[e])>=i&&(t=!1);if(t){for(let t=0;t<f.length;t+=1)f[t]=l[t];w=!0}return c.value=f,d(f)}if(a(f)&&a(l)){const t=c.objectKeys??Object.keys(f);let e=!0;for(const n of t)f[n]+=(l[n]-f[n])*s,Math.abs(l[n]-f[n])>=i&&(e=!1);if(e){for(const e of t)f[e]=l[e];w=!0}return c.value=f,d(f)}const r=l;return f+=(r-f)*s,c.value=f,Math.abs(r-f)<i&&(f=r,c.value=f,w=!0),f}const c=y({from:t,to:e,label:"Lerp"}),h=c.normalizeInput;let f=c.value,l=c.target,p=null,w=!1;const g=new Set;return{setTarget:function(t){const e=h(t),n=!m(e,l);if(l=e,c.target=e,f=c.value,s&&w&&n){w=!1,p=null;for(const t of g)t(l)}},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:i=!1,markDone:s=!1}=e;f=h(t),c.value=f,i&&(l=d(f),c.target=l);const o=w||!m(f,l);if(n&&(p=null),s&&(w=!0),o&&!s){w=!1,p=null;for(const t of g)t(l)}},getValue:o,isDone:function(){return w},onResume:function(t){return g.add(t),()=>{g.delete(t)}},step:r,next:function(t=performance.now()){if(null==p)return p=t,o();const e=(t-p)/1e3;p=t;const n=1/30;let i=e,s=o();for(;i>0&&!w;){const t=Math.min(i,n);s=r(t),i-=t}return s}}}(t),runLerp:(t,i,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&i(t.getValue(),t);const l=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);i(n,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&i(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),n.delete(d))};return n.add(d),d}}}}),j=()=>({name:"spring",extend:e=>{const{timer:n}=f().extend(e,e.host),i=new Set;return e.onDestroy(()=>{for(const t of i)t();i.clear()}),{createSpring:e=>t(e),runSpring:(t,e,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&e(t.getValue(),t);const l=()=>{f||(f=n.raf(n=>{if(h)return;const i=t.next(n);e(i,t),c&&t.isDone()&&u()},o))},u=()=>{f&&(f(),f=null)};l();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),l())}),d=()=>{h||(h=!0,a(),u(),i.delete(d))};return i.add(d),d}}}}),M="0.0.5",O=()=>{console.info("The website is using @petit-kit/scoped v"+M),console.info("https://github.com/petit-kit/scoped")},_=/\{([A-Za-z_$][\w$]*)\}/g,$="bind:";export{M as SCOPE_VERSION,i as define,s as devicePlugin,O as happy,c as inViewPlugin,h as lenisPlugin,S as lerpPlugin,o as morphPlugin,l as mousePlugin,b as pointerPlugin,j as springPlugin,f as timerPlugin,r as windowPlugin};
2
2
  //# sourceMappingURL=index.js.map
@@ -5,6 +5,7 @@ export { inViewPlugin, type InViewControls, type InViewHandler, type InViewOptio
5
5
  export { lenisPlugin, type LenisControls, type LenisGetter, type LenisInstance, type LenisScrollEvent, type LenisScrollHandler, } from './lenis';
6
6
  export { timerPlugin, type TimerControls, type TimerIntervalHandle, type TimerRafCallback, type TimerRafUnsubscribe, type TimerTimeoutHandle, } from './timer';
7
7
  export { mousePlugin, type MouseControls, type MouseEventHandler, type MouseUnsubscribe, type MouseWheelHandler, } from './mouse';
8
+ export { pointerPlugin, type PointerControls } from './pointer';
8
9
  export { lerpPlugin, type LerpControls } from './lerp';
9
10
  export { springPlugin, type SpringControls } from './spring';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EACL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { ComponentPlugin } from '../../index';
2
+ import { type MouseControls } from '../mouse';
3
+ /** Smoothed pointer position with velocity. */
4
+ export type PointerPosition = {
5
+ x: number;
6
+ y: number;
7
+ v: number;
8
+ };
9
+ /** Handler for smoothed pointer move. Receives position and velocity magnitude. */
10
+ export type PointerMoveHandler = (pos: PointerPosition) => void;
11
+ /**
12
+ * Pointer plugin controls. Combines raw mouse input with spring-smoothed position and velocity.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * define("cursor-follower", { plugins: [pointerPlugin()] }, ({ onPointerMove }) => {
17
+ * onPointerMove(({ x, y, v }) => {
18
+ * host.updateState({ cursorX: x, cursorY: y, speed: v });
19
+ * });
20
+ * return () => `<div style="left: {cursorX}px; top: {cursorY}px">...</div>`;
21
+ * });
22
+ * ```
23
+ */
24
+ export type PointerControls = {
25
+ /**
26
+ * Subscribe to spring-smoothed pointer movement. Fires each frame when position changes.
27
+ * Receives position (x, y) and velocity magnitude (v). Uses RAF internally.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * onPointerMove(({ x, y, v }) => {
32
+ * // Smooth position for cursor-following
33
+ * host.updateState({ posX: x, posY: y });
34
+ * // Use v for hover intensity or transition speed
35
+ * if (v > 5) setActive(true);
36
+ * });
37
+ * ```
38
+ */
39
+ onPointerMove: (handler: PointerMoveHandler) => void;
40
+ /** Raw mouse move subscription (from mouse plugin). See MouseControls. */
41
+ onMouseMove: MouseControls['onMouseMove'];
42
+ };
43
+ /**
44
+ * Pointer plugin – spring-smoothed cursor position and velocity.
45
+ *
46
+ * Wraps the mouse plugin to provide smoothed pointer coordinates via spring physics.
47
+ * `onPointerMove` fires on RAF when the smoothed position changes, and includes
48
+ * velocity magnitude for effects (e.g., intensity, transitions).
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * define("my-component", { plugins: [pointerPlugin()] }, ({ onPointerMove, onMouseMove }) => {
53
+ * onPointerMove(({ x, y, v }) => host.updateState({ cx: x, cy: y, velocity: v }));
54
+ * return () => `<div style="transform: translate({cx}px, {cy}px)">...</div>`;
55
+ * });
56
+ * ```
57
+ */
58
+ export declare const pointerPlugin: () => ComponentPlugin<PointerControls>;
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/pointer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAW3D,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;;;;;OAaG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,0EAA0E;IAC1E,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAoCF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,QAAO,eAAe,CAAC,eAAe,CAsD9D,CAAC"}
@@ -6,6 +6,9 @@ export type WindowControls = {
6
6
  onWindowResize: (handler: (width: number, height: number, event: UIEvent | ResizeObserverEntry) => void, options?: {
7
7
  immediate?: boolean;
8
8
  }) => () => void;
9
+ onWindowScroll: (handler: (scrollX: number, scrollY: number, event: Event) => void, options?: {
10
+ immediate?: boolean;
11
+ }) => () => void;
9
12
  };
10
13
  export declare const windowPlugin: () => ComponentPlugin<WindowControls>;
11
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/window/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,aAAa,CAAC;AAEzE,MAAM,MAAM,cAAc,GAAG;IAO3B,gBAAgB,EAAE,CAChB,OAAO,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CAAC,EAAE,OAAO,CAAA;KAAE,KAC9B,MAAM,IAAI,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,eAAe,CAAC,cAAc,CAuG5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petit-kit/scoped",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
4
4
  "description": "A lightweight, reactive web component framework with built-in plugins for modern web development.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -32,6 +32,15 @@
32
32
  "dist"
33
33
  ],
34
34
  "sideEffects": false,
35
+ "scripts": {
36
+ "build": "npm run clean && npm run format && rollup -c && npm run build:types",
37
+ "build:types": "tsc -p tsconfig.declarations.json",
38
+ "dev": "rollup -c -w",
39
+ "clean": "rm -rf dist",
40
+ "format": "prettier --write .",
41
+ "format:check": "prettier --check .",
42
+ "publish": "pnpm build && pnpm publish --access public"
43
+ },
35
44
  "author": "",
36
45
  "license": "MIT",
37
46
  "devDependencies": {
@@ -46,13 +55,5 @@
46
55
  },
47
56
  "dependencies": {
48
57
  "@petit-kit/animate": "^0.0.1"
49
- },
50
- "scripts": {
51
- "build": "npm run clean && npm run format && rollup -c && npm run build:types",
52
- "build:types": "tsc -p tsconfig.declarations.json",
53
- "dev": "rollup -c -w",
54
- "clean": "rm -rf dist",
55
- "format": "prettier --write .",
56
- "format:check": "prettier --check ."
57
58
  }
58
- }
59
+ }