@firsthandjs/dom 0.8.0 → 0.9.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CA0C3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAa5E;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazF;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CA8C3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAa5E;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazF;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
package/dist/render.d.ts CHANGED
@@ -10,4 +10,13 @@ import type { View } from './component.js';
10
10
  * children.
11
11
  */
12
12
  export declare function render(view: () => View, container?: ParentNode): Dispose;
13
+ /**
14
+ * The whole of mounting, with one hole in it.
15
+ *
16
+ * `around` is how `@firsthandjs/dom/hydrate` gets in: it wraps the run so that
17
+ * what the view builds is adopted rather than created. `render` passes
18
+ * nothing, which is why a build without a server contains neither the wrapper
19
+ * nor anything it would have called.
20
+ */
21
+ export declare function mount(view: () => View, container: ParentNode, around: ((body: () => void) => void) | null): Dispose;
13
22
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,CAmBvF"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,CAEvF;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,IAAI,EAChB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GAC1C,OAAO,CAcT"}
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAEzC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,eAAe,CAU1E;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAUpE"}
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAEzC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,eAAe,CA+B1E;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAUpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/dom",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "DOM parts, templates, components, portals and keyed lists for Firsthand.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,6 +11,11 @@
11
11
  "development": "./dist/index.dev.js",
12
12
  "default": "./dist/index.js"
13
13
  },
14
+ "./hydrate": {
15
+ "types": "./dist/hydrate.d.ts",
16
+ "development": "./dist/hydrate.dev.js",
17
+ "default": "./dist/hydrate.js"
18
+ },
14
19
  "./internal": {
15
20
  "types": "./dist/internal.d.ts",
16
21
  "development": "./dist/internal.dev.js",
@@ -25,7 +30,7 @@
25
30
  "LICENSE"
26
31
  ],
27
32
  "dependencies": {
28
- "@firsthandjs/core": "0.8.0"
33
+ "@firsthandjs/core": "0.9.1"
29
34
  },
