@firsthandjs/dom 0.3.0 → 0.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAM9E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAM5F;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE7E;AAED,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE5E;AAED,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC5C,IAAI,CAeN;AAED,2BAA2B;AAC3B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,M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,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EACzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,SAAS,GACvE,IAAI,CAmBN"}
@@ -0,0 +1 @@
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};
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,oFAAoF;AACpF,eAAO,MAAM,SAAS,EAAE,OAAO,MAA0C,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACvD;AAED,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,IAAI,GACd,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IAAI,EAAE,CAAC;AAEvF;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,C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+ function setComponentAdapter(next) {
5
+ adapter = next;
6
+ adapted = /* @__PURE__ */ new WeakMap();
7
+ }
8
+ var FirsthandComponentError = class extends Error {
9
+ constructor(name) {
10
+ super(
11
+ `${name} 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().`
12
+ );
13
+ this.name = "FirsthandComponentError";
14
+ }
15
+ };
16
+ function adapt(target) {
17
+ const existing = adapted.get(target);
18
+ if (existing !== void 0) {
19
+ return existing;
20
+ }
21
+ if (adapter === null) {
22
+ const name = typeof target === "function" && target.name !== "" ? target.name : "The value";
23
+ throw new FirsthandComponentError(name);
24
+ }
25
+ const component_ = adapter(target);
26
+ adapted.set(target, component_);
27
+ return component_;
28
+ }
29
+
30
+ // packages/dom/src/dev.ts
31
+ function devWarn(message) {
32
+ console.warn(`[firsthand] ${message}`);
33
+ }
34
+ var seen = /* @__PURE__ */ new Set();
35
+ function devWarnOnce(key2, message) {
36
+ if (!seen.has(key2)) {
37
+ seen.add(key2);
38
+ devWarn(message);
39
+ }
40
+ }
41
+ function devWarnRenderedObject(value) {
42
+ const cellish = "peek" in value && typeof value.peek === "function" && "value" in value;
43
+ devWarnOnce(
44
+ cellish ? "rendered-cell" : "rendered-object",
45
+ cellish ? 'A signal or computed was rendered directly, so the page shows "[object Object]". Read it instead: {count.value} rather than {count}.' : `An object was rendered as text, so the page shows "${String(value)}". Render a string, a number or a node.`
46
+ );
47
+ }
48
+ function hook() {
49
+ const installed2 = globalThis.__FIRSTHAND_DEVTOOLS__;
50
+ return installed2 !== void 0 && installed2.attached ? installed2 : void 0;
51
+ }
52
+ function devPart(node, property) {
53
+ hook()?.part(node, property);
54
+ }
55
+ function devComponent(owner, name) {
56
+ hook()?.component(owner, name);
57
+ }
58
+ function label(value, kind, name) {
59
+ if (typeof value === "object" && value !== null) {
60
+ hook()?.label(value, kind, name);
61
+ }
62
+ return value;
63
+ }
64
+
65
+ // packages/dom/src/insert.ts
66
+ import { bind, getOwner, onCleanup, runWithOwner } from "@firsthandjs/core";
67
+ var TEXT_NODE = 3;
68
+ function isNode(value) {
69
+ return typeof value.nodeType === "number";
70
+ }
71
+ var PART = /* @__PURE__ */ Symbol("firsthand.part");
72
+ function part(thunk) {
73
+ return { [PART]: true, anchor: document.createTextNode(""), thunk, owner: getOwner() };
74
+ }
75
+ function isDynamicChild(value) {
76
+ return PART in value;
77
+ }
78
+ function insert(parent, value, marker = null) {
79
+ if (typeof value !== "function") {
80
+ applyChild(parent, marker, null, value);
81
+ return;
82
+ }
83
+ let current = null;
84
+ bind(() => {
85
+ const next = value();
86
+ if (typeof next === "function") {
87
+ current = clear(current);
88
+ insert(parent, next, marker);
89
+ return;
90
+ }
91
+ current = applyChild(parent, marker, current, next);
92
+ });
93
+ onCleanup(() => {
94
+ current = clear(current);
95
+ });
96
+ }
97
+ function applyChild(parent, marker, current, value) {
98
+ const type = typeof value;
99
+ if (value == null || type === "boolean") {
100
+ devPart(parent, "text");
101
+ return clear(current);
102
+ }
103
+ if (type === "string" || type === "number") {
104
+ devPart(parent, "text");
105
+ const text = String(value);
106
+ if (current !== null && !Array.isArray(current) && current.nodeType === TEXT_NODE) {
107
+ current.data = text;
108
+ return current;
109
+ }
110
+ return single(parent, marker, current, document.createTextNode(text));
111
+ }
112
+ if (type === "function") {
113
+ return applyChild(parent, marker, current, value());
114
+ }
115
+ if (Array.isArray(value)) {
116
+ const next = [];
117
+ const dynamic = [];
118
+ flatten(value, next, dynamic);
119
+ if (next.length === 0) {
120
+ return clear(current);
121
+ }
122
+ reconcile(
123
+ parent,
124
+ marker,
125
+ current === null ? [] : Array.isArray(current) ? current : [current],
126
+ next
127
+ );
128
+ for (let i = 0; i < dynamic.length; i++) {
129
+ const child = dynamic[i];
130
+ runWithOwner(child.owner ?? getOwner(), () => {
131
+ insert(parent, child.thunk, child.anchor);
132
+ });
133
+ }
134
+ return next;
135
+ }
136
+ if (isDynamicChild(value)) {
137
+ return applyChild(parent, marker, current, [value]);
138
+ }
139
+ if (isNode(value)) {
140
+ return single(parent, marker, current, value);
141
+ }
142
+ devWarnRenderedObject(value);
143
+ return applyChild(parent, marker, current, String(value));
144
+ }
145
+ function flatten(value, out, dynamic) {
146
+ for (let i = 0; i < value.length; i++) {
147
+ let item = value[i];
148
+ if (typeof item === "object" && item !== null && isDynamicChild(item)) {
149
+ out.push(item.anchor);
150
+ dynamic.push(item);
151
+ continue;
152
+ }
153
+ while (typeof item === "function") {
154
+ item = item();
155
+ }
156
+ if (item == null || typeof item === "boolean") {
157
+ continue;
158
+ }
159
+ if (Array.isArray(item)) {
160
+ flatten(item, out, dynamic);
161
+ } else if (typeof item === "object" && isNode(item)) {
162
+ out.push(item);
163
+ } else {
164
+ out.push(document.createTextNode(String(item)));
165
+ }
166
+ }
167
+ }
168
+ function detach(node) {
169
+ const owner = node.parentNode;
170
+ if (owner !== null) {
171
+ owner.removeChild(node);
172
+ }
173
+ }
174
+ function clear(current) {
175
+ if (current !== null) {
176
+ if (Array.isArray(current)) {
177
+ for (let i = 0; i < current.length; i++) {
178
+ detach(current[i]);
179
+ }
180
+ } else {
181
+ detach(current);
182
+ }
183
+ }
184
+ return null;
185
+ }
186
+ function single(parent, marker, current, node) {
187
+ if (current === node) {
188
+ return node;
189
+ }
190
+ if (current !== null && !Array.isArray(current)) {
191
+ parent.replaceChild(node, current);
192
+ return node;
193
+ }
194
+ clear(current);
195
+ parent.insertBefore(node, marker);
196
+ return node;
197
+ }
198
+ function reconcile(parent, marker, a, b) {
199
+ let aStart = 0;
200
+ let bStart = 0;
201
+ let aEnd = a.length - 1;
202
+ let bEnd = b.length - 1;
203
+ while (aStart <= aEnd && bStart <= bEnd && a[aStart] === b[bStart]) {
204
+ aStart++;
205
+ bStart++;
206
+ }
207
+ while (aStart <= aEnd && bStart <= bEnd && a[aEnd] === b[bEnd]) {
208
+ aEnd--;
209
+ bEnd--;
210
+ }
211
+ const after = bEnd + 1 < b.length ? b[bEnd + 1] : marker;
212
+ if (aStart > aEnd) {
213
+ for (let i = bStart; i <= bEnd; i++) {
214
+ parent.insertBefore(b[i], after);
215
+ }
216
+ return;
217
+ }
218
+ if (bStart > bEnd) {
219
+ for (let i = aStart; i <= aEnd; i++) {
220
+ parent.removeChild(a[i]);
221
+ }
222
+ return;
223
+ }
224
+ const oldIndex = /* @__PURE__ */ new Map();
225
+ for (let i = aStart; i <= aEnd; i++) {
226
+ oldIndex.set(a[i], i);
227
+ }
228
+ const middle = bEnd - bStart + 1;
229
+ const sources = new Int32Array(middle).fill(-1);
230
+ for (let j = 0; j < middle; j++) {
231
+ const node = b[bStart + j];
232
+ const found = oldIndex.get(node);
233
+ if (found !== void 0) {
234
+ sources[j] = found;
235
+ oldIndex.delete(node);
236
+ }
237
+ }
238
+ for (const node of oldIndex.keys()) {
239
+ parent.removeChild(node);
240
+ }
241
+ const keep = longestIncreasing(sources);
242
+ let k = keep.length - 1;
243
+ let anchor = after;
244
+ for (let j = middle - 1; j >= 0; j--) {
245
+ const node = b[bStart + j];
246
+ if (k >= 0 && keep[k] === j) {
247
+ k--;
248
+ } else {
249
+ parent.insertBefore(node, anchor);
250
+ }
251
+ anchor = node;
252
+ }
253
+ }
254
+ function longestIncreasing(sources) {
255
+ const length = sources.length;
256
+ const predecessor = new Int32Array(length).fill(-1);
257
+ const tails = [];
258
+ for (let i = 0; i < length; i++) {
259
+ const value = sources[i];
260
+ if (value === -1) {
261
+ continue;
262
+ }
263
+ let low = 0;
264
+ let high = tails.length;
265
+ while (low < high) {
266
+ const mid = low + high >> 1;
267
+ if (sources[tails[mid]] < value) {
268
+ low = mid + 1;
269
+ } else {
270
+ high = mid;
271
+ }
272
+ }
273
+ if (low > 0) {
274
+ predecessor[i] = tails[low - 1];
275
+ }
276
+ tails[low] = i;
277
+ }
278
+ const result = [];
279
+ let cursor = tails.length > 0 ? tails[tails.length - 1] : -1;
280
+ while (cursor !== -1) {
281
+ result.push(cursor);
282
+ cursor = predecessor[cursor];
283
+ }
284
+ return result.reverse();
285
+ }
286
+
287
+ // packages/dom/src/component.ts
288
+ import {
289
+ signal,
290
+ createOwner,
291
+ devEnterSetup,
292
+ devExitSetup,
293
+ disposeOwner,
294
+ getOwner as getOwner2,
295
+ handleError,
296
+ setOwner,
297
+ untrack
298
+ } from "@firsthandjs/core";
299
+ var COMPONENT = /* @__PURE__ */ Symbol.for("firsthand.component");
300
+ var sequence = 0;
301
+ var prefix = "firsthand";
302
+ function setElementPrefix(value) {
303
+ prefix = value;
304
+ }
305
+ function component(setup, options, id, name) {
306
+ const instantiate = (props) => (
307
+ // The relaxation is in the signature only: the object itself is the
308
+ // caller's, and `P` is what the setup function sees.
309
+ createComponent(declared, props)
310
+ );
311
+ const declared = Object.assign(instantiate, {
312
+ [COMPONENT]: true,
313
+ setup,
314
+ options,
315
+ id: id ?? `c${String(++sequence)}`,
316
+ tag: void 0
317
+ });
318
+ Object.defineProperty(declared, "name", {
319
+ configurable: true,
320
+ value: name ?? (setup.name === "" ? "Component" : setup.name)
321
+ });
322
+ if (id === void 0) {
323
+ devWarnOnce(
324
+ "no-compiler",
325
+ `${declared.name} was declared without the Firsthand compiler, so component ids are generated at runtime and are not stable across builds. Element names and devtools labels degrade.`
326
+ );
327
+ }
328
+ if (options?.tag !== void 0 || options?.shadow === true) {
329
+ defineElement(declared, typeof options.tag === "string" ? options.tag : void 0);
330
+ }
331
+ return declared;
332
+ }
333
+ function isComponent(value) {
334
+ return typeof value === "function" && COMPONENT in value;
335
+ }
336
+ function createComponent(target, props) {
337
+ Object.freeze(props);
338
+ if (target.setup === void 0) {
339
+ return adapt(target)(props);
340
+ }
341
+ if (target.tag !== void 0) {
342
+ return createHost(target, props);
343
+ }
344
+ const owner = createOwner(getOwner2());
345
+ devComponent(owner, target.name);
346
+ const previous = setOwner(owner);
347
+ try {
348
+ devEnterSetup(target.id);
349
+ const result = untrack(() => target.setup(props));
350
+ devExitSetup();
351
+ setOwner(previous);
352
+ return result;
353
+ } catch (error) {
354
+ devExitSetup();
355
+ setOwner(previous);
356
+ handleError(error, owner);
357
+ return null;
358
+ }
359
+ }
360
+ function tagNameFor(target) {
361
+ const base = target.name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
362
+ return `${prefix}-${base}`;
363
+ }
364
+ function defineElement(target, tag) {
365
+ const declared = target;
366
+ if (declared.tag !== void 0) {
367
+ return declared.tag;
368
+ }
369
+ let name = tag ?? tagNameFor(declared);
370
+ if (customElements.get(name) !== void 0) {
371
+ name = `${name}-${declared.id.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()}`;
372
+ }
373
+ declared.tag = name;
374
+ customElements.define(name, elementClass(declared));
375
+ return name;
376
+ }
377
+ function elementClass(target) {
378
+ const shadow = target.options?.shadow === true;
379
+ const codecs = target.options?.attributes;
380
+ const observed = codecs !== void 0 ? Object.keys(codecs) : [];
381
+ const ctor = class extends HTMLElement {
382
+ static observedAttributes = observed;
383
+ constructor() {
384
+ super();
385
+ this.$owner = null;
386
+ this.$props = null;
387
+ this.$attrs = null;
388
+ this.$standalone = false;
389
+ }
390
+ connectedCallback() {
391
+ if (this.$owner !== null) {
392
+ return;
393
+ }
394
+ this.$standalone = true;
395
+ this.$attrs = {};
396
+ this.$props = attributeProps(this, codecs, this.$attrs);
397
+ mountHost(this, target, shadow);
398
+ }
399
+ disconnectedCallback() {
400
+ if (!this.$standalone || this.$owner === null) {
401
+ return;
402
+ }
403
+ disposeOwner(this.$owner);
404
+ this.$owner = null;
405
+ }
406
+ attributeChangedCallback(name, _old, value) {
407
+ const cell = this.$attrs?.[name];
408
+ if (cell !== void 0) {
409
+ cell.value = codecs[name]?.(value);
410
+ }
411
+ }
412
+ };
413
+ return ctor;
414
+ }
415
+ function attributeProps(element, codecs, cells) {
416
+ const props = {};
417
+ if (codecs !== void 0) {
418
+ for (const name in codecs) {
419
+ const cell = signal(codecs[name](element.getAttribute(name)));
420
+ cells[name] = cell;
421
+ Object.defineProperty(props, name, {
422
+ enumerable: true,
423
+ get: () => cell.value
424
+ });
425
+ }
426
+ }
427
+ return Object.freeze(props);
428
+ }
429
+ function mountHost(element, target, shadow) {
430
+ const owner = createOwner(getOwner2());
431
+ devComponent(owner, target.name);
432
+ element.$owner = owner;
433
+ const previous = setOwner(owner);
434
+ try {
435
+ devEnterSetup(target.id);
436
+ const root = shadow ? element.attachShadow({ mode: "open" }) : element;
437
+ const result = untrack(() => target.setup(element.$props));
438
+ devExitSetup();
439
+ applyChild(root, null, null, result);
440
+ } catch (error) {
441
+ devExitSetup();
442
+ handleError(error, owner);
443
+ } finally {
444
+ setOwner(previous);
445
+ }
446
+ }
447
+ function createHost(target, props) {
448
+ const element = document.createElement(target.tag);
449
+ element.$props = props;
450
+ mountHost(element, target, target.options?.shadow === true);
451
+ return element;
452
+ }
453
+
454
+ // packages/dom/src/list.ts
455
+ import {
456
+ batch,
457
+ createOwner as createOwner2,
458
+ disposeOwner as disposeOwner2,
459
+ getOwner as getOwner3,
460
+ setOwner as setOwner2,
461
+ signal as signal2,
462
+ untrack as untrack2
463
+ } from "@firsthandjs/core";
464
+ function list(each, keyOf, render) {
465
+ const host = createOwner2(getOwner3());
466
+ let rows = /* @__PURE__ */ new Map();
467
+ return () => {
468
+ const items = each();
469
+ const next = /* @__PURE__ */ new Map();
470
+ const nodes = [];
471
+ batch(() => {
472
+ for (let i = 0; i < items.length; i++) {
473
+ const item = items[i];
474
+ const key2 = untrack2(() => keyOf(item, i));
475
+ if (next.has(key2)) {
476
+ devWarn(
477
+ `Duplicate list key ${String(key2)}. Keys must be unique, or rows will be dropped.`
478
+ );
479
+ continue;
480
+ }
481
+ let row = rows.get(key2);
482
+ if (row === void 0) {
483
+ row = createRow(host, item, i, render);
484
+ } else {
485
+ rows.delete(key2);
486
+ row.item.value = item;
487
+ row.index.value = i;
488
+ }
489
+ next.set(key2, row);
490
+ for (let n = 0; n < row.nodes.length; n++) {
491
+ nodes.push(row.nodes[n]);
492
+ }
493
+ }
494
+ for (const row of rows.values()) {
495
+ disposeOwner2(row.owner);
496
+ }
497
+ });
498
+ rows = next;
499
+ return nodes;
500
+ };
501
+ }
502
+ function createRow(host, item, index, render) {
503
+ const owner = createOwner2(host);
504
+ const itemCell = signal2(item);
505
+ const indexCell = signal2(index);
506
+ const previous = setOwner2(owner);
507
+ let result;
508
+ try {
509
+ result = untrack2(() => render(itemCell, indexCell));
510
+ setOwner2(previous);
511
+ } catch (error) {
512
+ setOwner2(previous);
513
+ throw error;
514
+ }
515
+ const nodes = [];
516
+ collect(result, nodes);
517
+ return { owner, item: itemCell, index: indexCell, nodes };
518
+ }
519
+ function collect(value, out) {
520
+ if (value == null || typeof value === "boolean") {
521
+ return;
522
+ }
523
+ if (Array.isArray(value)) {
524
+ for (let i = 0; i < value.length; i++) {
525
+ collect(value[i], out);
526
+ }
527
+ return;
528
+ }
529
+ if (typeof value === "object" && typeof value.nodeType === "number") {
530
+ out.push(value);
531
+ return;
532
+ }
533
+ out.push(document.createTextNode(String(value)));
534
+ }
535
+
536
+ // packages/dom/src/events.ts
537
+ var DELEGATED = /* @__PURE__ */ new Set([
538
+ "click",
539
+ "dblclick",
540
+ "contextmenu",
541
+ "input",
542
+ "beforeinput",
543
+ "change",
544
+ "keydown",
545
+ "keyup",
546
+ "keypress",
547
+ "pointerdown",
548
+ "pointerup",
549
+ "pointermove",
550
+ "mousedown",
551
+ "mouseup",
552
+ "mouseover",
553
+ "mouseout",
554
+ "submit",
555
+ "focusin",
556
+ "focusout",
557
+ "touchstart",
558
+ "touchend"
559
+ ]);
560
+ var installed = /* @__PURE__ */ new Set();
561
+ function key(type) {
562
+ return `$firsthand$${type}`;
563
+ }
564
+ function dispatch(event) {
565
+ const name = key(event.type);
566
+ const path = event.composedPath();
567
+ let current = null;
568
+ Object.defineProperty(event, "currentTarget", {
569
+ configurable: true,
570
+ get: () => current
571
+ });
572
+ for (let i = 0; i < path.length; i++) {
573
+ const node = path[i];
574
+ const handler = node[name];
575
+ if (handler !== void 0) {
576
+ current = node;
577
+ handler.call(node, event);
578
+ if (event.cancelBubble) {
579
+ break;
580
+ }
581
+ }
582
+ if (node === document) {
583
+ break;
584
+ }
585
+ }
586
+ current = null;
587
+ }
588
+ function on(node, type, handler, options) {
589
+ if (options !== void 0 || !DELEGATED.has(type)) {
590
+ node.addEventListener(type, handler, options === true ? void 0 : options);
591
+ return;
592
+ }
593
+ node[key(type)] = handler;
594
+ if (!installed.has(type)) {
595
+ installed.add(type);
596
+ document.addEventListener(type, dispatch);
597
+ }
598
+ }
599
+ function off(node, type) {
600
+ node[key(type)] = void 0;
601
+ }
602
+
603
+ // packages/dom/src/attributes.ts
604
+ var PROPERTY_ALIASES = {
605
+ class: "className",
606
+ for: "htmlFor"
607
+ };
608
+ function setAttribute(node, name, value) {
609
+ devPart(node, name);
610
+ if (value == null || value === false) {
611
+ node.removeAttribute(name);
612
+ } else {
613
+ node.setAttribute(name, value === true ? "" : String(value));
614
+ }
615
+ }
616
+ function setAttributeNS(node, ns, name, value) {
617
+ devPart(node, name);
618
+ if (value == null || value === false) {
619
+ node.removeAttributeNS(ns, name);
620
+ } else {
621
+ node.setAttributeNS(ns, name, value === true ? "" : String(value));
622
+ }
623
+ }
624
+ function setProperty(node, name, value) {
625
+ devPart(node, name);
626
+ node[PROPERTY_ALIASES[name] ?? name] = value;
627
+ }
628
+ function setBoolean(node, name, value) {
629
+ devPart(node, name);
630
+ node[name] = !!value;
631
+ }
632
+ function setClass(node, value) {
633
+ devPart(node, "class");
634
+ if (value == null) {
635
+ node.removeAttribute("class");
636
+ } else {
637
+ node.className = String(value);
638
+ }
639
+ }
640
+ function setClassList(node, value, previous) {
641
+ const list2 = node.classList;
642
+ if (previous !== void 0) {
643
+ for (const name in previous) {
644
+ if (!(name in value)) {
645
+ list2.remove(name);
646
+ }
647
+ }
648
+ }
649
+ for (const name in value) {
650
+ const enabled = !!value[name];
651
+ if (previous === void 0 || !!previous[name] !== enabled) {
652
+ list2.toggle(name, enabled);
653
+ }
654
+ }
655
+ }
656
+ function setStyle(node, value) {
657
+ if (value == null) {
658
+ node.style.cssText = "";
659
+ } else {
660
+ node.style.cssText = String(value);
661
+ }
662
+ }
663
+ function setStyleObject(node, value, previous) {
664
+ const style = node.style;
665
+ if (previous !== void 0) {
666
+ for (const name in previous) {
667
+ if (!(name in value)) {
668
+ style.removeProperty(hyphenate(name));
669
+ }
670
+ }
671
+ }
672
+ for (const name in value) {
673
+ const next = value[name];
674
+ if (previous === void 0 || previous[name] !== next) {
675
+ if (next == null) {
676
+ style.removeProperty(hyphenate(name));
677
+ } else {
678
+ style.setProperty(hyphenate(name), String(next));
679
+ }
680
+ }
681
+ }
682
+ }
683
+ var HYPHENATE = /[A-Z]/g;
684
+ var hyphenateCache = /* @__PURE__ */ new Map();
685
+ function hyphenate(name) {
686
+ let result = hyphenateCache.get(name);
687
+ if (result === void 0) {
688
+ result = name.startsWith("--") ? name : name.replace(HYPHENATE, (letter) => `-${letter.toLowerCase()}`);
689
+ hyphenateCache.set(name, result);
690
+ }
691
+ return result;
692
+ }
693
+
694
+ // packages/dom/src/props.ts
695
+ function applyProp(node, name, value) {
696
+ if (name === "class" || name === "className") {
697
+ if (value !== null && typeof value === "object") {
698
+ setClassList(node, value, remember(node, "class", value));
699
+ } else {
700
+ setClass(node, value);
701
+ }
702
+ return;
703
+ }
704
+ if (name === "style") {
705
+ if (value !== null && typeof value === "object") {
706
+ setStyleObject(
707
+ node,
708
+ value,
709
+ remember(node, "style", value)
710
+ );
711
+ } else {
712
+ setStyle(node, value);
713
+ }
714
+ return;
715
+ }
716
+ if (name === "ref") {
717
+ value(node);
718
+ return;
719
+ }
720
+ if (name.startsWith("prop:")) {
721
+ setProperty(node, name.slice(5), value);
722
+ return;
723
+ }
724
+ if (name.startsWith("attr:")) {
725
+ setAttribute(node, name.slice(5), value);
726
+ return;
727
+ }
728
+ if (name.startsWith("on") && name.length > 2 && /[A-Z:]/.test(name[2])) {
729
+ applyEvent(node, name, value);
730
+ return;
731
+ }
732
+ if (name in node && typeof value !== "string") {
733
+ setProperty(node, name, value);
734
+ return;
735
+ }
736
+ setAttribute(node, name, value);
737
+ }
738
+ function applyEvent(node, name, value) {
739
+ const parts = name.slice(2).split(":");
740
+ const literal = parts[0] === "";
741
+ const type = literal ? parts[1] : parts[0].toLowerCase();
742
+ const modifier = parts[literal ? 2 : 1];
743
+ if (modifier === void 0) {
744
+ on(node, type, value);
745
+ } else if (modifier === "native") {
746
+ on(node, type, value, true);
747
+ } else {
748
+ on(node, type, value, { [modifier]: true });
749
+ }
750
+ }
751
+ function spread(node, props) {
752
+ for (const name in props) {
753
+ if (name !== "children") {
754
+ applyProp(node, name, props[name]);
755
+ }
756
+ }
757
+ }
758
+ function mergeProps(...sources) {
759
+ const target = {};
760
+ for (let i = 0; i < sources.length; i++) {
761
+ const source = sources[i];
762
+ for (const name of Object.keys(source)) {
763
+ Object.defineProperty(target, name, {
764
+ enumerable: true,
765
+ configurable: true,
766
+ get: () => source[name]
767
+ });
768
+ }
769
+ }
770
+ return target;
771
+ }
772
+ function rest(props, omit) {
773
+ const remaining = {};
774
+ for (const name of Object.keys(props)) {
775
+ if (!omit.includes(name)) {
776
+ Object.defineProperty(remaining, name, {
777
+ enumerable: true,
778
+ get: () => props[name]
779
+ });
780
+ }
781
+ }
782
+ return Object.freeze(remaining);
783
+ }
784
+ var records = /* @__PURE__ */ new WeakMap();
785
+ function remember(node, slot, value) {
786
+ let record = records.get(node);
787
+ if (record === void 0) {
788
+ record = {};
789
+ records.set(node, record);
790
+ }
791
+ const previous = record[slot];
792
+ record[slot] = value;
793
+ return previous;
794
+ }
795
+
796
+ export {
797
+ setComponentAdapter,
798
+ FirsthandComponentError,
799
+ label,
800
+ part,
801
+ insert,
802
+ applyChild,
803
+ reconcile,
804
+ COMPONENT,
805
+ setElementPrefix,
806
+ component,
807
+ isComponent,
808
+ createComponent,
809
+ defineElement,
810
+ list,
811
+ on,
812
+ off,
813
+ setAttribute,
814
+ setAttributeNS,
815
+ setProperty,
816
+ setBoolean,
817
+ setClass,
818
+ setClassList,
819
+ setStyle,
820
+ setStyleObject,
821
+ applyProp,
822
+ spread,
823
+ mergeProps,
824
+ rest
825
+ };
package/dist/dev.d.ts CHANGED
@@ -20,4 +20,22 @@ export declare function devWarnOnce(key: string, message: string): void;
20
20
  * it: `dev.prod.ts` replaces this with an empty function.
