@firsthandjs/dom 0.9.1 → 0.10.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.
- package/dist/adapter.d.ts +0 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/chunk-467WEPXM.js +1 -0
- package/dist/chunk-MWEKNBIC.js +1 -0
- package/dist/{chunk-6BRSYQCI.js → chunk-YX6HJXS6.js} +1 -1
- package/dist/{dev-chunk-MKONDKMD.js → dev-chunk-HLMVSIC4.js} +97 -74
- package/dist/{dev-chunk-6V32MCOI.js → dev-chunk-KJHYMOKB.js} +1 -1
- package/dist/{dev-chunk-ADHDPKZW.js → dev-chunk-U46CIJCO.js} +221 -311
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.dev.js +28 -24
- package/dist/hydrate.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.dev.js +3 -3
- package/dist/index.js +1 -1
- package/dist/insert.d.ts +41 -127
- package/dist/insert.d.ts.map +1 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.dev.js +121 -11
- package/dist/internal.js +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/nodes.d.ts +36 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/props.d.ts.map +1 -1
- package/dist/reconcile.d.ts +30 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/store.d.ts +105 -0
- package/dist/store.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-E4GAI5XA.js +0 -1
- package/dist/chunk-P4PXTIUD.js +0 -1
package/dist/adapter.d.ts
CHANGED
|
@@ -21,9 +21,6 @@ export type ComponentAdapter = (target: (props: never) => unknown) => Component<
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function setComponentAdapter(next: ComponentAdapter | null): void;
|
|
23
23
|
/** Thrown for an element type this framework cannot run. */
|
|
24
|
-
export declare class FirsthandComponentError extends Error {
|
|
25
|
-
constructor(name: string);
|
|
26
|
-
}
|
|
27
24
|
/** Resolves a foreign element type, or says why it cannot be resolved. */
|
|
28
25
|
export declare function adapt(target: object): Component<never>;
|
|
29
26
|
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAcvF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAKvE;AAED,4DAA4D;AAE5D,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAYtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function z(n,o,e){return n}var N={current:null};function K(n){let o=n.firstChild,e=N.current;return e===null?o:e.step(o)}function Q(n){let o=n.nextSibling,e=N.current;return e===null?o:e.step(o)}function m(n,o,e,t){let i=0,l=0,r=e.length-1,d=t.length-1;for(;i<=r&&l<=d&&e[i]===t[l];)i++,l++;for(;i<=r&&l<=d&&e[r]===t[d];)r--,d--;let u=d+1<t.length?t[d+1]:o;if(i>r){for(let s=l;s<=d;s++)n.insertBefore(t[s],u);return}if(l>d){for(let s=i;s<=r;s++)n.removeChild(e[s]);return}R(n,t,u,{a:e,aStart:i,aEnd:r,bStart:l,bEnd:d})}function R(n,o,e,t){let i=t.bEnd-t.bStart+1,l=k(n,o,t),r=P(l),d=r.length-1,u=e;for(let s=i-1;s>=0;s--){let a=o[t.bStart+s];d>=0&&r[d]===s?d--:n.insertBefore(a,u),u=a}}function k(n,o,e){let{a:t,aStart:i,aEnd:l,bStart:r,bEnd:d}=e,u=new Map;for(let f=i;f<=l;f++)u.set(t[f],f);let s=d-r+1,a=new Int32Array(s).fill(-1);for(let f=0;f<s;f++){let c=o[r+f],w=u.get(c);w!==void 0&&(a[f]=w,u.delete(c))}for(let f of u.keys())n.removeChild(f);return a}function P(n){let o=n.length,e=new Int32Array(o).fill(-1),t=[];for(let r=0;r<o;r++){let d=n[r];if(d===-1)continue;let u=0,s=t.length;for(;u<s;){let a=u+s>>1;n[t[a]]<d?u=a+1:s=a}u>0&&(e[r]=t[u-1]),t[u]=r}let i=[],l=t.length>0?t[t.length-1]:-1;for(;l!==-1;)i.push(l),l=e[l];return i.reverse()}import{bind as A,getOwner as _,onCleanup as j,runWithOwner as F}from"@firsthandjs/core";function g(n){return typeof n.nodeType=="number"}function S(n){let o=n.parentNode;o!==null&&o.removeChild(n)}function h(n,o,e){return o===null&&Array.isArray(e)&&e.length>1&&n.childNodes.length===e.length?(n.textContent="",null):p(e)}function p(n){if(n!==null)if(Array.isArray(n))for(let o=0;o<n.length;o++)S(n[o]);else S(n);return null}function x(n,o,e,t){return e===t?t:e!==null&&!Array.isArray(e)?(n.replaceChild(t,e),t):(p(e),n.insertBefore(t,o),t)}var C=0;function rn(n){C++;try{n()}finally{C--}}var E=Symbol("firsthand.part"),M=Symbol("firsthand.flat"),q=Symbol("firsthand.pending"),b=new WeakSet;function dn(n){return{[E]:!0,anchor:document.createTextNode(""),thunk:n,owner:_()}}function O(n){return E in n}function D(n,o,e=null,t){if(typeof o!="function"){y(n,e,null,o);return}let i=G(n,e,t?.seed),l=i===null?null:i.nodes,r=i?.text,d=i!==null,u=()=>{let a=o(),f=typeof a;if(f==="string"||f==="number"){let c=String(a);c!==r&&(r=c,l=y(n,e,l,c));return}if(r=void 0,f==="function"){l=d?null:p(l),D(n,a,e,{seed:d?i:null});return}l=y(n,e,l,a)},s=t?.report;H(i,s===void 0?u:()=>{u(),s(B(l,e))}),d=!1,j(()=>{l=C>0?null:p(l)})}function B(n,o){let e=n===null?[]:Array.isArray(n)?[...n]:[n];return e.push(o),e}function G(n,o,e){return e!==void 0?e:N.current===null?null:N.current.claim(n,o)}function H(n,o){if(n===null){A(o);return}N.current.within(n.region,()=>{A(o)})}function y(n,o,e,t){let i=typeof t;if(t==null||i==="boolean")return h(n,o,e);if(i==="string"||i==="number"){let l=String(t);return e!==null&&!Array.isArray(e)&&e.nodeType===3?(e.data=l,e):x(n,o,e,document.createTextNode(l))}return L(n,o,e,t)}function L(n,o,e,t){return typeof t=="function"?y(n,o,e,t()):Array.isArray(t)?T(n,o,e,t):O(t)?T(n,o,e,[t]):g(t)?x(n,o,e,t):y(n,o,e,String(t))}function v(n){return n===null?[]:Array.isArray(n)?n:[n]}function T(n,o,e,t){if(M in t){let r=t;return r.length===0?h(n,o,e):(m(n,o,v(e),r),t[q]?.(n),r)}let i=[],l=[];if(I(t,i,l),i.length===0)return h(n,o,e);m(n,o,v(e),i);for(let r=0;r<l.length;r++)X(l[r],n);return i}function X(n,o,e){b.has(n)||(b.add(n),F(n.owner??_(),()=>{D(o,n.thunk,n.anchor,e===void 0?void 0:{report:e}),j(()=>{b.delete(n)})}))}function I(n,o,e){for(let t=0;t<n.length;t++){let i=n[t];if(typeof i=="object"&&i!==null&&O(i)){o.push(i.anchor),e.push(i);continue}for(;typeof i=="function";)i=i();i==null||typeof i=="boolean"||(Array.isArray(i)?I(i,o,e):typeof i=="object"&&g(i)?o.push(i):o.push(document.createTextNode(String(i))))}}export{z as a,N as b,K as c,Q as d,m as e,rn as f,M as g,q as h,dn as i,O as j,D as k,y as l,X as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as E,f as P,g as x,h as T,i as f,j as v,l as O,m as $}from"./chunk-467WEPXM.js";var p=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"}};var y=null,h=new WeakMap;function $n(n){y=n,h=new WeakMap}function A(n){let e=h.get(n);if(e!==void 0)return e;if(y===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new p(o)}let t=y(n);return h.set(n,t),t}import{signal as tn,createOwner as N,devEnterSetup as S,devExitSetup as m,disposeOwner as on,getOwner as j,handleError as L,setOwner as a,untrack as H}from"@firsthandjs/core";var M=Symbol.for("firsthand.component"),D=Symbol.for("firsthand.view"),rn=0,F="firsthand";function Dn(n){F=n}function Fn(n,e,t,o){let s=Object.assign(i=>sn(s,i),{[M]:!0,setup:n,options:e,id:t??`c${String(++rn)}`,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)&&un(s,typeof e.tag=="string"?e.tag:void 0),s}function Vn(n){return typeof n=="function"&&M in n}function Wn(n){return n[D]=!0,n}function sn(n,e){if(Object.freeze(e),n.setup===void 0)return D in n?f(()=>n(e)):A(n)(e);if(n.tag!==void 0)return an(n,e);let t=N(j());n.name;let o=a(t);try{S(n.id);let r=H(()=>n.setup(e));return m(),a(o),r}catch(r){return m(),a(o),L(r,t),null}}function dn(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 un(n,e){let t=n;if(t.tag!==void 0)return t.tag;let o=e??dn(t);return customElements.get(o)!==void 0&&(o=`${o}-${t.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),t.tag=o,customElements.define(o,cn(t)),o}function cn(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=ln(this,t,this.$attrs),V(this,n,e))}disconnectedCallback(){!this.$standalone||this.$owner===null||(on(this.$owner),this.$owner=null)}attributeChangedCallback(s,i,d){let u=this.$attrs?.[s];u!==void 0&&(u.value=t[s]?.(d))}}}function ln(n,e,t){let o={};if(e!==void 0)for(let r in e){let s=tn(e[r](n.getAttribute(r)));t[r]=s,Object.defineProperty(o,r,{enumerable:!0,get:()=>s.value})}return Object.freeze(o)}function V(n,e,t){let o=N(j());e.name,n.$owner=o;let r=a(o);try{S(e.id);let s=t?n.attachShadow({mode:"open"}):n,i=H(()=>e.setup(n.$props));m(),O(s,null,null,i)}catch(s){m(),L(s,o)}finally{a(r)}}function an(n,e){let t=document.createElement(n.tag);return t.$props=e,V(t,n,n.options?.shadow===!0),t}import{batch as fn,createOwner as z,disposeOwner as pn,getOwner as mn,setOwner as W,signal as I,untrack as K}from"@firsthandjs/core";function _n(n,e,t){let o=z(mn()),r=new Map,s,i=!1;return()=>{i&&s!==void 0&&wn(s,r);let d=[];d[x]=!0;let u={items:n(),rows:r,next:new Map,nodes:d,host:o,keyOf:e,render:t,pending:void 0,views:i};K(()=>{fn(()=>{gn(u)})}),i=u.views,r=u.next,s=d;let c=u.pending;return c!==void 0&&(d[T]=l=>{for(let en of c)q(en,l)}),d}}function wn(n,e){n.length=0;for(let t of e.values())for(let o of t.pieces===void 0?t.nodes:B(t))n.push(o)}function gn(n){let{items:e,rows:t,next:o,nodes:r}=n;for(let s=0;s<e.length;s++){let i=e[s],d=n.keyOf(i,s);if(o.has(d)){`${String(d)}`;continue}let u=t.get(d)??yn(n,i,s);t.delete(d)&&(u.item.value=i,u.index.value=s),o.set(d,u);let c=u.pieces===void 0?u.nodes:B(u);for(let l=0;l<c.length;l++)r.push(c[l])}P(()=>{for(let s of t.values())pn(s.owner)})}function yn(n,e,t){let o=hn(n.host,e,t,n.render);return o.pieces!==void 0&&(n.views=!0,q(o,null)||(n.pending=n.pending===void 0?[o]:[...n.pending,o])),o}function Z(n){return typeof n.nodeType=="number"}function q(n,e){let t=n.pieces;for(let o of t){if(Z(o))continue;let r=e??E.current?.place(o.child.anchor)??null;if(r===null)return!1;$(o.child,r,s=>{o.nodes=s})}return!0}function B(n){let e=[];for(let t of n.pieces)if(Z(t))e.push(t);else for(let o of t.nodes)e.push(o);return e}function hn(n,e,t,o){let r=z(n),s=I(e),i=I(t),d=W(r),u=[],c;try{c=G(K(()=>o(s,i)),u)}finally{W(d)}return c?{owner:r,item:s,index:i,nodes:[],pieces:u}:{owner:r,item:s,index:i,nodes:u}}function G(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=G(n[o],e)||t;return t}if(typeof n=="function"){let t=f(n);return e.push({child:t,nodes:[t.anchor]}),!0}if(typeof n=="object"){if(v(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 bn=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),_=new Set;function w(n){return`$firsthand$${n}`}function kn(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||!bn.has(e)){let r=n,s=o===!0?void 0:o,i=`${w(e)}$${s===void 0?"":Object.keys(s).sort().join(",")}`,d=r[i];d!==void 0&&n.removeEventListener(e,d.handler,d.options),r[i]={handler:t,options:s},n.addEventListener(e,t,s);return}n[w(e)]=t,_.has(e)||(_.add(e),document.addEventListener(e,kn))}function Jn(n,e){n[w(e)]=void 0}var Rn={class:"className",for:"htmlFor"};function k(n,e,t){t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,t===!0?"":String(t))}function ne(n,e,t,o){o==null||o===!1?n.removeAttributeNS(e,t):n.setAttributeNS(e,t,o===!0?"":String(o))}function R(n,e,t){n[Rn[e]??e]=t}function ee(n,e,t){n[e]=!!t}function C(n,e){e==null?n.removeAttribute("class"):n.className=String(e)}function J(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 Q(n,e){e==null?n.style.cssText="":n.style.cssText=String(e)}function U(n,e,t){let o=n.style;if(t!==void 0)for(let r in t)r in e||o.removeProperty(b(r));for(let r in e){let s=e[r];(t===void 0||t[r]!==s)&&(s==null?o.removeProperty(b(r)):o.setProperty(b(r),String(s)))}}var Cn=/[A-Z]/g,Y=new Map;function b(n){let e=Y.get(n);return e===void 0&&(e=n.startsWith("--")?n:n.replace(Cn,t=>`-${t.toLowerCase()}`),Y.set(n,e)),e}function En(n,e,t){if(e==="class"||e==="className"){Pn(n,t);return}if(e==="style"){xn(n,t);return}if(e==="ref"){t(n);return}if(e.startsWith("prop:")){R(n,e.slice(5),t);return}if(e.startsWith("attr:")){k(n,e.slice(5),t);return}if(e.startsWith("on")&&e.length>2&&/[A-Z:]/.test(e[2])){Tn(n,e,t);return}if(e in n&&typeof t!="string"){R(n,e,t);return}k(n,e,t)}function Pn(n,e){if(Array.isArray(e)){C(n,e.filter(Boolean).join(" "));return}if(e!==null&&typeof e=="object"){J(n,e,nn(n,"class",e));return}C(n,e)}function xn(n,e){let t=n;if(e!==null&&typeof e=="object"){U(t,e,nn(n,"style",e));return}Q(t,e)}function Tn(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 se(n,e){for(let t in e)t!=="children"&&En(n,t,e[t])}function ie(...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 de(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 X=new WeakMap;function nn(n,e,t){let o=X.get(n);o===void 0&&(o={},X.set(n,o));let r=o[e];return o[e]=t,r}export{p as a,$n as b,M as c,D as d,Dn as e,Fn as f,Vn as g,Wn as h,sn as i,un as j,_n as k,g as l,Jn as m,k as n,ne as o,R as p,ee as q,C as r,J as s,Q as t,U as u,En as v,se as w,ie as x,de as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as d,l as i}from"./chunk-467WEPXM.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};
|
|
@@ -11,15 +11,9 @@ import {
|
|
|
11
11
|
hydration,
|
|
12
12
|
isDynamicChild,
|
|
13
13
|
part
|
|
14
|
-
} from "./dev-chunk-
|
|
14
|
+
} from "./dev-chunk-U46CIJCO.js";
|
|
15
15
|
|
|
16
|
-
// packages/dom/src/
|
|
17
|
-
var adapter = null;
|
|
18
|
-
var adapted = /* @__PURE__ */ new WeakMap();
|
|
19
|
-
function setComponentAdapter(next) {
|
|
20
|
-
adapter = next;
|
|
21
|
-
adapted = /* @__PURE__ */ new WeakMap();
|
|
22
|
-
}
|
|
16
|
+
// packages/dom/src/errors.ts
|
|
23
17
|
var FirsthandComponentError = class extends Error {
|
|
24
18
|
constructor(name) {
|
|
25
19
|
super(
|
|
@@ -28,6 +22,14 @@ var FirsthandComponentError = class extends Error {
|
|
|
28
22
|
this.name = "FirsthandComponentError";
|
|
29
23
|
}
|
|
30
24
|
};
|
|
25
|
+
|
|
26
|
+
// packages/dom/src/adapter.ts
|
|
27
|
+
var adapter = null;
|
|
28
|
+
var adapted = /* @__PURE__ */ new WeakMap();
|
|
29
|
+
function setComponentAdapter(next) {
|
|
30
|
+
adapter = next;
|
|
31
|
+
adapted = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
}
|
|
31
33
|
function adapt(target) {
|
|
32
34
|
const existing = adapted.get(target);
|
|
33
35
|
if (existing !== void 0) {
|
|
@@ -233,28 +235,32 @@ function list(each, keyOf, render) {
|
|
|
233
235
|
let placed;
|
|
234
236
|
let views = false;
|
|
235
237
|
return () => {
|
|
236
|
-
const items = each();
|
|
237
238
|
if (views && placed !== void 0) {
|
|
238
|
-
placed
|
|
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
|
-
}
|
|
239
|
+
rewritePlaced(placed, rows);
|
|
244
240
|
}
|
|
245
|
-
const next = /* @__PURE__ */ new Map();
|
|
246
241
|
const nodes = [];
|
|
247
242
|
nodes[FLAT] = true;
|
|
248
|
-
|
|
243
|
+
const pass = {
|
|
244
|
+
items: each(),
|
|
245
|
+
rows,
|
|
246
|
+
next: /* @__PURE__ */ new Map(),
|
|
247
|
+
nodes,
|
|
248
|
+
host,
|
|
249
|
+
keyOf,
|
|
250
|
+
render,
|
|
251
|
+
pending: void 0,
|
|
252
|
+
views
|
|
253
|
+
};
|
|
249
254
|
untrack2(() => {
|
|
250
255
|
batch(() => {
|
|
251
|
-
buildRows();
|
|
256
|
+
buildRows(pass);
|
|
252
257
|
});
|
|
253
258
|
});
|
|
254
|
-
|
|
259
|
+
views = pass.views;
|
|
260
|
+
rows = pass.next;
|
|
255
261
|
placed = nodes;
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
const made = pass.pending;
|
|
263
|
+
if (made !== void 0) {
|
|
258
264
|
nodes[PENDING] = (parent) => {
|
|
259
265
|
for (const row of made) {
|
|
260
266
|
bindRow(row, parent);
|
|
@@ -262,44 +268,52 @@ function list(each, keyOf, render) {
|
|
|
262
268
|
};
|
|
263
269
|
}
|
|
264
270
|
return nodes;
|
|
265
|
-
function buildRows() {
|
|
266
|
-
for (let i = 0; i < items.length; i++) {
|
|
267
|
-
const item = items[i];
|
|
268
|
-
const key2 = keyOf(item, i);
|
|
269
|
-
if (next.has(key2)) {
|
|
270
|
-
devWarn(
|
|
271
|
-
`Duplicate list key ${String(key2)}. Keys must be unique, or rows will be dropped.`
|
|
272
|
-
);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
let row = rows.get(key2);
|
|
276
|
-
if (row === void 0) {
|
|
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
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
rows.delete(key2);
|
|
286
|
-
row.item.value = item;
|
|
287
|
-
row.index.value = i;
|
|
288
|
-
}
|
|
289
|
-
next.set(key2, row);
|
|
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]);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
discard(() => {
|
|
296
|
-
for (const row of rows.values()) {
|
|
297
|
-
disposeOwner2(row.owner);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
271
|
};
|
|
302
272
|
}
|
|
273
|
+
function rewritePlaced(placed, rows) {
|
|
274
|
+
placed.length = 0;
|
|
275
|
+
for (const row of rows.values()) {
|
|
276
|
+
for (const node of row.pieces === void 0 ? row.nodes : nodesOf(row)) {
|
|
277
|
+
placed.push(node);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function buildRows(pass) {
|
|
282
|
+
const { items, rows, next, nodes } = pass;
|
|
283
|
+
for (let i = 0; i < items.length; i++) {
|
|
284
|
+
const item = items[i];
|
|
285
|
+
const key2 = pass.keyOf(item, i);
|
|
286
|
+
if (next.has(key2)) {
|
|
287
|
+
devWarn(`Duplicate list key ${String(key2)}. Keys must be unique, or rows will be dropped.`);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const row = rows.get(key2) ?? newRow(pass, item, i);
|
|
291
|
+
if (rows.delete(key2)) {
|
|
292
|
+
row.item.value = item;
|
|
293
|
+
row.index.value = i;
|
|
294
|
+
}
|
|
295
|
+
next.set(key2, row);
|
|
296
|
+
const found = row.pieces === void 0 ? row.nodes : nodesOf(row);
|
|
297
|
+
for (let n = 0; n < found.length; n++) {
|
|
298
|
+
nodes.push(found[n]);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
discard(() => {
|
|
302
|
+
for (const row of rows.values()) {
|
|
303
|
+
disposeOwner2(row.owner);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function newRow(pass, item, index) {
|
|
308
|
+
const row = createRow(pass.host, item, index, pass.render);
|
|
309
|
+
if (row.pieces !== void 0) {
|
|
310
|
+
pass.views = true;
|
|
311
|
+
if (!bindRow(row, null)) {
|
|
312
|
+
pass.pending = pass.pending === void 0 ? [row] : [...pass.pending, row];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return row;
|
|
316
|
+
}
|
|
303
317
|
function isNode(piece) {
|
|
304
318
|
return typeof piece.nodeType === "number";
|
|
305
319
|
}
|
|
@@ -548,25 +562,11 @@ function hyphenate(name) {
|
|
|
548
562
|
// packages/dom/src/props.ts
|
|
549
563
|
function applyProp(node, name, value) {
|
|
550
564
|
if (name === "class" || name === "className") {
|
|
551
|
-
|
|
552
|
-
setClass(node, value.filter(Boolean).join(" "));
|
|
553
|
-
} else if (value !== null && typeof value === "object") {
|
|
554
|
-
setClassList(node, value, remember(node, "class", value));
|
|
555
|
-
} else {
|
|
556
|
-
setClass(node, value);
|
|
557
|
-
}
|
|
565
|
+
applyClass(node, value);
|
|
558
566
|
return;
|
|
559
567
|
}
|
|
560
568
|
if (name === "style") {
|
|
561
|
-
|
|
562
|
-
setStyleObject(
|
|
563
|
-
node,
|
|
564
|
-
value,
|
|
565
|
-
remember(node, "style", value)
|
|
566
|
-
);
|
|
567
|
-
} else {
|
|
568
|
-
setStyle(node, value);
|
|
569
|
-
}
|
|
569
|
+
applyStyle(node, value);
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
if (name === "ref") {
|
|
@@ -591,6 +591,29 @@ function applyProp(node, name, value) {
|
|
|
591
591
|
}
|
|
592
592
|
setAttribute(node, name, value);
|
|
593
593
|
}
|
|
594
|
+
function applyClass(node, value) {
|
|
595
|
+
if (Array.isArray(value)) {
|
|
596
|
+
setClass(node, value.filter(Boolean).join(" "));
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
if (value !== null && typeof value === "object") {
|
|
600
|
+
setClassList(node, value, remember(node, "class", value));
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
setClass(node, value);
|
|
604
|
+
}
|
|
605
|
+
function applyStyle(node, value) {
|
|
606
|
+
const style = node;
|
|
607
|
+
if (value !== null && typeof value === "object") {
|
|
608
|
+
setStyleObject(
|
|
609
|
+
style,
|
|
610
|
+
value,
|
|
611
|
+
remember(node, "style", value)
|
|
612
|
+
);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
setStyle(style, value);
|
|
616
|
+
}
|
|
594
617
|
function applyEvent(node, name, value) {
|
|
595
618
|
const parts = name.slice(2).split(":");
|
|
596
619
|
const literal = parts[0] === "";
|
|
@@ -650,8 +673,8 @@ function remember(node, slot, value) {
|
|
|
650
673
|
}
|
|
651
674
|
|
|
652
675
|
export {
|
|
653
|
-
setComponentAdapter,
|
|
654
676
|
FirsthandComponentError,
|
|
677
|
+
setComponentAdapter,
|
|
655
678
|
COMPONENT,
|
|
656
679
|
VIEW,
|
|
657
680
|
setElementPrefix,
|