30
35
  "engines": {
31
36
  "node": ">=20.11.0"
@@ -1 +0,0 @@
1
- var C=null,S=new WeakMap;function Vn(n){C=n,S=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 j(n){let t=S.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 S.set(n,e),e}function qn(n,t,e){return n}import{bind as pn,createOwner as mn,signal as wn,disposeOwner as gn,getOwner as v,onCleanup as yn,runWithOwner as hn,setOwner as _}from"@firsthandjs/core";var bn=3;function W(n){return typeof n.nodeType=="number"}var D=Symbol("firsthand.part");function M(n){return{[D]:!0,anchor:document.createTextNode(""),thunk:n,owner:v()}}function I(n){return D in n}function Xn(n=""){return{slots:[],owner:v(),generation:0,name:n}}function R(n){n.busy=!0}function V(n,t){let e=n.slots[t];if(e!==void 0)return e.seen=n.generation,e;let o={seen:n.generation};return n.slots[t]=o,o}function Jn(n,t){let e=mn(n.owner);return t.owner=e,_(e)}function Qn(n){_(n)}function Un(n,t){let e=n.generation,o=n.slots;for(let r=0;r<o.length;r++){let i=o[r];i===void 0||i.seen===e||(i.owner!==void 0&&gn(i.owner),o[r]=void 0)}return n.generation=e+1,t}function ne(n,t,e){let o=V(n,t),r=o.cell;if(r===void 0){let i=wn(e);return o.cell=i,i}return r.peek()!==e&&(R(n),r.value=e),r}function ee(n,t,e,o,r){let i=V(n,t),s=typeof r;if(s==="string"||s==="number"){let l=String(r);if(l===i.text)return;R(n),i.text=l,i.node=p(e,o,i.node??null,l);return}i.text=void 0,r!==i.last&&(R(n),i.last=r,i.node=p(e,o,i.node??null,r))}function F(n,t,e=null){if(typeof t!="function"){p(n,e,null,t);return}let o=null,r;pn(()=>{let i=t(),s=typeof i;if(s==="string"||s==="number"){let l=String(i);l!==r&&(r=l,o=p(n,e,o,l));return}if(r=void 0,s==="function"){o=g(o),F(n,i,e);return}o=p(n,e,o,i)}),yn(()=>{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===bn?(e.data=i,e):L(n,t,e,document.createTextNode(i))}if(r==="function")return p(n,t,e,o());if(Array.isArray(o)){let i=[],s=[];if(q(o,i,s),i.length===0)return g(e);kn(n,t,e===null?[]:Array.isArray(e)?e:[e],i);for(let l=0;l<s.length;l++){let d=s[l];hn(d.owner??v(),()=>{F(n,d.thunk,d.anchor)})}return i}return I(o)?p(n,t,e,[o]):W(o)?L(n,t,e,o):p(n,t,e,String(o))}function q(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&I(r)){t.push(r.anchor),e.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?q(r,t,e):typeof r=="object"&&W(r)?t.push(r):t.push(document.createTextNode(String(r))))}}function H(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++)H(n[t]);else H(n);return null}function L(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 kn(n,t,e,o){let r=0,i=0,s=e.length-1,l=o.length-1;for(;r<=s&&i<=l&&e[r]===o[i];)r++,i++;for(;r<=s&&i<=l&&e[s]===o[l];)s--,l--;let d=l+1<o.length?o[l+1]:t;if(r>s){for(let u=i;u<=l;u++)n.insertBefore(o[u],d);return}if(i>l){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=l-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let w=o[i+u],$=c.get(w);$!==void 0&&(f[u]=$,c.delete(w))}for(let u of c.keys())n.removeChild(u);let m=xn(f),x=m.length-1,T=d;for(let u=a-1;u>=0;u--){let w=o[i+u];x>=0&&m[x]===u?x--:n.insertBefore(w,T),T=w}}function xn(n){let t=n.length,e=new Int32Array(t).fill(-1),o=[];for(let s=0;s<t;s++){let l=n[s];if(l===-1)continue;let d=0,c=o.length;for(;d<c;){let a=d+c>>1;n[o[a]]<l?d=a+1:c=a}d>0&&(e[s]=o[d-1]),o[d]=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 Cn,createOwner as z,devEnterSetup as B,devExitSetup as h,disposeOwner as Sn,getOwner as K,handleError as Z,setOwner as y,untrack as Y}from"@firsthandjs/core";var G=Symbol.for("firsthand.component"),X=Symbol.for("firsthand.view"),En=0,J="firsthand";function ue(n){J=n}function ce(n,t,e,o){let i=Object.assign(s=>Rn(i,s),{[G]:!0,setup:n,options:t,id:e??`c${String(++En)}`,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)&&Nn(i,typeof t.tag=="string"?t.tag:void 0),i}function ae(n){return typeof n=="function"&&G in n}function fe(n){return n[X]=!0,n}function Rn(n,t){if(Object.freeze(t),n.setup===void 0)return X in n?M(()=>n(t)):j(n)(t);if(n.tag!==void 0)return An(n,t);let e=z(K());n.name;let o=y(e);try{B(n.id);let r=Y(()=>n.setup(t));return h(),y(o),r}catch(r){return h(),y(o),Z(r,e),null}}function vn(n){let t=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${J}-${t}`}function Nn(n,t){let e=n;if(e.tag!==void 0)return e.tag;let o=t??vn(e);return customElements.get(o)!==void 0&&(o=`${o}-${e.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),e.tag=o,customElements.define(o,On(e)),o}function On(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=Pn(this,e,this.$attrs),Q(this,n,t))}disconnectedCallback(){!this.$standalone||this.$owner===null||(Sn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,l){let d=this.$attrs?.[i];d!==void 0&&(d.value=e[i]?.(l))}}}function Pn(n,t,e){let o={};if(t!==void 0)for(let r in t){let i=Cn(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=z(K());t.name,n.$owner=o;let r=y(o);try{B(t.id);let i=e?n.attachShadow({mode:"open"}):n,s=Y(()=>t.setup(n.$props));h(),p(i,null,null,s)}catch(i){h(),Z(i,o)}finally{y(r)}}function An(n,t){let e=document.createElement(n.tag);return e.$props=t,Q(e,n,n.options?.shadow===!0),e}import{batch as Tn,createOwner as nn,disposeOwner as $n,getOwner as jn,setOwner as N,signal as U,untrack as en}from"@firsthandjs/core";function he(n,t,e){let o=nn(jn()),r=new Map;return()=>{let i=n(),s=new Map,l=[];return Tn(()=>{for(let d=0;d<i.length;d++){let c=i[d],a=en(()=>t(c,d));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=Hn(o,c,d,e):(r.delete(a),f.item.value=c,f.index.value=d),s.set(a,f);for(let m=0;m<f.nodes.length;m++)l.push(f.nodes[m])}for(let d of r.values())$n(d.owner)}),r=s,l}}function Hn(n,t,e,o){let r=nn(n),i=U(t),s=U(e),l=N(r),d;try{d=en(()=>o(i,s)),N(l)}catch(a){throw N(l),a}let c=[];return tn(d,c),{owner:r,item:i,index:s,nodes:c}}function tn(n,t){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let e=0;e<n.length;e++)tn(n[e],t);return}if(typeof n=="object"&&typeof n.nodeType=="number"){t.push(n);return}t.push(document.createTextNode(String(n)))}}var Ln=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),on=new Set;function b(n){return`$firsthand$${n}`}function _n(n){let t=b(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 k(n,t,e,o){if(o!==void 0||!Ln.has(t)){let r=n,i=o===!0?void 0:o,s=`${b(t)}$${i===void 0?"":Object.keys(i).sort().join(",")}`,l=r[s];l!==void 0&&n.removeEventListener(t,l.handler,l.options),r[s]={handler:e,options:i},n.addEventListener(t,e,i);return}n[b(t)]=e,on.has(t)||(on.add(t),document.addEventListener(t,_n))}function ke(n,t){n[b(t)]=void 0}var Wn={class:"className",for:"htmlFor"};function P(n,t,e){e==null||e===!1?n.removeAttribute(t):n.setAttribute(t,e===!0?"":String(e))}function Se(n,t,e,o){o==null||o===!1?n.removeAttributeNS(t,e):n.setAttributeNS(t,e,o===!0?"":String(o))}function A(n,t,e){n[Wn[t]??t]=e}function Ee(n,t,e){n[t]=!!e}function sn(n,t){t==null?n.removeAttribute("class"):n.className=String(t)}function ln(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 dn(n,t){t==null?n.style.cssText="":n.style.cssText=String(t)}function un(n,t,e){let o=n.style;if(e!==void 0)for(let r in e)r in t||o.removeProperty(O(r));for(let r in t){let i=t[r];(e===void 0||e[r]!==i)&&(i==null?o.removeProperty(O(r)):o.setProperty(O(r),String(i)))}}var Dn=/[A-Z]/g,rn=new Map;function O(n){let t=rn.get(n);return t===void 0&&(t=n.startsWith("--")?n:n.replace(Dn,e=>`-${e.toLowerCase()}`),rn.set(n,t)),t}function Mn(n,t,e){if(t==="class"||t==="className"){e!==null&&typeof e=="object"?ln(n,e,an(n,"class",e)):sn(n,e);return}if(t==="style"){e!==null&&typeof e=="object"?un(n,e,an(n,"style",e)):dn(n,e);return}if(t==="ref"){e(n);return}if(t.startsWith("prop:")){A(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])){In(n,t,e);return}if(t in n&&typeof e!="string"){A(n,t,e);return}P(n,t,e)}function In(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?k(n,i,e):s==="native"?k(n,i,e,!0):k(n,i,e,{[s]:!0})}function Oe(n,t){for(let e in t)e!=="children"&&Mn(n,e,t[e])}function Pe(...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 Ae(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 cn=new WeakMap;function an(n,t,e){let o=cn.get(n);o===void 0&&(o={},cn.set(n,o));let r=o[t];return o[t]=e,r}export{Vn as a,E as b,qn as c,M as d,Xn as e,R as f,V as g,Jn as h,Qn as i,Un as j,ne as k,ee as l,F as m,p as n,kn as o,G as p,X as q,ue as r,ce as s,ae as t,fe as u,Rn as v,Nn as w,he as x,k as y,ke as z,P as A,Se as B,A as C,Ee as D,sn as E,ln as F,dn as G,un as H,Mn as I,Oe as J,Pe as K,Ae as L};