@firsthandjs/dom 0.1.0 → 0.3.0

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.
@@ -0,0 +1 @@
1
+ var C=null,x=new WeakMap;function $n(n){C=n,x=new WeakMap}var E=class extends Error{constructor(t){super(`${t} is not a Firsthand component. If it is a React component, import '@firsthandjs/react/auto' once at startup to render React components directly, or wrap it with fromReact(). Otherwise, declare it with component().`),this.name="FirsthandComponentError"}};function T(n){let t=x.get(n);if(t!==void 0)return t;if(C===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new E(o)}let e=C(n);return x.set(n,e),e}import{bind as ln,getOwner as L,onCleanup as dn,runWithOwner as un}from"@firsthandjs/core";var cn=3;function H(n){return typeof n.nodeType=="number"}var D=Symbol("firsthand.part");function Mn(n){return{[D]:!0,anchor:document.createTextNode(""),thunk:n,owner:L()}}function W(n){return D in n}function M(n,t,e=null){if(typeof t!="function"){p(n,e,null,t);return}let o=null;ln(()=>{let r=t();if(typeof r=="function"){o=g(o),M(n,r,e);return}o=p(n,e,o,r)}),dn(()=>{o=g(o)})}function p(n,t,e,o){let r=typeof o;if(o==null||r==="boolean")return g(e);if(r==="string"||r==="number"){let i=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===cn?(e.data=i,e):j(n,t,e,document.createTextNode(i))}if(r==="function")return p(n,t,e,o());if(Array.isArray(o)){let i=[],s=[];if(I(o,i,s),i.length===0)return g(e);an(n,t,e===null?[]:Array.isArray(e)?e:[e],i);for(let d=0;d<s.length;d++){let l=s[d];un(l.owner??L(),()=>{M(n,l.thunk,l.anchor)})}return i}return W(o)?p(n,t,e,[o]):H(o)?j(n,t,e,o):p(n,t,e,String(o))}function I(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&W(r)){t.push(r.anchor),e.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?I(r,t,e):typeof r=="object"&&H(r)?t.push(r):t.push(document.createTextNode(String(r))))}}function $(n){let t=n.parentNode;t!==null&&t.removeChild(n)}function g(n){if(n!==null)if(Array.isArray(n))for(let t=0;t<n.length;t++)$(n[t]);else $(n);return null}function j(n,t,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(g(e),n.insertBefore(o,t),o)}function an(n,t,e,o){let r=0,i=0,s=e.length-1,d=o.length-1;for(;r<=s&&i<=d&&e[r]===o[i];)r++,i++;for(;r<=s&&i<=d&&e[s]===o[d];)s--,d--;let l=d+1<o.length?o[d+1]:t;if(r>s){for(let u=i;u<=d;u++)n.insertBefore(o[u],l);return}if(i>d){for(let u=r;u<=s;u++)n.removeChild(e[u]);return}let c=new Map;for(let u=r;u<=s;u++)c.set(e[u],u);let a=d-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let w=o[i+u],v=c.get(w);v!==void 0&&(f[u]=v,c.delete(w))}for(let u of c.keys())n.removeChild(u);let m=fn(f),k=m.length-1,O=l;for(let u=a-1;u>=0;u--){let w=o[i+u];k>=0&&m[k]===u?k--:n.insertBefore(w,O),O=w}}function fn(n){let t=n.length,e=new Int32Array(t).fill(-1),o=[];for(let s=0;s<t;s++){let d=n[s];if(d===-1)continue;let l=0,c=o.length;for(;l<c;){let a=l+c>>1;n[o[a]]<d?l=a+1:c=a}l>0&&(e[s]=o[l-1]),o[l]=s}let r=[],i=o.length>0?o[o.length-1]:-1;for(;i!==-1;)r.push(i),i=e[i];return r.reverse()}import{signal as pn,createOwner as F,devEnterSetup as V,devExitSetup as y,disposeOwner as mn,getOwner as _,handleError as z,setOwner as h,untrack as B}from"@firsthandjs/core";var K=Symbol.for("firsthand.component"),wn=0,Z="firsthand";function Kn(n){Z=n}function Zn(n,t,e,o){let i=Object.assign(s=>gn(i,s),{[K]:!0,setup:n,options:t,id:e??`c${String(++wn)}`,tag:void 0});return Object.defineProperty(i,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),e===void 0&&(`${i.name}`,void 0),(t?.tag!==void 0||t?.shadow===!0)&&yn(i,typeof t.tag=="string"?t.tag:void 0),i}function qn(n){return typeof n=="function"&&K in n}function gn(n,t){if(Object.freeze(t),n.setup===void 0)return T(n)(t);if(n.tag!==void 0)return Cn(n,t);let e=F(_()),o=h(e);try{V(n.id);let r=B(()=>n.setup(t));return y(),h(o),r}catch(r){return y(),h(o),z(r,e),null}}function hn(n){let t=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${Z}-${t}`}function yn(n,t){let e=n;if(e.tag!==void 0)return e.tag;let o=t??hn(e);return customElements.get(o)!==void 0&&(o=`${o}-${e.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),e.tag=o,customElements.define(o,bn(e)),o}function bn(n){let t=n.options?.shadow===!0,e=n.options?.attributes,o=e!==void 0?Object.keys(e):[];return class extends HTMLElement{static observedAttributes=o;constructor(){super(),this.$owner=null,this.$props=null,this.$attrs=null,this.$standalone=!1}connectedCallback(){this.$owner===null&&(this.$standalone=!0,this.$attrs={},this.$props=kn(this,e,this.$attrs),q(this,n,t))}disconnectedCallback(){!this.$standalone||this.$owner===null||(mn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,d){let l=this.$attrs?.[i];l!==void 0&&(l.value=e[i]?.(d))}}}function kn(n,t,e){let o={};if(t!==void 0)for(let r in t){let i=pn(t[r](n.getAttribute(r)));e[r]=i,Object.defineProperty(o,r,{enumerable:!0,get:()=>i.value})}return Object.freeze(o)}function q(n,t,e){let o=F(_());n.$owner=o;let r=h(o);try{V(t.id);let i=e?n.attachShadow({mode:"open"}):n,s=B(()=>t.setup(n.$props));y(),p(i,null,null,s)}catch(i){y(),z(i,o)}finally{h(r)}}function Cn(n,t){let e=document.createElement(n.tag);return e.$props=t,q(e,n,n.options?.shadow===!0),e}import{batch as xn,createOwner as G,disposeOwner as En,getOwner as Rn,setOwner as R,signal as Y,untrack as X}from"@firsthandjs/core";function Un(n,t,e){let o=G(Rn()),r=new Map;return()=>{let i=n(),s=new Map,d=[];return xn(()=>{for(let l=0;l<i.length;l++){let c=i[l],a=X(()=>t(c,l));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=Nn(o,c,l,e):(r.delete(a),f.item.value=c,f.index.value=l),s.set(a,f);for(let m=0;m<f.nodes.length;m++)d.push(f.nodes[m])}for(let l of r.values())En(l.owner)}),r=s,d}}function Nn(n,t,e,o){let r=G(n),i=Y(t),s=Y(e),d=R(r),l;try{l=X(()=>o(i,s)),R(d)}catch(a){throw R(d),a}let c=[];return J(l,c),{owner:r,item:i,index:s,nodes:c}}function J(n,t){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let e=0;e<n.length;e++)J(n[e],t);return}if(typeof n=="object"&&typeof n.nodeType=="number"){t.push(n);return}t.push(document.createTextNode(String(n)))}}var An=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),Q=new Set;function N(n){return`$firsthand$${n}`}function Pn(n){let t=N(n.type),e=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<e.length;r++){let i=e[r],s=i[t];if(s!==void 0&&(o=i,s.call(i,n),n.cancelBubble)||i===document)break}o=null}function b(n,t,e,o){if(o!==void 0||!An.has(t)){n.addEventListener(t,e,o===!0?void 0:o);return}n[N(t)]=e,Q.has(t)||(Q.add(t),document.addEventListener(t,Pn))}function ee(n,t){n[N(t)]=void 0}var Sn={class:"className",for:"htmlFor"};function P(n,t,e){e==null||e===!1?n.removeAttribute(t):n.setAttribute(t,e===!0?"":String(e))}function oe(n,t,e,o){o==null||o===!1?n.removeAttributeNS(t,e):n.setAttributeNS(t,e,o===!0?"":String(o))}function S(n,t,e){n[Sn[t]??t]=e}function re(n,t,e){n[t]=!!e}function nn(n,t){t==null?n.removeAttribute("class"):n.className=String(t)}function en(n,t,e){let o=n.classList;if(e!==void 0)for(let r in e)r in t||o.remove(r);for(let r in t){let i=!!t[r];(e===void 0||!!e[r]!==i)&&o.toggle(r,i)}}function tn(n,t){t==null?n.style.cssText="":n.style.cssText=String(t)}function on(n,t,e){let o=n.style;if(e!==void 0)for(let r in e)r in t||o.removeProperty(A(r));for(let r in t){let i=t[r];(e===void 0||e[r]!==i)&&(i==null?o.removeProperty(A(r)):o.setProperty(A(r),String(i)))}}var On=/[A-Z]/g,U=new Map;function A(n){let t=U.get(n);return t===void 0&&(t=n.startsWith("--")?n:n.replace(On,e=>`-${e.toLowerCase()}`),U.set(n,t)),t}function vn(n,t,e){if(t==="class"||t==="className"){e!==null&&typeof e=="object"?en(n,e,sn(n,"class",e)):nn(n,e);return}if(t==="style"){e!==null&&typeof e=="object"?on(n,e,sn(n,"style",e)):tn(n,e);return}if(t==="ref"){e(n);return}if(t.startsWith("prop:")){S(n,t.slice(5),e);return}if(t.startsWith("attr:")){P(n,t.slice(5),e);return}if(t.startsWith("on")&&t.length>2&&/[A-Z:]/.test(t[2])){Tn(n,t,e);return}if(t in n&&typeof e!="string"){S(n,t,e);return}P(n,t,e)}function Tn(n,t,e){let o=t.slice(2).split(":"),r=o[0]==="",i=r?o[1]:o[0].toLowerCase(),s=o[r?2:1];s===void 0?b(n,i,e):s==="native"?b(n,i,e,!0):b(n,i,e,{[s]:!0})}function de(n,t){for(let e in t)e!=="children"&&vn(n,e,t[e])}function ue(...n){let t={};for(let e=0;e<n.length;e++){let o=n[e];for(let r of Object.keys(o))Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return t}function ce(n,t){let e={};for(let o of Object.keys(n))t.includes(o)||Object.defineProperty(e,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(e)}var rn=new WeakMap;function sn(n,t,e){let o=rn.get(n);o===void 0&&(o={},rn.set(n,o));let r=o[t];return o[t]=e,r}export{$n as a,E as b,Mn as c,M as d,p as e,an as f,K as g,Kn as h,Zn as i,qn as j,gn as k,yn as l,Un as m,b as n,ee as o,P as p,oe as q,S as r,re as s,nn as t,en as u,tn as v,on as w,vn as x,de as y,ue as z,ce as A};
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,oFAAoF;AACpF,eAAO,MAAM,SAAS,EAAE,OAAO,MAA0C,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACvD;AAED,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,IAAI,GACd,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IAAI,EAAE,CAAC;AAEvF;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,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EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAKD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,EAAE,CAAC,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAAC,CAAC,CAAC,CAgCd;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,CAErE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CA+BvE;AAcD,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAc5E"}
package/dist/dev.d.ts CHANGED
@@ -10,4 +10,14 @@
10
10
  export declare function devWarn(message: string): void;
11
11
  /** Warns at most once for a given key, so a repeated mistake is not spam. */
12
12
  export declare function devWarnOnce(key: string, message: string): void;
13
+ /**
14
+ * Warns when an object is about to be rendered as text.
15
+ *
16
+ * `<p>{count}</p>` — a signal without `.value` — is the mistake this exists
17
+ * for: TypeScript rejects it, but plain JavaScript and the runtime JSX path do
18
+ * not, and the result is a silent `[object Object]` in the page. The check
19
+ * lives here rather than at the call site so that production pays nothing for
20
+ * it: `dev.prod.ts` replaces this with an empty function.
21
+ */
22
+ export declare function devWarnRenderedObject(value: object): void;
13
23
  //# sourceMappingURL=dev.d.ts.map
package/dist/dev.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAID,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAK9D"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAID,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAK9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAWzD"}
@@ -1,4 +1,5 @@
1
1
  /** Production stub for `dev.ts`. Aliased in by the build; see `dev.ts`. */
2
2
  export declare function devWarn(_message: string): void;
3
3
  export declare function devWarnOnce(_key: string, _message: string): void;
4
+ export declare function devWarnRenderedObject(_value: object): void;
4
5
  //# sourceMappingURL=dev.prod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE"}
1
+ {"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as i,e as p,h as s,i as m,k as f,l as a,m as c,n as u,o as C,z as x}from"./chunk-6OTA5OKE.js";import{createRoot as y,onCleanup as h,untrack as N}from"@firsthandjs/core";function g(e,r=document.body){let o;return y(t=>{o=t;let n=null;n=p(r,null,null,N(e)),h(()=>{p(r,null,n,null)})}),o}import{onCleanup as E}from"@firsthandjs/core";function b(e,r){let o=[];l(e,o);for(let t=0;t<o.length;t++)r.appendChild(o[t]);return E(()=>{for(let t=0;t<o.length;t++){let n=o[t];n.parentNode?.removeChild(n)}}),null}function l(e,r){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)l(e[o],r);return}if(typeof e=="object"&&typeof e.nodeType=="number"){r.push(e);return}r.push(document.createTextNode(String(e)))}}import{signal as z,computed as B,effect as G,batch as H,untrack as I,onCleanup as J,createRoot as K,catchError as L,runWithOwner as M,createContext as Q,provide as U,useContext as X,FirsthandContextError as Y,FirsthandCycleError as Z,FirsthandReadonlyError as _}from"@firsthandjs/core";export{i as FirsthandComponentError,Y as FirsthandContextError,Z as FirsthandCycleError,_ as FirsthandReadonlyError,H as batch,L as catchError,m as component,B as computed,f as createComponent,Q as createContext,K as createRoot,a as defineElement,G as effect,c as list,x as mergeProps,C as off,u as on,J as onCleanup,b as portal,U as provide,g as render,M as runWithOwner,d as setComponentAdapter,s as setElementPrefix,z as signal,I as untrack,X as useContext};
1
+ import{a as d,b as i,e as p,h as s,i as m,k as f,l as a,m as c,n as u,o as C,z as x}from"./chunk-6OI7S46K.js";import{createRoot as y,onCleanup as h,untrack as N}from"@firsthandjs/core";function g(e,r=document.body){let o;return y(t=>{o=t;let n=null;n=p(r,null,null,N(e)),h(()=>{p(r,null,n,null)})}),o}import{onCleanup as E}from"@firsthandjs/core";function b(e,r){let o=[];l(e,o);for(let t=0;t<o.length;t++)r.appendChild(o[t]);return E(()=>{for(let t=0;t<o.length;t++){let n=o[t];n.parentNode?.removeChild(n)}}),null}function l(e,r){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)l(e[o],r);return}if(typeof e=="object"&&typeof e.nodeType=="number"){r.push(e);return}r.push(document.createTextNode(String(e)))}}import{signal as z,computed as B,effect as G,batch as H,untrack as I,onCleanup as J,createRoot as K,catchError as L,runWithOwner as M,createContext as Q,provide as U,useContext as X,FirsthandContextError as Y,FirsthandCycleError as Z,FirsthandReadonlyError as _}from"@firsthandjs/core";export{i as FirsthandComponentError,Y as FirsthandContextError,Z as FirsthandCycleError,_ as FirsthandReadonlyError,H as batch,L as catchError,m as component,B as computed,f as createComponent,Q as createContext,K as createRoot,a as defineElement,G as effect,c as list,x as mergeProps,C as off,u as on,J as onCleanup,b as portal,U as provide,g as render,M as runWithOwner,d as setComponentAdapter,s as setElementPrefix,z as signal,I as untrack,X as useContext};
@@ -1 +1 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAExF,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAQ7C,QAAA,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH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tB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,OAAO,GAAG,YAAY,CAEvD;AAMD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,IAAI,GAAG,IAAW,GAAG,IAAI,CA4BrF;AAED,6EAA6E;AAC7E,wBAAgB,UAAU,CACxB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAyDX;AAmED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAqEvF"}
package/dist/internal.js CHANGED
@@ -1 +1 @@
1
- import{A as L,c as l,d as s,e as i,f as a,g as m,j as d,k as f,m as c,n as u,o as x,p as N,q as y,r as C,s as h,t as b,u as O,v as S,w as P,x as T,y as g,z as E}from"./chunk-6OTA5OKE.js";function j(r,o=!1){let e;return()=>{if(e===void 0){let t=document.createElement("template");t.innerHTML=r,e=o?t.content:t.content.firstChild}return e.cloneNode(!0)}}function A(r,...o){let e=r;for(let t=0;t<o.length;t++){let n=e.firstChild;for(let p=o[t];p>0;p--)n=n.nextSibling;e=n}return e}import{bind as k}from"@firsthandjs/core";var M=1;export{m as COMPONENT,M as PROTOCOL_VERSION,i as applyChild,T as applyProp,k as bind,f as createComponent,s as insert,d as isComponent,c as list,E as mergeProps,x as off,u as on,l as part,A as path,a as reconcile,L as rest,N as setAttribute,y as setAttributeNS,h as setBoolean,b as setClass,O as setClassList,C as setProperty,S as setStyle,P as setStyleObject,g as spread,j as template};
1
+ import{A as L,c as l,d as s,e as i,f as a,g as m,j as d,k as f,m as c,n as u,o as x,p as N,q as y,r as C,s as h,t as b,u as O,v as S,w as P,x as T,y as g,z as E}from"./chunk-6OI7S46K.js";function j(r,o=!1){let e;return()=>{if(e===void 0){let t=document.createElement("template");t.innerHTML=r,e=o?t.content:t.content.firstChild}return e.cloneNode(!0)}}function A(r,...o){let e=r;for(let t=0;t<o.length;t++){let n=e.firstChild;for(let p=o[t];p>0;p--)n=n.nextSibling;e=n}return e}import{bind as k}from"@firsthandjs/core";var M=1;export{m as COMPONENT,M as PROTOCOL_VERSION,i as applyChild,T as applyProp,k as bind,f as createComponent,s as insert,d as isComponent,c as list,E as mergeProps,x as off,u as on,l as part,A as path,a as reconcile,L as rest,N as setAttribute,y as setAttributeNS,h as setBoolean,b as setClass,O as setClassList,C as setProperty,S as setStyle,P as setStyleObject,g as spread,j as template};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/dom",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "DOM parts, templates, components, portals and keyed lists for Firsthand.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "LICENSE"
24
24
  ],
