keits 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +126 -2
- package/dist/dev/index.js +435 -0
- package/dist/dev/shared/element-By0uLZli.js +544 -0
- package/dist/dev/svg.js +70 -0
- package/dist/prod/index.js +258 -0
- package/dist/prod/shared/element-C8c5hIhH.js +394 -0
- package/dist/prod/svg.js +8 -0
- package/dist/types/core/computed.d.ts +6 -0
- package/dist/types/core/context.d.ts +11 -0
- package/dist/types/core/effect.d.ts +4 -0
- package/dist/types/core/env.d.ts +1 -0
- package/dist/types/core/graph.d.ts +73 -0
- package/dist/types/core/owner.d.ts +12 -0
- package/dist/types/core/signal.d.ts +15 -0
- package/dist/types/core/store.d.ts +13 -0
- package/dist/types/core/types.d.ts +1 -0
- package/dist/types/dom/element.d.ts +3 -0
- package/dist/types/dom/events.d.ts +1 -0
- package/dist/types/dom/hooks.d.ts +8 -0
- package/dist/types/dom/index.d.ts +6 -0
- package/dist/types/dom/insert.d.ts +2 -0
- package/dist/types/dom/mount.d.ts +2 -0
- package/dist/types/dom/namespaces.d.ts +1 -0
- package/dist/types/dom/props.d.ts +3 -0
- package/dist/types/dom/render-effect.d.ts +1 -0
- package/dist/types/dom/tags.d.ts +112 -0
- package/dist/types/dom/types.d.ts +43 -0
- package/dist/types/dom/unsafe.d.ts +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/svg/element.d.ts +2 -0
- package/dist/types/svg/index.d.ts +3 -0
- package/dist/types/svg/tags.d.ts +63 -0
- package/dist/types/svg/types.d.ts +13 -0
- package/package.json +34 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Ranni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# keits
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A fine-grained reactive TypeScript framework. Real DOM, no virtual DOM, zero dependencies.
|
|
4
|
+
|
|
5
|
+
> **Status: 0.0.x, early.** This release is the **reactive core** only. The DOM layer
|
|
6
|
+
> (`$div`, `mount`, `$if`, `$for`, …), router, forms and static builds are in progress.
|
|
7
|
+
> Expect breaking changes before 1.0.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install keits
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
About 2.6 KB min+gzip for the whole core, and about 1.6 KB if you only use the basics
|
|
14
|
+
(everything is tree-shakable).
|
|
15
|
+
|
|
16
|
+
## Signals
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { signal, computed, effect } from "keits";
|
|
20
|
+
|
|
21
|
+
const count = signal(0);
|
|
22
|
+
const double = computed(() => count() * 2); // lazy and cached
|
|
23
|
+
|
|
24
|
+
effect(() => {
|
|
25
|
+
console.log(`${count()} × 2 = ${double()}`); // re-runs when count changes
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
count.set(1); // logs "1 × 2 = 2" before set() returns
|
|
29
|
+
count.set((prev) => prev + 1);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Read by calling: `count()`. Write with `.set(value)` or `.set(prev => next)`.
|
|
33
|
+
- Updates are **synchronous** and **glitch-free**: an effect never sees a half-updated state,
|
|
34
|
+
and runs once per change even when several computeds it reads changed.
|
|
35
|
+
- Equal values don't notify (`Object.is` by default; pass `{ equals }` to customise,
|
|
36
|
+
or `equals: false` to always notify).
|
|
37
|
+
- `batch(fn)` groups writes; `untrack(fn)` reads without subscribing.
|
|
38
|
+
|
|
39
|
+
## Ownership and cleanup
|
|
40
|
+
|
|
41
|
+
Every effect and computed belongs to an **owner**. Disposing the owner disposes everything
|
|
42
|
+
created inside it, so nothing leaks.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { createRoot, effect, onCleanup, onMount } from "keits";
|
|
46
|
+
|
|
47
|
+
const dispose = createRoot((dispose) => {
|
|
48
|
+
effect(() => {
|
|
49
|
+
const id = setInterval(tick, 1000);
|
|
50
|
+
onCleanup(() => clearInterval(id)); // runs before each re-run, and on dispose
|
|
51
|
+
});
|
|
52
|
+
onMount(() => console.log("ready")); // once, after the current update settles
|
|
53
|
+
return dispose;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
dispose();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- An effect created inside another effect is disposed when the outer one re-runs.
|
|
60
|
+
- Parent effects always run before their children.
|
|
61
|
+
- `getOwner()` / `runWithOwner(owner, fn)` resume an owner later, e.g. after an `await`.
|
|
62
|
+
|
|
63
|
+
## Errors
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { catchError, effect } from "keits";
|
|
67
|
+
|
|
68
|
+
catchError(
|
|
69
|
+
() => {
|
|
70
|
+
effect(() => {
|
|
71
|
+
if (input() < 0) throw new Error("negative");
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
(error) => showError(error), // error: unknown
|
|
75
|
+
);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Errors from effects, cleanups and `onMount` go to the nearest `catchError`. With none,
|
|
79
|
+
the rest of the update still finishes and the error is rethrown afterwards (several
|
|
80
|
+
become one `AggregateError`). A failed effect keeps its subscriptions and retries when
|
|
81
|
+
its inputs change.
|
|
82
|
+
|
|
83
|
+
## Context
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { createContext, provide, useContext } from "keits";
|
|
87
|
+
|
|
88
|
+
const Theme = createContext("light");
|
|
89
|
+
|
|
90
|
+
provide(Theme, "dark", () => {
|
|
91
|
+
useContext(Theme); // "dark", here and in anything created in here, even later
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Stores
|
|
96
|
+
|
|
97
|
+
Fine-grained reactivity for nested objects and arrays.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { store, reconcile, unwrap } from "keits";
|
|
101
|
+
|
|
102
|
+
const [state, setState] = store({ filter: "all", jobs: [] as Job[] });
|
|
103
|
+
|
|
104
|
+
effect(() => console.log(state.jobs[0]?.amount)); // tracks exactly that field
|
|
105
|
+
|
|
106
|
+
setState((draft) => {
|
|
107
|
+
draft.jobs.push({ id: 1, amount: 100 }); // only readers of what changed re-run
|
|
108
|
+
draft.filter = "paid";
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Fresh data from an API: keep existing objects, update only what changed
|
|
112
|
+
setState((draft) => reconcile(draft.jobs, freshJobs, { key: "id" }));
|
|
113
|
+
|
|
114
|
+
localStorage.setItem("state", JSON.stringify(unwrap(state)));
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Stores are read-only outside `setState`, enforced both by the types and at runtime in dev.
|
|
118
|
+
|
|
119
|
+
## Static rendering
|
|
120
|
+
|
|
121
|
+
`renderStatic(fn)` runs components the way a static build does: `effect` and `onMount`
|
|
122
|
+
are skipped, everything else works, and it all gets disposed afterwards. `isServer` is
|
|
123
|
+
`true` outside the browser.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { _ as runWithOwner$1, a as hooks, b as updateIfNeeded, c as addMount, d as dispose, f as getOwner$1, g as notify, h as isTracking, i as insert, l as adopt, m as isStaticRender, n as html, o as effect, p as handleError, s as addCleanup, u as batch, v as track, x as withStaticRender, y as untrack } from "./shared/element-By0uLZli.js";
|
|
2
|
+
// src/core/signal.ts
|
|
3
|
+
function signal(value, options) {
|
|
4
|
+
const node = {
|
|
5
|
+
kind: 0,
|
|
6
|
+
value,
|
|
7
|
+
equals: options?.equals ?? Object.is,
|
|
8
|
+
observers: [],
|
|
9
|
+
seenBy: 0
|
|
10
|
+
};
|
|
11
|
+
if (options?.name !== void 0) node.name = options.name;
|
|
12
|
+
const read = () => {
|
|
13
|
+
track(node);
|
|
14
|
+
return node.value;
|
|
15
|
+
};
|
|
16
|
+
const set = (next) => {
|
|
17
|
+
const value = typeof next === "function" ? next(node.value) : next;
|
|
18
|
+
if (node.equals !== false && node.equals(node.value, value)) return;
|
|
19
|
+
node.value = value;
|
|
20
|
+
notify(node);
|
|
21
|
+
};
|
|
22
|
+
return Object.assign(read, { set });
|
|
23
|
+
}
|
|
24
|
+
// src/core/computed.ts
|
|
25
|
+
function computed(fn, options) {
|
|
26
|
+
const node = {
|
|
27
|
+
kind: 2,
|
|
28
|
+
fn,
|
|
29
|
+
value: void 0,
|
|
30
|
+
equals: options?.equals ?? Object.is,
|
|
31
|
+
hasValue: false,
|
|
32
|
+
hasError: false,
|
|
33
|
+
error: void 0,
|
|
34
|
+
computing: false,
|
|
35
|
+
state: 2,
|
|
36
|
+
sources: [],
|
|
37
|
+
observers: [],
|
|
38
|
+
seenBy: 0,
|
|
39
|
+
flushId: 0,
|
|
40
|
+
flushRuns: 0,
|
|
41
|
+
owner: null,
|
|
42
|
+
children: null,
|
|
43
|
+
cleanups: null,
|
|
44
|
+
disposed: false
|
|
45
|
+
};
|
|
46
|
+
if (options?.name !== void 0) node.name = options.name;
|
|
47
|
+
adopt(node);
|
|
48
|
+
return () => {
|
|
49
|
+
if (node.computing) throw cycleError(node);
|
|
50
|
+
if (node.state !== 0) updateIfNeeded(node);
|
|
51
|
+
track(node);
|
|
52
|
+
if (node.hasError) throw node.error;
|
|
53
|
+
return node.value;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function cycleError(node) {
|
|
57
|
+
{
|
|
58
|
+
const who = node.name ? `"${node.name}"` : "a computed";
|
|
59
|
+
return /* @__PURE__ */ new Error(`[keits] Cycle detected: ${who} reads itself (directly or through other computeds).`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// src/core/env.ts
|
|
63
|
+
var isServer = typeof window === "undefined";
|
|
64
|
+
// src/core/owner.ts
|
|
65
|
+
function getOwner() {
|
|
66
|
+
return getOwner$1();
|
|
67
|
+
}
|
|
68
|
+
function runWithOwner(owner, fn) {
|
|
69
|
+
return runWithOwner$1(owner, fn);
|
|
70
|
+
}
|
|
71
|
+
function createRoot(fn) {
|
|
72
|
+
const root = {
|
|
73
|
+
kind: 3,
|
|
74
|
+
owner: getOwner$1(),
|
|
75
|
+
children: null,
|
|
76
|
+
cleanups: null,
|
|
77
|
+
disposed: false,
|
|
78
|
+
handler: null
|
|
79
|
+
};
|
|
80
|
+
const disposeRoot = () => batch(() => dispose(root));
|
|
81
|
+
return batch(() => {
|
|
82
|
+
try {
|
|
83
|
+
return runWithOwner$1(root, () => fn(disposeRoot));
|
|
84
|
+
} catch (error) {
|
|
85
|
+
dispose(root);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function onCleanup(fn) {
|
|
91
|
+
if (!addCleanup(fn) && true) console.warn("[keits] onCleanup was called outside an owner, so it will never run.");
|
|
92
|
+
}
|
|
93
|
+
function onMount(fn) {
|
|
94
|
+
addMount(fn);
|
|
95
|
+
}
|
|
96
|
+
function catchError(fn, handler) {
|
|
97
|
+
const boundary = {
|
|
98
|
+
kind: 3,
|
|
99
|
+
owner: null,
|
|
100
|
+
children: null,
|
|
101
|
+
cleanups: null,
|
|
102
|
+
disposed: false,
|
|
103
|
+
handler
|
|
104
|
+
};
|
|
105
|
+
adopt(boundary);
|
|
106
|
+
return batch(() => {
|
|
107
|
+
try {
|
|
108
|
+
return runWithOwner$1(boundary, fn);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
handleError(error, boundary);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function renderStatic(fn) {
|
|
116
|
+
return withStaticRender(() => createRoot((dispose) => {
|
|
117
|
+
try {
|
|
118
|
+
return fn();
|
|
119
|
+
} finally {
|
|
120
|
+
dispose();
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
// src/core/context.ts
|
|
125
|
+
function createContext(defaultValue, options) {
|
|
126
|
+
const context = { defaultValue };
|
|
127
|
+
if (options?.name !== void 0) context.name = options.name;
|
|
128
|
+
return context;
|
|
129
|
+
}
|
|
130
|
+
function provide(context, value, fn) {
|
|
131
|
+
const provider = {
|
|
132
|
+
kind: 3,
|
|
133
|
+
owner: null,
|
|
134
|
+
children: null,
|
|
135
|
+
cleanups: null,
|
|
136
|
+
disposed: false,
|
|
137
|
+
handler: null,
|
|
138
|
+
context: {
|
|
139
|
+
key: context,
|
|
140
|
+
value
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
adopt(provider);
|
|
144
|
+
return runWithOwner$1(provider, fn);
|
|
145
|
+
}
|
|
146
|
+
function useContext(context) {
|
|
147
|
+
for (let o = getOwner$1(); o !== null; o = o.owner) if (o.kind === 3 && o.context?.key === context) return o.context.value;
|
|
148
|
+
return context.defaultValue;
|
|
149
|
+
}
|
|
150
|
+
// src/core/store.ts
|
|
151
|
+
var RAW = Symbol("raw");
|
|
152
|
+
var SHAPE = Symbol("shape");
|
|
153
|
+
var proxies = /* @__PURE__ */ new WeakMap();
|
|
154
|
+
var nodeMaps = /* @__PURE__ */ new WeakMap();
|
|
155
|
+
var writing = 0;
|
|
156
|
+
function store(initial, options) {
|
|
157
|
+
const state = wrap(initial);
|
|
158
|
+
const name = options?.name;
|
|
159
|
+
const setState = (fn) => {
|
|
160
|
+
writing++;
|
|
161
|
+
try {
|
|
162
|
+
untrack(() => batch(() => fn(state)));
|
|
163
|
+
} finally {
|
|
164
|
+
writing--;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
if (name !== void 0) storeNames.set(unwrap(state), name);
|
|
168
|
+
return [state, setState];
|
|
169
|
+
}
|
|
170
|
+
var storeNames = /* @__PURE__ */ new WeakMap();
|
|
171
|
+
function unwrap(value) {
|
|
172
|
+
if (value !== null && typeof value === "object") {
|
|
173
|
+
const raw = value[RAW];
|
|
174
|
+
if (raw !== void 0) return raw;
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
function isWrappable(value) {
|
|
179
|
+
if (value === null || typeof value !== "object") return false;
|
|
180
|
+
if (Array.isArray(value)) return true;
|
|
181
|
+
const proto = Object.getPrototypeOf(value);
|
|
182
|
+
return proto === Object.prototype || proto === null;
|
|
183
|
+
}
|
|
184
|
+
function wrap(value) {
|
|
185
|
+
if (!isWrappable(value)) return value;
|
|
186
|
+
let proxy = proxies.get(value);
|
|
187
|
+
if (proxy === void 0) {
|
|
188
|
+
proxy = new Proxy(value, handler);
|
|
189
|
+
proxies.set(value, proxy);
|
|
190
|
+
}
|
|
191
|
+
return proxy;
|
|
192
|
+
}
|
|
193
|
+
function getNode(target, key) {
|
|
194
|
+
let nodes = nodeMaps.get(target);
|
|
195
|
+
if (nodes === void 0) nodeMaps.set(target, nodes = /* @__PURE__ */ new Map());
|
|
196
|
+
let node = nodes.get(key);
|
|
197
|
+
if (node === void 0) nodes.set(key, node = {
|
|
198
|
+
kind: 0,
|
|
199
|
+
observers: [],
|
|
200
|
+
seenBy: 0
|
|
201
|
+
});
|
|
202
|
+
return node;
|
|
203
|
+
}
|
|
204
|
+
function notifyKey(target, key) {
|
|
205
|
+
const node = nodeMaps.get(target)?.get(key);
|
|
206
|
+
if (node !== void 0) notify(node);
|
|
207
|
+
}
|
|
208
|
+
function readOnlyError(target) {
|
|
209
|
+
const name = storeNames.get(target);
|
|
210
|
+
return /* @__PURE__ */ new Error(`[keits] Store${name ? ` "${name}"` : ""} is read-only here. Change it inside setState(draft => { ... }).`);
|
|
211
|
+
}
|
|
212
|
+
var handler = {
|
|
213
|
+
get(target, key) {
|
|
214
|
+
if (key === RAW) return target;
|
|
215
|
+
const value = target[key];
|
|
216
|
+
if (isTracking() && (Object.hasOwn(target, key) || !(key in target))) track(getNode(target, key));
|
|
217
|
+
return wrap(value);
|
|
218
|
+
},
|
|
219
|
+
has(target, key) {
|
|
220
|
+
if (isTracking()) track(getNode(target, key));
|
|
221
|
+
return key in target;
|
|
222
|
+
},
|
|
223
|
+
ownKeys(target) {
|
|
224
|
+
if (isTracking()) track(getNode(target, SHAPE));
|
|
225
|
+
return Reflect.ownKeys(target);
|
|
226
|
+
},
|
|
227
|
+
set(target, key, value) {
|
|
228
|
+
if (writing === 0) {
|
|
229
|
+
const error = readOnlyError(target);
|
|
230
|
+
if (error) throw error;
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
const record = target;
|
|
234
|
+
const next = unwrap(value);
|
|
235
|
+
const hadKey = Object.hasOwn(target, key);
|
|
236
|
+
const prev = record[key];
|
|
237
|
+
const isArray = Array.isArray(target);
|
|
238
|
+
const prevLength = isArray ? target.length : 0;
|
|
239
|
+
if (hadKey && Object.is(prev, next)) return true;
|
|
240
|
+
record[key] = next;
|
|
241
|
+
notifyKey(target, key);
|
|
242
|
+
if (!hadKey) notifyKey(target, SHAPE);
|
|
243
|
+
if (isArray) {
|
|
244
|
+
const length = target.length;
|
|
245
|
+
if (length !== prevLength) {
|
|
246
|
+
if (key !== "length") notifyKey(target, "length");
|
|
247
|
+
notifyKey(target, SHAPE);
|
|
248
|
+
for (let i = length; i < prevLength; i++) notifyKey(target, String(i));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
},
|
|
253
|
+
deleteProperty(target, key) {
|
|
254
|
+
if (writing === 0) {
|
|
255
|
+
const error = readOnlyError(target);
|
|
256
|
+
if (error) throw error;
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
if (!Object.hasOwn(target, key)) return true;
|
|
260
|
+
delete target[key];
|
|
261
|
+
notifyKey(target, key);
|
|
262
|
+
notifyKey(target, SHAPE);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
function reconcile(target, source, options = {}) {
|
|
267
|
+
if (writing === 0) throw new Error("[keits] reconcile() must be called inside setState.");
|
|
268
|
+
reconcileInto(wrap(unwrap(target)), unwrap(source), options.key);
|
|
269
|
+
}
|
|
270
|
+
function reconcileInto(target, source, key) {
|
|
271
|
+
const raw = unwrap(target);
|
|
272
|
+
const draft = target;
|
|
273
|
+
if (Array.isArray(raw) && Array.isArray(source)) {
|
|
274
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
275
|
+
if (key !== void 0) {
|
|
276
|
+
for (const item of raw) if (isWrappable(item)) byKey.set(item[key], item);
|
|
277
|
+
}
|
|
278
|
+
for (let i = 0; i < source.length; i++) {
|
|
279
|
+
const next = source[i];
|
|
280
|
+
const existing = key !== void 0 && isWrappable(next) ? byKey.get(next[key]) : raw[i];
|
|
281
|
+
draft[i] = matchAndUpdate(existing, next, key);
|
|
282
|
+
}
|
|
283
|
+
if (raw.length !== source.length) draft.length = source.length;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
for (const k of Object.keys(source)) draft[k] = matchAndUpdate(raw[k], source[k], key);
|
|
287
|
+
for (const k of Object.keys(raw)) if (!Object.hasOwn(source, k)) delete draft[k];
|
|
288
|
+
}
|
|
289
|
+
function matchAndUpdate(existing, next, key) {
|
|
290
|
+
if (isWrappable(existing) && isWrappable(next) && Array.isArray(existing) === Array.isArray(next)) {
|
|
291
|
+
reconcileInto(wrap(existing), next, key);
|
|
292
|
+
return existing;
|
|
293
|
+
}
|
|
294
|
+
return next;
|
|
295
|
+
}
|
|
296
|
+
// src/dom/tags.ts
|
|
297
|
+
var $a = /* @__PURE__ */ html("a");
|
|
298
|
+
var $abbr = /* @__PURE__ */ html("abbr");
|
|
299
|
+
var $address = /* @__PURE__ */ html("address");
|
|
300
|
+
var $area = /* @__PURE__ */ html("area");
|
|
301
|
+
var $article = /* @__PURE__ */ html("article");
|
|
302
|
+
var $aside = /* @__PURE__ */ html("aside");
|
|
303
|
+
var $audio = /* @__PURE__ */ html("audio");
|
|
304
|
+
var $b = /* @__PURE__ */ html("b");
|
|
305
|
+
var $base = /* @__PURE__ */ html("base");
|
|
306
|
+
var $bdi = /* @__PURE__ */ html("bdi");
|
|
307
|
+
var $bdo = /* @__PURE__ */ html("bdo");
|
|
308
|
+
var $blockquote = /* @__PURE__ */ html("blockquote");
|
|
309
|
+
var $body = /* @__PURE__ */ html("body");
|
|
310
|
+
var $br = /* @__PURE__ */ html("br");
|
|
311
|
+
var $button = /* @__PURE__ */ html("button");
|
|
312
|
+
var $canvas = /* @__PURE__ */ html("canvas");
|
|
313
|
+
var $caption = /* @__PURE__ */ html("caption");
|
|
314
|
+
var $cite = /* @__PURE__ */ html("cite");
|
|
315
|
+
var $code = /* @__PURE__ */ html("code");
|
|
316
|
+
var $col = /* @__PURE__ */ html("col");
|
|
317
|
+
var $colgroup = /* @__PURE__ */ html("colgroup");
|
|
318
|
+
var $data = /* @__PURE__ */ html("data");
|
|
319
|
+
var $datalist = /* @__PURE__ */ html("datalist");
|
|
320
|
+
var $dd = /* @__PURE__ */ html("dd");
|
|
321
|
+
var $del = /* @__PURE__ */ html("del");
|
|
322
|
+
var $details = /* @__PURE__ */ html("details");
|
|
323
|
+
var $dfn = /* @__PURE__ */ html("dfn");
|
|
324
|
+
var $dialog = /* @__PURE__ */ html("dialog");
|
|
325
|
+
var $div = /* @__PURE__ */ html("div");
|
|
326
|
+
var $dl = /* @__PURE__ */ html("dl");
|
|
327
|
+
var $dt = /* @__PURE__ */ html("dt");
|
|
328
|
+
var $em = /* @__PURE__ */ html("em");
|
|
329
|
+
var $embed = /* @__PURE__ */ html("embed");
|
|
330
|
+
var $fieldset = /* @__PURE__ */ html("fieldset");
|
|
331
|
+
var $figcaption = /* @__PURE__ */ html("figcaption");
|
|
332
|
+
var $figure = /* @__PURE__ */ html("figure");
|
|
333
|
+
var $footer = /* @__PURE__ */ html("footer");
|
|
334
|
+
var $form = /* @__PURE__ */ html("form");
|
|
335
|
+
var $h1 = /* @__PURE__ */ html("h1");
|
|
336
|
+
var $h2 = /* @__PURE__ */ html("h2");
|
|
337
|
+
var $h3 = /* @__PURE__ */ html("h3");
|
|
338
|
+
var $h4 = /* @__PURE__ */ html("h4");
|
|
339
|
+
var $h5 = /* @__PURE__ */ html("h5");
|
|
340
|
+
var $h6 = /* @__PURE__ */ html("h6");
|
|
341
|
+
var $head = /* @__PURE__ */ html("head");
|
|
342
|
+
var $header = /* @__PURE__ */ html("header");
|
|
343
|
+
var $hgroup = /* @__PURE__ */ html("hgroup");
|
|
344
|
+
var $hr = /* @__PURE__ */ html("hr");
|
|
345
|
+
var $html = /* @__PURE__ */ html("html");
|
|
346
|
+
var $i = /* @__PURE__ */ html("i");
|
|
347
|
+
var $iframe = /* @__PURE__ */ html("iframe");
|
|
348
|
+
var $img = /* @__PURE__ */ html("img");
|
|
349
|
+
var $input = /* @__PURE__ */ html("input");
|
|
350
|
+
var $ins = /* @__PURE__ */ html("ins");
|
|
351
|
+
var $kbd = /* @__PURE__ */ html("kbd");
|
|
352
|
+
var $label = /* @__PURE__ */ html("label");
|
|
353
|
+
var $legend = /* @__PURE__ */ html("legend");
|
|
354
|
+
var $li = /* @__PURE__ */ html("li");
|
|
355
|
+
var $link = /* @__PURE__ */ html("link");
|
|
356
|
+
var $main = /* @__PURE__ */ html("main");
|
|
357
|
+
var $map = /* @__PURE__ */ html("map");
|
|
358
|
+
var $mark = /* @__PURE__ */ html("mark");
|
|
359
|
+
var $menu = /* @__PURE__ */ html("menu");
|
|
360
|
+
var $meta = /* @__PURE__ */ html("meta");
|
|
361
|
+
var $meter = /* @__PURE__ */ html("meter");
|
|
362
|
+
var $nav = /* @__PURE__ */ html("nav");
|
|
363
|
+
var $noscript = /* @__PURE__ */ html("noscript");
|
|
364
|
+
var $object = /* @__PURE__ */ html("object");
|
|
365
|
+
var $ol = /* @__PURE__ */ html("ol");
|
|
366
|
+
var $optgroup = /* @__PURE__ */ html("optgroup");
|
|
367
|
+
var $option = /* @__PURE__ */ html("option");
|
|
368
|
+
var $output = /* @__PURE__ */ html("output");
|
|
369
|
+
var $p = /* @__PURE__ */ html("p");
|
|
370
|
+
var $picture = /* @__PURE__ */ html("picture");
|
|
371
|
+
var $pre = /* @__PURE__ */ html("pre");
|
|
372
|
+
var $progress = /* @__PURE__ */ html("progress");
|
|
373
|
+
var $q = /* @__PURE__ */ html("q");
|
|
374
|
+
var $rp = /* @__PURE__ */ html("rp");
|
|
375
|
+
var $rt = /* @__PURE__ */ html("rt");
|
|
376
|
+
var $ruby = /* @__PURE__ */ html("ruby");
|
|
377
|
+
var $s = /* @__PURE__ */ html("s");
|
|
378
|
+
var $samp = /* @__PURE__ */ html("samp");
|
|
379
|
+
var $script = /* @__PURE__ */ html("script");
|
|
380
|
+
var $search = /* @__PURE__ */ html("search");
|
|
381
|
+
var $section = /* @__PURE__ */ html("section");
|
|
382
|
+
var $select = /* @__PURE__ */ html("select");
|
|
383
|
+
var $slot = /* @__PURE__ */ html("slot");
|
|
384
|
+
var $small = /* @__PURE__ */ html("small");
|
|
385
|
+
var $source = /* @__PURE__ */ html("source");
|
|
386
|
+
var $span = /* @__PURE__ */ html("span");
|
|
387
|
+
var $strong = /* @__PURE__ */ html("strong");
|
|
388
|
+
var $style = /* @__PURE__ */ html("style");
|
|
389
|
+
var $sub = /* @__PURE__ */ html("sub");
|
|
390
|
+
var $summary = /* @__PURE__ */ html("summary");
|
|
391
|
+
var $sup = /* @__PURE__ */ html("sup");
|
|
392
|
+
var $table = /* @__PURE__ */ html("table");
|
|
393
|
+
var $tbody = /* @__PURE__ */ html("tbody");
|
|
394
|
+
var $td = /* @__PURE__ */ html("td");
|
|
395
|
+
var $template = /* @__PURE__ */ html("template");
|
|
396
|
+
var $textarea = /* @__PURE__ */ html("textarea");
|
|
397
|
+
var $tfoot = /* @__PURE__ */ html("tfoot");
|
|
398
|
+
var $th = /* @__PURE__ */ html("th");
|
|
399
|
+
var $thead = /* @__PURE__ */ html("thead");
|
|
400
|
+
var $time = /* @__PURE__ */ html("time");
|
|
401
|
+
var $title = /* @__PURE__ */ html("title");
|
|
402
|
+
var $tr = /* @__PURE__ */ html("tr");
|
|
403
|
+
var $track = /* @__PURE__ */ html("track");
|
|
404
|
+
var $u = /* @__PURE__ */ html("u");
|
|
405
|
+
var $ul = /* @__PURE__ */ html("ul");
|
|
406
|
+
var $var = /* @__PURE__ */ html("var");
|
|
407
|
+
var $video = /* @__PURE__ */ html("video");
|
|
408
|
+
var $wbr = /* @__PURE__ */ html("wbr");
|
|
409
|
+
// src/dom/mount.ts
|
|
410
|
+
function mount(app, target) {
|
|
411
|
+
if (target === null) throw new Error("[keits] mount(): the target element was not found (null).");
|
|
412
|
+
const start = hooks.marker();
|
|
413
|
+
const end = hooks.marker();
|
|
414
|
+
target.append(start, end);
|
|
415
|
+
const dispose = createRoot((dispose) => {
|
|
416
|
+
insert(target, app(), end);
|
|
417
|
+
return dispose;
|
|
418
|
+
});
|
|
419
|
+
return () => {
|
|
420
|
+
dispose();
|
|
421
|
+
let node = start;
|
|
422
|
+
while (node !== null) {
|
|
423
|
+
const next = node === end ? null : node.nextSibling;
|
|
424
|
+
node.remove();
|
|
425
|
+
node = next;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
// src/dom/unsafe.ts
|
|
430
|
+
function unsafeHTML(markup) {
|
|
431
|
+
const template = document.createElement("template");
|
|
432
|
+
template.innerHTML = markup;
|
|
433
|
+
return template.content;
|
|
434
|
+
}
|
|
435
|
+
export { $a, $abbr, $address, $area, $article, $aside, $audio, $b, $base, $bdi, $bdo, $blockquote, $body, $br, $button, $canvas, $caption, $cite, $code, $col, $colgroup, $data, $datalist, $dd, $del, $details, $dfn, $dialog, $div, $dl, $dt, $em, $embed, $fieldset, $figcaption, $figure, $footer, $form, $h1, $h2, $h3, $h4, $h5, $h6, $head, $header, $hgroup, $hr, $html, $i, $iframe, $img, $input, $ins, $kbd, $label, $legend, $li, $link, $main, $map, $mark, $menu, $meta, $meter, $nav, $noscript, $object, $ol, $optgroup, $option, $output, $p, $picture, $pre, $progress, $q, $rp, $rt, $ruby, $s, $samp, $script, $search, $section, $select, $slot, $small, $source, $span, $strong, $style, $sub, $summary, $sup, $table, $tbody, $td, $template, $textarea, $tfoot, $th, $thead, $time, $title, $tr, $track, $u, $ul, $var, $video, $wbr, batch, catchError, computed, createContext, createRoot, effect, getOwner, html, insert, isServer, isStaticRender, mount, onCleanup, onMount, provide, reconcile, renderStatic, runWithOwner, signal, store, unsafeHTML, untrack, unwrap, useContext };
|