sibujs 1.0.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +53 -18
  4. package/dist/build.js +17 -10
  5. package/dist/cdn.global.js +6 -6
  6. package/dist/chunk-23VV7YD3.js +107 -0
  7. package/dist/chunk-3ARAQO7B.js +398 -0
  8. package/dist/chunk-6SA3QQES.js +61 -0
  9. package/dist/chunk-7BF6TK55.js +1097 -0
  10. package/dist/chunk-B7SWRFUT.js +332 -0
  11. package/dist/chunk-BW3WT46K.js +937 -0
  12. package/dist/chunk-C6KFWOFV.js +616 -0
  13. package/dist/chunk-EVCZO745.js +365 -0
  14. package/dist/chunk-GCOK2LC3.js +282 -0
  15. package/dist/chunk-L6JRBDNS.js +60 -0
  16. package/dist/chunk-LA6KQEDU.js +712 -0
  17. package/dist/chunk-MK4ERFYL.js +2249 -0
  18. package/dist/chunk-NHUC2QWH.js +282 -0
  19. package/dist/chunk-OUZZEE4S.js +365 -0
  20. package/dist/chunk-P6W3STU4.js +2249 -0
  21. package/dist/chunk-RQGQSLQK.js +725 -0
  22. package/dist/chunk-TNQWPPE6.js +37 -0
  23. package/dist/chunk-UNXCEF6S.js +21 -0
  24. package/dist/chunk-V2XTI523.js +347 -0
  25. package/dist/chunk-VMVDTCXB.js +712 -0
  26. package/dist/chunk-WADYRCO2.js +304 -0
  27. package/dist/chunk-WILQZRO4.js +282 -0
  28. package/dist/chunk-WR5D4EGH.js +26 -0
  29. package/dist/chunk-WUHJISPP.js +298 -0
  30. package/dist/chunk-YUTWTI4B.js +654 -0
  31. package/dist/chunk-Z6POF5YC.js +975 -0
  32. package/dist/chunk-ZBJP6WFL.js +482 -0
  33. package/dist/data.cjs +1 -1
  34. package/dist/data.js +6 -6
  35. package/dist/devtools.cjs +1 -1
  36. package/dist/devtools.js +4 -4
  37. package/dist/ecosystem.cjs +46 -18
  38. package/dist/ecosystem.js +7 -7
  39. package/dist/extras.cjs +53 -19
  40. package/dist/extras.js +21 -21
  41. package/dist/index.cjs +46 -18
  42. package/dist/index.d.cts +24 -8
  43. package/dist/index.d.ts +24 -8
  44. package/dist/index.js +10 -10
  45. package/dist/motion.cjs +1 -1
  46. package/dist/motion.js +3 -3
  47. package/dist/patterns.cjs +8 -2
  48. package/dist/patterns.js +5 -5
  49. package/dist/performance.cjs +1 -1
  50. package/dist/performance.js +3 -3
  51. package/dist/plugins.cjs +46 -18
  52. package/dist/plugins.js +9 -9
  53. package/dist/ssr-3RXHP5ES.js +38 -0
  54. package/dist/ssr.cjs +46 -18
  55. package/dist/ssr.d.cts +9 -0
  56. package/dist/ssr.d.ts +9 -0
  57. package/dist/ssr.js +8 -8
  58. package/dist/ui.cjs +1 -1
  59. package/dist/ui.js +6 -6
  60. package/dist/widgets.cjs +1 -1
  61. package/dist/widgets.js +5 -5
  62. package/package.json +1 -1