21
21
  */
22
22
  export declare function devWarnRenderedObject(value: object): void;
23
+ /**
24
+ * Reports the node and property a part is writing.
25
+ *
26
+ * Called from inside the part's own effect, so devtools can attribute it to
27
+ * whatever is running and turn an anonymous effect into `button.disabled`.
28
+ */
29
+ export declare function devPart(node: object, property: string): void;
30
+ /** Names the scope a component instance runs in. */
31
+ export declare function devComponent(owner: object, name: string): void;
32
+ /**
33
+ * Names a cell, from a label the compiler wrote.
34
+ *
35
+ * The value is returned so the call can wrap the expression it names, which
36
+ * keeps `signal` unchanged and leaves a cell created any other way simply
37
+ * unnamed. In a production build this is an empty function and the compiler
38
+ * emits no call to it at all.
39
+ */
40
+ export declare function label<T>(value: T, kind: string, name: string): T;
23
41
  //# 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;AAEH,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"}
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,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAKhE"}
@@ -2,4 +2,7 @@
2
2
  export declare function devWarn(_message: string): void;
3
3
  export declare function devWarnOnce(_key: string, _message: string): void;
4
4
  export declare function devWarnRenderedObject(_value: object): void;
5
+ export declare function devPart(_node: object, _property: string): void;
6
+ export declare function devComponent(_owner: object, _name: string): void;
7
+ export declare function label<T>(value: T, _kind: string, _name: string): T;
5
8
  //# sourceMappingURL=dev.prod.d.ts.map
