@firsthandjs/dom 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-26MSEGYG.js +1 -0
- package/dist/chunk-NNHZJMZS.js +1 -0
- package/dist/chunk-TZRPGQ3R.js +1 -0
- package/dist/claim.d.ts +76 -0
- package/dist/claim.d.ts.map +1 -0
- package/dist/dev-chunk-5QV3XALZ.js +45 -0
- package/dist/{dev-chunk-2CKM3OGC.js → dev-chunk-HCAUM4JK.js} +61 -435
- package/dist/dev-chunk-HTXIHAW7.js +501 -0
- package/dist/dev.d.ts +11 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.prod.d.ts +1 -0
- package/dist/dev.prod.d.ts.map +1 -1
- package/dist/hydrate.d.ts +91 -0
- package/dist/hydrate.d.ts.map +1 -0
- package/dist/hydrate.dev.js +153 -0
- package/dist/hydrate.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.dev.js +19 -35
- package/dist/index.js +1 -1
- package/dist/insert.d.ts +28 -1
- package/dist/insert.d.ts.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.dev.js +30 -12
- package/dist/internal.js +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/props.d.ts.map +1 -1
- package/dist/render.d.ts +9 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/template.d.ts.map +1 -1
- package/package.json +7 -2
- package/dist/chunk-EWYTWH5D.js +0 -1
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/dist/claim.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam hydration is installed through.
|
|
3
|
+
*
|
|
4
|
+
* `template` and `insert` have to be able to adopt nodes a server sent, and
|
|
5
|
+
* an application that has no server must not pay for the machinery that does
|
|
6
|
+
* it. So they do not import it. They read one holder, which is empty until
|
|
7
|
+
* `@firsthandjs/dom/hydrate` fills it — and a bundle that never imports that
|
|
8
|
+
* module never contains the machinery at all, because nothing references it.
|
|
9
|
+
*
|
|
10
|
+
* What is left behind in the ordinary path is one property read and one
|
|
11
|
+
* comparison against `null`, in two places.
|
|
12
|
+
*/
|
|
13
|
+
/** What a region of server markup turned out to hold. */
|
|
14
|
+
export type Claimed = {
|
|
15
|
+
/** The nodes the region holds, as a child slot. */
|
|
16
|
+
nodes: Node | Node[] | null;
|
|
17
|
+
/** The text already there, when the region is one text node. */
|
|
18
|
+
text: string | undefined;
|
|
19
|
+
/** The region itself, for the calls made while a child's first run happens. */
|
|
20
|
+
region: Region;
|
|
21
|
+
};
|
|
22
|
+
/** Where a claim has got to. */
|
|
23
|
+
export type Region = {
|
|
24
|
+
/** The next unclaimed node, or null when the region is used up. */
|
|
25
|
+
node: Node | null;
|
|
26
|
+
/** The node the region stops before. */
|
|
27
|
+
end: Node | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The part of a site hydration fills in.
|
|
31
|
+
*
|
|
32
|
+
* Structural, so that the holder does not have to import `insert.ts` and
|
|
33
|
+
* `insert.ts` does not have to export its record type to reach through it.
|
|
34
|
+
*/
|
|
35
|
+
export type Filled = {
|
|
36
|
+
node?: Node | Node[] | null;
|
|
37
|
+
};
|
|
38
|
+
export type Claimer = {
|
|
39
|
+
/** The element name a template's markup makes. */
|
|
40
|
+
tag(html: string): string;
|
|
41
|
+
/** The next node of the current region, if it is a `tag`. */
|
|
42
|
+
adopt(tag: string): Node | null;
|
|
43
|
+
/**
|
|
44
|
+
* Gives a child a run keeps the nodes the run claimed for it.
|
|
45
|
+
*
|
|
46
|
+
* Puts `anchor` at the end of the region and offers the region to whoever
|
|
47
|
+
* claims against that anchor next, which is the child's own `insert`.
|
|
48
|
+
*/
|
|
49
|
+
keep(slot: Filled, parent: Node, anchor: Node, claimed: Claimed): void;
|
|
50
|
+
/** The region belonging to the next dynamic child of `parent`. */
|
|
51
|
+
claim(parent: Node, marker: Node | null): Claimed | null;
|
|
52
|
+
/** Makes `region` the one nodes are adopted from while `body` runs. */
|
|
53
|
+
within<T>(region: Region, body: () => T): T;
|
|
54
|
+
/** A step through the template that goes over a whole region at a time. */
|
|
55
|
+
step(node: Node): Node;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The installed claimer, or nothing.
|
|
59
|
+
*
|
|
60
|
+
* A holder rather than an exported binding, so that every reader sees the
|
|
61
|
+
* same value however the module is bundled.
|
|
62
|
+
*/
|
|
63
|
+
export declare const hydration: {
|
|
64
|
+
current: Claimer | null;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The first child of `node`, stepping over a dynamic child's content.
|
|
68
|
+
*
|
|
69
|
+
* Emitted by the compiler in place of `.firstChild` for a build that can
|
|
70
|
+
* hydrate. `.firstChild` would walk into the content of a dynamic child,
|
|
71
|
+
* because the content has a length the template does not.
|
|
72
|
+
*/
|
|
73
|
+
export declare function first(node: Node): Node;
|
|
74
|
+
/** The next sibling of `node`, stepping over a dynamic child's content. */
|
|
75
|
+
export declare function next(node: Node): Node;
|
|
76
|
+
//# sourceMappingURL=claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yDAAyD;AACzD,MAAM,MAAM,OAAO,GAAG;IACpB,mDAAmD;IACnD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAC5B,gEAAgE;IAChE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,MAAM,GAAG;IACnB,mEAAmE;IACnE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,wCAAwC;IACxC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,kDAAkD;IAClD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAChC;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACvE,kEAAkE;IAClE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,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;CACxB,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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyChild,
|
|
3
|
+
insert
|
|
4
|
+
} from "./dev-chunk-HTXIHAW7.js";
|
|
5
|
+
|
|
6
|
+
// packages/dom/src/render.ts
|
|
7
|
+
import { createRoot, onCleanup, untrack } from "@firsthandjs/core";
|
|
8
|
+
function render(view, container = document.body) {
|
|
9
|
+
return mount(view, container, null);
|
|
10
|
+
}
|
|
11
|
+
function mount(view, container, around) {
|
|
12
|
+
let dispose;
|
|
13
|
+
createRoot((stop) => {
|
|
14
|
+
dispose = stop;
|
|
15
|
+
const run = () => {
|
|
16
|
+
attach(container, untrack(view), around !== null);
|
|
17
|
+
};
|
|
18
|
+
if (around === null) {
|
|
19
|
+
run();
|
|
20
|
+
} else {
|
|
21
|
+
around(run);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return dispose;
|
|
25
|
+
}
|
|
26
|
+
function attach(container, result, adopting) {
|
|
27
|
+
if (typeof result === "function") {
|
|
28
|
+
insert(container, result);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let slot = null;
|
|
32
|
+
if (adopting) {
|
|
33
|
+
const children = [...container.childNodes];
|
|
34
|
+
slot = children.length === 1 ? children[0] : children;
|
|
35
|
+
}
|
|
36
|
+
slot = applyChild(container, null, slot, result);
|
|
37
|
+
onCleanup(() => {
|
|
38
|
+
applyChild(container, null, slot, null);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
render,
|
|
44
|
+
mount
|
|
45
|
+
};
|