@@ -0,0 +1,332 @@
1
+ import {
2
+ bindAttribute,
3
+ isUrlAttribute,
4
+ sanitizeCSSValue,
5
+ sanitizeUrl
6
+ } from "./chunk-23VV7YD3.js";
7
+ import {
8
+ track
9
+ } from "./chunk-V2XTI523.js";
10
+ import {
11
+ devWarn,
12
+ isDev
13
+ } from "./chunk-UNXCEF6S.js";
14
+
15
+ // src/core/rendering/dispose.ts
16
+ var elementDisposers = /* @__PURE__ */ new WeakMap();
17
+ var _isDev = isDev();
18
+ var activeBindingCount = 0;
19
+ function registerDisposer(node, teardown) {
20
+ let disposers = elementDisposers.get(node);
21
+ if (!disposers) {
22
+ disposers = [];
23
+ elementDisposers.set(node, disposers);
24
+ }
25
+ disposers.push(teardown);
26
+ if (_isDev) activeBindingCount++;
27
+ }
28
+ function dispose(node) {
29
+ const stack = [node];
30
+ const order = [];
31
+ while (stack.length > 0) {
32
+ const current = stack.pop();
33
+ order.push(current);
34
+ const children = current.childNodes;
35
+ for (let i = 0; i < children.length; i++) {
36
+ stack.push(children[i]);
37
+ }
38
+ }
39
+ for (let i = order.length - 1; i >= 0; i--) {
40
+ const current = order[i];
41
+ const disposers = elementDisposers.get(current);
42
+ if (disposers) {
43
+ if (_isDev) activeBindingCount -= disposers.length;
44
+ for (const d of disposers) d();
45
+ elementDisposers.delete(current);
46
+ }
47
+ }
48
+ }
49
+ function checkLeaks(warnThreshold = 0) {
50
+ if (!_isDev) return 0;
51
+ if (warnThreshold > 0 && activeBindingCount > warnThreshold) {
52
+ devWarn(
53
+ `checkLeaks: ${activeBindingCount} active DOM bindings detected. Expected \u2264${warnThreshold}. This may indicate a component was removed from the DOM without calling dispose().`
54
+ );
55
+ }
56
+ return activeBindingCount;
57
+ }
58
+
59
+ // src/reactivity/bindChildNode.ts
60
+ var _isDev2 = isDev();
61
+ function bindChildNode(placeholder, getter) {
62
+ let lastNodes = [];
63
+ function commit() {
64
+ let result;
65
+ try {
66
+ result = getter();
67
+ } catch (err) {
68
+ if (_isDev2) devWarn(`bindChildNode: getter threw: ${err instanceof Error ? err.message : String(err)}`);
69
+ return;
70
+ }
71
+ if (result == null || typeof result === "boolean") {
72
+ for (let i = 0; i < lastNodes.length; i++) {
73
+ const node = lastNodes[i];
74
+ if (node.parentNode) node.parentNode.removeChild(node);
75
+ }
76
+ lastNodes.length = 0;
77
+ return;
78
+ }
79
+ const parent = placeholder.parentNode;
80
+ if (!parent) {
81
+ lastNodes.length = 0;
82
+ return;
83
+ }
84
+ let newNodes;
85
+ if (Array.isArray(result)) {
86
+ newNodes = [];
87
+ for (let i = 0; i < result.length; i++) {
88
+ const item = result[i];
89
+ if (item == null || typeof item === "boolean") continue;
90
+ newNodes.push(item instanceof Node ? item : document.createTextNode(String(item)));
91
+ }
92
+ } else {
93
+ const node = result instanceof Node ? result : document.createTextNode(String(result));
94
+ newNodes = [node];
95
+ }
96
+ const reused = lastNodes.length > 0 && newNodes.length > 0 ? /* @__PURE__ */ new Set() : void 0;
97
+ if (reused) {
98
+ for (let i = 0; i < newNodes.length; i++) {
99
+ for (let j = 0; j < lastNodes.length; j++) {
100
+ if (newNodes[i] === lastNodes[j]) {
101
+ reused.add(newNodes[i]);
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ for (let i = 0; i < lastNodes.length; i++) {
108
+ const node = lastNodes[i];
109
+ if (reused?.has(node)) continue;
110
+ if (node.parentNode) node.parentNode.removeChild(node);
111
+ }
112
+ const anchor = placeholder.nextSibling;
113
+ for (let i = 0; i < newNodes.length; i++) {
114
+ const node = newNodes[i];
115
+ if (reused?.has(node) && node.parentNode === parent) {
116
+ if (node.nextSibling !== anchor) {
117
+ parent.insertBefore(node, anchor);
118
+ }
119
+ } else {
120
+ parent.insertBefore(node, anchor);
121
+ }
122
+ }
123
+ lastNodes = newNodes;
124
+ }
125
+ return track(commit);
126
+ }
127
+
128
+ // src/core/rendering/tagFactory.ts
129
+ var SVG_NS = "http://www.w3.org/2000/svg";
130
+ var kebabCache = /* @__PURE__ */ new Map();
131
+ function toKebab(prop) {
132
+ let cached = kebabCache.get(prop);
133
+ if (cached !== void 0) return cached;
134
+ cached = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
135
+ kebabCache.set(prop, cached);
136
+ return cached;
137
+ }
138
+ function applyStyle(el, style) {
139
+ if (typeof style === "function") {
140
+ const teardown = track(() => {
141
+ el.setAttribute("style", style());
142
+ });
143
+ registerDisposer(el, teardown);
144
+ return;
145
+ }
146
+ if (typeof style === "string") {
147
+ el.setAttribute("style", style);
148
+ return;
149
+ }
150
+ const htmlEl = el;
151
+ for (const prop in style) {
152
+ const val = style[prop];
153
+ const name = toKebab(prop);
154
+ if (typeof val === "function") {
155
+ const getter = val;
156
+ const teardown = track(() => {
157
+ htmlEl.style.setProperty(name, sanitizeCSSValue(String(getter())));
158
+ });
159
+ registerDisposer(el, teardown);
160
+ } else {
161
+ htmlEl.style.setProperty(name, sanitizeCSSValue(String(val)));
162
+ }
163
+ }
164
+ }
165
+ function applyClass(el, cls) {
166
+ if (typeof cls === "string") {
167
+ el.setAttribute("class", cls);
168
+ return;
169
+ }
170
+ if (typeof cls === "function") {
171
+ const teardown = track(() => {
172
+ el.setAttribute("class", cls());
173
+ });
174
+ registerDisposer(el, teardown);
175
+ return;
176
+ }
177
+ const obj = cls;
178
+ let hasReactive = false;
179
+ let result = "";
180
+ for (const name in obj) {
181
+ const val = obj[name];
182
+ if (typeof val === "function") {
183
+ hasReactive = true;
184
+ break;
185
+ }
186
+ if (val) result = result ? `${result} ${name}` : name;
187
+ }
188
+ if (hasReactive) {
189
+ const update = () => {
190
+ let r = "";
191
+ for (const name in obj) {
192
+ const val = obj[name];
193
+ const active = typeof val === "function" ? val() : val;
194
+ if (active) r = r ? `${r} ${name}` : name;
195
+ }
196
+ el.setAttribute("class", r);
197
+ };
198
+ const teardown = track(update);
199
+ registerDisposer(el, teardown);
200
+ } else {
201
+ el.setAttribute("class", result);
202
+ }
203
+ }
204
+ function appendChildren(el, nodes) {
205
+ if (typeof nodes === "string") {
206
+ el.textContent = nodes;
207
+ return;
208
+ }
209
+ if (typeof nodes === "number") {
210
+ el.textContent = String(nodes);
211
+ return;
212
+ }
213
+ if (typeof nodes === "boolean" || nodes == null) {
214
+ return;
215
+ }
216
+ if (typeof nodes === "function") {
217
+ const ph = document.createComment("");
218
+ el.appendChild(ph);
219
+ registerDisposer(el, bindChildNode(ph, nodes));
220
+ return;
221
+ }
222
+ if (nodes instanceof Node) {
223
+ el.appendChild(nodes);
224
+ return;
225
+ }
226
+ if (Array.isArray(nodes)) {
227
+ for (let i = 0; i < nodes.length; i++) {
228
+ const c = nodes[i];
229
+ if (typeof c === "function") {
230
+ const ph = document.createComment("");
231
+ el.appendChild(ph);
232
+ registerDisposer(el, bindChildNode(ph, c));
233
+ } else if (c instanceof Node) {
234
+ el.appendChild(c);
235
+ } else if (Array.isArray(c)) {
236
+ for (let j = 0; j < c.length; j++) {
237
+ const inner = c[j];
238
+ if (typeof inner === "function") {
239
+ const ph = document.createComment("");
240
+ el.appendChild(ph);
241
+ registerDisposer(el, bindChildNode(ph, inner));
242
+ } else if (inner instanceof Node) {
243
+ el.appendChild(inner);
244
+ } else if (inner != null && typeof inner !== "boolean") {
245
+ el.appendChild(document.createTextNode(String(inner)));
246
+ }
247
+ }
248
+ } else if (c != null && typeof c !== "boolean") {
249
+ el.appendChild(document.createTextNode(String(c)));
250
+ }
251
+ }
252
+ }
253
+ }
254
+ var tagFactory = (tag, ns) => (first, second) => {
255
+ const el = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
256
+ if (first === void 0) return el;
257
+ if (second === void 0 && typeof first === "string") {
258
+ el.textContent = first;
259
+ return el;
260
+ }
261
+ if (second !== void 0) {
262
+ el.setAttribute("class", first);
263
+ appendChildren(el, second);
264
+ return el;
265
+ }
266
+ if (Array.isArray(first) || first instanceof Node) {
267
+ appendChildren(el, first);
268
+ return el;
269
+ }
270
+ const props = first;
271
+ const pClass = props.class;
272
+ if (pClass != null) applyClass(el, pClass);
273
+ const pId = props.id;
274
+ if (pId != null) el.id = pId;
275
+ const pNodes = props.nodes;
276
+ if (pNodes != null) appendChildren(el, pNodes);
277
+ const pOn = props.on;
278
+ if (pOn) {
279
+ for (const ev in pOn) {
280
+ el.addEventListener(ev, pOn[ev]);
281
+ }
282
+ }
283
+ const pStyle = props.style;
284
+ if (pStyle != null) applyStyle(el, pStyle);
285
+ const pRef = props.ref;
286
+ if (pRef) pRef.current = el;
287
+ for (const key in props) {
288
+ switch (key) {
289
+ case "class":
290
+ case "id":
291
+ case "nodes":
292
+ case "on":
293
+ case "style":
294
+ case "ref":
295
+ case "onElement":
296
+ continue;
297
+ // already handled above / below
298
+ default: {
299
+ const value = props[key];
300
+ if (value == null) continue;
301
+ if (key[0] === "o" && key[1] === "n") continue;
302
+ if (typeof value === "function") {
303
+ registerDisposer(el, bindAttribute(el, key, value));
304
+ } else if (typeof value === "boolean") {
305
+ if (key in el && (key === "checked" || key === "disabled" || key === "selected")) {
306
+ el[key] = value;
307
+ } else if (value) {
308
+ el.setAttribute(key, "");
309
+ } else {
310
+ el.removeAttribute(key);
311
+ }
312
+ } else {
313
+ const str = String(value);
314
+ el.setAttribute(key, isUrlAttribute(key) ? sanitizeUrl(str) : str);
315
+ }
316
+ }
317
+ }
318
+ }
319
+ if (props.onElement && typeof props.onElement === "function") {
320
+ props.onElement(el);
321
+ }
322
+ return el;
323
+ };
324
+
325
+ export {
326
+ bindChildNode,
327
+ registerDisposer,
328
+ dispose,
329
+ checkLeaks,
330
+ SVG_NS,
331
+ tagFactory
332
+ };