@@ -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"}
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"}
@@ -0,0 +1,109 @@
1
+ import {
2
+ FirsthandComponentError,
3
+ applyChild,
4
+ component,
5
+ createComponent,
6
+ defineElement,
7
+ list,
8
+ mergeProps,
9
+ off,
10
+ on,
11
+ setComponentAdapter,
12
+ setElementPrefix
13
+ } from "./dev-chunk-2INCAQ6G.js";
14
+
15
+ // packages/dom/src/render.ts
16
+ import { createRoot, onCleanup, untrack } from "@firsthandjs/core";
17
+ function render(view, container = document.body) {
18
+ let dispose;
19
+ createRoot((stop) => {
20
+ dispose = stop;
21
+ let slot = null;
22
+ slot = applyChild(container, null, null, untrack(view));
23
+ onCleanup(() => {
24
+ applyChild(container, null, slot, null);
25
+ });
26
+ });
27
+ return dispose;
28
+ }
29
+
30
+ // packages/dom/src/portal.ts
31
+ import { onCleanup as onCleanup2 } from "@firsthandjs/core";
32
+ function portal(view, target) {
33
+ const nodes = [];
34
+ collectNodes(view, nodes);
35
+ for (let i = 0; i < nodes.length; i++) {
36
+ target.appendChild(nodes[i]);
37
+ }
38
+ onCleanup2(() => {
39
+ for (let i = 0; i < nodes.length; i++) {
40
+ const node = nodes[i];
41
+ node.parentNode?.removeChild(node);
42
+ }
43
+ });
44
+ return null;
45
+ }
46
+ function collectNodes(value, out) {
47
+ if (value == null || typeof value === "boolean") {
48
+ return;
49
+ }
50
+ if (Array.isArray(value)) {
51
+ for (let i = 0; i < value.length; i++) {
52
+ collectNodes(value[i], out);
53
+ }
54
+ return;
55
+ }
56
+ if (typeof value === "object" && typeof value.nodeType === "number") {
57
+ out.push(value);
58
+ return;
59
+ }
60
+ out.push(document.createTextNode(String(value)));
61
+ }
62
+
63
+ // packages/dom/src/index.ts
64
+ import {
65
+ signal,
66
+ computed,
67
+ effect,
68
+ batch,
69
+ untrack as untrack2,
70
+ onCleanup as onCleanup3,
71
+ createRoot as createRoot2,
72
+ catchError,
73
+ runWithOwner,
74
+ createContext,
75
+ provide,
76
+ useContext,
77
+ FirsthandContextError,
78
+ FirsthandCycleError,
79
+ FirsthandReadonlyError
80
+ } from "@firsthandjs/core";
81
+ export {
82
+ FirsthandComponentError,
83
+ FirsthandContextError,
84
+ FirsthandCycleError,
85
+ FirsthandReadonlyError,
86
+ batch,
87
+ catchError,
88
+ component,
89
+ computed,
90
+ createComponent,
91
+ createContext,
92
+ createRoot2 as createRoot,
93
+ defineElement,
94
+ effect,
95
+ list,
96
+ mergeProps,
97
+ off,
98
+ on,
99
+ onCleanup3 as onCleanup,
100
+ portal,
101
+ provide,
102
+ render,
103
+ runWithOwner,
104
+ setComponentAdapter,
105
+ setElementPrefix,
106
+ signal,
107
+ untrack2 as untrack,
108
+ useContext
109
+ };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as i,e as p,h as s,i as m,k as f,l as a,m as c,n as u,o as C,z as x}from"./chunk-6OI7S46K.js";import{createRoot as y,onCleanup as h,untrack as N}from"@firsthandjs/core";function g(e,r=document.body){let o;return y(t=>{o=t;let n=null;n=p(r,null,null,N(e)),h(()=>{p(r,null,n,null)})}),o}import{onCleanup as E}from"@firsthandjs/core";function b(e,r){let o=[];l(e,o);for(let t=0;t<o.length;t++)r.appendChild(o[t]);return E(()=>{for(let t=0;t<o.length;t++){let n=o[t];n.parentNode?.removeChild(n)}}),null}function l(e,r){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)l(e[o],r);return}if(typeof e=="object"&&typeof e.nodeType=="number"){r.push(e);return}r.push(document.createTextNode(String(e)))}}import{signal as z,computed as B,effect as G,batch as H,untrack as I,onCleanup as J,createRoot as K,catchError as L,runWithOwner as M,createContext as Q,provide as U,useContext as X,FirsthandContextError as Y,FirsthandCycleError as Z,FirsthandReadonlyError as _}from"@firsthandjs/core";export{i as FirsthandComponentError,Y as FirsthandContextError,Z as FirsthandCycleError,_ as FirsthandReadonlyError,H as batch,L as catchError,m as component,B as computed,f as createComponent,Q as createContext,K as createRoot,a as defineElement,G as effect,c as list,x as mergeProps,C as off,u as on,J as onCleanup,b as portal,U as provide,g as render,M as runWithOwner,d as setComponentAdapter,s as setElementPrefix,z as signal,I as untrack,X as useContext};
1
+ import{A as x,a as d,b as i,f as p,i as s,j as m,l as f,m as a,n as c,o as u,p as C}from"./chunk-QZ5SESOU.js";import{createRoot as y,onCleanup as h,untrack as N}from"@firsthandjs/core";function g(e,r=document.body){let o;return y(t=>{o=t;let n=null;n=p(r,null,null,N(e)),h(()=>{p(r,null,n,null)})}),o}import{onCleanup as E}from"@firsthandjs/core";function b(e,r){let o=[];l(e,o);for(let t=0;t<o.length;t++)r.appendChild(o[t]);return E(()=>{for(let t=0;t<o.length;t++){let n=o[t];n.parentNode?.removeChild(n)}}),null}function l(e,r){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)l(e[o],r);return}if(typeof e=="object"&&typeof e.nodeType=="number"){r.push(e);return}r.push(document.createTextNode(String(e)))}}import{signal as z,computed as B,effect as G,batch as H,untrack as I,onCleanup as J,createRoot as K,catchError as L,runWithOwner as M,createContext as Q,provide as U,useContext as X,FirsthandContextError as Y,FirsthandCycleError as Z,FirsthandReadonlyError as _}from"@firsthandjs/core";export{i as FirsthandComponentError,Y as FirsthandContextError,Z as FirsthandCycleError,_ as FirsthandReadonlyError,H as batch,L as catchError,m as component,B as computed,f as createComponent,Q as createContext,K as createRoot,a as defineElement,G as effect,c as list,x as mergeProps,C as off,u as on,J as onCleanup,b as portal,U as provide,g as render,M as runWithOwner,d as setComponentAdapter,s as setElementPrefix,z as signal,I as untrack,X as useContext};
@@ -1 +1 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGxF,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,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,OAAO,GAAG,YAAY,CAEvD;AAMD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,IAAI,GAAG,IAAW,GAAG,IAAI,CA4BrF;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,CAyDX;AAmED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAA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olean, setClass, setCla
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
+ export { label } from './dev.js';
20
21
  export { list } from './list.js';
