sibujs 4.1.0 → 4.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.
- package/README.md +24 -0
- package/dist/browser.cjs +13 -21
- package/dist/browser.js +6 -6
- package/dist/build.cjs +278 -104
- package/dist/build.js +15 -15
- package/dist/cdn.dev.global.js +398 -0
- package/dist/cdn.global.js +10 -10
- package/dist/{chunk-DCDS2PQ6.js → chunk-2LOYNGBY.js} +2 -2
- package/dist/{chunk-VPP2FONR.js → chunk-2WLZ6757.js} +17 -10
- package/dist/{chunk-IM7N5WR4.js → chunk-3VTSPNC5.js} +2 -2
- package/dist/{chunk-TIRZCERI.js → chunk-5DXA2J44.js} +1 -1
- package/dist/{chunk-I3VI34DP.js → chunk-6ZGI3RBE.js} +149 -33
- package/dist/{chunk-D3SZ4LVS.js → chunk-7ALC7KGE.js} +5 -6
- package/dist/{chunk-PFTDGEPZ.js → chunk-7VEC3UD2.js} +3 -3
- package/dist/{chunk-KSOEJGFO.js → chunk-BMYYZWHX.js} +3 -3
- package/dist/{chunk-LOFZHP6V.js → chunk-BNKV4REK.js} +7 -8
- package/dist/{chunk-5GJ5RTHA.js → chunk-FOWBJZDL.js} +7 -8
- package/dist/{chunk-FB7KQXZI.js → chunk-GDUNQCCW.js} +4 -4
- package/dist/{chunk-UFSQEO7P.js → chunk-HECVW343.js} +7 -8
- package/dist/{chunk-SHDVWATN.js → chunk-HJEPKZ2O.js} +7 -8
- package/dist/{chunk-ANGSYNPX.js → chunk-HZEBO22J.js} +57 -37
- package/dist/{chunk-5INI7D2L.js → chunk-IXKSNWV5.js} +74 -11
- package/dist/{chunk-DAKLOMKS.js → chunk-KE4KWRDY.js} +3 -3
- package/dist/{chunk-AW6HPJ3L.js → chunk-KKLW7YWL.js} +1 -1
- package/dist/{chunk-BMSN6NWQ.js → chunk-NEYWS4EX.js} +6 -6
- package/dist/{chunk-HYCCIYNS.js → chunk-NIOYEGBQ.js} +13 -14
- package/dist/{chunk-4U7KD3RY.js → chunk-OUWAIXIK.js} +3 -3
- package/dist/{chunk-MRAMKDHQ.js → chunk-P3DHXBR6.js} +1 -1
- package/dist/{chunk-FMHIQNMP.js → chunk-QCFLDD7C.js} +5 -5
- package/dist/{chunk-DHDZ7IVN.js → chunk-QKRPLZ2V.js} +7 -8
- package/dist/{chunk-4RH6D7GR.js → chunk-QL4UREZO.js} +6 -6
- package/dist/{chunk-XIHMS2Y6.js → chunk-SF3TB4K6.js} +8 -8
- package/dist/{chunk-XSZRJW76.js → chunk-XZ2N525U.js} +6 -6
- package/dist/{customElement-CKLoO63w.d.ts → customElement-CNZxEB9G.d.cts} +77 -0
- package/dist/{customElement-CKLoO63w.d.cts → customElement-CNZxEB9G.d.ts} +77 -0
- package/dist/data.cjs +15 -24
- package/dist/data.js +9 -9
- package/dist/devtools.cjs +18 -22
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +8 -8
- package/dist/{dispose-4FZ6OFXR.js → dispose-46BOMMQJ.js} +2 -2
- package/dist/ecosystem.cjs +222 -67
- package/dist/ecosystem.js +11 -11
- package/dist/extras.cjs +243 -86
- package/dist/extras.d.cts +2 -2
- package/dist/extras.d.ts +2 -2
- package/dist/extras.js +25 -25
- package/dist/index.cjs +272 -98
- package/dist/index.d.cts +154 -33
- package/dist/index.d.ts +154 -33
- package/dist/index.js +15 -15
- package/dist/{introspect-RjLfIFpL.d.cts → introspect-D5xF-0Es.d.cts} +7 -0
- package/dist/{introspect-DOZfmC-4.d.ts → introspect-rSBIxEQi.d.ts} +7 -0
- package/dist/motion.cjs +13 -22
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +16 -24
- package/dist/patterns.d.cts +8 -0
- package/dist/patterns.d.ts +8 -0
- package/dist/patterns.js +7 -7
- package/dist/performance.cjs +16 -27
- package/dist/performance.js +9 -9
- package/dist/plugins.cjs +260 -86
- package/dist/plugins.d.cts +92 -0
- package/dist/plugins.d.ts +92 -0
- package/dist/plugins.js +18 -17
- package/dist/{ssr-JFP5535P.js → ssr-Y7XOEPEN.js} +5 -5
- package/dist/ssr.cjs +233 -79
- package/dist/ssr.js +12 -12
- package/dist/testing.cjs +11 -19
- package/dist/testing.js +5 -5
- package/dist/ui.cjs +98 -43
- package/dist/ui.d.cts +7 -1
- package/dist/ui.d.ts +7 -1
- package/dist/ui.js +10 -10
- package/dist/widgets.cjs +13 -21
- package/dist/widgets.d.cts +8 -0
- package/dist/widgets.d.ts +8 -0
- package/dist/widgets.js +9 -9
- package/package.json +5 -2
|
@@ -1,27 +1,121 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bindAttribute,
|
|
3
3
|
setSafeAttribute
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HJEPKZ2O.js";
|
|
5
5
|
import {
|
|
6
6
|
isEventHandlerAttr,
|
|
7
7
|
sanitizeCSSValue,
|
|
8
8
|
sanitizeStyleAttribute
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IXKSNWV5.js";
|
|
10
10
|
import {
|
|
11
11
|
dispose,
|
|
12
12
|
registerDisposer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QKRPLZ2V.js";
|
|
14
14
|
import {
|
|
15
15
|
reactiveBinding
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-7ALC7KGE.js";
|
|
17
17
|
import {
|
|
18
|
+
DEV,
|
|
18
19
|
devWarn,
|
|
19
|
-
|
|
20
|
+
devWarnLazy,
|
|
20
21
|
reportError
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-2WLZ6757.js";
|
|
23
|
+
|
|
24
|
+
// src/core/rendering/focusPreservation.ts
|
|
25
|
+
var IDENTITY_ATTRS = ["data-focus-key", "id", "name"];
|
|
26
|
+
var SELECTABLE_TYPES = /* @__PURE__ */ new Set(["text", "search", "url", "tel", "password", ""]);
|
|
27
|
+
function selectionOf(el) {
|
|
28
|
+
const tag = el.tagName;
|
|
29
|
+
const selectable = tag === "TEXTAREA" || tag === "INPUT" && SELECTABLE_TYPES.has(el.type.toLowerCase());
|
|
30
|
+
if (!selectable) return { start: null, end: null, direction: null };
|
|
31
|
+
const field = el;
|
|
32
|
+
return { start: field.selectionStart, end: field.selectionEnd, direction: field.selectionDirection };
|
|
33
|
+
}
|
|
34
|
+
function captureFocusWithin(nodes) {
|
|
35
|
+
if (nodes.length === 0 || typeof document === "undefined") return null;
|
|
36
|
+
const active = document.activeElement;
|
|
37
|
+
if (!active || active === document.body) return null;
|
|
38
|
+
let inside = false;
|
|
39
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
40
|
+
const n = nodes[i];
|
|
41
|
+
if (n === active || n.nodeType === 1 && n.contains(active)) {
|
|
42
|
+
inside = true;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!inside) return null;
|
|
47
|
+
let attr = null;
|
|
48
|
+
let value = null;
|
|
49
|
+
for (let i = 0; i < IDENTITY_ATTRS.length; i++) {
|
|
50
|
+
const candidate = active.getAttribute(IDENTITY_ATTRS[i]);
|
|
51
|
+
if (candidate) {
|
|
52
|
+
attr = IDENTITY_ATTRS[i];
|
|
53
|
+
value = candidate;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { el: active, attr, value, tag: active.tagName, ...selectionOf(active) };
|
|
58
|
+
}
|
|
59
|
+
function quote(value) {
|
|
60
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
61
|
+
}
|
|
62
|
+
function findUniqueByIdentity(nodes, selector) {
|
|
63
|
+
let el = null;
|
|
64
|
+
let count = 0;
|
|
65
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
66
|
+
const n = nodes[i];
|
|
67
|
+
if (n.nodeType !== 1) continue;
|
|
68
|
+
const root = n;
|
|
69
|
+
if (root.matches(selector)) {
|
|
70
|
+
count++;
|
|
71
|
+
el ?? (el = root);
|
|
72
|
+
}
|
|
73
|
+
const inner = root.querySelectorAll(selector);
|
|
74
|
+
for (let j = 0; j < inner.length; j++) {
|
|
75
|
+
count++;
|
|
76
|
+
el ?? (el = inner[j]);
|
|
77
|
+
}
|
|
78
|
+
if (count > 1) return { el: null, count };
|
|
79
|
+
}
|
|
80
|
+
return count === 1 ? { el, count } : { el: null, count };
|
|
81
|
+
}
|
|
82
|
+
function refocus(el, snapshot) {
|
|
83
|
+
el.focus();
|
|
84
|
+
if (snapshot.start !== null && typeof el.setSelectionRange === "function") {
|
|
85
|
+
const field = el;
|
|
86
|
+
const max = field.value.length;
|
|
87
|
+
const start = Math.min(snapshot.start, max);
|
|
88
|
+
const end = Math.min(snapshot.end ?? start, max);
|
|
89
|
+
field.setSelectionRange(start, end, snapshot.direction ?? "none");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function restoreFocusWithin(snapshot, nodes, where) {
|
|
93
|
+
if (!snapshot) return;
|
|
94
|
+
if (typeof document === "undefined") return;
|
|
95
|
+
const active = document.activeElement;
|
|
96
|
+
if (active === snapshot.el) return;
|
|
97
|
+
if (active && active !== document.body && active !== document.documentElement) return;
|
|
98
|
+
if (snapshot.el.isConnected) {
|
|
99
|
+
refocus(snapshot.el, snapshot);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let ambiguous = false;
|
|
103
|
+
if (snapshot.attr && snapshot.value) {
|
|
104
|
+
const { el: replacement, count } = findUniqueByIdentity(nodes, `[${snapshot.attr}=${quote(snapshot.value)}]`);
|
|
105
|
+
if (replacement && replacement.tagName === snapshot.tag) {
|
|
106
|
+
refocus(replacement, snapshot);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
ambiguous = count > 1;
|
|
110
|
+
}
|
|
111
|
+
devWarnLazy(() => {
|
|
112
|
+
const id = snapshot.attr ? ` (${snapshot.attr}="${snapshot.value}")` : "";
|
|
113
|
+
const why = ambiguous ? `several elements in the rebuilt subtree share ${snapshot.attr}="${snapshot.value}", so there is no way to tell which one the user was in \u2014 a shared name (a radio group) identifies a GROUP, not a control. Add a unique id or data-focus-key to each` : "no element in the rebuilt subtree carries the same identity. Give it a stable id, name, or data-focus-key that the rebuild reproduces";
|
|
114
|
+
return `${where}: a reactive rebuild discarded the focused element <${snapshot.tag.toLowerCase()}>${id} and could not re-establish it, so focus fell back to <body>. An in-progress edit ends here, and an in-progress IME composition is lost outright \u2014 a composition belongs to the DOM node, so it cannot survive the node being destroyed. ${why}, or stop the rebuild from happening: key the subtree with match(() => shapeKey(), { \u2026 }) so it is re-created only when the shape actually changes, and drive the rest with reactive attributes and text children, which mutate nodes in place instead of replacing them.`;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
22
117
|
|
|
23
118
|
// src/reactivity/bindChildNode.ts
|
|
24
|
-
var _isDev = isDev();
|
|
25
119
|
function bindChildNode(placeholder, getter) {
|
|
26
120
|
let lastNodes = [];
|
|
27
121
|
function commit() {
|
|
@@ -32,6 +126,7 @@ function bindChildNode(placeholder, getter) {
|
|
|
32
126
|
reportError(err, { phase: "binding", name: "bindChildNode", node: placeholder });
|
|
33
127
|
return;
|
|
34
128
|
}
|
|
129
|
+
const focused = captureFocusWithin(lastNodes);
|
|
35
130
|
if (result == null || typeof result === "boolean") {
|
|
36
131
|
for (let i = 0; i < lastNodes.length; i++) {
|
|
37
132
|
const node = lastNodes[i];
|
|
@@ -39,6 +134,7 @@ function bindChildNode(placeholder, getter) {
|
|
|
39
134
|
if (node.parentNode) node.parentNode.removeChild(node);
|
|
40
135
|
}
|
|
41
136
|
lastNodes.length = 0;
|
|
137
|
+
restoreFocusWithin(focused, lastNodes, "bindChildNode");
|
|
42
138
|
return;
|
|
43
139
|
}
|
|
44
140
|
const parent = placeholder.parentNode;
|
|
@@ -55,8 +151,7 @@ function bindChildNode(placeholder, getter) {
|
|
|
55
151
|
if (item == null || typeof item === "boolean") continue;
|
|
56
152
|
const node = item instanceof Node ? item : document.createTextNode(String(item));
|
|
57
153
|
if (seen.has(node)) {
|
|
58
|
-
if (
|
|
59
|
-
devWarn("bindChildNode: duplicate node reference in array \u2014 only the first occurrence is rendered.");
|
|
154
|
+
if (DEV) devWarn("bindChildNode: duplicate node reference in array \u2014 only the first occurrence is rendered.");
|
|
60
155
|
continue;
|
|
61
156
|
}
|
|
62
157
|
seen.add(node);
|
|
@@ -89,13 +184,13 @@ function bindChildNode(placeholder, getter) {
|
|
|
89
184
|
prev = node;
|
|
90
185
|
}
|
|
91
186
|
lastNodes = newNodes;
|
|
187
|
+
restoreFocusWithin(focused, newNodes, "bindChildNode");
|
|
92
188
|
}
|
|
93
189
|
return reactiveBinding(commit, placeholder);
|
|
94
190
|
}
|
|
95
191
|
|
|
96
192
|
// src/core/rendering/tagFactory.ts
|
|
97
193
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
98
|
-
var _isDev2 = isDev();
|
|
99
194
|
var BLOCKED_TAGS = /* @__PURE__ */ new Set(["script", "iframe", "object", "embed", "frame", "frameset"]);
|
|
100
195
|
function isBlockedTag(tag) {
|
|
101
196
|
return BLOCKED_TAGS.has(tag.toLowerCase());
|
|
@@ -113,18 +208,9 @@ var CLOBBER_RISKY_IDS = /* @__PURE__ */ new Set([
|
|
|
113
208
|
"self",
|
|
114
209
|
"frames"
|
|
115
210
|
]);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const tokens = t.split(/\s+/);
|
|
120
|
-
let sawClassish = false;
|
|
121
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
122
|
-
const tok = tokens[i];
|
|
123
|
-
if (!/^-?[A-Za-z_][A-Za-z0-9_:/.-]*$/.test(tok)) return false;
|
|
124
|
-
if (/[-:/0-9]/.test(tok)) sawClassish = true;
|
|
125
|
-
}
|
|
126
|
-
return sawClassish;
|
|
127
|
-
}
|
|
211
|
+
var warnedLoneStrings = /* @__PURE__ */ new Set();
|
|
212
|
+
var MAX_WARNED_LONE_STRINGS = 100;
|
|
213
|
+
var loneStringCapAnnounced = false;
|
|
128
214
|
var kebabCache = /* @__PURE__ */ new Map();
|
|
129
215
|
function toKebab(prop) {
|
|
130
216
|
let cached = kebabCache.get(prop);
|
|
@@ -136,13 +222,13 @@ function toKebab(prop) {
|
|
|
136
222
|
function applyStyle(el, style) {
|
|
137
223
|
if (typeof style === "function") {
|
|
138
224
|
const teardown = reactiveBinding(() => {
|
|
139
|
-
el.setAttribute("style", sanitizeStyleAttribute(String(style())));
|
|
225
|
+
el.setAttribute("style", sanitizeStyleAttribute(String(style()), { element: el }));
|
|
140
226
|
}, el);
|
|
141
227
|
registerDisposer(el, teardown);
|
|
142
228
|
return;
|
|
143
229
|
}
|
|
144
230
|
if (typeof style === "string") {
|
|
145
|
-
el.setAttribute("style", sanitizeStyleAttribute(style));
|
|
231
|
+
el.setAttribute("style", sanitizeStyleAttribute(style, { element: el }));
|
|
146
232
|
return;
|
|
147
233
|
}
|
|
148
234
|
const htmlEl = el;
|
|
@@ -152,14 +238,26 @@ function applyStyle(el, style) {
|
|
|
152
238
|
if (typeof val === "function") {
|
|
153
239
|
const getter = val;
|
|
154
240
|
const teardown = reactiveBinding(() => {
|
|
155
|
-
htmlEl.style.setProperty(name, sanitizeCSSValue(String(getter())));
|
|
241
|
+
htmlEl.style.setProperty(name, sanitizeCSSValue(String(getter()), { property: name, element: el }));
|
|
156
242
|
}, el);
|
|
157
243
|
registerDisposer(el, teardown);
|
|
158
244
|
} else {
|
|
159
|
-
htmlEl.style.setProperty(name, sanitizeCSSValue(String(val)));
|
|
245
|
+
htmlEl.style.setProperty(name, sanitizeCSSValue(String(val), { property: name, element: el }));
|
|
160
246
|
}
|
|
161
247
|
}
|
|
162
248
|
}
|
|
249
|
+
function resolveClassValue(cls) {
|
|
250
|
+
if (typeof cls === "string") return cls;
|
|
251
|
+
if (typeof cls === "function") return cls();
|
|
252
|
+
if (!cls) return "";
|
|
253
|
+
let out = "";
|
|
254
|
+
for (const name in cls) {
|
|
255
|
+
const val = cls[name];
|
|
256
|
+
const active = typeof val === "function" ? val() : val;
|
|
257
|
+
if (active) out = out ? `${out} ${name}` : name;
|
|
258
|
+
}
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
163
261
|
function applyClass(el, cls) {
|
|
164
262
|
if (typeof cls === "string") {
|
|
165
263
|
el.setAttribute("class", cls);
|
|
@@ -263,11 +361,26 @@ var tagFactory = (tag, ns) => {
|
|
|
263
361
|
appendChildren(el, second);
|
|
264
362
|
return el;
|
|
265
363
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
364
|
+
devWarnLazy(() => {
|
|
365
|
+
const tokens = first.trim().split(/\s+/);
|
|
366
|
+
if (tokens.length < 2) return "";
|
|
367
|
+
let utilityTokens = 0;
|
|
368
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
369
|
+
const tok = tokens[i];
|
|
370
|
+
if (!/^-?[A-Za-z_][A-Za-z0-9_:/.-]*$/.test(tok)) return "";
|
|
371
|
+
if (/[-:/0-9]/.test(tok)) utilityTokens++;
|
|
372
|
+
}
|
|
373
|
+
if (utilityTokens < 2) return "";
|
|
374
|
+
const key = `${tag}|${first}`;
|
|
375
|
+
if (warnedLoneStrings.has(key)) return "";
|
|
376
|
+
if (warnedLoneStrings.size >= MAX_WARNED_LONE_STRINGS) {
|
|
377
|
+
if (loneStringCapAnnounced) return "";
|
|
378
|
+
loneStringCapAnnounced = true;
|
|
379
|
+
return `tagFactory: ${MAX_WARNED_LONE_STRINGS} distinct lone-string class warnings have been reported; suppressing further ones for the rest of this session so they cannot flood the console. Fix the reported ones and reload to see any that remain.`;
|
|
380
|
+
}
|
|
381
|
+
warnedLoneStrings.add(key);
|
|
382
|
+
return `tagFactory: lone string "${first}" looks like a class list but is being rendered as TEXT. For a class, use ${tag}({ class: "${first}" }) \u2014 or ${tag}("${first}", children) to set the class AND add children.`;
|
|
383
|
+
});
|
|
271
384
|
el.textContent = first;
|
|
272
385
|
return el;
|
|
273
386
|
}
|
|
@@ -284,7 +397,7 @@ var tagFactory = (tag, ns) => {
|
|
|
284
397
|
if (pClass != null) applyClass(el, pClass);
|
|
285
398
|
const pId = props.id;
|
|
286
399
|
if (pId != null) {
|
|
287
|
-
if (
|
|
400
|
+
if (DEV && typeof pId === "string" && CLOBBER_RISKY_IDS.has(pId.toLowerCase())) {
|
|
288
401
|
devWarn(
|
|
289
402
|
`tagFactory: element id="${pId}" matches a common global and may cause DOM clobbering. Avoid setting ids from untrusted input.`
|
|
290
403
|
);
|
|
@@ -299,7 +412,7 @@ var tagFactory = (tag, ns) => {
|
|
|
299
412
|
const handler = pOn[ev];
|
|
300
413
|
if (typeof handler === "function") {
|
|
301
414
|
el.addEventListener(ev, handler);
|
|
302
|
-
} else if (
|
|
415
|
+
} else if (DEV) {
|
|
303
416
|
devWarn(
|
|
304
417
|
`tagFactory: on.${ev} handler is not a function (got ${typeof handler}). Event listener was not attached.`
|
|
305
418
|
);
|
|
@@ -341,7 +454,10 @@ var tagFactory = (tag, ns) => {
|
|
|
341
454
|
};
|
|
342
455
|
|
|
343
456
|
export {
|
|
457
|
+
captureFocusWithin,
|
|
458
|
+
restoreFocusWithin,
|
|
344
459
|
bindChildNode,
|
|
345
460
|
SVG_NS,
|
|
461
|
+
resolveClassValue,
|
|
346
462
|
tagFactory
|
|
347
463
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEV,
|
|
2
3
|
devWarn,
|
|
3
|
-
isDev,
|
|
4
4
|
reportError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2WLZ6757.js";
|
|
6
6
|
|
|
7
7
|
// src/reactivity/track-core.ts
|
|
8
8
|
var POOL_MAX = 4096;
|
|
@@ -460,17 +460,16 @@ function forEachSubscriber(signal, visit) {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
// src/reactivity/track.ts
|
|
463
|
-
var
|
|
464
|
-
var _runtimeVersion = true ? "4.1.0" : "dev";
|
|
463
|
+
var _runtimeVersion = true ? "4.2.0" : "dev";
|
|
465
464
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
466
465
|
function resolveReactiveApi() {
|
|
467
466
|
const g = globalThis;
|
|
468
467
|
const existing = g[REGISTRY_KEY];
|
|
469
468
|
if (existing) {
|
|
470
|
-
if (
|
|
469
|
+
if (DEV && !existing.__dupWarned) {
|
|
471
470
|
existing.__dupWarned = true;
|
|
472
471
|
devWarn(
|
|
473
|
-
`Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity
|
|
472
|
+
`Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity is NOT broken and no bundler configuration is required: every copy routes through the first one via a global registry, so signal writes still reach subscribers registered by any copy. This is only a SIZE issue \u2014 the duplicate copy's bytes are downloaded and parsed for nothing. If you want them back, de-duplicate sibujs in your bundler (Vite: resolve.dedupe: ['sibujs']). Mismatched VERSIONS above are worth fixing regardless, since only the first one loaded is used.`
|
|
474
473
|
);
|
|
475
474
|
}
|
|
476
475
|
return existing;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5DXA2J44.js";
|
|
4
4
|
import {
|
|
5
5
|
cleanup,
|
|
6
6
|
retrack,
|
|
7
7
|
untracked
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7ALC7KGE.js";
|
|
9
9
|
import {
|
|
10
10
|
devAssert,
|
|
11
11
|
reportError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-2WLZ6757.js";
|
|
13
13
|
|
|
14
14
|
// src/core/signals/effect.ts
|
|
15
15
|
var _g = globalThis;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5DXA2J44.js";
|
|
4
4
|
import {
|
|
5
5
|
resumeTracking,
|
|
6
6
|
suspendTracking,
|
|
7
7
|
track
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7ALC7KGE.js";
|
|
9
9
|
import {
|
|
10
10
|
devAssert
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2WLZ6757.js";
|
|
12
12
|
|
|
13
13
|
// src/core/signals/watch.ts
|
|
14
14
|
function watch(getter, callback) {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sanitizeUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IXKSNWV5.js";
|
|
4
4
|
import {
|
|
5
5
|
globalSingleton
|
|
6
6
|
} from "./chunk-7ZHH77QA.js";
|
|
7
7
|
import {
|
|
8
8
|
effect
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7VEC3UD2.js";
|
|
10
10
|
import {
|
|
11
11
|
dispose,
|
|
12
12
|
replaceChildrenSafely
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QKRPLZ2V.js";
|
|
14
14
|
import {
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HECVW343.js";
|
|
17
17
|
import {
|
|
18
|
+
DEV,
|
|
18
19
|
devWarn,
|
|
19
|
-
isDev,
|
|
20
20
|
reportError
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2WLZ6757.js";
|
|
22
22
|
|
|
23
23
|
// src/performance/scheduler.ts
|
|
24
24
|
var Priority = {
|
|
@@ -228,7 +228,6 @@ function uniqueId(suffix) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// src/performance/domRecycler.ts
|
|
231
|
-
var _isDev = isDev();
|
|
232
231
|
var DOMPool = class {
|
|
233
232
|
constructor(maxSize = 50) {
|
|
234
233
|
this.pools = /* @__PURE__ */ new Map();
|
|
@@ -255,7 +254,7 @@ var DOMPool = class {
|
|
|
255
254
|
* is almost certainly a bug.
|
|
256
255
|
*/
|
|
257
256
|
release(element) {
|
|
258
|
-
if (
|
|
257
|
+
if (DEV && element.isConnected) {
|
|
259
258
|
devWarn(
|
|
260
259
|
"DOMPool.release() called on a still-connected element. Detach it from the DOM first (remove() / dispose())."
|
|
261
260
|
);
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5DXA2J44.js";
|
|
4
4
|
import {
|
|
5
5
|
signal
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HECVW343.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
8
|
+
DEV,
|
|
9
|
+
devWarn
|
|
10
|
+
} from "./chunk-2WLZ6757.js";
|
|
11
11
|
|
|
12
12
|
// src/core/rendering/context.ts
|
|
13
|
-
var _isDev = isDev();
|
|
14
13
|
function context(defaultValue) {
|
|
15
14
|
const [getValue, setValue] = signal(defaultValue);
|
|
16
15
|
const warnIfSSR = (method) => {
|
|
17
|
-
if (!
|
|
16
|
+
if (!DEV || !isSSR()) return;
|
|
18
17
|
devWarn(
|
|
19
18
|
`context.${method}() called during SSR. SibuJS context() is application-global \u2014 it is NOT isolated per request, so a concurrent request can observe this value. Do not use context() for request-specific SSR data; pass it explicitly or use request-scoped storage instead.`
|
|
20
19
|
);
|
|
@@ -42,7 +41,7 @@ function context(defaultValue) {
|
|
|
42
41
|
setValue(value);
|
|
43
42
|
try {
|
|
44
43
|
const result = fn();
|
|
45
|
-
if (
|
|
44
|
+
if (DEV && result !== null && typeof result?.then === "function") {
|
|
46
45
|
devWarn(
|
|
47
46
|
"context.withContext() received an async callback. Scoping is synchronous only \u2014 the previous value is restored as soon as the callback returns its promise, so anything after an `await` runs outside the scope."
|
|
48
47
|
);
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-WWV3SJ3L.js";
|
|
4
4
|
import {
|
|
5
5
|
tagFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6ZGI3RBE.js";
|
|
7
7
|
import {
|
|
8
8
|
derived
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2LOYNGBY.js";
|
|
10
10
|
import {
|
|
11
11
|
effect
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7VEC3UD2.js";
|
|
13
13
|
import {
|
|
14
14
|
batch,
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HECVW343.js";
|
|
17
17
|
|
|
18
18
|
// src/ecosystem/adapters/mobx.ts
|
|
19
19
|
function mobXAdapter(options) {
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
notifySubscribers,
|
|
4
4
|
queueSignalNotification,
|
|
5
5
|
recordDependency
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7ALC7KGE.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
DEV
|
|
9
|
+
} from "./chunk-2WLZ6757.js";
|
|
10
10
|
|
|
11
11
|
// src/reactivity/batch.ts
|
|
12
12
|
var batchDepth = 0;
|
|
@@ -60,7 +60,6 @@ var isBatching = API.isBatching;
|
|
|
60
60
|
|
|
61
61
|
// src/core/signals/signal.ts
|
|
62
62
|
var _g = globalThis;
|
|
63
|
-
var _isDev = isDev();
|
|
64
63
|
function signal(initial, options) {
|
|
65
64
|
const state = {
|
|
66
65
|
value: initial,
|
|
@@ -73,7 +72,7 @@ function signal(initial, options) {
|
|
|
73
72
|
_d: false,
|
|
74
73
|
_validate: void 0
|
|
75
74
|
};
|
|
76
|
-
const debugName =
|
|
75
|
+
const debugName = DEV ? options?.name : void 0;
|
|
77
76
|
const equalsFn = options?.equals;
|
|
78
77
|
if (debugName) state.__name = debugName;
|
|
79
78
|
function get() {
|
|
@@ -90,7 +89,7 @@ function signal(initial, options) {
|
|
|
90
89
|
if (equalsFn(prev, newValue)) return;
|
|
91
90
|
state.value = newValue;
|
|
92
91
|
state.__v++;
|
|
93
|
-
if (
|
|
92
|
+
if (DEV) {
|
|
94
93
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
95
94
|
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
|
|
96
95
|
}
|
|
@@ -98,7 +97,7 @@ function signal(initial, options) {
|
|
|
98
97
|
notifySubscribers(state);
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
|
-
} else if (
|
|
100
|
+
} else if (DEV) {
|
|
102
101
|
set = (next) => {
|
|
103
102
|
const prev = state.value;
|
|
104
103
|
const newValue = typeof next === "function" ? next(prev) : next;
|
|
@@ -123,7 +122,7 @@ function signal(initial, options) {
|
|
|
123
122
|
}
|
|
124
123
|
};
|
|
125
124
|
}
|
|
126
|
-
if (
|
|
125
|
+
if (DEV) {
|
|
127
126
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
128
127
|
if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
|
|
129
128
|
}
|
|
@@ -2,18 +2,17 @@ import {
|
|
|
2
2
|
isEventHandlerAttr,
|
|
3
3
|
isHtmlContentAttribute,
|
|
4
4
|
sanitizeAttributeString
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-IXKSNWV5.js";
|
|
6
6
|
import {
|
|
7
7
|
reactiveBinding
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7ALC7KGE.js";
|
|
9
9
|
import {
|
|
10
|
+
DEV,
|
|
10
11
|
devWarn,
|
|
11
|
-
isDev,
|
|
12
12
|
reportError
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2WLZ6757.js";
|
|
14
14
|
|
|
15
15
|
// src/utils/setSafeAttribute.ts
|
|
16
|
-
var _isDev = isDev();
|
|
17
16
|
var HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
18
17
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
19
18
|
var XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
@@ -36,7 +35,7 @@ function setSafeAttribute(el, name, value, options = {}) {
|
|
|
36
35
|
const ns = namespaceFor(el, name);
|
|
37
36
|
const localName = ns ? name.slice(name.indexOf(":") + 1) : name;
|
|
38
37
|
if (isEventHandlerAttr(name)) {
|
|
39
|
-
if (
|
|
38
|
+
if (DEV) {
|
|
40
39
|
devWarn(
|
|
41
40
|
`${options.label ?? "setSafeAttribute"}: refusing to set event-handler attribute "${name}". Its value would be evaluated as JavaScript. Use on:{ ${name.slice(2)}: fn } instead.`
|
|
42
41
|
);
|
|
@@ -51,7 +50,7 @@ function setSafeAttribute(el, name, value, options = {}) {
|
|
|
51
50
|
return true;
|
|
52
51
|
}
|
|
53
52
|
if (isHtmlContentAttribute(name)) {
|
|
54
|
-
if (
|
|
53
|
+
if (DEV) {
|
|
55
54
|
devWarn(
|
|
56
55
|
`${options.label ?? "setSafeAttribute"}: refusing to set "${name}". The browser parses this attribute as a nested HTML document, so a generic string value cannot be made safe \u2014 attribute escaping is undone before the parse. Build the frame's content another way.`
|
|
57
56
|
);
|
|
@@ -80,7 +79,7 @@ function setSafeAttribute(el, name, value, options = {}) {
|
|
|
80
79
|
setProp(el, idlName, idlName === "checked" ? Boolean(value) : str);
|
|
81
80
|
return true;
|
|
82
81
|
}
|
|
83
|
-
const safe = sanitizeAttributeString(name, str);
|
|
82
|
+
const safe = sanitizeAttributeString(name, str, { element: el });
|
|
84
83
|
const current = ns ? el.getAttributeNS(ns, localName) : el.getAttribute(name);
|
|
85
84
|
if (current === safe) return true;
|
|
86
85
|
if (ns) el.setAttributeNS(ns, name, safe);
|