tina4js 1.0.0 → 1.0.2

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/TINA4.md CHANGED
@@ -156,6 +156,20 @@ tina4 build --target python
156
156
  - `formToken` injected into POST/PUT/PATCH/DELETE body
157
157
  - Token auto-rotated via `FreshToken` response header
158
158
 
159
+ ## Debug Overlay
160
+
161
+ ```ts
162
+ // Always-on
163
+ import 'tina4js/debug';
164
+
165
+ // Dev-only (recommended — stripped from production builds)
166
+ if (import.meta.env.DEV) import('tina4js/debug');
167
+ ```
168
+
169
+ - Toggle with **Ctrl+Shift+D**
170
+ - Shows: live signal values + subscriber counts, mounted components, route navigation history with timing, API request/response log
171
+ - Zero cost in production when using the `import.meta.env.DEV` guard (tree-shaken by Vite/Rollup)
172
+
159
173
  ## Framework Size
160
174
 
161
175
  | Module | Gzipped |
@@ -0,0 +1 @@
1
+ "use strict";const p=require("./signal.cjs.js");let r=null,n=null;function u(h,t){r=h,n=t}const e=class e extends HTMLElement{constructor(){super(),this._props={},this._rendered=!1;const t=this.constructor;this._root=t.shadow?this.attachShadow({mode:"open"}):this;for(const[o,s]of Object.entries(t.props))this._props[o]=p.signal(this._coerce(this.getAttribute(o),s))}static get observedAttributes(){return Object.keys(this.props)}connectedCallback(){if(this._rendered)return;this._rendered=!0;const t=this.constructor;if(t.styles&&t.shadow&&this._root instanceof ShadowRoot){const s=document.createElement("style");s.textContent=t.styles,this._root.appendChild(s)}const o=this.render();o&&this._root.appendChild(o),this.onMount(),r&&r(this)}disconnectedCallback(){this.onUnmount(),n&&n(this)}attributeChangedCallback(t,o,s){const c=this.constructor.props[t];c&&this._props[t]&&(this._props[t].value=this._coerce(s,c))}prop(t){if(!this._props[t])throw new Error(`[tina4] Prop '${t}' not declared in static props of <${this.tagName.toLowerCase()}>`);return this._props[t]}emit(t,o){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,...o}))}onMount(){}onUnmount(){}_coerce(t,o){return o===Boolean?t!==null:o===Number?t!==null?Number(t):0:t??""}};e.props={},e.styles="",e.shadow=!0;let i=e;exports.Tina4Element=i;exports.__setDebugComponentHooks=u;
@@ -0,0 +1,81 @@
1
+ import { s as p } from "./signal.es.js";
2
+ let r = null, n = null;
3
+ function a(h, t) {
4
+ r = h, n = t;
5
+ }
6
+ const e = class e extends HTMLElement {
7
+ constructor() {
8
+ super(), this._props = {}, this._rendered = !1;
9
+ const t = this.constructor;
10
+ this._root = t.shadow ? this.attachShadow({ mode: "open" }) : this;
11
+ for (const [o, s] of Object.entries(t.props))
12
+ this._props[o] = p(this._coerce(this.getAttribute(o), s));
13
+ }
14
+ static get observedAttributes() {
15
+ return Object.keys(this.props);
16
+ }
17
+ connectedCallback() {
18
+ if (this._rendered) return;
19
+ this._rendered = !0;
20
+ const t = this.constructor;
21
+ if (t.styles && t.shadow && this._root instanceof ShadowRoot) {
22
+ const s = document.createElement("style");
23
+ s.textContent = t.styles, this._root.appendChild(s);
24
+ }
25
+ const o = this.render();
26
+ o && this._root.appendChild(o), this.onMount(), r && r(this);
27
+ }
28
+ disconnectedCallback() {
29
+ this.onUnmount(), n && n(this);
30
+ }
31
+ attributeChangedCallback(t, o, s) {
32
+ const i = this.constructor.props[t];
33
+ i && this._props[t] && (this._props[t].value = this._coerce(s, i));
34
+ }
35
+ /**
36
+ * Get a reactive signal for a declared prop.
37
+ *
38
+ * ```ts
39
+ * render() {
40
+ * return html`<span>${this.prop('name')}</span>`;
41
+ * }
42
+ * ```
43
+ */
44
+ prop(t) {
45
+ if (!this._props[t])
46
+ throw new Error(`[tina4] Prop '${t}' not declared in static props of <${this.tagName.toLowerCase()}>`);
47
+ return this._props[t];
48
+ }
49
+ /**
50
+ * Dispatch a custom event from this component.
51
+ *
52
+ * ```ts
53
+ * this.emit('activate', { detail: 42 });
54
+ * ```
55
+ */
56
+ emit(t, o) {
57
+ this.dispatchEvent(new CustomEvent(t, {
58
+ bubbles: !0,
59
+ composed: !0,
60
+ // crosses shadow DOM boundary
61
+ ...o
62
+ }));
63
+ }
64
+ // ── Lifecycle hooks (override in subclass) ──────────────────────
65
+ /** Called after first render. */
66
+ onMount() {
67
+ }
68
+ /** Called when removed from DOM. */
69
+ onUnmount() {
70
+ }
71
+ // ── Private ─────────────────────────────────────────────────────
72
+ _coerce(t, o) {
73
+ return o === Boolean ? t !== null : o === Number ? t !== null ? Number(t) : 0 : t ?? "";
74
+ }
75
+ };
76
+ e.props = {}, e.styles = "", e.shadow = !0;
77
+ let c = e;
78
+ export {
79
+ c as T,
80
+ a as _
81
+ };
package/dist/core.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let l=null,p=0;const m=new Set;function y(n){let t=n;const e=new Set;return{_t4:!0,get value(){return l&&e.add(l),t},set value(o){if(!Object.is(o,t))if(t=o,p>0)for(const s of e)m.add(s);else for(const s of[...e])s()},_subscribe(o){return e.add(o),()=>{e.delete(o)}},peek(){return t}}}function S(n){const t=y(void 0);return a(()=>{t.value=n()}),{_t4:!0,get value(){return t.value},set value(e){throw new Error("[tina4] computed signals are read-only")},_subscribe(e){return t._subscribe(e)},peek(){return t.peek()}}}function a(n){let t=!1;const e=()=>{if(t)return;const o=l;l=e;try{n()}finally{l=o}};return e(),()=>{t=!0}}function x(n){p++;try{n()}finally{if(p--,p===0){const t=[...m];m.clear();for(const e of t)e()}}}function d(n){return n!==null&&typeof n=="object"&&n._t4===!0}const C=new WeakMap,_="t4:";function E(n,...t){let e=C.get(n);if(!e){e=document.createElement("template");let c="";for(let r=0;r<n.length;r++)c+=n[r],r<t.length&&(W(c)?c+=`__t4_${r}__`:c+=`<!--${_}${r}-->`);e.innerHTML=c,C.set(n,e)}const o=e.content.cloneNode(!0),s=T(o);for(const{marker:c,index:r}of s)j(c,t[r]);const i=M(o);for(const c of i)I(c,t);return o}function T(n){const t=[];return A(n,e=>{if(e.nodeType===8){const o=e.data;if(o&&o.startsWith(_)){const s=parseInt(o.slice(_.length),10);t.push({marker:e,index:s})}}}),t}function M(n){const t=[];return A(n,e=>{e.nodeType===1&&t.push(e)}),t}function A(n,t){const e=n.childNodes;for(let o=0;o<e.length;o++){const s=e[o];t(s),A(s,t)}}function j(n,t){const e=n.parentNode;if(e)if(d(t)){const o=document.createTextNode("");e.replaceChild(o,n),a(()=>{o.data=String(t.value??"")})}else if(typeof t=="function"){const o=document.createComment("");e.replaceChild(o,n);let s=[];a(()=>{var u;const i=t();for(const f of s)(u=f.parentNode)==null||u.removeChild(f);s=[];const c=b(i),r=o.parentNode;for(const f of c)r.insertBefore(f,o),s.push(f)})}else if(N(t))e.replaceChild(t,n);else if(t instanceof Node)e.replaceChild(t,n);else if(Array.isArray(t)){const o=document.createDocumentFragment();for(const s of t){const i=b(s);for(const c of i)o.appendChild(c)}e.replaceChild(o,n)}else{const o=document.createTextNode(String(t??""));e.replaceChild(o,n)}}function I(n,t){const e=[];for(const o of Array.from(n.attributes)){const s=o.name,i=o.value;if(s.startsWith("@")){const r=s.slice(1),u=i.match(/__t4_(\d+)__/);if(u){const f=t[parseInt(u[1],10)];typeof f=="function"&&n.addEventListener(r,f)}e.push(s);continue}if(s.startsWith("?")){const r=s.slice(1),u=i.match(/__t4_(\d+)__/);if(u){const f=t[parseInt(u[1],10)];if(d(f)){const w=f;a(()=>{w.value?n.setAttribute(r,""):n.removeAttribute(r)})}else f&&n.setAttribute(r,"")}e.push(s);continue}if(s.startsWith(".")){const r=s.slice(1),u=i.match(/__t4_(\d+)__/);if(u){const f=t[parseInt(u[1],10)];d(f)?a(()=>{n[r]=f.value}):n[r]=f}e.push(s);continue}const c=i.match(/__t4_(\d+)__/);if(c){const r=t[parseInt(c[1],10)];if(d(r)){const u=r;a(()=>{n.setAttribute(s,String(u.value??""))})}else typeof r=="function"?a(()=>{n.setAttribute(s,String(r()??""))}):n.setAttribute(s,String(r??""))}}for(const o of e)n.removeAttribute(o)}function b(n){if(n==null||n===!1)return[];if(N(n))return Array.from(n.childNodes);if(n instanceof Node)return[n];if(Array.isArray(n)){const t=[];for(const e of n)t.push(...b(e));return t}return[document.createTextNode(String(n))]}function N(n){return n!=null&&typeof n=="object"&&n.nodeType===11}function W(n){let t=!1,e=!1,o=!1;for(let s=0;s<n.length;s++){const i=n[s];i==="<"&&!t&&!e&&(o=!0),i===">"&&!t&&!e&&(o=!1),o&&(i==='"'&&!t&&(e=!e),i==="'"&&!e&&(t=!t))}return o}const h=class h extends HTMLElement{constructor(){super(),this._props={},this._rendered=!1;const t=this.constructor;this._root=t.shadow?this.attachShadow({mode:"open"}):this;for(const[e,o]of Object.entries(t.props))this._props[e]=y(this._coerce(this.getAttribute(e),o))}static get observedAttributes(){return Object.keys(this.props)}connectedCallback(){if(this._rendered)return;this._rendered=!0;const t=this.constructor;if(t.styles&&t.shadow&&this._root instanceof ShadowRoot){const o=document.createElement("style");o.textContent=t.styles,this._root.appendChild(o)}const e=this.render();e&&this._root.appendChild(e),this.onMount()}disconnectedCallback(){this.onUnmount()}attributeChangedCallback(t,e,o){const i=this.constructor.props[t];i&&this._props[t]&&(this._props[t].value=this._coerce(o,i))}prop(t){if(!this._props[t])throw new Error(`[tina4] Prop '${t}' not declared in static props of <${this.tagName.toLowerCase()}>`);return this._props[t]}emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,...e}))}onMount(){}onUnmount(){}_coerce(t,e){return e===Boolean?t!==null:e===Number?t!==null?Number(t):0:t??""}};h.props={},h.styles="",h.shadow=!0;let g=h;exports.Tina4Element=g;exports.batch=x;exports.computed=S;exports.effect=a;exports.html=E;exports.isSignal=d;exports.signal=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./signal.cjs.js"),_=require("./component.cjs.js"),h=new WeakMap,d="t4:";function A(t,...e){let n=h.get(t);if(!n){n=document.createElement("template");let c="";for(let s=0;s<t.length;s++)c+=t[s],s<e.length&&(T(c)?c+=`__t4_${s}__`:c+=`<!--${d}${s}-->`);n.innerHTML=c,h.set(t,n)}const o=n.content.cloneNode(!0),i=N(o);for(const{marker:c,index:s}of i)y(c,e[s]);const f=b(o);for(const c of f)S(c,e);return o}function N(t){const e=[];return u(t,n=>{if(n.nodeType===8){const o=n.data;if(o&&o.startsWith(d)){const i=parseInt(o.slice(d.length),10);e.push({marker:n,index:i})}}}),e}function b(t){const e=[];return u(t,n=>{n.nodeType===1&&e.push(n)}),e}function u(t,e){const n=t.childNodes;for(let o=0;o<n.length;o++){const i=n[o];e(i),u(i,e)}}function y(t,e){const n=t.parentNode;if(n)if(a.isSignal(e)){const o=document.createTextNode("");n.replaceChild(o,t),a.effect(()=>{o.data=String(e.value??"")})}else if(typeof e=="function"){const o=document.createComment("");n.replaceChild(o,t);let i=[];a.effect(()=>{var l;const f=e();for(const r of i)(l=r.parentNode)==null||l.removeChild(r);i=[];const c=m(f),s=o.parentNode;for(const r of c)s.insertBefore(r,o),i.push(r)})}else if(p(e))n.replaceChild(e,t);else if(e instanceof Node)n.replaceChild(e,t);else if(Array.isArray(e)){const o=document.createDocumentFragment();for(const i of e){const f=m(i);for(const c of f)o.appendChild(c)}n.replaceChild(o,t)}else{const o=document.createTextNode(String(e??""));n.replaceChild(o,t)}}function S(t,e){const n=[];for(const o of Array.from(t.attributes)){const i=o.name,f=o.value;if(i.startsWith("@")){const s=i.slice(1),l=f.match(/__t4_(\d+)__/);if(l){const r=e[parseInt(l[1],10)];typeof r=="function"&&t.addEventListener(s,r)}n.push(i);continue}if(i.startsWith("?")){const s=i.slice(1),l=f.match(/__t4_(\d+)__/);if(l){const r=e[parseInt(l[1],10)];if(a.isSignal(r)){const g=r;a.effect(()=>{g.value?t.setAttribute(s,""):t.removeAttribute(s)})}else r&&t.setAttribute(s,"")}n.push(i);continue}if(i.startsWith(".")){const s=i.slice(1),l=f.match(/__t4_(\d+)__/);if(l){const r=e[parseInt(l[1],10)];a.isSignal(r)?a.effect(()=>{t[s]=r.value}):t[s]=r}n.push(i);continue}const c=f.match(/__t4_(\d+)__/);if(c){const s=e[parseInt(c[1],10)];if(a.isSignal(s)){const l=s;a.effect(()=>{t.setAttribute(i,String(l.value??""))})}else typeof s=="function"?a.effect(()=>{t.setAttribute(i,String(s()??""))}):t.setAttribute(i,String(s??""))}}for(const o of n)t.removeAttribute(o)}function m(t){if(t==null||t===!1)return[];if(p(t))return Array.from(t.childNodes);if(t instanceof Node)return[t];if(Array.isArray(t)){const e=[];for(const n of t)e.push(...m(n));return e}return[document.createTextNode(String(t))]}function p(t){return t!=null&&typeof t=="object"&&t.nodeType===11}function T(t){let e=!1,n=!1,o=!1;for(let i=0;i<t.length;i++){const f=t[i];f==="<"&&!e&&!n&&(o=!0),f===">"&&!e&&!n&&(o=!1),o&&(f==='"'&&!e&&(n=!n),f==="'"&&!n&&(e=!e))}return o}exports.batch=a.batch;exports.computed=a.computed;exports.effect=a.effect;exports.isSignal=a.isSignal;exports.signal=a.signal;exports.Tina4Element=_.Tina4Element;exports.html=A;
package/dist/core.es.js CHANGED
@@ -1,315 +1,168 @@
1
- let d = null, h = 0;
2
- const m = /* @__PURE__ */ new Set();
3
- function C(n) {
4
- let t = n;
5
- const e = /* @__PURE__ */ new Set();
6
- return {
7
- _t4: !0,
8
- get value() {
9
- return d && e.add(d), t;
10
- },
11
- set value(o) {
12
- if (!Object.is(o, t))
13
- if (t = o, h > 0)
14
- for (const s of e) m.add(s);
15
- else
16
- for (const s of [...e]) s();
17
- },
18
- _subscribe(o) {
19
- return e.add(o), () => {
20
- e.delete(o);
21
- };
22
- },
23
- peek() {
24
- return t;
25
- }
26
- };
27
- }
28
- function M(n) {
29
- const t = C(void 0);
30
- return a(() => {
31
- t.value = n();
32
- }), {
33
- _t4: !0,
34
- get value() {
35
- return t.value;
36
- },
37
- set value(e) {
38
- throw new Error("[tina4] computed signals are read-only");
39
- },
40
- _subscribe(e) {
41
- return t._subscribe(e);
42
- },
43
- peek() {
44
- return t.peek();
45
- }
46
- };
47
- }
48
- function a(n) {
49
- let t = !1;
50
- const e = () => {
51
- if (t) return;
52
- const o = d;
53
- d = e;
54
- try {
55
- n();
56
- } finally {
57
- d = o;
58
- }
59
- };
60
- return e(), () => {
61
- t = !0;
62
- };
63
- }
64
- function j(n) {
65
- h++;
66
- try {
67
- n();
68
- } finally {
69
- if (h--, h === 0) {
70
- const t = [...m];
71
- m.clear();
72
- for (const e of t) e();
73
- }
74
- }
75
- }
76
- function p(n) {
77
- return n !== null && typeof n == "object" && n._t4 === !0;
78
- }
79
- const y = /* @__PURE__ */ new WeakMap(), _ = "t4:";
80
- function W(n, ...t) {
81
- let e = y.get(n);
82
- if (!e) {
83
- e = document.createElement("template");
84
- let c = "";
85
- for (let r = 0; r < n.length; r++)
86
- c += n[r], r < t.length && (I(c) ? c += `__t4_${r}__` : c += `<!--${_}${r}-->`);
87
- e.innerHTML = c, y.set(n, e);
88
- }
89
- const o = e.content.cloneNode(!0), s = S(o);
90
- for (const { marker: c, index: r } of s)
91
- E(c, t[r]);
92
- const i = x(o);
93
- for (const c of i)
94
- T(c, t);
1
+ import { i as l, e as d } from "./signal.es.js";
2
+ import { b as I, c as W, s as V } from "./signal.es.js";
3
+ import { T as D } from "./component.es.js";
4
+ const u = /* @__PURE__ */ new WeakMap(), m = "t4:";
5
+ function x(t, ...e) {
6
+ let n = u.get(t);
7
+ if (!n) {
8
+ n = document.createElement("template");
9
+ let r = "";
10
+ for (let i = 0; i < t.length; i++)
11
+ r += t[i], i < e.length && (T(r) ? r += `__t4_${i}__` : r += `<!--${m}${i}-->`);
12
+ n.innerHTML = r, u.set(t, n);
13
+ }
14
+ const o = n.content.cloneNode(!0), s = A(o);
15
+ for (const { marker: r, index: i } of s)
16
+ b(r, e[i]);
17
+ const f = N(o);
18
+ for (const r of f)
19
+ y(r, e);
95
20
  return o;
96
21
  }
97
- function S(n) {
98
- const t = [];
99
- return g(n, (e) => {
100
- if (e.nodeType === 8) {
101
- const o = e.data;
102
- if (o && o.startsWith(_)) {
103
- const s = parseInt(o.slice(_.length), 10);
104
- t.push({ marker: e, index: s });
22
+ function A(t) {
23
+ const e = [];
24
+ return h(t, (n) => {
25
+ if (n.nodeType === 8) {
26
+ const o = n.data;
27
+ if (o && o.startsWith(m)) {
28
+ const s = parseInt(o.slice(m.length), 10);
29
+ e.push({ marker: n, index: s });
105
30
  }
106
31
  }
107
- }), t;
32
+ }), e;
108
33
  }
109
- function x(n) {
110
- const t = [];
111
- return g(n, (e) => {
112
- e.nodeType === 1 && t.push(e);
113
- }), t;
34
+ function N(t) {
35
+ const e = [];
36
+ return h(t, (n) => {
37
+ n.nodeType === 1 && e.push(n);
38
+ }), e;
114
39
  }
115
- function g(n, t) {
116
- const e = n.childNodes;
117
- for (let o = 0; o < e.length; o++) {
118
- const s = e[o];
119
- t(s), g(s, t);
40
+ function h(t, e) {
41
+ const n = t.childNodes;
42
+ for (let o = 0; o < n.length; o++) {
43
+ const s = n[o];
44
+ e(s), h(s, e);
120
45
  }
121
46
  }
122
- function E(n, t) {
123
- const e = n.parentNode;
124
- if (e)
125
- if (p(t)) {
47
+ function b(t, e) {
48
+ const n = t.parentNode;
49
+ if (n)
50
+ if (l(e)) {
126
51
  const o = document.createTextNode("");
127
- e.replaceChild(o, n), a(() => {
128
- o.data = String(t.value ?? "");
52
+ n.replaceChild(o, t), d(() => {
53
+ o.data = String(e.value ?? "");
129
54
  });
130
- } else if (typeof t == "function") {
55
+ } else if (typeof e == "function") {
131
56
  const o = document.createComment("");
132
- e.replaceChild(o, n);
57
+ n.replaceChild(o, t);
133
58
  let s = [];
134
- a(() => {
135
- var u;
136
- const i = t();
137
- for (const f of s) (u = f.parentNode) == null || u.removeChild(f);
59
+ d(() => {
60
+ var a;
61
+ const f = e();
62
+ for (const c of s) (a = c.parentNode) == null || a.removeChild(c);
138
63
  s = [];
139
- const c = b(i), r = o.parentNode;
140
- for (const f of c)
141
- r.insertBefore(f, o), s.push(f);
64
+ const r = p(f), i = o.parentNode;
65
+ for (const c of r)
66
+ i.insertBefore(c, o), s.push(c);
142
67
  });
143
- } else if (N(t))
144
- e.replaceChild(t, n);
145
- else if (t instanceof Node)
146
- e.replaceChild(t, n);
147
- else if (Array.isArray(t)) {
68
+ } else if (_(e))
69
+ n.replaceChild(e, t);
70
+ else if (e instanceof Node)
71
+ n.replaceChild(e, t);
72
+ else if (Array.isArray(e)) {
148
73
  const o = document.createDocumentFragment();
149
- for (const s of t) {
150
- const i = b(s);
151
- for (const c of i) o.appendChild(c);
74
+ for (const s of e) {
75
+ const f = p(s);
76
+ for (const r of f) o.appendChild(r);
152
77
  }
153
- e.replaceChild(o, n);
78
+ n.replaceChild(o, t);
154
79
  } else {
155
- const o = document.createTextNode(String(t ?? ""));
156
- e.replaceChild(o, n);
80
+ const o = document.createTextNode(String(e ?? ""));
81
+ n.replaceChild(o, t);
157
82
  }
158
83
  }
159
- function T(n, t) {
160
- const e = [];
161
- for (const o of Array.from(n.attributes)) {
162
- const s = o.name, i = o.value;
84
+ function y(t, e) {
85
+ const n = [];
86
+ for (const o of Array.from(t.attributes)) {
87
+ const s = o.name, f = o.value;
163
88
  if (s.startsWith("@")) {
164
- const r = s.slice(1), u = i.match(/__t4_(\d+)__/);
165
- if (u) {
166
- const f = t[parseInt(u[1], 10)];
167
- typeof f == "function" && n.addEventListener(r, f);
89
+ const i = s.slice(1), a = f.match(/__t4_(\d+)__/);
90
+ if (a) {
91
+ const c = e[parseInt(a[1], 10)];
92
+ typeof c == "function" && t.addEventListener(i, c);
168
93
  }
169
- e.push(s);
94
+ n.push(s);
170
95
  continue;
171
96
  }
172
97
  if (s.startsWith("?")) {
173
- const r = s.slice(1), u = i.match(/__t4_(\d+)__/);
174
- if (u) {
175
- const f = t[parseInt(u[1], 10)];
176
- if (p(f)) {
177
- const w = f;
178
- a(() => {
179
- w.value ? n.setAttribute(r, "") : n.removeAttribute(r);
98
+ const i = s.slice(1), a = f.match(/__t4_(\d+)__/);
99
+ if (a) {
100
+ const c = e[parseInt(a[1], 10)];
101
+ if (l(c)) {
102
+ const g = c;
103
+ d(() => {
104
+ g.value ? t.setAttribute(i, "") : t.removeAttribute(i);
180
105
  });
181
106
  } else
182
- f && n.setAttribute(r, "");
107
+ c && t.setAttribute(i, "");
183
108
  }
184
- e.push(s);
109
+ n.push(s);
185
110
  continue;
186
111
  }
187
112
  if (s.startsWith(".")) {
188
- const r = s.slice(1), u = i.match(/__t4_(\d+)__/);
189
- if (u) {
190
- const f = t[parseInt(u[1], 10)];
191
- p(f) ? a(() => {
192
- n[r] = f.value;
193
- }) : n[r] = f;
113
+ const i = s.slice(1), a = f.match(/__t4_(\d+)__/);
114
+ if (a) {
115
+ const c = e[parseInt(a[1], 10)];
116
+ l(c) ? d(() => {
117
+ t[i] = c.value;
118
+ }) : t[i] = c;
194
119
  }
195
- e.push(s);
120
+ n.push(s);
196
121
  continue;
197
122
  }
198
- const c = i.match(/__t4_(\d+)__/);
199
- if (c) {
200
- const r = t[parseInt(c[1], 10)];
201
- if (p(r)) {
202
- const u = r;
203
- a(() => {
204
- n.setAttribute(s, String(u.value ?? ""));
123
+ const r = f.match(/__t4_(\d+)__/);
124
+ if (r) {
125
+ const i = e[parseInt(r[1], 10)];
126
+ if (l(i)) {
127
+ const a = i;
128
+ d(() => {
129
+ t.setAttribute(s, String(a.value ?? ""));
205
130
  });
206
- } else typeof r == "function" ? a(() => {
207
- n.setAttribute(s, String(r() ?? ""));
208
- }) : n.setAttribute(s, String(r ?? ""));
131
+ } else typeof i == "function" ? d(() => {
132
+ t.setAttribute(s, String(i() ?? ""));
133
+ }) : t.setAttribute(s, String(i ?? ""));
209
134
  }
210
135
  }
211
- for (const o of e) n.removeAttribute(o);
136
+ for (const o of n) t.removeAttribute(o);
212
137
  }
213
- function b(n) {
214
- if (n == null || n === !1) return [];
215
- if (N(n)) return Array.from(n.childNodes);
216
- if (n instanceof Node) return [n];
217
- if (Array.isArray(n)) {
218
- const t = [];
219
- for (const e of n) t.push(...b(e));
220
- return t;
221
- }
222
- return [document.createTextNode(String(n))];
138
+ function p(t) {
139
+ if (t == null || t === !1) return [];
140
+ if (_(t)) return Array.from(t.childNodes);
141
+ if (t instanceof Node) return [t];
142
+ if (Array.isArray(t)) {
143
+ const e = [];
144
+ for (const n of t) e.push(...p(n));
145
+ return e;
146
+ }
147
+ return [document.createTextNode(String(t))];
223
148
  }
224
- function N(n) {
225
- return n != null && typeof n == "object" && n.nodeType === 11;
149
+ function _(t) {
150
+ return t != null && typeof t == "object" && t.nodeType === 11;
226
151
  }
227
- function I(n) {
228
- let t = !1, e = !1, o = !1;
229
- for (let s = 0; s < n.length; s++) {
230
- const i = n[s];
231
- i === "<" && !t && !e && (o = !0), i === ">" && !t && !e && (o = !1), o && (i === '"' && !t && (e = !e), i === "'" && !e && (t = !t));
152
+ function T(t) {
153
+ let e = !1, n = !1, o = !1;
154
+ for (let s = 0; s < t.length; s++) {
155
+ const f = t[s];
156
+ f === "<" && !e && !n && (o = !0), f === ">" && !e && !n && (o = !1), o && (f === '"' && !e && (n = !n), f === "'" && !n && (e = !e));
232
157
  }
233
158
  return o;
234
159
  }
235
- const l = class l extends HTMLElement {
236
- constructor() {
237
- super(), this._props = {}, this._rendered = !1;
238
- const t = this.constructor;
239
- this._root = t.shadow ? this.attachShadow({ mode: "open" }) : this;
240
- for (const [e, o] of Object.entries(t.props))
241
- this._props[e] = C(this._coerce(this.getAttribute(e), o));
242
- }
243
- static get observedAttributes() {
244
- return Object.keys(this.props);
245
- }
246
- connectedCallback() {
247
- if (this._rendered) return;
248
- this._rendered = !0;
249
- const t = this.constructor;
250
- if (t.styles && t.shadow && this._root instanceof ShadowRoot) {
251
- const o = document.createElement("style");
252
- o.textContent = t.styles, this._root.appendChild(o);
253
- }
254
- const e = this.render();
255
- e && this._root.appendChild(e), this.onMount();
256
- }
257
- disconnectedCallback() {
258
- this.onUnmount();
259
- }
260
- attributeChangedCallback(t, e, o) {
261
- const i = this.constructor.props[t];
262
- i && this._props[t] && (this._props[t].value = this._coerce(o, i));
263
- }
264
- /**
265
- * Get a reactive signal for a declared prop.
266
- *
267
- * ```ts
268
- * render() {
269
- * return html`<span>${this.prop('name')}</span>`;
270
- * }
271
- * ```
272
- */
273
- prop(t) {
274
- if (!this._props[t])
275
- throw new Error(`[tina4] Prop '${t}' not declared in static props of <${this.tagName.toLowerCase()}>`);
276
- return this._props[t];
277
- }
278
- /**
279
- * Dispatch a custom event from this component.
280
- *
281
- * ```ts
282
- * this.emit('activate', { detail: 42 });
283
- * ```
284
- */
285
- emit(t, e) {
286
- this.dispatchEvent(new CustomEvent(t, {
287
- bubbles: !0,
288
- composed: !0,
289
- // crosses shadow DOM boundary
290
- ...e
291
- }));
292
- }
293
- // ── Lifecycle hooks (override in subclass) ──────────────────────
294
- /** Called after first render. */
295
- onMount() {
296
- }
297
- /** Called when removed from DOM. */
298
- onUnmount() {
299
- }
300
- // ── Private ─────────────────────────────────────────────────────
301
- _coerce(t, e) {
302
- return e === Boolean ? t !== null : e === Number ? t !== null ? Number(t) : 0 : t ?? "";
303
- }
304
- };
305
- l.props = {}, l.styles = "", l.shadow = !0;
306
- let A = l;
307
160
  export {
308
- A as Tina4Element,
309
- j as batch,
310
- M as computed,
311
- a as effect,
312
- W as html,
313
- p as isSignal,
314
- C as signal
161
+ D as Tina4Element,
162
+ I as batch,
163
+ W as computed,
164
+ d as effect,
165
+ x as html,
166
+ l as isSignal,
167
+ V as signal
315
168
  };