21
22
  export { createComponent, isComponent, COMPONENT } from './component.js';
22
23
  //# sourceMappingURL=internal.d.ts.map
@@ -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,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,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;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
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,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,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,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,82 @@
1
+ import {
2
+ COMPONENT,
3
+ applyChild,
4
+ applyProp,
5
+ createComponent,
6
+ insert,
7
+ isComponent,
8
+ label,
9
+ list,
10
+ mergeProps,
11
+ off,
12
+ on,
13
+ part,
14
+ reconcile,
15
+ rest,
16
+ setAttribute,
17
+ setAttributeNS,
18
+ setBoolean,
19
+ setClass,
20
+ setClassList,
21
+ setProperty,
22
+ setStyle,
23
+ setStyleObject,
24
+ spread
25
+ } from "./dev-chunk-2INCAQ6G.js";
26
+
27
+ // packages/dom/src/template.ts
28
+ function template(html, isFragment = false) {
29
+ let source;
30
+ return () => {
31
+ if (source === void 0) {
32
+ const element = document.createElement("template");
33
+ element.innerHTML = html;
34
+ source = isFragment ? element.content : element.content.firstChild;
35
+ }
36
+ return source.cloneNode(true);
37
+ };
38
+ }
39
+ function path(root, ...indices) {
40
+ let node = root;
41
+ for (let i = 0; i < indices.length; i++) {
42
+ let child = node.firstChild;
43
+ for (let step = indices[i]; step > 0; step--) {
44
+ child = child.nextSibling;
45
+ }
46
+ node = child;
47
+ }
48
+ return node;
49
+ }
50
+
51
+ // packages/dom/src/internal.ts
52
+ import { bind } from "@firsthandjs/core";
53
+ var PROTOCOL_VERSION = 1;
54
+ export {
55
+ COMPONENT,
56
+ PROTOCOL_VERSION,
57
+ applyChild,
58
+ applyProp,
59
+ bind,
60
+ createComponent,
61
+ insert,
62
+ isComponent,
63
+ label,
64
+ list,
65
+ mergeProps,
66
+ off,
67
+ on,
68
+ part,
69
+ path,
70
+ reconcile,
71
+ rest,
72
+ setAttribute,
73
+ setAttributeNS,
74
+ setBoolean,
75
+ setClass,
76
+ setClassList,
77
+ setProperty,
78
+ setStyle,
79
+ setStyleObject,
80
+ spread,
81
+ template
82
+ };
package/dist/internal.js CHANGED
@@ -1 +1 @@
1
- import{A as L,c as l,d as s,e as i,f as a,g as m,j as d,k as f,m as c,n as u,o as x,p as N,q as y,r as C,s as h,t as b,u as O,v as S,w as P,x as T,y as g,z as E}from"./chunk-6OI7S46K.js";function j(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 A(r,...o){let e=r;for(let t=0;t<o.length;t++){let n=e.firstChild;for(let p=o[t];p>0;p--)n=n.nextSibling;e=n}return e}import{bind as k}from"@firsthandjs/core";var M=1;export{m as COMPONENT,M as PROTOCOL_VERSION,i as applyChild,T as applyProp,k as bind,f as createComponent,s as insert,d as isComponent,c as list,E as mergeProps,x as off,u as on,l as part,A as path,a as reconcile,L as rest,N as setAttribute,y as setAttributeNS,h as setBoolean,b as setClass,O as setClassList,C as setProperty,S as setStyle,P as setStyleObject,g as spread,j as template};
1
+ import{A as L,B as j,c as p,d as s,e as a,f as i,g as m,h as d,k as f,l as c,n as x,o as u,p as N,q as y,r as C,s as h,t as b,u as O,v as S,w as P,x as T,y as g,z as E}from"./chunk-QZ5SESOU.js";function A(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 F(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 q}from"@firsthandjs/core";var R=1;export{d as COMPONENT,R as PROTOCOL_VERSION,i as applyChild,g as applyProp,q as bind,c as createComponent,a as insert,f as isComponent,p as label,x as list,L as mergeProps,N as off,u as on,s as part,F as path,m as reconcile,j as rest,y as setAttribute,C as setAttributeNS,b as setBoolean,O as setClass,S as setClassList,h as setProperty,P as setStyle,T as setStyleObject,E as spread,A as template};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/dom",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "DOM parts, templates, components, portals and keyed lists for Firsthand.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,10 +8,12 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
+ "development": "./dist/index.dev.js",
11
12
  "default": "./dist/index.js"
12
13
  },
13
14
  "./internal": {
14
15
  "types": "./dist/internal.d.ts",
16
+ "development": "./dist/internal.dev.js",
15
17
  "default": "./dist/internal.js"
16
18
  }
17
19
  },