25
25
  "dependencies": {
26
- "@firsthandjs/core": "0.1.0"
26
+ "@firsthandjs/core": "0.3.0"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=20.11.0"
@@ -1 +0,0 @@
1
- var k=null,C=new WeakMap;function $n(n){k=n,C=new WeakMap}var x=class extends Error{constructor(t){super(`${t} is not a Firsthand component. If it is a React component, import '@firsthandjs/react/auto' once at startup to render React components directly, or wrap it with fromReact(). Otherwise, declare it with component().`),this.name="FirsthandComponentError"}};function $(n){let t=C.get(n);if(t!==void 0)return t;if(k===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new x(o)}let e=k(n);return C.set(n,e),e}import{bind as rn,getOwner as j,onCleanup as sn,runWithOwner as ln}from"@firsthandjs/core";var dn=3;function L(n){return typeof n.nodeType=="number"}var H=Symbol("firsthand.part");function jn(n){return{[H]:!0,anchor:document.createTextNode(""),thunk:n,owner:j()}}function D(n){return H in n}function M(n,t,e=null){if(typeof t!="function"){p(n,e,null,t);return}let o=null;rn(()=>{let r=t();if(typeof r=="function"){o=w(o),M(n,r,e);return}o=p(n,e,o,r)}),sn(()=>{o=w(o)})}function p(n,t,e,o){let r=typeof o;if(o==null||r==="boolean")return w(e);if(r==="string"||r==="number"){let i=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===dn?(e.data=i,e):v(n,t,e,document.createTextNode(i))}if(r==="function")return p(n,t,e,o());if(Array.isArray(o)){let i=[],s=[];if(W(o,i,s),i.length===0)return w(e);un(n,t,e===null?[]:Array.isArray(e)?e:[e],i);for(let d=0;d<s.length;d++){let l=s[d];ln(l.owner??j(),()=>{M(n,l.thunk,l.anchor)})}return i}return D(o)?p(n,t,e,[o]):L(o)?v(n,t,e,o):p(n,t,e,String(o))}function W(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&D(r)){t.push(r.anchor),e.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?W(r,t,e):typeof r=="object"&&L(r)?t.push(r):t.push(document.createTextNode(String(r))))}}function T(n){let t=n.parentNode;t!==null&&t.removeChild(n)}function w(n){if(n!==null)if(Array.isArray(n))for(let t=0;t<n.length;t++)T(n[t]);else T(n);return null}function v(n,t,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(w(e),n.insertBefore(o,t),o)}function un(n,t,e,o){let r=0,i=0,s=e.length-1,d=o.length-1;for(;r<=s&&i<=d&&e[r]===o[i];)r++,i++;for(;r<=s&&i<=d&&e[s]===o[d];)s--,d--;let l=d+1<o.length?o[d+1]:t;if(r>s){for(let u=i;u<=d;u++)n.insertBefore(o[u],l);return}if(i>d){for(let u=r;u<=s;u++)n.removeChild(e[u]);return}let c=new Map;for(let u=r;u<=s;u++)c.set(e[u],u);let a=d-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let g=o[i+u],O=c.get(g);O!==void 0&&(f[u]=O,c.delete(g))}for(let u of c.keys())n.removeChild(u);let m=cn(f),b=m.length-1,S=l;for(let u=a-1;u>=0;u--){let g=o[i+u];b>=0&&m[b]===u?b--:n.insertBefore(g,S),S=g}}function cn(n){let t=n.length,e=new Int32Array(t).fill(-1),o=[];for(let s=0;s<t;s++){let d=n[s];if(d===-1)continue;let l=0,c=o.length;for(;l<c;){let a=l+c>>1;n[o[a]]<d?l=a+1:c=a}l>0&&(e[s]=o[l-1]),o[l]=s}let r=[],i=o.length>0?o[o.length-1]:-1;for(;i!==-1;)r.push(i),i=e[i];return r.reverse()}import{signal as an,createOwner as I,disposeOwner as fn,getOwner as F,handleError as V,setOwner as h,untrack as _}from"@firsthandjs/core";var z=Symbol.for("firsthand.component"),pn=0,B="firsthand";function Vn(n){B=n}function _n(n,t,e,o){let i=Object.assign(s=>mn(i,s),{[z]:!0,setup:n,options:t,id:e??`c${String(++pn)}`,tag:void 0});return Object.defineProperty(i,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),e===void 0&&(`${i.name}`,void 0),(t?.tag!==void 0||t?.shadow===!0)&&wn(i,typeof t.tag=="string"?t.tag:void 0),i}function zn(n){return typeof n=="function"&&z in n}function mn(n,t){if(Object.freeze(t),n.setup===void 0)return $(n)(t);if(n.tag!==void 0)return bn(n,t);let e=I(F()),o=h(e);try{let r=_(()=>n.setup(t));return h(o),r}catch(r){return h(o),V(r,e),null}}function gn(n){let t=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${B}-${t}`}function wn(n,t){let e=n;if(e.tag!==void 0)return e.tag;let o=t??gn(e);return customElements.get(o)!==void 0&&(o=`${o}-${e.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),e.tag=o,customElements.define(o,hn(e)),o}function hn(n){let t=n.options?.shadow===!0,e=n.options?.attributes,o=e!==void 0?Object.keys(e):[];return class extends HTMLElement{static observedAttributes=o;constructor(){super(),this.$owner=null,this.$props=null,this.$attrs=null,this.$standalone=!1}connectedCallback(){this.$owner===null&&(this.$props===null&&(this.$standalone=!0,this.$attrs={},this.$props=yn(this,e,this.$attrs)),K(this,n,t))}disconnectedCallback(){!this.$standalone||this.$owner===null||(fn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,d){let l=this.$attrs?.[i];l!==void 0&&(l.value=e[i]?.(d))}}}function yn(n,t,e){let o={};if(t!==void 0)for(let r in t){let i=an(t[r](n.getAttribute(r)));e[r]=i,Object.defineProperty(o,r,{enumerable:!0,get:()=>i.value})}return Object.freeze(o)}function K(n,t,e){let o=I(F());n.$owner=o;let r=h(o);try{let i=e?n.attachShadow({mode:"open"}):n,s=_(()=>t.setup(n.$props));p(i,null,null,s)}catch(i){V(i,o)}finally{h(r)}}function bn(n,t){let e=document.createElement(n.tag);return e.$props=t,e.$owner===null&&K(e,n,n.options?.shadow===!0),e}import{batch as kn,createOwner as q,disposeOwner as Cn,getOwner as xn,setOwner as E,signal as Z,untrack as Y}from"@firsthandjs/core";function Gn(n,t,e){let o=q(xn()),r=new Map;return()=>{let i=n(),s=new Map,d=[];return kn(()=>{for(let l=0;l<i.length;l++){let c=i[l],a=Y(()=>t(c,l));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=En(o,c,l,e):(r.delete(a),f.item.value=c,f.index.value=l),s.set(a,f);for(let m=0;m<f.nodes.length;m++)d.push(f.nodes[m])}for(let l of r.values())Cn(l.owner)}),r=s,d}}function En(n,t,e,o){let r=q(n),i=Z(t),s=Z(e),d=E(r),l;try{l=Y(()=>o(i,s)),E(d)}catch(a){throw E(d),a}let c=[];return G(l,c),{owner:r,item:i,index:s,nodes:c}}function G(n,t){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let e=0;e<n.length;e++)G(n[e],t);return}if(typeof n=="object"&&typeof n.nodeType=="number"){t.push(n);return}t.push(document.createTextNode(String(n)))}}var Rn=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),X=new Set;function R(n){return`$firsthand$${n}`}function Nn(n){let t=R(n.type),e=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<e.length;r++){let i=e[r],s=i[t];if(s!==void 0&&(o=i,s.call(i,n),n.cancelBubble)||i===document)break}o=null}function y(n,t,e,o){if(o!==void 0||!Rn.has(t)){n.addEventListener(t,e,o===!0?void 0:o);return}n[R(t)]=e,X.has(t)||(X.add(t),document.addEventListener(t,Nn))}function Jn(n,t){n[R(t)]=void 0}var An={class:"className",for:"htmlFor"};function A(n,t,e){e==null||e===!1?n.removeAttribute(t):n.setAttribute(t,e===!0?"":String(e))}function Un(n,t,e,o){o==null||o===!1?n.removeAttributeNS(t,e):n.setAttributeNS(t,e,o===!0?"":String(o))}function P(n,t,e){n[An[t]??t]=e}function ne(n,t,e){n[t]=!!e}function Q(n,t){t==null?n.removeAttribute("class"):n.className=String(t)}function U(n,t,e){let o=n.classList;if(e!==void 0)for(let r in e)r in t||o.remove(r);for(let r in t){let i=!!t[r];(e===void 0||!!e[r]!==i)&&o.toggle(r,i)}}function nn(n,t){t==null?n.style.cssText="":n.style.cssText=String(t)}function en(n,t,e){let o=n.style;if(e!==void 0)for(let r in e)r in t||o.removeProperty(N(r));for(let r in t){let i=t[r];(e===void 0||e[r]!==i)&&(i==null?o.removeProperty(N(r)):o.setProperty(N(r),String(i)))}}var Pn=/[A-Z]/g,J=new Map;function N(n){let t=J.get(n);return t===void 0&&(t=n.startsWith("--")?n:n.replace(Pn,e=>`-${e.toLowerCase()}`),J.set(n,t)),t}function Sn(n,t,e){if(t==="class"||t==="className"){e!==null&&typeof e=="object"?U(n,e,on(n,"class",e)):Q(n,e);return}if(t==="style"){e!==null&&typeof e=="object"?en(n,e,on(n,"style",e)):nn(n,e);return}if(t==="ref"){e(n);return}if(t.startsWith("prop:")){P(n,t.slice(5),e);return}if(t.startsWith("attr:")){A(n,t.slice(5),e);return}if(t.startsWith("on")&&t.length>2&&/[A-Z:]/.test(t[2])){On(n,t,e);return}if(t in n&&typeof e!="string"){P(n,t,e);return}A(n,t,e)}function On(n,t,e){let o=t.slice(2).split(":"),r=o[0]==="",i=r?o[1]:o[0].toLowerCase(),s=o[r?2:1];s===void 0?y(n,i,e):s==="native"?y(n,i,e,!0):y(n,i,e,{[s]:!0})}function re(n,t){for(let e in t)e!=="children"&&Sn(n,e,t[e])}function ie(...n){let t={};for(let e=0;e<n.length;e++){let o=n[e];for(let r of Object.keys(o))Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return t}function se(n,t){let e={};for(let o of Object.keys(n))t.includes(o)||Object.defineProperty(e,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(e)}var tn=new WeakMap;function on(n,t,e){let o=tn.get(n);o===void 0&&(o={},tn.set(n,o));let r=o[t];return o[t]=e,r}export{$n as a,x as b,jn as c,M as d,p as e,un as f,z as g,Vn as h,_n as i,zn as j,mn as k,wn as l,Gn as m,y as n,Jn as o,A as p,Un as q,P as r,ne as s,Q as t,U as u,nn as v,en as w,Sn as x,re as y,ie as z,se as A};