@firsthandjs/dom 0.9.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
- import{p as d,q as i}from"./chunk-NNHZJMZS.js";import{createRoot as r,onCleanup as s,untrack as u}from"@firsthandjs/core";function y(o,e=document.body){return f(o,e,null)}function f(o,e,l){let t;return r(n=>{t=n;let p=()=>{c(e,u(o),l!==null)};l===null?p():l(p)}),t}function c(o,e,l){if(typeof e=="function"){d(o,e);return}let t=null;if(l){let n=[...o.childNodes];t=n.length===1?n[0]:n}t=i(o,null,t,e),s(()=>{i(o,null,t,null)})}export{y as a,f as b};
1
+ import{r as d,s as i}from"./chunk-P4PXTIUD.js";import{createRoot as r,onCleanup as s,untrack as u}from"@firsthandjs/core";function y(o,e=document.body){return f(o,e,null)}function f(o,e,l){let t;return r(n=>{t=n;let p=()=>{c(e,u(o),l!==null)};l===null?p():l(p)}),t}function c(o,e,l){if(typeof e=="function"){d(o,e);return}let t=null;if(l){let n=[...o.childNodes];t=n.length===1?n[0]:n}t=i(o,null,t,e),s(()=>{i(o,null,t,null)})}export{y as a,f as b};
@@ -0,0 +1 @@
1
+ import{b as S,e as T,f as A,g as N,h as g,i as j,s as L,t as H}from"./chunk-P4PXTIUD.js";var C=null,E=new WeakMap;function $n(n){C=n,E=new WeakMap}var R=class extends Error{constructor(e){super(`${e} 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 M(n){let e=E.get(n);if(e!==void 0)return e;if(C===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new R(o)}let t=C(n);return E.set(n,t),t}import{signal as un,createOwner as D,devEnterSetup as V,devExitSetup as y,disposeOwner as ln,getOwner as F,handleError as W,setOwner as w,untrack as I}from"@firsthandjs/core";var z=Symbol.for("firsthand.component"),K=Symbol.for("firsthand.view"),an=0,Z="firsthand";function Mn(n){Z=n}function Dn(n,e,t,o){let s=Object.assign(i=>fn(s,i),{[z]:!0,setup:n,options:e,id:t??`c${String(++an)}`,tag:void 0});return Object.defineProperty(s,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),t===void 0&&(`${s.name}`,void 0),(e?.tag!==void 0||e?.shadow===!0)&&mn(s,typeof e.tag=="string"?e.tag:void 0),s}function Vn(n){return typeof n=="function"&&z in n}function Fn(n){return n[K]=!0,n}function fn(n,e){if(Object.freeze(e),n.setup===void 0)return K in n?g(()=>n(e)):M(n)(e);if(n.tag!==void 0)return yn(n,e);let t=D(F());n.name;let o=w(t);try{V(n.id);let r=I(()=>n.setup(e));return y(),w(o),r}catch(r){return y(),w(o),W(r,t),null}}function pn(n){let e=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${Z}-${e}`}function mn(n,e){let t=n;if(t.tag!==void 0)return t.tag;let o=e??pn(t);return customElements.get(o)!==void 0&&(o=`${o}-${t.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),t.tag=o,customElements.define(o,wn(t)),o}function wn(n){let e=n.options?.shadow===!0,t=n.options?.attributes,o=t!==void 0?Object.keys(t):[];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=gn(this,t,this.$attrs),q(this,n,e))}disconnectedCallback(){!this.$standalone||this.$owner===null||(ln(this.$owner),this.$owner=null)}attributeChangedCallback(s,i,u){let l=this.$attrs?.[s];l!==void 0&&(l.value=t[s]?.(u))}}}function gn(n,e,t){let o={};if(e!==void 0)for(let r in e){let s=un(e[r](n.getAttribute(r)));t[r]=s,Object.defineProperty(o,r,{enumerable:!0,get:()=>s.value})}return Object.freeze(o)}function q(n,e,t){let o=D(F());e.name,n.$owner=o;let r=w(o);try{V(e.id);let s=t?n.attachShadow({mode:"open"}):n,i=I(()=>e.setup(n.$props));y(),L(s,null,null,i)}catch(s){y(),W(s,o)}finally{w(r)}}function yn(n,e){let t=document.createElement(n.tag);return t.$props=e,q(t,n,n.options?.shadow===!0),t}import{batch as hn,createOwner as J,disposeOwner as bn,getOwner as kn,setOwner as B,signal as G,untrack as Q}from"@firsthandjs/core";function Gn(n,e,t){let o=J(kn()),r=new Map,s,i=!1;return()=>{let u=n();if(i&&s!==void 0){s.length=0;for(let d of r.values())for(let f of d.pieces===void 0?d.nodes:Y(d))s.push(f)}let l=new Map,a=[];a[A]=!0;let m;if(Q(()=>{hn(()=>{cn()})}),r=l,s=a,m!==void 0){let d=m;a[N]=f=>{for(let p of d)_(p,f)}}return a;function cn(){for(let d=0;d<u.length;d++){let f=u[d],p=e(f,d);if(l.has(p)){`${String(p)}`;continue}let c=r.get(p);c===void 0?(c=Cn(o,f,d,t),c.pieces!==void 0&&(i=!0,_(c,null)||(m=m===void 0?[c]:[...m,c]))):(r.delete(p),c.item.value=f,c.index.value=d),l.set(p,c);let $=c.pieces===void 0?c.nodes:Y(c);for(let k=0;k<$.length;k++)a.push($[k])}T(()=>{for(let d of r.values())bn(d.owner)})}}}function U(n){return typeof n.nodeType=="number"}function _(n,e){let t=n.pieces;for(let o of t){if(U(o))continue;let r=e??S.current?.place(o.child.anchor)??null;if(r===null)return!1;H(o.child,r,s=>{o.nodes=s})}return!0}function Y(n){let e=[];for(let t of n.pieces)if(U(t))e.push(t);else for(let o of t.nodes)e.push(o);return e}function Cn(n,e,t,o){let r=J(n),s=G(e),i=G(t),u=B(r),l=[],a;try{a=X(Q(()=>o(s,i)),l)}finally{B(u)}return a?{owner:r,item:s,index:i,nodes:[],pieces:l}:{owner:r,item:s,index:i,nodes:l}}function X(n,e){if(n==null||typeof n=="boolean")return!1;if(Array.isArray(n)){let t=!1;for(let o=0;o<n.length;o++)t=X(n[o],e)||t;return t}if(typeof n=="function"){let t=g(n);return e.push({child:t,nodes:[t.anchor]}),!0}if(typeof n=="object"){if(j(n))return e.push({child:n,nodes:[n.anchor]}),!0;if(typeof n.nodeType=="number")return e.push(n),!1}return e.push(document.createTextNode(String(n))),!1}var En=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),nn=new Set;function h(n){return`$firsthand$${n}`}function Rn(n){let e=h(n.type),t=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<t.length;r++){let s=t[r],i=s[e];if(i!==void 0&&(o=s,i.call(s,n),n.cancelBubble)||s===document)break}o=null}function b(n,e,t,o){if(o!==void 0||!En.has(e)){let r=n,s=o===!0?void 0:o,i=`${h(e)}$${s===void 0?"":Object.keys(s).sort().join(",")}`,u=r[i];u!==void 0&&n.removeEventListener(e,u.handler,u.options),r[i]={handler:t,options:s},n.addEventListener(e,t,s);return}n[h(e)]=t,nn.has(e)||(nn.add(e),document.addEventListener(e,Rn))}function Yn(n,e){n[h(e)]=void 0}var Pn={class:"className",for:"htmlFor"};function x(n,e,t){t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,t===!0?"":String(t))}function Xn(n,e,t,o){o==null||o===!1?n.removeAttributeNS(e,t):n.setAttributeNS(e,t,o===!0?"":String(o))}function v(n,e,t){n[Pn[e]??e]=t}function ne(n,e,t){n[e]=!!t}function O(n,e){e==null?n.removeAttribute("class"):n.className=String(e)}function tn(n,e,t){let o=n.classList;if(t!==void 0)for(let r in t)r in e||o.remove(r);for(let r in e){let s=!!e[r];(t===void 0||!!t[r]!==s)&&o.toggle(r,s)}}function on(n,e){e==null?n.style.cssText="":n.style.cssText=String(e)}function rn(n,e,t){let o=n.style;if(t!==void 0)for(let r in t)r in e||o.removeProperty(P(r));for(let r in e){let s=e[r];(t===void 0||t[r]!==s)&&(s==null?o.removeProperty(P(r)):o.setProperty(P(r),String(s)))}}var xn=/[A-Z]/g,en=new Map;function P(n){let e=en.get(n);return e===void 0&&(e=n.startsWith("--")?n:n.replace(xn,t=>`-${t.toLowerCase()}`),en.set(n,e)),e}function vn(n,e,t){if(e==="class"||e==="className"){Array.isArray(t)?O(n,t.filter(Boolean).join(" ")):t!==null&&typeof t=="object"?tn(n,t,dn(n,"class",t)):O(n,t);return}if(e==="style"){t!==null&&typeof t=="object"?rn(n,t,dn(n,"style",t)):on(n,t);return}if(e==="ref"){t(n);return}if(e.startsWith("prop:")){v(n,e.slice(5),t);return}if(e.startsWith("attr:")){x(n,e.slice(5),t);return}if(e.startsWith("on")&&e.length>2&&/[A-Z:]/.test(e[2])){On(n,e,t);return}if(e in n&&typeof t!="string"){v(n,e,t);return}x(n,e,t)}function On(n,e,t){let o=e.slice(2).split(":"),r=o[0]==="",s=r?o[1]:o[0].toLowerCase(),i=o[r?2:1];i===void 0?b(n,s,t):i==="native"?b(n,s,t,!0):b(n,s,t,{[i]:!0})}function re(n,e){for(let t in e)t!=="children"&&vn(n,t,e[t])}function se(...n){let e={};for(let t=0;t<n.length;t++){let o=n[t];for(let r of Object.keys(o))Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return e}function ie(n,e){let t={};for(let o of Object.keys(n))e.includes(o)||Object.defineProperty(t,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(t)}var sn=new WeakMap;function dn(n,e,t){let o=sn.get(n);o===void 0&&(o={},sn.set(n,o));let r=o[e];return o[e]=t,r}export{$n as a,R as b,z as c,K as d,Mn as e,Dn as f,Vn as g,Fn as h,fn as i,mn as j,Gn as k,b as l,Yn as m,x as n,Xn as o,v as p,ne as q,O as r,tn as s,on as t,rn as u,vn as v,re as w,se as x,ie as y};
@@ -0,0 +1 @@
1
+ function Q(n,i,e){return n}var a={current:null};function V(n){let i=n.firstChild,e=a.current;return e===null?i:e.step(i)}function Y(n){let i=n.nextSibling,e=a.current;return e===null?i:e.step(i)}import{bind as v,createOwner as B,signal as H,disposeOwner as G,getOwner as A,onCleanup as k,runWithOwner as E,setOwner as I}from"@firsthandjs/core";var S=0;function dn(n){S++;try{n()}finally{S--}}var M=3;function P(n){return typeof n.nodeType=="number"}var W=Symbol("firsthand.part"),L=Symbol("firsthand.flat"),X=Symbol("firsthand.pending"),w=new WeakSet;function sn(n){return{[W]:!0,anchor:document.createTextNode(""),thunk:n,owner:A()}}function T(n){return W in n}function un(n=""){return{slots:[],owner:A(),generation:0,name:n}}function C(n){n.busy=!0}function q(n,i){let e=n.slots[i];if(e!==void 0)return e.seen=n.generation,e;let o={seen:n.generation};return n.slots[i]=o,o}function fn(n,i){let e=B(n.owner);return i.owner=e,I(e)}function cn(n){I(n)}function an(n,i){let e=n.generation,o=n.slots;for(let t=0;t<o.length;t++){let l=o[t];l===void 0||l.seen===e||(l.owner!==void 0&&G(l.owner),o[t]=void 0)}return n.generation=e+1,i}function yn(n,i,e){let o=q(n,i),t=o.cell;if(t===void 0){let l=H(e);return o.cell=l,l}return t.peek()!==e&&(C(n),t.value=e),t}function hn(n,i,e,o,t){let l=q(n,i);if(l.node===void 0&&a.current!==null){let r=a.current.claim(e,o);if(r!==null){if(typeof t=="object"&&t!==null&&T(t)){l.last=t,a.current.keep(l,e,t.anchor,r),E(t.owner,()=>{m(e,t.thunk,t.anchor)});return}l.node=r.nodes,l.text=r.text}}let d=typeof t;if(d==="string"||d==="number"){let r=String(t);if(r===l.text)return;C(n),l.text=r,l.node=h(e,o,l.node??null,r);return}l.text=void 0,t!==l.last&&(C(n),l.last=t,l.node=h(e,o,l.node??null,t))}function m(n,i,e=null,o,t){if(typeof i!="function"){h(n,e,null,i);return}let l=null,d,r=o!==void 0?o:a.current===null?null:a.current.claim(n,e),u=r!==null;r!==null&&(l=r.nodes,d=r.text);let f=()=>{c(),t?.(z(l,e))},c=()=>{let y=i(),g=typeof y;if(g==="string"||g==="number"){let p=String(y);p!==d&&(d=p,l=h(n,e,l,p));return}if(d=void 0,g==="function"){if(u){l=null,m(n,y,e,r);return}l=x(l),m(n,y,e,null);return}l=h(n,e,l,y)};r===null?v(f):a.current.within(r.region,()=>{v(f)}),u=!1,k(()=>{l=S>0?null:x(l)})}function z(n,i){let e=n===null?[]:Array.isArray(n)?[...n]:[n];return e.push(i),e}function h(n,i,e,o){let t=typeof o;if(o==null||t==="boolean")return b(n,i,e);if(t==="string"||t==="number"){let l=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===M?(e.data=l,e):D(n,i,e,document.createTextNode(l))}if(t==="function")return h(n,i,e,o());if(Array.isArray(o)){if(L in o){let r=o;return r.length===0?b(n,i,e):(R(n,i,e===null?[]:Array.isArray(e)?e:[e],r),o[X]?.(n),r)}let l=[],d=[];if(F(o,l,d),l.length===0)return b(n,i,e);R(n,i,e===null?[]:Array.isArray(e)?e:[e],l);for(let r=0;r<d.length;r++)J(d[r],n);return l}return T(o)?h(n,i,e,[o]):P(o)?D(n,i,e,o):h(n,i,e,String(o))}function J(n,i,e){w.has(n)||(w.add(n),E(n.owner??A(),()=>{m(i,n.thunk,n.anchor,void 0,e),k(()=>{w.delete(n)})}))}function F(n,i,e){for(let o=0;o<n.length;o++){let t=n[o];if(typeof t=="object"&&t!==null&&T(t)){i.push(t.anchor),e.push(t);continue}for(;typeof t=="function";)t=t();t==null||typeof t=="boolean"||(Array.isArray(t)?F(t,i,e):typeof t=="object"&&P(t)?i.push(t):i.push(document.createTextNode(String(t))))}}function j(n){let i=n.parentNode;i!==null&&i.removeChild(n)}function b(n,i,e){return i===null&&Array.isArray(e)&&e.length>1&&n.childNodes.length===e.length?(n.textContent="",null):x(e)}function x(n){if(n!==null)if(Array.isArray(n))for(let i=0;i<n.length;i++)j(n[i]);else j(n);return null}function D(n,i,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(x(e),n.insertBefore(o,i),o)}function R(n,i,e,o){let t=0,l=0,d=e.length-1,r=o.length-1;for(;t<=d&&l<=r&&e[t]===o[l];)t++,l++;for(;t<=d&&l<=r&&e[d]===o[r];)d--,r--;let u=r+1<o.length?o[r+1]:i;if(t>d){for(let s=l;s<=r;s++)n.insertBefore(o[s],u);return}if(l>r){for(let s=t;s<=d;s++)n.removeChild(e[s]);return}let f=new Map;for(let s=t;s<=d;s++)f.set(e[s],s);let c=r-l+1,y=new Int32Array(c).fill(-1);for(let s=0;s<c;s++){let N=o[l+s],_=f.get(N);_!==void 0&&(y[s]=_,f.delete(N))}for(let s of f.keys())n.removeChild(s);let g=K(y),p=g.length-1,O=u;for(let s=c-1;s>=0;s--){let N=o[l+s];p>=0&&g[p]===s?p--:n.insertBefore(N,O),O=N}}function K(n){let i=n.length,e=new Int32Array(i).fill(-1),o=[];for(let d=0;d<i;d++){let r=n[d];if(r===-1)continue;let u=0,f=o.length;for(;u<f;){let c=u+f>>1;n[o[c]]<r?u=c+1:f=c}u>0&&(e[d]=o[u-1]),o[u]=d}let t=[],l=o.length>0?o[o.length-1]:-1;for(;l!==-1;)t.push(l),l=e[l];return t.reverse()}export{Q as a,a as b,V as c,Y as d,dn as e,L as f,X as g,sn as h,T as i,un as j,C as k,q as l,fn as m,cn as n,an as o,yn as p,hn as q,m as r,h as s,J as t,R as u};
package/dist/claim.d.ts CHANGED
@@ -53,6 +53,16 @@ export type Claimer = {
53
53
  within<T>(region: Region, body: () => T): T;
54
54
  /** A step through the template that goes over a whole region at a time. */
55
55
  step(node: Node): Node;
56
+ /**
57
+ * Puts `anchor` where hydration has got to, and says what it went into.
58
+ *
59
+ * What a keyed list needs to adopt a row that is a view: the row has
60
+ * nothing of its own until it runs, and it has to run where its markup is,
61
+ * in the order the rows come in — not after the list has decided what goes
62
+ * where. Null when the region is used up, which is a list with more rows
63
+ * than the server sent: those are built.
64
+ */
65
+ place(anchor: Node): Node | null;
56
66
  };
57
67
  /**
58
68
  * The installed claimer, or nothing.
@@ -1 +1 @@
1
- {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,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AG,IAAI,CAAC;IACzD,uEAAuE;IACvE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C,2EAA2E;IAC3E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE;IAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAsB,CAAC;AAExE;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAItC;AAED,2EAA2E;AAC3E,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAIrC"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  applyChild,
3
3
  insert
4
- } from "./dev-chunk-HTXIHAW7.js";
4
+ } from "./dev-chunk-ADHDPKZW.js";
5
5
 
6
6
  // packages/dom/src/render.ts
7
7
  import { createRoot, onCleanup, untrack } from "@firsthandjs/core";
@@ -117,6 +117,8 @@ function isNode(value) {
117
117
  }
118
118
  var PART = /* @__PURE__ */ Symbol("firsthand.part");
119
119
  var FLAT = /* @__PURE__ */ Symbol("firsthand.flat");
120
+ var PENDING = /* @__PURE__ */ Symbol("firsthand.pending");
121
+ var mounted = /* @__PURE__ */ new WeakSet();
120
122
  function part(thunk) {
121
123
  return { [PART]: true, anchor: document.createTextNode(""), thunk, owner: getOwner() };
122
124
  }
@@ -215,7 +217,7 @@ function writeChild(store2, index, parent, marker, value) {
215
217
  slot.last = value;
216
218
  slot.node = applyChild(parent, marker, slot.node ?? null, value);
217
219
  }
218
- function insert(parent, value, marker = null, seed) {
220
+ function insert(parent, value, marker = null, seed, report) {
219
221
  if (typeof value !== "function") {
220
222
  applyChild(parent, marker, null, value);
221
223
  return;
@@ -229,6 +231,10 @@ function insert(parent, value, marker = null, seed) {
229
231
  written = claimed.text;
230
232
  }
231
233
  const body = () => {
234
+ run();
235
+ report?.(nodesOf(current, marker));
236
+ };
237
+ const run = () => {
232
238
  const next2 = value();
233
239
  const type = typeof next2;
234
240
  if (type === "string" || type === "number") {
@@ -264,6 +270,11 @@ function insert(parent, value, marker = null, seed) {
264
270
  current = discarding > 0 ? null : clear(current);
265
271
  });
266
272
  }
273
+ function nodesOf(current, anchor) {
274
+ const nodes = current === null ? [] : Array.isArray(current) ? [...current] : [current];
275
+ nodes.push(anchor);
276
+ return nodes;
277
+ }
267
278
  function applyChild(parent, marker, current, value) {
268
279
  const type = typeof value;
269
280
  if (value == null || type === "boolean") {
@@ -294,6 +305,7 @@ function applyChild(parent, marker, current, value) {
294
305
  current === null ? [] : Array.isArray(current) ? current : [current],
295
306
  rows
296
307
  );
308
+ value[PENDING]?.(parent);
297
309
  return rows;
298
310
  }
299
311
  const next2 = [];
@@ -309,10 +321,7 @@ function applyChild(parent, marker, current, value) {
309
321
  next2
310
322
  );
311
323
  for (let i = 0; i < dynamic.length; i++) {
312
- const child = dynamic[i];
313
- runWithOwner(child.owner ?? getOwner(), () => {
314
- insert(parent, child.thunk, child.anchor);
315
- });
324
+ bindPart(dynamic[i], parent);
316
325
  }
317
326
  return next2;
318
327
  }
@@ -325,6 +334,18 @@ function applyChild(parent, marker, current, value) {
325
334
  devWarnRenderedObject(value);
326
335
  return applyChild(parent, marker, current, String(value));
327
336
  }
337
+ function bindPart(child, parent, report) {
338
+ if (mounted.has(child)) {
339
+ return;
340
+ }
341
+ mounted.add(child);
342
+ runWithOwner(child.owner ?? getOwner(), () => {
343
+ insert(parent, child.thunk, child.anchor, void 0, report);
344
+ onCleanup(() => {
345
+ mounted.delete(child);
346
+ });
347
+ });
348
+ }
328
349
  function flatten(value, out, dynamic) {
329
350
  for (let i = 0; i < value.length; i++) {
330
351
  let item = value[i];
@@ -486,7 +507,9 @@ export {
486
507
  next,
487
508
  discard,
488
509
  FLAT,
510
+ PENDING,
489
511
  part,
512
+ isDynamicChild,
490
513
  store,
491
514
  wrote,
492
515
  site,
@@ -497,5 +520,6 @@ export {
497
520
  writeChild,
498
521
  insert,
499
522
  applyChild,
523
+ bindPart,
500
524
  reconcile
501
525
  };
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  FLAT,
3
+ PENDING,
3
4
  applyChild,
5
+ bindPart,
4
6
  devComponent,
5
7
  devPart,
6
8
  devWarn,
7
9
  devWarnOnce,
8
10
  discard,
11
+ hydration,
12
+ isDynamicChild,
9
13
  part
10
- } from "./dev-chunk-HTXIHAW7.js";
14
+ } from "./dev-chunk-ADHDPKZW.js";
11
15
 
12
16
  // packages/dom/src/adapter.ts
13
17
  var adapter = null;
@@ -226,17 +230,37 @@ import {
226
230
  function list(each, keyOf, render) {
227
231
  const host = createOwner2(getOwner2());
228
232
  let rows = /* @__PURE__ */ new Map();
233
+ let placed;
234
+ let views = false;
229
235
  return () => {
230
236
  const items = each();
237
+ if (views && placed !== void 0) {
238
+ placed.length = 0;
239
+ for (const row of rows.values()) {
240
+ for (const node of row.pieces === void 0 ? row.nodes : nodesOf(row)) {
241
+ placed.push(node);
242
+ }
243
+ }
244
+ }
231
245
  const next = /* @__PURE__ */ new Map();
232
246
  const nodes = [];
233
247
  nodes[FLAT] = true;
248
+ let pending;
234
249
  untrack2(() => {
235
250
  batch(() => {
236
251
  buildRows();
237
252
  });
238
253
  });
239
254
  rows = next;
255
+ placed = nodes;
256
+ if (pending !== void 0) {
257
+ const made = pending;
258
+ nodes[PENDING] = (parent) => {
259
+ for (const row of made) {
260
+ bindRow(row, parent);
261
+ }
262
+ };
263
+ }
240
264
  return nodes;
241
265
  function buildRows() {
242
266
  for (let i = 0; i < items.length; i++) {
@@ -251,14 +275,21 @@ function list(each, keyOf, render) {
251
275
  let row = rows.get(key2);
252
276
  if (row === void 0) {
253
277
  row = createRow(host, item, i, render);
278
+ if (row.pieces !== void 0) {
279
+ views = true;
280
+ if (!bindRow(row, null)) {
281
+ pending = pending === void 0 ? [row] : [...pending, row];
282
+ }
283
+ }
254
284
  } else {
255
285
  rows.delete(key2);
256
286
  row.item.value = item;
257
287
  row.index.value = i;
258
288
  }
259
289
  next.set(key2, row);
260
- for (let n = 0; n < row.nodes.length; n++) {
261
- nodes.push(row.nodes[n]);
290
+ const found = row.pieces === void 0 ? row.nodes : nodesOf(row);
291
+ for (let n = 0; n < found.length; n++) {
292
+ nodes.push(found[n]);
262
293
  }
263
294
  }
264
295
  discard(() => {
@@ -269,38 +300,83 @@ function list(each, keyOf, render) {
269
300
  }
270
301
  };
271
302
  }
303
+ function isNode(piece) {
304
+ return typeof piece.nodeType === "number";
305
+ }
306
+ function bindRow(row, into) {
307
+ const pieces = row.pieces;
308
+ for (const piece of pieces) {
309
+ if (isNode(piece)) {
310
+ continue;
311
+ }
312
+ const parent = into ?? hydration.current?.place(piece.child.anchor) ?? null;
313
+ if (parent === null) {
314
+ return false;
315
+ }
316
+ bindPart(piece.child, parent, (found) => {
317
+ piece.nodes = found;
318
+ });
319
+ }
320
+ return true;
321
+ }
322
+ function nodesOf(row) {
323
+ const nodes = [];
324
+ for (const piece of row.pieces) {
325
+ if (isNode(piece)) {
326
+ nodes.push(piece);
327
+ } else {
328
+ for (const node of piece.nodes) {
329
+ nodes.push(node);
330
+ }
331
+ }
332
+ }
333
+ return nodes;
334
+ }
272
335
  function createRow(host, item, index, render) {
273
336
  const owner = createOwner2(host);
274
337
  const itemCell = signal2(item);
275
338
  const indexCell = signal2(index);
276
339
  const previous = setOwner2(owner);
277
- let result;
340
+ const pieces = [];
341
+ let parts;
278
342
  try {
279
- result = untrack2(() => render(itemCell, indexCell));
280
- setOwner2(previous);
281
- } catch (error) {
343
+ parts = collect(
344
+ untrack2(() => render(itemCell, indexCell)),
345
+ pieces
346
+ );
347
+ } finally {
282
348
  setOwner2(previous);
283
- throw error;
284
349
  }
285
- const nodes = [];
286
- collect(result, nodes);
287
- return { owner, item: itemCell, index: indexCell, nodes };
350
+ return parts ? { owner, item: itemCell, index: indexCell, nodes: [], pieces } : { owner, item: itemCell, index: indexCell, nodes: pieces };
288
351
  }
289
352
  function collect(value, out) {
290
353
  if (value == null || typeof value === "boolean") {
291
- return;
354
+ return false;
292
355
  }
293
356
  if (Array.isArray(value)) {
357
+ let parts = false;
294
358
  for (let i = 0; i < value.length; i++) {
295
- collect(value[i], out);
359
+ parts = collect(value[i], out) || parts;
296
360
  }
297
- return;
361
+ return parts;
298
362
  }
299
- if (typeof value === "object" && typeof value.nodeType === "number") {
300
- out.push(value);
301
- return;
363
+ if (typeof value === "function") {
364
+ const child = part(value);
365
+ out.push({ child, nodes: [child.anchor] });
366
+ return true;
367
+ }
368
+ if (typeof value === "object") {
369
+ if (isDynamicChild(value)) {
370
+ out.push({ child: value, nodes: [value.anchor] });
371
+ return true;
372
+ }
373
+ if (typeof value.nodeType === "number") {
374
+ out.push(value);
375
+ return false;
376
+ }
302
377
  }
303
378
  out.push(document.createTextNode(String(value)));
379
+ return false;
304
380
  }
305
381
 
306
382
  // packages/dom/src/events.ts
package/dist/hydrate.d.ts CHANGED
@@ -86,6 +86,17 @@ export declare function adopt(tag: string): Node | null;
86
86
  * and the caller renders it from nothing instead.
87
87
  */
88
88
  export declare function claimRegion(parent: Node, marker: Node | null): Claimed | null;
89
+ /**
90
+ * Puts an anchor where hydration has got to, and hands back its parent.
91
+ *
92
+ * A keyed list's row that is a view is bound here rather than with the rest,
93
+ * because by then the reconciler would have put the list's anchors where the
94
+ * server's rows are and taken the rows out. The anchor goes in at the point
95
+ * the region has reached, and the row runs there — which adopts the nodes the
96
+ * server sent for it, in row order, because that is the order the markup is
97
+ * in.
98
+ */
99
+ export declare function place(anchor: Node): Node | null;
89
100
  /** Makes `region` the one nodes are adopted from while `body` runs. */
90
101
  export declare function within<T>(region: Region, body: () => T): T;
91
102
  //# sourceMappingURL=hydrate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hyd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;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,CAIxF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAgBhE;AAaD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAW9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAqD7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAK/C;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ1D"}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  mount
3
- } from "./dev-chunk-5QV3XALZ.js";
3
+ } from "./dev-chunk-6V32MCOI.js";
4
4
  import {
5
5
  hydration
6
- } from "./dev-chunk-HTXIHAW7.js";
6
+ } from "./dev-chunk-ADHDPKZW.js";
7
7
 
8
8
  // packages/dom/src/hydrate.ts
9
9
  var COMMENT_NODE = 8;
@@ -103,6 +103,12 @@ function claimRegion(parent, marker) {
103
103
  region: { node: start, end }
104
104
  };
105
105
  }
106
+ function place(anchor) {
107
+ const node = claim === null ? null : claim.node;
108
+ const parent = node?.parentNode ?? null;
109
+ parent?.insertBefore(anchor, node);
110
+ return parent;
111
+ }
106
112
  function within(region, body) {
107
113
  const outer = claim;
108
114
  claim = region;
@@ -143,11 +149,12 @@ function keep(slot, parent, anchor, claimed) {
143
149
  slot.node = claimed.nodes === null ? anchor : [...Array.isArray(claimed.nodes) ? claimed.nodes : [claimed.nodes], anchor];
144
150
  offers.set(anchor, claimed);
145
151
  }
146
- var claimer = { tag: tagOf, adopt, claim: claimRegion, within, keep, step };
152
+ var claimer = { tag: tagOf, adopt, claim: claimRegion, within, keep, step, place };
147
153
  export {
148
154
  adopt,
149
155
  claimRegion,
150
156
  hydrate,
151
157
  hydrateWith,
158
+ place,
152
159
  within
153
160
  };
package/dist/hydrate.js CHANGED
@@ -1 +1 @@
1
- import{b as x}from"./chunk-26MSEGYG.js";import{b as a}from"./chunk-NNHZJMZS.js";var m=8,C=3,w="[",i=null,p=0,g=new WeakMap,c=[],N=new Map;function F(e,n=document.body){return x(e,n,l=>{M(n,l)})}function M(e,n){let l=i,o=p;p++,a.current=V,i={node:e.firstChild,end:null};try{return n()}finally{i=l,p=o,p===0&&(a.current=null,O())}}function O(){for(let e=0;e<c.length;e++){let n=c[e];n.parentNode?.removeChild(n)}c=[],g=new WeakMap,N=new Map}function S(e){if(i===null)return null;let n=i.node;if(n===null||n.nodeName!==e)return null;let l=n.nextSibling;return i.node=l===i.end?null:l,n}function v(e,n){if(n!==null){let r=N.get(n);if(r!==void 0)return N.delete(n),r}let l=g.get(e),o=l===void 0,h=o?e.firstChild:l,d,u,T=o?n:null,t=h;for(;t!==null&&t!==T&&!y(t);)t=t.nextSibling;if(t!==null&&t!==T){if(u=b(t),n!==null&&n!==u)return null;c.push(t),d=t.nextSibling}else if(o)d=h,u=n;else return null;g.set(e,u===null?null:u.nextSibling),d===u&&(d=null);let s=[];for(let r=d;r!==null&&r!==u;r=r.nextSibling)s.push(r);let f=s.length===1?s[0]:null;return{nodes:s.length===0?null:f??s,text:f!==null&&f.nodeType===C?f.data:void 0,region:{node:d,end:u}}}function E(e,n){let l=i;i=e;try{return n()}finally{i=l}}function y(e){return e!==null&&e.nodeType===m&&e.nodeValue===w}function b(e){let n=0;for(let l=e.nextSibling;l!==null;l=l.nextSibling)if(l.nodeType===m){if(y(l)){n++;continue}if(n===0)return l;n--}return null}function D(e){return y(e)?b(e):e}function R(e){return e.slice(1,e.search(/[\s/>]/)).toUpperCase()}function W(e,n,l,o){n.insertBefore(l,o.region.end),e.node=o.nodes===null?l:[...Array.isArray(o.nodes)?o.nodes:[o.nodes],l],N.set(l,o)}var V={tag:R,adopt:S,claim:v,within:E,keep:W,step:D};export{S as adopt,v as claimRegion,F as hydrate,M as hydrateWith,E as within};
1
+ import{b as T}from"./chunk-6BRSYQCI.js";import{b as a}from"./chunk-P4PXTIUD.js";var m=8,C=3,w="[",t=null,p=0,g=new WeakMap,c=[],N=new Map;function F(e,n=document.body){return T(e,n,o=>{M(n,o)})}function M(e,n){let o=t,l=p;p++,a.current=j,t={node:e.firstChild,end:null};try{return n()}finally{t=o,p=l,p===0&&(a.current=null,O())}}function O(){for(let e=0;e<c.length;e++){let n=c[e];n.parentNode?.removeChild(n)}c=[],g=new WeakMap,N=new Map}function S(e){if(t===null)return null;let n=t.node;if(n===null||n.nodeName!==e)return null;let o=n.nextSibling;return t.node=o===t.end?null:o,n}function v(e,n){if(n!==null){let r=N.get(n);if(r!==void 0)return N.delete(n),r}let o=g.get(e),l=o===void 0,h=l?e.firstChild:o,d,u,x=l?n:null,i=h;for(;i!==null&&i!==x&&!y(i);)i=i.nextSibling;if(i!==null&&i!==x){if(u=b(i),n!==null&&n!==u)return null;c.push(i),d=i.nextSibling}else if(l)d=h,u=n;else return null;g.set(e,u===null?null:u.nextSibling),d===u&&(d=null);let s=[];for(let r=d;r!==null&&r!==u;r=r.nextSibling)s.push(r);let f=s.length===1?s[0]:null;return{nodes:s.length===0?null:f??s,text:f!==null&&f.nodeType===C?f.data:void 0,region:{node:d,end:u}}}function E(e){let n=t===null?null:t.node,o=n?.parentNode??null;return o?.insertBefore(e,n),o}function D(e,n){let o=t;t=e;try{return n()}finally{t=o}}function y(e){return e!==null&&e.nodeType===m&&e.nodeValue===w}function b(e){let n=0;for(let o=e.nextSibling;o!==null;o=o.nextSibling)if(o.nodeType===m){if(y(o)){n++;continue}if(n===0)return o;n--}return null}function R(e){return y(e)?b(e):e}function W(e){return e.slice(1,e.search(/[\s/>]/)).toUpperCase()}function V(e,n,o,l){n.insertBefore(o,l.region.end),e.node=l.nodes===null?o:[...Array.isArray(l.nodes)?l.nodes:[l.nodes],o],N.set(o,l)}var j={tag:W,adopt:S,claim:v,within:D,keep:V,step:R,place:E};export{S as adopt,v as claimRegion,F as hydrate,M as hydrateWith,E as place,D as within};
package/dist/index.dev.js CHANGED
@@ -10,11 +10,11 @@ import {
10
10
  setComponentAdapter,
11
11
  setElementPrefix,
12
12
  view
13
- } from "./dev-chunk-HCAUM4JK.js";
13
+ } from "./dev-chunk-MKONDKMD.js";
14
14
  import {
15
15
  render
16
- } from "./dev-chunk-5QV3XALZ.js";
17
- import "./dev-chunk-HTXIHAW7.js";
16
+ } from "./dev-chunk-6V32MCOI.js";
17
+ import "./dev-chunk-ADHDPKZW.js";
18
18
 
19
19
  // packages/dom/src/portal.ts
20
20
  import { onCleanup } from "@firsthandjs/core";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as i,e as f,f as s,h as a,i as m,j as l,k as x,l as C,m as h,x as y}from"./chunk-TZRPGQ3R.js";import{a as c}from"./chunk-26MSEGYG.js";import"./chunk-NNHZJMZS.js";import{onCleanup as u}from"@firsthandjs/core";function N(e,t){let o=[];p(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return u(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function p(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)p(e[o],t);return}if(typeof e=="object"&&typeof e.nodeType=="number"){t.push(e);return}t.push(document.createTextNode(String(e)))}}import{signal as D,computed as S,effect as T,batch as V,untrack as W,onCleanup as q,createRoot as z,catchError as B,runWithOwner as G,createContext as H,provide as I,useContext as J,FirsthandContextError as K,FirsthandCycleError as L,FirsthandReadonlyError as M}from"@firsthandjs/core";export{i as FirsthandComponentError,K as FirsthandContextError,L as FirsthandCycleError,M as FirsthandReadonlyError,V as batch,B as catchError,s as component,S as computed,m as createComponent,H as createContext,z as createRoot,l as defineElement,T as effect,x as list,y as mergeProps,h as off,C as on,q as onCleanup,N as portal,I as provide,c as render,G as runWithOwner,d as setComponentAdapter,f as setElementPrefix,D as signal,W as untrack,J as useContext,a as view};
1
+ import{a as d,b as i,e as f,f as s,h as a,i as m,j as l,k as x,l as C,m as h,x as y}from"./chunk-E4GAI5XA.js";import{a as c}from"./chunk-6BRSYQCI.js";import"./chunk-P4PXTIUD.js";import{onCleanup as u}from"@firsthandjs/core";function N(e,t){let o=[];p(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return u(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function p(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)p(e[o],t);return}if(typeof e=="object"&&typeof e.nodeType=="number"){t.push(e);return}t.push(document.createTextNode(String(e)))}}import{signal as D,computed as S,effect as T,batch as V,untrack as W,onCleanup as q,createRoot as z,catchError as B,runWithOwner as G,createContext as H,provide as I,useContext as J,FirsthandContextError as K,FirsthandCycleError as L,FirsthandReadonlyError as M}from"@firsthandjs/core";export{i as FirsthandComponentError,K as FirsthandContextError,L as FirsthandCycleError,M as FirsthandReadonlyError,V as batch,B as catchError,s as component,S as computed,m as createComponent,H as createContext,z as createRoot,l as defineElement,T as effect,x as list,y as mergeProps,h as off,C as on,q as onCleanup,N as portal,I as provide,c as render,G as runWithOwner,d as setComponentAdapter,f as setElementPrefix,D as signal,W as untrack,J as useContext,a as view};
package/dist/insert.d.ts CHANGED
@@ -21,6 +21,16 @@ declare const PART: unique symbol;
21
21
  * allocation and ten thousand steps for a list of ten thousand rows.
22
22
  */
23
23
  export declare const FLAT: unique symbol;
24
+ /**
25
+ * What a keyed list still has to do once its nodes are in the document.
26
+ *
27
+ * A row whose component handed back a render function is a part like any
28
+ * other, and a part cannot be bound where it is made: the list has an array,
29
+ * not a place in the document. So the list puts the row's anchor among its
30
+ * nodes and leaves the binding here, to be run with the parent that was
31
+ * missing — the same two steps `flatten` takes for a fragment's children.
32
+ */
33
+ export declare const PENDING: unique symbol;
24
34
  /**
25
35
  * A dynamic child inside an array, carrying the scope it was written in.
26
36
  *
@@ -43,6 +53,7 @@ export type DynamicChild = {
43
53
  };
44
54
  /** Marks a dynamic child of a fragment. Emitted by the compiler. */
45
55
  export declare function part(thunk: () => unknown): DynamicChild;
56
+ export declare function isDynamicChild(value: object): value is DynamicChild;
46
57
  /**
47
58
  * One place a run writes to, and what it last put there.
48
59
  *
@@ -141,9 +152,34 @@ export declare function insert(parent: Node, value: unknown, marker?: Node | nul
141
152
  * produce another part gives the markup it claimed to the part that will
142
153
  * actually own it — see the `function` branch below.
143
154
  */
144
- seed?: Claimed | null): void;
155
+ seed?: Claimed | null,
156
+ /**
157
+ * Told what this part currently has in the document, after every run.
158
+ *
159
+ * The compiler never passes this either. A keyed list needs it: a row that
160
+ * is a view owns nodes that change without the list running, and a reorder
161
+ * has to move what the row has now rather than what it had when it was
162
+ * made.
163
+ */
164
+ report?: Report): void;
165
+ /** Told what a part has in the document, when somebody needs to know. */
166
+ export type Report = (nodes: Node[]) => void;
145
167
  /** Applies one value to a child slot and returns the slot's new contents. */
146
168
  export declare function applyChild(parent: Node, marker: Node | null, current: ChildSlot, value: unknown): ChildSlot;
169
+ /**
170
+ * Binds parts whose anchors are now in the document.
171
+ *
172
+ * Each runs under the owner it was written in, which is what keeps context,
173
+ * disposal and error ownership lexical. A part created outside any scope —
174
+ * runtime JSX at module level, say — is bound under the scope doing the
175
+ * inserting, so that it is still disposed by something rather than by nothing.
176
+ *
177
+ * A part that is already mounted is left alone. A run hands back what it made
178
+ * rather than making it again, so the same part arrives here on every run of
179
+ * the run that owns it, and binding it twice would put a second copy of the
180
+ * whole child on the page beside the first.
181
+ */
182
+ export declare function bindPart(child: DynamicChild, parent: Node, report?: Report): void;
147
183
  /**
148
184
  * Reconciles two node lists in place, by node identity.
149
185
  *
@@ -1 +1 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAiB7C;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAO9C;AAQD,QAAA,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,OAAO,GAAG,YAAY,CAEvD;AAMD;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,4DAA4D;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CA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AE,IAAI,GAAG,IAAI,EACnB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAyEX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAajF;AA4FD;;;;;;;;;;;;;;;;;;;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"}
@@ -19,7 +19,7 @@ import {
19
19
  setStyleObject,
20
20
  spread,
21
21
  view
22
- } from "./dev-chunk-HCAUM4JK.js";
22
+ } from "./dev-chunk-MKONDKMD.js";
23
23
  import {
24
24
  applyChild,
25
25
  cell,
@@ -38,7 +38,7 @@ import {
38
38
  store,
39
39
  writeChild,
40
40
  wrote
41
- } from "./dev-chunk-HTXIHAW7.js";
41
+ } from "./dev-chunk-ADHDPKZW.js";
42
42
 
43
43
  // packages/dom/src/template.ts
44
44
  function template(html, isFragment = false) {
package/dist/internal.js CHANGED
@@ -1 +1 @@
1
- import{c as O,d as g,g as E,h as P,i as T,k as w,l as L,m as M,n as j,o as v,p as A,q as F,r as H,s as I,t as R,u as V,v as B,w as D,x as W,y as _}from"./chunk-TZRPGQ3R.js";import{a as p,b as i,c as s,d as a,g as d,h as m,i as f,j as c,k as u,l as x,m as y,n as C,o as N,p as h,q as b,r as S}from"./chunk-NNHZJMZS.js";function k(n,l=!1){let t,o;return()=>{let r=i.current;if(r!==null){o??=r.tag(n);let e=r.adopt(o);if(e!==null)return e}if(t===void 0){let e=document.createElement("template");e.innerHTML=n,t=l?e.content:e.content.firstChild}return t.cloneNode(!0)}}function q(n,...l){let t=n;for(let o=0;o<l.length;o++){let r=t.firstChild;for(let e=l[o];e>0;e--)r=r.nextSibling;t=r}return t}import{bind as oe}from"@firsthandjs/core";var Q=1;export{O as COMPONENT,Q as PROTOCOL_VERSION,g as VIEW,b as applyChild,B as applyProp,oe as bind,C as cell,x as close,T as createComponent,s as first,h as insert,E as isComponent,p as label,w as list,W as mergeProps,a as next,M as off,L as on,u as open,d as part,q as path,y as ran,S as reconcile,_ as rest,j as setAttribute,v as setAttributeNS,F as setBoolean,H as setClass,I as setClassList,A as setProperty,R as setStyle,V as setStyleObject,c as site,D as spread,m as store,k as template,P as view,N as writeChild,f as wrote};
1
+ import{c as O,d as g,g as E,h as P,i as T,k as w,l as L,m as M,n as j,o as v,p as A,q as F,r as H,s as I,t as R,u as V,v as B,w as D,x as W,y as _}from"./chunk-E4GAI5XA.js";import{a as p,b as i,c as s,d as a,h as d,j as m,k as f,l as c,m as u,n as x,o as y,p as C,q as N,r as h,s as b,u as S}from"./chunk-P4PXTIUD.js";function k(n,l=!1){let t,o;return()=>{let r=i.current;if(r!==null){o??=r.tag(n);let e=r.adopt(o);if(e!==null)return e}if(t===void 0){let e=document.createElement("template");e.innerHTML=n,t=l?e.content:e.content.firstChild}return t.cloneNode(!0)}}function q(n,...l){let t=n;for(let o=0;o<l.length;o++){let r=t.firstChild;for(let e=l[o];e>0;e--)r=r.nextSibling;t=r}return t}import{bind as oe}from"@firsthandjs/core";var Q=1;export{O as COMPONENT,Q as PROTOCOL_VERSION,g as VIEW,b as applyChild,B as applyProp,oe as bind,C as cell,x as close,T as createComponent,s as first,h as insert,E as isComponent,p as label,w as list,W as mergeProps,a as next,M as off,L as on,u as open,d as part,q as path,y as ran,S as reconcile,_ as rest,j as setAttribute,v as setAttributeNS,F as setBoolean,H as setClass,I as setClassList,A as setProperty,R as setStyle,V as setStyleObject,c as site,D as spread,m as store,k as template,P as view,N as writeChild,f as wrote};
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAW3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,GACtE,MAAM,IAAI,EAAE,CAyDd"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAmC3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,GACtE,MAAM,IAAI,EAAE,CA2Gd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/dom",
3
- "version": "0.9.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",
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "dependencies": {
33
- "@firsthandjs/core": "0.9.0"
33
+ "@firsthandjs/core": "0.9.1"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">=20.11.0"
@@ -1 +0,0 @@
1
- function z(n,i,e){return n}var a={current:null};function J(n){let i=n.firstChild,e=a.current;return e===null?i:e.step(i)}function K(n){let i=n.nextSibling,e=a.current;return e===null?i:e.step(i)}import{bind as O,createOwner as q,signal as P,disposeOwner as B,getOwner as S,onCleanup as H,runWithOwner as R,setOwner as D}from"@firsthandjs/core";var w=0;function tn(n){w++;try{n()}finally{w--}}var M=3;function E(n){return typeof n.nodeType=="number"}var I=Symbol("firsthand.part"),L=Symbol("firsthand.flat");function on(n){return{[I]:!0,anchor:document.createTextNode(""),thunk:n,owner:S()}}function C(n){return I in n}function ln(n=""){return{slots:[],owner:S(),generation:0,name:n}}function b(n){n.busy=!0}function F(n,i){let e=n.slots[i];if(e!==void 0)return e.seen=n.generation,e;let o={seen:n.generation};return n.slots[i]=o,o}function rn(n,i){let e=q(n.owner);return i.owner=e,D(e)}function dn(n){D(n)}function sn(n,i){let e=n.generation,o=n.slots;for(let t=0;t<o.length;t++){let l=o[t];l===void 0||l.seen===e||(l.owner!==void 0&&B(l.owner),o[t]=void 0)}return n.generation=e+1,i}function un(n,i,e){let o=F(n,i),t=o.cell;if(t===void 0){let l=P(e);return o.cell=l,l}return t.peek()!==e&&(b(n),t.value=e),t}function fn(n,i,e,o,t){let l=F(n,i);if(l.node===void 0&&a.current!==null){let r=a.current.claim(e,o);if(r!==null){if(typeof t=="object"&&t!==null&&C(t)){l.last=t,a.current.keep(l,e,t.anchor,r),R(t.owner,()=>{p(e,t.thunk,t.anchor)});return}l.node=r.nodes,l.text=r.text}}let d=typeof t;if(d==="string"||d==="number"){let r=String(t);if(r===l.text)return;b(n),l.text=r,l.node=h(e,o,l.node??null,r);return}l.text=void 0,t!==l.last&&(b(n),l.last=t,l.node=h(e,o,l.node??null,t))}function p(n,i,e=null,o){if(typeof i!="function"){h(n,e,null,i);return}let t=null,l,d=o!==void 0?o:a.current===null?null:a.current.claim(n,e),r=d!==null;d!==null&&(t=d.nodes,l=d.text);let u=()=>{let f=i(),c=typeof f;if(c==="string"||c==="number"){let y=String(f);y!==l&&(l=y,t=h(n,e,t,y));return}if(l=void 0,c==="function"){if(r){t=null,p(n,f,e,d);return}t=N(t),p(n,f,e,null);return}t=h(n,e,t,f)};d===null?O(u):a.current.within(d.region,()=>{O(u)}),r=!1,H(()=>{t=w>0?null:N(t)})}function h(n,i,e,o){let t=typeof o;if(o==null||t==="boolean")return x(n,i,e);if(t==="string"||t==="number"){let l=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===M?(e.data=l,e):k(n,i,e,document.createTextNode(l))}if(t==="function")return h(n,i,e,o());if(Array.isArray(o)){if(L in o){let r=o;return r.length===0?x(n,i,e):(v(n,i,e===null?[]:Array.isArray(e)?e:[e],r),r)}let l=[],d=[];if(W(o,l,d),l.length===0)return x(n,i,e);v(n,i,e===null?[]:Array.isArray(e)?e:[e],l);for(let r=0;r<d.length;r++){let u=d[r];R(u.owner??S(),()=>{p(n,u.thunk,u.anchor)})}return l}return C(o)?h(n,i,e,[o]):E(o)?k(n,i,e,o):h(n,i,e,String(o))}function W(n,i,e){for(let o=0;o<n.length;o++){let t=n[o];if(typeof t=="object"&&t!==null&&C(t)){i.push(t.anchor),e.push(t);continue}for(;typeof t=="function";)t=t();t==null||typeof t=="boolean"||(Array.isArray(t)?W(t,i,e):typeof t=="object"&&E(t)?i.push(t):i.push(document.createTextNode(String(t))))}}function j(n){let i=n.parentNode;i!==null&&i.removeChild(n)}function x(n,i,e){return i===null&&Array.isArray(e)&&e.length>1&&n.childNodes.length===e.length?(n.textContent="",null):N(e)}function N(n){if(n!==null)if(Array.isArray(n))for(let i=0;i<n.length;i++)j(n[i]);else j(n);return null}function k(n,i,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(N(e),n.insertBefore(o,i),o)}function v(n,i,e,o){let t=0,l=0,d=e.length-1,r=o.length-1;for(;t<=d&&l<=r&&e[t]===o[l];)t++,l++;for(;t<=d&&l<=r&&e[d]===o[r];)d--,r--;let u=r+1<o.length?o[r+1]:i;if(t>d){for(let s=l;s<=r;s++)n.insertBefore(o[s],u);return}if(l>r){for(let s=t;s<=d;s++)n.removeChild(e[s]);return}let f=new Map;for(let s=t;s<=d;s++)f.set(e[s],s);let c=r-l+1,y=new Int32Array(c).fill(-1);for(let s=0;s<c;s++){let g=o[l+s],_=f.get(g);_!==void 0&&(y[s]=_,f.delete(g))}for(let s of f.keys())n.removeChild(s);let A=X(y),m=A.length-1,T=u;for(let s=c-1;s>=0;s--){let g=o[l+s];m>=0&&A[m]===s?m--:n.insertBefore(g,T),T=g}}function X(n){let i=n.length,e=new Int32Array(i).fill(-1),o=[];for(let d=0;d<i;d++){let r=n[d];if(r===-1)continue;let u=0,f=o.length;for(;u<f;){let c=u+f>>1;n[o[c]]<r?u=c+1:f=c}u>0&&(e[d]=o[u-1]),o[u]=d}let t=[],l=o.length>0?o[o.length-1]:-1;for(;l!==-1;)t.push(l),l=e[l];return t.reverse()}export{z as a,a as b,J as c,K as d,tn as e,L as f,on as g,ln as h,b as i,F as j,rn as k,dn as l,sn as m,un as n,fn as o,p,h as q,v as r};
@@ -1 +0,0 @@
1
- import{e as v,f as $,g as O,q as A}from"./chunk-NNHZJMZS.js";var b=null,k=new WeakMap;function yn(n){b=n,k=new WeakMap}var h=class extends Error{constructor(e){super(`${e} 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 S(n){let e=k.get(n);if(e!==void 0)return e;if(b===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new h(o)}let t=b(n);return k.set(n,t),t}import{signal as Q,createOwner as T,devEnterSetup as j,devExitSetup as m,disposeOwner as U,getOwner as N,handleError as L,setOwner as f,untrack as H}from"@firsthandjs/core";var M=Symbol.for("firsthand.component"),V=Symbol.for("firsthand.view"),X=0,F="firsthand";function Pn(n){F=n}function vn(n,e,t,o){let s=Object.assign(i=>nn(s,i),{[M]:!0,setup:n,options:e,id:t??`c${String(++X)}`,tag:void 0});return Object.defineProperty(s,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),t===void 0&&(`${s.name}`,void 0),(e?.tag!==void 0||e?.shadow===!0)&&tn(s,typeof e.tag=="string"?e.tag:void 0),s}function $n(n){return typeof n=="function"&&M in n}function On(n){return n[V]=!0,n}function nn(n,e){if(Object.freeze(e),n.setup===void 0)return V in n?O(()=>n(e)):S(n)(e);if(n.tag!==void 0)return sn(n,e);let t=T(N());n.name;let o=f(t);try{j(n.id);let r=H(()=>n.setup(e));return m(),f(o),r}catch(r){return m(),f(o),L(r,t),null}}function en(n){let e=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${F}-${e}`}function tn(n,e){let t=n;if(t.tag!==void 0)return t.tag;let o=e??en(t);return customElements.get(o)!==void 0&&(o=`${o}-${t.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),t.tag=o,customElements.define(o,on(t)),o}function on(n){let e=n.options?.shadow===!0,t=n.options?.attributes,o=t!==void 0?Object.keys(t):[];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=rn(this,t,this.$attrs),W(this,n,e))}disconnectedCallback(){!this.$standalone||this.$owner===null||(U(this.$owner),this.$owner=null)}attributeChangedCallback(s,i,u){let c=this.$attrs?.[s];c!==void 0&&(c.value=t[s]?.(u))}}}function rn(n,e,t){let o={};if(e!==void 0)for(let r in e){let s=Q(e[r](n.getAttribute(r)));t[r]=s,Object.defineProperty(o,r,{enumerable:!0,get:()=>s.value})}return Object.freeze(o)}function W(n,e,t){let o=T(N());e.name,n.$owner=o;let r=f(o);try{j(e.id);let s=t?n.attachShadow({mode:"open"}):n,i=H(()=>e.setup(n.$props));m(),A(s,null,null,i)}catch(s){m(),L(s,o)}finally{f(r)}}function sn(n,e){let t=document.createElement(n.tag);return t.$props=e,W(t,n,n.options?.shadow===!0),t}import{batch as un,createOwner as z,disposeOwner as dn,getOwner as cn,setOwner as C,signal as I,untrack as D}from"@firsthandjs/core";function Hn(n,e,t){let o=z(cn()),r=new Map;return()=>{let s=n(),i=new Map,u=[];return u[$]=!0,D(()=>{un(()=>{c()})}),r=i,u;function c(){for(let d=0;d<s.length;d++){let a=s[d],p=e(a,d);if(i.has(p)){`${String(p)}`;continue}let l=r.get(p);l===void 0?l=ln(o,a,d,t):(r.delete(p),l.item.value=a,l.index.value=d),i.set(p,l);for(let y=0;y<l.nodes.length;y++)u.push(l.nodes[y])}v(()=>{for(let d of r.values())dn(d.owner)})}}}function ln(n,e,t,o){let r=z(n),s=I(e),i=I(t),u=C(r),c;try{c=D(()=>o(s,i)),C(u)}catch(a){throw C(u),a}let d=[];return K(c,d),{owner:r,item:s,index:i,nodes:d}}function K(n,e){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let t=0;t<n.length;t++)K(n[t],e);return}if(typeof n=="object"&&typeof n.nodeType=="number"){e.push(n);return}e.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"]),Z=new Set;function w(n){return`$firsthand$${n}`}function pn(n){let e=w(n.type),t=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<t.length;r++){let s=t[r],i=s[e];if(i!==void 0&&(o=s,i.call(s,n),n.cancelBubble)||s===document)break}o=null}function g(n,e,t,o){if(o!==void 0||!an.has(e)){let r=n,s=o===!0?void 0:o,i=`${w(e)}$${s===void 0?"":Object.keys(s).sort().join(",")}`,u=r[i];u!==void 0&&n.removeEventListener(e,u.handler,u.options),r[i]={handler:t,options:s},n.addEventListener(e,t,s);return}n[w(e)]=t,Z.has(e)||(Z.add(e),document.addEventListener(e,pn))}function Vn(n,e){n[w(e)]=void 0}var fn={class:"className",for:"htmlFor"};function R(n,e,t){t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,t===!0?"":String(t))}function zn(n,e,t,o){o==null||o===!1?n.removeAttributeNS(e,t):n.setAttributeNS(e,t,o===!0?"":String(o))}function x(n,e,t){n[fn[e]??e]=t}function Dn(n,e,t){n[e]=!!t}function P(n,e){e==null?n.removeAttribute("class"):n.className=String(e)}function B(n,e,t){let o=n.classList;if(t!==void 0)for(let r in t)r in e||o.remove(r);for(let r in e){let s=!!e[r];(t===void 0||!!t[r]!==s)&&o.toggle(r,s)}}function _(n,e){e==null?n.style.cssText="":n.style.cssText=String(e)}function Y(n,e,t){let o=n.style;if(t!==void 0)for(let r in t)r in e||o.removeProperty(E(r));for(let r in e){let s=e[r];(t===void 0||t[r]!==s)&&(s==null?o.removeProperty(E(r)):o.setProperty(E(r),String(s)))}}var mn=/[A-Z]/g,q=new Map;function E(n){let e=q.get(n);return e===void 0&&(e=n.startsWith("--")?n:n.replace(mn,t=>`-${t.toLowerCase()}`),q.set(n,e)),e}function wn(n,e,t){if(e==="class"||e==="className"){Array.isArray(t)?P(n,t.filter(Boolean).join(" ")):t!==null&&typeof t=="object"?B(n,t,J(n,"class",t)):P(n,t);return}if(e==="style"){t!==null&&typeof t=="object"?Y(n,t,J(n,"style",t)):_(n,t);return}if(e==="ref"){t(n);return}if(e.startsWith("prop:")){x(n,e.slice(5),t);return}if(e.startsWith("attr:")){R(n,e.slice(5),t);return}if(e.startsWith("on")&&e.length>2&&/[A-Z:]/.test(e[2])){gn(n,e,t);return}if(e in n&&typeof t!="string"){x(n,e,t);return}R(n,e,t)}function gn(n,e,t){let o=e.slice(2).split(":"),r=o[0]==="",s=r?o[1]:o[0].toLowerCase(),i=o[r?2:1];i===void 0?g(n,s,t):i==="native"?g(n,s,t,!0):g(n,s,t,{[i]:!0})}function Bn(n,e){for(let t in e)t!=="children"&&wn(n,t,e[t])}function _n(...n){let e={};for(let t=0;t<n.length;t++){let o=n[t];for(let r of Object.keys(o))Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return e}function Yn(n,e){let t={};for(let o of Object.keys(n))e.includes(o)||Object.defineProperty(t,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(t)}var G=new WeakMap;function J(n,e,t){let o=G.get(n);o===void 0&&(o={},G.set(n,o));let r=o[e];return o[e]=t,r}export{yn as a,h as b,M as c,V as d,Pn as e,vn as f,$n as g,On as h,nn as i,tn as j,Hn as k,g as l,Vn as m,R as n,zn as o,x as p,Dn as q,P as r,B as s,_ as t,Y as u,wn as v,Bn as w,_n as x,Yn as y};