@@ -23,7 +25,7 @@
23
25
  "LICENSE"
24
26
  ],
25
27
  "dependencies": {
26
- "@firsthandjs/core": "0.3.0"
28
+ "@firsthandjs/core": "0.4.0"
27
29
  },
28
30
  "engines": {
29
31
  "node": ">=20.11.0"
@@ -1 +0,0 @@
1
- var C=null,x=new WeakMap;function $n(n){C=n,x=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 T(n){let t=x.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 x.set(n,e),e}import{bind as ln,getOwner as L,onCleanup as dn,runWithOwner as un}from"@firsthandjs/core";var cn=3;function H(n){return typeof n.nodeType=="number"}var D=Symbol("firsthand.part");function Mn(n){return{[D]:!0,anchor:document.createTextNode(""),thunk:n,owner:L()}}function W(n){return D in n}function M(n,t,e=null){if(typeof t!="function"){p(n,e,null,t);return}let o=null;ln(()=>{let r=t();if(typeof r=="function"){o=g(o),M(n,r,e);return}o=p(n,e,o,r)}),dn(()=>{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===cn?(e.data=i,e):j(n,t,e,document.createTextNode(i))}if(r==="function")return p(n,t,e,o());if(Array.isArray(o)){let i=[],s=[];if(I(o,i,s),i.length===0)return g(e);an(n,t,e===null?[]:Array.isArray(e)?e:[e],i);for(let d=0;d<s.length;d++){let l=s[d];un(l.owner??L(),()=>{M(n,l.thunk,l.anchor)})}return i}return W(o)?p(n,t,e,[o]):H(o)?j(n,t,e,o):p(n,t,e,String(o))}function I(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(typeof r=="object"&&r!==null&&W(r)){t.push(r.anchor),e.push(r);continue}for(;typeof r=="function";)r=r();r==null||typeof r=="boolean"||(Array.isArray(r)?I(r,t,e):typeof r=="object"&&H(r)?t.push(r):t.push(document.createTextNode(String(r))))}}function $(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++)$(n[t]);else $(n);return null}function j(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 an(n,t,e,o){let r=0,i=0,s=e.length-1,d=o.length-1;for(;r<=s&&i<=d&&e[r]===o[i];)r++,i++;for(;r<=s&&i<=d&&e[s]===o[d];)s--,d--;let l=d+1<o.length?o[d+1]:t;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(e[u]);return}let c=new Map;for(let u=r;u<=s;u++)c.set(e[u],u);let a=d-i+1,f=new Int32Array(a).fill(-1);for(let u=0;u<a;u++){let w=o[i+u],v=c.get(w);v!==void 0&&(f[u]=v,c.delete(w))}for(let u of c.keys())n.removeChild(u);let m=fn(f),k=m.length-1,O=l;for(let u=a-1;u>=0;u--){let w=o[i+u];k>=0&&m[k]===u?k--:n.insertBefore(w,O),O=w}}function fn(n){let t=n.length,e=new Int32Array(t).fill(-1),o=[];for(let s=0;s<t;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&&(e[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=e[i];return r.reverse()}import{signal as pn,createOwner as F,devEnterSetup as V,devExitSetup as y,disposeOwner as mn,getOwner as _,handleError as z,setOwner as h,untrack as B}from"@firsthandjs/core";var K=Symbol.for("firsthand.component"),wn=0,Z="firsthand";function Kn(n){Z=n}function Zn(n,t,e,o){let i=Object.assign(s=>gn(i,s),{[K]:!0,setup:n,options:t,id:e??`c${String(++wn)}`,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)&&yn(i,typeof t.tag=="string"?t.tag:void 0),i}function qn(n){return typeof n=="function"&&K in n}function gn(n,t){if(Object.freeze(t),n.setup===void 0)return T(n)(t);if(n.tag!==void 0)return Cn(n,t);let e=F(_()),o=h(e);try{V(n.id);let r=B(()=>n.setup(t));return y(),h(o),r}catch(r){return y(),h(o),z(r,e),null}}function hn(n){let t=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${Z}-${t}`}function yn(n,t){let e=n;if(e.tag!==void 0)return e.tag;let o=t??hn(e);return customElements.get(o)!==void 0&&(o=`${o}-${e.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),e.tag=o,customElements.define(o,bn(e)),o}function bn(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=kn(this,e,this.$attrs),q(this,n,t))}disconnectedCallback(){!this.$standalone||this.$owner===null||(mn(this.$owner),this.$owner=null)}attributeChangedCallback(i,s,d){let l=this.$attrs?.[i];l!==void 0&&(l.value=e[i]?.(d))}}}function kn(n,t,e){let o={};if(t!==void 0)for(let r in t){let i=pn(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=F(_());n.$owner=o;let r=h(o);try{V(t.id);let i=e?n.attachShadow({mode:"open"}):n,s=B(()=>t.setup(n.$props));y(),p(i,null,null,s)}catch(i){y(),z(i,o)}finally{h(r)}}function Cn(n,t){let e=document.createElement(n.tag);return e.$props=t,q(e,n,n.options?.shadow===!0),e}import{batch as xn,createOwner as G,disposeOwner as En,getOwner as Rn,setOwner as R,signal as Y,untrack as X}from"@firsthandjs/core";function Un(n,t,e){let o=G(Rn()),r=new Map;return()=>{let i=n(),s=new Map,d=[];return xn(()=>{for(let l=0;l<i.length;l++){let c=i[l],a=X(()=>t(c,l));if(s.has(a)){`${String(a)}`;continue}let f=r.get(a);f===void 0?f=Nn(o,c,l,e):(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())En(l.owner)}),r=s,d}}function Nn(n,t,e,o){let r=G(n),i=Y(t),s=Y(e),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,t){if(!(n==null||typeof n=="boolean")){if(Array.isArray(n)){for(let e=0;e<n.length;e++)J(n[e],t);return}if(typeof n=="object"&&typeof n.nodeType=="number"){t.push(n);return}t.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 Pn(n){let t=N(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 b(n,t,e,o){if(o!==void 0||!An.has(t)){n.addEventListener(t,e,o===!0?void 0:o);return}n[N(t)]=e,Q.has(t)||(Q.add(t),document.addEventListener(t,Pn))}function ee(n,t){n[N(t)]=void 0}var Sn={class:"className",for:"htmlFor"};function P(n,t,e){e==null||e===!1?n.removeAttribute(t):n.setAttribute(t,e===!0?"":String(e))}function oe(n,t,e,o){o==null||o===!1?n.removeAttributeNS(t,e):n.setAttributeNS(t,e,o===!0?"":String(o))}function S(n,t,e){n[Sn[t]??t]=e}function re(n,t,e){n[t]=!!e}function nn(n,t){t==null?n.removeAttribute("class"):n.className=String(t)}function en(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 tn(n,t){t==null?n.style.cssText="":n.style.cssText=String(t)}function on(n,t,e){let o=n.style;if(e!==void 0)for(let r in e)r in t||o.removeProperty(A(r));for(let r in t){let i=t[r];(e===void 0||e[r]!==i)&&(i==null?o.removeProperty(A(r)):o.setProperty(A(r),String(i)))}}var On=/[A-Z]/g,U=new Map;function A(n){let t=U.get(n);return t===void 0&&(t=n.startsWith("--")?n:n.replace(On,e=>`-${e.toLowerCase()}`),U.set(n,t)),t}function vn(n,t,e){if(t==="class"||t==="className"){e!==null&&typeof e=="object"?en(n,e,sn(n,"class",e)):nn(n,e);return}if(t==="style"){e!==null&&typeof e=="object"?on(n,e,sn(n,"style",e)):tn(n,e);return}if(t==="ref"){e(n);return}if(t.startsWith("prop:")){S(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])){Tn(n,t,e);return}if(t in n&&typeof e!="string"){S(n,t,e);return}P(n,t,e)}function Tn(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?b(n,i,e):s==="native"?b(n,i,e,!0):b(n,i,e,{[s]:!0})}function de(n,t){for(let e in t)e!=="children"&&vn(n,e,t[e])}function ue(...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 ce(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 rn=new WeakMap;function sn(n,t,e){let o=rn.get(n);o===void 0&&(o={},rn.set(n,o));let r=o[t];return o[t]=e,r}export{$n as a,E as b,Mn as c,M as d,p as e,an as f,K as g,Kn as h,Zn as i,qn as j,gn as k,yn as l,Un as m,b as n,ee as o,P as p,oe as q,S as r,re as s,nn as t,en as u,tn as v,on as w,vn as x,de as y,ue as z,ce as A};