@ktjs/core 0.37.8 → 0.38.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 +9 -6
- package/dist/index.d.ts +49 -30
- package/dist/index.mjs +162 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,17 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
## Recent Updates
|
|
19
19
|
|
|
20
|
-
1. 0.
|
|
20
|
+
1. 0.38.x - reactive helper additions
|
|
21
|
+
1. `reactive.is(target)`: create a boolean computed based on `Object.is` comparison.
|
|
22
|
+
2. `reactive.match(pattern)`: create a boolean computed using deep object/array pattern matching.
|
|
23
|
+
2. 0.37.x - fixes and refactors
|
|
21
24
|
1. fix schedulers clear issue. Which would occur when some handler throws an error.
|
|
22
25
|
2. `Fragment` is refactored. Fixes memory leak issues and makes it more robust.
|
|
23
|
-
|
|
26
|
+
3. 0.36.x - override 0.35.x. Now refs and computeds have 2 new apis:
|
|
24
27
|
1. `get(...keys)`: create a `KTSubComputed` object. It is a light version of computed, used to bind values
|
|
25
28
|
2. `subref(...keys)`: create a `KTSubRef` object. It is a light version of ref, used to bind values and also support two-way binding with `k-model`.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
4. 0.34.x - `ref.notify()` no-longer has an optional argument.
|
|
30
|
+
5. 0.33.x - `ref.value` remains the standard read API, and it can also replace the whole outer value with `ref.value = nextValue`.
|
|
31
|
+
6. 0.33.x - `ref.draft` is the deep-mutation entry for literally any objects. Just use `someRef.draft.a = someValue`, and kt.js will add it to microqueue and redraw it on the next tick. Works for `Map`, `Set`, `Array`, `Date` and your custom objects.
|
|
29
32
|
1. `ref.draft` itself is **not assignable**.
|
|
30
|
-
|
|
33
|
+
7. `addOnChange((newValue, oldValue) => ...)` keeps `oldValue` as the previous reference, not a deep snapshot.
|
|
31
34
|
|
|
32
35
|
## Community
|
|
33
36
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,50 +3,48 @@ export { HTMLTag, InputElementTag, MathMLTag, SVGTag } from '@ktjs/shared';
|
|
|
3
3
|
|
|
4
4
|
declare class KTComputed<T> extends KTReactive<T> {
|
|
5
5
|
readonly ktype = KTReactiveType.Computed;
|
|
6
|
-
private readonly _calculator;
|
|
7
|
-
private readonly _dependencies;
|
|
8
|
-
private readonly _recalculateListener;
|
|
9
6
|
private _disposed;
|
|
10
7
|
private _recalculate;
|
|
11
8
|
constructor(calculator: () => T, dependencies: Array<KTReactiveLike<any>>);
|
|
12
9
|
notify(): this;
|
|
13
|
-
dispose():
|
|
10
|
+
dispose(): void;
|
|
14
11
|
}
|
|
15
|
-
declare class KTSubComputed<T> extends KTSubReactive<T> {
|
|
16
|
-
readonly ktype = KTReactiveType.SubComputed;
|
|
17
|
-
}
|
|
18
|
-
type KTComputedLike<T> = KTComputed<T> | KTSubComputed<T>;
|
|
19
12
|
/**
|
|
20
13
|
* Create a computed value that automatically updates when its dependencies change.
|
|
21
14
|
* @param calculator synchronous function that calculates the value of the computed. It should not have side effects.
|
|
22
15
|
* @param dependencies an array of reactive dependencies that the computed value depends on. The computed value will automatically update when any of these dependencies change.
|
|
23
16
|
*/
|
|
24
17
|
declare const computed: <T>(calculator: () => T, dependencies: Array<KTReactiveLike<any>>) => KTComputed<T>;
|
|
18
|
+
declare class KTSubComputed<T> extends KTSubReactive<T> {
|
|
19
|
+
readonly ktype = KTReactiveType.SubComputed;
|
|
20
|
+
constructor(source: KTReactive<any>, getter: (sv: KTReactive<any>['value']) => T, dependency?: KTReactive<any>);
|
|
21
|
+
get value(): T;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
type KTComputedLike<T> = KTComputed<T> | KTSubComputed<T>;
|
|
25
25
|
|
|
26
26
|
type ChangeHandler<T> = (newValue: T, oldValue: T) => void;
|
|
27
27
|
declare const enum KTReactiveType {
|
|
28
|
-
|
|
28
|
+
Pseudo = 1,
|
|
29
29
|
Ref = 2,
|
|
30
30
|
SubRef = 4,
|
|
31
31
|
RefLike = 6,
|
|
32
32
|
Computed = 8,
|
|
33
33
|
SubComputed = 16,
|
|
34
34
|
ComputedLike = 24,
|
|
35
|
-
Reactive = 10
|
|
35
|
+
Reactive = 10,
|
|
36
|
+
SubReactive = 20,
|
|
37
|
+
ReactiveLike = 31
|
|
36
38
|
}
|
|
39
|
+
declare const nextKid: () => number;
|
|
40
|
+
declare const nextHandlerId: (kid: number) => string;
|
|
37
41
|
declare abstract class KTReactiveLike<T> {
|
|
38
42
|
readonly kid: number;
|
|
39
43
|
abstract readonly ktype: KTReactiveType;
|
|
40
44
|
abstract get value(): T;
|
|
41
45
|
abstract addOnChange(handler: ChangeHandler<T>, key?: any): this;
|
|
42
46
|
abstract removeOnChange(key: any): this;
|
|
43
|
-
|
|
44
|
-
* Create a computed value via current reactive value.
|
|
45
|
-
* - No matter `this` is added to `dependencies` or not, it is always listened.
|
|
46
|
-
* @param calculator A function that generates a new value based on current value.
|
|
47
|
-
* @param dependencies optional other dependencies that the computed value depends on.
|
|
48
|
-
*/
|
|
49
|
-
map<U>(calculator: (value: T) => U, dependencies?: Array<KTReactiveLike<any>>): KTComputed<U>;
|
|
47
|
+
abstract dispose(): void;
|
|
50
48
|
}
|
|
51
49
|
declare abstract class KTReactive<T> extends KTReactiveLike<T> {
|
|
52
50
|
constructor(value: T);
|
|
@@ -56,6 +54,25 @@ declare abstract class KTReactive<T> extends KTReactiveLike<T> {
|
|
|
56
54
|
removeOnChange(key: any): this;
|
|
57
55
|
clearOnChange(): this;
|
|
58
56
|
notify(): this;
|
|
57
|
+
/**
|
|
58
|
+
* Create a computed value via current reactive value.
|
|
59
|
+
* - No matter `this` is added to `dependencies` or not, it is always listened.
|
|
60
|
+
* @param calculator A function that generates a new value based on current value.
|
|
61
|
+
* @param dependencies optional other dependencies that the computed value depends on.
|
|
62
|
+
*/
|
|
63
|
+
map<U>(calculator: (value: T) => U, dependencies?: Array<KTReactiveLike<any>>): KTComputed<U>;
|
|
64
|
+
/**
|
|
65
|
+
* Make a computed value that checks if the reactive value is strictly equal to a specific value.
|
|
66
|
+
* - Use `Object.is` for comparison.
|
|
67
|
+
* - if `o` is reactive-like, it will be added to dependencies
|
|
68
|
+
*/
|
|
69
|
+
is(o: T | KTReactiveLike<T>): KTSubComputed<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Make a computed value that checks if the reactive value matches a specific object structure.
|
|
72
|
+
* - Deeply match.
|
|
73
|
+
* - if `o` is reactive-like, it will be added to dependencies
|
|
74
|
+
*/
|
|
75
|
+
match(o: object | KTReactiveLike<object>): KTSubComputed<boolean>;
|
|
59
76
|
/**
|
|
60
77
|
* Generate a sub-computed value based on this reactive, using keys to access nested properties.
|
|
61
78
|
* - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.
|
|
@@ -89,11 +106,10 @@ declare abstract class KTReactive<T> extends KTReactiveLike<T> {
|
|
|
89
106
|
}
|
|
90
107
|
declare abstract class KTSubReactive<T> extends KTReactiveLike<T> {
|
|
91
108
|
readonly source: KTReactive<any>;
|
|
92
|
-
constructor(source: KTReactive<any>,
|
|
93
|
-
get value(): T;
|
|
109
|
+
constructor(source: KTReactive<any>, getter: (sv: KTReactive<any>['value']) => T);
|
|
94
110
|
addOnChange(handler: ChangeHandler<T>, key?: any): this;
|
|
95
111
|
removeOnChange(key: any): this;
|
|
96
|
-
|
|
112
|
+
dispose(): void;
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
declare class KTRef<T> extends KTReactive<T> {
|
|
@@ -137,15 +153,7 @@ declare class KTRef<T> extends KTReactive<T> {
|
|
|
137
153
|
* - `KTSubRef` is lighter than `KTRef`.
|
|
138
154
|
*/
|
|
139
155
|
subref<K0 extends keyof T>(key0: K0): KTSubRef<T[K0]>;
|
|
140
|
-
|
|
141
|
-
declare class KTSubRef<T> extends KTSubReactive<T> {
|
|
142
|
-
readonly ktype = KTReactiveType.SubRef;
|
|
143
|
-
readonly source: KTRef<any>;
|
|
144
|
-
constructor(source: KTRef<any>, paths: string);
|
|
145
|
-
get value(): T;
|
|
146
|
-
set value(newValue: T);
|
|
147
|
-
get draft(): T;
|
|
148
|
-
notify(): this;
|
|
156
|
+
dispose(): void;
|
|
149
157
|
}
|
|
150
158
|
/**
|
|
151
159
|
* Create a reactive reference to a value. The returned object has a single property `value` that holds the internal value.
|
|
@@ -157,6 +165,17 @@ declare const ref: <T>(value?: T) => KTRef<T>;
|
|
|
157
165
|
*/
|
|
158
166
|
declare const assertModel: <T = any>(props: any, defaultValue?: T) => KTRefLike<T>;
|
|
159
167
|
type KTRefLike<T> = KTRef<T> | KTSubRef<T>;
|
|
168
|
+
declare class KTSubRef<T> extends KTSubReactive<T> {
|
|
169
|
+
readonly ktype = KTReactiveType.SubRef;
|
|
170
|
+
readonly source: KTRef<any>;
|
|
171
|
+
constructor(source: KTRef<any>, getter: (sv: KTReactive<any>['value']) => T, setter: (s: object, newValue: T) => void);
|
|
172
|
+
get value(): T;
|
|
173
|
+
set value(newValue: T);
|
|
174
|
+
/**
|
|
175
|
+
* Only use it for object's nested properties.
|
|
176
|
+
*/
|
|
177
|
+
get draft(): T;
|
|
178
|
+
}
|
|
160
179
|
|
|
161
180
|
/**
|
|
162
181
|
* Makes `KTReactify<'a' | 'b'> to be KTReactiveLike<'a'> | KTReactiveLike<'b'>`
|
|
@@ -1555,5 +1574,5 @@ declare function KTFor<T>(props: KTForProps<T>): KTForElement;
|
|
|
1555
1574
|
|
|
1556
1575
|
declare function KTConditional(condition: any | KTReactiveLike<any>, tagIf: JSXTag, propsIf: KTAttribute, tagElse?: JSXTag, propsElse?: KTAttribute): Element;
|
|
1557
1576
|
|
|
1558
|
-
export { Fragment, JSX, KTAsync, KTComputed, KTConditional, KTFor, KTReactive, KTReactiveLike, KTReactiveType, KTRef, KTSubComputed, KTSubReactive, KTSubRef, applyAttr, assertModel, computed, h as createElement, mathml$1 as createMathMLElement, svg$1 as createSVGElement, dereactive, effect, h, isComputed, isComputedLike, isKT, isReactive, isReactiveLike, isRef, isRefLike, isSubComputed, isSubRef, jsx, jsxDEV, jsxs, mathml, mathml as mathmlRuntime, ref, svg, svg as svgRuntime, toReactive };
|
|
1577
|
+
export { Fragment, JSX, KTAsync, KTComputed, KTConditional, KTFor, KTReactive, KTReactiveLike, KTReactiveType, KTRef, KTSubComputed, KTSubReactive, KTSubRef, applyAttr, assertModel, computed, h as createElement, mathml$1 as createMathMLElement, svg$1 as createSVGElement, dereactive, effect, h, isComputed, isComputedLike, isKT, isReactive, isReactiveLike, isRef, isRefLike, isSubComputed, isSubRef, jsx, jsxDEV, jsxs, mathml, mathml as mathmlRuntime, nextHandlerId, nextKid, ref, svg, svg as svgRuntime, toReactive };
|
|
1559
1578
|
export type { AliasElement, ChangeHandler, EventHandler, HTML, KTAttribute, KTComputedLike, KTForElement, KTForProps, KTMaybeReactive, KTMaybeReactiveProps, KTPrefixedEventAttribute, KTRawAttr, KTRawContent, KTRawContents, KTReactify, KTReactifyObject, KTReactifyProps, KTReactifySplit, KTRefLike };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $isArray, $isThenable, $isNode, $stringify, $is, $emptyFn, $forEach, $identity } from "@ktjs/shared";
|
|
1
|
+
import { $isArray, $isThenable, $isNode, $stringify, $is, $emptyFn, $deepMatch, $forEach, $identity } from "@ktjs/shared";
|
|
2
2
|
|
|
3
3
|
function isKT(obj) {
|
|
4
4
|
return "number" == typeof obj?.kid;
|
|
@@ -36,7 +36,35 @@ function isReactive(obj) {
|
|
|
36
36
|
return "number" == typeof obj?.ktype && !!(10 & obj.ktype);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
function isSubReactive(obj) {
|
|
40
|
+
return "number" == typeof obj?.ktype && !!(20 & obj.ktype);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const $createSubGetter = path => {
|
|
44
|
+
switch (path.length) {
|
|
45
|
+
case 1:
|
|
46
|
+
return s => s[path[0]];
|
|
47
|
+
|
|
48
|
+
case 2:
|
|
49
|
+
return s => s[path[0]][path[1]];
|
|
50
|
+
|
|
51
|
+
case 3:
|
|
52
|
+
return s => s[path[0]][path[1]][path[2]];
|
|
53
|
+
|
|
54
|
+
case 4:
|
|
55
|
+
return s => s[path[0]][path[1]][path[2]][path[3]];
|
|
56
|
+
|
|
57
|
+
case 5:
|
|
58
|
+
return s => s[path[0]][path[1]][path[2]][path[3]][path[4]];
|
|
59
|
+
|
|
60
|
+
default:
|
|
61
|
+
return s => {
|
|
62
|
+
let r = s[path[0]][path[1]][path[2]][path[3]][path[4]];
|
|
63
|
+
for (let i = 5; i < path.length; i++) r = r[path[i]];
|
|
64
|
+
return r;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
40
68
|
|
|
41
69
|
class KTAnchor extends Comment {
|
|
42
70
|
isKTAnchor=!0;
|
|
@@ -92,7 +120,7 @@ const $cleanupRemovedNode = node => {
|
|
|
92
120
|
for (let i = cleanups.length - 1; i >= 0; i--) try {
|
|
93
121
|
cleanups[i]();
|
|
94
122
|
} catch (error) {
|
|
95
|
-
console.error("[
|
|
123
|
+
console.error("[kt.js error]", "KTNodeCleanup:", error);
|
|
96
124
|
}
|
|
97
125
|
}
|
|
98
126
|
}, $addNodeCleanup = (node, cleanup) => {
|
|
@@ -146,7 +174,7 @@ const $cleanupRemovedNode = node => {
|
|
|
146
174
|
|
|
147
175
|
function applyAttr(element, attr) {
|
|
148
176
|
if (attr) {
|
|
149
|
-
if ("object" != typeof attr || null === attr) throw new Error("[
|
|
177
|
+
if ("object" != typeof attr || null === attr) throw new Error("[kt.js error] attr must be an object.");
|
|
150
178
|
!function(element, attr) {
|
|
151
179
|
const classValue = attr.class || attr.className;
|
|
152
180
|
void 0 !== classValue && (isKT(classValue) ? (element.setAttribute("class", classValue.value),
|
|
@@ -217,7 +245,7 @@ function applyContent(element, content) {
|
|
|
217
245
|
}
|
|
218
246
|
|
|
219
247
|
function applyKModel(element, valueRef) {
|
|
220
|
-
if (!isRefLike(valueRef)) throw new Error("[
|
|
248
|
+
if (!isRefLike(valueRef)) throw new Error("[kt.js error] k-model value must be a KTRefLike.");
|
|
221
249
|
if ("INPUT" !== element.tagName) {
|
|
222
250
|
if ("SELECT" === element.tagName || "TEXTAREA" === element.tagName) {
|
|
223
251
|
element.value = valueRef.value ?? "";
|
|
@@ -226,7 +254,7 @@ function applyKModel(element, valueRef) {
|
|
|
226
254
|
$addNodeCleanup(element, () => element.removeEventListener("change", onChange)),
|
|
227
255
|
void $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));
|
|
228
256
|
}
|
|
229
|
-
console.warn("[
|
|
257
|
+
console.warn("[kt.js warn]", "not supported element for k-model:");
|
|
230
258
|
} else if ("radio" === element.type || "checkbox" === element.type) {
|
|
231
259
|
element.checked = Boolean(valueRef.value);
|
|
232
260
|
const onChange = () => valueRef.value = element.checked, onValueChange = newValue => element.checked = newValue;
|
|
@@ -251,24 +279,24 @@ function applyKModel(element, valueRef) {
|
|
|
251
279
|
* ## About
|
|
252
280
|
* @package @ktjs/core
|
|
253
281
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
254
|
-
* @version 0.
|
|
282
|
+
* @version 0.38.0 (Last Update: 2026.04.07 15:29:51.995)
|
|
255
283
|
* @license MIT
|
|
256
284
|
* @link https://github.com/baendlorel/kt.js
|
|
257
285
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
258
286
|
* @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
|
|
259
287
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
260
288
|
*/ const h = (tag, attr, content) => {
|
|
261
|
-
if ("string" != typeof tag) throw new Error("[
|
|
289
|
+
if ("string" != typeof tag) throw new Error("[kt.js error] tagName must be a string.");
|
|
262
290
|
const element = document.createElement(tag);
|
|
263
291
|
return "object" == typeof attr && null !== attr && "k-model" in attr && applyKModel(element, attr["k-model"]),
|
|
264
292
|
applyAttr(element, attr), applyContent(element, content), element;
|
|
265
293
|
}, svg$1 = (tag, attr, content) => {
|
|
266
|
-
if ("string" != typeof tag) throw new Error("[
|
|
294
|
+
if ("string" != typeof tag) throw new Error("[kt.js error] tagName must be a string.");
|
|
267
295
|
const element = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
268
296
|
return applyAttr(element, attr), applyContent(element, content), "object" == typeof attr && null !== attr && "k-model" in attr && applyKModel(element, attr["k-model"]),
|
|
269
297
|
element;
|
|
270
298
|
}, mathml$1 = (tag, attr, content) => {
|
|
271
|
-
if ("string" != typeof tag) throw new Error("[
|
|
299
|
+
if ("string" != typeof tag) throw new Error("[kt.js error] tagName must be a string.");
|
|
272
300
|
const element = document.createElementNS("http://www.w3.org/1998/Math/MathML", tag);
|
|
273
301
|
return applyAttr(element, attr), applyContent(element, content), "object" == typeof attr && null !== attr && "k-model" in attr && applyKModel(element, attr["k-model"]),
|
|
274
302
|
element;
|
|
@@ -276,11 +304,10 @@ function applyKModel(element, valueRef) {
|
|
|
276
304
|
|
|
277
305
|
let kid = 1, handlerId = 1;
|
|
278
306
|
|
|
307
|
+
const nextHandlerId = kid => `@@k-handler-${kid}-${handlerId++}`;
|
|
308
|
+
|
|
279
309
|
class KTReactiveLike {
|
|
280
|
-
kid=kid
|
|
281
|
-
map(calculator, dependencies) {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
310
|
+
kid=(() => kid++)();
|
|
284
311
|
}
|
|
285
312
|
|
|
286
313
|
class KTReactive extends KTReactiveLike {
|
|
@@ -293,13 +320,13 @@ class KTReactive extends KTReactiveLike {
|
|
|
293
320
|
return this._value;
|
|
294
321
|
}
|
|
295
322
|
set value(_newValue) {
|
|
296
|
-
console.warn("[
|
|
323
|
+
console.warn("[kt.js warn]", "Setting value to a non-ref instance takes no effect.");
|
|
297
324
|
}
|
|
298
325
|
_emit(newValue, oldValue) {
|
|
299
326
|
return this._changeHandlers.forEach(handler => handler(newValue, oldValue)), this;
|
|
300
327
|
}
|
|
301
|
-
addOnChange(handler, key) {
|
|
302
|
-
if (
|
|
328
|
+
addOnChange(handler, key = nextHandlerId(this.kid)) {
|
|
329
|
+
if (this._changeHandlers.has(key)) throw new Error(`[kt.js error] Overriding existing change handler with key ${$stringify(key)}.`);
|
|
303
330
|
return this._changeHandlers.set(key, handler), this;
|
|
304
331
|
}
|
|
305
332
|
removeOnChange(key) {
|
|
@@ -311,6 +338,15 @@ class KTReactive extends KTReactiveLike {
|
|
|
311
338
|
notify() {
|
|
312
339
|
return this._emit(this._value, this._value);
|
|
313
340
|
}
|
|
341
|
+
map(calculator, dependencies) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
is(o) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
match(o) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
314
350
|
get(..._keys) {
|
|
315
351
|
return null;
|
|
316
352
|
}
|
|
@@ -318,31 +354,24 @@ class KTReactive extends KTReactiveLike {
|
|
|
318
354
|
|
|
319
355
|
class KTSubReactive extends KTReactiveLike {
|
|
320
356
|
source;
|
|
357
|
+
_value;
|
|
321
358
|
_getter;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
get value() {
|
|
333
|
-
return this._getter(this.source._value);
|
|
334
|
-
}
|
|
335
|
-
addOnChange(handler, key) {
|
|
336
|
-
return this.source.addOnChange((newSourceValue, oldSourceValue) => {
|
|
337
|
-
const oldValue = this._getter(oldSourceValue), newValue = this._getter(newSourceValue);
|
|
338
|
-
handler(newValue, oldValue);
|
|
339
|
-
}, key), this;
|
|
359
|
+
_handler;
|
|
360
|
+
_handlerKeys;
|
|
361
|
+
constructor(source, getter) {
|
|
362
|
+
super(), this.source = source, this._getter = getter, this._handlerKeys = [], this._value = this._getter(source._value),
|
|
363
|
+
this._handler = () => this._value = getter(source._value), this._handlerKeys.push(nextHandlerId(this.kid)),
|
|
364
|
+
source.addOnChange(this._handler, this._handlerKeys[0]);
|
|
365
|
+
}
|
|
366
|
+
addOnChange(handler, key = nextHandlerId(this.kid)) {
|
|
367
|
+
return this._handlerKeys.push(key), this.source.addOnChange((newValue, oldValue) => handler(this._getter(newValue), this._getter(oldValue)), key),
|
|
368
|
+
this;
|
|
340
369
|
}
|
|
341
370
|
removeOnChange(key) {
|
|
342
371
|
return this.source.removeOnChange(key), this;
|
|
343
372
|
}
|
|
344
|
-
|
|
345
|
-
|
|
373
|
+
dispose() {
|
|
374
|
+
this._handlerKeys.forEach(key => this.source.removeOnChange(key));
|
|
346
375
|
}
|
|
347
376
|
}
|
|
348
377
|
|
|
@@ -350,7 +379,7 @@ const reactiveToOldValue = new Map;
|
|
|
350
379
|
|
|
351
380
|
let scheduled = !1;
|
|
352
381
|
|
|
353
|
-
const markMutation = reactive => {
|
|
382
|
+
const $markMutation = reactive => {
|
|
354
383
|
if (!reactiveToOldValue.has(reactive)) {
|
|
355
384
|
if (reactiveToOldValue.set(reactive, reactive._value), scheduled) return;
|
|
356
385
|
scheduled = !0, Promise.resolve().then(() => {
|
|
@@ -358,7 +387,7 @@ const markMutation = reactive => {
|
|
|
358
387
|
try {
|
|
359
388
|
reactive._changeHandlers.forEach(handler => handler(reactive.value, oldValue));
|
|
360
389
|
} catch (error) {
|
|
361
|
-
console.error("[
|
|
390
|
+
console.error("[kt.js error]", "KTScheduler:", error);
|
|
362
391
|
}
|
|
363
392
|
}), reactiveToOldValue.clear();
|
|
364
393
|
});
|
|
@@ -379,41 +408,41 @@ class KTRef extends KTReactive {
|
|
|
379
408
|
this._value = newValue, this._emit(newValue, oldValue);
|
|
380
409
|
}
|
|
381
410
|
get draft() {
|
|
382
|
-
return markMutation(this), this._value;
|
|
411
|
+
return $markMutation(this), this._value;
|
|
383
412
|
}
|
|
384
413
|
notify() {
|
|
385
414
|
return this._emit(this._value, this._value);
|
|
386
415
|
}
|
|
387
416
|
subref(...keys) {
|
|
388
|
-
if (0 === keys.length) throw new Error("[
|
|
389
|
-
return new KTSubRef(this, keys
|
|
390
|
-
|
|
391
|
-
|
|
417
|
+
if (0 === keys.length) throw new Error("[kt.js error] At least one key is required to get a sub-ref.");
|
|
418
|
+
return new KTSubRef(this, $createSubGetter(keys), (path => {
|
|
419
|
+
switch (path.length) {
|
|
420
|
+
case 1:
|
|
421
|
+
return (s, newValue) => s[path[0]] = newValue;
|
|
392
422
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
423
|
+
case 2:
|
|
424
|
+
return (s, newValue) => s[path[0]][path[1]] = newValue;
|
|
425
|
+
|
|
426
|
+
case 3:
|
|
427
|
+
return (s, newValue) => s[path[0]][path[1]][path[2]] = newValue;
|
|
428
|
+
|
|
429
|
+
case 4:
|
|
430
|
+
return (s, newValue) => s[path[0]][path[1]][path[2]][path[3]] = newValue;
|
|
431
|
+
|
|
432
|
+
case 5:
|
|
433
|
+
return (s, newValue) => s[path[0]][path[1]][path[2]][path[3]][path[4]] = newValue;
|
|
434
|
+
|
|
435
|
+
default:
|
|
436
|
+
return (s, newValue) => {
|
|
437
|
+
let r = s[path[0]][path[1]][path[2]][path[3]][path[4]];
|
|
438
|
+
for (let i = 5; i < path.length - 1; i++) r = r[path[i]];
|
|
439
|
+
r[path[path.length - 1]] = newValue;
|
|
440
|
+
};
|
|
403
441
|
}
|
|
404
|
-
})(
|
|
405
|
-
}
|
|
406
|
-
get value() {
|
|
407
|
-
return this._getter(this.source._value);
|
|
408
|
-
}
|
|
409
|
-
set value(newValue) {
|
|
410
|
-
this._setter(this.source._value, newValue), this.source.notify();
|
|
411
|
-
}
|
|
412
|
-
get draft() {
|
|
413
|
-
return markMutation(this.source), this._getter(this.source._value);
|
|
442
|
+
})(keys));
|
|
414
443
|
}
|
|
415
|
-
|
|
416
|
-
|
|
444
|
+
dispose() {
|
|
445
|
+
this._changeHandlers.clear();
|
|
417
446
|
}
|
|
418
447
|
}
|
|
419
448
|
|
|
@@ -421,21 +450,39 @@ const ref = value => new KTRef(value), assertModel = (props, defaultValue) => {
|
|
|
421
450
|
if ("k-model" in props) {
|
|
422
451
|
const kmodel = props["k-model"];
|
|
423
452
|
if (isRefLike(kmodel)) return kmodel;
|
|
424
|
-
throw new Error("[
|
|
453
|
+
throw new Error("[kt.js error] k-model data must be a KTRef object, please use 'ref(...)' to wrap it.");
|
|
425
454
|
}
|
|
426
455
|
return ref(defaultValue);
|
|
427
456
|
}, $refSetter = (props, node) => props.ref.value = node, $initRef = (props, node) => {
|
|
428
457
|
if (!("ref" in props)) return $emptyFn;
|
|
429
458
|
const r = props.ref;
|
|
430
459
|
if (isRefLike(r)) return r.value = node, $refSetter;
|
|
431
|
-
throw new Error("[
|
|
460
|
+
throw new Error("[kt.js error] Fragment: ref must be a KTRef");
|
|
432
461
|
};
|
|
433
462
|
|
|
463
|
+
class KTSubRef extends KTSubReactive {
|
|
464
|
+
ktype=4;
|
|
465
|
+
_setter;
|
|
466
|
+
constructor(source, getter, setter) {
|
|
467
|
+
super(source, getter), this._setter = setter;
|
|
468
|
+
}
|
|
469
|
+
get value() {
|
|
470
|
+
return this._value;
|
|
471
|
+
}
|
|
472
|
+
set value(newValue) {
|
|
473
|
+
this._value = newValue, this._setter(this.source._value, newValue), this.source.notify();
|
|
474
|
+
}
|
|
475
|
+
get draft() {
|
|
476
|
+
return $markMutation(this.source), this._value;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
434
480
|
class KTComputed extends KTReactive {
|
|
435
481
|
ktype=8;
|
|
436
482
|
_calculator;
|
|
437
483
|
_dependencies;
|
|
438
|
-
|
|
484
|
+
_handler;
|
|
485
|
+
_handlerKeys;
|
|
439
486
|
_disposed=!1;
|
|
440
487
|
_recalculate(forced = !1) {
|
|
441
488
|
const newValue = this._calculator(), oldValue = this._value;
|
|
@@ -444,35 +491,60 @@ class KTComputed extends KTReactive {
|
|
|
444
491
|
}
|
|
445
492
|
constructor(calculator, dependencies) {
|
|
446
493
|
super(calculator()), this._calculator = calculator, this._dependencies = dependencies,
|
|
447
|
-
this.
|
|
448
|
-
|
|
494
|
+
this._handler = () => this._recalculate(), this._handlerKeys = dependencies.map(() => nextHandlerId(this.kid));
|
|
495
|
+
const uniqueSources = new Set;
|
|
496
|
+
for (let i = 0; i < dependencies.length; i++) {
|
|
497
|
+
const dep = dependencies[i];
|
|
498
|
+
if (isSubReactive(dep)) {
|
|
499
|
+
if (uniqueSources.has(dep.source)) continue;
|
|
500
|
+
uniqueSources.add(dep.source);
|
|
501
|
+
}
|
|
502
|
+
dep.addOnChange(this._handler, this._handlerKeys[i]);
|
|
503
|
+
}
|
|
504
|
+
uniqueSources.clear();
|
|
449
505
|
}
|
|
450
506
|
notify() {
|
|
451
507
|
return this._recalculate(!0);
|
|
452
508
|
}
|
|
453
509
|
dispose() {
|
|
454
|
-
if (this._disposed)
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
510
|
+
if (!this._disposed) {
|
|
511
|
+
this._disposed = !0;
|
|
512
|
+
for (let i = 0; i < this._dependencies.length; i++) this._dependencies[i].removeOnChange(this._handlerKeys[i]);
|
|
513
|
+
this._dependencies.length = 0, this._changeHandlers.clear();
|
|
514
|
+
}
|
|
458
515
|
}
|
|
459
516
|
}
|
|
460
517
|
|
|
461
|
-
|
|
518
|
+
KTReactive.prototype.map = function(c, dep) {
|
|
462
519
|
return new KTComputed(() => c(this.value), dep ? [ this, ...dep ] : [ this ]);
|
|
520
|
+
}, KTReactive.prototype.is = function(o) {
|
|
521
|
+
return isReactive(o) ? new KTSubComputed(this, v => $is(v, o.value), o) : new KTSubComputed(this, v => $is(v, o));
|
|
522
|
+
}, KTReactive.prototype.match = function(o) {
|
|
523
|
+
return isReactive(o) ? new KTSubComputed(this, v => $deepMatch(v, o.value), o) : new KTSubComputed(this, v => $deepMatch(v, o));
|
|
463
524
|
}, KTReactive.prototype.get = function(...keys) {
|
|
464
|
-
if (0 === keys.length) throw new Error("[
|
|
465
|
-
return new KTSubComputed(this,
|
|
525
|
+
if (0 === keys.length) throw new Error("[kt.js error] At least one key is required to get a sub-computed.");
|
|
526
|
+
return new KTSubComputed(this, $createSubGetter(keys));
|
|
466
527
|
};
|
|
467
528
|
|
|
529
|
+
const computed = (calculator, dependencies) => new KTComputed(calculator, dependencies);
|
|
530
|
+
|
|
468
531
|
class KTSubComputed extends KTSubReactive {
|
|
469
532
|
ktype=16;
|
|
533
|
+
_dependency;
|
|
534
|
+
constructor(source, getter, dependency) {
|
|
535
|
+
super(source, getter), this._dependency = dependency, dependency && (this._handlerKeys.push(nextHandlerId(this.kid)),
|
|
536
|
+
dependency.addOnChange(this._handler, this._handlerKeys[1]));
|
|
537
|
+
}
|
|
538
|
+
get value() {
|
|
539
|
+
return this._value;
|
|
540
|
+
}
|
|
541
|
+
dispose() {
|
|
542
|
+
this._handlerKeys.forEach(key => this.source.removeOnChange(key)), this._dependency?.removeOnChange(this._handlerKeys[1]);
|
|
543
|
+
}
|
|
470
544
|
}
|
|
471
545
|
|
|
472
|
-
const computed = (calculator, dependencies) => new KTComputed(calculator, dependencies);
|
|
473
|
-
|
|
474
546
|
function effect(effectFn, reactives, options) {
|
|
475
|
-
const {lazy: lazy = !1, onCleanup: onCleanup = $emptyFn, debugName: debugName = ""} = Object(options);
|
|
547
|
+
const {lazy: lazy = !1, onCleanup: onCleanup = $emptyFn, debugName: debugName = ""} = Object(options), listenerKeys = [];
|
|
476
548
|
let active = !0;
|
|
477
549
|
const run = () => {
|
|
478
550
|
if (active) {
|
|
@@ -480,11 +552,15 @@ function effect(effectFn, reactives, options) {
|
|
|
480
552
|
try {
|
|
481
553
|
effectFn();
|
|
482
554
|
} catch (err) {
|
|
483
|
-
console.debug("[
|
|
555
|
+
console.debug("[kt.js debug]", "effect error:", debugName, err);
|
|
484
556
|
}
|
|
485
557
|
}
|
|
486
558
|
};
|
|
487
|
-
for (let i = 0; i < reactives.length; i++)
|
|
559
|
+
for (let i = 0; i < reactives.length; i++) {
|
|
560
|
+
listenerKeys[i] = i;
|
|
561
|
+
const r = reactives[i];
|
|
562
|
+
isSubReactive(r) ? r.source._changeHandlers.set(listenerKeys[i], run) : r.addOnChange(run, effectFn);
|
|
563
|
+
}
|
|
488
564
|
return lazy || run(), () => {
|
|
489
565
|
if (active) {
|
|
490
566
|
active = !1;
|
|
@@ -514,7 +590,7 @@ class FragmentAnchor extends KTAnchor {
|
|
|
514
590
|
const jsxh = (tag, props) => "function" == typeof tag ? tag(props) : h(tag, props, props.children), placeholder = data => document.createComment(data);
|
|
515
591
|
|
|
516
592
|
function create(creator, tag, props) {
|
|
517
|
-
if (props.ref && isComputedLike(props.ref)) throw new Error("[
|
|
593
|
+
if (props.ref && isComputedLike(props.ref)) throw new Error("[kt.js error] Cannot assign a computed value to an element.");
|
|
518
594
|
const el = creator(tag, props, props.children);
|
|
519
595
|
return $initRef(props, el), el;
|
|
520
596
|
}
|
|
@@ -532,7 +608,7 @@ function Fragment(props) {
|
|
|
532
608
|
return span.textContent = String(child), void elements.push(span);
|
|
533
609
|
}
|
|
534
610
|
if (child instanceof Element) elements.push(child); else {
|
|
535
|
-
if (!isKT(child)) throw console.warn("[
|
|
611
|
+
if (!isKT(child)) throw console.warn("[kt.js warn]", "Fragment: unsupported child type", child),
|
|
536
612
|
new Error("Fragment: unsupported child type");
|
|
537
613
|
processChild(child.value);
|
|
538
614
|
}
|
|
@@ -581,7 +657,7 @@ class KTForAnchor extends KTAnchor {
|
|
|
581
657
|
}
|
|
582
658
|
|
|
583
659
|
const setForNodeMap = (nodeMap, key, node, index) => {
|
|
584
|
-
nodeMap.has(key) && console.error("[
|
|
660
|
+
nodeMap.has(key) && console.error("[kt.js error]", `[KTFor] Duplicate key detected at index ${index}. Later items override earlier ones. key=${String(key)}`),
|
|
585
661
|
nodeMap.set(key, node);
|
|
586
662
|
};
|
|
587
663
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/reactable/common.ts","../src/jsx/anchor.ts","../src/h/attr-helpers.ts","../src/h/attr.ts","../src/h/content.ts","../src/h/model.ts","../src/h/index.ts","../src/reactable/reactive.ts","../src/reactable/scheduler.ts","../src/reactable/ref.ts","../src/reactable/computed.ts","../src/reactable/effect.ts","../src/reactable/index.ts","../src/jsx/fragment.ts","../src/jsx/common.ts","../src/jsx/jsx-runtime.ts","../src/jsx/async.ts","../src/jsx/for.ts","../src/jsx/if.ts"],"sourcesContent":["import { KTReactiveLike, KTReactiveType, type KTReactive } from './reactive.js';\nimport type { KTRef, KTRefLike, KTSubRef } from './ref.js';\nimport type { KTComputed, KTComputedLike, KTSubComputed } from './computed.js';\n\n// # type guards\nexport function isKT<T = any>(obj: any): obj is KTReactiveLike<T> {\n return typeof obj?.kid === 'number';\n}\nexport function isReactiveLike<T = any>(obj: any): obj is KTReactiveLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.ReactiveLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isRef<T = any>(obj: any): obj is KTRef<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.Ref;\n } else {\n return false;\n }\n}\n\nexport function isSubRef<T = any>(obj: any): obj is KTSubRef<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.SubRef;\n } else {\n return false;\n }\n}\n\nexport function isRefLike<T = any>(obj: any): obj is KTRefLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.RefLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isComputed<T = any>(obj: any): obj is KTComputed<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.Computed;\n } else {\n return false;\n }\n}\n\nexport function isSubComputed<T = any>(obj: any): obj is KTSubComputed<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.SubComputed;\n } else {\n return false;\n }\n}\n\nexport function isComputedLike<T = any>(obj: any): obj is KTComputedLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.ComputedLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isReactive<T = any>(obj: any): obj is KTReactive<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.Reactive) !== 0;\n } else {\n return false;\n }\n}\n\n// # sub getter/setter factory\n\ntype SubGetter = (s: any) => any;\ntype SubSetter = (s: any, newValue: any) => void;\nconst _getters = new Map<string, SubGetter>();\nconst _setters = new Map<string, SubSetter>();\n\nexport const $createSubGetter = (path: string): SubGetter => {\n const exist = _getters.get(path);\n if (exist) {\n return exist;\n } else {\n const cache = new Function('s', `return s${path}`) as SubGetter;\n _getters.set(path, cache);\n return cache;\n }\n};\n\nexport const $createSubSetter = (path: string): SubSetter => {\n const exist = _setters.get(path);\n if (exist) {\n return exist;\n } else {\n const cache = new Function('s', 'v', `s${path}=v`) as SubSetter;\n _setters.set(path, cache);\n return cache;\n }\n};\n","export const enum AnchorType {\n Fragment = 'kt-fragment',\n For = 'kt-for',\n}\n\nexport abstract class KTAnchor<T extends Node = Node> extends Comment {\n readonly isKTAnchor: true = true;\n readonly list: T[] = [];\n abstract readonly type: AnchorType;\n mountCallback?: () => void;\n\n constructor(data: AnchorType) {\n super(data);\n $ensureAnchorObserver();\n }\n\n mount(parent?: Node) {\n if (parent && this.parentNode !== parent) {\n parent.appendChild(this);\n }\n if (this.parentNode) {\n this.mountCallback?.();\n }\n }\n}\n\ntype MountableKTAnchor = Node & {\n isKTAnchor?: true;\n mount?: (parent?: Node) => void;\n};\ntype NodeCleanup = () => void;\n\nconst CANNOT_MOUNT = typeof document === 'undefined' || typeof Node === 'undefined';\nconst CANNOT_OBSERVE = CANNOT_MOUNT || typeof MutationObserver === 'undefined';\nconst COMMENT_FILTER = typeof NodeFilter === 'undefined' ? 0x80 : NodeFilter.SHOW_COMMENT;\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\nconst nodeToCleanups = new WeakMap<Node, NodeCleanup[]>();\nlet anchorObserver: MutationObserver | undefined;\n\nconst $cleanupRemovedNode = (node: Node) => {\n if (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n const children = Array.from(node.childNodes);\n for (let i = 0; i < children.length; i++) {\n $cleanupRemovedNode(children[i]);\n }\n }\n\n const anchor = node as KTAnchor<Node>;\n if (anchor.isKTAnchor === true) {\n const list = anchor.list.slice();\n anchor.list.length = 0;\n for (let i = 0; i < list.length; i++) {\n const listNode = list[i] as ChildNode;\n if (listNode.parentNode) {\n listNode.remove();\n }\n $cleanupRemovedNode(listNode);\n }\n }\n\n $runNodeCleanups(node);\n};\n\nconst $ensureAnchorObserver = () => {\n if (CANNOT_OBSERVE || anchorObserver || !document.body) {\n return;\n }\n\n anchorObserver = new MutationObserver((records) => {\n if (typeof document === 'undefined') {\n anchorObserver?.disconnect();\n anchorObserver = undefined;\n return;\n }\n\n for (let i = 0; i < records.length; i++) {\n const addedNodes = records[i].addedNodes;\n for (let j = 0; j < addedNodes.length; j++) {\n $mountFragmentAnchors(addedNodes[j]);\n }\n\n const removedNodes = records[i].removedNodes;\n for (let j = 0; j < removedNodes.length; j++) {\n $cleanupRemovedNode(removedNodes[j]);\n }\n }\n });\n anchorObserver.observe(document.body, { childList: true, subtree: true });\n};\n\nconst $mountIfFragmentAnchor = (node: Node) => {\n const anchor = node as MountableKTAnchor;\n if (anchor.isKTAnchor === true && typeof anchor.mount === 'function') {\n anchor.mount();\n }\n};\n\nconst $runNodeCleanups = (node: Node) => {\n const cleanups = nodeToCleanups.get(node);\n if (!cleanups) {\n return;\n }\n\n nodeToCleanups.delete(node);\n for (let i = cleanups.length - 1; i >= 0; i--) {\n try {\n cleanups[i]();\n } catch (error) {\n $error('KTNodeCleanup:', error);\n }\n }\n};\n\nexport const $addNodeCleanup = (node: Node, cleanup: NodeCleanup) => {\n $ensureAnchorObserver();\n const cleanups = nodeToCleanups.get(node);\n if (cleanups) {\n cleanups.push(cleanup);\n } else {\n nodeToCleanups.set(node, [cleanup]);\n }\n return cleanup;\n};\n\nexport const $removeNodeCleanup = (node: Node, cleanup: NodeCleanup) => {\n const cleanups = nodeToCleanups.get(node);\n if (!cleanups) {\n return;\n }\n\n const index = cleanups.indexOf(cleanup);\n if (index === -1) {\n return;\n }\n\n cleanups.splice(index, 1);\n if (cleanups.length === 0) {\n nodeToCleanups.delete(node);\n }\n};\n\nexport const $mountFragmentAnchors = (node: unknown) => {\n if (CANNOT_MOUNT || typeof document === 'undefined' || !node || typeof (node as any).nodeType !== 'number') {\n return;\n }\n\n const nodeObj = node as Node;\n $mountIfFragmentAnchor(nodeObj);\n\n if (nodeObj.nodeType !== ELEMENT_NODE && nodeObj.nodeType !== DOCUMENT_FRAGMENT_NODE) {\n return;\n }\n\n const walker = document.createTreeWalker(nodeObj, COMMENT_FILTER);\n let current = walker.nextNode();\n while (current) {\n $mountIfFragmentAnchor(current);\n current = walker.nextNode();\n }\n};\n","const booleanHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => {\n if (key in element) {\n (element as any)[key] = !!value;\n } else {\n element.setAttribute(key, value);\n }\n};\n\nconst valueHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => {\n if (key in element) {\n (element as any)[key] = value;\n } else {\n element.setAttribute(key, value);\n }\n};\n\n// Attribute handlers map for optimized lookup\nexport const handlers: Record<\n string,\n (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => void\n> = {\n checked: booleanHandler,\n selected: booleanHandler,\n value: valueHandler,\n valueAsDate: valueHandler,\n valueAsNumber: valueHandler,\n defaultValue: valueHandler,\n defaultChecked: booleanHandler,\n defaultSelected: booleanHandler,\n disabled: booleanHandler,\n readOnly: booleanHandler,\n multiple: booleanHandler,\n required: booleanHandler,\n autofocus: booleanHandler,\n open: booleanHandler,\n controls: booleanHandler,\n autoplay: booleanHandler,\n loop: booleanHandler,\n muted: booleanHandler,\n defer: booleanHandler,\n async: booleanHandler,\n hidden: (element, _key, value) => ((element as HTMLElement).hidden = !!value),\n};\n","import type { KTReactifyProps } from '../reactable/types.js';\nimport type { KTRawAttr, KTAttribute } from '../types/h.js';\nimport { isKT } from '../reactable/common.js';\nimport { $addNodeCleanup } from '../jsx/anchor.js';\nimport { handlers } from './attr-helpers.js';\n\nconst defaultHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) =>\n element.setAttribute(key, value);\n\nconst setElementStyle = (\n element: HTMLElement | SVGElement | MathMLElement,\n style: Partial<CSSStyleDeclaration> | string,\n) => {\n if (typeof style === 'string') {\n (element as HTMLElement).style.cssText = style;\n return;\n }\n\n for (const key in style) {\n (element as any).style[key as any] = style[key];\n }\n};\n\nconst addReactiveCleanup = (\n element: HTMLElement | SVGElement | MathMLElement,\n reactive: {\n addOnChange: (handler: (value: any) => void, key?: any) => unknown;\n removeOnChange: (key: any) => unknown;\n },\n handler: (value: any) => void,\n) => {\n reactive.addOnChange(handler, handler);\n $addNodeCleanup(element, () => reactive.removeOnChange(handler));\n};\n\nfunction attrIsObject(element: HTMLElement | SVGElement | MathMLElement, attr: KTReactifyProps<KTAttribute>) {\n const classValue = attr.class || attr.className;\n if (classValue !== undefined) {\n if (isKT<string>(classValue)) {\n element.setAttribute('class', classValue.value);\n addReactiveCleanup(element, classValue, (v) => element.setAttribute('class', v));\n } else {\n element.setAttribute('class', classValue);\n }\n }\n\n const style = attr.style;\n if (style) {\n if (typeof style === 'string') {\n element.setAttribute('style', style);\n } else if (typeof style === 'object') {\n if (isKT(style)) {\n setElementStyle(element, style.value);\n addReactiveCleanup(element, style, (v: Partial<CSSStyleDeclaration> | string) => setElementStyle(element, v));\n } else {\n setElementStyle(element, style as Partial<CSSStyleDeclaration>);\n }\n }\n }\n\n // ! Security: `k-html` is an explicit raw HTML escape hatch. kt.js intentionally does not sanitize here; callers must pass only trusted HTML.\n if ('k-html' in attr) {\n const html = attr['k-html'];\n // ?? 这是要干嘛啊\n const setHTML = (value: any) => {\n while (element.firstChild) {\n element.firstChild.remove();\n }\n element.innerHTML = value;\n };\n if (isKT(html)) {\n setHTML(html.value);\n addReactiveCleanup(element, html, (v) => setHTML(v));\n } else {\n setHTML(html);\n }\n }\n\n for (const key in attr) {\n // & Arranged in order of usage frequency\n if (\n // key === 'k-if' ||\n // key === 'k-else' ||\n key === 'k-model' ||\n key === 'k-for' ||\n key === 'k-key' ||\n key === 'ref' ||\n key === 'class' ||\n key === 'className' ||\n key === 'style' ||\n key === 'children' ||\n key === 'k-html'\n ) {\n continue;\n }\n\n const o = attr[key];\n\n // normal event handler\n if (key.startsWith('on:')) {\n if (o) {\n const eventName = key.slice(3);\n element.addEventListener(eventName, o); // chop off the `on:`\n $addNodeCleanup(element, () => element.removeEventListener(eventName, o));\n }\n continue;\n }\n\n // normal attributes\n // Security: all non-`on:` attributes are forwarded as-is.\n // Dangerous values such as raw `on*`, `href`, `src`, `srcdoc`, SVG href, etc.\n // remain the caller's responsibility.\n const handler = handlers[key] || defaultHandler;\n if (isKT(o)) {\n handler(element, key, o.value);\n addReactiveCleanup(element, o, (v) => handler(element, key, v));\n } else {\n handler(element, key, o);\n }\n }\n}\n\nexport function applyAttr(element: HTMLElement | SVGElement | MathMLElement, attr: KTRawAttr) {\n if (!attr) {\n return;\n }\n if (typeof attr === 'object' && attr !== null) {\n attrIsObject(element, attr as KTAttribute);\n } else {\n $throw('attr must be an object.');\n }\n}\n","import { $isArray, $isNode, $isThenable } from '@ktjs/shared';\nimport type { KTAvailableContent, KTRawContent } from '../types/h.js';\nimport { isKT } from '../reactable/common.js';\nimport { AnchorType } from '../jsx/anchor.js';\nimport { $addNodeCleanup, $mountFragmentAnchors } from '../jsx/anchor.js';\n\nconst assureNode = (o: any) => ($isNode(o) ? o : document.createTextNode(o));\n\nfunction apdSingle(element: HTMLElement | DocumentFragment | SVGElement | MathMLElement, c: KTAvailableContent) {\n // & Ignores falsy values, consistent with React's behavior\n if (c === undefined || c === null || c === false) {\n return;\n }\n\n if (isKT(c)) {\n let node = assureNode(c.value);\n element.appendChild(node);\n const onChange = (newValue: KTAvailableContent) => {\n const newNode = assureNode(newValue);\n const oldNode = node;\n node = newNode;\n oldNode.replaceWith(newNode);\n $mountFragmentAnchors(newNode);\n };\n c.addOnChange(onChange, onChange);\n $addNodeCleanup(element, () => c.removeOnChange(onChange));\n } else {\n const node = assureNode(c);\n element.appendChild(node);\n const anchor = node as { type?: AnchorType; list?: any[] };\n if (anchor.type === AnchorType.For) {\n apd(element, anchor.list);\n }\n }\n}\n\nfunction apd(element: HTMLElement | DocumentFragment | SVGElement | MathMLElement, c: KTAvailableContent) {\n if ($isThenable(c)) {\n c.then((r) => apd(element, r));\n } else if ($isArray(c)) {\n for (let i = 0; i < c.length; i++) {\n // & might be thenable here too\n const ci = c[i];\n if ($isThenable(ci)) {\n const comment = document.createComment('ktjs-promise-placeholder');\n element.appendChild(comment);\n ci.then((awaited) => {\n if ($isNode(awaited)) {\n // ?? 难道不能都在observer回调里做吗\n comment.replaceWith(awaited);\n $mountFragmentAnchors(awaited);\n } else {\n const awaitedNode = assureNode(awaited);\n comment.replaceWith(awaitedNode);\n $mountFragmentAnchors(awaitedNode);\n }\n });\n } else {\n apdSingle(element, ci);\n }\n }\n } else {\n // & here is thened, so must be a simple elementj\n apdSingle(element, c);\n }\n}\n\nexport function applyContent(element: HTMLElement | SVGElement | MathMLElement, content: KTRawContent): void {\n if ($isArray(content)) {\n for (let i = 0; i < content.length; i++) {\n apd(element, content[i]);\n }\n } else {\n apd(element, content as KTAvailableContent);\n }\n}\n","import type { InputElementTag } from '@ktjs/shared';\nimport type { KTRefLike } from '../reactable/ref.js';\n\nimport { static_cast } from 'type-narrow';\nimport { isRefLike } from '../reactable/common.js';\nimport { $addNodeCleanup } from '../jsx/anchor.js';\n\nexport function applyKModel(element: HTMLElementTagNameMap[InputElementTag], valueRef: KTRefLike<any>) {\n if (!isRefLike(valueRef)) {\n $throw('k-model value must be a KTRefLike.');\n }\n\n if (element.tagName === 'INPUT') {\n static_cast<HTMLInputElement>(element);\n if (element.type === 'radio' || element.type === 'checkbox') {\n element.checked = Boolean(valueRef.value);\n const onChange = () => (valueRef.value = element.checked);\n const onValueChange = (newValue: boolean) => (element.checked = newValue);\n element.addEventListener('change', onChange);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('change', onChange));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n } else {\n element.value = valueRef.value ?? '';\n const onInput = () => (valueRef.value = element.value);\n const onValueChange = (newValue: string) => (element.value = newValue);\n element.addEventListener('input', onInput);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('input', onInput));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n }\n return;\n }\n\n if (element.tagName === 'SELECT' || element.tagName === 'TEXTAREA') {\n element.value = valueRef.value ?? '';\n const onChange = () => (valueRef.value = element.value);\n const onValueChange = (newValue: string) => (element.value = newValue);\n element.addEventListener('change', onChange);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('change', onChange));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n return;\n }\n\n $warn('not supported element for k-model:');\n}\n","import type { HTMLTag, MathMLTag, SVGTag } from '@ktjs/shared';\nimport type { KTRawAttr, KTRawContent, HTML } from '../types/h.js';\n\nimport { applyAttr } from './attr.js';\nimport { applyContent } from './content.js';\nimport { applyKModel } from './model.js';\n\n/**\n * Create an enhanced HTMLElement.\n * - Only supports HTMLElements, **NOT** SVGElements or other Elements.\n * @param tag tag of an `HTMLElement`\n * @param attr attribute object or className\n * @param content a string or an array of HTMLEnhancedElement as child nodes\n *\n * __PKG_INFO__\n */\nexport const h = <T extends HTMLTag | SVGTag | MathMLTag>(\n tag: T,\n attr?: KTRawAttr,\n content?: KTRawContent,\n): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElement(tag) as HTML<T>;\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n return element;\n};\n\nexport const svg = <T extends SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElementNS('http://www.w3.org/2000/svg', tag) as HTML<T>;\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n return element;\n};\n\nexport const mathml = <T extends MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElementNS('http://www.w3.org/1998/Math/MathML', tag) as HTML<T>;\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n return element;\n};\n","import type { KTComputed, KTSubComputed } from './computed.js';\n\nimport { $stringify } from '@ktjs/shared';\nimport { $createSubGetter } from './common.js';\n\nexport type ChangeHandler<T> = (newValue: T, oldValue: T) => void;\n\nexport const enum KTReactiveType {\n ReactiveLike = 0b11111,\n Ref = 0b00010,\n SubRef = 0b00100,\n RefLike = Ref | SubRef,\n Computed = 0b01000,\n SubComputed = 0b10000,\n ComputedLike = Computed | SubComputed,\n Reactive = Ref | Computed,\n}\n\nlet kid = 1;\nlet handlerId = 1;\n\nexport abstract class KTReactiveLike<T> {\n readonly kid = kid++;\n\n abstract readonly ktype: KTReactiveType;\n\n abstract get value(): T;\n\n abstract addOnChange(handler: ChangeHandler<T>, key?: any): this;\n\n abstract removeOnChange(key: any): this;\n\n /**\n * Create a computed value via current reactive value.\n * - No matter `this` is added to `dependencies` or not, it is always listened.\n * @param calculator A function that generates a new value based on current value.\n * @param dependencies optional other dependencies that the computed value depends on.\n */\n map<U>(calculator: (value: T) => U, dependencies?: Array<KTReactiveLike<any>>): KTComputed<U> {\n return null as any;\n }\n}\n\nexport abstract class KTReactive<T> extends KTReactiveLike<T> {\n /**\n * @internal\n */\n protected _value: T;\n\n /**\n * @internal\n */\n protected readonly _changeHandlers = new Map<any, ChangeHandler<any>>();\n\n constructor(value: T) {\n super();\n this._value = value;\n }\n\n get value() {\n return this._value;\n }\n\n set value(_newValue: T) {\n $warn('Setting value to a non-ref instance takes no effect.');\n }\n\n /**\n * @internal\n */\n protected _emit(newValue: T, oldValue: T): this {\n this._changeHandlers.forEach((handler) => handler(newValue, oldValue));\n return this;\n }\n\n addOnChange(handler: ChangeHandler<T>, key?: any): this {\n key ??= handlerId++;\n if (this._changeHandlers.has(key)) {\n $throw(`Overriding existing change handler with key ${$stringify(key)}.`);\n }\n this._changeHandlers.set(key, handler);\n return this;\n }\n\n removeOnChange(key: any): this {\n this._changeHandlers.delete(key);\n return this;\n }\n\n clearOnChange(): this {\n this._changeHandlers.clear();\n return this;\n }\n\n notify(): this {\n return this._emit(this._value, this._value);\n }\n\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<\n K0 extends keyof T,\n K1 extends keyof T[K0],\n K2 extends keyof T[K0][K1],\n K3 extends keyof T[K0][K1][K2],\n K4 extends keyof T[K0][K1][K2][K3],\n >(key0: K0, key1: K1, key2: K2, key3: K3, key4: K4): KTSubComputed<T[K0][K1][K2][K3][K4]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1], K3 extends keyof T[K0][K1][K2]>(\n key0: K0,\n key1: K1,\n key2: K2,\n key3: K3,\n ): KTSubComputed<T[K0][K1][K2][K3]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1]>(\n key0: K0,\n key1: K1,\n key2: K2,\n ): KTSubComputed<T[K0][K1][K2]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0]>(key0: K0, key1: K1): KTSubComputed<T[K0][K1]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T>(key0: K0): KTSubComputed<T[K0]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get(..._keys: Array<string | number>): KTSubComputed<any> {\n // & Will be implemented in computed.ts to avoid circular dependency\n return null as any;\n }\n}\n\nexport abstract class KTSubReactive<T> extends KTReactiveLike<T> {\n readonly source: KTReactive<any>;\n\n /**\n * @internal\n */\n protected readonly _getter: (sv: KTReactive<any>['value']) => T;\n\n constructor(source: KTReactive<any>, paths: string) {\n super();\n this.source = source;\n this._getter = $createSubGetter(paths);\n }\n\n get value() {\n // @ts-expect-error _value is private\n return this._getter(this.source._value);\n }\n\n addOnChange(handler: ChangeHandler<T>, key?: any): this {\n this.source.addOnChange((newSourceValue, oldSourceValue) => {\n const oldValue = this._getter(oldSourceValue);\n const newValue = this._getter(newSourceValue);\n handler(newValue, oldValue);\n }, key);\n return this;\n }\n\n removeOnChange(key: any): this {\n this.source.removeOnChange(key);\n return this;\n }\n\n notify(): this {\n this.source.notify();\n return this;\n }\n}\n","// Use microqueue to schedule the flush of pending reactions\n\nimport type { KTRef } from './ref.js';\n\nconst reactiveToOldValue = new Map<KTRef<any>, any>();\n\nlet scheduled = false;\n\nexport const markMutation = (reactive: KTRef<any>) => {\n if (!reactiveToOldValue.has(reactive)) {\n // @ts-expect-error accessing protected property\n reactiveToOldValue.set(reactive, reactive._value);\n\n // # schedule by microqueue\n if (scheduled) {\n return;\n }\n\n scheduled = true;\n Promise.resolve().then(() => {\n scheduled = false;\n reactiveToOldValue.forEach((oldValue, reactive) => {\n try {\n // @ts-expect-error accessing protected property\n reactive._changeHandlers.forEach((handler) => handler(reactive.value, oldValue));\n } catch (error) {\n $error('KTScheduler:', error);\n }\n });\n reactiveToOldValue.clear();\n });\n }\n};\n","import { $emptyFn, $is, $stringify } from '@ktjs/shared';\nimport { KTReactive, KTReactiveType, KTSubReactive } from './reactive.js';\nimport { markMutation } from './scheduler.js';\nimport { $createSubSetter, isRefLike } from './common.js';\n\nexport class KTRef<T> extends KTReactive<T> {\n readonly ktype = KTReactiveType.Ref;\n\n constructor(_value: T) {\n super(_value);\n }\n\n // ! Cannot be omitted, otherwise this will override `KTReactive` with only setter. And getter will return undefined.\n get value() {\n return this._value;\n }\n\n set value(newValue: T) {\n if ($is(newValue, this._value)) {\n return;\n }\n const oldValue = this._value;\n this._value = newValue;\n this._emit(newValue, oldValue);\n }\n\n /**\n * Used to mutate the value in-place.\n * - internal value is changed instantly, but the change handlers will be called in the next microtask.\n */\n get draft() {\n markMutation(this);\n return this._value;\n }\n\n notify(): this {\n return this._emit(this._value, this._value);\n }\n\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<\n K0 extends keyof T,\n K1 extends keyof T[K0],\n K2 extends keyof T[K0][K1],\n K3 extends keyof T[K0][K1][K2],\n K4 extends keyof T[K0][K1][K2][K3],\n >(key0: K0, key1: K1, key2: K2, key3: K3, key4: K4): KTSubRef<T[K0][K1][K2][K3][K4]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1], K3 extends keyof T[K0][K1][K2]>(\n key0: K0,\n key1: K1,\n key2: K2,\n key3: K3,\n ): KTSubRef<T[K0][K1][K2][K3]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1]>(\n key0: K0,\n key1: K1,\n key2: K2,\n ): KTSubRef<T[K0][K1][K2]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0]>(key0: K0, key1: K1): KTSubRef<T[K0][K1]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T>(key0: K0): KTSubRef<T[K0]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref(...keys: Array<string | number>): KTSubRef<any> {\n if (keys.length === 0) {\n $throw('At least one key is required to get a sub-ref.');\n }\n return new KTSubRef(this, keys.map((key) => `[${$stringify(key)}]`).join(''));\n }\n}\n\nexport class KTSubRef<T> extends KTSubReactive<T> {\n readonly ktype = KTReactiveType.SubRef;\n declare readonly source: KTRef<any>;\n\n /**\n * @internal\n */\n protected readonly _setter: (s: object, newValue: T) => void;\n\n constructor(source: KTRef<any>, paths: string) {\n super(source, paths);\n this._setter = $createSubSetter(paths);\n }\n\n get value() {\n // @ts-expect-error _value is private\n return this._getter(this.source._value);\n }\n\n set value(newValue: T) {\n // @ts-expect-error _value is private\n this._setter(this.source._value, newValue);\n this.source.notify();\n }\n\n get draft() {\n // Same implementation as `draft` in `KTRef`\n markMutation(this.source);\n // @ts-expect-error _value is private\n return this._getter(this.source._value);\n }\n\n notify(): this {\n this.source.notify();\n return this;\n }\n}\n\n/**\n * Create a reactive reference to a value. The returned object has a single property `value` that holds the internal value.\n * @param value listened value\n */\nexport const ref = <T>(value?: T): KTRef<T> => new KTRef(value as any);\n\n/**\n * Assert `k-model` to be a ref-like object\n */\nexport const assertModel = <T = any>(props: any, defaultValue?: T): KTRefLike<T> => {\n // & props is an object. Won't use it in any other place\n if ('k-model' in props) {\n const kmodel = props['k-model'];\n if (isRefLike(kmodel)) {\n return kmodel;\n } else {\n $throw(`k-model data must be a KTRef object, please use 'ref(...)' to wrap it.`);\n }\n }\n return ref(defaultValue) as KTRef<T>;\n};\n\nconst $refSetter = <T>(props: { ref?: KTRef<T> }, node: T) => (props.ref!.value = node);\ntype RefSetter<T> = (props: { ref?: KTRef<T> }, node: T) => void;\n\nexport type KTRefLike<T> = KTRef<T> | KTSubRef<T>;\n\n/**\n * Whether `props.ref` is a `KTRef` only needs to be checked in the initial render\n */\nexport const $initRef = <T extends Node>(props: { ref?: KTRefLike<T> }, node: T): RefSetter<T> => {\n if (!('ref' in props)) {\n return $emptyFn;\n }\n\n const r = props.ref;\n if (isRefLike(r)) {\n r.value = node;\n return $refSetter;\n } else {\n $throw('Fragment: ref must be a KTRef');\n }\n};\n","import { $is, $stringify } from '@ktjs/shared';\nimport { KTReactive, KTReactiveLike, KTReactiveType, KTSubReactive } from './reactive.js';\n\nexport class KTComputed<T> extends KTReactive<T> {\n readonly ktype = KTReactiveType.Computed;\n\n private readonly _calculator: () => T;\n private readonly _dependencies: Array<KTReactiveLike<any>>;\n private readonly _recalculateListener: () => void;\n private _disposed = false;\n\n private _recalculate(forced: boolean = false): this {\n const newValue = this._calculator();\n const oldValue = this._value;\n if (!$is(oldValue, newValue) || forced) {\n this._value = newValue;\n this._emit(newValue, oldValue);\n }\n return this;\n }\n\n constructor(calculator: () => T, dependencies: Array<KTReactiveLike<any>>) {\n super(calculator());\n this._calculator = calculator;\n this._dependencies = dependencies;\n this._recalculateListener = () => this._recalculate();\n for (let i = 0; i < dependencies.length; i++) {\n dependencies[i].addOnChange(this._recalculateListener, this._recalculateListener);\n }\n }\n\n notify(): this {\n return this._recalculate(true);\n }\n\n dispose(): this {\n if (this._disposed) {\n return this;\n }\n\n this._disposed = true;\n for (let i = 0; i < this._dependencies.length; i++) {\n this._dependencies[i].removeOnChange(this._recalculateListener);\n }\n return this;\n }\n}\n\nKTReactiveLike.prototype.map = function <U>(\n this: KTReactive<unknown>,\n c: (value: unknown) => U,\n dep?: Array<KTReactiveLike<any>>,\n) {\n return new KTComputed(() => c(this.value), dep ? [this, ...dep] : [this]);\n};\n\nKTReactive.prototype.get = function <T>(this: KTReactive<T>, ...keys: Array<string | number>) {\n if (keys.length === 0) {\n $throw('At least one key is required to get a sub-computed.');\n }\n return new KTSubComputed(this, keys.map((key) => `[${$stringify(key)}]`).join(''));\n};\n\nexport class KTSubComputed<T> extends KTSubReactive<T> {\n readonly ktype = KTReactiveType.SubComputed;\n}\n\nexport type KTComputedLike<T> = KTComputed<T> | KTSubComputed<T>;\n\n/**\n * Create a computed value that automatically updates when its dependencies change.\n * @param calculator synchronous function that calculates the value of the computed. It should not have side effects.\n * @param dependencies an array of reactive dependencies that the computed value depends on. The computed value will automatically update when any of these dependencies change.\n */\nexport const computed = <T>(calculator: () => T, dependencies: Array<KTReactiveLike<any>>): KTComputed<T> =>\n new KTComputed(calculator, dependencies);\n","import { $emptyFn } from '@ktjs/shared';\nimport type { KTReactiveLike } from './reactive.js';\n\ninterface KTEffectOptions {\n lazy: boolean;\n onCleanup: () => void;\n debugName: string;\n}\n\n/**\n * Register a reactive effect with options.\n * @param effectFn The effect function to run when dependencies change\n * @param reactives The reactive dependencies\n * @param options Effect options: lazy, onCleanup, debugName\n * @returns stop function to remove all listeners\n */\nexport function effect(\n effectFn: () => void,\n reactives: Array<KTReactiveLike<any>>,\n options?: Partial<KTEffectOptions>,\n) {\n const { lazy = false, onCleanup = $emptyFn, debugName = '' } = Object(options);\n const listenerKeys: Array<string | number> = [];\n\n let active = true;\n\n const run = () => {\n if (!active) {\n return;\n }\n\n // cleanup before rerun\n onCleanup();\n\n try {\n effectFn();\n } catch (err) {\n $debug('effect error:', debugName, err);\n }\n };\n\n // subscribe to dependencies\n for (let i = 0; i < reactives.length; i++) {\n listenerKeys[i] = i;\n reactives[i].addOnChange(run, effectFn);\n }\n\n // auto run unless lazy\n if (!lazy) {\n run();\n }\n\n // stop function\n return () => {\n if (!active) {\n return;\n }\n active = false;\n\n for (let i = 0; i < reactives.length; i++) {\n reactives[i].removeOnChange(effectFn);\n }\n\n // final cleanup\n onCleanup();\n };\n}\n","import type { KTReactive, KTReactiveLike } from './reactive.js';\nimport { isKT } from './common.js';\nimport { ref } from './ref.js';\n\n/**\n * Ensure a value is reactive. If it's already `KTReactiveLike`, return it as is; otherwise, wrap it in a `ref`.\n */\nexport const toReactive = <T>(o: T | KTReactiveLike<T>): KTReactiveLike<T> =>\n isKT(o) ? o : (ref(o as T) as KTReactive<T>);\n\n/**\n * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.\n */\nexport const dereactive = <T>(value: T | KTReactiveLike<T>): T => (isKT<T>(value) ? value.value : value);\n\nexport type { KTRef, KTSubRef, KTRefLike } from './ref.js';\nexport { ref, assertModel } from './ref.js';\nexport type { KTComputed, KTSubComputed, KTComputedLike } from './computed.js';\nexport { computed } from './computed.js';\nexport { KTReactiveType } from './reactive.js';\nexport type * from './reactive.js';\n\nexport {\n isKT,\n isReactiveLike,\n isRef,\n isSubRef,\n isRefLike,\n isComputed,\n isSubComputed,\n isComputedLike,\n isReactive,\n} from './common.js';\nexport { effect } from './effect.js';\nexport type * from './types.js';\n","import type { KTReactiveLike } from '../reactable/reactive.js';\nimport type { KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport { $initRef, type KTRefLike } from '../reactable/ref.js';\n\nimport { $forEach, $isArray } from '@ktjs/shared';\nimport { isKT, toReactive } from '../reactable/index.js';\nimport { $addNodeCleanup, AnchorType, KTAnchor } from './anchor.js';\n\nexport class FragmentAnchor extends KTAnchor<Node> {\n readonly type = AnchorType.Fragment;\n\n constructor() {\n super(AnchorType.Fragment);\n }\n\n /**\n * Remove elements in the list\n */\n removeElements() {\n const list = this.list.slice();\n this.list.length = 0;\n for (let i = 0; i < list.length; i++) {\n const node = list[i] as ChildNode;\n if (node.parentNode) {\n node.remove();\n }\n }\n }\n}\n\nexport interface FragmentProps<T extends Node = Node> {\n /** Array of child elements, supports reactive arrays */\n children: T[] | KTReactiveLike<T[]>;\n\n /** element key function for optimization (future enhancement) */\n key?: (element: T, index: number, array: T[]) => any;\n\n /** ref to get the anchor node */\n ref?: KTRefLike<JSX.Element>;\n}\n\n/**\n * Fragment - Container component for managing arrays of child elements\n *\n * Features:\n * 1. Returns a comment anchor node, child elements are inserted after the anchor\n * 2. Supports reactive arrays, automatically updates DOM when array changes\n * 3. Basic version uses simple replacement algorithm (remove all old elements, insert all new elements)\n * 4. Future enhancement: key-based optimization\n *\n * Usage example:\n * ```tsx\n * const children = ref([<div>A</div>, <div>B</div>]);\n * const fragment = <Fragment children={children} />;\n * document.body.appendChild(fragment);\n *\n * // Automatic update\n * children.value = [<div>C</div>, <div>D</div>];\n * ```\n */\nexport function Fragment<T extends Node = Node>(props: FragmentProps<T>): JSX.Element & FragmentAnchor {\n const anchor = new FragmentAnchor();\n const elements = anchor.list as T[];\n const childrenRef = toReactive(props.children);\n\n const redraw = () => {\n const newElements = childrenRef.value;\n const parent = anchor.parentNode;\n\n if (!parent) {\n elements.length = 0;\n for (let i = 0; i < newElements.length; i++) {\n elements.push(newElements[i]);\n }\n return;\n }\n\n anchor.removeElements();\n elements.length = 0;\n\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < newElements.length; i++) {\n const element = newElements[i];\n elements.push(element);\n fragment.appendChild(element);\n }\n\n parent.insertBefore(fragment, anchor.nextSibling);\n };\n\n childrenRef.addOnChange(redraw, redraw);\n $addNodeCleanup(anchor, () => childrenRef.removeOnChange(redraw));\n anchor.mountCallback = redraw;\n redraw();\n\n $initRef(props as { ref?: KTRefLike<Node> }, anchor);\n\n return anchor as unknown as JSX.Element & FragmentAnchor;\n}\n\n/**\n * Convert KTRawContent to HTMLElement array\n */\nexport function convertChildrenToElements(children: KTRawContent): Element[] {\n const elements: Element[] = [];\n\n const processChild = (child: any): void => {\n if (child === undefined || child === null || child === false || child === true) {\n // Ignore null, undefined, false, true\n return;\n }\n\n if ($isArray(child)) {\n // Recursively process array\n $forEach(child, processChild);\n return;\n }\n\n if (typeof child === 'string' || typeof child === 'number') {\n const span = document.createElement('span');\n span.textContent = String(child);\n elements.push(span);\n return;\n }\n\n if (child instanceof Element) {\n elements.push(child);\n return;\n }\n\n if (isKT(child)) {\n processChild(child.value);\n return;\n }\n\n $warn('Fragment: unsupported child type', child);\n if (process.env.IS_DEV) {\n throw new Error(`Fragment: unsupported child type`);\n }\n };\n\n processChild(children);\n return elements;\n}\n","import type { JSXTag } from '@ktjs/shared';\nimport type { KTAttribute } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport { h } from '../h/index';\n\nexport const jsxh = (tag: JSXTag, props: KTAttribute): JSX.Element =>\n (typeof tag === 'function' ? tag(props) : h(tag, props, props.children)) as JSX.Element;\n\nexport const placeholder = (data: string): JSX.Element => document.createComment(data) as unknown as JSX.Element;\n","import type { JSXTag, MathMLTag, SVGTag } from '@ktjs/shared';\nimport type { KTAttribute, KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\n\nimport { h, mathml as _mathml, svg as _svg } from '../h/index.js';\nimport { $initRef } from '../reactable/ref.js';\nimport { isComputedLike } from '../reactable/common.js';\n\nimport { convertChildrenToElements, Fragment as FragmentArray } from './fragment.js';\nimport { jsxh, placeholder } from './common.js';\n\nfunction create(\n creator: (tag: any, props: KTAttribute, content?: KTRawContent) => JSX.Element,\n tag: any,\n props: KTAttribute,\n) {\n if (props.ref && isComputedLike(props.ref)) {\n $throw('Cannot assign a computed value to an element.');\n }\n const el = creator(tag, props, props.children);\n $initRef(props, el);\n return el;\n}\n\nexport const jsx = (tag: JSXTag, props: KTAttribute): JSX.Element => create(jsxh, tag, props);\nexport const svg = (tag: SVGTag, props: KTAttribute): JSX.Element => create(_svg, tag, props);\nexport const mathml = (tag: MathMLTag, props: KTAttribute): JSX.Element => create(_mathml, tag, props);\nexport { svg as svgRuntime, mathml as mathmlRuntime };\n\n/**\n * Fragment support - returns an array of children\n * Enhanced Fragment component that manages arrays of elements\n */\nexport function Fragment(props: { children?: KTRawContent }): JSX.Element {\n const { children } = props ?? {};\n\n if (!children) {\n return placeholder('kt-fragment-empty');\n }\n\n const elements = convertChildrenToElements(children);\n\n return FragmentArray({ children: elements });\n}\n\n/**\n * JSX Development runtime - same as jsx but with additional dev checks\n */\nexport const jsxDEV: typeof jsx = (...args) => {\n // console.log('JSX DEV called:', ...args);\n // console.log('children', (args[1] as any)?.children);\n return jsx(...args);\n};\n\n/**\n * JSX runtime for React 17+ automatic runtime\n * This is called when using jsx: \"react-jsx\" or \"react-jsxdev\"\n */\nexport const jsxs = jsx;\n\n// Export h as the classic JSX factory for backward compatibility\nexport { h, h as createElement };\n","import { $isThenable } from '@ktjs/shared';\nimport type { KTComponent, KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport type { KTRef } from '../reactable/ref.js';\nimport { $mountFragmentAnchors } from './anchor.js';\n\n/**\n * Extract component props type (excluding ref and children)\n */\ntype ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};\n\nexport function KTAsync<T extends KTComponent>(\n props: {\n ref?: KTRef<JSX.Element>;\n skeleton?: JSX.Element;\n component: T;\n children?: KTRawContent;\n } & ExtractComponentProps<T>,\n): JSX.Element {\n const raw = props.component(props);\n let comp: JSX.Element =\n props.skeleton ?? (document.createComment('ktjs-suspense-placeholder') as unknown as JSX.Element);\n\n if ($isThenable(raw)) {\n raw.then((resolved) => {\n comp.replaceWith(resolved);\n $mountFragmentAnchors(resolved);\n });\n } else {\n comp = raw as JSX.Element;\n }\n\n return comp;\n}\n","import type { JSX } from '../types/jsx.js';\nimport type { KTRefLike } from '../reactable/ref.js';\nimport type { KTReactiveLike } from '../reactable/reactive.js';\n\nimport { $identity } from '@ktjs/shared';\nimport { toReactive } from '../reactable/index.js';\nimport { $initRef } from '../reactable/ref.js';\nimport { $addNodeCleanup } from './anchor.js';\nimport { AnchorType, KTAnchor } from './anchor.js';\n\nexport class KTForAnchor extends KTAnchor<JSX.Element> {\n readonly type = AnchorType.For;\n\n constructor() {\n super(AnchorType.For);\n }\n}\n\nexport type KTForElement = JSX.Element & KTForAnchor;\n\nexport interface KTForProps<T> {\n ref?: KTRefLike<KTForElement>;\n list: T[] | KTReactiveLike<T[]>;\n key?: (item: T, index: number, array: T[]) => any;\n map?: (item: T, index: number, array: T[]) => JSX.Element;\n}\n\nconst setForNodeMap = (nodeMap: Map<any, JSX.Element>, key: any, node: JSX.Element, index: number) => {\n if (nodeMap.has(key)) {\n $error(`[KTFor] Duplicate key detected at index ${index}. Later items override earlier ones. key=${String(key)}`);\n }\n nodeMap.set(key, node);\n};\n\n// TASK 对于template标签的for和if,会编译为fragment,可特殊处理,让它们保持原样\n/**\n * KTFor - List rendering component with key-based optimization\n * Returns a Comment anchor node with rendered elements in anchor.list\n */\nexport function KTFor<T>(props: KTForProps<T>): KTForElement {\n const redraw = () => {\n const newList = listRef.value;\n const parent = anchor.parentNode;\n\n if (!parent) {\n anchor.list.length = 0;\n nodeMap.clear();\n for (let index = 0; index < newList.length; index++) {\n const item = newList[index];\n const itemKey = currentKey(item, index, newList);\n const node = currentMap(item, index, newList);\n setForNodeMap(nodeMap, itemKey, node, index);\n anchor.list.push(node);\n }\n return anchor;\n }\n\n const oldLength = anchor.list.length;\n const newLength = newList.length;\n\n if (newLength === 0) {\n nodeMap.forEach((node) => node.remove());\n nodeMap.clear();\n anchor.list.length = 0;\n return anchor;\n }\n\n if (oldLength === 0) {\n anchor.list.length = 0;\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < newLength; i++) {\n const item = newList[i];\n const itemKey = currentKey(item, i, newList);\n const node = currentMap(item, i, newList);\n setForNodeMap(nodeMap, itemKey, node, i);\n anchor.list.push(node);\n fragment.appendChild(node);\n }\n parent.insertBefore(fragment, anchor.nextSibling);\n return anchor;\n }\n\n const newKeyToNewIndex = new Map<any, number>();\n const newElements: JSX.Element[] = new Array(newLength);\n for (let i = 0; i < newLength; i++) {\n const item = newList[i];\n const itemKey = currentKey(item, i, newList);\n newKeyToNewIndex.set(itemKey, i);\n newElements[i] = nodeMap.has(itemKey) ? nodeMap.get(itemKey)! : currentMap(item, i, newList);\n }\n\n const toRemove: JSX.Element[] = [];\n nodeMap.forEach((node, key) => {\n if (!newKeyToNewIndex.has(key)) {\n toRemove.push(node);\n }\n });\n for (let i = 0; i < toRemove.length; i++) {\n toRemove[i].remove();\n }\n\n let currentNode = anchor.nextSibling;\n for (let i = 0; i < newLength; i++) {\n const node = newElements[i];\n if (currentNode !== node) {\n parent.insertBefore(node, currentNode);\n } else {\n currentNode = currentNode.nextSibling;\n }\n }\n\n nodeMap.clear();\n anchor.list.length = 0;\n for (let i = 0; i < newLength; i++) {\n const itemKey = currentKey(newList[i], i, newList);\n const node = newElements[i];\n setForNodeMap(nodeMap, itemKey, node, i);\n anchor.list.push(node);\n }\n return anchor;\n };\n\n const currentKey: NonNullable<KTForProps<T>['key']> = props.key ?? ((item: T) => item);\n const currentMap: NonNullable<KTForProps<T>['map']> =\n props.map ?? ((item: T) => $identity(item) as unknown as JSX.Element);\n const listRef = toReactive(props.list);\n const anchor = new KTForAnchor() as KTForElement;\n const nodeMap = new Map<any, JSX.Element>();\n\n for (let index = 0; index < listRef.value.length; index++) {\n const item = listRef.value[index];\n const itemKey = currentKey(item, index, listRef.value);\n const node = currentMap(item, index, listRef.value);\n setForNodeMap(nodeMap, itemKey, node, index);\n anchor.list.push(node);\n }\n\n listRef.addOnChange(redraw, redraw);\n $addNodeCleanup(anchor, () => listRef.removeOnChange(redraw));\n anchor.mountCallback = redraw;\n $initRef(props, anchor);\n\n return anchor;\n}\n","import type { JSXTag } from '@ktjs/shared';\nimport type { KTAttribute } from '../types/h.js';\nimport type { KTReactiveLike } from '../reactable/reactive.js';\n\nimport { isKT } from '../reactable/index.js';\nimport { $addNodeCleanup, $mountFragmentAnchors, $removeNodeCleanup } from './anchor.js';\nimport { jsxh, placeholder } from './common.js';\n\nexport function KTConditional(\n condition: any | KTReactiveLike<any>,\n tagIf: JSXTag,\n propsIf: KTAttribute,\n tagElse?: JSXTag,\n propsElse?: KTAttribute,\n) {\n if (!isKT(condition)) {\n return condition ? jsxh(tagIf, propsIf) : tagElse ? jsxh(tagElse, propsElse!) : placeholder('kt-conditional');\n }\n\n if (tagElse) {\n let current = condition.value ? jsxh(tagIf, propsIf) : jsxh(tagElse!, propsElse!);\n const cleanup = () => condition.removeOnChange(onChange);\n const onChange = (newValue: any) => {\n const old = current;\n current = newValue ? jsxh(tagIf, propsIf) : jsxh(tagElse!, propsElse!);\n $removeNodeCleanup(old, cleanup);\n $addNodeCleanup(current, cleanup);\n old.replaceWith(current);\n $mountFragmentAnchors(current);\n };\n condition.addOnChange(onChange, onChange);\n $addNodeCleanup(current, cleanup);\n return current;\n } else {\n const dummy = placeholder('kt-conditional') as HTMLElement;\n let current = condition.value ? jsxh(tagIf, propsIf) : dummy;\n const cleanup = () => condition.removeOnChange(onChange);\n const onChange = (newValue: any) => {\n const old = current;\n current = newValue ? jsxh(tagIf, propsIf) : dummy;\n $removeNodeCleanup(old, cleanup);\n $addNodeCleanup(current, cleanup);\n old.replaceWith(current);\n $mountFragmentAnchors(current);\n };\n condition.addOnChange(onChange, onChange);\n $addNodeCleanup(current, cleanup);\n return current;\n }\n}\n"],"names":["isKT","obj","kid","isReactiveLike","ktype","isRef","isSubRef","isRefLike","isComputed","isSubComputed","isComputedLike","isReactive","_getters","Map","_setters","KTAnchor","Comment","isKTAnchor","list","mountCallback","constructor","data","super","$ensureAnchorObserver","mount","parent","this","parentNode","appendChild","CANNOT_MOUNT","document","Node","CANNOT_OBSERVE","MutationObserver","COMMENT_FILTER","NodeFilter","SHOW_COMMENT","nodeToCleanups","WeakMap","anchorObserver","$cleanupRemovedNode","node","nodeType","children","Array","from","childNodes","i","length","anchor","slice","listNode","remove","$runNodeCleanups","body","records","disconnect","undefined","addedNodes","j","$mountFragmentAnchors","removedNodes","observe","childList","subtree","$mountIfFragmentAnchor","cleanups","get","delete","error","console","$addNodeCleanup","cleanup","push","set","$removeNodeCleanup","index","indexOf","splice","nodeObj","walker","createTreeWalker","current","nextNode","booleanHandler","element","key","value","setAttribute","valueHandler","handlers","checked","selected","valueAsDate","valueAsNumber","defaultValue","defaultChecked","defaultSelected","disabled","readOnly","multiple","required","autofocus","open","controls","autoplay","loop","muted","defer","async","hidden","_key","defaultHandler","setElementStyle","style","cssText","addReactiveCleanup","reactive","handler","addOnChange","removeOnChange","applyAttr","attr","Error","classValue","class","className","v","html","setHTML","firstChild","innerHTML","o","startsWith","eventName","addEventListener","removeEventListener","attrIsObject","assureNode","$isNode","createTextNode","apdSingle","c","onChange","newValue","newNode","oldNode","replaceWith","type","apd","$isThenable","then","r","$isArray","ci","comment","createComment","awaited","awaitedNode","applyContent","content","applyKModel","valueRef","tagName","onValueChange","Boolean","onInput","h","tag","createElement","svg","createElementNS","mathml","handlerId","KTReactiveLike","map","calculator","dependencies","KTReactive","_value","_changeHandlers","_newValue","warn","_emit","oldValue","forEach","has","$stringify","clearOnChange","clear","notify","_keys","KTSubReactive","source","_getter","paths","path","exist","cache","Function","$createSubGetter","newSourceValue","oldSourceValue","reactiveToOldValue","scheduled","markMutation","Promise","resolve","KTRef","$is","draft","subref","keys","KTSubRef","join","_setter","$createSubSetter","ref","assertModel","props","kmodel","$refSetter","$initRef","$emptyFn","KTComputed","_calculator","_dependencies","_recalculateListener","_disposed","_recalculate","forced","dispose","prototype","dep","KTSubComputed","computed","effect","effectFn","reactives","options","lazy","onCleanup","debugName","Object","active","run","err","debug","toReactive","dereactive","FragmentAnchor","removeElements","jsxh","placeholder","create","creator","el","jsx","_svg","_mathml","Fragment","elements","processChild","child","$forEach","span","textContent","String","Element","convertChildrenToElements","childrenRef","redraw","newElements","fragment","createDocumentFragment","insertBefore","nextSibling","FragmentArray","jsxDEV","args","jsxs","KTAsync","raw","component","comp","skeleton","resolved","KTForAnchor","setForNodeMap","nodeMap","KTFor","newList","listRef","item","itemKey","currentKey","currentMap","oldLength","newLength","newKeyToNewIndex","toRemove","currentNode","$identity","KTConditional","condition","tagIf","propsIf","tagElse","propsElse","old","dummy"],"mappings":";;AAKM,SAAUA,KAAcC;IAC5B,OAA2B,mBAAbA,KAAKC;AACrB;;AACM,SAAUC,eAAwBF;IACtC,OAA0B,mBAAfA,KAAKG,iBACNH,IAAIG;AAIhB;;AAEM,SAAUC,MAAeJ;IAC7B,OAA0B,mBAAfA,KAAKG,SACE,MAATH,IAAIG;AAIf;;AAEM,SAAUE,SAAkBL;IAChC,OAA0B,mBAAfA,KAAKG,SACE,MAATH,IAAIG;AAIf;;AAEM,SAAUG,UAAmBN;IACjC,OAA0B,mBAAfA,KAAKG,gBACNH,IAAIG;AAIhB;;AAEM,SAAUI,WAAoBP;IAClC,OAA0B,mBAAfA,KAAKG,SACE,MAATH,IAAIG;AAIf;;AAEM,SAAUK,cAAuBR;IACrC,OAA0B,mBAAfA,KAAKG,SACE,OAATH,IAAIG;AAIf;;AAEM,SAAUM,eAAwBT;IACtC,OAA0B,mBAAfA,KAAKG,iBACNH,IAAIG;AAIhB;;AAEM,SAAUO,WAAoBV;IAClC,OAA0B,mBAAfA,KAAKG,iBACNH,IAAIG;AAIhB;;AAMA,MAAMQ,WAAW,IAAIC,KACfC,WAAW,IAAID;;ACxEf,MAAgBE,iBAAwCC;IACnDC,YAAmB;IACnBC,KAAY;IAErBC;IAEA,WAAAC,CAAYC;QACVC,MAAMD,OACNE;AACF;IAEA,KAAAC,CAAMC;QACAA,UAAUC,KAAKC,eAAeF,UAChCA,OAAOG,YAAYF,OAEjBA,KAAKC,cACPD,K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L,YAAYwB,UAAUA,WAChCxE,gBAAgBW,SAASV;QAClBU;AACT;IAAO;QACL,MAAMoO,QAAQzD,YAAY;QAC1B,IAAI3K,UAAU8N,UAAUzN,QAAQqK,KAAKqD,OAAOC,WAAWI;QACvD,MAAM9O,UAAU,MAAMwO,UAAUxL,eAAeuB,WACzCA,WAAYC;YAChB,MAAMqK,MAAMnO;YACZA,UAAU8D,WAAW4G,KAAKqD,OAAOC,WAAWI,OAC5C3O,mBAAmB0O,KAAK7O;YACxBD,gBAAgBW,SAASV,UACzB6O,IAAIlK,YAAYjE,UAChBtB,sBAAsBsB;;QAIxB,OAFA8N,UAAUzL,YAAYwB,UAAUA,WAChCxE,gBAAgBW,SAASV;QAClBU;AACT;AACF;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/reactable/common.ts","../src/jsx/anchor.ts","../src/h/attr-helpers.ts","../src/h/attr.ts","../src/h/content.ts","../src/h/model.ts","../src/h/index.ts","../src/reactable/reactive.ts","../src/reactable/scheduler.ts","../src/reactable/ref.ts","../src/reactable/computed.ts","../src/reactable/effect.ts","../src/reactable/index.ts","../src/jsx/fragment.ts","../src/jsx/common.ts","../src/jsx/jsx-runtime.ts","../src/jsx/async.ts","../src/jsx/for.ts","../src/jsx/if.ts"],"sourcesContent":["import { KTReactiveLike, KTReactiveType, type KTReactive } from './reactive.js';\nimport type { KTRef, KTRefLike, KTSubRef } from './ref.js';\nimport type { KTComputed, KTComputedLike, KTSubComputed } from './computed.js';\n\n// # type guards\nexport function isKT<T = any>(obj: any): obj is KTReactiveLike<T> {\n return typeof obj?.kid === 'number';\n}\nexport function isReactiveLike<T = any>(obj: any): obj is KTReactiveLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.ReactiveLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isRef<T = any>(obj: any): obj is KTRef<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.Ref;\n } else {\n return false;\n }\n}\n\nexport function isSubRef<T = any>(obj: any): obj is KTSubRef<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.SubRef;\n } else {\n return false;\n }\n}\n\nexport function isRefLike<T = any>(obj: any): obj is KTRefLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.RefLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isComputed<T = any>(obj: any): obj is KTComputed<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.Computed;\n } else {\n return false;\n }\n}\n\nexport function isSubComputed<T = any>(obj: any): obj is KTSubComputed<T> {\n if (typeof obj?.ktype === 'number') {\n return obj.ktype === KTReactiveType.SubComputed;\n } else {\n return false;\n }\n}\n\nexport function isComputedLike<T = any>(obj: any): obj is KTComputedLike<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.ComputedLike) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isReactive<T = any>(obj: any): obj is KTReactive<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.Reactive) !== 0;\n } else {\n return false;\n }\n}\n\nexport function isSubReactive<T = any>(obj: any): obj is KTSubComputed<T> {\n if (typeof obj?.ktype === 'number') {\n return (obj.ktype & KTReactiveType.SubReactive) !== 0;\n } else {\n return false;\n }\n}\n\n// # sub getter/setter factory\n\ntype SubGetter = (s: any) => any;\ntype SubSetter = (s: any, newValue: any) => void;\n\n/**\n * Create a value getter which params is `reactive.value`(or `ref.draft`)\n */\nexport const $createSubGetter = (path: Array<string | number>): SubGetter => {\n // & path.length is guaranteed to be greater than 0 in `KTReactive.get` and `KTRef.get`\n switch (path.length) {\n // ? Does it use less memory if we write this:\n // const [k2_0, k2_1] = path;\n // return (s) => s[k2_0][k2_1];\n case 1:\n return (s) => s[path[0]];\n case 2:\n return (s) => s[path[0]][path[1]];\n case 3:\n return (s) => s[path[0]][path[1]][path[2]];\n case 4:\n return (s) => s[path[0]][path[1]][path[2]][path[3]];\n case 5:\n return (s) => s[path[0]][path[1]][path[2]][path[3]][path[4]];\n default:\n return (s) => {\n let r = s[path[0]][path[1]][path[2]][path[3]][path[4]];\n for (let i = 5; i < path.length; i++) {\n r = r[path[i]];\n }\n return r;\n };\n }\n};\n\n/**\n * Create a value setter which params is `reactive.value`(or `ref.draft`)\n */\nexport const $createSubSetter = (path: Array<string | number>): SubSetter => {\n switch (path.length) {\n case 1:\n return (s, newValue) => (s[path[0]] = newValue);\n case 2:\n return (s, newValue) => (s[path[0]][path[1]] = newValue);\n case 3:\n return (s, newValue) => (s[path[0]][path[1]][path[2]] = newValue);\n case 4:\n return (s, newValue) => (s[path[0]][path[1]][path[2]][path[3]] = newValue);\n case 5:\n return (s, newValue) => (s[path[0]][path[1]][path[2]][path[3]][path[4]] = newValue);\n default:\n return (s, newValue) => {\n let r = s[path[0]][path[1]][path[2]][path[3]][path[4]];\n for (let i = 5; i < path.length - 1; i++) {\n r = r[path[i]];\n }\n r[path[path.length - 1]] = newValue;\n };\n }\n};\n","export const enum AnchorType {\n Fragment = 'kt-fragment',\n For = 'kt-for',\n}\n\nexport abstract class KTAnchor<T extends Node = Node> extends Comment {\n readonly isKTAnchor: true = true;\n readonly list: T[] = [];\n abstract readonly type: AnchorType;\n mountCallback?: () => void;\n\n constructor(data: AnchorType) {\n super(data);\n $ensureAnchorObserver();\n }\n\n mount(parent?: Node) {\n if (parent && this.parentNode !== parent) {\n parent.appendChild(this);\n }\n if (this.parentNode) {\n this.mountCallback?.();\n }\n }\n}\n\ntype MountableKTAnchor = Node & {\n isKTAnchor?: true;\n mount?: (parent?: Node) => void;\n};\ntype NodeCleanup = () => void;\n\nconst CANNOT_MOUNT = typeof document === 'undefined' || typeof Node === 'undefined';\nconst CANNOT_OBSERVE = CANNOT_MOUNT || typeof MutationObserver === 'undefined';\nconst COMMENT_FILTER = typeof NodeFilter === 'undefined' ? 0x80 : NodeFilter.SHOW_COMMENT;\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\nconst nodeToCleanups = new WeakMap<Node, NodeCleanup[]>();\nlet anchorObserver: MutationObserver | undefined;\n\nconst $cleanupRemovedNode = (node: Node) => {\n if (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n const children = Array.from(node.childNodes);\n for (let i = 0; i < children.length; i++) {\n $cleanupRemovedNode(children[i]);\n }\n }\n\n const anchor = node as KTAnchor<Node>;\n if (anchor.isKTAnchor === true) {\n const list = anchor.list.slice();\n anchor.list.length = 0;\n for (let i = 0; i < list.length; i++) {\n const listNode = list[i] as ChildNode;\n if (listNode.parentNode) {\n listNode.remove();\n }\n $cleanupRemovedNode(listNode);\n }\n }\n\n $runNodeCleanups(node);\n};\n\nconst $ensureAnchorObserver = () => {\n if (CANNOT_OBSERVE || anchorObserver || !document.body) {\n return;\n }\n\n anchorObserver = new MutationObserver((records) => {\n if (typeof document === 'undefined') {\n anchorObserver?.disconnect();\n anchorObserver = undefined;\n return;\n }\n\n for (let i = 0; i < records.length; i++) {\n const addedNodes = records[i].addedNodes;\n for (let j = 0; j < addedNodes.length; j++) {\n $mountFragmentAnchors(addedNodes[j]);\n }\n\n const removedNodes = records[i].removedNodes;\n for (let j = 0; j < removedNodes.length; j++) {\n $cleanupRemovedNode(removedNodes[j]);\n }\n }\n });\n anchorObserver.observe(document.body, { childList: true, subtree: true });\n};\n\nconst $mountIfFragmentAnchor = (node: Node) => {\n const anchor = node as MountableKTAnchor;\n if (anchor.isKTAnchor === true && typeof anchor.mount === 'function') {\n anchor.mount();\n }\n};\n\nconst $runNodeCleanups = (node: Node) => {\n const cleanups = nodeToCleanups.get(node);\n if (!cleanups) {\n return;\n }\n\n nodeToCleanups.delete(node);\n for (let i = cleanups.length - 1; i >= 0; i--) {\n try {\n cleanups[i]();\n } catch (error) {\n $error('KTNodeCleanup:', error);\n }\n }\n};\n\nexport const $addNodeCleanup = (node: Node, cleanup: NodeCleanup) => {\n $ensureAnchorObserver();\n const cleanups = nodeToCleanups.get(node);\n if (cleanups) {\n cleanups.push(cleanup);\n } else {\n nodeToCleanups.set(node, [cleanup]);\n }\n return cleanup;\n};\n\nexport const $removeNodeCleanup = (node: Node, cleanup: NodeCleanup) => {\n const cleanups = nodeToCleanups.get(node);\n if (!cleanups) {\n return;\n }\n\n const index = cleanups.indexOf(cleanup);\n if (index === -1) {\n return;\n }\n\n cleanups.splice(index, 1);\n if (cleanups.length === 0) {\n nodeToCleanups.delete(node);\n }\n};\n\nexport const $mountFragmentAnchors = (node: unknown) => {\n if (CANNOT_MOUNT || typeof document === 'undefined' || !node || typeof (node as any).nodeType !== 'number') {\n return;\n }\n\n const nodeObj = node as Node;\n $mountIfFragmentAnchor(nodeObj);\n\n if (nodeObj.nodeType !== ELEMENT_NODE && nodeObj.nodeType !== DOCUMENT_FRAGMENT_NODE) {\n return;\n }\n\n const walker = document.createTreeWalker(nodeObj, COMMENT_FILTER);\n let current = walker.nextNode();\n while (current) {\n $mountIfFragmentAnchor(current);\n current = walker.nextNode();\n }\n};\n","const booleanHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => {\n if (key in element) {\n (element as any)[key] = !!value;\n } else {\n element.setAttribute(key, value);\n }\n};\n\nconst valueHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => {\n if (key in element) {\n (element as any)[key] = value;\n } else {\n element.setAttribute(key, value);\n }\n};\n\n// Attribute handlers map for optimized lookup\nexport const handlers: Record<\n string,\n (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) => void\n> = {\n checked: booleanHandler,\n selected: booleanHandler,\n value: valueHandler,\n valueAsDate: valueHandler,\n valueAsNumber: valueHandler,\n defaultValue: valueHandler,\n defaultChecked: booleanHandler,\n defaultSelected: booleanHandler,\n disabled: booleanHandler,\n readOnly: booleanHandler,\n multiple: booleanHandler,\n required: booleanHandler,\n autofocus: booleanHandler,\n open: booleanHandler,\n controls: booleanHandler,\n autoplay: booleanHandler,\n loop: booleanHandler,\n muted: booleanHandler,\n defer: booleanHandler,\n async: booleanHandler,\n hidden: (element, _key, value) => ((element as HTMLElement).hidden = !!value),\n};\n","import type { KTReactifyProps } from '../reactable/types.js';\nimport type { KTRawAttr, KTAttribute } from '../types/h.js';\nimport { isKT } from '../reactable/common.js';\nimport { $addNodeCleanup } from '../jsx/anchor.js';\nimport { handlers } from './attr-helpers.js';\n\nconst defaultHandler = (element: HTMLElement | SVGElement | MathMLElement, key: string, value: any) =>\n element.setAttribute(key, value);\n\nconst setElementStyle = (\n element: HTMLElement | SVGElement | MathMLElement,\n style: Partial<CSSStyleDeclaration> | string,\n) => {\n if (typeof style === 'string') {\n (element as HTMLElement).style.cssText = style;\n return;\n }\n\n for (const key in style) {\n (element as any).style[key as any] = style[key];\n }\n};\n\nconst addReactiveCleanup = (\n element: HTMLElement | SVGElement | MathMLElement,\n reactive: {\n addOnChange: (handler: (value: any) => void, key?: any) => unknown;\n removeOnChange: (key: any) => unknown;\n },\n handler: (value: any) => void,\n) => {\n reactive.addOnChange(handler, handler);\n $addNodeCleanup(element, () => reactive.removeOnChange(handler));\n};\n\nfunction attrIsObject(element: HTMLElement | SVGElement | MathMLElement, attr: KTReactifyProps<KTAttribute>) {\n const classValue = attr.class || attr.className;\n if (classValue !== undefined) {\n if (isKT<string>(classValue)) {\n element.setAttribute('class', classValue.value);\n addReactiveCleanup(element, classValue, (v) => element.setAttribute('class', v));\n } else {\n element.setAttribute('class', classValue);\n }\n }\n\n const style = attr.style;\n if (style) {\n if (typeof style === 'string') {\n element.setAttribute('style', style);\n } else if (typeof style === 'object') {\n if (isKT(style)) {\n setElementStyle(element, style.value);\n addReactiveCleanup(element, style, (v: Partial<CSSStyleDeclaration> | string) => setElementStyle(element, v));\n } else {\n setElementStyle(element, style as Partial<CSSStyleDeclaration>);\n }\n }\n }\n\n // ! Security: `k-html` is an explicit raw HTML escape hatch. kt.js intentionally does not sanitize here; callers must pass only trusted HTML.\n if ('k-html' in attr) {\n const html = attr['k-html'];\n // ?? 这是要干嘛啊\n const setHTML = (value: any) => {\n while (element.firstChild) {\n element.firstChild.remove();\n }\n element.innerHTML = value;\n };\n if (isKT(html)) {\n setHTML(html.value);\n addReactiveCleanup(element, html, (v) => setHTML(v));\n } else {\n setHTML(html);\n }\n }\n\n for (const key in attr) {\n // & Arranged in order of usage frequency\n if (\n // key === 'k-if' ||\n // key === 'k-else' ||\n key === 'k-model' ||\n key === 'k-for' ||\n key === 'k-key' ||\n key === 'ref' ||\n key === 'class' ||\n key === 'className' ||\n key === 'style' ||\n key === 'children' ||\n key === 'k-html'\n ) {\n continue;\n }\n\n const o = attr[key];\n\n // normal event handler\n if (key.startsWith('on:')) {\n if (o) {\n const eventName = key.slice(3);\n element.addEventListener(eventName, o); // chop off the `on:`\n $addNodeCleanup(element, () => element.removeEventListener(eventName, o));\n }\n continue;\n }\n\n // normal attributes\n // Security: all non-`on:` attributes are forwarded as-is.\n // Dangerous values such as raw `on*`, `href`, `src`, `srcdoc`, SVG href, etc.\n // remain the caller's responsibility.\n const handler = handlers[key] || defaultHandler;\n if (isKT(o)) {\n handler(element, key, o.value);\n addReactiveCleanup(element, o, (v) => handler(element, key, v));\n } else {\n handler(element, key, o);\n }\n }\n}\n\nexport function applyAttr(element: HTMLElement | SVGElement | MathMLElement, attr: KTRawAttr) {\n if (!attr) {\n return;\n }\n if (typeof attr === 'object' && attr !== null) {\n attrIsObject(element, attr as KTAttribute);\n } else {\n $throw('attr must be an object.');\n }\n}\n","import { $isArray, $isNode, $isThenable } from '@ktjs/shared';\nimport type { KTAvailableContent, KTRawContent } from '../types/h.js';\nimport { isKT } from '../reactable/common.js';\nimport { AnchorType } from '../jsx/anchor.js';\nimport { $addNodeCleanup, $mountFragmentAnchors } from '../jsx/anchor.js';\n\nconst assureNode = (o: any) => ($isNode(o) ? o : document.createTextNode(o));\n\nfunction apdSingle(element: HTMLElement | DocumentFragment | SVGElement | MathMLElement, c: KTAvailableContent) {\n // & Ignores falsy values, consistent with React's behavior\n if (c === undefined || c === null || c === false) {\n return;\n }\n\n if (isKT(c)) {\n let node = assureNode(c.value);\n element.appendChild(node);\n const onChange = (newValue: KTAvailableContent) => {\n const newNode = assureNode(newValue);\n const oldNode = node;\n node = newNode;\n oldNode.replaceWith(newNode);\n $mountFragmentAnchors(newNode);\n };\n c.addOnChange(onChange, onChange);\n $addNodeCleanup(element, () => c.removeOnChange(onChange));\n } else {\n const node = assureNode(c);\n element.appendChild(node);\n const anchor = node as { type?: AnchorType; list?: any[] };\n if (anchor.type === AnchorType.For) {\n apd(element, anchor.list);\n }\n }\n}\n\nfunction apd(element: HTMLElement | DocumentFragment | SVGElement | MathMLElement, c: KTAvailableContent) {\n if ($isThenable(c)) {\n c.then((r) => apd(element, r));\n } else if ($isArray(c)) {\n for (let i = 0; i < c.length; i++) {\n // & might be thenable here too\n const ci = c[i];\n if ($isThenable(ci)) {\n const comment = document.createComment('ktjs-promise-placeholder');\n element.appendChild(comment);\n ci.then((awaited) => {\n if ($isNode(awaited)) {\n // ?? 难道不能都在observer回调里做吗\n comment.replaceWith(awaited);\n $mountFragmentAnchors(awaited);\n } else {\n const awaitedNode = assureNode(awaited);\n comment.replaceWith(awaitedNode);\n $mountFragmentAnchors(awaitedNode);\n }\n });\n } else {\n apdSingle(element, ci);\n }\n }\n } else {\n // & here is thened, so must be a simple elementj\n apdSingle(element, c);\n }\n}\n\nexport function applyContent(element: HTMLElement | SVGElement | MathMLElement, content: KTRawContent): void {\n if ($isArray(content)) {\n for (let i = 0; i < content.length; i++) {\n apd(element, content[i]);\n }\n } else {\n apd(element, content as KTAvailableContent);\n }\n}\n","import type { InputElementTag } from '@ktjs/shared';\nimport type { KTRefLike } from '../reactable/ref.js';\n\nimport { static_cast } from 'type-narrow';\nimport { isRefLike } from '../reactable/common.js';\nimport { $addNodeCleanup } from '../jsx/anchor.js';\n\nexport function applyKModel(element: HTMLElementTagNameMap[InputElementTag], valueRef: KTRefLike<any>) {\n if (!isRefLike(valueRef)) {\n $throw('k-model value must be a KTRefLike.');\n }\n\n if (element.tagName === 'INPUT') {\n static_cast<HTMLInputElement>(element);\n if (element.type === 'radio' || element.type === 'checkbox') {\n element.checked = Boolean(valueRef.value);\n const onChange = () => (valueRef.value = element.checked);\n const onValueChange = (newValue: boolean) => (element.checked = newValue);\n element.addEventListener('change', onChange);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('change', onChange));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n } else {\n element.value = valueRef.value ?? '';\n const onInput = () => (valueRef.value = element.value);\n const onValueChange = (newValue: string) => (element.value = newValue);\n element.addEventListener('input', onInput);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('input', onInput));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n }\n return;\n }\n\n if (element.tagName === 'SELECT' || element.tagName === 'TEXTAREA') {\n element.value = valueRef.value ?? '';\n const onChange = () => (valueRef.value = element.value);\n const onValueChange = (newValue: string) => (element.value = newValue);\n element.addEventListener('change', onChange);\n valueRef.addOnChange(onValueChange, onValueChange);\n $addNodeCleanup(element, () => element.removeEventListener('change', onChange));\n $addNodeCleanup(element, () => valueRef.removeOnChange(onValueChange));\n return;\n }\n\n $warn('not supported element for k-model:');\n}\n","import type { HTMLTag, MathMLTag, SVGTag } from '@ktjs/shared';\nimport type { KTRawAttr, KTRawContent, HTML } from '../types/h.js';\n\nimport { applyAttr } from './attr.js';\nimport { applyContent } from './content.js';\nimport { applyKModel } from './model.js';\n\n/**\n * Create an enhanced HTMLElement.\n * - Only supports HTMLElements, **NOT** SVGElements or other Elements.\n * @param tag tag of an `HTMLElement`\n * @param attr attribute object or className\n * @param content a string or an array of HTMLEnhancedElement as child nodes\n *\n * __PKG_INFO__\n */\nexport const h = <T extends HTMLTag | SVGTag | MathMLTag>(\n tag: T,\n attr?: KTRawAttr,\n content?: KTRawContent,\n): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElement(tag) as HTML<T>;\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n return element;\n};\n\nexport const svg = <T extends SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElementNS('http://www.w3.org/2000/svg', tag) as HTML<T>;\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n return element;\n};\n\nexport const mathml = <T extends MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent): HTML<T> => {\n if (typeof tag !== 'string') {\n $throw('tagName must be a string.');\n }\n\n // * start creating the element\n const element = document.createElementNS('http://www.w3.org/1998/Math/MathML', tag) as HTML<T>;\n\n // * Handle content\n applyAttr(element, attr);\n applyContent(element, content);\n\n if (typeof attr === 'object' && attr !== null && 'k-model' in attr) {\n applyKModel(element as any, attr['k-model'] as any);\n }\n\n return element;\n};\n","import type { KTComputed, KTSubComputed } from './computed.js';\n\nimport { $stringify } from '@ktjs/shared';\n\nexport type ChangeHandler<T> = (newValue: T, oldValue: T) => void;\n\nexport const enum KTReactiveType {\n Pseudo = 0b000001,\n Ref = 0b000010,\n SubRef = 0b000100,\n RefLike = Ref | SubRef,\n Computed = 0b001000,\n SubComputed = 0b010000,\n ComputedLike = Computed | SubComputed,\n Reactive = Ref | Computed,\n SubReactive = SubRef | SubComputed,\n ReactiveLike = RefLike | ComputedLike | Pseudo,\n}\n\nlet kid = 1;\nlet handlerId = 1;\n\nexport const nextKid = () => kid++;\nexport const nextHandlerId = (kid: number) => `@@k-handler-${kid}-${handlerId++}`;\n\nexport abstract class KTReactiveLike<T> {\n readonly kid = nextKid();\n\n abstract readonly ktype: KTReactiveType;\n\n abstract get value(): T;\n\n abstract addOnChange(handler: ChangeHandler<T>, key?: any): this;\n abstract removeOnChange(key: any): this;\n\n abstract dispose(): void;\n}\n\nexport abstract class KTReactive<T> extends KTReactiveLike<T> {\n /**\n * @internal\n */\n protected _value: T;\n\n /**\n * @internal\n */\n protected readonly _changeHandlers = new Map<any, ChangeHandler<any>>();\n\n constructor(value: T) {\n super();\n this._value = value;\n }\n\n get value() {\n return this._value;\n }\n\n set value(_newValue: T) {\n $warn('Setting value to a non-ref instance takes no effect.');\n }\n\n /**\n * @internal\n */\n protected _emit(newValue: T, oldValue: T): this {\n this._changeHandlers.forEach((handler) => handler(newValue, oldValue));\n return this;\n }\n\n addOnChange(handler: ChangeHandler<T>, key: any = nextHandlerId(this.kid)): this {\n if (this._changeHandlers.has(key)) {\n $throw(`Overriding existing change handler with key ${$stringify(key)}.`);\n }\n this._changeHandlers.set(key, handler);\n return this;\n }\n\n removeOnChange(key: any): this {\n this._changeHandlers.delete(key);\n return this;\n }\n\n clearOnChange(): this {\n this._changeHandlers.clear();\n return this;\n }\n\n notify(): this {\n return this._emit(this._value, this._value);\n }\n\n /**\n * Create a computed value via current reactive value.\n * - No matter `this` is added to `dependencies` or not, it is always listened.\n * @param calculator A function that generates a new value based on current value.\n * @param dependencies optional other dependencies that the computed value depends on.\n */\n map<U>(calculator: (value: T) => U, dependencies?: Array<KTReactiveLike<any>>): KTComputed<U> {\n return null as any; // & implemented in computed.ts to avoid circular dependency\n }\n\n /**\n * Make a computed value that checks if the reactive value is strictly equal to a specific value.\n * - Use `Object.is` for comparison.\n * - if `o` is reactive-like, it will be added to dependencies\n */\n is(o: T | KTReactiveLike<T>): KTSubComputed<boolean> {\n return null as any; // & implemented in computed.ts to avoid circular dependency\n }\n\n /**\n * Make a computed value that checks if the reactive value matches a specific object structure.\n * - Deeply match.\n * - if `o` is reactive-like, it will be added to dependencies\n */\n match(o: object | KTReactiveLike<object>): KTSubComputed<boolean> {\n return null as any; // & implemented in computed.ts to avoid circular dependency\n }\n\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<\n K0 extends keyof T,\n K1 extends keyof T[K0],\n K2 extends keyof T[K0][K1],\n K3 extends keyof T[K0][K1][K2],\n K4 extends keyof T[K0][K1][K2][K3],\n >(key0: K0, key1: K1, key2: K2, key3: K3, key4: K4): KTSubComputed<T[K0][K1][K2][K3][K4]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1], K3 extends keyof T[K0][K1][K2]>(\n key0: K0,\n key1: K1,\n key2: K2,\n key3: K3,\n ): KTSubComputed<T[K0][K1][K2][K3]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1]>(\n key0: K0,\n key1: K1,\n key2: K2,\n ): KTSubComputed<T[K0][K1][K2]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T, K1 extends keyof T[K0]>(key0: K0, key1: K1): KTSubComputed<T[K0][K1]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get<K0 extends keyof T>(key0: K0): KTSubComputed<T[K0]>;\n /**\n * Generate a sub-computed value based on this reactive, using keys to access nested properties.\n * - `reactive.get('a', 'b')` means a sub-computed value to `this.value.a.b`.\n * - `KTSubComputed` is lighter than `KTComputed` because it only listens to changes on the source reactive, while `KTComputed` listens to all its dependencies. So it's better to use `get` when you only need to access nested properties without doing any calculation.\n */\n get(..._keys: Array<string | number>): KTSubComputed<any> {\n // & Will be implemented in computed.ts to avoid circular dependency\n return null as any;\n }\n}\n\nexport abstract class KTSubReactive<T> extends KTReactiveLike<T> {\n readonly source: KTReactive<any>;\n\n /**\n * @internal\n */\n protected _value: T;\n\n /**\n * @internal\n */\n protected readonly _getter: (sv: KTReactive<any>['value']) => T;\n\n /**\n * @internal\n */\n protected readonly _handler: ChangeHandler<any>;\n\n /**\n * @internal\n */\n protected readonly _handlerKeys: string[];\n\n constructor(source: KTReactive<any>, getter: (sv: KTReactive<any>['value']) => T) {\n super();\n this.source = source;\n this._getter = getter;\n this._handlerKeys = [];\n\n // @ts-expect-error _value is protected\n this._value = this._getter(source._value);\n // @ts-expect-error _value is protected\n this._handler = () => (this._value = getter(source._value));\n\n this._handlerKeys.push(nextHandlerId(this.kid));\n source.addOnChange(this._handler, this._handlerKeys[0]);\n }\n\n addOnChange(handler: ChangeHandler<T>, key: any = nextHandlerId(this.kid)): this {\n this._handlerKeys.push(key);\n this.source.addOnChange((newValue, oldValue) => handler(this._getter(newValue), this._getter(oldValue)), key);\n return this;\n }\n\n removeOnChange(key: any): this {\n this.source.removeOnChange(key);\n return this;\n }\n\n dispose(): void {\n this._handlerKeys.forEach((key) => this.source.removeOnChange(key));\n }\n}\n","// Use microqueue to schedule the flush of pending reactions\n\nimport type { KTRef } from './ref.js';\n\nconst reactiveToOldValue = new Map<KTRef<any>, any>();\n\nlet scheduled = false;\n\nexport const $markMutation = (reactive: KTRef<any>) => {\n if (!reactiveToOldValue.has(reactive)) {\n // @ts-expect-error accessing protected property\n reactiveToOldValue.set(reactive, reactive._value);\n\n // # schedule by microqueue\n if (scheduled) {\n return;\n }\n\n scheduled = true;\n Promise.resolve().then(() => {\n scheduled = false;\n reactiveToOldValue.forEach((oldValue, reactive) => {\n try {\n // @ts-expect-error accessing protected property\n reactive._changeHandlers.forEach((handler) => handler(reactive.value, oldValue));\n } catch (error) {\n $error('KTScheduler:', error);\n }\n });\n reactiveToOldValue.clear();\n });\n }\n};\n","import { $emptyFn, $is } from '@ktjs/shared';\nimport { $createSubGetter, $createSubSetter, isRefLike } from './common.js';\nimport { KTReactive, KTReactiveType, KTSubReactive } from './reactive.js';\nimport { $markMutation } from './scheduler.js';\n\nexport class KTRef<T> extends KTReactive<T> {\n readonly ktype = KTReactiveType.Ref;\n\n constructor(_value: T) {\n super(_value);\n }\n\n // ! Cannot be omitted, otherwise this will override `KTReactive` with only setter. And getter will return undefined.\n get value() {\n return this._value;\n }\n\n set value(newValue: T) {\n if ($is(newValue, this._value)) {\n return;\n }\n const oldValue = this._value;\n this._value = newValue;\n this._emit(newValue, oldValue);\n }\n\n /**\n * Used to mutate the value in-place.\n * - internal value is changed instantly, but the change handlers will be called in the next microtask.\n */\n get draft() {\n $markMutation(this);\n return this._value;\n }\n\n notify(): this {\n return this._emit(this._value, this._value);\n }\n\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<\n K0 extends keyof T,\n K1 extends keyof T[K0],\n K2 extends keyof T[K0][K1],\n K3 extends keyof T[K0][K1][K2],\n K4 extends keyof T[K0][K1][K2][K3],\n >(key0: K0, key1: K1, key2: K2, key3: K3, key4: K4): KTSubRef<T[K0][K1][K2][K3][K4]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1], K3 extends keyof T[K0][K1][K2]>(\n key0: K0,\n key1: K1,\n key2: K2,\n key3: K3,\n ): KTSubRef<T[K0][K1][K2][K3]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0], K2 extends keyof T[K0][K1]>(\n key0: K0,\n key1: K1,\n key2: K2,\n ): KTSubRef<T[K0][K1][K2]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T, K1 extends keyof T[K0]>(key0: K0, key1: K1): KTSubRef<T[K0][K1]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref<K0 extends keyof T>(key0: K0): KTSubRef<T[K0]>;\n /**\n * Derive a lighter sub-ref from this ref, using keys to access nested properties.\n * - `ref.subref('a', 'b')` means a sub-ref to `this.value.a.b`. Change it will also change `this.value` and trigger the handlers.\n * - `KTSubRef` is lighter than `KTRef`.\n */\n subref(...keys: Array<string | number>): KTSubRef<any> {\n if (keys.length === 0) {\n $throw('At least one key is required to get a sub-ref.');\n }\n return new KTSubRef(this, $createSubGetter(keys), $createSubSetter(keys));\n }\n\n dispose(): void {\n this._changeHandlers.clear();\n }\n}\n\n/**\n * Create a reactive reference to a value. The returned object has a single property `value` that holds the internal value.\n * @param value listened value\n */\nexport const ref = <T>(value?: T): KTRef<T> => new KTRef(value as any);\n\n/**\n * Assert `k-model` to be a ref-like object\n */\nexport const assertModel = <T = any>(props: any, defaultValue?: T): KTRefLike<T> => {\n // & props is an object. Won't use it in any other place\n if ('k-model' in props) {\n const kmodel = props['k-model'];\n if (isRefLike(kmodel)) {\n return kmodel;\n } else {\n $throw(`k-model data must be a KTRef object, please use 'ref(...)' to wrap it.`);\n }\n }\n return ref(defaultValue) as KTRef<T>;\n};\n\nconst $refSetter = <T>(props: { ref?: KTRef<T> }, node: T) => (props.ref!.value = node);\ntype RefSetter<T> = (props: { ref?: KTRef<T> }, node: T) => void;\n\nexport type KTRefLike<T> = KTRef<T> | KTSubRef<T>;\n\n/**\n * Whether `props.ref` is a `KTRef` only needs to be checked in the initial render\n */\nexport const $initRef = <T extends Node>(props: { ref?: KTRefLike<T> }, node: T): RefSetter<T> => {\n if (!('ref' in props)) {\n return $emptyFn;\n }\n\n const r = props.ref;\n if (isRefLike(r)) {\n r.value = node;\n return $refSetter;\n } else {\n $throw('Fragment: ref must be a KTRef');\n }\n};\n\n// # SubRef\n\nexport class KTSubRef<T> extends KTSubReactive<T> {\n readonly ktype = KTReactiveType.SubRef;\n declare readonly source: KTRef<any>;\n\n /**\n * @internal\n */\n protected readonly _setter: (s: object, newValue: T) => void;\n\n constructor(\n source: KTRef<any>,\n getter: (sv: KTReactive<any>['value']) => T,\n setter: (s: object, newValue: T) => void,\n ) {\n super(source, getter);\n this._setter = setter;\n }\n\n get value() {\n return this._value;\n }\n\n set value(newValue: T) {\n this._value = newValue;\n // @ts-expect-error _value is private\n this._setter(this.source._value, newValue);\n this.source.notify();\n }\n\n /**\n * Only use it for object's nested properties.\n */\n get draft() {\n // Same implementation as `draft` in `KTRef`\n $markMutation(this.source);\n return this._value;\n }\n}\n","import { $deepMatch, $is } from '@ktjs/shared';\nimport { KTReactive, KTReactiveLike, KTReactiveType, KTSubReactive, nextHandlerId } from './reactive.js';\nimport { $createSubGetter, isReactive, isSubReactive } from './common.js';\n\nexport class KTComputed<T> extends KTReactive<T> {\n readonly ktype = KTReactiveType.Computed;\n\n /**\n * @internal\n */\n private readonly _calculator: () => T;\n /**\n * @internal\n */\n private readonly _dependencies: Array<KTReactiveLike<any>>;\n /**\n * @internal\n */\n private readonly _handler: () => void;\n /**\n * @internal\n */\n protected readonly _handlerKeys: string[];\n private _disposed = false;\n\n private _recalculate(forced: boolean = false): this {\n const newValue = this._calculator();\n const oldValue = this._value;\n if (!$is(oldValue, newValue) || forced) {\n this._value = newValue;\n this._emit(newValue, oldValue);\n }\n return this;\n }\n\n // todo 依赖再次允许支持所有reactivelike\n constructor(calculator: () => T, dependencies: Array<KTReactiveLike<any>>) {\n super(calculator());\n this._calculator = calculator;\n this._dependencies = dependencies;\n this._handler = () => this._recalculate();\n this._handlerKeys = dependencies.map(() => nextHandlerId(this.kid));\n\n const uniqueSources = new Set<KTReactive<any>>();\n for (let i = 0; i < dependencies.length; i++) {\n const dep = dependencies[i];\n if (isSubReactive(dep)) {\n if (uniqueSources.has(dep.source)) {\n continue;\n } else {\n uniqueSources.add(dep.source);\n }\n }\n dep.addOnChange(this._handler, this._handlerKeys[i]);\n }\n uniqueSources.clear();\n }\n\n notify(): this {\n return this._recalculate(true);\n }\n\n dispose(): void {\n if (this._disposed) {\n return;\n }\n\n this._disposed = true;\n for (let i = 0; i < this._dependencies.length; i++) {\n this._dependencies[i].removeOnChange(this._handlerKeys[i]);\n }\n\n this._dependencies.length = 0;\n this._changeHandlers.clear();\n }\n}\n\nKTReactive.prototype.map = function <U>(\n this: KTReactive<unknown>,\n c: (value: unknown) => U,\n dep?: Array<KTReactive<any>>,\n) {\n return new KTComputed(() => c(this.value), dep ? [this, ...dep] : [this]);\n};\n\nKTReactive.prototype.is = function (this: KTReactive<unknown>, o: unknown) {\n if (isReactive(o)) {\n return new KTSubComputed(this, (v) => $is(v, o.value), o);\n } else {\n return new KTSubComputed(this, (v) => $is(v, o));\n }\n};\n\nKTReactive.prototype.match = function (this: KTReactive<object>, o: object) {\n if (isReactive(o)) {\n return new KTSubComputed(this, (v) => $deepMatch(v, o.value), o);\n } else {\n return new KTSubComputed(this, (v) => $deepMatch(v, o));\n }\n};\n\nKTReactive.prototype.get = function <T>(this: KTReactive<T>, ...keys: Array<string | number>) {\n if (keys.length === 0) {\n $throw('At least one key is required to get a sub-computed.');\n }\n return new KTSubComputed(this, $createSubGetter(keys));\n};\n\n/**\n * Create a computed value that automatically updates when its dependencies change.\n * @param calculator synchronous function that calculates the value of the computed. It should not have side effects.\n * @param dependencies an array of reactive dependencies that the computed value depends on. The computed value will automatically update when any of these dependencies change.\n */\nexport const computed = <T>(calculator: () => T, dependencies: Array<KTReactiveLike<any>>): KTComputed<T> =>\n new KTComputed(calculator, dependencies);\n\n// # SubComputed\n\nexport class KTSubComputed<T> extends KTSubReactive<T> {\n readonly ktype = KTReactiveType.SubComputed;\n\n /**\n * Used for `reactive.is` and `reactive.match` to track the single dependency.\n * @internal\n */\n private readonly _dependency?: KTReactive<any>;\n\n constructor(source: KTReactive<any>, getter: (sv: KTReactive<any>['value']) => T, dependency?: KTReactive<any>) {\n super(source, getter);\n this._dependency = dependency;\n\n if (dependency) {\n this._handlerKeys.push(nextHandlerId(this.kid));\n dependency.addOnChange(this._handler, this._handlerKeys[1]);\n }\n }\n\n get value() {\n return this._value;\n }\n\n dispose(): void {\n this._handlerKeys.forEach((key) => this.source.removeOnChange(key));\n this._dependency?.removeOnChange(this._handlerKeys[1]);\n }\n}\n\nexport type KTComputedLike<T> = KTComputed<T> | KTSubComputed<T>;\n","import { $emptyFn } from '@ktjs/shared';\nimport type { KTReactiveLike } from './reactive.js';\nimport { isSubReactive } from './common.js';\n\ninterface KTEffectOptions {\n lazy: boolean;\n onCleanup: () => void;\n debugName: string;\n}\n\n/**\n * Register a reactive effect with options.\n * @param effectFn The effect function to run when dependencies change\n * @param reactives The reactive dependencies\n * @param options Effect options: lazy, onCleanup, debugName\n * @returns stop function to remove all listeners\n */\nexport function effect(\n effectFn: () => void,\n reactives: Array<KTReactiveLike<any>>,\n options?: Partial<KTEffectOptions>,\n) {\n const { lazy = false, onCleanup = $emptyFn, debugName = '' } = Object(options);\n const listenerKeys: Array<string | number> = [];\n\n let active = true;\n\n const run = () => {\n if (!active) {\n return;\n }\n\n // cleanup before rerun\n onCleanup();\n\n try {\n effectFn();\n } catch (err) {\n $debug('effect error:', debugName, err);\n }\n };\n\n // subscribe to dependencies\n for (let i = 0; i < reactives.length; i++) {\n listenerKeys[i] = i;\n const r = reactives[i];\n if (isSubReactive(r)) {\n // @ts-expect-error _changeHandlers is protected\n r.source._changeHandlers.set(listenerKeys[i], run);\n } else {\n r.addOnChange(run, effectFn);\n }\n }\n\n // auto run unless lazy\n if (!lazy) {\n run();\n }\n\n // stop function\n return () => {\n if (!active) {\n return;\n }\n active = false;\n\n for (let i = 0; i < reactives.length; i++) {\n reactives[i].removeOnChange(effectFn);\n }\n\n // final cleanup\n onCleanup();\n };\n}\n","import type { KTReactive, KTReactiveLike } from './reactive.js';\nimport { isKT } from './common.js';\nimport { ref } from './ref.js';\n\n/**\n * Ensure a value is reactive. If it's already `KTReactiveLike`, return it as is; otherwise, wrap it in a `ref`.\n */\nexport const toReactive = <T>(o: T | KTReactiveLike<T>): KTReactiveLike<T> =>\n isKT(o) ? o : (ref(o as T) as KTReactive<T>);\n\n/**\n * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.\n */\nexport const dereactive = <T>(value: T | KTReactiveLike<T>): T => (isKT<T>(value) ? value.value : value);\n\nexport type { KTRef, KTSubRef, KTRefLike } from './ref.js';\nexport { ref, assertModel } from './ref.js';\nexport type { KTComputed, KTSubComputed, KTComputedLike } from './computed.js';\nexport { computed } from './computed.js';\nexport { KTReactiveType } from './reactive.js';\nexport type * from './reactive.js';\n\nexport {\n isKT,\n isReactiveLike,\n isRef,\n isSubRef,\n isRefLike,\n isComputed,\n isSubComputed,\n isComputedLike,\n isReactive,\n} from './common.js';\nexport { effect } from './effect.js';\nexport type * from './types.js';\n","import type { KTReactiveLike } from '../reactable/reactive.js';\nimport type { KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport { $initRef, type KTRefLike } from '../reactable/ref.js';\n\nimport { $forEach, $isArray } from '@ktjs/shared';\nimport { isKT, toReactive } from '../reactable/index.js';\nimport { $addNodeCleanup, AnchorType, KTAnchor } from './anchor.js';\n\nexport class FragmentAnchor extends KTAnchor<Node> {\n readonly type = AnchorType.Fragment;\n\n constructor() {\n super(AnchorType.Fragment);\n }\n\n /**\n * Remove elements in the list\n */\n removeElements() {\n const list = this.list.slice();\n this.list.length = 0;\n for (let i = 0; i < list.length; i++) {\n const node = list[i] as ChildNode;\n if (node.parentNode) {\n node.remove();\n }\n }\n }\n}\n\nexport interface FragmentProps<T extends Node = Node> {\n /** Array of child elements, supports reactive arrays */\n children: T[] | KTReactiveLike<T[]>;\n\n /** element key function for optimization (future enhancement) */\n key?: (element: T, index: number, array: T[]) => any;\n\n /** ref to get the anchor node */\n ref?: KTRefLike<JSX.Element>;\n}\n\n/**\n * Fragment - Container component for managing arrays of child elements\n *\n * Features:\n * 1. Returns a comment anchor node, child elements are inserted after the anchor\n * 2. Supports reactive arrays, automatically updates DOM when array changes\n * 3. Basic version uses simple replacement algorithm (remove all old elements, insert all new elements)\n * 4. Future enhancement: key-based optimization\n *\n * Usage example:\n * ```tsx\n * const children = ref([<div>A</div>, <div>B</div>]);\n * const fragment = <Fragment children={children} />;\n * document.body.appendChild(fragment);\n *\n * // Automatic update\n * children.value = [<div>C</div>, <div>D</div>];\n * ```\n */\nexport function Fragment<T extends Node = Node>(props: FragmentProps<T>): JSX.Element & FragmentAnchor {\n const anchor = new FragmentAnchor();\n const elements = anchor.list as T[];\n const childrenRef = toReactive(props.children);\n\n const redraw = () => {\n const newElements = childrenRef.value;\n const parent = anchor.parentNode;\n\n if (!parent) {\n elements.length = 0;\n for (let i = 0; i < newElements.length; i++) {\n elements.push(newElements[i]);\n }\n return;\n }\n\n anchor.removeElements();\n elements.length = 0;\n\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < newElements.length; i++) {\n const element = newElements[i];\n elements.push(element);\n fragment.appendChild(element);\n }\n\n parent.insertBefore(fragment, anchor.nextSibling);\n };\n\n childrenRef.addOnChange(redraw, redraw);\n $addNodeCleanup(anchor, () => childrenRef.removeOnChange(redraw));\n anchor.mountCallback = redraw;\n redraw();\n\n $initRef(props as { ref?: KTRefLike<Node> }, anchor);\n\n return anchor as unknown as JSX.Element & FragmentAnchor;\n}\n\n/**\n * Convert KTRawContent to HTMLElement array\n */\nexport function convertChildrenToElements(children: KTRawContent): Element[] {\n const elements: Element[] = [];\n\n const processChild = (child: any): void => {\n if (child === undefined || child === null || child === false || child === true) {\n // Ignore null, undefined, false, true\n return;\n }\n\n if ($isArray(child)) {\n // Recursively process array\n $forEach(child, processChild);\n return;\n }\n\n if (typeof child === 'string' || typeof child === 'number') {\n const span = document.createElement('span');\n span.textContent = String(child);\n elements.push(span);\n return;\n }\n\n if (child instanceof Element) {\n elements.push(child);\n return;\n }\n\n if (isKT(child)) {\n processChild(child.value);\n return;\n }\n\n $warn('Fragment: unsupported child type', child);\n if (process.env.IS_DEV) {\n throw new Error(`Fragment: unsupported child type`);\n }\n };\n\n processChild(children);\n return elements;\n}\n","import type { JSXTag } from '@ktjs/shared';\nimport type { KTAttribute } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport { h } from '../h/index';\n\nexport const jsxh = (tag: JSXTag, props: KTAttribute): JSX.Element =>\n (typeof tag === 'function' ? tag(props) : h(tag, props, props.children)) as JSX.Element;\n\nexport const placeholder = (data: string): JSX.Element => document.createComment(data) as unknown as JSX.Element;\n","import type { JSXTag, MathMLTag, SVGTag } from '@ktjs/shared';\nimport type { KTAttribute, KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\n\nimport { h, mathml as _mathml, svg as _svg } from '../h/index.js';\nimport { $initRef } from '../reactable/ref.js';\nimport { isComputedLike } from '../reactable/common.js';\n\nimport { convertChildrenToElements, Fragment as FragmentArray } from './fragment.js';\nimport { jsxh, placeholder } from './common.js';\n\nfunction create(\n creator: (tag: any, props: KTAttribute, content?: KTRawContent) => JSX.Element,\n tag: any,\n props: KTAttribute,\n) {\n if (props.ref && isComputedLike(props.ref)) {\n $throw('Cannot assign a computed value to an element.');\n }\n const el = creator(tag, props, props.children);\n $initRef(props, el);\n return el;\n}\n\nexport const jsx = (tag: JSXTag, props: KTAttribute): JSX.Element => create(jsxh, tag, props);\nexport const svg = (tag: SVGTag, props: KTAttribute): JSX.Element => create(_svg, tag, props);\nexport const mathml = (tag: MathMLTag, props: KTAttribute): JSX.Element => create(_mathml, tag, props);\nexport { svg as svgRuntime, mathml as mathmlRuntime };\n\n/**\n * Fragment support - returns an array of children\n * Enhanced Fragment component that manages arrays of elements\n */\nexport function Fragment(props: { children?: KTRawContent }): JSX.Element {\n const { children } = props ?? {};\n\n if (!children) {\n return placeholder('kt-fragment-empty');\n }\n\n const elements = convertChildrenToElements(children);\n\n return FragmentArray({ children: elements });\n}\n\n/**\n * JSX Development runtime - same as jsx but with additional dev checks\n */\nexport const jsxDEV: typeof jsx = (...args) => {\n // console.log('JSX DEV called:', ...args);\n // console.log('children', (args[1] as any)?.children);\n return jsx(...args);\n};\n\n/**\n * JSX runtime for React 17+ automatic runtime\n * This is called when using jsx: \"react-jsx\" or \"react-jsxdev\"\n */\nexport const jsxs = jsx;\n\n// Export h as the classic JSX factory for backward compatibility\nexport { h, h as createElement };\n","import { $isThenable } from '@ktjs/shared';\nimport type { KTComponent, KTRawContent } from '../types/h.js';\nimport type { JSX } from '../types/jsx.js';\nimport type { KTRef } from '../reactable/ref.js';\nimport { $mountFragmentAnchors } from './anchor.js';\n\n/**\n * Extract component props type (excluding ref and children)\n */\ntype ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};\n\nexport function KTAsync<T extends KTComponent>(\n props: {\n ref?: KTRef<JSX.Element>;\n skeleton?: JSX.Element;\n component: T;\n children?: KTRawContent;\n } & ExtractComponentProps<T>,\n): JSX.Element {\n const raw = props.component(props);\n let comp: JSX.Element =\n props.skeleton ?? (document.createComment('ktjs-suspense-placeholder') as unknown as JSX.Element);\n\n if ($isThenable(raw)) {\n raw.then((resolved) => {\n comp.replaceWith(resolved);\n $mountFragmentAnchors(resolved);\n });\n } else {\n comp = raw as JSX.Element;\n }\n\n return comp;\n}\n","import type { JSX } from '../types/jsx.js';\nimport type { KTRefLike } from '../reactable/ref.js';\nimport type { KTReactiveLike } from '../reactable/reactive.js';\n\nimport { $identity } from '@ktjs/shared';\nimport { toReactive } from '../reactable/index.js';\nimport { $initRef } from '../reactable/ref.js';\nimport { $addNodeCleanup } from './anchor.js';\nimport { AnchorType, KTAnchor } from './anchor.js';\n\nexport class KTForAnchor extends KTAnchor<JSX.Element> {\n readonly type = AnchorType.For;\n\n constructor() {\n super(AnchorType.For);\n }\n}\n\nexport type KTForElement = JSX.Element & KTForAnchor;\n\nexport interface KTForProps<T> {\n ref?: KTRefLike<KTForElement>;\n list: T[] | KTReactiveLike<T[]>;\n key?: (item: T, index: number, array: T[]) => any;\n map?: (item: T, index: number, array: T[]) => JSX.Element;\n}\n\nconst setForNodeMap = (nodeMap: Map<any, JSX.Element>, key: any, node: JSX.Element, index: number) => {\n if (nodeMap.has(key)) {\n $error(`[KTFor] Duplicate key detected at index ${index}. Later items override earlier ones. key=${String(key)}`);\n }\n nodeMap.set(key, node);\n};\n\n// TASK 对于template标签的for和if,会编译为fragment,可特殊处理,让它们保持原样\n/**\n * KTFor - List rendering component with key-based optimization\n * Returns a Comment anchor node with rendered elements in anchor.list\n */\nexport function KTFor<T>(props: KTForProps<T>): KTForElement {\n const redraw = () => {\n const newList = listRef.value;\n const parent = anchor.parentNode;\n\n if (!parent) {\n anchor.list.length = 0;\n nodeMap.clear();\n for (let index = 0; index < newList.length; index++) {\n const item = newList[index];\n const itemKey = currentKey(item, index, newList);\n const node = currentMap(item, index, newList);\n setForNodeMap(nodeMap, itemKey, node, index);\n anchor.list.push(node);\n }\n return anchor;\n }\n\n const oldLength = anchor.list.length;\n const newLength = newList.length;\n\n if (newLength === 0) {\n nodeMap.forEach((node) => node.remove());\n nodeMap.clear();\n anchor.list.length = 0;\n return anchor;\n }\n\n if (oldLength === 0) {\n anchor.list.length = 0;\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < newLength; i++) {\n const item = newList[i];\n const itemKey = currentKey(item, i, newList);\n const node = currentMap(item, i, newList);\n setForNodeMap(nodeMap, itemKey, node, i);\n anchor.list.push(node);\n fragment.appendChild(node);\n }\n parent.insertBefore(fragment, anchor.nextSibling);\n return anchor;\n }\n\n const newKeyToNewIndex = new Map<any, number>();\n const newElements: JSX.Element[] = new Array(newLength);\n for (let i = 0; i < newLength; i++) {\n const item = newList[i];\n const itemKey = currentKey(item, i, newList);\n newKeyToNewIndex.set(itemKey, i);\n newElements[i] = nodeMap.has(itemKey) ? nodeMap.get(itemKey)! : currentMap(item, i, newList);\n }\n\n const toRemove: JSX.Element[] = [];\n nodeMap.forEach((node, key) => {\n if (!newKeyToNewIndex.has(key)) {\n toRemove.push(node);\n }\n });\n for (let i = 0; i < toRemove.length; i++) {\n toRemove[i].remove();\n }\n\n let currentNode = anchor.nextSibling;\n for (let i = 0; i < newLength; i++) {\n const node = newElements[i];\n if (currentNode !== node) {\n parent.insertBefore(node, currentNode);\n } else {\n currentNode = currentNode.nextSibling;\n }\n }\n\n nodeMap.clear();\n anchor.list.length = 0;\n for (let i = 0; i < newLength; i++) {\n const itemKey = currentKey(newList[i], i, newList);\n const node = newElements[i];\n setForNodeMap(nodeMap, itemKey, node, i);\n anchor.list.push(node);\n }\n return anchor;\n };\n\n const currentKey: NonNullable<KTForProps<T>['key']> = props.key ?? ((item: T) => item);\n const currentMap: NonNullable<KTForProps<T>['map']> =\n props.map ?? ((item: T) => $identity(item) as unknown as JSX.Element);\n const listRef = toReactive(props.list);\n const anchor = new KTForAnchor() as KTForElement;\n const nodeMap = new Map<any, JSX.Element>();\n\n for (let index = 0; index < listRef.value.length; index++) {\n const item = listRef.value[index];\n const itemKey = currentKey(item, index, listRef.value);\n const node = currentMap(item, index, listRef.value);\n setForNodeMap(nodeMap, itemKey, node, index);\n anchor.list.push(node);\n }\n\n listRef.addOnChange(redraw, redraw);\n $addNodeCleanup(anchor, () => listRef.removeOnChange(redraw));\n anchor.mountCallback = redraw;\n $initRef(props, anchor);\n\n return anchor;\n}\n","import type { JSXTag } from '@ktjs/shared';\nimport type { KTAttribute } from '../types/h.js';\nimport type { KTReactiveLike } from '../reactable/reactive.js';\n\nimport { isKT } from '../reactable/index.js';\nimport { $addNodeCleanup, $mountFragmentAnchors, $removeNodeCleanup } from './anchor.js';\nimport { jsxh, placeholder } from './common.js';\n\nexport function KTConditional(\n condition: any | KTReactiveLike<any>,\n tagIf: JSXTag,\n propsIf: KTAttribute,\n tagElse?: JSXTag,\n propsElse?: KTAttribute,\n) {\n if (!isKT(condition)) {\n return condition ? jsxh(tagIf, propsIf) : tagElse ? jsxh(tagElse, propsElse!) : placeholder('kt-conditional');\n }\n\n if (tagElse) {\n let current = condition.value ? jsxh(tagIf, propsIf) : jsxh(tagElse!, propsElse!);\n const cleanup = () => condition.removeOnChange(onChange);\n const onChange = (newValue: any) => {\n const old = current;\n current = newValue ? jsxh(tagIf, propsIf) : jsxh(tagElse!, propsElse!);\n $removeNodeCleanup(old, cleanup);\n $addNodeCleanup(current, cleanup);\n old.replaceWith(current);\n $mountFragmentAnchors(current);\n };\n condition.addOnChange(onChange, onChange);\n $addNodeCleanup(current, cleanup);\n return current;\n } else {\n const dummy = placeholder('kt-conditional') as HTMLElement;\n let current = condition.value ? jsxh(tagIf, propsIf) : dummy;\n const cleanup = () => condition.removeOnChange(onChange);\n const onChange = (newValue: any) => {\n const old = current;\n current = newValue ? jsxh(tagIf, propsIf) : dummy;\n $removeNodeCleanup(old, cleanup);\n $addNodeCleanup(current, cleanup);\n old.replaceWith(current);\n $mountFragmentAnchors(current);\n };\n condition.addOnChange(onChange, onChange);\n $addNodeCleanup(current, cleanup);\n return current;\n }\n}\n"],"names":["isKT","obj","kid","isReactiveLike","ktype","isRef","isSubRef","isRefLike","isComputed","isSubComputed","isComputedLike","isReactive","isSubReactive","$createSubGetter","path","length","s","r","i","KTAnchor","Comment","isKTAnchor","list","mountCallback","constructor","data","super","$ensureAnchorObserver","mount","parent","this","parentNode","appendChild","CANNOT_MOUNT","document","Node","CANNOT_OBSERVE","MutationObserver","COMMENT_FILTER","NodeFilter","SHOW_COMMENT","nodeToCleanups","WeakMap","anchorObserver","$cleanupRemovedNode","node","nodeType","children","Array","from","childNodes","anchor","slice","listNode","remove","$runNodeCleanups","body","records","disconnect","undefined","addedNodes","j","$mountFragmentAnchors","removedNodes","observe","childList","subtree","$mountIfFragmentAnchor","cleanups","get","delete","error","console","$addNodeCleanup","cleanup","push","set","$removeNodeCleanup","index","indexOf","splice","nodeObj","walker","createTreeWalker","current","nextNode","booleanHandler","element","key","value","setAttribute","valueHandler","handlers","checked","selected","valueAsDate","valueAsNumber","defaultValue","defaultChecked","defaultSelected","disabled","readOnly","multiple","required","autofocus","open","controls","autoplay","loop","muted","defer","async","hidden","_key","defaultHandler","setElementStyle","style","cssText","addReactiveCleanup","reactive","handler","addOnChange","removeOnChange","applyAttr","attr","Error","classValue","class","className","v","html","setHTML","firstChild","innerHTML","o","startsWith","eventName","addEventListener","removeEventListener","attrIsObject","assureNode","$isNode","createTextNode","apdSingle","c","onChange","newValue","newNode","oldNode","replaceWith","type","apd","$isThenable","then","$isArray","ci","comment","createComment","awaited","awaitedNode","applyContent","content","applyKModel","valueRef","tagName","onValueChange","Boolean","onInput","h","tag","createElement","svg","createElementNS","mathml","handlerId","nextHandlerId","KTReactiveLike","nextKid","KTReactive","_value","_changeHandlers","Map","_newValue","warn","_emit","oldValue","forEach","has","$stringify","clearOnChange","clear","notify","map","calculator","dependencies","is","match","_keys","KTSubReactive","source","_getter","_handler","_handlerKeys","getter","dispose","reactiveToOldValue","scheduled","$markMutation","Promise","resolve","KTRef","$is","draft","subref","keys","KTSubRef","$createSubSetter","ref","assertModel","props","kmodel","$refSetter","$initRef","$emptyFn","_setter","setter","KTComputed","_calculator","_dependencies","_disposed","_recalculate","forced","uniqueSources","Set","dep","add","prototype","KTSubComputed","$deepMatch","computed","_dependency","dependency","effect","effectFn","reactives","options","lazy","onCleanup","debugName","Object","listenerKeys","active","run","err","debug","toReactive","dereactive","FragmentAnchor","removeElements","jsxh","placeholder","create","creator","el","jsx","_svg","_mathml","Fragment","elements","processChild","child","$forEach","span","textContent","String","Element","convertChildrenToElements","childrenRef","redraw","newElements","fragment","createDocumentFragment","insertBefore","nextSibling","FragmentArray","jsxDEV","args","jsxs","KTAsync","raw","component","comp","skeleton","resolved","KTForAnchor","setForNodeMap","nodeMap","KTFor","newList","listRef","item","itemKey","currentKey","currentMap","oldLength","newLength","newKeyToNewIndex","toRemove","currentNode","$identity","KTConditional","condition","tagIf","propsIf","tagElse","propsElse","old","dummy"],"mappings":";;AAKM,SAAUA,KAAcC;IAC5B,OAA2B,mBAAbA,KAAKC;AACrB;;AACM,SAAUC,eAAwBF;IACtC,OAA0B,mBAAfA,KAAKG,iBACNH,IAAIG;AAIhB;;AAEM,SAAUC,MAAeJ;IAC7B,OAA0B,mBAAfA,KAAKG,SACE,MAATH,IAAIG;AAIf;;AAEM,SAAUE,SAAkBL;IAChC,OAA0B,mBAAfA,KAAKG,SACE,MAATH,IAAIG;AAIf;;AAEM,SAAUG,UAAmBN;IACjC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