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 +14 -0
- package/dist/component.cjs.js +1 -0
- package/dist/component.es.js +81 -0
- package/dist/core.cjs.js +1 -1
- package/dist/core.es.js +124 -271
- package/dist/debug.cjs.js +268 -0
- package/dist/debug.es.js +598 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.es.js +105 -0
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +5 -81
- package/dist/signal.cjs.js +1 -0
- package/dist/signal.es.js +98 -0
- package/dist/tina4.cjs.js +1 -1
- package/dist/tina4.es.js +18 -16
- package/package.json +5 -1
- package/readme.md +35 -0
- package/dist/api/fetch.d.ts +0 -37
- package/dist/api/fetch.d.ts.map +0 -1
- package/dist/api/index.d.ts +0 -6
- package/dist/api/index.d.ts.map +0 -1
- package/dist/core/component.d.ts +0 -53
- package/dist/core/component.d.ts.map +0 -1
- package/dist/core/html.d.ts +0 -8
- package/dist/core/html.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -9
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/signal.d.ts +0 -32
- package/dist/core/signal.d.ts.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +0 -1
- package/dist/pwa/index.d.ts +0 -6
- package/dist/pwa/index.d.ts.map +0 -1
- package/dist/pwa/pwa.d.ts +0 -24
- package/dist/pwa/pwa.d.ts.map +0 -1
- package/dist/router/index.d.ts +0 -6
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/router.d.ts +0 -34
- package/dist/router/router.d.ts.map +0 -1
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"});
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
if (
|
|
101
|
-
const o =
|
|
102
|
-
if (o && o.startsWith(
|
|
103
|
-
const s = parseInt(o.slice(
|
|
104
|
-
|
|
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
|
-
}),
|
|
32
|
+
}), e;
|
|
108
33
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
}),
|
|
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
|
|
116
|
-
const
|
|
117
|
-
for (let o = 0; o <
|
|
118
|
-
const s =
|
|
119
|
-
|
|
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
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
if (
|
|
47
|
+
function b(t, e) {
|
|
48
|
+
const n = t.parentNode;
|
|
49
|
+
if (n)
|
|
50
|
+
if (l(e)) {
|
|
126
51
|
const o = document.createTextNode("");
|
|
127
|
-
|
|
128
|
-
o.data = String(
|
|
52
|
+
n.replaceChild(o, t), d(() => {
|
|
53
|
+
o.data = String(e.value ?? "");
|
|
129
54
|
});
|
|
130
|
-
} else if (typeof
|
|
55
|
+
} else if (typeof e == "function") {
|
|
131
56
|
const o = document.createComment("");
|
|
132
|
-
|
|
57
|
+
n.replaceChild(o, t);
|
|
133
58
|
let s = [];
|
|
134
|
-
|
|
135
|
-
var
|
|
136
|
-
const
|
|
137
|
-
for (const
|
|
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
|
|
140
|
-
for (const
|
|
141
|
-
|
|
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 (
|
|
144
|
-
|
|
145
|
-
else if (
|
|
146
|
-
|
|
147
|
-
else if (Array.isArray(
|
|
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
|
|
150
|
-
const
|
|
151
|
-
for (const
|
|
74
|
+
for (const s of e) {
|
|
75
|
+
const f = p(s);
|
|
76
|
+
for (const r of f) o.appendChild(r);
|
|
152
77
|
}
|
|
153
|
-
|
|
78
|
+
n.replaceChild(o, t);
|
|
154
79
|
} else {
|
|
155
|
-
const o = document.createTextNode(String(
|
|
156
|
-
|
|
80
|
+
const o = document.createTextNode(String(e ?? ""));
|
|
81
|
+
n.replaceChild(o, t);
|
|
157
82
|
}
|
|
158
83
|
}
|
|
159
|
-
function
|
|
160
|
-
const
|
|
161
|
-
for (const o of Array.from(
|
|
162
|
-
const s = o.name,
|
|
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
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
typeof
|
|
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
|
-
|
|
94
|
+
n.push(s);
|
|
170
95
|
continue;
|
|
171
96
|
}
|
|
172
97
|
if (s.startsWith("?")) {
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
107
|
+
c && t.setAttribute(i, "");
|
|
183
108
|
}
|
|
184
|
-
|
|
109
|
+
n.push(s);
|
|
185
110
|
continue;
|
|
186
111
|
}
|
|
187
112
|
if (s.startsWith(".")) {
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}) :
|
|
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
|
-
|
|
120
|
+
n.push(s);
|
|
196
121
|
continue;
|
|
197
122
|
}
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
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
|
|
207
|
-
|
|
208
|
-
}) :
|
|
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
|
|
136
|
+
for (const o of n) t.removeAttribute(o);
|
|
212
137
|
}
|
|
213
|
-
function
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
if (
|
|
217
|
-
if (Array.isArray(
|
|
218
|
-
const
|
|
219
|
-
for (const
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
return [document.createTextNode(String(
|
|
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
|
|
225
|
-
return
|
|
149
|
+
function _(t) {
|
|
150
|
+
return t != null && typeof t == "object" && t.nodeType === 11;
|
|
226
151
|
}
|
|
227
|
-
function
|
|
228
|
-
let
|
|
229
|
-
for (let s = 0; s <
|
|
230
|
-
const
|
|
231
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
};
|