@firsthandjs/dom 0.7.1 → 0.8.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-EWYTWH5D.js +1 -0
- package/dist/component.d.ts +36 -1
- package/dist/component.d.ts.map +1 -1
- package/dist/{dev-chunk-2INCAQ6G.js → dev-chunk-2CKM3OGC.js} +184 -33
- package/dist/dev.d.ts +23 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.prod.d.ts +8 -0
- package/dist/dev.prod.d.ts.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.dev.js +8 -2
- package/dist/index.js +1 -1
- package/dist/insert.d.ts +84 -1
- package/dist/insert.d.ts.map +1 -1
- package/dist/internal.d.ts +3 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.dev.js +23 -3
- package/dist/internal.js +1 -1
- package/dist/render.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-QZ5SESOU.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=null,S=new WeakMap;function Vn(n){C=n,S=new WeakMap}var E=class extends Error{constructor(t){super(`${t} is not a Firsthand component. If it is a React component, import '@firsthandjs/react/auto' once at startup to render React components directly, or wrap it with fromReact(). Otherwise, declare it with component().`),this.name="FirsthandComponentError"}};function j(n){let t=S.get(n);if(t!==void 0)return t;if(C===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new E(o)}let e=C(n);return S.set(n,e),e}function qn(n,t,e){return n}import{bind as pn,createOwner as mn,signal as wn,disposeOwner as gn,getOwner as v,onCleanup as yn,runWithOwner as hn,setOwner as _}from"@firsthandjs/core";var bn=3;function W(n){return typeof n.nodeType=="number"}var D=Symbol("firsthand.part");function M(n){return{[D]:!0,anchor:document.createTextNode(""),thunk:n,owner:v()}}function I(n){return D in n}function Xn(n=""){return{slots:[],owner:v(),generation:0,name:n}}function R(n){n.busy=!0}function V(n,t){let e=n.slots[t];if(e!==void 0)return e.seen=n.generation,e;let o={seen:n.generation};return n.slots[t]=o,o}function Jn(n,t){let e=mn(n.owner);return t.owner=e,_(e)}function Qn(n){_(n)}function Un(n,t){let e=n.generation,o=n.slots;for(let r=0;r<o.length;r++){let i=o[r];i===void 0||i.seen===e||(i.owner!==void 0&&gn(i.owner),o[r]=void 0)}return n.generation=e+1,t}function ne(n,t,e){let o=V(n,t),r=o.cell;if(r===void 0){let i=wn(e);return o.cell=i,i}return r.peek()!==e&&(R(n),r.value=e),r}function ee(n,t,e,o,r){let i=V(n,t),s=typeof r;if(s==="string"||s==="number"){let l=String(r);if(l===i.text)return;R(n),i.text=l,i.node=p(e,o,i.node??null,l);return}i.text=void 0,r!==i.last&&(R(n),i.last=r,i.node=p(e,o,i.node??null,r))}function F(n,t,e=null){if(typeof t!="function"){p(n,e,null,t);return}let o=null,r;pn(()=>{let i=t(),s=typeof i;if(s==="string"||s==="number"){let l=String(i);l!==r&&(r=l,o=p(n,e,o,l));return}if(r=void 0,s==="function"){o=g(o),F(n,i,e);return}o=p(n,e,o,i)}),yn(()=>{o=g(o)})}function p(n,t,e,o){let r=typeof o;if(o==null||r==="boolean")return g(e);if(r==="string"||r==="number"){let i=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===bn?(e.data=i,e):L(n,t,e,document.createTextNode(i))}if(r==="function")return p(n,t,e,o());if(Array.isArray(o)){let i=[],s=[];if(q(o,i,s),i.length===0)return g(e);kn(n,t,e===null?[]:Array.isArray(e)?e:[e],i);for(let l=0;l<s.length;l++){let d=s[l];hn(d.owner??v(),()=>{F(n,d.thunk,d.anchor)})}return i}return I(o)?p(n,t,e,[o]):W(o)?L(n,t,e,o):p(n,t,e,String(o))}function q(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&I(r)){t.push(r.anchor),e.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?q(r,t,e):typeof r=="object"&&W(r)?t.push(r):t.push(document.createTextNode(String(r))))}}function H(n){let t=n.parentNode;t!==null&&t.removeChild(n)}function g(n){if(n!==null)if(Array.isArray(n))for(let t=0;t<n.length;t++)H(n[t]);else H(n);return null}function L(n,t,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(g(e),n.insertBefore(o,t),o)}function kn(n,t,e,o){let r=0,i=0,s=e.length-1,l=o.length-1;for(;r<=s&&i<=l&&e[r]===o[i];)r++,i++;for(;r<=s&&i<=l&&e[s]===o[l];)s--,l--;let d=l+1<o.length?o[l+1]:t;if(r>s){for(let u=i;u<=l;u++)n.insertBefore(o[u],d);return}if(i>l){for(let u=r;u<=s;u++)n.removeChild(e[u]);return}let c=new Map;for(let u=r;u<=s;u++)c.set(e[u],u);let a=l-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let w=o[i+u],$=c.get(w);$!==void 0&&(f[u]=$,c.delete(w))}for(let u of c.keys())n.removeChild(u);let m=xn(f),x=m.length-1,T=d;for(let u=a-1;u>=0;u--){let w=o[i+u];x>=0&&m[x]===u?x--:n.insertBefore(w,T),T=w}}function xn(n){let t=n.length,e=new Int32Array(t).fill(-1),o=[];for(let s=0;s<t;s++){let l=n[s];if(l===-1)continue;let d=0,c=o.length;for(;d<c;){let a=d+c>>1;n[o[a]]<l?d=a+1:c=a}d>0&&(e[s]=o[d-1]),o[d]=s}let r=[],i=o.length>0?o[o.length-1]:-1;for(;i!==-1;)r.push(i),i=e[i];return r.reverse()}import{signal as Cn,createOwner as z,devEnterSetup as B,devExitSetup as h,disposeOwner as Sn,getOwner as K,handleError as Z,setOwner as y,untrack as Y}from"@firsthandjs/core";var G=Symbol.for("firsthand.component"),X=Symbol.for("firsthand.view"),En=0,J="firsthand";function ue(n){J=n}function ce(n,t,e,o){let i=Object.assign(s=>Rn(i,s),{[G]:!0,setup:n,options:t,id:e??`c${String(++En)}`,tag:void 0});return Object.defineProperty(i,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),e===void 0&&(`${i.name}`,void 0),(t?.tag!==void 0||t?.shadow===!0)&&Nn(i,typeof t.tag=="string"?t.tag:void 0),i}function ae(n){return typeof n=="function"&&G in n}function fe(n){return n[X]=!0,n}function Rn(n,t){if(Object.freeze(t),n.setup===void 0)return X in n?M(()=>n(t)):j(n)(t);if(n.tag!==void 0)return An(n,t);let e=z(K());n.name;let o=y(e);try{B(n.id);let r=Y(()=>n.setup(t));return h(),y(o),r}catch(r){return h(),y(o),Z(r,e),null}}function vn(n){let t=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${J}-${t}`}function Nn(n,t){let e=n;if(e.tag!==void 0)return e.tag;let o=t??vn(e);return customElements.get(o)!==void 0&&(o=`${o}-${e.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),e.tag=o,customElements.define(o,On(e)),o}function On(n){let t=n.options?.shadow===!0,e=n.options?.attributes,o=e!==void 0?Object.keys(e):[];return class extends HTMLElement{static observedAttributes=o;constructor(){super(),this.$owner=null,this.$props=null,this.$attrs=null,this.$standalone=!1}connectedCallback(){this.$owner===null&&(this.$standalone=!0,this.$attrs={},this.$props=Pn(this,e,this.$attrs),Q(this,n,t))}disconnectedCallback(){!this.$standalone||this.$owner===null||(Sn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,l){let d=this.$attrs?.[i];d!==void 0&&(d.value=e[i]?.(l))}}}function Pn(n,t,e){let o={};if(t!==void 0)for(let r in t){let i=Cn(t[r](n.getAttribute(r)));e[r]=i,Object.defineProperty(o,r,{enumerable:!0,get:()=>i.value})}return Object.freeze(o)}function Q(n,t,e){let o=z(K());t.name,n.$owner=o;let r=y(o);try{B(t.id);let i=e?n.attachShadow({mode:"open"}):n,s=Y(()=>t.setup(n.$props));h(),p(i,null,null,s)}catch(i){h(),Z(i,o)}finally{y(r)}}function An(n,t){let e=document.createElement(n.tag);return e.$props=t,Q(e,n,n.options?.shadow===!0),e}import{batch as Tn,createOwner as nn,disposeOwner as $n,getOwner as jn,setOwner as N,signal as U,untrack as en}from"@firsthandjs/core";function he(n,t,e){let o=nn(jn()),r=new Map;return()=>{let i=n(),s=new Map,l=[];return Tn(()=>{for(let d=0;d<i.length;d++){let c=i[d],a=en(()=>t(c,d));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=Hn(o,c,d,e):(r.delete(a),f.item.value=c,f.index.value=d),s.set(a,f);for(let m=0;m<f.nodes.length;m++)l.push(f.nodes[m])}for(let d of r.values())$n(d.owner)}),r=s,l}}function Hn(n,t,e,o){let r=nn(n),i=U(t),s=U(e),l=N(r),d;try{d=en(()=>o(i,s)),N(l)}catch(a){throw N(l),a}let c=[];return tn(d,c),{owner:r,item:i,index:s,nodes:c}}function tn(n,t){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let e=0;e<n.length;e++)tn(n[e],t);return}if(typeof n=="object"&&typeof n.nodeType=="number"){t.push(n);return}t.push(document.createTextNode(String(n)))}}var Ln=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),on=new Set;function b(n){return`$firsthand$${n}`}function _n(n){let t=b(n.type),e=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<e.length;r++){let i=e[r],s=i[t];if(s!==void 0&&(o=i,s.call(i,n),n.cancelBubble)||i===document)break}o=null}function k(n,t,e,o){if(o!==void 0||!Ln.has(t)){let r=n,i=o===!0?void 0:o,s=`${b(t)}$${i===void 0?"":Object.keys(i).sort().join(",")}`,l=r[s];l!==void 0&&n.removeEventListener(t,l.handler,l.options),r[s]={handler:e,options:i},n.addEventListener(t,e,i);return}n[b(t)]=e,on.has(t)||(on.add(t),document.addEventListener(t,_n))}function ke(n,t){n[b(t)]=void 0}var Wn={class:"className",for:"htmlFor"};function P(n,t,e){e==null||e===!1?n.removeAttribute(t):n.setAttribute(t,e===!0?"":String(e))}function Se(n,t,e,o){o==null||o===!1?n.removeAttributeNS(t,e):n.setAttributeNS(t,e,o===!0?"":String(o))}function A(n,t,e){n[Wn[t]??t]=e}function Ee(n,t,e){n[t]=!!e}function sn(n,t){t==null?n.removeAttribute("class"):n.className=String(t)}function ln(n,t,e){let o=n.classList;if(e!==void 0)for(let r in e)r in t||o.remove(r);for(let r in t){let i=!!t[r];(e===void 0||!!e[r]!==i)&&o.toggle(r,i)}}function dn(n,t){t==null?n.style.cssText="":n.style.cssText=String(t)}function un(n,t,e){let o=n.style;if(e!==void 0)for(let r in e)r in t||o.removeProperty(O(r));for(let r in t){let i=t[r];(e===void 0||e[r]!==i)&&(i==null?o.removeProperty(O(r)):o.setProperty(O(r),String(i)))}}var Dn=/[A-Z]/g,rn=new Map;function O(n){let t=rn.get(n);return t===void 0&&(t=n.startsWith("--")?n:n.replace(Dn,e=>`-${e.toLowerCase()}`),rn.set(n,t)),t}function Mn(n,t,e){if(t==="class"||t==="className"){e!==null&&typeof e=="object"?ln(n,e,an(n,"class",e)):sn(n,e);return}if(t==="style"){e!==null&&typeof e=="object"?un(n,e,an(n,"style",e)):dn(n,e);return}if(t==="ref"){e(n);return}if(t.startsWith("prop:")){A(n,t.slice(5),e);return}if(t.startsWith("attr:")){P(n,t.slice(5),e);return}if(t.startsWith("on")&&t.length>2&&/[A-Z:]/.test(t[2])){In(n,t,e);return}if(t in n&&typeof e!="string"){A(n,t,e);return}P(n,t,e)}function In(n,t,e){let o=t.slice(2).split(":"),r=o[0]==="",i=r?o[1]:o[0].toLowerCase(),s=o[r?2:1];s===void 0?k(n,i,e):s==="native"?k(n,i,e,!0):k(n,i,e,{[s]:!0})}function Oe(n,t){for(let e in t)e!=="children"&&Mn(n,e,t[e])}function Pe(...n){let t={};for(let e=0;e<n.length;e++){let o=n[e];for(let r of Object.keys(o))Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return t}function Ae(n,t){let e={};for(let o of Object.keys(n))t.includes(o)||Object.defineProperty(e,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(e)}var cn=new WeakMap;function an(n,t,e){let o=cn.get(n);o===void 0&&(o={},cn.set(n,o));let r=o[t];return o[t]=e,r}export{Vn as a,E as b,qn as c,M as d,Xn as e,R as f,V as g,Jn as h,Qn as i,Un as j,ne as k,ee as l,F as m,p as n,kn as o,G as p,X as q,ue as r,ce as s,ae as t,fe as u,Rn as v,Nn as w,he as x,k as y,ke as z,P as A,Se as B,A as C,Ee as D,sn as E,ln as F,dn as G,un as H,Mn as I,Oe as J,Pe as K,Ae as L};
|
package/dist/component.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type { ReadonlyProps } from '@firsthandjs/core';
|
|
|
2
2
|
import { type DynamicChild } from './insert.js';
|
|
3
3
|
/** Marks a value as a Firsthand component; used by the JSX runtime and compiler. */
|
|
4
4
|
export declare const COMPONENT: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* Marks a plain function that returns markup.
|
|
7
|
+
*
|
|
8
|
+
* `Symbol.for` rather than a local symbol: the mark has to survive a module
|
|
9
|
+
* boundary, so a view function compiled in one package is recognised in
|
|
10
|
+
* another that may hold its own copy of this module.
|
|
11
|
+
*/
|
|
12
|
+
export declare const VIEW: unique symbol;
|
|
5
13
|
export type ComponentOptions = {
|
|
6
14
|
/** Attach a shadow root to the element host. Implies `tag` (ADR-0007). */
|
|
7
15
|
shadow?: boolean;
|
|
@@ -23,7 +31,20 @@ export type AttributeCodec = (raw: string | null) => unknown;
|
|
|
23
31
|
* fragment, and what a component returns when it renders something that has to
|
|
24
32
|
* be bound after it is placed — a route outlet, for instance.
|
|
25
33
|
*/
|
|
26
|
-
export type View = Node | string | number | boolean | null | undefined | DynamicChild | readonly View[];
|
|
34
|
+
export type View = Node | string | number | boolean | null | undefined | DynamicChild | readonly View[] | Render;
|
|
35
|
+
/**
|
|
36
|
+
* A view that is evaluated as a whole, again, when something it read changes.
|
|
37
|
+
*
|
|
38
|
+
* This is what a setup returns when it has statements above its markup — an
|
|
39
|
+
* `if`, a value derived from several signals — and it is an ordinary function,
|
|
40
|
+
* which is the point: it is a reactive scope like `effect` and `computed`, one
|
|
41
|
+
* level up.
|
|
42
|
+
*
|
|
43
|
+
* ```tsx
|
|
44
|
+
* component(() => () => (signedIn.value ? <Page /> : <SignIn />));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export type Render = () => View;
|
|
27
48
|
/**
|
|
28
49
|
* Props as a *caller* may write them.
|
|
29
50
|
*
|
|
@@ -73,6 +94,20 @@ export declare function setElementPrefix(value: string): void;
|
|
|
73
94
|
*/
|
|
74
95
|
export declare function component<P>(setup: (props: ReadonlyProps<P>) => View, options?: ComponentOptions, id?: string, name?: string): Component<P>;
|
|
75
96
|
export declare function isComponent(value: unknown): value is Component<never>;
|
|
97
|
+
/**
|
|
98
|
+
* Declares a plain function to be a view.
|
|
99
|
+
*
|
|
100
|
+
* A function that returns markup is a view, and a view is a reactive scope:
|
|
101
|
+
* `<Badge user={user} />` calls it where it stands, and calls it again when
|
|
102
|
+
* something it read changes. It has no setup, so it owns nothing that has to
|
|
103
|
+
* survive a run — `signal`, `effect` and their kind belong in a `component`.
|
|
104
|
+
*
|
|
105
|
+
* The compiler emits this for every module-level function it compiled markup
|
|
106
|
+
* into, so that a view imported from another module is still recognised as
|
|
107
|
+
* ours rather than handed to whatever adapter is installed. Inside one module
|
|
108
|
+
* the compiler resolves the call itself and this is never consulted.
|
|
109
|
+
*/
|
|
110
|
+
export declare function view<T extends (props: never) => unknown>(target: T): T;
|
|
76
111
|
/**
|
|
77
112
|
* Instantiates a component.
|
|
78
113
|
*
|
package/dist/component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAYA,OAAO,K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AAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAc5E"}
|
|
@@ -61,9 +61,46 @@ function label(value, kind, name) {
|
|
|
61
61
|
}
|
|
62
62
|
return value;
|
|
63
63
|
}
|
|
64
|
+
var QUIET = 20;
|
|
65
|
+
function devRan(store2) {
|
|
66
|
+
if (store2.busy === true) {
|
|
67
|
+
store2.busy = false;
|
|
68
|
+
store2.quiet = 0;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const quiet = (store2.quiet ?? 0) + 1;
|
|
72
|
+
store2.quiet = quiet;
|
|
73
|
+
if (quiet !== QUIET) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
devWarnOnce(
|
|
77
|
+
`quiet-run:${store2.name}`,
|
|
78
|
+
`<${store2.name}> ran ${String(QUIET)} times and wrote nothing.
|
|
79
|
+
Something it reads in a statement changes more often than what it shows. Move that read into the markup, where it is a part of its own, or move the derivation into a computed in the setup.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function devHandedNewFunction(store2, value) {
|
|
83
|
+
if (typeof value !== "function") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
devWarnOnce(
|
|
87
|
+
`new-function:${store2.name}`,
|
|
88
|
+
`<${store2.name}> hands a child a new function on every run, so that child runs again whenever this one does.
|
|
89
|
+
If the handler does not depend on the run, define it in the setup.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
64
92
|
|
|
65
93
|
// packages/dom/src/insert.ts
|
|
66
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
bind,
|
|
96
|
+
createOwner,
|
|
97
|
+
signal,
|
|
98
|
+
disposeOwner,
|
|
99
|
+
getOwner,
|
|
100
|
+
onCleanup,
|
|
101
|
+
runWithOwner,
|
|
102
|
+
setOwner
|
|
103
|
+
} from "@firsthandjs/core";
|
|
67
104
|
var TEXT_NODE = 3;
|
|
68
105
|
function isNode(value) {
|
|
69
106
|
return typeof value.nodeType === "number";
|
|
@@ -75,15 +112,103 @@ function part(thunk) {
|
|
|
75
112
|
function isDynamicChild(value) {
|
|
76
113
|
return PART in value;
|
|
77
114
|
}
|
|
115
|
+
function store(name = "") {
|
|
116
|
+
return { slots: [], owner: getOwner(), generation: 0, name };
|
|
117
|
+
}
|
|
118
|
+
function wrote(store2) {
|
|
119
|
+
store2.busy = true;
|
|
120
|
+
}
|
|
121
|
+
function site(store2, index) {
|
|
122
|
+
const existing = store2.slots[index];
|
|
123
|
+
if (existing !== void 0) {
|
|
124
|
+
existing.seen = store2.generation;
|
|
125
|
+
return existing;
|
|
126
|
+
}
|
|
127
|
+
const slot = { seen: store2.generation };
|
|
128
|
+
store2.slots[index] = slot;
|
|
129
|
+
return slot;
|
|
130
|
+
}
|
|
131
|
+
function open(store2, slot) {
|
|
132
|
+
const owner = createOwner(store2.owner);
|
|
133
|
+
slot.owner = owner;
|
|
134
|
+
return setOwner(owner);
|
|
135
|
+
}
|
|
136
|
+
function close(previous) {
|
|
137
|
+
setOwner(previous);
|
|
138
|
+
}
|
|
139
|
+
function ran(store2, value) {
|
|
140
|
+
devRan(store2);
|
|
141
|
+
const generation = store2.generation;
|
|
142
|
+
const slots = store2.slots;
|
|
143
|
+
for (let i = 0; i < slots.length; i++) {
|
|
144
|
+
const slot = slots[i];
|
|
145
|
+
if (slot === void 0 || slot.seen === generation) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (slot.owner !== void 0) {
|
|
149
|
+
disposeOwner(slot.owner);
|
|
150
|
+
}
|
|
151
|
+
slots[i] = void 0;
|
|
152
|
+
}
|
|
153
|
+
store2.generation = generation + 1;
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
function cell(store2, index, value) {
|
|
157
|
+
const slot = site(store2, index);
|
|
158
|
+
const existing = slot.cell;
|
|
159
|
+
if (existing === void 0) {
|
|
160
|
+
const made = signal(value);
|
|
161
|
+
slot.cell = made;
|
|
162
|
+
return made;
|
|
163
|
+
}
|
|
164
|
+
if (existing.peek() !== value) {
|
|
165
|
+
devHandedNewFunction(store2, value);
|
|
166
|
+
wrote(store2);
|
|
167
|
+
existing.value = value;
|
|
168
|
+
}
|
|
169
|
+
return existing;
|
|
170
|
+
}
|
|
171
|
+
function writeChild(store2, index, parent, marker, value) {
|
|
172
|
+
const slot = site(store2, index);
|
|
173
|
+
const type = typeof value;
|
|
174
|
+
if (type === "string" || type === "number") {
|
|
175
|
+
const text = String(value);
|
|
176
|
+
if (text === slot.text) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
wrote(store2);
|
|
180
|
+
slot.text = text;
|
|
181
|
+
slot.node = applyChild(parent, marker, slot.node ?? null, text);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
slot.text = void 0;
|
|
185
|
+
if (value === slot.last) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
wrote(store2);
|
|
189
|
+
slot.last = value;
|
|
190
|
+
slot.node = applyChild(parent, marker, slot.node ?? null, value);
|
|
191
|
+
}
|
|
78
192
|
function insert(parent, value, marker = null) {
|
|
79
193
|
if (typeof value !== "function") {
|
|
80
194
|
applyChild(parent, marker, null, value);
|
|
81
195
|
return;
|
|
82
196
|
}
|
|
83
197
|
let current = null;
|
|
198
|
+
let written;
|
|
84
199
|
bind(() => {
|
|
85
200
|
const next = value();
|
|
86
|
-
|
|
201
|
+
const type = typeof next;
|
|
202
|
+
if (type === "string" || type === "number") {
|
|
203
|
+
const text = String(next);
|
|
204
|
+
if (text !== written) {
|
|
205
|
+
written = text;
|
|
206
|
+
current = applyChild(parent, marker, current, text);
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
written = void 0;
|
|
211
|
+
if (type === "function") {
|
|
87
212
|
current = clear(current);
|
|
88
213
|
insert(parent, next, marker);
|
|
89
214
|
return;
|
|
@@ -286,17 +411,18 @@ function longestIncreasing(sources) {
|
|
|
286
411
|
|
|
287
412
|
// packages/dom/src/component.ts
|
|
288
413
|
import {
|
|
289
|
-
signal,
|
|
290
|
-
createOwner,
|
|
414
|
+
signal as signal2,
|
|
415
|
+
createOwner as createOwner2,
|
|
291
416
|
devEnterSetup,
|
|
292
417
|
devExitSetup,
|
|
293
|
-
disposeOwner,
|
|
418
|
+
disposeOwner as disposeOwner2,
|
|
294
419
|
getOwner as getOwner2,
|
|
295
420
|
handleError,
|
|
296
|
-
setOwner,
|
|
421
|
+
setOwner as setOwner2,
|
|
297
422
|
untrack
|
|
298
423
|
} from "@firsthandjs/core";
|
|
299
424
|
var COMPONENT = /* @__PURE__ */ Symbol.for("firsthand.component");
|
|
425
|
+
var VIEW = /* @__PURE__ */ Symbol.for("firsthand.view");
|
|
300
426
|
var sequence = 0;
|
|
301
427
|
var prefix = "firsthand";
|
|
302
428
|
function setElementPrefix(value) {
|
|
@@ -333,26 +459,33 @@ function component(setup, options, id, name) {
|
|
|
333
459
|
function isComponent(value) {
|
|
334
460
|
return typeof value === "function" && COMPONENT in value;
|
|
335
461
|
}
|
|
462
|
+
function view(target) {
|
|
463
|
+
target[VIEW] = true;
|
|
464
|
+
return target;
|
|
465
|
+
}
|
|
336
466
|
function createComponent(target, props) {
|
|
337
467
|
Object.freeze(props);
|
|
338
468
|
if (target.setup === void 0) {
|
|
469
|
+
if (VIEW in target) {
|
|
470
|
+
return part(() => target(props));
|
|
471
|
+
}
|
|
339
472
|
return adapt(target)(props);
|
|
340
473
|
}
|
|
341
474
|
if (target.tag !== void 0) {
|
|
342
475
|
return createHost(target, props);
|
|
343
476
|
}
|
|
344
|
-
const owner =
|
|
477
|
+
const owner = createOwner2(getOwner2());
|
|
345
478
|
devComponent(owner, target.name);
|
|
346
|
-
const previous =
|
|
479
|
+
const previous = setOwner2(owner);
|
|
347
480
|
try {
|
|
348
481
|
devEnterSetup(target.id);
|
|
349
482
|
const result = untrack(() => target.setup(props));
|
|
350
483
|
devExitSetup();
|
|
351
|
-
|
|
484
|
+
setOwner2(previous);
|
|
352
485
|
return result;
|
|
353
486
|
} catch (error) {
|
|
354
487
|
devExitSetup();
|
|
355
|
-
|
|
488
|
+
setOwner2(previous);
|
|
356
489
|
handleError(error, owner);
|
|
357
490
|
return null;
|
|
358
491
|
}
|
|
@@ -400,13 +533,13 @@ function elementClass(target) {
|
|
|
400
533
|
if (!this.$standalone || this.$owner === null) {
|
|
401
534
|
return;
|
|
402
535
|
}
|
|
403
|
-
|
|
536
|
+
disposeOwner2(this.$owner);
|
|
404
537
|
this.$owner = null;
|
|
405
538
|
}
|
|
406
539
|
attributeChangedCallback(name, _old, value) {
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
|
|
540
|
+
const cell2 = this.$attrs?.[name];
|
|
541
|
+
if (cell2 !== void 0) {
|
|
542
|
+
cell2.value = codecs[name]?.(value);
|
|
410
543
|
}
|
|
411
544
|
}
|
|
412
545
|
};
|
|
@@ -416,21 +549,21 @@ function attributeProps(element, codecs, cells) {
|
|
|
416
549
|
const props = {};
|
|
417
550
|
if (codecs !== void 0) {
|
|
418
551
|
for (const name in codecs) {
|
|
419
|
-
const
|
|
420
|
-
cells[name] =
|
|
552
|
+
const cell2 = signal2(codecs[name](element.getAttribute(name)));
|
|
553
|
+
cells[name] = cell2;
|
|
421
554
|
Object.defineProperty(props, name, {
|
|
422
555
|
enumerable: true,
|
|
423
|
-
get: () =>
|
|
556
|
+
get: () => cell2.value
|
|
424
557
|
});
|
|
425
558
|
}
|
|
426
559
|
}
|
|
427
560
|
return Object.freeze(props);
|
|
428
561
|
}
|
|
429
562
|
function mountHost(element, target, shadow) {
|
|
430
|
-
const owner =
|
|
563
|
+
const owner = createOwner2(getOwner2());
|
|
431
564
|
devComponent(owner, target.name);
|
|
432
565
|
element.$owner = owner;
|
|
433
|
-
const previous =
|
|
566
|
+
const previous = setOwner2(owner);
|
|
434
567
|
try {
|
|
435
568
|
devEnterSetup(target.id);
|
|
436
569
|
const root = shadow ? element.attachShadow({ mode: "open" }) : element;
|
|
@@ -441,7 +574,7 @@ function mountHost(element, target, shadow) {
|
|
|
441
574
|
devExitSetup();
|
|
442
575
|
handleError(error, owner);
|
|
443
576
|
} finally {
|
|
444
|
-
|
|
577
|
+
setOwner2(previous);
|
|
445
578
|
}
|
|
446
579
|
}
|
|
447
580
|
function createHost(target, props) {
|
|
@@ -454,15 +587,15 @@ function createHost(target, props) {
|
|
|
454
587
|
// packages/dom/src/list.ts
|
|
455
588
|
import {
|
|
456
589
|
batch,
|
|
457
|
-
createOwner as
|
|
458
|
-
disposeOwner as
|
|
590
|
+
createOwner as createOwner3,
|
|
591
|
+
disposeOwner as disposeOwner3,
|
|
459
592
|
getOwner as getOwner3,
|
|
460
|
-
setOwner as
|
|
461
|
-
signal as
|
|
593
|
+
setOwner as setOwner3,
|
|
594
|
+
signal as signal3,
|
|
462
595
|
untrack as untrack2
|
|
463
596
|
} from "@firsthandjs/core";
|
|
464
597
|
function list(each, keyOf, render) {
|
|
465
|
-
const host =
|
|
598
|
+
const host = createOwner3(getOwner3());
|
|
466
599
|
let rows = /* @__PURE__ */ new Map();
|
|
467
600
|
return () => {
|
|
468
601
|
const items = each();
|
|
@@ -492,7 +625,7 @@ function list(each, keyOf, render) {
|
|
|
492
625
|
}
|
|
493
626
|
}
|
|
494
627
|
for (const row of rows.values()) {
|
|
495
|
-
|
|
628
|
+
disposeOwner3(row.owner);
|
|
496
629
|
}
|
|
497
630
|
});
|
|
498
631
|
rows = next;
|
|
@@ -500,16 +633,16 @@ function list(each, keyOf, render) {
|
|
|
500
633
|
};
|
|
501
634
|
}
|
|
502
635
|
function createRow(host, item, index, render) {
|
|
503
|
-
const owner =
|
|
504
|
-
const itemCell =
|
|
505
|
-
const indexCell =
|
|
506
|
-
const previous =
|
|
636
|
+
const owner = createOwner3(host);
|
|
637
|
+
const itemCell = signal3(item);
|
|
638
|
+
const indexCell = signal3(index);
|
|
639
|
+
const previous = setOwner3(owner);
|
|
507
640
|
let result;
|
|
508
641
|
try {
|
|
509
642
|
result = untrack2(() => render(itemCell, indexCell));
|
|
510
|
-
|
|
643
|
+
setOwner3(previous);
|
|
511
644
|
} catch (error) {
|
|
512
|
-
|
|
645
|
+
setOwner3(previous);
|
|
513
646
|
throw error;
|
|
514
647
|
}
|
|
515
648
|
const nodes = [];
|
|
@@ -587,7 +720,15 @@ function dispatch(event) {
|
|
|
587
720
|
}
|
|
588
721
|
function on(node, type, handler, options) {
|
|
589
722
|
if (options !== void 0 || !DELEGATED.has(type)) {
|
|
590
|
-
|
|
723
|
+
const host = node;
|
|
724
|
+
const resolved = options === true ? void 0 : options;
|
|
725
|
+
const slot = `${key(type)}$${resolved === void 0 ? "" : Object.keys(resolved).sort().join(",")}`;
|
|
726
|
+
const previous = host[slot];
|
|
727
|
+
if (previous !== void 0) {
|
|
728
|
+
node.removeEventListener(type, previous.handler, previous.options);
|
|
729
|
+
}
|
|
730
|
+
host[slot] = { handler, options: resolved };
|
|
731
|
+
node.addEventListener(type, handler, resolved);
|
|
591
732
|
return;
|
|
592
733
|
}
|
|
593
734
|
node[key(type)] = handler;
|
|
@@ -798,13 +939,23 @@ export {
|
|
|
798
939
|
FirsthandComponentError,
|
|
799
940
|
label,
|
|
800
941
|
part,
|
|
942
|
+
store,
|
|
943
|
+
wrote,
|
|
944
|
+
site,
|
|
945
|
+
open,
|
|
946
|
+
close,
|
|
947
|
+
ran,
|
|
948
|
+
cell,
|
|
949
|
+
writeChild,
|
|
801
950
|
insert,
|
|
802
951
|
applyChild,
|
|
803
952
|
reconcile,
|
|
804
953
|
COMPONENT,
|
|
954
|
+
VIEW,
|
|
805
955
|
setElementPrefix,
|
|
806
956
|
component,
|
|
807
957
|
isComponent,
|
|
958
|
+
view,
|
|
808
959
|
createComponent,
|
|
809
960
|
defineElement,
|
|
810
961
|
list,
|
package/dist/dev.d.ts
CHANGED
|
@@ -38,4 +38,27 @@ export declare function devComponent(owner: object, name: string): void;
|
|
|
38
38
|
* emits no call to it at all.
|
|
39
39
|
*/
|
|
40
40
|
export declare function label<T>(value: T, kind: string, name: string): T;
|
|
41
|
+
/**
|
|
42
|
+
* Reports a render function that keeps running and keeps changing nothing.
|
|
43
|
+
*
|
|
44
|
+
* Nothing is optimised here and nothing is hidden: this is bookkeeping, said
|
|
45
|
+
* out loud. A run that produces exactly what is already on screen did work for
|
|
46
|
+
* no one, and the reason is always the same — it reads something in a
|
|
47
|
+
* statement that moves more often than what it shows.
|
|
48
|
+
*/
|
|
49
|
+
export declare function devRan(store: {
|
|
50
|
+
name: string;
|
|
51
|
+
busy?: boolean;
|
|
52
|
+
quiet?: number;
|
|
53
|
+
}): void;
|
|
54
|
+
/**
|
|
55
|
+
* Reports a child that is handed a new function on every run.
|
|
56
|
+
*
|
|
57
|
+
* A function made in a run is never equal to the one before it, so the child
|
|
58
|
+
* it is given to runs again every time its parent does — the `useCallback`
|
|
59
|
+
* problem, named rather than papered over.
|
|
60
|
+
*/
|
|
61
|
+
export declare function devHandedNewFunction(store: {
|
|
62
|
+
name: string;
|
|
63
|
+
}, value: unknown): void;
|
|
41
64
|
//# sourceMappingURL=dev.d.ts.map
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAID,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAK9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAWzD;AAkBD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAA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EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAUlF"}
|
package/dist/dev.prod.d.ts
CHANGED
|
@@ -5,4 +5,12 @@ export declare function devWarnRenderedObject(_value: object): void;
|
|
|
5
5
|
export declare function devPart(_node: object, _property: string): void;
|
|
6
6
|
export declare function devComponent(_owner: object, _name: string): void;
|
|
7
7
|
export declare function label<T>(value: T, _kind: string, _name: string): T;
|
|
8
|
+
export declare function devRan(_store: {
|
|
9
|
+
name: string;
|
|
10
|
+
busy?: boolean;
|
|
11
|
+
quiet?: number;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function devHandedNewFunction(_store: {
|
|
14
|
+
name: string;
|
|
15
|
+
}, _value: unknown): void;
|
|
8
16
|
//# sourceMappingURL=dev.prod.d.ts.map
|
package/dist/dev.prod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAElE"}
|
|
1
|
+
{"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAErF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAEpF"}
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkEH;;;;;;GAMG;AACH,wBAAgB,EAAE,CAChB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI,GACvC,IAAI,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkEH;;;;;;GAMG;AACH,wBAAgB,EAAE,CAChB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI,GACvC,IAAI,CA2BN;AAED,yEAAyE;AACzE,wBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED,kEAAkE;AAClE,wBAAgB,eAAe,IAAI,IAAI,CAKtC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export { component, defineElement, setElementPrefix, createComponent } from './component.js';
|
|
7
7
|
export { setComponentAdapter, FirsthandComponentError } from './adapter.js';
|
|
8
8
|
export type { ComponentAdapter } from './adapter.js';
|
|
9
|
-
export type { Component, ComponentOptions, AttributeCodec, View } from './component.js';
|
|
9
|
+
export type { Component, ComponentOptions, AttributeCodec, View, Render } from './component.js';
|
|
10
10
|
export { render } from './render.js';
|
|
11
11
|
export { portal } from './portal.js';
|
|
12
12
|
export { list } from './list.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,WAAW,EACX,OAAO,EACP,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,MAAM,GACP,MAAM,mBAAmB,CAAC"}
|
package/dist/index.dev.js
CHANGED
|
@@ -4,13 +4,14 @@ import {
|
|
|
4
4
|
component,
|
|
5
5
|
createComponent,
|
|
6
6
|
defineElement,
|
|
7
|
+
insert,
|
|
7
8
|
list,
|
|
8
9
|
mergeProps,
|
|
9
10
|
off,
|
|
10
11
|
on,
|
|
11
12
|
setComponentAdapter,
|
|
12
13
|
setElementPrefix
|
|
13
|
-
} from "./dev-chunk-
|
|
14
|
+
} from "./dev-chunk-2CKM3OGC.js";
|
|
14
15
|
|
|
15
16
|
// packages/dom/src/render.ts
|
|
16
17
|
import { createRoot, onCleanup, untrack } from "@firsthandjs/core";
|
|
@@ -18,8 +19,13 @@ function render(view, container = document.body) {
|
|
|
18
19
|
let dispose;
|
|
19
20
|
createRoot((stop) => {
|
|
20
21
|
dispose = stop;
|
|
22
|
+
const result = untrack(view);
|
|
23
|
+
if (typeof result === "function") {
|
|
24
|
+
insert(container, result);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
21
27
|
let slot = null;
|
|
22
|
-
slot = applyChild(container, null, null,
|
|
28
|
+
slot = applyChild(container, null, null, result);
|
|
23
29
|
onCleanup(() => {
|
|
24
30
|
applyChild(container, null, slot, null);
|
|
25
31
|
});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{K as h,a as s,b as f,m as i,n as p,r as m,s as a,v as c,w as u,x as C,y,z as x}from"./chunk-EWYTWH5D.js";import{createRoot as N,onCleanup as g,untrack as E}from"@firsthandjs/core";function R(e,t=document.body){let o;return N(r=>{o=r;let n=E(e);if(typeof n=="function"){i(t,n);return}let l=null;l=p(t,null,null,n),g(()=>{p(t,null,l,null)})}),o}import{onCleanup as b}from"@firsthandjs/core";function w(e,t){let o=[];d(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return b(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function d(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)d(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 G,computed as H,effect as I,batch as J,untrack as K,onCleanup as L,createRoot as M,catchError as Q,runWithOwner as U,createContext as X,provide as Y,useContext as Z,FirsthandContextError as _,FirsthandCycleError as $,FirsthandReadonlyError as v}from"@firsthandjs/core";export{f as FirsthandComponentError,_ as FirsthandContextError,$ as FirsthandCycleError,v as FirsthandReadonlyError,J as batch,Q as catchError,a as component,H as computed,c as createComponent,X as createContext,M as createRoot,u as defineElement,I as effect,C as list,h as mergeProps,x as off,y as on,L as onCleanup,w as portal,Y as provide,R as render,U as runWithOwner,s as setComponentAdapter,m as setElementPrefix,G as signal,K as untrack,Z as useContext};
|
package/dist/insert.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Owner } from '@firsthandjs/core';
|
|
1
|
+
import { type Owner, type Signal } from '@firsthandjs/core';
|
|
2
2
|
/** What a child part currently owns in the DOM. */
|
|
3
3
|
export type ChildSlot = Node | Node[] | null;
|
|
4
4
|
declare const PART: unique symbol;
|
|
@@ -24,6 +24,89 @@ export type DynamicChild = {
|
|
|
24
24
|
};
|
|
25
25
|
/** Marks a dynamic child of a fragment. Emitted by the compiler. */
|
|
26
26
|
export declare function part(thunk: () => unknown): DynamicChild;
|
|
27
|
+
/**
|
|
28
|
+
* One place a run writes to, and what it last put there.
|
|
29
|
+
*
|
|
30
|
+
* A render function runs as a whole, so the DOM it describes has to be the DOM
|
|
31
|
+
* it already made: created on the first run, written on every one after. These
|
|
32
|
+
* records are what survives between runs — the node, and the last value, so a
|
|
33
|
+
* run that produces what is already on screen writes nothing.
|
|
34
|
+
*/
|
|
35
|
+
export type Slot = {
|
|
36
|
+
/** What this site made, or what a write currently owns. */
|
|
37
|
+
node?: ChildSlot;
|
|
38
|
+
/** The last primitive written here, when the last thing written was one. */
|
|
39
|
+
text?: string | undefined;
|
|
40
|
+
/** The last value written to an attribute or a property. */
|
|
41
|
+
last?: unknown;
|
|
42
|
+
/** What the site made besides its node: parts, listeners, components. */
|
|
43
|
+
owner?: Owner;
|
|
44
|
+
/** The run that last reached this site. */
|
|
45
|
+
seen?: number;
|
|
46
|
+
/** A prop a run feeds a child, held so the child keeps its instance. */
|
|
47
|
+
cell?: Signal<unknown>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Where a run keeps its sites.
|
|
51
|
+
*
|
|
52
|
+
* One per instance, made in the setup — which runs once, so there is nothing
|
|
53
|
+
* to look up and nothing ambient. What a site makes belongs to `owner`, the
|
|
54
|
+
* component's own, rather than to the run that happened to make it: a run's
|
|
55
|
+
* scope is cleared before it runs again, and anything left there would be
|
|
56
|
+
* disposed by the second run.
|
|
57
|
+
*/
|
|
58
|
+
export type Store = {
|
|
59
|
+
slots: (Slot | undefined)[];
|
|
60
|
+
owner: Owner | null;
|
|
61
|
+
/** Which run is in progress, so that what it did not reach can be found. */
|
|
62
|
+
generation: number;
|
|
63
|
+
/** The component this belongs to, for what development has to say about it. */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Whether this run has changed anything. Development only. */
|
|
66
|
+
busy?: boolean;
|
|
67
|
+
/** How many runs in a row have changed nothing. Development only. */
|
|
68
|
+
quiet?: number;
|
|
69
|
+
};
|
|
70
|
+
/** Declared once per instance by the compiler, in the setup. */
|
|
71
|
+
export declare function store(name?: string): Store;
|
|
72
|
+
/** Notes that this run has actually changed something. */
|
|
73
|
+
export declare function wrote(store: Store): void;
|
|
74
|
+
/** The record for one site, made the first time a run reaches it. */
|
|
75
|
+
export declare function site(store: Store, index: number): Slot;
|
|
76
|
+
/**
|
|
77
|
+
* Opens a site: what it makes now belongs to the instance, not to this run.
|
|
78
|
+
*
|
|
79
|
+
* Returns the owner to restore, which the compiler hands back to `close`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function open(store: Store, slot: Slot): Owner | null;
|
|
82
|
+
export declare function close(previous: Owner | null): void;
|
|
83
|
+
/**
|
|
84
|
+
* Ends a run, and disposes what it did not reach.
|
|
85
|
+
*
|
|
86
|
+
* A branch the run has left is gone, not hidden: its components run their
|
|
87
|
+
* cleanups and its parts stop, exactly as if the markup had never been there.
|
|
88
|
+
* Coming back builds it again. That is what the control flow says, so it is
|
|
89
|
+
* what happens.
|
|
90
|
+
*/
|
|
91
|
+
export declare function ran<T>(store: Store, value: T): T;
|
|
92
|
+
/**
|
|
93
|
+
* A prop whose value belongs to the run, as something the child can hold.
|
|
94
|
+
*
|
|
95
|
+
* The child keeps its instance across runs, so its props cannot be getters
|
|
96
|
+
* over the run that made them — that value belongs to one call. It gets a cell
|
|
97
|
+
* instead, made the first time and written afterwards, so a prop that did not
|
|
98
|
+
* change wakes nothing.
|
|
99
|
+
*/
|
|
100
|
+
export declare function cell(store: Store, index: number, value: unknown): Signal<unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* Writes a child position a run owns.
|
|
103
|
+
*
|
|
104
|
+
* The same text twice is not a write: `data` would accept it, and measuring
|
|
105
|
+
* says that comparing a remembered string costs half what setting one does.
|
|
106
|
+
* Anything else goes through `applyChild`, where a node that has not moved is
|
|
107
|
+
* recognised and left where it is.
|
|
108
|
+
*/
|
|
109
|
+
export declare function writeChild(store: Store, index: number, parent: Node, marker: Node | null, value: unknown): void;
|
|
27
110
|
/**
|
|
28
111
|
* Binds a dynamic child position.
|
|
29
112
|
*
|
package/dist/insert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAG3B,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAQ7C,QAAA,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAErD;;;;;;;;;;;;;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,QAA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KAAK,GAAG,IAAI,CAI3D;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAgBhD;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAcjF;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,KAAK,EAAE,OAAO,GACb,IAAI,CAsBN;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,IAAI,GAAG,IAAW,GAAG,IAAI,CAkDrF;AAED,6EAA6E;AAC7E,wBAAgB,UAAU,CACxB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAiEX;AAmED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAqEvF"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const PROTOCOL_VERSION = 1;
|
|
13
13
|
export { template, path } from './template.js';
|
|
14
|
-
export { insert, applyChild, reconcile, part } from './insert.js';
|
|
15
|
-
export type { DynamicChild, ChildSlot } from './insert.js';
|
|
14
|
+
export { insert, applyChild, reconcile, part, store, site, open, close, ran, wrote, cell, writeChild, } from './insert.js';
|
|
15
|
+
export type { DynamicChild, ChildSlot, Slot, Store } from './insert.js';
|
|
16
16
|
export { setAttribute, setAttributeNS, setProperty, setBoolean, setClass, setClassList, setStyle, setStyleObject, } from './attributes.js';
|
|
17
17
|
export { on, off } from './events.js';
|
|
18
18
|
export { applyProp, spread, mergeProps, rest } from './props.js';
|
|
19
19
|
export { bind } from '@firsthandjs/core';
|
|
20
20
|
export { label } from './dev.js';
|
|
21
21
|
export { list } from './list.js';
|
|
22
|
-
export { createComponent, isComponent, COMPONENT } from './component.js';
|
|
22
|
+
export { createComponent, isComponent, view, COMPONENT, VIEW } from './component.js';
|
|
23
23
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/internal.dev.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPONENT,
|
|
3
|
+
VIEW,
|
|
3
4
|
applyChild,
|
|
4
5
|
applyProp,
|
|
6
|
+
cell,
|
|
7
|
+
close,
|
|
5
8
|
createComponent,
|
|
6
9
|
insert,
|
|
7
10
|
isComponent,
|
|
@@ -10,7 +13,9 @@ import {
|
|
|
10
13
|
mergeProps,
|
|
11
14
|
off,
|
|
12
15
|
on,
|
|
16
|
+
open,
|
|
13
17
|
part,
|
|
18
|
+
ran,
|
|
14
19
|
reconcile,
|
|
15
20
|
rest,
|
|
16
21
|
setAttribute,
|
|
@@ -21,8 +26,13 @@ import {
|
|
|
21
26
|
setProperty,
|
|
22
27
|
setStyle,
|
|
23
28
|
setStyleObject,
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
site,
|
|
30
|
+
spread,
|
|
31
|
+
store,
|
|
32
|
+
view,
|
|
33
|
+
writeChild,
|
|
34
|
+
wrote
|
|
35
|
+
} from "./dev-chunk-2CKM3OGC.js";
|
|
26
36
|
|
|
27
37
|
// packages/dom/src/template.ts
|
|
28
38
|
function template(html, isFragment = false) {
|
|
@@ -54,9 +64,12 @@ var PROTOCOL_VERSION = 1;
|
|
|
54
64
|
export {
|
|
55
65
|
COMPONENT,
|
|
56
66
|
PROTOCOL_VERSION,
|
|
67
|
+
VIEW,
|
|
57
68
|
applyChild,
|
|
58
69
|
applyProp,
|
|
59
70
|
bind,
|
|
71
|
+
cell,
|
|
72
|
+
close,
|
|
60
73
|
createComponent,
|
|
61
74
|
insert,
|
|
62
75
|
isComponent,
|
|
@@ -65,8 +78,10 @@ export {
|
|
|
65
78
|
mergeProps,
|
|
66
79
|
off,
|
|
67
80
|
on,
|
|
81
|
+
open,
|
|
68
82
|
part,
|
|
69
83
|
path,
|
|
84
|
+
ran,
|
|
70
85
|
reconcile,
|
|
71
86
|
rest,
|
|
72
87
|
setAttribute,
|
|
@@ -77,6 +92,11 @@ export {
|
|
|
77
92
|
setProperty,
|
|
78
93
|
setStyle,
|
|
79
94
|
setStyleObject,
|
|
95
|
+
site,
|
|
80
96
|
spread,
|
|
81
|
-
|
|
97
|
+
store,
|
|
98
|
+
template,
|
|
99
|
+
view,
|
|
100
|
+
writeChild,
|
|
101
|
+
wrote
|
|
82
102
|
};
|
package/dist/internal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as w,B as L,C as j,D as A,E as F,F as I,G as M,H as R,I as V,J as v,K as B,L as D,c as p,d as s,e as i,f as a,g as m,h as d,i as f,j as c,k as x,l as u,m as C,n as N,o as y,p as h,q as b,t as S,u as O,v as P,x as T,y as g,z as E}from"./chunk-EWYTWH5D.js";function H(r,o=!1){let e;return()=>{if(e===void 0){let t=document.createElement("template");t.innerHTML=r,e=o?t.content:t.content.firstChild}return e.cloneNode(!0)}}function W(r,...o){let e=r;for(let t=0;t<o.length;t++){let n=e.firstChild;for(let l=o[t];l>0;l--)n=n.nextSibling;e=n}return e}import{bind as X}from"@firsthandjs/core";var k=1;export{h as COMPONENT,k as PROTOCOL_VERSION,b as VIEW,N as applyChild,V as applyProp,X as bind,x as cell,f as close,P as createComponent,C as insert,S as isComponent,p as label,T as list,B as mergeProps,E as off,g as on,d as open,s as part,W as path,c as ran,y as reconcile,D as rest,w as setAttribute,L as setAttributeNS,A as setBoolean,F as setClass,I as setClassList,j as setProperty,M as setStyle,R as setStyleObject,m as site,v as spread,i as store,H as template,O as view,u as writeChild,a as wrote};
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,CAmBvF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/dom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "DOM parts, templates, components, portals and keyed lists for Firsthand.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"LICENSE"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@firsthandjs/core": "0.
|
|
28
|
+
"@firsthandjs/core": "0.8.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=20.11.0"
|
package/dist/chunk-QZ5SESOU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var C=null,x=new WeakMap;function jn(n){C=n,x=new WeakMap}var E=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 T(n){let e=x.get(n);if(e!==void 0)return e;if(C===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new E(o)}let t=C(n);return x.set(n,t),t}function Hn(n,e,t){return n}import{bind as dn,getOwner as L,onCleanup as un,runWithOwner as cn}from"@firsthandjs/core";var an=3;function H(n){return typeof n.nodeType=="number"}var D=Symbol("firsthand.part");function In(n){return{[D]:!0,anchor:document.createTextNode(""),thunk:n,owner:L()}}function W(n){return D in n}function _(n,e,t=null){if(typeof e!="function"){p(n,t,null,e);return}let o=null;dn(()=>{let r=e();if(typeof r=="function"){o=w(o),_(n,r,t);return}o=p(n,t,o,r)}),un(()=>{o=w(o)})}function p(n,e,t,o){let r=typeof o;if(o==null||r==="boolean")return w(t);if(r==="string"||r==="number"){let i=String(o);return t!==null&&!Array.isArray(t)&&t.nodeType===an?(t.data=i,t):j(n,e,t,document.createTextNode(i))}if(r==="function")return p(n,e,t,o());if(Array.isArray(o)){let i=[],s=[];if(M(o,i,s),i.length===0)return w(t);fn(n,e,t===null?[]:Array.isArray(t)?t:[t],i);for(let d=0;d<s.length;d++){let l=s[d];cn(l.owner??L(),()=>{_(n,l.thunk,l.anchor)})}return i}return W(o)?p(n,e,t,[o]):H(o)?j(n,e,t,o):p(n,e,t,String(o))}function M(n,e,t){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&W(r)){e.push(r.anchor),t.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?M(r,e,t):typeof r=="object"&&H(r)?e.push(r):e.push(document.createTextNode(String(r))))}}function $(n){let e=n.parentNode;e!==null&&e.removeChild(n)}function w(n){if(n!==null)if(Array.isArray(n))for(let e=0;e<n.length;e++)$(n[e]);else $(n);return null}function j(n,e,t,o){return t===o?o:t!==null&&!Array.isArray(t)?(n.replaceChild(o,t),o):(w(t),n.insertBefore(o,e),o)}function fn(n,e,t,o){let r=0,i=0,s=t.length-1,d=o.length-1;for(;r<=s&&i<=d&&t[r]===o[i];)r++,i++;for(;r<=s&&i<=d&&t[s]===o[d];)s--,d--;let l=d+1<o.length?o[d+1]:e;if(r>s){for(let u=i;u<=d;u++)n.insertBefore(o[u],l);return}if(i>d){for(let u=r;u<=s;u++)n.removeChild(t[u]);return}let c=new Map;for(let u=r;u<=s;u++)c.set(t[u],u);let a=d-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let g=o[i+u],O=c.get(g);O!==void 0&&(f[u]=O,c.delete(g))}for(let u of c.keys())n.removeChild(u);let m=pn(f),k=m.length-1,v=l;for(let u=a-1;u>=0;u--){let g=o[i+u];k>=0&&m[k]===u?k--:n.insertBefore(g,v),v=g}}function pn(n){let e=n.length,t=new Int32Array(e).fill(-1),o=[];for(let s=0;s<e;s++){let d=n[s];if(d===-1)continue;let l=0,c=o.length;for(;l<c;){let a=l+c>>1;n[o[a]]<d?l=a+1:c=a}l>0&&(t[s]=o[l-1]),o[l]=s}let r=[],i=o.length>0?o[o.length-1]:-1;for(;i!==-1;)r.push(i),i=t[i];return r.reverse()}import{signal as mn,createOwner as I,devEnterSetup as F,devExitSetup as h,disposeOwner as gn,getOwner as V,handleError as z,setOwner as y,untrack as B}from"@firsthandjs/core";var K=Symbol.for("firsthand.component"),wn=0,Z="firsthand";function Yn(n){Z=n}function Gn(n,e,t,o){let i=Object.assign(s=>yn(i,s),{[K]:!0,setup:n,options:e,id:t??`c${String(++wn)}`,tag:void 0});return Object.defineProperty(i,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),t===void 0&&(`${i.name}`,void 0),(e?.tag!==void 0||e?.shadow===!0)&&bn(i,typeof e.tag=="string"?e.tag:void 0),i}function Xn(n){return typeof n=="function"&&K in n}function yn(n,e){if(Object.freeze(e),n.setup===void 0)return T(n)(e);if(n.tag!==void 0)return xn(n,e);let t=I(V());n.name;let o=y(t);try{F(n.id);let r=B(()=>n.setup(e));return h(),y(o),r}catch(r){return h(),y(o),z(r,t),null}}function hn(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 bn(n,e){let t=n;if(t.tag!==void 0)return t.tag;let o=e??hn(t);return customElements.get(o)!==void 0&&(o=`${o}-${t.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),t.tag=o,customElements.define(o,kn(t)),o}function kn(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=Cn(this,t,this.$attrs),q(this,n,e))}disconnectedCallback(){!this.$standalone||this.$owner===null||(gn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,d){let l=this.$attrs?.[i];l!==void 0&&(l.value=t[i]?.(d))}}}function Cn(n,e,t){let o={};if(e!==void 0)for(let r in e){let i=mn(e[r](n.getAttribute(r)));t[r]=i,Object.defineProperty(o,r,{enumerable:!0,get:()=>i.value})}return Object.freeze(o)}function q(n,e,t){let o=I(V());e.name,n.$owner=o;let r=y(o);try{F(e.id);let i=t?n.attachShadow({mode:"open"}):n,s=B(()=>e.setup(n.$props));h(),p(i,null,null,s)}catch(i){h(),z(i,o)}finally{y(r)}}function xn(n,e){let t=document.createElement(n.tag);return t.$props=e,q(t,n,n.options?.shadow===!0),t}import{batch as En,createOwner as G,disposeOwner as Rn,getOwner as Nn,setOwner as R,signal as Y,untrack as X}from"@firsthandjs/core";function te(n,e,t){let o=G(Nn()),r=new Map;return()=>{let i=n(),s=new Map,d=[];return En(()=>{for(let l=0;l<i.length;l++){let c=i[l],a=X(()=>e(c,l));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=Pn(o,c,l,t):(r.delete(a),f.item.value=c,f.index.value=l),s.set(a,f);for(let m=0;m<f.nodes.length;m++)d.push(f.nodes[m])}for(let l of r.values())Rn(l.owner)}),r=s,d}}function Pn(n,e,t,o){let r=G(n),i=Y(e),s=Y(t),d=R(r),l;try{l=X(()=>o(i,s)),R(d)}catch(a){throw R(d),a}let c=[];return J(l,c),{owner:r,item:i,index:s,nodes:c}}function J(n,e){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let t=0;t<n.length;t++)J(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"]),Q=new Set;function N(n){return`$firsthand$${n}`}function Sn(n){let e=N(n.type),t=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<t.length;r++){let i=t[r],s=i[e];if(s!==void 0&&(o=i,s.call(i,n),n.cancelBubble)||i===document)break}o=null}function b(n,e,t,o){if(o!==void 0||!An.has(e)){n.addEventListener(e,t,o===!0?void 0:o);return}n[N(e)]=t,Q.has(e)||(Q.add(e),document.addEventListener(e,Sn))}function re(n,e){n[N(e)]=void 0}var vn={class:"className",for:"htmlFor"};function A(n,e,t){t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,t===!0?"":String(t))}function le(n,e,t,o){o==null||o===!1?n.removeAttributeNS(e,t):n.setAttributeNS(e,t,o===!0?"":String(o))}function S(n,e,t){n[vn[e]??e]=t}function de(n,e,t){n[e]=!!t}function nn(n,e){e==null?n.removeAttribute("class"):n.className=String(e)}function en(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 i=!!e[r];(t===void 0||!!t[r]!==i)&&o.toggle(r,i)}}function tn(n,e){e==null?n.style.cssText="":n.style.cssText=String(e)}function on(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 i=e[r];(t===void 0||t[r]!==i)&&(i==null?o.removeProperty(P(r)):o.setProperty(P(r),String(i)))}}var On=/[A-Z]/g,U=new Map;function P(n){let e=U.get(n);return e===void 0&&(e=n.startsWith("--")?n:n.replace(On,t=>`-${t.toLowerCase()}`),U.set(n,e)),e}function Tn(n,e,t){if(e==="class"||e==="className"){t!==null&&typeof t=="object"?en(n,t,sn(n,"class",t)):nn(n,t);return}if(e==="style"){t!==null&&typeof t=="object"?on(n,t,sn(n,"style",t)):tn(n,t);return}if(e==="ref"){t(n);return}if(e.startsWith("prop:")){S(n,e.slice(5),t);return}if(e.startsWith("attr:")){A(n,e.slice(5),t);return}if(e.startsWith("on")&&e.length>2&&/[A-Z:]/.test(e[2])){$n(n,e,t);return}if(e in n&&typeof t!="string"){S(n,e,t);return}A(n,e,t)}function $n(n,e,t){let o=e.slice(2).split(":"),r=o[0]==="",i=r?o[1]:o[0].toLowerCase(),s=o[r?2:1];s===void 0?b(n,i,t):s==="native"?b(n,i,t,!0):b(n,i,t,{[s]:!0})}function fe(n,e){for(let t in e)t!=="children"&&Tn(n,t,e[t])}function pe(...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 me(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 rn=new WeakMap;function sn(n,e,t){let o=rn.get(n);o===void 0&&(o={},rn.set(n,o));let r=o[e];return o[e]=t,r}export{jn as a,E as b,Hn as c,In as d,_ as e,p as f,fn as g,K as h,Yn as i,Gn as j,Xn as k,yn as l,bn as m,te as n,b as o,re as p,A as q,le as r,S as s,de as t,nn as u,en as v,tn as w,on as x,Tn as y,fe as z,pe as A,me as B};
|