sprae 8.1.2 → 9.0.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/core.js +127 -0
- package/directive/aria.js +10 -0
- package/directive/class.js +17 -0
- package/directive/data.js +10 -0
- package/directive/default.js +148 -0
- package/directive/each.js +64 -0
- package/directive/fx.js +6 -0
- package/directive/html.js +11 -0
- package/directive/if.js +40 -0
- package/directive/ref.js +10 -0
- package/directive/scope.js +11 -0
- package/directive/style.js +16 -0
- package/directive/text.js +12 -0
- package/directive/value.js +31 -0
- package/dist/sprae.js +749 -0
- package/dist/sprae.min.js +1 -0
- package/package.json +17 -15
- package/readme.md +379 -208
- package/sprae.js +14 -977
- package/sprae.auto.js +0 -976
- package/sprae.auto.min.js +0 -1
- package/sprae.min.js +0 -1
- package/src/core.js +0 -82
- package/src/directives.js +0 -447
- package/src/domdiff.js +0 -71
- package/src/index.js +0 -6
- package/src/state.proxy.js +0 -150
- package/src/state.signals-proxy.js +0 -151
- package/src/state.signals.js +0 -82
- package/src/util.js +0 -13
package/dist/sprae.js
ADDED
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// node_modules/swapdom/swap-inflate.js
|
|
8
|
+
var swap = (parent, a, b, end = null) => {
|
|
9
|
+
let i = 0, cur2, next, bi, n = b.length, m = a.length, { remove, same, insert, replace } = swap;
|
|
10
|
+
while (i < n && i < m && same(a[i], b[i]))
|
|
11
|
+
i++;
|
|
12
|
+
while (i < n && i < m && same(b[n - 1], a[m - 1]))
|
|
13
|
+
end = b[--m, --n];
|
|
14
|
+
if (i == m)
|
|
15
|
+
while (i < n)
|
|
16
|
+
insert(end, b[i++], parent);
|
|
17
|
+
else {
|
|
18
|
+
cur2 = a[i];
|
|
19
|
+
while (i < n) {
|
|
20
|
+
bi = b[i++], next = cur2 ? cur2.nextSibling : end;
|
|
21
|
+
if (same(cur2, bi))
|
|
22
|
+
cur2 = next;
|
|
23
|
+
else if (i < n && same(b[i], next))
|
|
24
|
+
replace(cur2, bi, parent), cur2 = next;
|
|
25
|
+
else
|
|
26
|
+
insert(cur2, bi, parent);
|
|
27
|
+
}
|
|
28
|
+
while (!same(cur2, end))
|
|
29
|
+
next = cur2.nextSibling, remove(cur2, parent), cur2 = next;
|
|
30
|
+
}
|
|
31
|
+
return b;
|
|
32
|
+
};
|
|
33
|
+
swap.same = (a, b) => a == b;
|
|
34
|
+
swap.replace = (a, b, parent) => parent.replaceChild(b, a);
|
|
35
|
+
swap.insert = (a, b, parent) => parent.insertBefore(b, a);
|
|
36
|
+
swap.remove = (a, parent) => parent.removeChild(a);
|
|
37
|
+
var swap_inflate_default = swap;
|
|
38
|
+
|
|
39
|
+
// node_modules/ulive/dist/ulive.es.js
|
|
40
|
+
var ulive_es_exports = {};
|
|
41
|
+
__export(ulive_es_exports, {
|
|
42
|
+
batch: () => batch,
|
|
43
|
+
computed: () => computed,
|
|
44
|
+
current: () => current,
|
|
45
|
+
effect: () => effect,
|
|
46
|
+
signal: () => signal,
|
|
47
|
+
untracked: () => untracked
|
|
48
|
+
});
|
|
49
|
+
var current;
|
|
50
|
+
var signal = (v, s, obs = /* @__PURE__ */ new Set()) => (s = {
|
|
51
|
+
get value() {
|
|
52
|
+
current?.deps.push(obs.add(current));
|
|
53
|
+
return v;
|
|
54
|
+
},
|
|
55
|
+
set value(val) {
|
|
56
|
+
if (val === v)
|
|
57
|
+
return;
|
|
58
|
+
v = val;
|
|
59
|
+
for (let sub of obs)
|
|
60
|
+
sub(val);
|
|
61
|
+
},
|
|
62
|
+
peek() {
|
|
63
|
+
return v;
|
|
64
|
+
}
|
|
65
|
+
}, s.toJSON = s.then = s.toString = s.valueOf = () => s.value, s);
|
|
66
|
+
var effect = (fn, teardown, run, deps) => (run = (prev) => {
|
|
67
|
+
teardown?.call?.();
|
|
68
|
+
prev = current, current = run;
|
|
69
|
+
try {
|
|
70
|
+
teardown = fn();
|
|
71
|
+
} finally {
|
|
72
|
+
current = prev;
|
|
73
|
+
}
|
|
74
|
+
}, deps = run.deps = [], run(), (dep) => {
|
|
75
|
+
teardown?.call?.();
|
|
76
|
+
while (dep = deps.pop())
|
|
77
|
+
dep.delete(run);
|
|
78
|
+
});
|
|
79
|
+
var computed = (fn, s = signal(), c, e) => (c = {
|
|
80
|
+
get value() {
|
|
81
|
+
e ||= effect(() => s.value = fn());
|
|
82
|
+
return s.value;
|
|
83
|
+
},
|
|
84
|
+
peek: s.peek
|
|
85
|
+
}, c.toJSON = c.then = c.toString = c.valueOf = () => c.value, c);
|
|
86
|
+
var batch = (fn) => fn();
|
|
87
|
+
var untracked = (fn, prev, v) => (prev = current, current = null, v = fn(), current = prev, v);
|
|
88
|
+
|
|
89
|
+
// node_modules/subscript/src/const.js
|
|
90
|
+
var PERIOD = 46;
|
|
91
|
+
var SPACE = 32;
|
|
92
|
+
var COLON = 58;
|
|
93
|
+
var DQUOTE = 34;
|
|
94
|
+
var QUOTE = 39;
|
|
95
|
+
var _0 = 48;
|
|
96
|
+
var _9 = 57;
|
|
97
|
+
var _E = 69;
|
|
98
|
+
var _e = 101;
|
|
99
|
+
var BSLASH = 92;
|
|
100
|
+
var STAR = 42;
|
|
101
|
+
var PREC_SEQ = 1;
|
|
102
|
+
var PREC_ASSIGN = 2;
|
|
103
|
+
var PREC_LOR = 3;
|
|
104
|
+
var PREC_LAND = 4;
|
|
105
|
+
var PREC_OR = 5;
|
|
106
|
+
var PREC_XOR = 6;
|
|
107
|
+
var PREC_AND = 7;
|
|
108
|
+
var PREC_EQ = 8;
|
|
109
|
+
var PREC_COMP = 9;
|
|
110
|
+
var PREC_SHIFT = 10;
|
|
111
|
+
var PREC_ADD = 11;
|
|
112
|
+
var PREC_MULT = 12;
|
|
113
|
+
var PREC_EXP = 13;
|
|
114
|
+
var PREC_PREFIX = 14;
|
|
115
|
+
var PREC_POSTFIX = 15;
|
|
116
|
+
var PREC_ACCESS = 17;
|
|
117
|
+
var PREC_TOKEN = 20;
|
|
118
|
+
|
|
119
|
+
// node_modules/subscript/src/parse.js
|
|
120
|
+
var idx;
|
|
121
|
+
var cur;
|
|
122
|
+
var parse = (s) => (idx = 0, cur = s, s = expr(), cur[idx] ? err2() : s || "");
|
|
123
|
+
var err2 = (msg = "Bad syntax", lines = cur.slice(0, idx).split("\n"), last2 = lines.pop()) => {
|
|
124
|
+
let before = cur.slice(idx - 108, idx).split("\n").pop();
|
|
125
|
+
let after = cur.slice(idx, idx + 108).split("\n").shift();
|
|
126
|
+
throw EvalError(`${msg} at ${lines.length}:${last2.length} \`${idx >= 108 ? "\u2026" : ""}${before}\u25B6${after}\``, "font-weight: bold");
|
|
127
|
+
};
|
|
128
|
+
var skip = (is = 1, from = idx, l) => {
|
|
129
|
+
if (typeof is == "number")
|
|
130
|
+
idx += is;
|
|
131
|
+
else
|
|
132
|
+
while (l = is(cur.charCodeAt(idx)))
|
|
133
|
+
idx += l;
|
|
134
|
+
return cur.slice(from, idx);
|
|
135
|
+
};
|
|
136
|
+
var expr = (prec = 0, end, cc, token2, newNode, fn) => {
|
|
137
|
+
while ((cc = parse.space()) && (newNode = ((fn = lookup[cc]) && fn(token2, prec)) ?? (!token2 && parse.id())))
|
|
138
|
+
token2 = newNode;
|
|
139
|
+
if (end)
|
|
140
|
+
cc == end ? idx++ : err2();
|
|
141
|
+
return token2;
|
|
142
|
+
};
|
|
143
|
+
var isId = (c) => c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c == 36 || c == 95 || c >= 192 && c != 215 && c != 247;
|
|
144
|
+
var id = parse.id = () => skip(isId);
|
|
145
|
+
var space = parse.space = (cc) => {
|
|
146
|
+
while ((cc = cur.charCodeAt(idx)) <= SPACE)
|
|
147
|
+
idx++;
|
|
148
|
+
return cc;
|
|
149
|
+
};
|
|
150
|
+
var lookup = [];
|
|
151
|
+
var token = (op, prec = SPACE, map, c = op.charCodeAt(0), l = op.length, prev = lookup[c], word = op.toUpperCase() !== op) => lookup[c] = (a, curPrec, from = idx) => curPrec < prec && (l < 2 || cur.substr(idx, l) == op) && (!word || !isId(cur.charCodeAt(idx + l))) && (idx += l, map(a, curPrec)) || (idx = from, prev?.(a, curPrec));
|
|
152
|
+
var binary = (op, prec, right = false) => token(op, prec, (a, b) => a && (b = expr(prec - (right ? 0.5 : 0))) && [op, a, b]);
|
|
153
|
+
var unary = (op, prec, post) => token(op, prec, (a) => post ? a && [op, a] : !a && (a = expr(prec - 0.5)) && [op, a]);
|
|
154
|
+
var nary = (op, prec) => {
|
|
155
|
+
token(
|
|
156
|
+
op,
|
|
157
|
+
prec,
|
|
158
|
+
(a, b) => (b = expr(prec), (!a || a[0] !== op) && (a = [op, a]), a.push(b), a)
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
var group = (op, prec) => token(op[0], prec, (a) => !a && [op, expr(0, op.charCodeAt(1))]);
|
|
162
|
+
var access = (op, prec) => token(op[0], prec, (a) => a && [op[0], a, expr(0, op.charCodeAt(1))]);
|
|
163
|
+
var parse_default = parse;
|
|
164
|
+
|
|
165
|
+
// node_modules/subscript/src/compile.js
|
|
166
|
+
var compile = (node) => !Array.isArray(node) ? compile.id(node) : !node[0] ? () => node[1] : operators[node[0]](...node.slice(1));
|
|
167
|
+
var id2 = compile.id = (name) => (ctx) => ctx?.[name];
|
|
168
|
+
var operators = {};
|
|
169
|
+
var operator = (op, fn, prev = operators[op]) => operators[op] = (...args) => fn(...args) || prev && prev(...args);
|
|
170
|
+
var prop = (a, fn, generic, obj, path) => a[0] === "()" ? prop(a[1], fn, generic) : typeof a === "string" ? (ctx) => fn(ctx, a, ctx) : a[0] === "." ? (obj = compile(a[1]), path = a[2], (ctx) => fn(obj(ctx), path, ctx)) : a[0] === "[" ? (obj = compile(a[1]), path = compile(a[2]), (ctx) => fn(obj(ctx), path(ctx), ctx)) : generic ? (a = compile(a), (ctx) => fn([a(ctx)], 0, ctx)) : () => err2("Bad left value");
|
|
171
|
+
var compile_default = compile;
|
|
172
|
+
|
|
173
|
+
// node_modules/subscript/feature/number.js
|
|
174
|
+
var num = (a) => a ? err2() : [, (a = +skip((c) => c === PERIOD || c >= _0 && c <= _9 || (c === _E || c === _e ? 2 : 0))) != a ? err2() : a];
|
|
175
|
+
lookup[PERIOD] = (a) => !a && num();
|
|
176
|
+
for (let i = _0; i <= _9; i++)
|
|
177
|
+
lookup[i] = num;
|
|
178
|
+
|
|
179
|
+
// node_modules/subscript/feature/string.js
|
|
180
|
+
var escape = { n: "\n", r: "\r", t: " ", b: "\b", f: "\f", v: "\v" };
|
|
181
|
+
var string = (q) => (qc, c, str = "") => {
|
|
182
|
+
qc && err2("Unexpected string");
|
|
183
|
+
skip();
|
|
184
|
+
while (c = cur.charCodeAt(idx), c - q) {
|
|
185
|
+
if (c === BSLASH)
|
|
186
|
+
skip(), c = skip(), str += escape[c] || c;
|
|
187
|
+
else
|
|
188
|
+
str += skip();
|
|
189
|
+
}
|
|
190
|
+
skip() || err2("Bad string");
|
|
191
|
+
return [, str];
|
|
192
|
+
};
|
|
193
|
+
lookup[DQUOTE] = string(DQUOTE);
|
|
194
|
+
lookup[QUOTE] = string(QUOTE);
|
|
195
|
+
|
|
196
|
+
// node_modules/subscript/feature/call.js
|
|
197
|
+
access("()", PREC_ACCESS);
|
|
198
|
+
operator(
|
|
199
|
+
"(",
|
|
200
|
+
(a, b, args) => (args = !b ? () => [] : b[0] === "," ? (b = b.slice(1).map((b2) => !b2 ? err() : compile(b2)), (ctx) => b.map((arg) => arg(ctx))) : (b = compile(b), (ctx) => [b(ctx)]), prop(a, (obj, path, ctx) => obj[path](...args(ctx)), true))
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
// node_modules/subscript/feature/access.js
|
|
204
|
+
access("[]", PREC_ACCESS);
|
|
205
|
+
operator("[", (a, b) => !b ? err() : (a = compile(a), b = compile(b), (ctx) => a(ctx)[b(ctx)]));
|
|
206
|
+
binary(".", PREC_ACCESS);
|
|
207
|
+
operator(".", (a, b) => (a = compile(a), b = !b[0] ? b[1] : b, (ctx) => a(ctx)[b]));
|
|
208
|
+
|
|
209
|
+
// node_modules/subscript/feature/group.js
|
|
210
|
+
group("()", PREC_ACCESS);
|
|
211
|
+
operator("()", (a) => (!a && err2("Empty ()"), compile(a)));
|
|
212
|
+
var last = (...args) => (args = args.map(compile), (ctx) => args.map((arg) => arg(ctx)).pop());
|
|
213
|
+
nary(",", PREC_SEQ), operator(",", last);
|
|
214
|
+
nary(";", PREC_SEQ, true), operator(";", last);
|
|
215
|
+
|
|
216
|
+
// node_modules/subscript/feature/mult.js
|
|
217
|
+
binary("*", PREC_MULT), operator("*", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) * b(ctx)));
|
|
218
|
+
binary("/", PREC_MULT), operator("/", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) / b(ctx)));
|
|
219
|
+
binary("%", PREC_MULT), operator("%", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) % b(ctx)));
|
|
220
|
+
binary("*=", PREC_ASSIGN, true);
|
|
221
|
+
operator("*=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] *= b(ctx))));
|
|
222
|
+
binary("/=", PREC_ASSIGN, true);
|
|
223
|
+
operator("/=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] /= b(ctx))));
|
|
224
|
+
binary("%=", PREC_ASSIGN, true);
|
|
225
|
+
operator("%=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] %= b(ctx))));
|
|
226
|
+
|
|
227
|
+
// node_modules/subscript/feature/add.js
|
|
228
|
+
unary("+", PREC_PREFIX), operator("+", (a, b) => !b && (a = compile(a), (ctx) => +a(ctx)));
|
|
229
|
+
unary("-", PREC_PREFIX), operator("-", (a, b) => !b && (a = compile(a), (ctx) => -a(ctx)));
|
|
230
|
+
binary("+", PREC_ADD), operator("+", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) + b(ctx)));
|
|
231
|
+
binary("-", PREC_ADD), operator("-", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) - b(ctx)));
|
|
232
|
+
binary("+=", PREC_ASSIGN, true);
|
|
233
|
+
operator("+=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] += b(ctx))));
|
|
234
|
+
binary("-=", PREC_ASSIGN, true);
|
|
235
|
+
operator("-=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] -= b(ctx))));
|
|
236
|
+
|
|
237
|
+
// node_modules/subscript/feature/increment.js
|
|
238
|
+
var inc;
|
|
239
|
+
var dec;
|
|
240
|
+
token("++", PREC_POSTFIX, (a) => a ? ["++-", a] : ["++", expr(PREC_POSTFIX - 1)]);
|
|
241
|
+
operator("++", inc = (a) => prop(a, (obj, path, ctx) => ++obj[path]));
|
|
242
|
+
operator("++-", inc = (a) => prop(a, (obj, path, ctx) => obj[path]++));
|
|
243
|
+
token("--", PREC_POSTFIX, (a) => a ? ["--+", a] : ["--", expr(PREC_POSTFIX - 1)]);
|
|
244
|
+
operator("--", dec = (a) => prop(a, (obj, path, ctx) => --obj[path]));
|
|
245
|
+
operator("--+", dec = (a) => prop(a, (obj, path, ctx) => obj[path]--));
|
|
246
|
+
|
|
247
|
+
// node_modules/subscript/feature/bitwise.js
|
|
248
|
+
unary("~", PREC_PREFIX), operator("~", (a, b) => !b && (a = compile(a), (ctx) => ~a(ctx)));
|
|
249
|
+
binary("|", PREC_OR), operator("|", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) | b(ctx)));
|
|
250
|
+
binary("&", PREC_AND), operator("&", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) & b(ctx)));
|
|
251
|
+
binary("^", PREC_XOR), operator("^", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) ^ b(ctx)));
|
|
252
|
+
binary(">>", PREC_SHIFT), operator(">>", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) >> b(ctx)));
|
|
253
|
+
binary("<<", PREC_SHIFT), operator("<<", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) << b(ctx)));
|
|
254
|
+
|
|
255
|
+
// node_modules/subscript/feature/compare.js
|
|
256
|
+
binary("==", PREC_EQ), operator("==", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) == b(ctx)));
|
|
257
|
+
binary("!=", PREC_EQ), operator("!=", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) != b(ctx)));
|
|
258
|
+
binary(">", PREC_COMP), operator(">", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) > b(ctx)));
|
|
259
|
+
binary("<", PREC_COMP), operator("<", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) < b(ctx)));
|
|
260
|
+
binary(">=", PREC_COMP), operator(">=", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) >= b(ctx)));
|
|
261
|
+
binary("<=", PREC_COMP), operator("<=", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) <= b(ctx)));
|
|
262
|
+
|
|
263
|
+
// node_modules/subscript/feature/logic.js
|
|
264
|
+
unary("!", PREC_PREFIX), operator("!", (a, b) => !b && (a = compile(a), (ctx) => !a(ctx)));
|
|
265
|
+
binary("||", PREC_LOR);
|
|
266
|
+
operator("||", (a, b) => (a = compile(a), b = compile(b), (ctx) => a(ctx) || b(ctx)));
|
|
267
|
+
binary("&&", PREC_LAND);
|
|
268
|
+
operator("&&", (a, b) => (a = compile(a), b = compile(b), (ctx) => a(ctx) && b(ctx)));
|
|
269
|
+
|
|
270
|
+
// node_modules/subscript/feature/assign.js
|
|
271
|
+
binary("=", PREC_ASSIGN, true);
|
|
272
|
+
operator("=", (a, b) => (b = compile(b), prop(a, (container, path, ctx) => container[path] = b(ctx))));
|
|
273
|
+
|
|
274
|
+
// node_modules/subscript/subscript.js
|
|
275
|
+
var subscript_default = (s) => compile_default(parse_default(s));
|
|
276
|
+
|
|
277
|
+
// node_modules/subscript/feature/comment.js
|
|
278
|
+
token("/*", PREC_TOKEN, (a, prec) => (skip((c) => c !== STAR && cur.charCodeAt(idx + 1) !== 47), skip(2), a || expr(prec) || []));
|
|
279
|
+
token("//", PREC_TOKEN, (a, prec) => (skip((c) => c >= SPACE), a || expr(prec) || [""]));
|
|
280
|
+
|
|
281
|
+
// node_modules/subscript/feature/pow.js
|
|
282
|
+
binary("**", PREC_EXP, true), operator("**", (a, b) => b && (a = compile(a), b = compile(b), (ctx) => a(ctx) ** b(ctx)));
|
|
283
|
+
|
|
284
|
+
// node_modules/subscript/feature/ternary.js
|
|
285
|
+
token("?", PREC_ASSIGN, (a, b, c) => a && (b = expr(PREC_ASSIGN, COLON)) && (c = expr(PREC_ASSIGN + 1), ["?", a, b, c]));
|
|
286
|
+
operator("?", (a, b, c) => (a = compile(a), b = compile(b), c = compile(c), (ctx) => a(ctx) ? b(ctx) : c(ctx)));
|
|
287
|
+
|
|
288
|
+
// node_modules/subscript/feature/bool.js
|
|
289
|
+
token("true", PREC_TOKEN, (a) => a ? err() : [, true]);
|
|
290
|
+
token("false", PREC_TOKEN, (a) => a ? err() : [, false]);
|
|
291
|
+
|
|
292
|
+
// node_modules/subscript/feature/array.js
|
|
293
|
+
group("[]", PREC_TOKEN);
|
|
294
|
+
operator("[]", (a, b) => !a ? () => [] : a[0] === "," ? (a = a.slice(1).map(compile), (ctx) => a.map((a2) => a2(ctx))) : (a = compile(a), (ctx) => [a(ctx)]));
|
|
295
|
+
|
|
296
|
+
// node_modules/subscript/feature/object.js
|
|
297
|
+
group("{}", PREC_TOKEN);
|
|
298
|
+
operator("{}", (a, b) => !a ? () => ({}) : a[0] === "," ? (a = a.slice(1).map(compile), (ctx) => Object.fromEntries(a.map((a2) => a2(ctx)))) : a[0] === ":" ? (a = compile(a), (ctx) => Object.fromEntries([a(ctx)])) : (b = compile(a), (ctx) => ({ [a]: b(ctx) })));
|
|
299
|
+
binary(":", PREC_ASSIGN, true);
|
|
300
|
+
operator(":", (a, b) => (b = compile(b), a = Array.isArray(a) ? compile(a) : ((a2) => a2).bind(0, a), (ctx) => [a(ctx), b(ctx)]));
|
|
301
|
+
|
|
302
|
+
// node_modules/subscript/feature/arrow.js
|
|
303
|
+
binary("=>", PREC_ASSIGN, true);
|
|
304
|
+
operator(
|
|
305
|
+
"=>",
|
|
306
|
+
(a, b) => (a = a[0] === "()" ? a[1] : a, a = !a ? [] : a[0] === "," ? a = a.slice(1) : a = [a], b = compile(b[0] === "{}" ? b[1] : b), (ctx = null) => (ctx = Object.create(ctx), (...args) => (a.map((a2, i) => ctx[a2] = args[i]), b(ctx))))
|
|
307
|
+
);
|
|
308
|
+
binary("");
|
|
309
|
+
|
|
310
|
+
// node_modules/subscript/feature/optional.js
|
|
311
|
+
token("?.", PREC_ACCESS, (a) => a && ["?.", a]);
|
|
312
|
+
operator("?.", (a) => (a = compile(a), (ctx) => a(ctx) || (() => {
|
|
313
|
+
})));
|
|
314
|
+
token("?.", PREC_ACCESS, (a, b) => a && (b = expr(PREC_ACCESS), !b?.map) && ["?.", a, b]);
|
|
315
|
+
operator("?.", (a, b) => b && (a = compile(a), (ctx) => a(ctx)?.[b]));
|
|
316
|
+
operator("(", (a, b, container, args, path, optional) => a[0] === "?." && (a[2] || Array.isArray(a[1])) && (args = !b ? () => [] : b[0] === "," ? (b = b.slice(1).map(compile), (ctx) => b.map((a2) => a2(ctx))) : (b = compile(b), (ctx) => [b(ctx)]), !a[2] && (optional = true, a = a[1]), a[0] === "[" ? path = compile(a[2]) : path = () => a[2], container = compile(a[1]), optional ? (ctx) => container(ctx)?.[path(ctx)]?.(...args(ctx)) : (ctx) => container(ctx)?.[path(ctx)](...args(ctx))));
|
|
317
|
+
|
|
318
|
+
// node_modules/subscript/justin.js
|
|
319
|
+
binary("in", PREC_COMP), operator("in", (a, b) => b && (a = compile_default(a), b = compile_default(b), (ctx) => a(ctx) in b(ctx)));
|
|
320
|
+
binary("===", PREC_EQ), binary("!==", 9);
|
|
321
|
+
operator("===", (a, b) => (a = compile_default(a), b = compile_default(b), (ctx) => a(ctx) === b(ctx)));
|
|
322
|
+
operator("===", (a, b) => (a = compile_default(a), b = compile_default(b), (ctx) => a(ctx) !== b(ctx)));
|
|
323
|
+
binary("??", PREC_LOR);
|
|
324
|
+
operator("??", (a, b) => b && (a = compile_default(a), b = compile_default(b), (ctx) => a(ctx) ?? b(ctx)));
|
|
325
|
+
binary("??=", PREC_ASSIGN, true);
|
|
326
|
+
operator("??=", (a, b) => (b = compile_default(b), prop(a, (obj, path, ctx) => obj[path] ??= b(ctx))));
|
|
327
|
+
binary("||=", PREC_ASSIGN, true);
|
|
328
|
+
operator("||=", (a, b) => (b = compile_default(b), prop(a, (obj, path, ctx) => obj[path] ||= b(ctx))));
|
|
329
|
+
binary("&&=", PREC_ASSIGN, true);
|
|
330
|
+
operator("&&=", (a, b) => (b = compile_default(b), prop(a, (obj, path, ctx) => obj[path] &&= b(ctx))));
|
|
331
|
+
token("undefined", 20, (a) => a ? err2() : [, void 0]);
|
|
332
|
+
token("NaN", 20, (a) => a ? err2() : [, NaN]);
|
|
333
|
+
token("null", 20, (a) => a ? err2() : [, null]);
|
|
334
|
+
var justin_default = subscript_default;
|
|
335
|
+
|
|
336
|
+
// core.js
|
|
337
|
+
var _dispose = Symbol.dispose ||= Symbol("dispose");
|
|
338
|
+
var SPRAE = `\u2234`;
|
|
339
|
+
var { signal: signal2, effect: effect2, batch: batch2, computed: computed2, untracked: untracked2 } = ulive_es_exports;
|
|
340
|
+
var directive = {};
|
|
341
|
+
var memo = /* @__PURE__ */ new WeakMap();
|
|
342
|
+
function sprae(container, values) {
|
|
343
|
+
if (!container.children)
|
|
344
|
+
return;
|
|
345
|
+
if (memo.has(container)) {
|
|
346
|
+
const [state2, effects2] = memo.get(container);
|
|
347
|
+
for (let k in values)
|
|
348
|
+
state2[k] = values[k];
|
|
349
|
+
for (let fx of effects2)
|
|
350
|
+
fx();
|
|
351
|
+
}
|
|
352
|
+
const state = values || {};
|
|
353
|
+
const effects = [];
|
|
354
|
+
const init = (el, parent = el.parentNode) => {
|
|
355
|
+
if (el.attributes) {
|
|
356
|
+
for (let i = 0; i < el.attributes.length; ) {
|
|
357
|
+
let attr2 = el.attributes[i];
|
|
358
|
+
if (attr2.name[0] === ":") {
|
|
359
|
+
el.removeAttribute(attr2.name);
|
|
360
|
+
let names = attr2.name.slice(1).split(":");
|
|
361
|
+
for (let name of names) {
|
|
362
|
+
let update = (directive[name] || directive.default)(el, attr2.value, state, name);
|
|
363
|
+
if (update) {
|
|
364
|
+
update[_dispose] = effect2(update);
|
|
365
|
+
effects.push(update);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (memo.has(el))
|
|
369
|
+
return;
|
|
370
|
+
if (el.parentNode !== parent)
|
|
371
|
+
return false;
|
|
372
|
+
} else
|
|
373
|
+
i++;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
for (let i = 0, child; child = el.children[i]; i++) {
|
|
377
|
+
if (init(child, el) === false)
|
|
378
|
+
i--;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
init(container);
|
|
382
|
+
if (memo.has(container))
|
|
383
|
+
return state;
|
|
384
|
+
memo.set(container, [state, effects]);
|
|
385
|
+
container.classList?.add(SPRAE);
|
|
386
|
+
container[_dispose] = () => {
|
|
387
|
+
while (effects.length)
|
|
388
|
+
effects.pop()[_dispose]();
|
|
389
|
+
container.classList.remove(SPRAE);
|
|
390
|
+
memo.delete(container);
|
|
391
|
+
let els = container.getElementsByClassName(SPRAE);
|
|
392
|
+
while (els.length)
|
|
393
|
+
els[0][_dispose]?.();
|
|
394
|
+
};
|
|
395
|
+
return state;
|
|
396
|
+
}
|
|
397
|
+
var evalMemo = {};
|
|
398
|
+
var compile2 = (expr2, dir, evaluate) => {
|
|
399
|
+
if (evaluate = evalMemo[expr2 = expr2.trim()])
|
|
400
|
+
return evaluate;
|
|
401
|
+
try {
|
|
402
|
+
evaluate = justin_default(expr2);
|
|
403
|
+
} catch (e) {
|
|
404
|
+
throw Object.assign(e, { message: `${SPRAE} ${e.message}
|
|
405
|
+
|
|
406
|
+
${dir}${expr2 ? `="${expr2}"
|
|
407
|
+
|
|
408
|
+
` : ""}`, expr: expr2 });
|
|
409
|
+
}
|
|
410
|
+
return evalMemo[expr2] = evaluate;
|
|
411
|
+
};
|
|
412
|
+
var swap2 = swap_inflate_default;
|
|
413
|
+
var ipol = (v, state) => {
|
|
414
|
+
return v?.replace ? v.replace(/\$<([^>]+)>/g, (match, field) => state[field]?.valueOf?.() ?? "") : v;
|
|
415
|
+
};
|
|
416
|
+
sprae.use = (s) => {
|
|
417
|
+
s.signal && (signal2 = s.signal, effect2 = s.effect, computed2 = s.computed, batch2 = s.batch || ((fn) => fn()), untracked2 = s.untracked || batch2);
|
|
418
|
+
s.swap && (swap2 = s.swap);
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// directive/each.js
|
|
422
|
+
var _each = Symbol(":each");
|
|
423
|
+
var keys = {};
|
|
424
|
+
directive.each = (tpl, expr2, state, name) => {
|
|
425
|
+
let [leftSide, itemsExpr] = expr2.split(/\s+in\s+/);
|
|
426
|
+
let [itemVar, idxVar = "_$"] = leftSide.split(/\s*,\s*/);
|
|
427
|
+
const holder = tpl[_each] = document.createTextNode("");
|
|
428
|
+
tpl.replaceWith(holder);
|
|
429
|
+
const evaluate = compile2(itemsExpr, name);
|
|
430
|
+
const memo2 = /* @__PURE__ */ new WeakMap();
|
|
431
|
+
tpl.removeAttribute(":key");
|
|
432
|
+
let cur2 = [];
|
|
433
|
+
return () => {
|
|
434
|
+
let items = evaluate(state)?.valueOf(), els = [];
|
|
435
|
+
if (typeof items === "number")
|
|
436
|
+
items = Array.from({ length: items }, (_, i) => i);
|
|
437
|
+
const count = /* @__PURE__ */ new WeakSet();
|
|
438
|
+
for (let idx2 in items) {
|
|
439
|
+
let item = items[idx2];
|
|
440
|
+
let substate = Object.create(state, { [idxVar]: { value: idx2 } });
|
|
441
|
+
substate[itemVar] = item;
|
|
442
|
+
item = item.peek?.() ?? item;
|
|
443
|
+
let key = item.key ?? item.id ?? item;
|
|
444
|
+
let el;
|
|
445
|
+
if (key == null)
|
|
446
|
+
el = tpl.cloneNode(true);
|
|
447
|
+
else {
|
|
448
|
+
if (Object(key) !== key)
|
|
449
|
+
key = keys[key] ||= Object(key);
|
|
450
|
+
if (count.has(key)) {
|
|
451
|
+
console.warn("Duplicate key", key), el = tpl.cloneNode(true);
|
|
452
|
+
} else {
|
|
453
|
+
console.log(key, count.has(key));
|
|
454
|
+
count.add(key);
|
|
455
|
+
el = memo2.get(key) || memo2.set(key, tpl.cloneNode(true)).get(key);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (el.content)
|
|
459
|
+
el = el.content.cloneNode(true);
|
|
460
|
+
sprae(el, substate);
|
|
461
|
+
if (el.nodeType === 11)
|
|
462
|
+
els.push(...el.childNodes);
|
|
463
|
+
else
|
|
464
|
+
els.push(el);
|
|
465
|
+
}
|
|
466
|
+
swap2(holder.parentNode, cur2, cur2 = els, holder);
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
// directive/if.js
|
|
471
|
+
var _prevIf = Symbol("if");
|
|
472
|
+
directive.if = (ifEl, expr2, state, name) => {
|
|
473
|
+
let parent = ifEl.parentNode, next = ifEl.nextElementSibling, holder = document.createTextNode(""), evaluate = compile2(expr2, name), cur2, ifs, elses, none = [];
|
|
474
|
+
ifEl.after(holder);
|
|
475
|
+
if (ifEl.content)
|
|
476
|
+
cur2 = none, ifEl.remove(), ifs = [...ifEl.content.childNodes];
|
|
477
|
+
else
|
|
478
|
+
ifs = cur2 = [ifEl];
|
|
479
|
+
if (next?.hasAttribute(":else")) {
|
|
480
|
+
next.removeAttribute(":else");
|
|
481
|
+
if (next.hasAttribute(":if"))
|
|
482
|
+
elses = none;
|
|
483
|
+
else
|
|
484
|
+
next.remove(), elses = next.content ? [...next.content.childNodes] : [next];
|
|
485
|
+
} else
|
|
486
|
+
elses = none;
|
|
487
|
+
return () => {
|
|
488
|
+
const newEls = evaluate(state)?.valueOf() ? ifs : ifEl[_prevIf] ? none : elses;
|
|
489
|
+
if (next)
|
|
490
|
+
next[_prevIf] = newEls === ifs;
|
|
491
|
+
if (cur2 != newEls) {
|
|
492
|
+
if (cur2[0]?.[_each])
|
|
493
|
+
cur2 = [cur2[0][_each]];
|
|
494
|
+
swap2(parent, cur2, cur2 = newEls, holder);
|
|
495
|
+
for (let el of cur2)
|
|
496
|
+
sprae(el, state);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// directive/ref.js
|
|
502
|
+
directive.ref = (el, expr2, state) => {
|
|
503
|
+
let prev;
|
|
504
|
+
return () => {
|
|
505
|
+
if (prev)
|
|
506
|
+
delete state[prev];
|
|
507
|
+
state[prev = ipol(expr2, state)] = el;
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
// directive/scope.js
|
|
512
|
+
directive.scope = (el, expr2, rootState, name) => {
|
|
513
|
+
let evaluate = compile2(expr2, name);
|
|
514
|
+
return () => {
|
|
515
|
+
sprae(el, { ...rootState, ...evaluate(rootState)?.valueOf?.() || {} });
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// directive/html.js
|
|
520
|
+
directive.html = (el, expr2, state, name) => {
|
|
521
|
+
let evaluate = compile2(expr2, name), tpl = evaluate(state);
|
|
522
|
+
if (!tpl)
|
|
523
|
+
return;
|
|
524
|
+
let content = (tpl.content || tpl).cloneNode(true);
|
|
525
|
+
el.replaceChildren(content);
|
|
526
|
+
sprae(el, state);
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// directive/text.js
|
|
530
|
+
directive.text = (el, expr2, state) => {
|
|
531
|
+
let evaluate = compile2(expr2, "text");
|
|
532
|
+
if (el.content)
|
|
533
|
+
el.replaceWith(el = document.createTextNode(""));
|
|
534
|
+
return () => {
|
|
535
|
+
let value = evaluate(state)?.valueOf();
|
|
536
|
+
el.textContent = value == null ? "" : value;
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// directive/class.js
|
|
541
|
+
directive.class = (el, expr2, state) => {
|
|
542
|
+
let evaluate = compile2(expr2, "class");
|
|
543
|
+
let cur2 = /* @__PURE__ */ new Set();
|
|
544
|
+
return () => {
|
|
545
|
+
let v = evaluate(state);
|
|
546
|
+
let clsx = /* @__PURE__ */ new Set();
|
|
547
|
+
if (v) {
|
|
548
|
+
if (typeof v === "string")
|
|
549
|
+
ipol(v?.valueOf?.(), state).split(" ").map((cls) => clsx.add(cls));
|
|
550
|
+
else if (Array.isArray(v))
|
|
551
|
+
v.map((v2) => (v2 = ipol(v2?.valueOf?.(), state)) && clsx.add(v2));
|
|
552
|
+
else
|
|
553
|
+
Object.entries(v).map(([k, v2]) => v2?.valueOf?.() && clsx.add(k));
|
|
554
|
+
}
|
|
555
|
+
for (let cls of cur2)
|
|
556
|
+
if (clsx.has(cls))
|
|
557
|
+
clsx.delete(cls);
|
|
558
|
+
else
|
|
559
|
+
el.classList.remove(cls);
|
|
560
|
+
for (let cls of cur2 = clsx)
|
|
561
|
+
el.classList.add(cls);
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// directive/style.js
|
|
566
|
+
directive.style = (el, expr2, state) => {
|
|
567
|
+
let evaluate = compile2(expr2, "style");
|
|
568
|
+
let initStyle = el.getAttribute("style") || "";
|
|
569
|
+
if (!initStyle.endsWith(";"))
|
|
570
|
+
initStyle += "; ";
|
|
571
|
+
return () => {
|
|
572
|
+
let v = evaluate(state)?.valueOf();
|
|
573
|
+
if (typeof v === "string")
|
|
574
|
+
el.setAttribute("style", initStyle + ipol(v, state));
|
|
575
|
+
else {
|
|
576
|
+
el.setAttribute("style", initStyle);
|
|
577
|
+
for (let k in v)
|
|
578
|
+
el.style.setProperty(k, ipol(v[k], state));
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// directive/default.js
|
|
584
|
+
directive.default = (el, expr2, state, name) => {
|
|
585
|
+
let evt = name.startsWith("on") && name.slice(2);
|
|
586
|
+
let evaluate = compile2(expr2, name);
|
|
587
|
+
if (evt) {
|
|
588
|
+
let off;
|
|
589
|
+
return () => (off?.(), off = on(el, evt, evaluate(state)));
|
|
590
|
+
}
|
|
591
|
+
return () => {
|
|
592
|
+
let value = evaluate(state)?.valueOf();
|
|
593
|
+
if (name)
|
|
594
|
+
attr(el, name, ipol(value, state));
|
|
595
|
+
else
|
|
596
|
+
for (let key in value)
|
|
597
|
+
attr(el, dashcase(key), ipol(value[key], state));
|
|
598
|
+
};
|
|
599
|
+
};
|
|
600
|
+
var on = (el, e, fn = () => {
|
|
601
|
+
}) => {
|
|
602
|
+
const ctx = { evt: "", target: el, test: () => true };
|
|
603
|
+
ctx.evt = e.replace(
|
|
604
|
+
/\.(\w+)?-?([-\w]+)?/g,
|
|
605
|
+
(match, mod, param = "") => (ctx.test = mods[mod]?.(ctx, ...param.split("-")) || ctx.test, "")
|
|
606
|
+
);
|
|
607
|
+
const { evt, target, test, defer, stop, prevent, ...opts } = ctx;
|
|
608
|
+
if (defer)
|
|
609
|
+
fn = defer(fn);
|
|
610
|
+
const cb = (e2) => test(e2) && (stop && e2.stopPropagation(), prevent && e2.preventDefault(), fn.call(target, e2));
|
|
611
|
+
target.addEventListener(evt, cb, opts);
|
|
612
|
+
return () => target.removeEventListener(evt, cb, opts);
|
|
613
|
+
};
|
|
614
|
+
var mods = {
|
|
615
|
+
prevent(ctx) {
|
|
616
|
+
ctx.prevent = true;
|
|
617
|
+
},
|
|
618
|
+
stop(ctx) {
|
|
619
|
+
ctx.stop = true;
|
|
620
|
+
},
|
|
621
|
+
once(ctx) {
|
|
622
|
+
ctx.once = true;
|
|
623
|
+
},
|
|
624
|
+
passive(ctx) {
|
|
625
|
+
ctx.passive = true;
|
|
626
|
+
},
|
|
627
|
+
capture(ctx) {
|
|
628
|
+
ctx.capture = true;
|
|
629
|
+
},
|
|
630
|
+
window(ctx) {
|
|
631
|
+
ctx.target = window;
|
|
632
|
+
},
|
|
633
|
+
document(ctx) {
|
|
634
|
+
ctx.target = document;
|
|
635
|
+
},
|
|
636
|
+
throttle(ctx, limit) {
|
|
637
|
+
ctx.defer = (fn) => throttle(fn, limit ? Number(limit) || 0 : 108);
|
|
638
|
+
},
|
|
639
|
+
debounce(ctx, wait) {
|
|
640
|
+
ctx.defer = (fn) => debounce(fn, wait ? Number(wait) || 0 : 108);
|
|
641
|
+
},
|
|
642
|
+
outside: (ctx) => (e) => {
|
|
643
|
+
let target = ctx.target;
|
|
644
|
+
if (target.contains(e.target))
|
|
645
|
+
return false;
|
|
646
|
+
if (e.target.isConnected === false)
|
|
647
|
+
return false;
|
|
648
|
+
if (target.offsetWidth < 1 && target.offsetHeight < 1)
|
|
649
|
+
return false;
|
|
650
|
+
return true;
|
|
651
|
+
},
|
|
652
|
+
self: (ctx) => (e) => e.target === ctx.target,
|
|
653
|
+
ctrl: (_, ...param) => (e) => keys2.ctrl(e) && param.every((p) => keys2[p] ? keys2[p](e) : e.key === p),
|
|
654
|
+
shift: (_, ...param) => (e) => keys2.shift(e) && param.every((p) => keys2[p] ? keys2[p](e) : e.key === p),
|
|
655
|
+
alt: (_, ...param) => (e) => keys2.alt(e) && param.every((p) => keys2[p] ? keys2[p](e) : e.key === p),
|
|
656
|
+
meta: (_, ...param) => (e) => keys2.meta(e) && param.every((p) => keys2[p] ? keys2[p](e) : e.key === p),
|
|
657
|
+
arrow: () => keys2.arrow,
|
|
658
|
+
enter: () => keys2.enter,
|
|
659
|
+
escape: () => keys2.escape,
|
|
660
|
+
tab: () => keys2.tab,
|
|
661
|
+
space: () => keys2.space,
|
|
662
|
+
backspace: () => keys2.backspace,
|
|
663
|
+
delete: () => keys2.delete,
|
|
664
|
+
digit: () => keys2.digit,
|
|
665
|
+
letter: () => keys2.letter,
|
|
666
|
+
character: () => keys2.character
|
|
667
|
+
};
|
|
668
|
+
var keys2 = {
|
|
669
|
+
ctrl: (e) => e.ctrlKey || e.key === "Control" || e.key === "Ctrl",
|
|
670
|
+
shift: (e) => e.shiftKey || e.key === "Shift",
|
|
671
|
+
alt: (e) => e.altKey || e.key === "Alt",
|
|
672
|
+
meta: (e) => e.metaKey || e.key === "Meta" || e.key === "Command",
|
|
673
|
+
arrow: (e) => e.key.startsWith("Arrow"),
|
|
674
|
+
enter: (e) => e.key === "Enter",
|
|
675
|
+
escape: (e) => e.key.startsWith("Esc"),
|
|
676
|
+
tab: (e) => e.key === "Tab",
|
|
677
|
+
space: (e) => e.key === "\xA0" || e.key === "Space" || e.key === " ",
|
|
678
|
+
backspace: (e) => e.key === "Backspace",
|
|
679
|
+
delete: (e) => e.key === "Delete",
|
|
680
|
+
digit: (e) => /^\d$/.test(e.key),
|
|
681
|
+
letter: (e) => /^[a-zA-Z]$/.test(e.key),
|
|
682
|
+
character: (e) => /^\S$/.test(e.key)
|
|
683
|
+
};
|
|
684
|
+
var attr = (el, name, v) => {
|
|
685
|
+
if (v == null || v === false)
|
|
686
|
+
el.removeAttribute(name);
|
|
687
|
+
else
|
|
688
|
+
el.setAttribute(name, v === true ? "" : typeof v === "number" || typeof v === "string" ? v : "");
|
|
689
|
+
};
|
|
690
|
+
var throttle = (fn, limit) => {
|
|
691
|
+
let pause, planned, block = (e) => {
|
|
692
|
+
pause = true;
|
|
693
|
+
setTimeout(() => {
|
|
694
|
+
pause = false;
|
|
695
|
+
if (planned)
|
|
696
|
+
return planned = false, block(e), fn(e);
|
|
697
|
+
}, limit);
|
|
698
|
+
};
|
|
699
|
+
return (e) => {
|
|
700
|
+
if (pause)
|
|
701
|
+
return planned = true;
|
|
702
|
+
block(e);
|
|
703
|
+
return fn(e);
|
|
704
|
+
};
|
|
705
|
+
};
|
|
706
|
+
var debounce = (fn, wait) => {
|
|
707
|
+
let timeout;
|
|
708
|
+
return (e) => {
|
|
709
|
+
clearTimeout(timeout);
|
|
710
|
+
timeout = setTimeout(() => {
|
|
711
|
+
timeout = null;
|
|
712
|
+
fn(e);
|
|
713
|
+
}, wait);
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
var dashcase = (str) => {
|
|
717
|
+
return str.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (match) => "-" + match.toLowerCase());
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
// directive/value.js
|
|
721
|
+
directive.value = (el, expr2, state) => {
|
|
722
|
+
let evaluate = compile2(expr2, "value");
|
|
723
|
+
let from, to;
|
|
724
|
+
let update = el.type === "text" || el.type === "" ? (value) => el.setAttribute("value", el.value = value == null ? "" : value) : el.tagName === "TEXTAREA" || el.type === "text" || el.type === "" ? (value) => (from = el.selectionStart, to = el.selectionEnd, el.setAttribute("value", el.value = value == null ? "" : value), from && el.setSelectionRange(from, to)) : el.type === "checkbox" ? (value) => (el.checked = value, attr(el, "checked", value)) : el.type === "select-one" ? (value) => {
|
|
725
|
+
for (let option in el.options)
|
|
726
|
+
option.removeAttribute("selected");
|
|
727
|
+
el.value = value;
|
|
728
|
+
el.selectedOptions[0]?.setAttribute("selected", "");
|
|
729
|
+
} : (value) => el.value = value;
|
|
730
|
+
return () => update(evaluate(state)?.valueOf?.());
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// directive/fx.js
|
|
734
|
+
directive.fx = (el, expr2, state, name) => {
|
|
735
|
+
let evaluate = compile2(expr2, name);
|
|
736
|
+
return () => evaluate(state);
|
|
737
|
+
};
|
|
738
|
+
export {
|
|
739
|
+
batch2 as batch,
|
|
740
|
+
compile2 as compile,
|
|
741
|
+
computed2 as computed,
|
|
742
|
+
sprae as default,
|
|
743
|
+
directive,
|
|
744
|
+
effect2 as effect,
|
|
745
|
+
ipol,
|
|
746
|
+
signal2 as signal,
|
|
747
|
+
swap2 as swap,
|
|
748
|
+
untracked2 as untracked
|
|
749
|
+
};
|