@hypen-space/web 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/canvas/accessibility.js +29 -4
- package/dist/src/canvas/accessibility.js.map +2 -2
- package/dist/src/canvas/events.js +152 -8
- package/dist/src/canvas/events.js.map +4 -3
- package/dist/src/canvas/index.js +2116 -20
- package/dist/src/canvas/index.js.map +11 -3
- package/dist/src/canvas/input.js +152 -7
- package/dist/src/canvas/input.js.map +4 -3
- package/dist/src/canvas/layout.js +256 -11
- package/dist/src/canvas/layout.js.map +5 -3
- package/dist/src/canvas/paint.js +256 -8
- package/dist/src/canvas/paint.js.map +5 -3
- package/dist/src/canvas/renderer.js +1866 -22
- package/dist/src/canvas/renderer.js.map +10 -3
- package/dist/src/canvas/text.js +152 -7
- package/dist/src/canvas/text.js.map +4 -3
- package/dist/src/canvas/utils.js +29 -4
- package/dist/src/canvas/utils.js.map +2 -2
- package/dist/src/dom/applicators/advanced-layout.js +29 -7
- package/dist/src/dom/applicators/advanced-layout.js.map +2 -2
- package/dist/src/dom/applicators/background.js +29 -7
- package/dist/src/dom/applicators/background.js.map +2 -2
- package/dist/src/dom/applicators/border.js +29 -7
- package/dist/src/dom/applicators/border.js.map +2 -2
- package/dist/src/dom/applicators/color.js +29 -7
- package/dist/src/dom/applicators/color.js.map +2 -2
- package/dist/src/dom/applicators/display.js +29 -7
- package/dist/src/dom/applicators/display.js.map +2 -2
- package/dist/src/dom/applicators/effects.js +29 -7
- package/dist/src/dom/applicators/effects.js.map +2 -2
- package/dist/src/dom/applicators/events.js +29 -7
- package/dist/src/dom/applicators/events.js.map +2 -2
- package/dist/src/dom/applicators/font.js +29 -7
- package/dist/src/dom/applicators/font.js.map +2 -2
- package/dist/src/dom/applicators/index.js +1244 -94
- package/dist/src/dom/applicators/index.js.map +18 -3
- package/dist/src/dom/applicators/layout.js +29 -7
- package/dist/src/dom/applicators/layout.js.map +2 -2
- package/dist/src/dom/applicators/margin.js +29 -6
- package/dist/src/dom/applicators/margin.js.map +2 -2
- package/dist/src/dom/applicators/padding.js +29 -9
- package/dist/src/dom/applicators/padding.js.map +2 -2
- package/dist/src/dom/applicators/size.js +29 -7
- package/dist/src/dom/applicators/size.js.map +2 -2
- package/dist/src/dom/applicators/transform.js +29 -7
- package/dist/src/dom/applicators/transform.js.map +2 -2
- package/dist/src/dom/applicators/transition.js +29 -7
- package/dist/src/dom/applicators/transition.js.map +2 -2
- package/dist/src/dom/applicators/typography.js +29 -7
- package/dist/src/dom/applicators/typography.js.map +2 -2
- package/dist/src/dom/canvas/index.js +29 -4
- package/dist/src/dom/canvas/index.js.map +2 -2
- package/dist/src/dom/components/audio.js +29 -7
- package/dist/src/dom/components/audio.js.map +2 -2
- package/dist/src/dom/components/avatar.js +29 -7
- package/dist/src/dom/components/avatar.js.map +2 -2
- package/dist/src/dom/components/badge.js +29 -7
- package/dist/src/dom/components/badge.js.map +2 -2
- package/dist/src/dom/components/button.js +29 -7
- package/dist/src/dom/components/button.js.map +2 -2
- package/dist/src/dom/components/card.js +29 -7
- package/dist/src/dom/components/card.js.map +2 -2
- package/dist/src/dom/components/center.js +29 -7
- package/dist/src/dom/components/center.js.map +2 -2
- package/dist/src/dom/components/checkbox.js +29 -7
- package/dist/src/dom/components/checkbox.js.map +2 -2
- package/dist/src/dom/components/column.js +29 -7
- package/dist/src/dom/components/column.js.map +2 -2
- package/dist/src/dom/components/container.js +29 -7
- package/dist/src/dom/components/container.js.map +2 -2
- package/dist/src/dom/components/divider.js +29 -7
- package/dist/src/dom/components/divider.js.map +2 -2
- package/dist/src/dom/components/grid.js +29 -7
- package/dist/src/dom/components/grid.js.map +2 -2
- package/dist/src/dom/components/heading.js +29 -7
- package/dist/src/dom/components/heading.js.map +2 -2
- package/dist/src/dom/components/image.js +29 -7
- package/dist/src/dom/components/image.js.map +2 -2
- package/dist/src/dom/components/index.js +1036 -187
- package/dist/src/dom/components/index.js.map +33 -3
- package/dist/src/dom/components/input.js +29 -7
- package/dist/src/dom/components/input.js.map +2 -2
- package/dist/src/dom/components/link.js +29 -7
- package/dist/src/dom/components/link.js.map +2 -2
- package/dist/src/dom/components/list.js +29 -7
- package/dist/src/dom/components/list.js.map +2 -2
- package/dist/src/dom/components/paragraph.js +29 -7
- package/dist/src/dom/components/paragraph.js.map +2 -2
- package/dist/src/dom/components/progressbar.js +29 -7
- package/dist/src/dom/components/progressbar.js.map +2 -2
- package/dist/src/dom/components/route.js +29 -7
- package/dist/src/dom/components/route.js.map +2 -2
- package/dist/src/dom/components/router.js +29 -7
- package/dist/src/dom/components/router.js.map +2 -2
- package/dist/src/dom/components/row.js +29 -7
- package/dist/src/dom/components/row.js.map +2 -2
- package/dist/src/dom/components/select.js +29 -7
- package/dist/src/dom/components/select.js.map +2 -2
- package/dist/src/dom/components/slider.js +29 -7
- package/dist/src/dom/components/slider.js.map +2 -2
- package/dist/src/dom/components/spacer.js +29 -7
- package/dist/src/dom/components/spacer.js.map +2 -2
- package/dist/src/dom/components/spinner.js +29 -7
- package/dist/src/dom/components/spinner.js.map +2 -2
- package/dist/src/dom/components/stack.js +29 -7
- package/dist/src/dom/components/stack.js.map +2 -2
- package/dist/src/dom/components/switch.js +29 -7
- package/dist/src/dom/components/switch.js.map +2 -2
- package/dist/src/dom/components/text.js +29 -7
- package/dist/src/dom/components/text.js.map +2 -2
- package/dist/src/dom/components/textarea.js +29 -7
- package/dist/src/dom/components/textarea.js.map +2 -2
- package/dist/src/dom/components/video.js +29 -7
- package/dist/src/dom/components/video.js.map +2 -2
- package/dist/src/dom/debug.js +29 -4
- package/dist/src/dom/debug.js.map +2 -2
- package/dist/src/dom/events.js +29 -4
- package/dist/src/dom/events.js.map +2 -2
- package/dist/src/dom/index.js +2999 -64
- package/dist/src/dom/index.js.map +54 -3
- package/dist/src/dom/renderer.js +2677 -63
- package/dist/src/dom/renderer.js.map +52 -3
- package/dist/src/hypen.js +2895 -56
- package/dist/src/hypen.js.map +53 -3
- package/dist/src/index.js +5419 -81
- package/dist/src/index.js.map +63 -3
- package/package.json +2 -2
- package/dist/chunk-2s02mkzs.js +0 -32
- package/dist/chunk-2s02mkzs.js.map +0 -9
package/dist/src/hypen.js
CHANGED
|
@@ -1,56 +1,2897 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
6
|
+
var __toCommonJS = (from) => {
|
|
7
|
+
var entry = __moduleCache.get(from), desc;
|
|
8
|
+
if (entry)
|
|
9
|
+
return entry;
|
|
10
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
}));
|
|
16
|
+
__moduleCache.set(from, entry);
|
|
17
|
+
return entry;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, {
|
|
22
|
+
get: all[name],
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
set: (newValue) => all[name] = () => newValue
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
|
+
|
|
30
|
+
// src/dom/components/column.ts
|
|
31
|
+
var exports_column = {};
|
|
32
|
+
__export(exports_column, {
|
|
33
|
+
columnHandler: () => columnHandler
|
|
34
|
+
});
|
|
35
|
+
var columnHandler;
|
|
36
|
+
var init_column = __esm(() => {
|
|
37
|
+
columnHandler = {
|
|
38
|
+
create() {
|
|
39
|
+
const el = document.createElement("div");
|
|
40
|
+
el.style.display = "flex";
|
|
41
|
+
el.style.flexDirection = "column";
|
|
42
|
+
el.dataset.hypenType = "column";
|
|
43
|
+
return el;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// src/dom/components/row.ts
|
|
49
|
+
var exports_row = {};
|
|
50
|
+
__export(exports_row, {
|
|
51
|
+
rowHandler: () => rowHandler
|
|
52
|
+
});
|
|
53
|
+
var rowHandler;
|
|
54
|
+
var init_row = __esm(() => {
|
|
55
|
+
rowHandler = {
|
|
56
|
+
create() {
|
|
57
|
+
const el = document.createElement("div");
|
|
58
|
+
el.style.display = "flex";
|
|
59
|
+
el.style.flexDirection = "row";
|
|
60
|
+
el.dataset.hypenType = "row";
|
|
61
|
+
return el;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/dom/components/text.ts
|
|
67
|
+
var exports_text = {};
|
|
68
|
+
__export(exports_text, {
|
|
69
|
+
textHandler: () => textHandler
|
|
70
|
+
});
|
|
71
|
+
var textHandler;
|
|
72
|
+
var init_text = __esm(() => {
|
|
73
|
+
textHandler = {
|
|
74
|
+
create() {
|
|
75
|
+
const el = document.createElement("span");
|
|
76
|
+
el.style.display = "inline-block";
|
|
77
|
+
el.dataset.hypenType = "text";
|
|
78
|
+
return el;
|
|
79
|
+
},
|
|
80
|
+
applyProps(el, props) {
|
|
81
|
+
const text = props["0"] || props.text;
|
|
82
|
+
if (text !== undefined) {
|
|
83
|
+
el.dataset.textTemplate = String(text);
|
|
84
|
+
el.textContent = String(text);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/dom/components/image.ts
|
|
91
|
+
var exports_image = {};
|
|
92
|
+
__export(exports_image, {
|
|
93
|
+
imageHandler: () => imageHandler
|
|
94
|
+
});
|
|
95
|
+
var imageHandler;
|
|
96
|
+
var init_image = __esm(() => {
|
|
97
|
+
imageHandler = {
|
|
98
|
+
create() {
|
|
99
|
+
const el = document.createElement("img");
|
|
100
|
+
el.dataset.hypenType = "image";
|
|
101
|
+
return el;
|
|
102
|
+
},
|
|
103
|
+
applyProps(el, props) {
|
|
104
|
+
const img = el;
|
|
105
|
+
const src = props["0"] || props.url || props.src;
|
|
106
|
+
if (src !== undefined) {
|
|
107
|
+
img.src = String(src);
|
|
108
|
+
}
|
|
109
|
+
if (props.alt !== undefined) {
|
|
110
|
+
img.alt = String(props.alt);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// src/dom/components/button.ts
|
|
117
|
+
var exports_button = {};
|
|
118
|
+
__export(exports_button, {
|
|
119
|
+
buttonHandler: () => buttonHandler
|
|
120
|
+
});
|
|
121
|
+
var buttonHandler;
|
|
122
|
+
var init_button = __esm(() => {
|
|
123
|
+
buttonHandler = {
|
|
124
|
+
create() {
|
|
125
|
+
const el = document.createElement("button");
|
|
126
|
+
el.dataset.hypenType = "button";
|
|
127
|
+
return el;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// src/dom/components/container.ts
|
|
133
|
+
var exports_container = {};
|
|
134
|
+
__export(exports_container, {
|
|
135
|
+
containerHandler: () => containerHandler
|
|
136
|
+
});
|
|
137
|
+
var containerHandler;
|
|
138
|
+
var init_container = __esm(() => {
|
|
139
|
+
containerHandler = {
|
|
140
|
+
create() {
|
|
141
|
+
const el = document.createElement("div");
|
|
142
|
+
el.dataset.hypenType = "container";
|
|
143
|
+
return el;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// src/dom/components/center.ts
|
|
149
|
+
var exports_center = {};
|
|
150
|
+
__export(exports_center, {
|
|
151
|
+
centerHandler: () => centerHandler
|
|
152
|
+
});
|
|
153
|
+
var centerHandler;
|
|
154
|
+
var init_center = __esm(() => {
|
|
155
|
+
centerHandler = {
|
|
156
|
+
create() {
|
|
157
|
+
const el = document.createElement("div");
|
|
158
|
+
el.style.display = "flex";
|
|
159
|
+
el.style.alignItems = "center";
|
|
160
|
+
el.style.justifyContent = "center";
|
|
161
|
+
el.dataset.hypenType = "center";
|
|
162
|
+
return el;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// src/dom/components/list.ts
|
|
168
|
+
var exports_list = {};
|
|
169
|
+
__export(exports_list, {
|
|
170
|
+
listHandler: () => listHandler
|
|
171
|
+
});
|
|
172
|
+
var listHandler;
|
|
173
|
+
var init_list = __esm(() => {
|
|
174
|
+
listHandler = {
|
|
175
|
+
create() {
|
|
176
|
+
const el = document.createElement("div");
|
|
177
|
+
el.style.display = "flex";
|
|
178
|
+
el.style.overflow = "auto";
|
|
179
|
+
el.dataset.hypenType = "list";
|
|
180
|
+
return el;
|
|
181
|
+
},
|
|
182
|
+
applyProps(el, props) {
|
|
183
|
+
const direction = props.direction || props["1"] || "vertical";
|
|
184
|
+
if (direction === "vertical") {
|
|
185
|
+
el.style.flexDirection = "column";
|
|
186
|
+
} else {
|
|
187
|
+
el.style.flexDirection = "row";
|
|
188
|
+
}
|
|
189
|
+
if (props.gap !== undefined) {
|
|
190
|
+
el.style.gap = typeof props.gap === "number" ? `${props.gap}px` : String(props.gap);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// src/dom/components/input.ts
|
|
197
|
+
var exports_input = {};
|
|
198
|
+
__export(exports_input, {
|
|
199
|
+
inputHandler: () => inputHandler
|
|
200
|
+
});
|
|
201
|
+
var inputHandler;
|
|
202
|
+
var init_input = __esm(() => {
|
|
203
|
+
inputHandler = {
|
|
204
|
+
create() {
|
|
205
|
+
const el = document.createElement("input");
|
|
206
|
+
el.dataset.hypenType = "input";
|
|
207
|
+
return el;
|
|
208
|
+
},
|
|
209
|
+
applyProps(el, props) {
|
|
210
|
+
const input = el;
|
|
211
|
+
if (props.type !== undefined) {
|
|
212
|
+
input.type = String(props.type);
|
|
213
|
+
}
|
|
214
|
+
if (props.placeholder !== undefined) {
|
|
215
|
+
input.placeholder = String(props.placeholder);
|
|
216
|
+
}
|
|
217
|
+
if (props.value !== undefined) {
|
|
218
|
+
input.value = String(props.value);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// src/dom/components/link.ts
|
|
225
|
+
var exports_link = {};
|
|
226
|
+
__export(exports_link, {
|
|
227
|
+
linkHandler: () => linkHandler
|
|
228
|
+
});
|
|
229
|
+
var linkHandler;
|
|
230
|
+
var init_link = __esm(() => {
|
|
231
|
+
linkHandler = {
|
|
232
|
+
create() {
|
|
233
|
+
const el = document.createElement("a");
|
|
234
|
+
el.dataset.hypenType = "link";
|
|
235
|
+
return el;
|
|
236
|
+
},
|
|
237
|
+
applyProps(el, props) {
|
|
238
|
+
const anchor = el;
|
|
239
|
+
const href = props["0"] || props.href;
|
|
240
|
+
if (href !== undefined) {
|
|
241
|
+
anchor.href = String(href);
|
|
242
|
+
}
|
|
243
|
+
if (props.target !== undefined) {
|
|
244
|
+
anchor.target = String(props.target);
|
|
245
|
+
}
|
|
246
|
+
if (props.rel !== undefined) {
|
|
247
|
+
anchor.rel = String(props.rel);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// src/dom/components/textarea.ts
|
|
254
|
+
var exports_textarea = {};
|
|
255
|
+
__export(exports_textarea, {
|
|
256
|
+
textareaHandler: () => textareaHandler
|
|
257
|
+
});
|
|
258
|
+
var textareaHandler;
|
|
259
|
+
var init_textarea = __esm(() => {
|
|
260
|
+
textareaHandler = {
|
|
261
|
+
create() {
|
|
262
|
+
const el = document.createElement("textarea");
|
|
263
|
+
el.dataset.hypenType = "textarea";
|
|
264
|
+
return el;
|
|
265
|
+
},
|
|
266
|
+
applyProps(el, props) {
|
|
267
|
+
const textarea = el;
|
|
268
|
+
const value = props["0"] || props.value;
|
|
269
|
+
if (value !== undefined) {
|
|
270
|
+
textarea.value = String(value);
|
|
271
|
+
}
|
|
272
|
+
if (props.placeholder !== undefined) {
|
|
273
|
+
textarea.placeholder = String(props.placeholder);
|
|
274
|
+
}
|
|
275
|
+
if (props.rows !== undefined) {
|
|
276
|
+
textarea.rows = Number(props.rows);
|
|
277
|
+
}
|
|
278
|
+
if (props.cols !== undefined) {
|
|
279
|
+
textarea.cols = Number(props.cols);
|
|
280
|
+
}
|
|
281
|
+
if (props.disabled !== undefined) {
|
|
282
|
+
textarea.disabled = Boolean(props.disabled);
|
|
283
|
+
}
|
|
284
|
+
if (props.readonly !== undefined) {
|
|
285
|
+
textarea.readOnly = Boolean(props.readonly);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// src/dom/components/checkbox.ts
|
|
292
|
+
var exports_checkbox = {};
|
|
293
|
+
__export(exports_checkbox, {
|
|
294
|
+
checkboxHandler: () => checkboxHandler
|
|
295
|
+
});
|
|
296
|
+
var checkboxHandler;
|
|
297
|
+
var init_checkbox = __esm(() => {
|
|
298
|
+
checkboxHandler = {
|
|
299
|
+
create() {
|
|
300
|
+
const wrapper = document.createElement("label");
|
|
301
|
+
wrapper.dataset.hypenType = "checkbox";
|
|
302
|
+
wrapper.style.display = "inline-flex";
|
|
303
|
+
wrapper.style.alignItems = "center";
|
|
304
|
+
wrapper.style.gap = "8px";
|
|
305
|
+
wrapper.style.cursor = "pointer";
|
|
306
|
+
const input = document.createElement("input");
|
|
307
|
+
input.type = "checkbox";
|
|
308
|
+
input.dataset.hypenCheckbox = "true";
|
|
309
|
+
wrapper.appendChild(input);
|
|
310
|
+
return wrapper;
|
|
311
|
+
},
|
|
312
|
+
applyProps(el, props) {
|
|
313
|
+
const input = el.querySelector('input[type="checkbox"]');
|
|
314
|
+
if (!input)
|
|
315
|
+
return;
|
|
316
|
+
if (props.checked !== undefined) {
|
|
317
|
+
input.checked = Boolean(props.checked);
|
|
318
|
+
}
|
|
319
|
+
if (props.disabled !== undefined) {
|
|
320
|
+
input.disabled = Boolean(props.disabled);
|
|
321
|
+
}
|
|
322
|
+
const label = props["0"] || props.label;
|
|
323
|
+
if (label !== undefined) {
|
|
324
|
+
const textNodes = Array.from(el.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE);
|
|
325
|
+
textNodes.forEach((node) => node.remove());
|
|
326
|
+
el.appendChild(document.createTextNode(String(label)));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// src/dom/components/select.ts
|
|
333
|
+
var exports_select = {};
|
|
334
|
+
__export(exports_select, {
|
|
335
|
+
selectHandler: () => selectHandler
|
|
336
|
+
});
|
|
337
|
+
var selectHandler;
|
|
338
|
+
var init_select = __esm(() => {
|
|
339
|
+
selectHandler = {
|
|
340
|
+
create() {
|
|
341
|
+
const el = document.createElement("select");
|
|
342
|
+
el.dataset.hypenType = "select";
|
|
343
|
+
return el;
|
|
344
|
+
},
|
|
345
|
+
applyProps(el, props) {
|
|
346
|
+
const select = el;
|
|
347
|
+
if (props.value !== undefined) {
|
|
348
|
+
select.value = String(props.value);
|
|
349
|
+
}
|
|
350
|
+
if (props.disabled !== undefined) {
|
|
351
|
+
select.disabled = Boolean(props.disabled);
|
|
352
|
+
}
|
|
353
|
+
if (props.multiple !== undefined) {
|
|
354
|
+
select.multiple = Boolean(props.multiple);
|
|
355
|
+
}
|
|
356
|
+
if (props.options && Array.isArray(props.options)) {
|
|
357
|
+
select.innerHTML = "";
|
|
358
|
+
props.options.forEach((opt) => {
|
|
359
|
+
const option = document.createElement("option");
|
|
360
|
+
if (typeof opt === "string") {
|
|
361
|
+
option.value = opt;
|
|
362
|
+
option.textContent = opt;
|
|
363
|
+
} else if (typeof opt === "object") {
|
|
364
|
+
option.value = String(opt.value ?? opt.label ?? "");
|
|
365
|
+
option.textContent = String(opt.label ?? opt.value ?? "");
|
|
366
|
+
if (opt.disabled)
|
|
367
|
+
option.disabled = true;
|
|
368
|
+
}
|
|
369
|
+
select.appendChild(option);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// src/dom/components/spacer.ts
|
|
377
|
+
var exports_spacer = {};
|
|
378
|
+
__export(exports_spacer, {
|
|
379
|
+
spacerHandler: () => spacerHandler
|
|
380
|
+
});
|
|
381
|
+
var spacerHandler;
|
|
382
|
+
var init_spacer = __esm(() => {
|
|
383
|
+
spacerHandler = {
|
|
384
|
+
create() {
|
|
385
|
+
const el = document.createElement("div");
|
|
386
|
+
el.style.flex = "1";
|
|
387
|
+
el.dataset.hypenType = "spacer";
|
|
388
|
+
return el;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
// src/dom/components/stack.ts
|
|
394
|
+
var exports_stack = {};
|
|
395
|
+
__export(exports_stack, {
|
|
396
|
+
stackHandler: () => stackHandler
|
|
397
|
+
});
|
|
398
|
+
var stackHandler;
|
|
399
|
+
var init_stack = __esm(() => {
|
|
400
|
+
stackHandler = {
|
|
401
|
+
create() {
|
|
402
|
+
const el = document.createElement("div");
|
|
403
|
+
el.style.position = "relative";
|
|
404
|
+
el.style.display = "flex";
|
|
405
|
+
el.dataset.hypenType = "stack";
|
|
406
|
+
const style = document.createElement("style");
|
|
407
|
+
style.textContent = `
|
|
408
|
+
[data-hypen-type="stack"] > * {
|
|
409
|
+
position: absolute;
|
|
410
|
+
top: 0;
|
|
411
|
+
left: 0;
|
|
412
|
+
width: 100%;
|
|
413
|
+
height: 100%;
|
|
414
|
+
}
|
|
415
|
+
[data-hypen-type="stack"] > *:first-child {
|
|
416
|
+
position: relative;
|
|
417
|
+
}
|
|
418
|
+
`;
|
|
419
|
+
el.appendChild(style);
|
|
420
|
+
return el;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// src/dom/components/divider.ts
|
|
426
|
+
var exports_divider = {};
|
|
427
|
+
__export(exports_divider, {
|
|
428
|
+
dividerHandler: () => dividerHandler
|
|
429
|
+
});
|
|
430
|
+
var dividerHandler;
|
|
431
|
+
var init_divider = __esm(() => {
|
|
432
|
+
dividerHandler = {
|
|
433
|
+
create() {
|
|
434
|
+
const el = document.createElement("hr");
|
|
435
|
+
el.dataset.hypenType = "divider";
|
|
436
|
+
el.style.border = "none";
|
|
437
|
+
el.style.borderTop = "1px solid #e0e0e0";
|
|
438
|
+
el.style.margin = "0";
|
|
439
|
+
return el;
|
|
440
|
+
},
|
|
441
|
+
applyProps(el, props) {
|
|
442
|
+
if (props.thickness !== undefined) {
|
|
443
|
+
const thickness = typeof props.thickness === "number" ? `${props.thickness}px` : String(props.thickness);
|
|
444
|
+
el.style.borderTopWidth = thickness;
|
|
445
|
+
}
|
|
446
|
+
if (props.orientation === "vertical") {
|
|
447
|
+
el.style.borderTop = "none";
|
|
448
|
+
el.style.borderLeft = "1px solid #e0e0e0";
|
|
449
|
+
el.style.height = "100%";
|
|
450
|
+
el.style.width = "0";
|
|
451
|
+
el.style.display = "inline-block";
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// src/dom/components/grid.ts
|
|
458
|
+
var exports_grid = {};
|
|
459
|
+
__export(exports_grid, {
|
|
460
|
+
gridHandler: () => gridHandler
|
|
461
|
+
});
|
|
462
|
+
var gridHandler;
|
|
463
|
+
var init_grid = __esm(() => {
|
|
464
|
+
gridHandler = {
|
|
465
|
+
create() {
|
|
466
|
+
const el = document.createElement("div");
|
|
467
|
+
el.style.display = "grid";
|
|
468
|
+
el.dataset.hypenType = "grid";
|
|
469
|
+
return el;
|
|
470
|
+
},
|
|
471
|
+
applyProps(el, props) {
|
|
472
|
+
if (props.columns !== undefined) {
|
|
473
|
+
const columns = typeof props.columns === "number" ? `repeat(${props.columns}, 1fr)` : String(props.columns);
|
|
474
|
+
el.style.gridTemplateColumns = columns;
|
|
475
|
+
}
|
|
476
|
+
if (props.rows !== undefined) {
|
|
477
|
+
const rows = typeof props.rows === "number" ? `repeat(${props.rows}, 1fr)` : String(props.rows);
|
|
478
|
+
el.style.gridTemplateRows = rows;
|
|
479
|
+
}
|
|
480
|
+
if (props.gap !== undefined) {
|
|
481
|
+
const gap = typeof props.gap === "number" ? `${props.gap}px` : String(props.gap);
|
|
482
|
+
el.style.gap = gap;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// src/dom/components/card.ts
|
|
489
|
+
var exports_card = {};
|
|
490
|
+
__export(exports_card, {
|
|
491
|
+
cardHandler: () => cardHandler
|
|
492
|
+
});
|
|
493
|
+
var cardHandler;
|
|
494
|
+
var init_card = __esm(() => {
|
|
495
|
+
cardHandler = {
|
|
496
|
+
create() {
|
|
497
|
+
const el = document.createElement("div");
|
|
498
|
+
el.dataset.hypenType = "card";
|
|
499
|
+
el.style.backgroundColor = "#ffffff";
|
|
500
|
+
el.style.borderRadius = "8px";
|
|
501
|
+
el.style.boxShadow = "0 2px 4px rgba(0, 0, 0, 0.1)";
|
|
502
|
+
el.style.padding = "16px";
|
|
503
|
+
return el;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// src/dom/components/heading.ts
|
|
509
|
+
var exports_heading = {};
|
|
510
|
+
__export(exports_heading, {
|
|
511
|
+
headingHandler: () => headingHandler
|
|
512
|
+
});
|
|
513
|
+
var headingHandler;
|
|
514
|
+
var init_heading = __esm(() => {
|
|
515
|
+
headingHandler = {
|
|
516
|
+
create() {
|
|
517
|
+
const el = document.createElement("h2");
|
|
518
|
+
el.dataset.hypenType = "heading";
|
|
519
|
+
return el;
|
|
520
|
+
},
|
|
521
|
+
applyProps(el, props) {
|
|
522
|
+
if (props.level !== undefined) {
|
|
523
|
+
const level = Math.max(1, Math.min(6, Number(props.level)));
|
|
524
|
+
const newEl = document.createElement(`h${level}`);
|
|
525
|
+
newEl.dataset.hypenType = "heading";
|
|
526
|
+
newEl.innerHTML = el.innerHTML;
|
|
527
|
+
Array.from(el.attributes).forEach((attr) => {
|
|
528
|
+
newEl.setAttribute(attr.name, attr.value);
|
|
529
|
+
});
|
|
530
|
+
if (el.parentNode) {
|
|
531
|
+
el.parentNode.replaceChild(newEl, el);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
const text = props["0"] || props.text;
|
|
535
|
+
if (text !== undefined) {
|
|
536
|
+
el.textContent = String(text);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// src/dom/components/switch.ts
|
|
543
|
+
var exports_switch = {};
|
|
544
|
+
__export(exports_switch, {
|
|
545
|
+
switchHandler: () => switchHandler
|
|
546
|
+
});
|
|
547
|
+
var switchHandler;
|
|
548
|
+
var init_switch = __esm(() => {
|
|
549
|
+
switchHandler = {
|
|
550
|
+
create() {
|
|
551
|
+
const wrapper = document.createElement("label");
|
|
552
|
+
wrapper.dataset.hypenType = "switch";
|
|
553
|
+
wrapper.style.display = "inline-flex";
|
|
554
|
+
wrapper.style.alignItems = "center";
|
|
555
|
+
wrapper.style.gap = "8px";
|
|
556
|
+
wrapper.style.cursor = "pointer";
|
|
557
|
+
const input = document.createElement("input");
|
|
558
|
+
input.type = "checkbox";
|
|
559
|
+
input.dataset.hypenSwitch = "true";
|
|
560
|
+
input.style.appearance = "none";
|
|
561
|
+
input.style.width = "44px";
|
|
562
|
+
input.style.height = "24px";
|
|
563
|
+
input.style.backgroundColor = "#ccc";
|
|
564
|
+
input.style.borderRadius = "12px";
|
|
565
|
+
input.style.position = "relative";
|
|
566
|
+
input.style.cursor = "pointer";
|
|
567
|
+
input.style.transition = "background-color 0.2s";
|
|
568
|
+
const style = document.createElement("style");
|
|
569
|
+
style.textContent = `
|
|
570
|
+
input[data-hypen-switch="true"]::before {
|
|
571
|
+
content: "";
|
|
572
|
+
position: absolute;
|
|
573
|
+
width: 20px;
|
|
574
|
+
height: 20px;
|
|
575
|
+
background-color: white;
|
|
576
|
+
border-radius: 50%;
|
|
577
|
+
top: 2px;
|
|
578
|
+
left: 2px;
|
|
579
|
+
transition: transform 0.2s;
|
|
580
|
+
}
|
|
581
|
+
input[data-hypen-switch="true"]:checked {
|
|
582
|
+
background-color: #4CAF50;
|
|
583
|
+
}
|
|
584
|
+
input[data-hypen-switch="true"]:checked::before {
|
|
585
|
+
transform: translateX(20px);
|
|
586
|
+
}
|
|
587
|
+
`;
|
|
588
|
+
wrapper.appendChild(style);
|
|
589
|
+
wrapper.appendChild(input);
|
|
590
|
+
return wrapper;
|
|
591
|
+
},
|
|
592
|
+
applyProps(el, props) {
|
|
593
|
+
const input = el.querySelector('input[type="checkbox"]');
|
|
594
|
+
if (!input)
|
|
595
|
+
return;
|
|
596
|
+
if (props.on !== undefined) {
|
|
597
|
+
input.checked = Boolean(props.on);
|
|
598
|
+
}
|
|
599
|
+
if (props.disabled !== undefined) {
|
|
600
|
+
input.disabled = Boolean(props.disabled);
|
|
601
|
+
}
|
|
602
|
+
const label = props["0"] || props.label;
|
|
603
|
+
if (label !== undefined) {
|
|
604
|
+
const textNodes = Array.from(el.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE);
|
|
605
|
+
textNodes.forEach((node) => node.remove());
|
|
606
|
+
el.appendChild(document.createTextNode(String(label)));
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// src/dom/components/slider.ts
|
|
613
|
+
var exports_slider = {};
|
|
614
|
+
__export(exports_slider, {
|
|
615
|
+
sliderHandler: () => sliderHandler
|
|
616
|
+
});
|
|
617
|
+
var sliderHandler;
|
|
618
|
+
var init_slider = __esm(() => {
|
|
619
|
+
sliderHandler = {
|
|
620
|
+
create() {
|
|
621
|
+
const el = document.createElement("input");
|
|
622
|
+
el.type = "range";
|
|
623
|
+
el.dataset.hypenType = "slider";
|
|
624
|
+
return el;
|
|
625
|
+
},
|
|
626
|
+
applyProps(el, props) {
|
|
627
|
+
const input = el;
|
|
628
|
+
if (props.value !== undefined) {
|
|
629
|
+
input.value = String(props.value);
|
|
630
|
+
}
|
|
631
|
+
if (props.min !== undefined) {
|
|
632
|
+
input.min = String(props.min);
|
|
633
|
+
}
|
|
634
|
+
if (props.max !== undefined) {
|
|
635
|
+
input.max = String(props.max);
|
|
636
|
+
}
|
|
637
|
+
if (props.step !== undefined) {
|
|
638
|
+
input.step = String(props.step);
|
|
639
|
+
}
|
|
640
|
+
if (props.disabled !== undefined) {
|
|
641
|
+
input.disabled = Boolean(props.disabled);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
// src/dom/components/spinner.ts
|
|
648
|
+
var exports_spinner = {};
|
|
649
|
+
__export(exports_spinner, {
|
|
650
|
+
spinnerHandler: () => spinnerHandler
|
|
651
|
+
});
|
|
652
|
+
var spinnerHandler;
|
|
653
|
+
var init_spinner = __esm(() => {
|
|
654
|
+
spinnerHandler = {
|
|
655
|
+
create() {
|
|
656
|
+
const wrapper = document.createElement("div");
|
|
657
|
+
wrapper.dataset.hypenType = "spinner";
|
|
658
|
+
wrapper.style.display = "inline-block";
|
|
659
|
+
const spinner = document.createElement("div");
|
|
660
|
+
spinner.style.width = "40px";
|
|
661
|
+
spinner.style.height = "40px";
|
|
662
|
+
spinner.style.border = "4px solid #f3f3f3";
|
|
663
|
+
spinner.style.borderTop = "4px solid #3498db";
|
|
664
|
+
spinner.style.borderRadius = "50%";
|
|
665
|
+
spinner.style.animation = "spin 1s linear infinite";
|
|
666
|
+
const style = document.createElement("style");
|
|
667
|
+
style.textContent = `
|
|
668
|
+
@keyframes spin {
|
|
669
|
+
0% { transform: rotate(0deg); }
|
|
670
|
+
100% { transform: rotate(360deg); }
|
|
671
|
+
}
|
|
672
|
+
`;
|
|
673
|
+
wrapper.appendChild(style);
|
|
674
|
+
wrapper.appendChild(spinner);
|
|
675
|
+
return wrapper;
|
|
676
|
+
},
|
|
677
|
+
applyProps(el, props) {
|
|
678
|
+
const spinner = el.querySelector("div:not(style)");
|
|
679
|
+
if (!spinner)
|
|
680
|
+
return;
|
|
681
|
+
if (props.size !== undefined) {
|
|
682
|
+
const size = String(props.size);
|
|
683
|
+
const sizeMap = {
|
|
684
|
+
small: "24px",
|
|
685
|
+
medium: "40px",
|
|
686
|
+
large: "60px"
|
|
687
|
+
};
|
|
688
|
+
const actualSize = sizeMap[size] || size;
|
|
689
|
+
spinner.style.width = actualSize;
|
|
690
|
+
spinner.style.height = actualSize;
|
|
691
|
+
}
|
|
692
|
+
if (props.color !== undefined) {
|
|
693
|
+
spinner.style.borderTopColor = String(props.color);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
// src/dom/components/badge.ts
|
|
700
|
+
var exports_badge = {};
|
|
701
|
+
__export(exports_badge, {
|
|
702
|
+
badgeHandler: () => badgeHandler
|
|
703
|
+
});
|
|
704
|
+
var badgeHandler;
|
|
705
|
+
var init_badge = __esm(() => {
|
|
706
|
+
badgeHandler = {
|
|
707
|
+
create() {
|
|
708
|
+
const el = document.createElement("span");
|
|
709
|
+
el.dataset.hypenType = "badge";
|
|
710
|
+
el.style.display = "inline-block";
|
|
711
|
+
el.style.padding = "4px 8px";
|
|
712
|
+
el.style.borderRadius = "4px";
|
|
713
|
+
el.style.fontSize = "12px";
|
|
714
|
+
el.style.fontWeight = "600";
|
|
715
|
+
el.style.backgroundColor = "#e0e0e0";
|
|
716
|
+
el.style.color = "#333";
|
|
717
|
+
return el;
|
|
718
|
+
},
|
|
719
|
+
applyProps(el, props) {
|
|
720
|
+
if (props.theme !== undefined) {
|
|
721
|
+
const theme = String(props.theme);
|
|
722
|
+
const themeColors = {
|
|
723
|
+
success: { bg: "#4CAF50", color: "#fff" },
|
|
724
|
+
error: { bg: "#f44336", color: "#fff" },
|
|
725
|
+
warning: { bg: "#ff9800", color: "#fff" },
|
|
726
|
+
info: { bg: "#2196F3", color: "#fff" },
|
|
727
|
+
default: { bg: "#e0e0e0", color: "#333" }
|
|
728
|
+
};
|
|
729
|
+
const colors = themeColors[theme] || themeColors.default;
|
|
730
|
+
el.style.backgroundColor = colors.bg;
|
|
731
|
+
el.style.color = colors.color;
|
|
732
|
+
}
|
|
733
|
+
const text = props["0"] || props.text;
|
|
734
|
+
if (text !== undefined) {
|
|
735
|
+
el.textContent = String(text);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// src/dom/components/avatar.ts
|
|
742
|
+
var exports_avatar = {};
|
|
743
|
+
__export(exports_avatar, {
|
|
744
|
+
avatarHandler: () => avatarHandler
|
|
745
|
+
});
|
|
746
|
+
var avatarHandler;
|
|
747
|
+
var init_avatar = __esm(() => {
|
|
748
|
+
avatarHandler = {
|
|
749
|
+
create() {
|
|
750
|
+
const el = document.createElement("div");
|
|
751
|
+
el.dataset.hypenType = "avatar";
|
|
752
|
+
el.style.display = "inline-flex";
|
|
753
|
+
el.style.alignItems = "center";
|
|
754
|
+
el.style.justifyContent = "center";
|
|
755
|
+
el.style.width = "40px";
|
|
756
|
+
el.style.height = "40px";
|
|
757
|
+
el.style.borderRadius = "50%";
|
|
758
|
+
el.style.backgroundColor = "#9e9e9e";
|
|
759
|
+
el.style.color = "#fff";
|
|
760
|
+
el.style.fontSize = "16px";
|
|
761
|
+
el.style.fontWeight = "600";
|
|
762
|
+
el.style.overflow = "hidden";
|
|
763
|
+
return el;
|
|
764
|
+
},
|
|
765
|
+
applyProps(el, props) {
|
|
766
|
+
if (props.src !== undefined) {
|
|
767
|
+
const img = document.createElement("img");
|
|
768
|
+
img.src = String(props.src);
|
|
769
|
+
img.style.width = "100%";
|
|
770
|
+
img.style.height = "100%";
|
|
771
|
+
img.style.objectFit = "cover";
|
|
772
|
+
el.innerHTML = "";
|
|
773
|
+
el.appendChild(img);
|
|
774
|
+
} else if (props.initials !== undefined) {
|
|
775
|
+
el.textContent = String(props.initials).toUpperCase();
|
|
776
|
+
}
|
|
777
|
+
if (props.size !== undefined) {
|
|
778
|
+
const size = typeof props.size === "number" ? `${props.size}px` : String(props.size);
|
|
779
|
+
el.style.width = size;
|
|
780
|
+
el.style.height = size;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
// src/dom/components/progressbar.ts
|
|
787
|
+
var exports_progressbar = {};
|
|
788
|
+
__export(exports_progressbar, {
|
|
789
|
+
progressBarHandler: () => progressBarHandler
|
|
790
|
+
});
|
|
791
|
+
var progressBarHandler;
|
|
792
|
+
var init_progressbar = __esm(() => {
|
|
793
|
+
progressBarHandler = {
|
|
794
|
+
create() {
|
|
795
|
+
const wrapper = document.createElement("div");
|
|
796
|
+
wrapper.dataset.hypenType = "progressbar";
|
|
797
|
+
wrapper.style.width = "100%";
|
|
798
|
+
wrapper.style.height = "8px";
|
|
799
|
+
wrapper.style.backgroundColor = "#e0e0e0";
|
|
800
|
+
wrapper.style.borderRadius = "4px";
|
|
801
|
+
wrapper.style.overflow = "hidden";
|
|
802
|
+
const bar = document.createElement("div");
|
|
803
|
+
bar.dataset.hypenBar = "true";
|
|
804
|
+
bar.style.height = "100%";
|
|
805
|
+
bar.style.backgroundColor = "#2196F3";
|
|
806
|
+
bar.style.transition = "width 0.3s ease";
|
|
807
|
+
bar.style.width = "0%";
|
|
808
|
+
wrapper.appendChild(bar);
|
|
809
|
+
return wrapper;
|
|
810
|
+
},
|
|
811
|
+
applyProps(el, props) {
|
|
812
|
+
const bar = el.querySelector('[data-hypen-bar="true"]');
|
|
813
|
+
if (!bar)
|
|
814
|
+
return;
|
|
815
|
+
const value = Number(props.value || 0);
|
|
816
|
+
const max = Number(props.max || 100);
|
|
817
|
+
const percentage = Math.min(100, Math.max(0, value / max * 100));
|
|
818
|
+
bar.style.width = `${percentage}%`;
|
|
819
|
+
if (props.color !== undefined) {
|
|
820
|
+
bar.style.backgroundColor = String(props.color);
|
|
821
|
+
}
|
|
822
|
+
if (props.height !== undefined) {
|
|
823
|
+
const height = typeof props.height === "number" ? `${props.height}px` : String(props.height);
|
|
824
|
+
el.style.height = height;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// src/dom/components/video.ts
|
|
831
|
+
var exports_video = {};
|
|
832
|
+
__export(exports_video, {
|
|
833
|
+
videoHandler: () => videoHandler
|
|
834
|
+
});
|
|
835
|
+
var videoHandler;
|
|
836
|
+
var init_video = __esm(() => {
|
|
837
|
+
videoHandler = {
|
|
838
|
+
create() {
|
|
839
|
+
const el = document.createElement("video");
|
|
840
|
+
el.dataset.hypenType = "video";
|
|
841
|
+
return el;
|
|
842
|
+
},
|
|
843
|
+
applyProps(el, props) {
|
|
844
|
+
const video = el;
|
|
845
|
+
const src = props["0"] || props.src;
|
|
846
|
+
if (src !== undefined) {
|
|
847
|
+
video.src = String(src);
|
|
848
|
+
}
|
|
849
|
+
if (props.controls !== undefined) {
|
|
850
|
+
video.controls = Boolean(props.controls);
|
|
851
|
+
}
|
|
852
|
+
if (props.autoplay !== undefined) {
|
|
853
|
+
video.autoplay = Boolean(props.autoplay);
|
|
854
|
+
}
|
|
855
|
+
if (props.loop !== undefined) {
|
|
856
|
+
video.loop = Boolean(props.loop);
|
|
857
|
+
}
|
|
858
|
+
if (props.muted !== undefined) {
|
|
859
|
+
video.muted = Boolean(props.muted);
|
|
860
|
+
}
|
|
861
|
+
if (props.poster !== undefined) {
|
|
862
|
+
video.poster = String(props.poster);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
// src/dom/components/audio.ts
|
|
869
|
+
var exports_audio = {};
|
|
870
|
+
__export(exports_audio, {
|
|
871
|
+
audioHandler: () => audioHandler
|
|
872
|
+
});
|
|
873
|
+
var audioHandler;
|
|
874
|
+
var init_audio = __esm(() => {
|
|
875
|
+
audioHandler = {
|
|
876
|
+
create() {
|
|
877
|
+
const el = document.createElement("audio");
|
|
878
|
+
el.dataset.hypenType = "audio";
|
|
879
|
+
return el;
|
|
880
|
+
},
|
|
881
|
+
applyProps(el, props) {
|
|
882
|
+
const audio = el;
|
|
883
|
+
const src = props["0"] || props.src;
|
|
884
|
+
if (src !== undefined) {
|
|
885
|
+
audio.src = String(src);
|
|
886
|
+
}
|
|
887
|
+
if (props.controls !== undefined) {
|
|
888
|
+
audio.controls = Boolean(props.controls);
|
|
889
|
+
}
|
|
890
|
+
if (props.autoplay !== undefined) {
|
|
891
|
+
audio.autoplay = Boolean(props.autoplay);
|
|
892
|
+
}
|
|
893
|
+
if (props.loop !== undefined) {
|
|
894
|
+
audio.loop = Boolean(props.loop);
|
|
895
|
+
}
|
|
896
|
+
if (props.muted !== undefined) {
|
|
897
|
+
audio.muted = Boolean(props.muted);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// src/dom/components/paragraph.ts
|
|
904
|
+
var exports_paragraph = {};
|
|
905
|
+
__export(exports_paragraph, {
|
|
906
|
+
paragraphHandler: () => paragraphHandler
|
|
907
|
+
});
|
|
908
|
+
var paragraphHandler;
|
|
909
|
+
var init_paragraph = __esm(() => {
|
|
910
|
+
paragraphHandler = {
|
|
911
|
+
create() {
|
|
912
|
+
const el = document.createElement("p");
|
|
913
|
+
el.dataset.hypenType = "paragraph";
|
|
914
|
+
return el;
|
|
915
|
+
},
|
|
916
|
+
applyProps(el, props) {
|
|
917
|
+
const text = props["0"] || props.text;
|
|
918
|
+
if (text !== undefined) {
|
|
919
|
+
el.textContent = String(text);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
// src/dom/components/router.ts
|
|
926
|
+
var exports_router = {};
|
|
927
|
+
__export(exports_router, {
|
|
928
|
+
routerHandler: () => routerHandler
|
|
929
|
+
});
|
|
930
|
+
var routerHandler;
|
|
931
|
+
var init_router = __esm(() => {
|
|
932
|
+
routerHandler = {
|
|
933
|
+
create() {
|
|
934
|
+
const el = document.createElement("div");
|
|
935
|
+
el.style.display = "flex";
|
|
936
|
+
el.style.flexDirection = "column";
|
|
937
|
+
el.style.width = "100%";
|
|
938
|
+
el.dataset.hypenType = "router";
|
|
939
|
+
return el;
|
|
940
|
+
},
|
|
941
|
+
applyProps(el, props) {}
|
|
942
|
+
};
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// src/dom/components/route.ts
|
|
946
|
+
var exports_route = {};
|
|
947
|
+
__export(exports_route, {
|
|
948
|
+
routeHandler: () => routeHandler
|
|
949
|
+
});
|
|
950
|
+
var routeHandler;
|
|
951
|
+
var init_route = __esm(() => {
|
|
952
|
+
routeHandler = {
|
|
953
|
+
create() {
|
|
954
|
+
const el = document.createElement("div");
|
|
955
|
+
el.style.display = "flex";
|
|
956
|
+
el.style.flexDirection = "column";
|
|
957
|
+
el.style.width = "100%";
|
|
958
|
+
el.dataset.hypenType = "route";
|
|
959
|
+
el.dataset.routeRendered = "false";
|
|
960
|
+
return el;
|
|
961
|
+
},
|
|
962
|
+
applyProps(el, props) {
|
|
963
|
+
const path = props.path || props["0"] || "/";
|
|
964
|
+
el.dataset.routePath = String(path);
|
|
965
|
+
const isLazy = props.__lazy === true;
|
|
966
|
+
el.dataset.routeLazy = String(isLazy);
|
|
967
|
+
const componentName = props.component || props.__lazy_child;
|
|
968
|
+
if (componentName) {
|
|
969
|
+
el.dataset.routeComponent = String(componentName);
|
|
970
|
+
}
|
|
971
|
+
console.log(`\uD83D\uDEE3️ Route created: path="${path}", lazy=${isLazy}, component="${el.dataset.routeComponent || "none"}"`);
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// src/dom/applicators/padding.ts
|
|
977
|
+
var exports_padding = {};
|
|
978
|
+
__export(exports_padding, {
|
|
979
|
+
paddingHandler: () => paddingHandler
|
|
980
|
+
});
|
|
981
|
+
var paddingHandler = (el, value) => {
|
|
982
|
+
if (typeof value === "number") {
|
|
983
|
+
el.style.padding = `${value}px`;
|
|
984
|
+
} else if (typeof value === "object") {
|
|
985
|
+
if (value.left !== undefined)
|
|
986
|
+
el.style.paddingLeft = `${value.left}px`;
|
|
987
|
+
if (value.right !== undefined)
|
|
988
|
+
el.style.paddingRight = `${value.right}px`;
|
|
989
|
+
if (value.top !== undefined)
|
|
990
|
+
el.style.paddingTop = `${value.top}px`;
|
|
991
|
+
if (value.bottom !== undefined)
|
|
992
|
+
el.style.paddingBottom = `${value.bottom}px`;
|
|
993
|
+
} else {
|
|
994
|
+
el.style.padding = String(value);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
// src/dom/applicators/margin.ts
|
|
999
|
+
var exports_margin = {};
|
|
1000
|
+
__export(exports_margin, {
|
|
1001
|
+
marginHandler: () => marginHandler
|
|
1002
|
+
});
|
|
1003
|
+
var marginHandler = (el, value) => {
|
|
1004
|
+
if (typeof value === "number") {
|
|
1005
|
+
el.style.margin = `${value}px`;
|
|
1006
|
+
} else if (typeof value === "object") {
|
|
1007
|
+
if (value.left !== undefined)
|
|
1008
|
+
el.style.marginLeft = `${value.left}px`;
|
|
1009
|
+
if (value.right !== undefined)
|
|
1010
|
+
el.style.marginRight = `${value.right}px`;
|
|
1011
|
+
if (value.top !== undefined)
|
|
1012
|
+
el.style.marginTop = `${value.top}px`;
|
|
1013
|
+
if (value.bottom !== undefined)
|
|
1014
|
+
el.style.marginBottom = `${value.bottom}px`;
|
|
1015
|
+
} else {
|
|
1016
|
+
el.style.margin = String(value);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
// src/dom/applicators/color.ts
|
|
1021
|
+
var exports_color = {};
|
|
1022
|
+
__export(exports_color, {
|
|
1023
|
+
colorHandlers: () => colorHandlers
|
|
1024
|
+
});
|
|
1025
|
+
var colorHandlers;
|
|
1026
|
+
var init_color = __esm(() => {
|
|
1027
|
+
colorHandlers = {
|
|
1028
|
+
color: (el, value) => {
|
|
1029
|
+
el.style.color = String(value);
|
|
1030
|
+
},
|
|
1031
|
+
backgroundColor: (el, value) => {
|
|
1032
|
+
el.style.backgroundColor = String(value);
|
|
1033
|
+
},
|
|
1034
|
+
borderColor: (el, value) => {
|
|
1035
|
+
el.style.borderColor = String(value);
|
|
1036
|
+
},
|
|
1037
|
+
opacity: (el, value) => {
|
|
1038
|
+
el.style.opacity = String(value);
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
// src/dom/applicators/border.ts
|
|
1044
|
+
var exports_border = {};
|
|
1045
|
+
__export(exports_border, {
|
|
1046
|
+
borderHandlers: () => borderHandlers
|
|
1047
|
+
});
|
|
1048
|
+
var borderHandlers;
|
|
1049
|
+
var init_border = __esm(() => {
|
|
1050
|
+
borderHandlers = {
|
|
1051
|
+
borderWidth: (el, value) => {
|
|
1052
|
+
el.style.borderWidth = typeof value === "number" ? `${value}px` : String(value);
|
|
1053
|
+
},
|
|
1054
|
+
borderStyle: (el, value) => {
|
|
1055
|
+
el.style.borderStyle = String(value);
|
|
1056
|
+
},
|
|
1057
|
+
borderRadius: (el, value) => {
|
|
1058
|
+
el.style.borderRadius = typeof value === "number" ? `${value}px` : String(value);
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
// src/dom/applicators/size.ts
|
|
1064
|
+
var exports_size = {};
|
|
1065
|
+
__export(exports_size, {
|
|
1066
|
+
sizeHandlers: () => sizeHandlers
|
|
1067
|
+
});
|
|
1068
|
+
var sizeHandlers;
|
|
1069
|
+
var init_size = __esm(() => {
|
|
1070
|
+
sizeHandlers = {
|
|
1071
|
+
width: (el, value) => {
|
|
1072
|
+
el.style.width = typeof value === "number" ? `${value}px` : String(value);
|
|
1073
|
+
},
|
|
1074
|
+
height: (el, value) => {
|
|
1075
|
+
el.style.height = typeof value === "number" ? `${value}px` : String(value);
|
|
1076
|
+
},
|
|
1077
|
+
minWidth: (el, value) => {
|
|
1078
|
+
el.style.minWidth = typeof value === "number" ? `${value}px` : String(value);
|
|
1079
|
+
},
|
|
1080
|
+
minHeight: (el, value) => {
|
|
1081
|
+
el.style.minHeight = typeof value === "number" ? `${value}px` : String(value);
|
|
1082
|
+
},
|
|
1083
|
+
maxWidth: (el, value) => {
|
|
1084
|
+
el.style.maxWidth = typeof value === "number" ? `${value}px` : String(value);
|
|
1085
|
+
},
|
|
1086
|
+
maxHeight: (el, value) => {
|
|
1087
|
+
el.style.maxHeight = typeof value === "number" ? `${value}px` : String(value);
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
// src/dom/applicators/font.ts
|
|
1093
|
+
var exports_font = {};
|
|
1094
|
+
__export(exports_font, {
|
|
1095
|
+
fontHandlers: () => fontHandlers
|
|
1096
|
+
});
|
|
1097
|
+
var fontHandlers;
|
|
1098
|
+
var init_font = __esm(() => {
|
|
1099
|
+
fontHandlers = {
|
|
1100
|
+
fontSize: (el, value) => {
|
|
1101
|
+
el.style.fontSize = typeof value === "number" ? `${value}px` : String(value);
|
|
1102
|
+
},
|
|
1103
|
+
fontWeight: (el, value) => {
|
|
1104
|
+
el.style.fontWeight = String(value);
|
|
1105
|
+
},
|
|
1106
|
+
fontFamily: (el, value) => {
|
|
1107
|
+
el.style.fontFamily = String(value);
|
|
1108
|
+
},
|
|
1109
|
+
textAlign: (el, value) => {
|
|
1110
|
+
el.style.textAlign = String(value);
|
|
1111
|
+
},
|
|
1112
|
+
lineHeight: (el, value) => {
|
|
1113
|
+
el.style.lineHeight = String(value);
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
// src/dom/applicators/layout.ts
|
|
1119
|
+
var exports_layout = {};
|
|
1120
|
+
__export(exports_layout, {
|
|
1121
|
+
layoutHandlers: () => layoutHandlers
|
|
1122
|
+
});
|
|
1123
|
+
var layoutHandlers;
|
|
1124
|
+
var init_layout = __esm(() => {
|
|
1125
|
+
layoutHandlers = {
|
|
1126
|
+
verticalAlignment: (el, value) => {
|
|
1127
|
+
const val = String(value);
|
|
1128
|
+
const flexDirection = getComputedStyle(el).flexDirection;
|
|
1129
|
+
if (flexDirection === "column" || flexDirection === "column-reverse") {
|
|
1130
|
+
el.style.justifyContent = val;
|
|
1131
|
+
} else {
|
|
1132
|
+
el.style.alignItems = val;
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
horizontalAlignment: (el, value) => {
|
|
1136
|
+
const val = String(value);
|
|
1137
|
+
const flexDirection = getComputedStyle(el).flexDirection;
|
|
1138
|
+
if (flexDirection === "column" || flexDirection === "column-reverse") {
|
|
1139
|
+
el.style.alignItems = val;
|
|
1140
|
+
} else {
|
|
1141
|
+
el.style.justifyContent = val;
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
horizontalAlign: (el, value) => {
|
|
1145
|
+
el.style.justifyContent = String(value);
|
|
1146
|
+
},
|
|
1147
|
+
verticalAlign: (el, value) => {
|
|
1148
|
+
el.style.alignItems = String(value);
|
|
1149
|
+
},
|
|
1150
|
+
gap: (el, value) => {
|
|
1151
|
+
el.style.gap = typeof value === "number" ? `${value}px` : String(value);
|
|
1152
|
+
},
|
|
1153
|
+
weight: (el, value) => {
|
|
1154
|
+
el.style.flex = String(value);
|
|
1155
|
+
},
|
|
1156
|
+
flex: (el, value) => {
|
|
1157
|
+
el.style.flex = String(value);
|
|
1158
|
+
},
|
|
1159
|
+
flexGrow: (el, value) => {
|
|
1160
|
+
el.style.flexGrow = String(value);
|
|
1161
|
+
},
|
|
1162
|
+
flexShrink: (el, value) => {
|
|
1163
|
+
el.style.flexShrink = String(value);
|
|
1164
|
+
},
|
|
1165
|
+
cursor: (el, value) => {
|
|
1166
|
+
el.style.cursor = String(value);
|
|
1167
|
+
},
|
|
1168
|
+
overflow: (el, value) => {
|
|
1169
|
+
el.style.overflow = String(value);
|
|
1170
|
+
},
|
|
1171
|
+
scrollable: (el, value) => {
|
|
1172
|
+
if (value === true || value === "true") {
|
|
1173
|
+
el.style.overflow = "auto";
|
|
1174
|
+
} else if (value === false || value === "false") {
|
|
1175
|
+
el.style.overflow = "hidden";
|
|
1176
|
+
} else if (value === "vertical") {
|
|
1177
|
+
el.style.overflowX = "hidden";
|
|
1178
|
+
el.style.overflowY = "auto";
|
|
1179
|
+
} else if (value === "horizontal") {
|
|
1180
|
+
el.style.overflowX = "auto";
|
|
1181
|
+
el.style.overflowY = "hidden";
|
|
1182
|
+
} else if (value === "both") {
|
|
1183
|
+
el.style.overflow = "auto";
|
|
1184
|
+
} else {
|
|
1185
|
+
el.style.overflow = String(value);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
// src/dom/applicators/events.ts
|
|
1192
|
+
var exports_events = {};
|
|
1193
|
+
__export(exports_events, {
|
|
1194
|
+
eventHandlers: () => eventHandlers
|
|
1195
|
+
});
|
|
1196
|
+
function toPlainObject(value) {
|
|
1197
|
+
if (value instanceof Map) {
|
|
1198
|
+
const obj = {};
|
|
1199
|
+
for (const [key, val] of value.entries()) {
|
|
1200
|
+
obj[key] = toPlainObject(val);
|
|
1201
|
+
}
|
|
1202
|
+
return obj;
|
|
1203
|
+
}
|
|
1204
|
+
if (Array.isArray(value)) {
|
|
1205
|
+
return value.map((item) => toPlainObject(item));
|
|
1206
|
+
}
|
|
1207
|
+
if (value && typeof value === "object") {
|
|
1208
|
+
const obj = {};
|
|
1209
|
+
for (const [key, val] of Object.entries(value)) {
|
|
1210
|
+
obj[key] = toPlainObject(val);
|
|
1211
|
+
}
|
|
1212
|
+
return obj;
|
|
1213
|
+
}
|
|
1214
|
+
return value;
|
|
1215
|
+
}
|
|
1216
|
+
function extractActionDetails(value) {
|
|
1217
|
+
if (typeof value === "string") {
|
|
1218
|
+
if (!value.startsWith("@")) {
|
|
1219
|
+
return { actionName: null, payload: {} };
|
|
1220
|
+
}
|
|
1221
|
+
let actionName = value.substring(1);
|
|
1222
|
+
if (actionName.startsWith("actions.")) {
|
|
1223
|
+
actionName = actionName.substring(8);
|
|
1224
|
+
}
|
|
1225
|
+
return { actionName, payload: {} };
|
|
1226
|
+
}
|
|
1227
|
+
if (value && typeof value === "object") {
|
|
1228
|
+
const plain = toPlainObject(value);
|
|
1229
|
+
const payload = {};
|
|
1230
|
+
let actionName = null;
|
|
1231
|
+
if (plain && typeof plain === "object") {
|
|
1232
|
+
const actionValue = plain["0"];
|
|
1233
|
+
if (typeof actionValue === "string" && actionValue.startsWith("@")) {
|
|
1234
|
+
actionName = actionValue.substring(1);
|
|
1235
|
+
if (actionName.startsWith("actions.")) {
|
|
1236
|
+
actionName = actionName.substring(8);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
for (const [key, val] of Object.entries(plain)) {
|
|
1240
|
+
if (key !== "0") {
|
|
1241
|
+
payload[key] = val;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return { actionName, payload };
|
|
1246
|
+
}
|
|
1247
|
+
return { actionName: null, payload: {} };
|
|
1248
|
+
}
|
|
1249
|
+
function extractEventData(event, element) {
|
|
1250
|
+
const data = {
|
|
1251
|
+
type: event.type,
|
|
1252
|
+
timestamp: Date.now()
|
|
1253
|
+
};
|
|
1254
|
+
if (event instanceof MouseEvent) {
|
|
1255
|
+
data.clientX = event.clientX;
|
|
1256
|
+
data.clientY = event.clientY;
|
|
1257
|
+
data.button = event.button;
|
|
1258
|
+
}
|
|
1259
|
+
if (event instanceof KeyboardEvent) {
|
|
1260
|
+
data.key = event.key;
|
|
1261
|
+
data.code = event.code;
|
|
1262
|
+
data.ctrlKey = event.ctrlKey;
|
|
1263
|
+
data.shiftKey = event.shiftKey;
|
|
1264
|
+
data.altKey = event.altKey;
|
|
1265
|
+
data.metaKey = event.metaKey;
|
|
1266
|
+
}
|
|
1267
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
1268
|
+
data.value = element.value;
|
|
1269
|
+
}
|
|
1270
|
+
if (element instanceof HTMLSelectElement) {
|
|
1271
|
+
data.value = element.value;
|
|
1272
|
+
data.selectedIndex = element.selectedIndex;
|
|
1273
|
+
}
|
|
1274
|
+
if (event.type === "submit" && element instanceof HTMLFormElement) {
|
|
1275
|
+
data.formData = new FormData(element);
|
|
1276
|
+
}
|
|
1277
|
+
return data;
|
|
1278
|
+
}
|
|
1279
|
+
var eventHandlers;
|
|
1280
|
+
var init_events = __esm(() => {
|
|
1281
|
+
eventHandlers = {
|
|
1282
|
+
onClick: (element, value) => {
|
|
1283
|
+
console.log(`[EventApplicator] onClick called with value:`, value);
|
|
1284
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1285
|
+
if (!actionName) {
|
|
1286
|
+
console.warn(`[EventApplicator] onClick value must be an action reference, got:`, value);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
const existingListener = element.__hypenClickListener;
|
|
1290
|
+
if (existingListener) {
|
|
1291
|
+
element.removeEventListener("click", existingListener);
|
|
1292
|
+
}
|
|
1293
|
+
const listener = (event) => {
|
|
1294
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onClick fired, dispatching action: ${actionName}`);
|
|
1295
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : extractEventData(event, element);
|
|
1296
|
+
console.log(`[EventApplicator] onClick payload:`, payload);
|
|
1297
|
+
const engine = element.__hypenEngine;
|
|
1298
|
+
if (engine) {
|
|
1299
|
+
engine.dispatchAction(actionName, payload);
|
|
1300
|
+
} else {
|
|
1301
|
+
console.warn(`[EventApplicator] No engine attached to element for onClick`);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
element.__hypenClickListener = listener;
|
|
1305
|
+
element.addEventListener("click", listener);
|
|
1306
|
+
console.log(`[EventApplicator] onClick handler attached for action: ${actionName}`);
|
|
1307
|
+
},
|
|
1308
|
+
onPress: (element, value) => {
|
|
1309
|
+
eventHandlers.onClick(element, value);
|
|
1310
|
+
},
|
|
1311
|
+
onChange: (element, value) => {
|
|
1312
|
+
const { actionName } = extractActionDetails(value);
|
|
1313
|
+
if (!actionName) {
|
|
1314
|
+
console.warn(`[EventApplicator] onChange value must be an action reference starting with @, got:`, value);
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
const existingListener = element.__hypenChangeListener;
|
|
1318
|
+
if (existingListener) {
|
|
1319
|
+
element.removeEventListener("change", existingListener);
|
|
1320
|
+
}
|
|
1321
|
+
const listener = (event) => {
|
|
1322
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onChange fired, dispatching action: ${actionName}`);
|
|
1323
|
+
const payload = extractEventData(event, element);
|
|
1324
|
+
const engine = element.__hypenEngine;
|
|
1325
|
+
if (engine) {
|
|
1326
|
+
engine.dispatchAction(actionName, payload);
|
|
1327
|
+
} else {
|
|
1328
|
+
console.warn(`[EventApplicator] No engine attached to element for onChange`);
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
element.__hypenChangeListener = listener;
|
|
1332
|
+
element.addEventListener("change", listener);
|
|
1333
|
+
console.log(`[EventApplicator] onChange handler attached for action: ${actionName}`);
|
|
1334
|
+
},
|
|
1335
|
+
onSubmit: (element, value) => {
|
|
1336
|
+
const { actionName } = extractActionDetails(value);
|
|
1337
|
+
if (!actionName) {
|
|
1338
|
+
console.warn(`[EventApplicator] onSubmit value must be an action reference starting with @, got:`, value);
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
const existingListener = element.__hypenSubmitListener;
|
|
1342
|
+
if (existingListener) {
|
|
1343
|
+
element.removeEventListener("submit", existingListener);
|
|
1344
|
+
}
|
|
1345
|
+
const listener = (event) => {
|
|
1346
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onSubmit fired, dispatching action: ${actionName}`);
|
|
1347
|
+
event.preventDefault();
|
|
1348
|
+
const payload = extractEventData(event, element);
|
|
1349
|
+
const engine = element.__hypenEngine;
|
|
1350
|
+
if (engine) {
|
|
1351
|
+
engine.dispatchAction(actionName, payload);
|
|
1352
|
+
} else {
|
|
1353
|
+
console.warn(`[EventApplicator] No engine attached to element for onSubmit`);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
element.__hypenSubmitListener = listener;
|
|
1357
|
+
element.addEventListener("submit", listener);
|
|
1358
|
+
console.log(`[EventApplicator] onSubmit handler attached for action: ${actionName}`);
|
|
1359
|
+
},
|
|
1360
|
+
onInput: (element, value) => {
|
|
1361
|
+
console.log(`[EventApplicator] onInput called with value:`, value);
|
|
1362
|
+
const { actionName } = extractActionDetails(value);
|
|
1363
|
+
if (!actionName) {
|
|
1364
|
+
console.warn(`[EventApplicator] onInput value must be an action reference starting with @, got:`, value);
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
const existingListener = element.__hypenInputListener;
|
|
1368
|
+
if (existingListener) {
|
|
1369
|
+
element.removeEventListener("input", existingListener);
|
|
1370
|
+
}
|
|
1371
|
+
const listener = (event) => {
|
|
1372
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onInput fired, dispatching action: ${actionName}`);
|
|
1373
|
+
const target = event.target;
|
|
1374
|
+
const payload = {
|
|
1375
|
+
type: event.type,
|
|
1376
|
+
timestamp: Date.now(),
|
|
1377
|
+
value: target.value,
|
|
1378
|
+
input: target.value
|
|
1379
|
+
};
|
|
1380
|
+
console.log(`[EventApplicator] onInput payload:`, payload);
|
|
1381
|
+
const engine = element.__hypenEngine;
|
|
1382
|
+
if (engine) {
|
|
1383
|
+
engine.dispatchAction(actionName, payload);
|
|
1384
|
+
} else {
|
|
1385
|
+
console.warn(`[EventApplicator] No engine attached to element for onInput`);
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
element.__hypenInputListener = listener;
|
|
1389
|
+
element.addEventListener("input", listener);
|
|
1390
|
+
console.log(`[EventApplicator] onInput handler attached for action: ${actionName}`);
|
|
1391
|
+
},
|
|
1392
|
+
onKey: (element, value) => {
|
|
1393
|
+
console.log(`[EventApplicator] onKey called with value:`, value);
|
|
1394
|
+
const { actionName } = extractActionDetails(value);
|
|
1395
|
+
if (actionName) {
|
|
1396
|
+
const existingListener = element.__hypenKeyListener;
|
|
1397
|
+
if (existingListener) {
|
|
1398
|
+
element.removeEventListener("keydown", existingListener);
|
|
1399
|
+
}
|
|
1400
|
+
const listener = (event) => {
|
|
1401
|
+
if (event.key === "Enter") {
|
|
1402
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onKey fired (Enter), dispatching action: ${actionName}`);
|
|
1403
|
+
event.preventDefault();
|
|
1404
|
+
const target = event.target;
|
|
1405
|
+
const payload = {
|
|
1406
|
+
type: event.type,
|
|
1407
|
+
timestamp: Date.now(),
|
|
1408
|
+
key: event.key,
|
|
1409
|
+
code: event.code,
|
|
1410
|
+
value: target.value,
|
|
1411
|
+
input: target.value,
|
|
1412
|
+
ctrlKey: event.ctrlKey,
|
|
1413
|
+
shiftKey: event.shiftKey,
|
|
1414
|
+
altKey: event.altKey,
|
|
1415
|
+
metaKey: event.metaKey
|
|
1416
|
+
};
|
|
1417
|
+
const engine = element.__hypenEngine;
|
|
1418
|
+
if (engine) {
|
|
1419
|
+
engine.dispatchAction(actionName, payload);
|
|
1420
|
+
} else {
|
|
1421
|
+
console.warn(`[EventApplicator] No engine attached to element for onKey`);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
element.__hypenKeyListener = listener;
|
|
1426
|
+
element.addEventListener("keydown", listener);
|
|
1427
|
+
console.log(`[EventApplicator] onKey handler attached for action: ${actionName} (triggers on Enter)`);
|
|
1428
|
+
} else {
|
|
1429
|
+
console.warn(`[EventApplicator] onKey value must be an action reference starting with @, got: ${value}`);
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1432
|
+
"onKey.key": (element, keyValue) => {
|
|
1433
|
+
console.log(`[EventApplicator] onKey.key called with value:`, keyValue);
|
|
1434
|
+
element.__hypenKeyTarget = keyValue;
|
|
1435
|
+
},
|
|
1436
|
+
"onKey.action": (element, value) => {
|
|
1437
|
+
console.log(`[EventApplicator] onKey.action called with value:`, value);
|
|
1438
|
+
const { actionName } = extractActionDetails(value);
|
|
1439
|
+
if (actionName) {
|
|
1440
|
+
const targetKey = element.__hypenKeyTarget || "Enter";
|
|
1441
|
+
const existingListener = element.__hypenKeyListener;
|
|
1442
|
+
if (existingListener) {
|
|
1443
|
+
element.removeEventListener("keydown", existingListener);
|
|
1444
|
+
}
|
|
1445
|
+
const listener = (event) => {
|
|
1446
|
+
const keyToMatch = targetKey.toLowerCase() === "return" ? "Enter" : targetKey;
|
|
1447
|
+
if (event.key === keyToMatch) {
|
|
1448
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onKey fired (${keyToMatch}), dispatching action: ${actionName}`);
|
|
1449
|
+
event.preventDefault();
|
|
1450
|
+
const target = event.target;
|
|
1451
|
+
const payload = {
|
|
1452
|
+
type: event.type,
|
|
1453
|
+
timestamp: Date.now(),
|
|
1454
|
+
key: event.key,
|
|
1455
|
+
code: event.code,
|
|
1456
|
+
value: target.value,
|
|
1457
|
+
input: target.value,
|
|
1458
|
+
ctrlKey: event.ctrlKey,
|
|
1459
|
+
shiftKey: event.shiftKey,
|
|
1460
|
+
altKey: event.altKey,
|
|
1461
|
+
metaKey: event.metaKey
|
|
1462
|
+
};
|
|
1463
|
+
const engine = element.__hypenEngine;
|
|
1464
|
+
if (engine) {
|
|
1465
|
+
engine.dispatchAction(actionName, payload);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
element.__hypenKeyListener = listener;
|
|
1470
|
+
element.addEventListener("keydown", listener);
|
|
1471
|
+
console.log(`[EventApplicator] onKey handler attached for action: ${actionName} on key: ${targetKey}`);
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
onScroll: (element, value) => {
|
|
1475
|
+
console.log(`[EventApplicator] onScroll called with value:`, value);
|
|
1476
|
+
const { actionName } = extractActionDetails(value);
|
|
1477
|
+
if (actionName) {
|
|
1478
|
+
const existingListener = element.__hypenScrollListener;
|
|
1479
|
+
if (existingListener) {
|
|
1480
|
+
element.removeEventListener("scroll", existingListener);
|
|
1481
|
+
}
|
|
1482
|
+
let throttleTimer = null;
|
|
1483
|
+
const listener = (event) => {
|
|
1484
|
+
if (throttleTimer)
|
|
1485
|
+
return;
|
|
1486
|
+
throttleTimer = setTimeout(() => {
|
|
1487
|
+
throttleTimer = null;
|
|
1488
|
+
}, 100);
|
|
1489
|
+
const target = event.target;
|
|
1490
|
+
const scrollTop = target.scrollTop;
|
|
1491
|
+
const scrollHeight = target.scrollHeight;
|
|
1492
|
+
const clientHeight = target.clientHeight;
|
|
1493
|
+
const scrollPercentage = scrollTop / (scrollHeight - clientHeight) * 100;
|
|
1494
|
+
const nearBottom = scrollHeight - scrollTop - clientHeight < 100 || scrollPercentage > 90;
|
|
1495
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onScroll fired, scrollTop: ${scrollTop}, nearBottom: ${nearBottom}`);
|
|
1496
|
+
const payload = {
|
|
1497
|
+
type: "scroll",
|
|
1498
|
+
timestamp: Date.now(),
|
|
1499
|
+
scrollTop,
|
|
1500
|
+
scrollLeft: target.scrollLeft,
|
|
1501
|
+
scrollHeight,
|
|
1502
|
+
scrollWidth: target.scrollWidth,
|
|
1503
|
+
clientHeight,
|
|
1504
|
+
clientWidth: target.clientWidth,
|
|
1505
|
+
scrollPercentage: Math.round(scrollPercentage),
|
|
1506
|
+
nearBottom,
|
|
1507
|
+
atBottom: scrollHeight - scrollTop === clientHeight,
|
|
1508
|
+
atTop: scrollTop === 0
|
|
1509
|
+
};
|
|
1510
|
+
const engine = element.__hypenEngine;
|
|
1511
|
+
if (engine) {
|
|
1512
|
+
engine.dispatchAction(actionName, payload);
|
|
1513
|
+
} else {
|
|
1514
|
+
console.warn(`[EventApplicator] No engine attached to element for onScroll`);
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
element.__hypenScrollListener = listener;
|
|
1518
|
+
element.addEventListener("scroll", listener, { passive: true });
|
|
1519
|
+
console.log(`[EventApplicator] onScroll handler attached for action: ${actionName}`);
|
|
1520
|
+
} else {
|
|
1521
|
+
console.warn(`[EventApplicator] onScroll value must be an action reference starting with @, got: ${value}`);
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
onLongClick: (element, value) => {
|
|
1525
|
+
console.log(`[EventApplicator] onLongClick called with value:`, value);
|
|
1526
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1527
|
+
if (!actionName) {
|
|
1528
|
+
console.warn(`[EventApplicator] onLongClick value must be an action reference, got:`, value);
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
const existingDownListener = element.__hypenLongClickDownListener;
|
|
1532
|
+
const existingUpListener = element.__hypenLongClickUpListener;
|
|
1533
|
+
if (existingDownListener) {
|
|
1534
|
+
element.removeEventListener("pointerdown", existingDownListener);
|
|
1535
|
+
}
|
|
1536
|
+
if (existingUpListener) {
|
|
1537
|
+
element.removeEventListener("pointerup", existingUpListener);
|
|
1538
|
+
element.removeEventListener("pointerleave", existingUpListener);
|
|
1539
|
+
}
|
|
1540
|
+
let longClickTimer = null;
|
|
1541
|
+
const LONG_CLICK_THRESHOLD = 500;
|
|
1542
|
+
const downListener = (event) => {
|
|
1543
|
+
longClickTimer = setTimeout(() => {
|
|
1544
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onLongClick fired, dispatching action: ${actionName}`);
|
|
1545
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : {
|
|
1546
|
+
type: "longclick",
|
|
1547
|
+
timestamp: Date.now(),
|
|
1548
|
+
clientX: event.clientX,
|
|
1549
|
+
clientY: event.clientY
|
|
1550
|
+
};
|
|
1551
|
+
const engine = element.__hypenEngine;
|
|
1552
|
+
if (engine) {
|
|
1553
|
+
engine.dispatchAction(actionName, payload);
|
|
1554
|
+
} else {
|
|
1555
|
+
console.warn(`[EventApplicator] No engine attached to element for onLongClick`);
|
|
1556
|
+
}
|
|
1557
|
+
longClickTimer = null;
|
|
1558
|
+
}, LONG_CLICK_THRESHOLD);
|
|
1559
|
+
};
|
|
1560
|
+
const upListener = () => {
|
|
1561
|
+
if (longClickTimer) {
|
|
1562
|
+
clearTimeout(longClickTimer);
|
|
1563
|
+
longClickTimer = null;
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
element.__hypenLongClickDownListener = downListener;
|
|
1567
|
+
element.__hypenLongClickUpListener = upListener;
|
|
1568
|
+
element.addEventListener("pointerdown", downListener);
|
|
1569
|
+
element.addEventListener("pointerup", upListener);
|
|
1570
|
+
element.addEventListener("pointerleave", upListener);
|
|
1571
|
+
console.log(`[EventApplicator] onLongClick handler attached for action: ${actionName}`);
|
|
1572
|
+
},
|
|
1573
|
+
onFocus: (element, value) => {
|
|
1574
|
+
console.log(`[EventApplicator] onFocus called with value:`, value);
|
|
1575
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1576
|
+
if (!actionName) {
|
|
1577
|
+
console.warn(`[EventApplicator] onFocus value must be an action reference, got:`, value);
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
const existingListener = element.__hypenFocusListener;
|
|
1581
|
+
if (existingListener) {
|
|
1582
|
+
element.removeEventListener("focus", existingListener);
|
|
1583
|
+
}
|
|
1584
|
+
const listener = (event) => {
|
|
1585
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onFocus fired, dispatching action: ${actionName}`);
|
|
1586
|
+
const target = event.target;
|
|
1587
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : {
|
|
1588
|
+
type: "focus",
|
|
1589
|
+
timestamp: Date.now(),
|
|
1590
|
+
value: target.value ?? undefined
|
|
1591
|
+
};
|
|
1592
|
+
const engine = element.__hypenEngine;
|
|
1593
|
+
if (engine) {
|
|
1594
|
+
engine.dispatchAction(actionName, payload);
|
|
1595
|
+
} else {
|
|
1596
|
+
console.warn(`[EventApplicator] No engine attached to element for onFocus`);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
element.__hypenFocusListener = listener;
|
|
1600
|
+
element.addEventListener("focus", listener);
|
|
1601
|
+
console.log(`[EventApplicator] onFocus handler attached for action: ${actionName}`);
|
|
1602
|
+
},
|
|
1603
|
+
onBlur: (element, value) => {
|
|
1604
|
+
console.log(`[EventApplicator] onBlur called with value:`, value);
|
|
1605
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1606
|
+
if (!actionName) {
|
|
1607
|
+
console.warn(`[EventApplicator] onBlur value must be an action reference, got:`, value);
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
const existingListener = element.__hypenBlurListener;
|
|
1611
|
+
if (existingListener) {
|
|
1612
|
+
element.removeEventListener("blur", existingListener);
|
|
1613
|
+
}
|
|
1614
|
+
const listener = (event) => {
|
|
1615
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onBlur fired, dispatching action: ${actionName}`);
|
|
1616
|
+
const target = event.target;
|
|
1617
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : {
|
|
1618
|
+
type: "blur",
|
|
1619
|
+
timestamp: Date.now(),
|
|
1620
|
+
value: target.value ?? undefined
|
|
1621
|
+
};
|
|
1622
|
+
const engine = element.__hypenEngine;
|
|
1623
|
+
if (engine) {
|
|
1624
|
+
engine.dispatchAction(actionName, payload);
|
|
1625
|
+
} else {
|
|
1626
|
+
console.warn(`[EventApplicator] No engine attached to element for onBlur`);
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
element.__hypenBlurListener = listener;
|
|
1630
|
+
element.addEventListener("blur", listener);
|
|
1631
|
+
console.log(`[EventApplicator] onBlur handler attached for action: ${actionName}`);
|
|
1632
|
+
},
|
|
1633
|
+
onMouseEnter: (element, value) => {
|
|
1634
|
+
console.log(`[EventApplicator] onMouseEnter called with value:`, value);
|
|
1635
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1636
|
+
if (!actionName) {
|
|
1637
|
+
console.warn(`[EventApplicator] onMouseEnter value must be an action reference, got:`, value);
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
const existingListener = element.__hypenMouseEnterListener;
|
|
1641
|
+
if (existingListener) {
|
|
1642
|
+
element.removeEventListener("mouseenter", existingListener);
|
|
1643
|
+
}
|
|
1644
|
+
const listener = (event) => {
|
|
1645
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onMouseEnter fired, dispatching action: ${actionName}`);
|
|
1646
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : {
|
|
1647
|
+
type: "mouseenter",
|
|
1648
|
+
timestamp: Date.now(),
|
|
1649
|
+
clientX: event.clientX,
|
|
1650
|
+
clientY: event.clientY
|
|
1651
|
+
};
|
|
1652
|
+
const engine = element.__hypenEngine;
|
|
1653
|
+
if (engine) {
|
|
1654
|
+
engine.dispatchAction(actionName, payload);
|
|
1655
|
+
} else {
|
|
1656
|
+
console.warn(`[EventApplicator] No engine attached to element for onMouseEnter`);
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
element.__hypenMouseEnterListener = listener;
|
|
1660
|
+
element.addEventListener("mouseenter", listener);
|
|
1661
|
+
console.log(`[EventApplicator] onMouseEnter handler attached for action: ${actionName}`);
|
|
1662
|
+
},
|
|
1663
|
+
onMouseLeave: (element, value) => {
|
|
1664
|
+
console.log(`[EventApplicator] onMouseLeave called with value:`, value);
|
|
1665
|
+
const { actionName, payload: customPayload } = extractActionDetails(value);
|
|
1666
|
+
if (!actionName) {
|
|
1667
|
+
console.warn(`[EventApplicator] onMouseLeave value must be an action reference, got:`, value);
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
const existingListener = element.__hypenMouseLeaveListener;
|
|
1671
|
+
if (existingListener) {
|
|
1672
|
+
element.removeEventListener("mouseleave", existingListener);
|
|
1673
|
+
}
|
|
1674
|
+
const listener = (event) => {
|
|
1675
|
+
console.log(`\uD83D\uDD25 [EventApplicator] onMouseLeave fired, dispatching action: ${actionName}`);
|
|
1676
|
+
const payload = Object.keys(customPayload).length > 0 ? { ...customPayload } : {
|
|
1677
|
+
type: "mouseleave",
|
|
1678
|
+
timestamp: Date.now(),
|
|
1679
|
+
clientX: event.clientX,
|
|
1680
|
+
clientY: event.clientY
|
|
1681
|
+
};
|
|
1682
|
+
const engine = element.__hypenEngine;
|
|
1683
|
+
if (engine) {
|
|
1684
|
+
engine.dispatchAction(actionName, payload);
|
|
1685
|
+
} else {
|
|
1686
|
+
console.warn(`[EventApplicator] No engine attached to element for onMouseLeave`);
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
element.__hypenMouseLeaveListener = listener;
|
|
1690
|
+
element.addEventListener("mouseleave", listener);
|
|
1691
|
+
console.log(`[EventApplicator] onMouseLeave handler attached for action: ${actionName}`);
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
// src/dom/applicators/typography.ts
|
|
1697
|
+
var exports_typography = {};
|
|
1698
|
+
__export(exports_typography, {
|
|
1699
|
+
typographyHandlers: () => typographyHandlers
|
|
1700
|
+
});
|
|
1701
|
+
var typographyHandlers;
|
|
1702
|
+
var init_typography = __esm(() => {
|
|
1703
|
+
typographyHandlers = {
|
|
1704
|
+
textAlign: (el, value) => {
|
|
1705
|
+
el.style.textAlign = String(value);
|
|
1706
|
+
},
|
|
1707
|
+
textTransform: (el, value) => {
|
|
1708
|
+
el.style.textTransform = String(value);
|
|
1709
|
+
},
|
|
1710
|
+
textDecoration: (el, value) => {
|
|
1711
|
+
el.style.textDecoration = String(value);
|
|
1712
|
+
},
|
|
1713
|
+
textDecorationColor: (el, value) => {
|
|
1714
|
+
el.style.textDecorationColor = String(value);
|
|
1715
|
+
},
|
|
1716
|
+
textDecorationStyle: (el, value) => {
|
|
1717
|
+
el.style.textDecorationStyle = String(value);
|
|
1718
|
+
},
|
|
1719
|
+
textDecorationThickness: (el, value) => {
|
|
1720
|
+
el.style.textDecorationThickness = typeof value === "number" ? `${value}px` : String(value);
|
|
1721
|
+
},
|
|
1722
|
+
letterSpacing: (el, value) => {
|
|
1723
|
+
el.style.letterSpacing = typeof value === "number" ? `${value}px` : String(value);
|
|
1724
|
+
},
|
|
1725
|
+
wordSpacing: (el, value) => {
|
|
1726
|
+
el.style.wordSpacing = typeof value === "number" ? `${value}px` : String(value);
|
|
1727
|
+
},
|
|
1728
|
+
lineHeight: (el, value) => {
|
|
1729
|
+
el.style.lineHeight = String(value);
|
|
1730
|
+
},
|
|
1731
|
+
textIndent: (el, value) => {
|
|
1732
|
+
el.style.textIndent = typeof value === "number" ? `${value}px` : String(value);
|
|
1733
|
+
},
|
|
1734
|
+
textOverflow: (el, value) => {
|
|
1735
|
+
el.style.textOverflow = String(value);
|
|
1736
|
+
},
|
|
1737
|
+
whiteSpace: (el, value) => {
|
|
1738
|
+
el.style.whiteSpace = String(value);
|
|
1739
|
+
},
|
|
1740
|
+
wordBreak: (el, value) => {
|
|
1741
|
+
el.style.wordBreak = String(value);
|
|
1742
|
+
},
|
|
1743
|
+
verticalAlign: (el, value) => {
|
|
1744
|
+
el.style.verticalAlign = String(value);
|
|
1745
|
+
},
|
|
1746
|
+
fontVariant: (el, value) => {
|
|
1747
|
+
el.style.fontVariant = String(value);
|
|
1748
|
+
},
|
|
1749
|
+
fontStretch: (el, value) => {
|
|
1750
|
+
el.style.fontStretch = String(value);
|
|
1751
|
+
},
|
|
1752
|
+
fontStyle: (el, value) => {
|
|
1753
|
+
el.style.fontStyle = String(value);
|
|
1754
|
+
},
|
|
1755
|
+
writingMode: (el, value) => {
|
|
1756
|
+
el.style.writingMode = String(value);
|
|
1757
|
+
},
|
|
1758
|
+
maxLines: (el, value) => {
|
|
1759
|
+
const lines = typeof value === "number" ? value : parseInt(String(value), 10);
|
|
1760
|
+
if (!isNaN(lines) && lines > 0) {
|
|
1761
|
+
el.style.display = "-webkit-box";
|
|
1762
|
+
el.style.setProperty("-webkit-line-clamp", String(lines));
|
|
1763
|
+
el.style.setProperty("-webkit-box-orient", "vertical");
|
|
1764
|
+
el.style.overflow = "hidden";
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
});
|
|
1769
|
+
|
|
1770
|
+
// src/dom/applicators/transform.ts
|
|
1771
|
+
var exports_transform = {};
|
|
1772
|
+
__export(exports_transform, {
|
|
1773
|
+
transformHandlers: () => transformHandlers
|
|
1774
|
+
});
|
|
1775
|
+
var transformHandlers;
|
|
1776
|
+
var init_transform = __esm(() => {
|
|
1777
|
+
transformHandlers = {
|
|
1778
|
+
transform: (el, value) => {
|
|
1779
|
+
el.style.transform = String(value);
|
|
1780
|
+
},
|
|
1781
|
+
transformOrigin: (el, value) => {
|
|
1782
|
+
el.style.transformOrigin = String(value);
|
|
1783
|
+
},
|
|
1784
|
+
translateX: (el, value) => {
|
|
1785
|
+
const current = el.style.transform || "";
|
|
1786
|
+
const val = typeof value === "number" ? `${value}px` : String(value);
|
|
1787
|
+
el.style.transform = current ? `${current} translateX(${val})` : `translateX(${val})`;
|
|
1788
|
+
},
|
|
1789
|
+
translateY: (el, value) => {
|
|
1790
|
+
const current = el.style.transform || "";
|
|
1791
|
+
const val = typeof value === "number" ? `${value}px` : String(value);
|
|
1792
|
+
el.style.transform = current ? `${current} translateY(${val})` : `translateY(${val})`;
|
|
1793
|
+
},
|
|
1794
|
+
translateZ: (el, value) => {
|
|
1795
|
+
const current = el.style.transform || "";
|
|
1796
|
+
const val = typeof value === "number" ? `${value}px` : String(value);
|
|
1797
|
+
el.style.transform = current ? `${current} translateZ(${val})` : `translateZ(${val})`;
|
|
1798
|
+
},
|
|
1799
|
+
rotate: (el, value) => {
|
|
1800
|
+
const current = el.style.transform || "";
|
|
1801
|
+
const val = String(value);
|
|
1802
|
+
el.style.transform = current ? `${current} rotate(${val})` : `rotate(${val})`;
|
|
1803
|
+
},
|
|
1804
|
+
rotateX: (el, value) => {
|
|
1805
|
+
const current = el.style.transform || "";
|
|
1806
|
+
const val = String(value);
|
|
1807
|
+
el.style.transform = current ? `${current} rotateX(${val})` : `rotateX(${val})`;
|
|
1808
|
+
},
|
|
1809
|
+
rotateY: (el, value) => {
|
|
1810
|
+
const current = el.style.transform || "";
|
|
1811
|
+
const val = String(value);
|
|
1812
|
+
el.style.transform = current ? `${current} rotateY(${val})` : `rotateY(${val})`;
|
|
1813
|
+
},
|
|
1814
|
+
rotateZ: (el, value) => {
|
|
1815
|
+
const current = el.style.transform || "";
|
|
1816
|
+
const val = String(value);
|
|
1817
|
+
el.style.transform = current ? `${current} rotateZ(${val})` : `rotateZ(${val})`;
|
|
1818
|
+
},
|
|
1819
|
+
scale: (el, value) => {
|
|
1820
|
+
const current = el.style.transform || "";
|
|
1821
|
+
el.style.transform = current ? `${current} scale(${value})` : `scale(${value})`;
|
|
1822
|
+
},
|
|
1823
|
+
scaleX: (el, value) => {
|
|
1824
|
+
const current = el.style.transform || "";
|
|
1825
|
+
el.style.transform = current ? `${current} scaleX(${value})` : `scaleX(${value})`;
|
|
1826
|
+
},
|
|
1827
|
+
scaleY: (el, value) => {
|
|
1828
|
+
const current = el.style.transform || "";
|
|
1829
|
+
el.style.transform = current ? `${current} scaleY(${value})` : `scaleY(${value})`;
|
|
1830
|
+
},
|
|
1831
|
+
skew: (el, value) => {
|
|
1832
|
+
const current = el.style.transform || "";
|
|
1833
|
+
el.style.transform = current ? `${current} skew(${value})` : `skew(${value})`;
|
|
1834
|
+
},
|
|
1835
|
+
skewX: (el, value) => {
|
|
1836
|
+
const current = el.style.transform || "";
|
|
1837
|
+
el.style.transform = current ? `${current} skewX(${value})` : `skewX(${value})`;
|
|
1838
|
+
},
|
|
1839
|
+
skewY: (el, value) => {
|
|
1840
|
+
const current = el.style.transform || "";
|
|
1841
|
+
el.style.transform = current ? `${current} skewY(${value})` : `skewY(${value})`;
|
|
1842
|
+
},
|
|
1843
|
+
perspective: (el, value) => {
|
|
1844
|
+
el.style.perspective = typeof value === "number" ? `${value}px` : String(value);
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
});
|
|
1848
|
+
|
|
1849
|
+
// src/dom/applicators/effects.ts
|
|
1850
|
+
var exports_effects = {};
|
|
1851
|
+
__export(exports_effects, {
|
|
1852
|
+
effectsHandlers: () => effectsHandlers
|
|
1853
|
+
});
|
|
1854
|
+
var effectsHandlers;
|
|
1855
|
+
var init_effects = __esm(() => {
|
|
1856
|
+
effectsHandlers = {
|
|
1857
|
+
boxShadow: (el, value) => {
|
|
1858
|
+
el.style.boxShadow = String(value);
|
|
1859
|
+
},
|
|
1860
|
+
textShadow: (el, value) => {
|
|
1861
|
+
el.style.textShadow = String(value);
|
|
1862
|
+
},
|
|
1863
|
+
filter: (el, value) => {
|
|
1864
|
+
el.style.filter = String(value);
|
|
1865
|
+
},
|
|
1866
|
+
backdropFilter: (el, value) => {
|
|
1867
|
+
el.style.backdropFilter = String(value);
|
|
1868
|
+
},
|
|
1869
|
+
blur: (el, value) => {
|
|
1870
|
+
const val = typeof value === "number" ? `${value}px` : String(value);
|
|
1871
|
+
const current = el.style.filter || "";
|
|
1872
|
+
el.style.filter = current ? `${current} blur(${val})` : `blur(${val})`;
|
|
1873
|
+
},
|
|
1874
|
+
brightness: (el, value) => {
|
|
1875
|
+
const current = el.style.filter || "";
|
|
1876
|
+
el.style.filter = current ? `${current} brightness(${value})` : `brightness(${value})`;
|
|
1877
|
+
},
|
|
1878
|
+
contrast: (el, value) => {
|
|
1879
|
+
const current = el.style.filter || "";
|
|
1880
|
+
el.style.filter = current ? `${current} contrast(${value})` : `contrast(${value})`;
|
|
1881
|
+
},
|
|
1882
|
+
grayscale: (el, value) => {
|
|
1883
|
+
const current = el.style.filter || "";
|
|
1884
|
+
el.style.filter = current ? `${current} grayscale(${value})` : `grayscale(${value})`;
|
|
1885
|
+
},
|
|
1886
|
+
hueRotate: (el, value) => {
|
|
1887
|
+
const val = String(value);
|
|
1888
|
+
const current = el.style.filter || "";
|
|
1889
|
+
el.style.filter = current ? `${current} hue-rotate(${val})` : `hue-rotate(${val})`;
|
|
1890
|
+
},
|
|
1891
|
+
invert: (el, value) => {
|
|
1892
|
+
const current = el.style.filter || "";
|
|
1893
|
+
el.style.filter = current ? `${current} invert(${value})` : `invert(${value})`;
|
|
1894
|
+
},
|
|
1895
|
+
saturate: (el, value) => {
|
|
1896
|
+
const current = el.style.filter || "";
|
|
1897
|
+
el.style.filter = current ? `${current} saturate(${value})` : `saturate(${value})`;
|
|
1898
|
+
},
|
|
1899
|
+
sepia: (el, value) => {
|
|
1900
|
+
const current = el.style.filter || "";
|
|
1901
|
+
el.style.filter = current ? `${current} sepia(${value})` : `sepia(${value})`;
|
|
1902
|
+
},
|
|
1903
|
+
dropShadow: (el, value) => {
|
|
1904
|
+
const current = el.style.filter || "";
|
|
1905
|
+
el.style.filter = current ? `${current} drop-shadow(${value})` : `drop-shadow(${value})`;
|
|
1906
|
+
},
|
|
1907
|
+
mixBlendMode: (el, value) => {
|
|
1908
|
+
el.style.mixBlendMode = String(value);
|
|
1909
|
+
},
|
|
1910
|
+
backgroundBlendMode: (el, value) => {
|
|
1911
|
+
el.style.backgroundBlendMode = String(value);
|
|
1912
|
+
},
|
|
1913
|
+
clipPath: (el, value) => {
|
|
1914
|
+
el.style.clipPath = String(value);
|
|
1915
|
+
},
|
|
1916
|
+
mask: (el, value) => {
|
|
1917
|
+
el.style.mask = String(value);
|
|
1918
|
+
},
|
|
1919
|
+
maskImage: (el, value) => {
|
|
1920
|
+
el.style.maskImage = String(value);
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
// src/dom/applicators/advanced-layout.ts
|
|
1926
|
+
var exports_advanced_layout = {};
|
|
1927
|
+
__export(exports_advanced_layout, {
|
|
1928
|
+
advancedLayoutHandlers: () => advancedLayoutHandlers
|
|
1929
|
+
});
|
|
1930
|
+
var advancedLayoutHandlers;
|
|
1931
|
+
var init_advanced_layout = __esm(() => {
|
|
1932
|
+
advancedLayoutHandlers = {
|
|
1933
|
+
flexDirection: (el, value) => {
|
|
1934
|
+
el.style.flexDirection = String(value);
|
|
1935
|
+
},
|
|
1936
|
+
flexWrap: (el, value) => {
|
|
1937
|
+
el.style.flexWrap = String(value);
|
|
1938
|
+
},
|
|
1939
|
+
flexBasis: (el, value) => {
|
|
1940
|
+
el.style.flexBasis = typeof value === "number" ? `${value}px` : String(value);
|
|
1941
|
+
},
|
|
1942
|
+
justifyContent: (el, value) => {
|
|
1943
|
+
el.style.justifyContent = String(value);
|
|
1944
|
+
},
|
|
1945
|
+
alignItems: (el, value) => {
|
|
1946
|
+
el.style.alignItems = String(value);
|
|
1947
|
+
},
|
|
1948
|
+
alignContent: (el, value) => {
|
|
1949
|
+
el.style.alignContent = String(value);
|
|
1950
|
+
},
|
|
1951
|
+
alignSelf: (el, value) => {
|
|
1952
|
+
el.style.alignSelf = String(value);
|
|
1953
|
+
},
|
|
1954
|
+
order: (el, value) => {
|
|
1955
|
+
el.style.order = String(value);
|
|
1956
|
+
},
|
|
1957
|
+
gridTemplateColumns: (el, value) => {
|
|
1958
|
+
el.style.gridTemplateColumns = String(value);
|
|
1959
|
+
},
|
|
1960
|
+
gridTemplateRows: (el, value) => {
|
|
1961
|
+
el.style.gridTemplateRows = String(value);
|
|
1962
|
+
},
|
|
1963
|
+
gridTemplateAreas: (el, value) => {
|
|
1964
|
+
el.style.gridTemplateAreas = String(value);
|
|
1965
|
+
},
|
|
1966
|
+
gridColumn: (el, value) => {
|
|
1967
|
+
el.style.gridColumn = String(value);
|
|
1968
|
+
},
|
|
1969
|
+
gridRow: (el, value) => {
|
|
1970
|
+
el.style.gridRow = String(value);
|
|
1971
|
+
},
|
|
1972
|
+
gridArea: (el, value) => {
|
|
1973
|
+
el.style.gridArea = String(value);
|
|
1974
|
+
},
|
|
1975
|
+
gridAutoFlow: (el, value) => {
|
|
1976
|
+
el.style.gridAutoFlow = String(value);
|
|
1977
|
+
},
|
|
1978
|
+
gridAutoColumns: (el, value) => {
|
|
1979
|
+
el.style.gridAutoColumns = String(value);
|
|
1980
|
+
},
|
|
1981
|
+
gridAutoRows: (el, value) => {
|
|
1982
|
+
el.style.gridAutoRows = String(value);
|
|
1983
|
+
},
|
|
1984
|
+
rowGap: (el, value) => {
|
|
1985
|
+
el.style.rowGap = typeof value === "number" ? `${value}px` : String(value);
|
|
1986
|
+
},
|
|
1987
|
+
columnGap: (el, value) => {
|
|
1988
|
+
el.style.columnGap = typeof value === "number" ? `${value}px` : String(value);
|
|
1989
|
+
},
|
|
1990
|
+
placeItems: (el, value) => {
|
|
1991
|
+
el.style.placeItems = String(value);
|
|
1992
|
+
},
|
|
1993
|
+
placeContent: (el, value) => {
|
|
1994
|
+
el.style.placeContent = String(value);
|
|
1995
|
+
},
|
|
1996
|
+
placeSelf: (el, value) => {
|
|
1997
|
+
el.style.placeSelf = String(value);
|
|
1998
|
+
},
|
|
1999
|
+
position: (el, value) => {
|
|
2000
|
+
el.style.position = String(value);
|
|
2001
|
+
},
|
|
2002
|
+
top: (el, value) => {
|
|
2003
|
+
el.style.top = typeof value === "number" ? `${value}px` : String(value);
|
|
2004
|
+
},
|
|
2005
|
+
right: (el, value) => {
|
|
2006
|
+
el.style.right = typeof value === "number" ? `${value}px` : String(value);
|
|
2007
|
+
},
|
|
2008
|
+
bottom: (el, value) => {
|
|
2009
|
+
el.style.bottom = typeof value === "number" ? `${value}px` : String(value);
|
|
2010
|
+
},
|
|
2011
|
+
left: (el, value) => {
|
|
2012
|
+
el.style.left = typeof value === "number" ? `${value}px` : String(value);
|
|
2013
|
+
},
|
|
2014
|
+
inset: (el, value) => {
|
|
2015
|
+
el.style.inset = typeof value === "number" ? `${value}px` : String(value);
|
|
2016
|
+
},
|
|
2017
|
+
zIndex: (el, value) => {
|
|
2018
|
+
el.style.zIndex = String(value);
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
});
|
|
2022
|
+
|
|
2023
|
+
// src/dom/applicators/background.ts
|
|
2024
|
+
var exports_background = {};
|
|
2025
|
+
__export(exports_background, {
|
|
2026
|
+
backgroundHandlers: () => backgroundHandlers
|
|
2027
|
+
});
|
|
2028
|
+
var backgroundHandlers;
|
|
2029
|
+
var init_background = __esm(() => {
|
|
2030
|
+
backgroundHandlers = {
|
|
2031
|
+
backgroundImage: (el, value) => {
|
|
2032
|
+
el.style.backgroundImage = String(value);
|
|
2033
|
+
},
|
|
2034
|
+
backgroundSize: (el, value) => {
|
|
2035
|
+
el.style.backgroundSize = String(value);
|
|
2036
|
+
},
|
|
2037
|
+
backgroundPosition: (el, value) => {
|
|
2038
|
+
el.style.backgroundPosition = String(value);
|
|
2039
|
+
},
|
|
2040
|
+
backgroundRepeat: (el, value) => {
|
|
2041
|
+
el.style.backgroundRepeat = String(value);
|
|
2042
|
+
},
|
|
2043
|
+
backgroundAttachment: (el, value) => {
|
|
2044
|
+
el.style.backgroundAttachment = String(value);
|
|
2045
|
+
},
|
|
2046
|
+
backgroundClip: (el, value) => {
|
|
2047
|
+
el.style.backgroundClip = String(value);
|
|
2048
|
+
},
|
|
2049
|
+
backgroundOrigin: (el, value) => {
|
|
2050
|
+
el.style.backgroundOrigin = String(value);
|
|
2051
|
+
},
|
|
2052
|
+
linearGradient: (el, value) => {
|
|
2053
|
+
el.style.backgroundImage = `linear-gradient(${value})`;
|
|
2054
|
+
},
|
|
2055
|
+
radialGradient: (el, value) => {
|
|
2056
|
+
el.style.backgroundImage = `radial-gradient(${value})`;
|
|
2057
|
+
},
|
|
2058
|
+
conicGradient: (el, value) => {
|
|
2059
|
+
el.style.backgroundImage = `conic-gradient(${value})`;
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
// src/dom/applicators/display.ts
|
|
2065
|
+
var exports_display = {};
|
|
2066
|
+
__export(exports_display, {
|
|
2067
|
+
displayHandlers: () => displayHandlers
|
|
2068
|
+
});
|
|
2069
|
+
var displayHandlers;
|
|
2070
|
+
var init_display = __esm(() => {
|
|
2071
|
+
displayHandlers = {
|
|
2072
|
+
display: (el, value) => {
|
|
2073
|
+
el.style.display = String(value);
|
|
2074
|
+
},
|
|
2075
|
+
visibility: (el, value) => {
|
|
2076
|
+
el.style.visibility = String(value);
|
|
2077
|
+
},
|
|
2078
|
+
overflowX: (el, value) => {
|
|
2079
|
+
el.style.overflowX = String(value);
|
|
2080
|
+
},
|
|
2081
|
+
overflowY: (el, value) => {
|
|
2082
|
+
el.style.overflowY = String(value);
|
|
2083
|
+
},
|
|
2084
|
+
pointerEvents: (el, value) => {
|
|
2085
|
+
el.style.pointerEvents = String(value);
|
|
2086
|
+
},
|
|
2087
|
+
userSelect: (el, value) => {
|
|
2088
|
+
el.style.userSelect = String(value);
|
|
2089
|
+
},
|
|
2090
|
+
resize: (el, value) => {
|
|
2091
|
+
el.style.resize = String(value);
|
|
2092
|
+
},
|
|
2093
|
+
boxSizing: (el, value) => {
|
|
2094
|
+
el.style.boxSizing = String(value);
|
|
2095
|
+
},
|
|
2096
|
+
aspectRatio: (el, value) => {
|
|
2097
|
+
el.style.aspectRatio = String(value);
|
|
2098
|
+
},
|
|
2099
|
+
objectFit: (el, value) => {
|
|
2100
|
+
el.style.objectFit = String(value);
|
|
2101
|
+
},
|
|
2102
|
+
objectPosition: (el, value) => {
|
|
2103
|
+
el.style.objectPosition = String(value);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
});
|
|
2107
|
+
|
|
2108
|
+
// src/dom/applicators/transition.ts
|
|
2109
|
+
var exports_transition = {};
|
|
2110
|
+
__export(exports_transition, {
|
|
2111
|
+
transitionHandlers: () => transitionHandlers
|
|
2112
|
+
});
|
|
2113
|
+
var transitionHandlers;
|
|
2114
|
+
var init_transition = __esm(() => {
|
|
2115
|
+
transitionHandlers = {
|
|
2116
|
+
transition: (el, value) => {
|
|
2117
|
+
el.style.transition = String(value);
|
|
2118
|
+
},
|
|
2119
|
+
transitionProperty: (el, value) => {
|
|
2120
|
+
el.style.transitionProperty = String(value);
|
|
2121
|
+
},
|
|
2122
|
+
transitionDuration: (el, value) => {
|
|
2123
|
+
el.style.transitionDuration = String(value);
|
|
2124
|
+
},
|
|
2125
|
+
transitionTimingFunction: (el, value) => {
|
|
2126
|
+
el.style.transitionTimingFunction = String(value);
|
|
2127
|
+
},
|
|
2128
|
+
transitionDelay: (el, value) => {
|
|
2129
|
+
el.style.transitionDelay = String(value);
|
|
2130
|
+
},
|
|
2131
|
+
animation: (el, value) => {
|
|
2132
|
+
el.style.animation = String(value);
|
|
2133
|
+
},
|
|
2134
|
+
animationName: (el, value) => {
|
|
2135
|
+
el.style.animationName = String(value);
|
|
2136
|
+
},
|
|
2137
|
+
animationDuration: (el, value) => {
|
|
2138
|
+
el.style.animationDuration = String(value);
|
|
2139
|
+
},
|
|
2140
|
+
animationTimingFunction: (el, value) => {
|
|
2141
|
+
el.style.animationTimingFunction = String(value);
|
|
2142
|
+
},
|
|
2143
|
+
animationDelay: (el, value) => {
|
|
2144
|
+
el.style.animationDelay = String(value);
|
|
2145
|
+
},
|
|
2146
|
+
animationIterationCount: (el, value) => {
|
|
2147
|
+
el.style.animationIterationCount = String(value);
|
|
2148
|
+
},
|
|
2149
|
+
animationDirection: (el, value) => {
|
|
2150
|
+
el.style.animationDirection = String(value);
|
|
2151
|
+
},
|
|
2152
|
+
animationFillMode: (el, value) => {
|
|
2153
|
+
el.style.animationFillMode = String(value);
|
|
2154
|
+
},
|
|
2155
|
+
animationPlayState: (el, value) => {
|
|
2156
|
+
el.style.animationPlayState = String(value);
|
|
2157
|
+
}
|
|
2158
|
+
};
|
|
2159
|
+
});
|
|
2160
|
+
|
|
2161
|
+
// src/dom/components/index.ts
|
|
2162
|
+
class ComponentRegistry {
|
|
2163
|
+
handlers = new Map;
|
|
2164
|
+
constructor() {
|
|
2165
|
+
this.registerDefaults();
|
|
2166
|
+
}
|
|
2167
|
+
register(type, handler) {
|
|
2168
|
+
this.handlers.set(type.toLowerCase(), handler);
|
|
2169
|
+
}
|
|
2170
|
+
get(type) {
|
|
2171
|
+
return this.handlers.get(type.toLowerCase());
|
|
2172
|
+
}
|
|
2173
|
+
createElement(type, props = {}) {
|
|
2174
|
+
const handler = this.get(type);
|
|
2175
|
+
if (!handler)
|
|
2176
|
+
return null;
|
|
2177
|
+
const element = handler.create();
|
|
2178
|
+
if (handler.applyProps) {
|
|
2179
|
+
handler.applyProps(element, props);
|
|
2180
|
+
}
|
|
2181
|
+
return element;
|
|
2182
|
+
}
|
|
2183
|
+
registerDefaults() {
|
|
2184
|
+
const { columnHandler: columnHandler2 } = (init_column(), __toCommonJS(exports_column));
|
|
2185
|
+
const { rowHandler: rowHandler2 } = (init_row(), __toCommonJS(exports_row));
|
|
2186
|
+
const { textHandler: textHandler2 } = (init_text(), __toCommonJS(exports_text));
|
|
2187
|
+
const { imageHandler: imageHandler2 } = (init_image(), __toCommonJS(exports_image));
|
|
2188
|
+
const { buttonHandler: buttonHandler2 } = (init_button(), __toCommonJS(exports_button));
|
|
2189
|
+
const { containerHandler: containerHandler2 } = (init_container(), __toCommonJS(exports_container));
|
|
2190
|
+
const { centerHandler: centerHandler2 } = (init_center(), __toCommonJS(exports_center));
|
|
2191
|
+
const { listHandler: listHandler2 } = (init_list(), __toCommonJS(exports_list));
|
|
2192
|
+
const { inputHandler: inputHandler2 } = (init_input(), __toCommonJS(exports_input));
|
|
2193
|
+
const { linkHandler: linkHandler2 } = (init_link(), __toCommonJS(exports_link));
|
|
2194
|
+
const { textareaHandler: textareaHandler2 } = (init_textarea(), __toCommonJS(exports_textarea));
|
|
2195
|
+
const { checkboxHandler: checkboxHandler2 } = (init_checkbox(), __toCommonJS(exports_checkbox));
|
|
2196
|
+
const { selectHandler: selectHandler2 } = (init_select(), __toCommonJS(exports_select));
|
|
2197
|
+
const { spacerHandler: spacerHandler2 } = (init_spacer(), __toCommonJS(exports_spacer));
|
|
2198
|
+
const { stackHandler: stackHandler2 } = (init_stack(), __toCommonJS(exports_stack));
|
|
2199
|
+
const { dividerHandler: dividerHandler2 } = (init_divider(), __toCommonJS(exports_divider));
|
|
2200
|
+
const { gridHandler: gridHandler2 } = (init_grid(), __toCommonJS(exports_grid));
|
|
2201
|
+
const { cardHandler: cardHandler2 } = (init_card(), __toCommonJS(exports_card));
|
|
2202
|
+
const { headingHandler: headingHandler2 } = (init_heading(), __toCommonJS(exports_heading));
|
|
2203
|
+
const { switchHandler: switchHandler2 } = (init_switch(), __toCommonJS(exports_switch));
|
|
2204
|
+
const { sliderHandler: sliderHandler2 } = (init_slider(), __toCommonJS(exports_slider));
|
|
2205
|
+
const { spinnerHandler: spinnerHandler2 } = (init_spinner(), __toCommonJS(exports_spinner));
|
|
2206
|
+
const { badgeHandler: badgeHandler2 } = (init_badge(), __toCommonJS(exports_badge));
|
|
2207
|
+
const { avatarHandler: avatarHandler2 } = (init_avatar(), __toCommonJS(exports_avatar));
|
|
2208
|
+
const { progressBarHandler: progressBarHandler2 } = (init_progressbar(), __toCommonJS(exports_progressbar));
|
|
2209
|
+
const { videoHandler: videoHandler2 } = (init_video(), __toCommonJS(exports_video));
|
|
2210
|
+
const { audioHandler: audioHandler2 } = (init_audio(), __toCommonJS(exports_audio));
|
|
2211
|
+
const { paragraphHandler: paragraphHandler2 } = (init_paragraph(), __toCommonJS(exports_paragraph));
|
|
2212
|
+
const { routerHandler: routerHandler2 } = (init_router(), __toCommonJS(exports_router));
|
|
2213
|
+
const { routeHandler: routeHandler2 } = (init_route(), __toCommonJS(exports_route));
|
|
2214
|
+
this.register("column", columnHandler2);
|
|
2215
|
+
this.register("row", rowHandler2);
|
|
2216
|
+
this.register("text", textHandler2);
|
|
2217
|
+
this.register("image", imageHandler2);
|
|
2218
|
+
this.register("button", buttonHandler2);
|
|
2219
|
+
this.register("container", containerHandler2);
|
|
2220
|
+
this.register("box", containerHandler2);
|
|
2221
|
+
this.register("center", centerHandler2);
|
|
2222
|
+
this.register("list", listHandler2);
|
|
2223
|
+
this.register("input", inputHandler2);
|
|
2224
|
+
this.register("link", linkHandler2);
|
|
2225
|
+
this.register("textarea", textareaHandler2);
|
|
2226
|
+
this.register("checkbox", checkboxHandler2);
|
|
2227
|
+
this.register("select", selectHandler2);
|
|
2228
|
+
this.register("spacer", spacerHandler2);
|
|
2229
|
+
this.register("stack", stackHandler2);
|
|
2230
|
+
this.register("divider", dividerHandler2);
|
|
2231
|
+
this.register("grid", gridHandler2);
|
|
2232
|
+
this.register("card", cardHandler2);
|
|
2233
|
+
this.register("heading", headingHandler2);
|
|
2234
|
+
this.register("switch", switchHandler2);
|
|
2235
|
+
this.register("slider", sliderHandler2);
|
|
2236
|
+
this.register("spinner", spinnerHandler2);
|
|
2237
|
+
this.register("badge", badgeHandler2);
|
|
2238
|
+
this.register("avatar", avatarHandler2);
|
|
2239
|
+
this.register("progressbar", progressBarHandler2);
|
|
2240
|
+
this.register("video", videoHandler2);
|
|
2241
|
+
this.register("audio", audioHandler2);
|
|
2242
|
+
this.register("paragraph", paragraphHandler2);
|
|
2243
|
+
this.register("router", routerHandler2);
|
|
2244
|
+
this.register("route", routeHandler2);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
// src/dom/applicators/index.ts
|
|
2249
|
+
class ApplicatorRegistry {
|
|
2250
|
+
handlers = new Map;
|
|
2251
|
+
elementState = new WeakMap;
|
|
2252
|
+
constructor() {
|
|
2253
|
+
this.registerDefaults();
|
|
2254
|
+
}
|
|
2255
|
+
register(name, handler) {
|
|
2256
|
+
this.handlers.set(name, handler);
|
|
2257
|
+
}
|
|
2258
|
+
apply(element, name, value) {
|
|
2259
|
+
const { handlerName, argKey, aggregate, fallbackName } = this.parseApplicatorName(name);
|
|
2260
|
+
const handler = this.handlers.get(handlerName);
|
|
2261
|
+
const state = this.getElementState(element);
|
|
2262
|
+
const previous = state.get(handlerName);
|
|
2263
|
+
if (aggregate && argKey !== null) {
|
|
2264
|
+
const merged = this.mergeAggregateState(previous, argKey, this.normalizeValue(value));
|
|
2265
|
+
state.set(handlerName, merged);
|
|
2266
|
+
if (handler) {
|
|
2267
|
+
handler(element, merged);
|
|
2268
|
+
} else {
|
|
2269
|
+
this.setStyleProperty(element, fallbackName, value);
|
|
2270
|
+
}
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (handler) {
|
|
2274
|
+
if (this.isEventApplicator(handlerName)) {
|
|
2275
|
+
const normalizedValue = this.normalizeEventValue(previous, value);
|
|
2276
|
+
state.set(handlerName, normalizedValue);
|
|
2277
|
+
handler(element, normalizedValue);
|
|
2278
|
+
} else {
|
|
2279
|
+
state.set(handlerName, value);
|
|
2280
|
+
handler(element, value);
|
|
2281
|
+
}
|
|
2282
|
+
} else {
|
|
2283
|
+
this.setStyleProperty(element, handlerName, value);
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
parseApplicatorName(name) {
|
|
2287
|
+
const dotIndex = name.indexOf(".");
|
|
2288
|
+
if (dotIndex === -1) {
|
|
2289
|
+
return { handlerName: name, argKey: null, aggregate: false, fallbackName: name };
|
|
2290
|
+
}
|
|
2291
|
+
const baseName = name.substring(0, dotIndex);
|
|
2292
|
+
const argKey = name.substring(dotIndex + 1);
|
|
2293
|
+
if (this.handlers.has(baseName) && this.isEventApplicator(baseName)) {
|
|
2294
|
+
return { handlerName: baseName, argKey, aggregate: true, fallbackName: name };
|
|
2295
|
+
}
|
|
2296
|
+
if (/^\d+$/.test(argKey)) {
|
|
2297
|
+
return { handlerName: baseName, argKey: null, aggregate: false, fallbackName: baseName };
|
|
2298
|
+
}
|
|
2299
|
+
return { handlerName: name, argKey: null, aggregate: false, fallbackName: name };
|
|
2300
|
+
}
|
|
2301
|
+
getElementState(element) {
|
|
2302
|
+
let state = this.elementState.get(element);
|
|
2303
|
+
if (!state) {
|
|
2304
|
+
state = new Map;
|
|
2305
|
+
this.elementState.set(element, state);
|
|
2306
|
+
}
|
|
2307
|
+
return state;
|
|
2308
|
+
}
|
|
2309
|
+
mergeAggregateState(previous, argKey, value) {
|
|
2310
|
+
const base = this.cloneAggregateState(previous);
|
|
2311
|
+
if (value === undefined) {
|
|
2312
|
+
delete base[argKey];
|
|
2313
|
+
} else {
|
|
2314
|
+
base[argKey] = value;
|
|
2315
|
+
}
|
|
2316
|
+
return base;
|
|
2317
|
+
}
|
|
2318
|
+
cloneAggregateState(previous) {
|
|
2319
|
+
if (previous && typeof previous === "object" && !Array.isArray(previous)) {
|
|
2320
|
+
return { ...previous };
|
|
2321
|
+
}
|
|
2322
|
+
if (typeof previous === "string") {
|
|
2323
|
+
return { "0": previous };
|
|
2324
|
+
}
|
|
2325
|
+
return {};
|
|
2326
|
+
}
|
|
2327
|
+
normalizeEventValue(previous, value) {
|
|
2328
|
+
const normalizedInput = this.normalizeValue(value);
|
|
2329
|
+
const base = this.cloneAggregateState(previous);
|
|
2330
|
+
if (normalizedInput && typeof normalizedInput === "object" && !Array.isArray(normalizedInput)) {
|
|
2331
|
+
const next = { ...base, ...normalizedInput };
|
|
2332
|
+
if (!Object.prototype.hasOwnProperty.call(next, "0") && base["0"] !== undefined) {
|
|
2333
|
+
next["0"] = base["0"];
|
|
2334
|
+
}
|
|
2335
|
+
return next;
|
|
2336
|
+
}
|
|
2337
|
+
if (normalizedInput !== undefined) {
|
|
2338
|
+
base["0"] = normalizedInput;
|
|
2339
|
+
}
|
|
2340
|
+
return base;
|
|
2341
|
+
}
|
|
2342
|
+
normalizeValue(value) {
|
|
2343
|
+
if (value instanceof Map) {
|
|
2344
|
+
const obj = {};
|
|
2345
|
+
for (const [key, val] of value.entries()) {
|
|
2346
|
+
obj[key] = this.normalizeValue(val);
|
|
2347
|
+
}
|
|
2348
|
+
return obj;
|
|
2349
|
+
}
|
|
2350
|
+
if (Array.isArray(value)) {
|
|
2351
|
+
return value.map((item) => this.normalizeValue(item));
|
|
2352
|
+
}
|
|
2353
|
+
if (value && typeof value === "object") {
|
|
2354
|
+
const obj = {};
|
|
2355
|
+
for (const [key, val] of Object.entries(value)) {
|
|
2356
|
+
obj[key] = this.normalizeValue(val);
|
|
2357
|
+
}
|
|
2358
|
+
return obj;
|
|
2359
|
+
}
|
|
2360
|
+
return value;
|
|
2361
|
+
}
|
|
2362
|
+
isEventApplicator(name) {
|
|
2363
|
+
return /^on[A-Z]/.test(name);
|
|
2364
|
+
}
|
|
2365
|
+
applyAll(element, applicators) {
|
|
2366
|
+
const grouped = new Map;
|
|
2367
|
+
for (const [name, value] of Object.entries(applicators)) {
|
|
2368
|
+
const dotIndex = name.indexOf(".");
|
|
2369
|
+
const baseName = dotIndex !== -1 ? name.substring(0, dotIndex) : name;
|
|
2370
|
+
const argKey = dotIndex !== -1 ? name.substring(dotIndex + 1) : null;
|
|
2371
|
+
if (!grouped.has(baseName)) {
|
|
2372
|
+
grouped.set(baseName, {});
|
|
2373
|
+
}
|
|
2374
|
+
const args = grouped.get(baseName);
|
|
2375
|
+
if (argKey !== null) {
|
|
2376
|
+
args[argKey] = value;
|
|
2377
|
+
} else {
|
|
2378
|
+
args["__value"] = value;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
for (const [baseName, args] of grouped.entries()) {
|
|
2382
|
+
if (Object.keys(args).length === 1) {
|
|
2383
|
+
if ("__value" in args) {
|
|
2384
|
+
this.apply(element, baseName, args["__value"]);
|
|
2385
|
+
} else if ("0" in args) {
|
|
2386
|
+
this.apply(element, baseName, args["0"]);
|
|
2387
|
+
} else {
|
|
2388
|
+
this.apply(element, baseName, args);
|
|
2389
|
+
}
|
|
2390
|
+
} else {
|
|
2391
|
+
this.apply(element, baseName, args);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
setStyleProperty(element, name, value) {
|
|
2396
|
+
const cssName = name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2397
|
+
if (typeof value === "number" && this.needsUnit(cssName)) {
|
|
2398
|
+
element.style.setProperty(cssName, `${value}px`);
|
|
2399
|
+
} else {
|
|
2400
|
+
element.style.setProperty(cssName, String(value));
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
needsUnit(prop) {
|
|
2404
|
+
const unitless = [
|
|
2405
|
+
"opacity",
|
|
2406
|
+
"z-index",
|
|
2407
|
+
"font-weight",
|
|
2408
|
+
"line-height",
|
|
2409
|
+
"flex",
|
|
2410
|
+
"flex-grow",
|
|
2411
|
+
"flex-shrink",
|
|
2412
|
+
"order"
|
|
2413
|
+
];
|
|
2414
|
+
return !unitless.includes(prop);
|
|
2415
|
+
}
|
|
2416
|
+
registerDefaults() {
|
|
2417
|
+
const { paddingHandler: paddingHandler2 } = __toCommonJS(exports_padding);
|
|
2418
|
+
const { marginHandler: marginHandler2 } = __toCommonJS(exports_margin);
|
|
2419
|
+
const { colorHandlers: colorHandlers2 } = (init_color(), __toCommonJS(exports_color));
|
|
2420
|
+
const { borderHandlers: borderHandlers2 } = (init_border(), __toCommonJS(exports_border));
|
|
2421
|
+
const { sizeHandlers: sizeHandlers2 } = (init_size(), __toCommonJS(exports_size));
|
|
2422
|
+
const { fontHandlers: fontHandlers2 } = (init_font(), __toCommonJS(exports_font));
|
|
2423
|
+
const { layoutHandlers: layoutHandlers2 } = (init_layout(), __toCommonJS(exports_layout));
|
|
2424
|
+
const { eventHandlers: eventHandlers2 } = (init_events(), __toCommonJS(exports_events));
|
|
2425
|
+
const { typographyHandlers: typographyHandlers2 } = (init_typography(), __toCommonJS(exports_typography));
|
|
2426
|
+
const { transformHandlers: transformHandlers2 } = (init_transform(), __toCommonJS(exports_transform));
|
|
2427
|
+
const { effectsHandlers: effectsHandlers2 } = (init_effects(), __toCommonJS(exports_effects));
|
|
2428
|
+
const { advancedLayoutHandlers: advancedLayoutHandlers2 } = (init_advanced_layout(), __toCommonJS(exports_advanced_layout));
|
|
2429
|
+
const { backgroundHandlers: backgroundHandlers2 } = (init_background(), __toCommonJS(exports_background));
|
|
2430
|
+
const { displayHandlers: displayHandlers2 } = (init_display(), __toCommonJS(exports_display));
|
|
2431
|
+
const { transitionHandlers: transitionHandlers2 } = (init_transition(), __toCommonJS(exports_transition));
|
|
2432
|
+
this.register("padding", paddingHandler2);
|
|
2433
|
+
this.register("margin", marginHandler2);
|
|
2434
|
+
for (const [name, handler] of Object.entries(colorHandlers2)) {
|
|
2435
|
+
this.register(name, handler);
|
|
2436
|
+
}
|
|
2437
|
+
for (const [name, handler] of Object.entries(borderHandlers2)) {
|
|
2438
|
+
this.register(name, handler);
|
|
2439
|
+
}
|
|
2440
|
+
for (const [name, handler] of Object.entries(sizeHandlers2)) {
|
|
2441
|
+
this.register(name, handler);
|
|
2442
|
+
}
|
|
2443
|
+
for (const [name, handler] of Object.entries(fontHandlers2)) {
|
|
2444
|
+
this.register(name, handler);
|
|
2445
|
+
}
|
|
2446
|
+
for (const [name, handler] of Object.entries(layoutHandlers2)) {
|
|
2447
|
+
this.register(name, handler);
|
|
2448
|
+
}
|
|
2449
|
+
for (const [name, handler] of Object.entries(eventHandlers2)) {
|
|
2450
|
+
this.register(name, handler);
|
|
2451
|
+
}
|
|
2452
|
+
for (const [name, handler] of Object.entries(typographyHandlers2)) {
|
|
2453
|
+
this.register(name, handler);
|
|
2454
|
+
}
|
|
2455
|
+
for (const [name, handler] of Object.entries(transformHandlers2)) {
|
|
2456
|
+
this.register(name, handler);
|
|
2457
|
+
}
|
|
2458
|
+
for (const [name, handler] of Object.entries(effectsHandlers2)) {
|
|
2459
|
+
this.register(name, handler);
|
|
2460
|
+
}
|
|
2461
|
+
for (const [name, handler] of Object.entries(advancedLayoutHandlers2)) {
|
|
2462
|
+
this.register(name, handler);
|
|
2463
|
+
}
|
|
2464
|
+
for (const [name, handler] of Object.entries(backgroundHandlers2)) {
|
|
2465
|
+
this.register(name, handler);
|
|
2466
|
+
}
|
|
2467
|
+
for (const [name, handler] of Object.entries(displayHandlers2)) {
|
|
2468
|
+
this.register(name, handler);
|
|
2469
|
+
}
|
|
2470
|
+
for (const [name, handler] of Object.entries(transitionHandlers2)) {
|
|
2471
|
+
this.register(name, handler);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
// src/dom/canvas/index.ts
|
|
2477
|
+
var canvasHandler = {
|
|
2478
|
+
create() {
|
|
2479
|
+
const el = document.createElement("canvas");
|
|
2480
|
+
el.dataset.hypenType = "canvas";
|
|
2481
|
+
return el;
|
|
2482
|
+
},
|
|
2483
|
+
applyProps(el, props) {
|
|
2484
|
+
const canvas = el;
|
|
2485
|
+
if (props.width !== undefined) {
|
|
2486
|
+
canvas.width = Number(props.width);
|
|
2487
|
+
}
|
|
2488
|
+
if (props.height !== undefined) {
|
|
2489
|
+
canvas.height = Number(props.height);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
var canvasApplicators = {
|
|
2494
|
+
fillStyle: (el, value) => {
|
|
2495
|
+
const canvas = el;
|
|
2496
|
+
const ctx = canvas.getContext("2d");
|
|
2497
|
+
if (ctx) {
|
|
2498
|
+
ctx.fillStyle = String(value);
|
|
2499
|
+
}
|
|
2500
|
+
},
|
|
2501
|
+
strokeStyle: (el, value) => {
|
|
2502
|
+
const canvas = el;
|
|
2503
|
+
const ctx = canvas.getContext("2d");
|
|
2504
|
+
if (ctx) {
|
|
2505
|
+
ctx.strokeStyle = String(value);
|
|
2506
|
+
}
|
|
2507
|
+
},
|
|
2508
|
+
lineWidth: (el, value) => {
|
|
2509
|
+
const canvas = el;
|
|
2510
|
+
const ctx = canvas.getContext("2d");
|
|
2511
|
+
if (ctx) {
|
|
2512
|
+
ctx.lineWidth = Number(value);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
};
|
|
2516
|
+
|
|
2517
|
+
// src/dom/debug.ts
|
|
2518
|
+
var defaultDebugConfig = {
|
|
2519
|
+
enabled: false,
|
|
2520
|
+
showHeatmap: true,
|
|
2521
|
+
heatmapIncrement: 5,
|
|
2522
|
+
maxOpacity: 0.8,
|
|
2523
|
+
fadeOutDuration: 2000
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
class RerenderTracker {
|
|
2527
|
+
renderCounts = new Map;
|
|
2528
|
+
overlays = new Map;
|
|
2529
|
+
config;
|
|
2530
|
+
constructor(config = defaultDebugConfig) {
|
|
2531
|
+
this.config = config;
|
|
2532
|
+
}
|
|
2533
|
+
setConfig(config) {
|
|
2534
|
+
this.config = { ...this.config, ...config };
|
|
2535
|
+
if (!this.config.enabled) {
|
|
2536
|
+
this.cleanup();
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
trackRerender(id, element, patchType) {
|
|
2540
|
+
if (!this.config.enabled || !this.config.showHeatmap) {
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
console.log(`\uD83D\uDD25 [Debug] Tracking re-render: ${id} - ${patchType}`);
|
|
2544
|
+
const currentCount = this.renderCounts.get(id) || 0;
|
|
2545
|
+
const newCount = currentCount + 1;
|
|
2546
|
+
this.renderCounts.set(id, newCount);
|
|
2547
|
+
this.updateHeatmap(id, element, newCount, patchType);
|
|
2548
|
+
}
|
|
2549
|
+
updateHeatmap(id, element, renderCount, patchType) {
|
|
2550
|
+
const opacity = Math.min(renderCount * this.config.heatmapIncrement / 100, this.config.maxOpacity);
|
|
2551
|
+
console.log(`\uD83D\uDD25 [Debug] Updating heatmap for ${id}, count: ${renderCount}, opacity: ${opacity}`);
|
|
2552
|
+
const isInline = window.getComputedStyle(element).display.includes("inline");
|
|
2553
|
+
if (isInline || element.tagName === "SPAN") {
|
|
2554
|
+
if (!element.dataset.hypenDebugOriginalBg) {
|
|
2555
|
+
element.dataset.hypenDebugOriginalBg = element.style.backgroundColor || "";
|
|
2556
|
+
element.dataset.hypenDebugOriginalOutline = element.style.outline || "";
|
|
2557
|
+
element.dataset.hypenDebugOriginalPosition = element.style.position || "";
|
|
2558
|
+
}
|
|
2559
|
+
element.style.backgroundColor = `rgba(255, 0, 0, ${Math.max(opacity, 0.15)})`;
|
|
2560
|
+
element.style.outline = `2px solid rgba(255, 0, 0, ${Math.max(opacity + 0.2, 0.3)})`;
|
|
2561
|
+
element.style.outlineOffset = "2px";
|
|
2562
|
+
element.style.position = "relative";
|
|
2563
|
+
element.setAttribute("data-hypen-renders", `${renderCount}× ${patchType}`);
|
|
2564
|
+
if (!document.getElementById("hypen-debug-styles")) {
|
|
2565
|
+
const style = document.createElement("style");
|
|
2566
|
+
style.id = "hypen-debug-styles";
|
|
2567
|
+
style.textContent = `
|
|
2568
|
+
[data-hypen-renders]::before {
|
|
2569
|
+
content: attr(data-hypen-renders);
|
|
2570
|
+
position: absolute;
|
|
2571
|
+
top: -18px;
|
|
2572
|
+
left: 0;
|
|
2573
|
+
background: rgba(255, 0, 0, 0.9);
|
|
2574
|
+
color: white;
|
|
2575
|
+
padding: 2px 6px;
|
|
2576
|
+
font-size: 10px;
|
|
2577
|
+
font-family: 'Courier New', monospace;
|
|
2578
|
+
font-weight: bold;
|
|
2579
|
+
border-radius: 3px;
|
|
2580
|
+
z-index: 999999;
|
|
2581
|
+
pointer-events: none;
|
|
2582
|
+
white-space: nowrap;
|
|
2583
|
+
text-shadow: none;
|
|
2584
|
+
}
|
|
2585
|
+
`;
|
|
2586
|
+
document.head.appendChild(style);
|
|
2587
|
+
}
|
|
2588
|
+
this.overlays.set(id, element);
|
|
2589
|
+
if (this.config.fadeOutDuration > 0) {
|
|
2590
|
+
setTimeout(() => {
|
|
2591
|
+
const originalBg = element.dataset.hypenDebugOriginalBg || "";
|
|
2592
|
+
const originalOutline = element.dataset.hypenDebugOriginalOutline || "";
|
|
2593
|
+
element.style.backgroundColor = originalBg;
|
|
2594
|
+
element.style.outline = originalOutline;
|
|
2595
|
+
element.style.opacity = "1";
|
|
2596
|
+
}, this.config.fadeOutDuration);
|
|
2597
|
+
}
|
|
2598
|
+
} else {
|
|
2599
|
+
let overlay = this.overlays.get(id);
|
|
2600
|
+
if (!overlay) {
|
|
2601
|
+
overlay = document.createElement("div");
|
|
2602
|
+
overlay.className = "hypen-debug-overlay";
|
|
2603
|
+
overlay.style.cssText = `
|
|
2604
|
+
position: absolute;
|
|
2605
|
+
top: 0;
|
|
2606
|
+
left: 0;
|
|
2607
|
+
right: 0;
|
|
2608
|
+
bottom: 0;
|
|
2609
|
+
pointer-events: none;
|
|
2610
|
+
z-index: 999999 !important;
|
|
2611
|
+
transition: opacity ${this.config.fadeOutDuration}ms ease-out;
|
|
2612
|
+
border: 2px solid rgba(255, 0, 0, 0.7) !important;
|
|
2613
|
+
box-sizing: border-box;
|
|
2614
|
+
font-size: 11px;
|
|
2615
|
+
color: white;
|
|
2616
|
+
text-shadow: 0 0 3px black, 0 0 5px black;
|
|
2617
|
+
padding: 4px;
|
|
2618
|
+
font-family: 'Courier New', monospace;
|
|
2619
|
+
font-weight: bold;
|
|
2620
|
+
display: block !important;
|
|
2621
|
+
visibility: visible !important;
|
|
2622
|
+
`;
|
|
2623
|
+
const currentPosition = window.getComputedStyle(element).position;
|
|
2624
|
+
if (currentPosition === "static") {
|
|
2625
|
+
element.style.position = "relative";
|
|
2626
|
+
}
|
|
2627
|
+
element.appendChild(overlay);
|
|
2628
|
+
this.overlays.set(id, overlay);
|
|
2629
|
+
}
|
|
2630
|
+
overlay.style.backgroundColor = `rgba(255, 0, 0, ${Math.max(opacity, 0.15)})`;
|
|
2631
|
+
overlay.style.opacity = "1";
|
|
2632
|
+
overlay.textContent = `${renderCount}× ${patchType}`;
|
|
2633
|
+
if (this.config.fadeOutDuration > 0) {
|
|
2634
|
+
setTimeout(() => {
|
|
2635
|
+
if (overlay) {
|
|
2636
|
+
overlay.style.opacity = "0.2";
|
|
2637
|
+
}
|
|
2638
|
+
}, this.config.fadeOutDuration);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
reset(id) {
|
|
2643
|
+
this.renderCounts.delete(id);
|
|
2644
|
+
const overlay = this.overlays.get(id);
|
|
2645
|
+
if (overlay) {
|
|
2646
|
+
overlay.remove();
|
|
2647
|
+
this.overlays.delete(id);
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
resetAll() {
|
|
2651
|
+
this.renderCounts.clear();
|
|
2652
|
+
for (const overlay of this.overlays.values()) {
|
|
2653
|
+
overlay.remove();
|
|
2654
|
+
}
|
|
2655
|
+
this.overlays.clear();
|
|
2656
|
+
}
|
|
2657
|
+
getRenderCount(id) {
|
|
2658
|
+
return this.renderCounts.get(id) || 0;
|
|
2659
|
+
}
|
|
2660
|
+
cleanup() {
|
|
2661
|
+
for (const overlay of this.overlays.values()) {
|
|
2662
|
+
overlay.remove();
|
|
2663
|
+
}
|
|
2664
|
+
this.overlays.clear();
|
|
2665
|
+
}
|
|
2666
|
+
getStats() {
|
|
2667
|
+
const totalRerenders = Array.from(this.renderCounts.values()).reduce((sum, count) => sum + count, 0);
|
|
2668
|
+
const elementCount = this.renderCounts.size;
|
|
2669
|
+
const avgRerenders = elementCount > 0 ? totalRerenders / elementCount : 0;
|
|
2670
|
+
return {
|
|
2671
|
+
totalRerenders,
|
|
2672
|
+
elementCount,
|
|
2673
|
+
avgRerenders: Math.round(avgRerenders * 100) / 100
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
// src/dom/renderer.ts
|
|
2679
|
+
class DOMRenderer {
|
|
2680
|
+
container;
|
|
2681
|
+
nodes = new Map;
|
|
2682
|
+
rootId = null;
|
|
2683
|
+
components;
|
|
2684
|
+
applicators;
|
|
2685
|
+
engine;
|
|
2686
|
+
currentState = {};
|
|
2687
|
+
routerContext = null;
|
|
2688
|
+
globalContext = null;
|
|
2689
|
+
componentInstances = new Map;
|
|
2690
|
+
debugTracker;
|
|
2691
|
+
constructor(container, engine, debugConfig) {
|
|
2692
|
+
this.container = container;
|
|
2693
|
+
this.engine = engine;
|
|
2694
|
+
this.components = new ComponentRegistry;
|
|
2695
|
+
this.applicators = new ApplicatorRegistry;
|
|
2696
|
+
this.debugTracker = new RerenderTracker({ ...defaultDebugConfig, ...debugConfig });
|
|
2697
|
+
this.components.register("canvas", canvasHandler);
|
|
2698
|
+
for (const [name, handler] of Object.entries(canvasApplicators)) {
|
|
2699
|
+
this.applicators.register(name, handler);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
setContext(routerContext, globalContext) {
|
|
2703
|
+
this.routerContext = routerContext;
|
|
2704
|
+
this.globalContext = globalContext;
|
|
2705
|
+
}
|
|
2706
|
+
applyPatches(patches) {
|
|
2707
|
+
for (const patch of patches) {
|
|
2708
|
+
this.applyPatch(patch);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
updateState(state) {
|
|
2712
|
+
console.log(`[Renderer] Updating state:`, state);
|
|
2713
|
+
this.currentState = state;
|
|
2714
|
+
this.interpolateAllText();
|
|
2715
|
+
}
|
|
2716
|
+
mergeComponentState(componentState) {
|
|
2717
|
+
this.currentState = { ...this.currentState, ...componentState };
|
|
2718
|
+
console.log(`[Renderer] Merged state:`, this.currentState);
|
|
2719
|
+
this.interpolateAllText();
|
|
2720
|
+
}
|
|
2721
|
+
interpolateAllText() {
|
|
2722
|
+
for (const [id, element] of this.nodes.entries()) {
|
|
2723
|
+
if (element.dataset.hypenType === "text" && element.dataset.textTemplate) {
|
|
2724
|
+
const template = element.dataset.textTemplate;
|
|
2725
|
+
const interpolated = this.interpolateText(template, this.currentState);
|
|
2726
|
+
const currentText = element.textContent;
|
|
2727
|
+
if (currentText !== interpolated) {
|
|
2728
|
+
this.debugTracker.trackRerender(id, element, "interpolate");
|
|
2729
|
+
}
|
|
2730
|
+
element.textContent = interpolated;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
interpolateText(template, state) {
|
|
2735
|
+
return template.replace(/\$\{([^}]+)\}/g, (match, path) => {
|
|
2736
|
+
try {
|
|
2737
|
+
const value = path.split(".").reduce((obj, key) => {
|
|
2738
|
+
if (key === "state")
|
|
2739
|
+
return state;
|
|
2740
|
+
return obj?.[key];
|
|
2741
|
+
}, state);
|
|
2742
|
+
return value !== undefined ? String(value) : match;
|
|
2743
|
+
} catch {
|
|
2744
|
+
return match;
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
}
|
|
2748
|
+
applyPatch(patch) {
|
|
2749
|
+
switch (patch.type) {
|
|
2750
|
+
case "create":
|
|
2751
|
+
this.onCreate(patch.id, patch.element_type, patch.props || {});
|
|
2752
|
+
break;
|
|
2753
|
+
case "setProp":
|
|
2754
|
+
this.onSetProp(patch.id, patch.name, patch.value);
|
|
2755
|
+
break;
|
|
2756
|
+
case "setText":
|
|
2757
|
+
this.onSetText(patch.id, patch.text);
|
|
2758
|
+
break;
|
|
2759
|
+
case "insert":
|
|
2760
|
+
this.onInsert(patch.parent_id, patch.id, patch.before_id);
|
|
2761
|
+
break;
|
|
2762
|
+
case "move":
|
|
2763
|
+
this.onMove(patch.parent_id, patch.id, patch.before_id);
|
|
2764
|
+
break;
|
|
2765
|
+
case "remove":
|
|
2766
|
+
this.onRemove(patch.id);
|
|
2767
|
+
break;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
onCreate(id, elementType, props) {
|
|
2771
|
+
const propsObj = props instanceof Map ? Object.fromEntries(props) : props;
|
|
2772
|
+
const element = this.components.createElement(elementType, propsObj);
|
|
2773
|
+
if (!element) {
|
|
2774
|
+
const fallback = document.createElement("div");
|
|
2775
|
+
fallback.dataset.hypenType = elementType;
|
|
2776
|
+
fallback.textContent = `Unknown component: ${elementType}`;
|
|
2777
|
+
this.nodes.set(id, fallback);
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
element.dataset.hypenType = elementType.toLowerCase();
|
|
2781
|
+
element.dataset.hypenId = id;
|
|
2782
|
+
element.__hypenEngine = this.engine;
|
|
2783
|
+
this.applicators.applyAll(element, propsObj);
|
|
2784
|
+
this.nodes.set(id, element);
|
|
2785
|
+
this.debugTracker.trackRerender(id, element, `create:${elementType}`);
|
|
2786
|
+
if (!this.rootId) {
|
|
2787
|
+
this.rootId = id;
|
|
2788
|
+
if (!this.container.contains(element)) {
|
|
2789
|
+
this.container.appendChild(element);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
onSetProp(id, name, value) {
|
|
2794
|
+
const element = this.nodes.get(id);
|
|
2795
|
+
if (!element)
|
|
2796
|
+
return;
|
|
2797
|
+
this.debugTracker.trackRerender(id, element, `setProp:${name}`);
|
|
2798
|
+
if (name === "0" || name === "text") {
|
|
2799
|
+
const elementType = element.dataset.hypenType;
|
|
2800
|
+
if (elementType === "input") {
|
|
2801
|
+
const inputEl = element;
|
|
2802
|
+
inputEl.value = String(value);
|
|
2803
|
+
console.log(`[Renderer] Updated input value: "${value}"`);
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
const nextText = String(value);
|
|
2807
|
+
element.textContent = nextText;
|
|
2808
|
+
const currentTemplate = element.dataset.textTemplate;
|
|
2809
|
+
const nextLooksLikeTemplate = nextText.includes("${");
|
|
2810
|
+
const currentLooksLikeTemplate = typeof currentTemplate === "string" && currentTemplate.includes("${");
|
|
2811
|
+
if (nextLooksLikeTemplate) {
|
|
2812
|
+
element.dataset.textTemplate = nextText;
|
|
2813
|
+
} else if (currentTemplate === undefined) {
|
|
2814
|
+
element.dataset.textTemplate = nextText;
|
|
2815
|
+
} else if (!currentLooksLikeTemplate) {
|
|
2816
|
+
element.dataset.textTemplate = nextText;
|
|
2817
|
+
}
|
|
2818
|
+
console.log(`[Renderer] Updated text content: "${value}"`);
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
this.applicators.apply(element, name, value);
|
|
2822
|
+
}
|
|
2823
|
+
onSetText(id, text) {
|
|
2824
|
+
const element = this.nodes.get(id);
|
|
2825
|
+
if (!element)
|
|
2826
|
+
return;
|
|
2827
|
+
this.debugTracker.trackRerender(id, element, "setText");
|
|
2828
|
+
element.textContent = text;
|
|
2829
|
+
}
|
|
2830
|
+
onInsert(parentId, id, beforeId) {
|
|
2831
|
+
const parent = parentId === "root" ? this.container : this.nodes.get(parentId);
|
|
2832
|
+
const child = this.nodes.get(id);
|
|
2833
|
+
console.log(`[Renderer] Inserting ${id} into ${parentId}`, {
|
|
2834
|
+
parent: parent ? `${parent.tagName}#${parent.id || "no-id"}` : "null",
|
|
2835
|
+
child: child ? `${child.tagName}#${child.id || "no-id"}` : "null",
|
|
2836
|
+
childText: child?.textContent?.substring(0, 20)
|
|
2837
|
+
});
|
|
2838
|
+
if (!parent || !child)
|
|
2839
|
+
return;
|
|
2840
|
+
if (parentId === "root") {
|
|
2841
|
+
this.rootId = id;
|
|
2842
|
+
}
|
|
2843
|
+
if (beforeId) {
|
|
2844
|
+
const before = this.nodes.get(beforeId);
|
|
2845
|
+
if (before && before.parentNode === parent) {
|
|
2846
|
+
parent.insertBefore(child, before);
|
|
2847
|
+
} else if (!parent.contains(child)) {
|
|
2848
|
+
parent.appendChild(child);
|
|
2849
|
+
}
|
|
2850
|
+
} else {
|
|
2851
|
+
if (!parent.contains(child)) {
|
|
2852
|
+
parent.appendChild(child);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
onMove(parentId, id, beforeId) {
|
|
2857
|
+
this.onInsert(parentId, id, beforeId);
|
|
2858
|
+
}
|
|
2859
|
+
onRemove(id) {
|
|
2860
|
+
const element = this.nodes.get(id);
|
|
2861
|
+
if (!element)
|
|
2862
|
+
return;
|
|
2863
|
+
if (element.parentNode) {
|
|
2864
|
+
element.parentNode.removeChild(element);
|
|
2865
|
+
}
|
|
2866
|
+
this.nodes.delete(id);
|
|
2867
|
+
if (this.rootId === id) {
|
|
2868
|
+
this.rootId = null;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
getNode(id) {
|
|
2872
|
+
return this.nodes.get(id);
|
|
2873
|
+
}
|
|
2874
|
+
clear() {
|
|
2875
|
+
this.container.innerHTML = "";
|
|
2876
|
+
this.nodes.clear();
|
|
2877
|
+
this.rootId = null;
|
|
2878
|
+
}
|
|
2879
|
+
getComponentRegistry() {
|
|
2880
|
+
return this.components;
|
|
2881
|
+
}
|
|
2882
|
+
getApplicatorRegistry() {
|
|
2883
|
+
return this.applicators;
|
|
2884
|
+
}
|
|
2885
|
+
setDebugConfig(config) {
|
|
2886
|
+
this.debugTracker.setConfig(config);
|
|
2887
|
+
}
|
|
2888
|
+
resetDebugTracking() {
|
|
2889
|
+
this.debugTracker.resetAll();
|
|
2890
|
+
}
|
|
2891
|
+
getDebugStats() {
|
|
2892
|
+
return this.debugTracker.getStats();
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
54
2895
|
|
|
55
2896
|
// src/hypen.ts
|
|
56
2897
|
import {
|
|
@@ -391,6 +3232,4 @@ export {
|
|
|
391
3232
|
Hypen
|
|
392
3233
|
};
|
|
393
3234
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
//# debugId=7427343EFC068BA764756E2164756E21
|
|
3235
|
+
//# debugId=7C7B1C60678C334D64756E2164756E21
|