keits 0.0.0-stage → 0.0.1

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 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
- # Temporary Holding Version
1
+ # keits
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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,604 @@
1
+ var LOOP_LIMIT = 100;
2
+ var currentObserver = null;
3
+ var currentOwner = null;
4
+ var currentRunId = 0;
5
+ var runCounter = 0;
6
+ var newSources = null;
7
+ var keptCount = 0;
8
+ var batchDepth = 0;
9
+ var flushCounter = 0;
10
+ var queue = [];
11
+ var mounts = [];
12
+ var lastWritten = null;
13
+ var unhandledErrors = [];
14
+ var staticDepth = 0;
15
+ function track(source) {
16
+ const observer = currentObserver;
17
+ if (observer === null || source.seenBy === currentRunId) return;
18
+ source.seenBy = currentRunId;
19
+ if (newSources === null && observer.sources[keptCount] === source) {
20
+ keptCount++;
21
+ return;
22
+ }
23
+ (newSources ??= []).push(source);
24
+ source.observers.push(observer);
25
+ }
26
+ function isTracking() {
27
+ return currentObserver !== null;
28
+ }
29
+ function notify(source) {
30
+ if (source.observers.length === 0) return;
31
+ lastWritten = source;
32
+ batchDepth++;
33
+ try {
34
+ for (const observer of source.observers) mark(observer, 2);
35
+ } finally {
36
+ endBatch();
37
+ }
38
+ }
39
+ function mark(node, state) {
40
+ if (node.state >= state) return;
41
+ const wasClean = node.state === 0;
42
+ node.state = state;
43
+ if (!wasClean) return;
44
+ if (node.kind === 1) queue.push(node);
45
+ else for (const observer of node.observers) mark(observer, 1);
46
+ }
47
+ function updateIfNeeded(node) {
48
+ if (node.state === 1) for (const source of node.sources) {
49
+ if (source.kind !== 2) continue;
50
+ updateIfNeeded(source);
51
+ if (node.state === 2) break;
52
+ }
53
+ if (node.state === 2) {
54
+ if (node.kind === 1) runEffect(node);
55
+ else recompute(node);
56
+ } else node.state = 0;
57
+ }
58
+ function recompute(node) {
59
+ let changed;
60
+ node.computing = true;
61
+ try {
62
+ const next = run(node, () => node.fn(node.value));
63
+ changed = !node.hasValue || node.hasError || node.equals === false || !node.equals(node.value, next);
64
+ if (changed) node.value = next;
65
+ node.hasValue = true;
66
+ node.hasError = false;
67
+ node.error = void 0;
68
+ } catch (error) {
69
+ changed = true;
70
+ node.hasError = true;
71
+ node.error = error;
72
+ } finally {
73
+ node.computing = false;
74
+ }
75
+ if (changed) {
76
+ for (const observer of node.observers) if (observer.state === 1) observer.state = 2;
77
+ }
78
+ }
79
+ function runEffect(node) {
80
+ try {
81
+ run(node, node.fn);
82
+ } catch (error) {
83
+ handleError(error, node);
84
+ }
85
+ }
86
+ function run(node, fn) {
87
+ cleanNode(node);
88
+ const prevObserver = currentObserver;
89
+ const prevOwner = currentOwner;
90
+ const prevRunId = currentRunId;
91
+ const prevNew = newSources;
92
+ const prevKept = keptCount;
93
+ currentObserver = node;
94
+ currentOwner = node;
95
+ currentRunId = ++runCounter;
96
+ newSources = null;
97
+ keptCount = 0;
98
+ node.state = 0;
99
+ try {
100
+ return fn();
101
+ } finally {
102
+ updateSources(node, newSources, keptCount);
103
+ currentObserver = prevObserver;
104
+ currentOwner = prevOwner;
105
+ currentRunId = prevRunId;
106
+ newSources = prevNew;
107
+ keptCount = prevKept;
108
+ }
109
+ }
110
+ function updateSources(node, added, kept) {
111
+ if (node.disposed) {
112
+ if (added !== null) for (const source of added) unlink(source, node);
113
+ return;
114
+ }
115
+ const sources = node.sources;
116
+ for (let i = kept; i < sources.length; i++) unlink(sources[i], node);
117
+ sources.length = kept;
118
+ if (added !== null) for (const source of added) sources.push(source);
119
+ }
120
+ function unlink(source, node) {
121
+ const observers = source.observers;
122
+ const i = observers.lastIndexOf(node);
123
+ if (i === -1) return;
124
+ observers[i] = observers[observers.length - 1];
125
+ observers.pop();
126
+ }
127
+ function batch(fn) {
128
+ batchDepth++;
129
+ try {
130
+ return fn();
131
+ } finally {
132
+ endBatch();
133
+ }
134
+ }
135
+ function endBatch() {
136
+ if (--batchDepth === 0) settle();
137
+ }
138
+ function settle() {
139
+ do {
140
+ flush();
141
+ if (mounts.length > 0) runMounts();
142
+ } while (queue.length > 0 || mounts.length > 0);
143
+ if (unhandledErrors.length > 0) {
144
+ const errors = unhandledErrors.splice(0);
145
+ throw errors.length === 1 ? errors[0] : new AggregateError(errors, "[keits] multiple unhandled errors");
146
+ }
147
+ }
148
+ function runMounts() {
149
+ batchDepth++;
150
+ const pending = mounts.splice(0);
151
+ try {
152
+ for (const { owner, fn } of pending) {
153
+ if (owner?.disposed) continue;
154
+ try {
155
+ runWithOwner$1(owner, fn);
156
+ } catch (error) {
157
+ handleError(error, owner);
158
+ }
159
+ }
160
+ } finally {
161
+ batchDepth--;
162
+ }
163
+ }
164
+ function flush() {
165
+ batchDepth++;
166
+ const flushId = ++flushCounter;
167
+ let completed = false;
168
+ try {
169
+ for (let i = 0; i < queue.length; i++) {
170
+ const node = queue[i];
171
+ if (node.state === 0) continue;
172
+ if (node.flushId !== flushId) {
173
+ node.flushId = flushId;
174
+ node.flushRuns = 0;
175
+ }
176
+ if (++node.flushRuns > LOOP_LIMIT) {
177
+ node.state = 0;
178
+ handleError(loopError(node), node);
179
+ continue;
180
+ }
181
+ runTop(node);
182
+ }
183
+ completed = true;
184
+ } finally {
185
+ if (!completed) for (const node of queue) node.state = 0;
186
+ queue.length = 0;
187
+ batchDepth--;
188
+ }
189
+ }
190
+ function runTop(node) {
191
+ const staleOwners = [];
192
+ for (let o = node.owner; o !== null; o = o.owner) if (o.kind !== 3 && o.state !== 0) staleOwners.push(o);
193
+ for (let i = staleOwners.length - 1; i >= 0; i--) updateIfNeeded(staleOwners[i]);
194
+ updateIfNeeded(node);
195
+ }
196
+ function loopError(node) {
197
+ {
198
+ const who = node.name ? `"${node.name}"` : "an unnamed effect";
199
+ const what = lastWritten?.name ? ` Last signal written: "${lastWritten.name}".` : "";
200
+ return /* @__PURE__ */ new Error(`[keits] Infinite update loop: ${who} re-ran ${LOOP_LIMIT} times in one update. It probably writes a signal it also reads.${what}`);
201
+ }
202
+ }
203
+ function untrack(fn) {
204
+ const prev = currentObserver;
205
+ currentObserver = null;
206
+ try {
207
+ return fn();
208
+ } finally {
209
+ currentObserver = prev;
210
+ }
211
+ }
212
+ function adopt(node) {
213
+ const owner = currentOwner;
214
+ node.owner = owner;
215
+ if (owner !== null) (owner.children ??= []).push(node);
216
+ }
217
+ function getOwner$1() {
218
+ return currentOwner;
219
+ }
220
+ function runWithOwner$1(owner, fn) {
221
+ const prevOwner = currentOwner;
222
+ const prevObserver = currentObserver;
223
+ currentOwner = owner;
224
+ currentObserver = null;
225
+ try {
226
+ return fn();
227
+ } finally {
228
+ currentOwner = prevOwner;
229
+ currentObserver = prevObserver;
230
+ }
231
+ }
232
+ function addCleanup(fn) {
233
+ if (currentOwner === null) return false;
234
+ (currentOwner.cleanups ??= []).push(fn);
235
+ return true;
236
+ }
237
+ function addMount(fn) {
238
+ if (staticDepth > 0) return;
239
+ mounts.push({
240
+ owner: currentOwner,
241
+ fn
242
+ });
243
+ }
244
+ function cleanNode(node) {
245
+ const children = node.children;
246
+ const cleanups = node.cleanups;
247
+ node.children = null;
248
+ node.cleanups = null;
249
+ if (children !== null) for (let i = children.length - 1; i >= 0; i--) dispose(children[i]);
250
+ if (cleanups !== null) for (let i = cleanups.length - 1; i >= 0; i--) try {
251
+ cleanups[i]();
252
+ } catch (error) {
253
+ handleError(error, node);
254
+ }
255
+ }
256
+ function dispose(node) {
257
+ if (node.disposed) return;
258
+ node.disposed = true;
259
+ if (node.kind !== 3) {
260
+ for (const source of node.sources) unlink(source, node);
261
+ node.sources.length = 0;
262
+ node.state = 0;
263
+ }
264
+ cleanNode(node);
265
+ }
266
+ function handleError(error, owner) {
267
+ for (let o = owner; o !== null; o = o.owner) {
268
+ if (o.kind !== 3 || o.handler === null || o.disposed) continue;
269
+ const handler = o.handler;
270
+ try {
271
+ runWithOwner$1(o.owner, () => handler(error));
272
+ return;
273
+ } catch (handlerError) {
274
+ error = handlerError;
275
+ }
276
+ }
277
+ if (batchDepth === 0) throw error;
278
+ unhandledErrors.push(error);
279
+ }
280
+ function isStaticRender() {
281
+ return staticDepth > 0;
282
+ }
283
+ function withStaticRender(fn) {
284
+ staticDepth++;
285
+ try {
286
+ return fn();
287
+ } finally {
288
+ staticDepth--;
289
+ }
290
+ }
291
+ // src/core/signal.ts
292
+ function signal(value, options) {
293
+ const node = {
294
+ kind: 0,
295
+ value,
296
+ equals: options?.equals ?? Object.is,
297
+ observers: [],
298
+ seenBy: 0
299
+ };
300
+ if (options?.name !== void 0) node.name = options.name;
301
+ const read = () => {
302
+ track(node);
303
+ return node.value;
304
+ };
305
+ const set = (next) => {
306
+ const value = typeof next === "function" ? next(node.value) : next;
307
+ if (node.equals !== false && node.equals(node.value, value)) return;
308
+ node.value = value;
309
+ notify(node);
310
+ };
311
+ return Object.assign(read, { set });
312
+ }
313
+ // src/core/effect.ts
314
+ function effect(fn, options) {
315
+ if (isStaticRender()) return;
316
+ const node = {
317
+ kind: 1,
318
+ fn,
319
+ state: 0,
320
+ sources: [],
321
+ flushId: 0,
322
+ flushRuns: 0,
323
+ owner: null,
324
+ children: null,
325
+ cleanups: null,
326
+ disposed: false
327
+ };
328
+ if (options?.name !== void 0) node.name = options.name;
329
+ adopt(node);
330
+ batch(() => runEffect(node));
331
+ }
332
+ // src/core/computed.ts
333
+ function computed(fn, options) {
334
+ const node = {
335
+ kind: 2,
336
+ fn,
337
+ value: void 0,
338
+ equals: options?.equals ?? Object.is,
339
+ hasValue: false,
340
+ hasError: false,
341
+ error: void 0,
342
+ computing: false,
343
+ state: 2,
344
+ sources: [],
345
+ observers: [],
346
+ seenBy: 0,
347
+ flushId: 0,
348
+ flushRuns: 0,
349
+ owner: null,
350
+ children: null,
351
+ cleanups: null,
352
+ disposed: false
353
+ };
354
+ if (options?.name !== void 0) node.name = options.name;
355
+ adopt(node);
356
+ return () => {
357
+ if (node.computing) throw cycleError(node);
358
+ if (node.state !== 0) updateIfNeeded(node);
359
+ track(node);
360
+ if (node.hasError) throw node.error;
361
+ return node.value;
362
+ };
363
+ }
364
+ function cycleError(node) {
365
+ {
366
+ const who = node.name ? `"${node.name}"` : "a computed";
367
+ return /* @__PURE__ */ new Error(`[keits] Cycle detected: ${who} reads itself (directly or through other computeds).`);
368
+ }
369
+ }
370
+ // src/core/env.ts
371
+ var isServer = typeof window === "undefined";
372
+ // src/core/owner.ts
373
+ function getOwner() {
374
+ return getOwner$1();
375
+ }
376
+ function runWithOwner(owner, fn) {
377
+ return runWithOwner$1(owner, fn);
378
+ }
379
+ function createRoot(fn) {
380
+ const root = {
381
+ kind: 3,
382
+ owner: getOwner$1(),
383
+ children: null,
384
+ cleanups: null,
385
+ disposed: false,
386
+ handler: null
387
+ };
388
+ const disposeRoot = () => batch(() => dispose(root));
389
+ return batch(() => {
390
+ try {
391
+ return runWithOwner$1(root, () => fn(disposeRoot));
392
+ } catch (error) {
393
+ dispose(root);
394
+ throw error;
395
+ }
396
+ });
397
+ }
398
+ function onCleanup(fn) {
399
+ if (!addCleanup(fn) && true) console.warn("[keits] onCleanup was called outside an owner, so it will never run.");
400
+ }
401
+ function onMount(fn) {
402
+ addMount(fn);
403
+ }
404
+ function catchError(fn, handler) {
405
+ const boundary = {
406
+ kind: 3,
407
+ owner: null,
408
+ children: null,
409
+ cleanups: null,
410
+ disposed: false,
411
+ handler
412
+ };
413
+ adopt(boundary);
414
+ return batch(() => {
415
+ try {
416
+ return runWithOwner$1(boundary, fn);
417
+ } catch (error) {
418
+ handleError(error, boundary);
419
+ return;
420
+ }
421
+ });
422
+ }
423
+ function renderStatic(fn) {
424
+ return withStaticRender(() => createRoot((dispose) => {
425
+ try {
426
+ return fn();
427
+ } finally {
428
+ dispose();
429
+ }
430
+ }));
431
+ }
432
+ // src/core/context.ts
433
+ function createContext(defaultValue, options) {
434
+ const context = { defaultValue };
435
+ if (options?.name !== void 0) context.name = options.name;
436
+ return context;
437
+ }
438
+ function provide(context, value, fn) {
439
+ const provider = {
440
+ kind: 3,
441
+ owner: null,
442
+ children: null,
443
+ cleanups: null,
444
+ disposed: false,
445
+ handler: null,
446
+ context: {
447
+ key: context,
448
+ value
449
+ }
450
+ };
451
+ adopt(provider);
452
+ return runWithOwner$1(provider, fn);
453
+ }
454
+ function useContext(context) {
455
+ for (let o = getOwner$1(); o !== null; o = o.owner) if (o.kind === 3 && o.context?.key === context) return o.context.value;
456
+ return context.defaultValue;
457
+ }
458
+ // src/core/store.ts
459
+ var RAW = Symbol("raw");
460
+ var SHAPE = Symbol("shape");
461
+ var proxies = /* @__PURE__ */ new WeakMap();
462
+ var nodeMaps = /* @__PURE__ */ new WeakMap();
463
+ var writing = 0;
464
+ function store(initial, options) {
465
+ const state = wrap(initial);
466
+ const name = options?.name;
467
+ const setState = (fn) => {
468
+ writing++;
469
+ try {
470
+ untrack(() => batch(() => fn(state)));
471
+ } finally {
472
+ writing--;
473
+ }
474
+ };
475
+ if (name !== void 0) storeNames.set(unwrap(state), name);
476
+ return [state, setState];
477
+ }
478
+ var storeNames = /* @__PURE__ */ new WeakMap();
479
+ function unwrap(value) {
480
+ if (value !== null && typeof value === "object") {
481
+ const raw = value[RAW];
482
+ if (raw !== void 0) return raw;
483
+ }
484
+ return value;
485
+ }
486
+ function isWrappable(value) {
487
+ if (value === null || typeof value !== "object") return false;
488
+ if (Array.isArray(value)) return true;
489
+ const proto = Object.getPrototypeOf(value);
490
+ return proto === Object.prototype || proto === null;
491
+ }
492
+ function wrap(value) {
493
+ if (!isWrappable(value)) return value;
494
+ let proxy = proxies.get(value);
495
+ if (proxy === void 0) {
496
+ proxy = new Proxy(value, handler);
497
+ proxies.set(value, proxy);
498
+ }
499
+ return proxy;
500
+ }
501
+ function getNode(target, key) {
502
+ let nodes = nodeMaps.get(target);
503
+ if (nodes === void 0) nodeMaps.set(target, nodes = /* @__PURE__ */ new Map());
504
+ let node = nodes.get(key);
505
+ if (node === void 0) nodes.set(key, node = {
506
+ kind: 0,
507
+ observers: [],
508
+ seenBy: 0
509
+ });
510
+ return node;
511
+ }
512
+ function notifyKey(target, key) {
513
+ const node = nodeMaps.get(target)?.get(key);
514
+ if (node !== void 0) notify(node);
515
+ }
516
+ function readOnlyError(target) {
517
+ const name = storeNames.get(target);
518
+ return /* @__PURE__ */ new Error(`[keits] Store${name ? ` "${name}"` : ""} is read-only here. Change it inside setState(draft => { ... }).`);
519
+ }
520
+ var handler = {
521
+ get(target, key) {
522
+ if (key === RAW) return target;
523
+ const value = target[key];
524
+ if (isTracking() && (Object.hasOwn(target, key) || !(key in target))) track(getNode(target, key));
525
+ return wrap(value);
526
+ },
527
+ has(target, key) {
528
+ if (isTracking()) track(getNode(target, key));
529
+ return key in target;
530
+ },
531
+ ownKeys(target) {
532
+ if (isTracking()) track(getNode(target, SHAPE));
533
+ return Reflect.ownKeys(target);
534
+ },
535
+ set(target, key, value) {
536
+ if (writing === 0) {
537
+ const error = readOnlyError(target);
538
+ if (error) throw error;
539
+ return false;
540
+ }
541
+ const record = target;
542
+ const next = unwrap(value);
543
+ const hadKey = Object.hasOwn(target, key);
544
+ const prev = record[key];
545
+ const isArray = Array.isArray(target);
546
+ const prevLength = isArray ? target.length : 0;
547
+ if (hadKey && Object.is(prev, next)) return true;
548
+ record[key] = next;
549
+ notifyKey(target, key);
550
+ if (!hadKey) notifyKey(target, SHAPE);
551
+ if (isArray) {
552
+ const length = target.length;
553
+ if (length !== prevLength) {
554
+ if (key !== "length") notifyKey(target, "length");
555
+ notifyKey(target, SHAPE);
556
+ for (let i = length; i < prevLength; i++) notifyKey(target, String(i));
557
+ }
558
+ }
559
+ return true;
560
+ },
561
+ deleteProperty(target, key) {
562
+ if (writing === 0) {
563
+ const error = readOnlyError(target);
564
+ if (error) throw error;
565
+ return false;
566
+ }
567
+ if (!Object.hasOwn(target, key)) return true;
568
+ delete target[key];
569
+ notifyKey(target, key);
570
+ notifyKey(target, SHAPE);
571
+ return true;
572
+ }
573
+ };
574
+ function reconcile(target, source, options = {}) {
575
+ if (writing === 0) throw new Error("[keits] reconcile() must be called inside setState.");
576
+ reconcileInto(wrap(unwrap(target)), unwrap(source), options.key);
577
+ }
578
+ function reconcileInto(target, source, key) {
579
+ const raw = unwrap(target);
580
+ const draft = target;
581
+ if (Array.isArray(raw) && Array.isArray(source)) {
582
+ const byKey = /* @__PURE__ */ new Map();
583
+ if (key !== void 0) {
584
+ for (const item of raw) if (isWrappable(item)) byKey.set(item[key], item);
585
+ }
586
+ for (let i = 0; i < source.length; i++) {
587
+ const next = source[i];
588
+ const existing = key !== void 0 && isWrappable(next) ? byKey.get(next[key]) : raw[i];
589
+ draft[i] = matchAndUpdate(existing, next, key);
590
+ }
591
+ if (raw.length !== source.length) draft.length = source.length;
592
+ return;
593
+ }
594
+ for (const k of Object.keys(source)) draft[k] = matchAndUpdate(raw[k], source[k], key);
595
+ for (const k of Object.keys(raw)) if (!Object.hasOwn(source, k)) delete draft[k];
596
+ }
597
+ function matchAndUpdate(existing, next, key) {
598
+ if (isWrappable(existing) && isWrappable(next) && Array.isArray(existing) === Array.isArray(next)) {
599
+ reconcileInto(wrap(existing), next, key);
600
+ return existing;
601
+ }
602
+ return next;
603
+ }
604
+ export { batch, catchError, computed, createContext, createRoot, effect, getOwner, isServer, isStaticRender, onCleanup, onMount, provide, reconcile, renderStatic, runWithOwner, signal, store, untrack, unwrap, useContext };
@@ -0,0 +1,460 @@
1
+ var e = null, t = null, n = 0, r = 0, i = null, a = 0, o = 0, s = 0, c = [], l = [], u = [], d = 0;
2
+ function f(t) {
3
+ let r = e;
4
+ r !== null && t.seenBy !== n && (t.seenBy = n, i === null && r.sources[a] === t ? a++ : ((i ??= []).push(t), t.observers.push(r)));
5
+ }
6
+ function p() {
7
+ return e !== null;
8
+ }
9
+ function m(e) {
10
+ if (e.observers.length !== 0) {
11
+ o++;
12
+ try {
13
+ for (let t of e.observers) h(t, 2);
14
+ } finally {
15
+ S();
16
+ }
17
+ }
18
+ }
19
+ function h(e, t) {
20
+ if (e.state >= t) return;
21
+ let n = e.state === 0;
22
+ if (e.state = t, n) {
23
+ if (e.kind === 1) c.push(e);
24
+ else for (let t of e.observers) h(t, 1);
25
+ }
26
+ }
27
+ function g(e) {
28
+ if (e.state === 1) {
29
+ for (let t of e.sources) if (t.kind === 2 && (g(t), e.state === 2)) break;
30
+ }
31
+ e.state === 2 ? e.kind === 1 ? _(e) : ee(e) : e.state = 0;
32
+ }
33
+ function ee(e) {
34
+ let t;
35
+ e.computing = !0;
36
+ try {
37
+ let n = v(e, () => e.fn(e.value));
38
+ t = !e.hasValue || e.hasError || e.equals === !1 || !e.equals(e.value, n), t && (e.value = n), e.hasValue = !0, e.hasError = !1, e.error = void 0;
39
+ } catch (n) {
40
+ t = !0, e.hasError = !0, e.error = n;
41
+ } finally {
42
+ e.computing = !1;
43
+ }
44
+ if (t) for (let t of e.observers) t.state === 1 && (t.state = 2);
45
+ }
46
+ function _(e) {
47
+ try {
48
+ v(e, e.fn);
49
+ } catch (t) {
50
+ j(t, e);
51
+ }
52
+ }
53
+ function v(o, s) {
54
+ k(o);
55
+ let c = e, l = t, u = n, d = i, f = a;
56
+ e = o, t = o, n = ++r, i = null, a = 0, o.state = 0;
57
+ try {
58
+ return s();
59
+ } finally {
60
+ y(o, i, a), e = c, t = l, n = u, i = d, a = f;
61
+ }
62
+ }
63
+ function y(e, t, n) {
64
+ if (e.disposed) {
65
+ if (t !== null) for (let n of t) b(n, e);
66
+ return;
67
+ }
68
+ let r = e.sources;
69
+ for (let t = n; t < r.length; t++) b(r[t], e);
70
+ if (r.length = n, t !== null) for (let e of t) r.push(e);
71
+ }
72
+ function b(e, t) {
73
+ let n = e.observers, r = n.lastIndexOf(t);
74
+ r !== -1 && (n[r] = n[n.length - 1], n.pop());
75
+ }
76
+ function x(e) {
77
+ o++;
78
+ try {
79
+ return e();
80
+ } finally {
81
+ S();
82
+ }
83
+ }
84
+ function S() {
85
+ --o === 0 && te();
86
+ }
87
+ function te() {
88
+ do
89
+ w(), l.length > 0 && C();
90
+ while (c.length > 0 || l.length > 0);
91
+ if (u.length > 0) {
92
+ let e = u.splice(0);
93
+ throw e.length === 1 ? e[0] : AggregateError(e, "[keits] multiple unhandled errors");
94
+ }
95
+ }
96
+ function C() {
97
+ o++;
98
+ let e = l.splice(0);
99
+ try {
100
+ for (let { owner: t, fn: n } of e) if (!t?.disposed) try {
101
+ O(t, n);
102
+ } catch (e) {
103
+ j(e, t);
104
+ }
105
+ } finally {
106
+ o--;
107
+ }
108
+ }
109
+ function w() {
110
+ o++;
111
+ let e = ++s, t = !1;
112
+ try {
113
+ for (let t = 0; t < c.length; t++) {
114
+ let n = c[t];
115
+ n.state !== 0 && (n.flushId !== e && (n.flushId = e, n.flushRuns = 0), ++n.flushRuns > 100 ? (n.state = 0, j(re(n), n)) : ne(n));
116
+ }
117
+ t = !0;
118
+ } finally {
119
+ if (!t) for (let e of c) e.state = 0;
120
+ c.length = 0, o--;
121
+ }
122
+ }
123
+ function ne(e) {
124
+ let t = [];
125
+ for (let n = e.owner; n !== null; n = n.owner) n.kind !== 3 && n.state !== 0 && t.push(n);
126
+ for (let e = t.length - 1; e >= 0; e--) g(t[e]);
127
+ g(e);
128
+ }
129
+ function re(e) {
130
+ return /* @__PURE__ */ Error("[keits] infinite update loop");
131
+ }
132
+ function T(t) {
133
+ let n = e;
134
+ e = null;
135
+ try {
136
+ return t();
137
+ } finally {
138
+ e = n;
139
+ }
140
+ }
141
+ function E(e) {
142
+ let n = t;
143
+ e.owner = n, n !== null && (n.children ??= []).push(e);
144
+ }
145
+ function D() {
146
+ return t;
147
+ }
148
+ function O(n, r) {
149
+ let i = t, a = e;
150
+ t = n, e = null;
151
+ try {
152
+ return r();
153
+ } finally {
154
+ t = i, e = a;
155
+ }
156
+ }
157
+ function ie(e) {
158
+ return t !== null && ((t.cleanups ??= []).push(e), !0);
159
+ }
160
+ function ae(e) {
161
+ d > 0 || l.push({
162
+ owner: t,
163
+ fn: e
164
+ });
165
+ }
166
+ function k(e) {
167
+ let t = e.children, n = e.cleanups;
168
+ if (e.children = null, e.cleanups = null, t !== null) for (let e = t.length - 1; e >= 0; e--) A(t[e]);
169
+ if (n !== null) for (let t = n.length - 1; t >= 0; t--) try {
170
+ n[t]();
171
+ } catch (t) {
172
+ j(t, e);
173
+ }
174
+ }
175
+ function A(e) {
176
+ if (!e.disposed) {
177
+ if (e.disposed = !0, e.kind !== 3) {
178
+ for (let t of e.sources) b(t, e);
179
+ e.sources.length = 0, e.state = 0;
180
+ }
181
+ k(e);
182
+ }
183
+ }
184
+ function j(e, t) {
185
+ for (let n = t; n !== null; n = n.owner) {
186
+ if (n.kind !== 3 || n.handler === null || n.disposed) continue;
187
+ let t = n.handler;
188
+ try {
189
+ O(n.owner, () => t(e));
190
+ return;
191
+ } catch (t) {
192
+ e = t;
193
+ }
194
+ }
195
+ if (o === 0) throw e;
196
+ u.push(e);
197
+ }
198
+ function M() {
199
+ return d > 0;
200
+ }
201
+ function oe(e) {
202
+ d++;
203
+ try {
204
+ return e();
205
+ } finally {
206
+ d--;
207
+ }
208
+ }
209
+ // src/core/signal.ts
210
+ function se(e, t) {
211
+ let n = {
212
+ kind: 0,
213
+ value: e,
214
+ equals: t?.equals ?? Object.is,
215
+ observers: [],
216
+ seenBy: 0
217
+ };
218
+ return Object.assign(() => (f(n), n.value), { set: (e) => {
219
+ let t = typeof e == "function" ? e(n.value) : e;
220
+ n.equals !== !1 && n.equals(n.value, t) || (n.value = t, m(n));
221
+ } });
222
+ }
223
+ // src/core/effect.ts
224
+ function ce(e, t) {
225
+ if (M()) return;
226
+ let n = {
227
+ kind: 1,
228
+ fn: e,
229
+ state: 0,
230
+ sources: [],
231
+ flushId: 0,
232
+ flushRuns: 0,
233
+ owner: null,
234
+ children: null,
235
+ cleanups: null,
236
+ disposed: !1
237
+ };
238
+ E(n), x(() => _(n));
239
+ }
240
+ // src/core/computed.ts
241
+ function le(e, t) {
242
+ let n = {
243
+ kind: 2,
244
+ fn: e,
245
+ value: void 0,
246
+ equals: t?.equals ?? Object.is,
247
+ hasValue: !1,
248
+ hasError: !1,
249
+ error: void 0,
250
+ computing: !1,
251
+ state: 2,
252
+ sources: [],
253
+ observers: [],
254
+ seenBy: 0,
255
+ flushId: 0,
256
+ flushRuns: 0,
257
+ owner: null,
258
+ children: null,
259
+ cleanups: null,
260
+ disposed: !1
261
+ };
262
+ return E(n), () => {
263
+ if (n.computing) throw ue(n);
264
+ if (n.state !== 0 && g(n), f(n), n.hasError) throw n.error;
265
+ return n.value;
266
+ };
267
+ }
268
+ function ue(e) {
269
+ return /* @__PURE__ */ Error("[keits] cycle detected");
270
+ }
271
+ // src/core/env.ts
272
+ var de = typeof window > "u";
273
+ // src/core/owner.ts
274
+ function fe() {
275
+ return D();
276
+ }
277
+ function N(e, t) {
278
+ return O(e, t);
279
+ }
280
+ function P(e) {
281
+ let t = {
282
+ kind: 3,
283
+ owner: D(),
284
+ children: null,
285
+ cleanups: null,
286
+ disposed: !1,
287
+ handler: null
288
+ }, n = () => x(() => A(t));
289
+ return x(() => {
290
+ try {
291
+ return O(t, () => e(n));
292
+ } catch (e) {
293
+ throw A(t), e;
294
+ }
295
+ });
296
+ }
297
+ function F(e) {
298
+ ie(e);
299
+ }
300
+ function I(e) {
301
+ ae(e);
302
+ }
303
+ function L(e, t) {
304
+ let n = {
305
+ kind: 3,
306
+ owner: null,
307
+ children: null,
308
+ cleanups: null,
309
+ disposed: !1,
310
+ handler: t
311
+ };
312
+ return E(n), x(() => {
313
+ try {
314
+ return O(n, e);
315
+ } catch (e) {
316
+ j(e, n);
317
+ return;
318
+ }
319
+ });
320
+ }
321
+ function R(e) {
322
+ return oe(() => P((t) => {
323
+ try {
324
+ return e();
325
+ } finally {
326
+ t();
327
+ }
328
+ }));
329
+ }
330
+ // src/core/context.ts
331
+ function z(e, t) {
332
+ return { defaultValue: e };
333
+ }
334
+ function B(e, t, n) {
335
+ let r = {
336
+ kind: 3,
337
+ owner: null,
338
+ children: null,
339
+ cleanups: null,
340
+ disposed: !1,
341
+ handler: null,
342
+ context: {
343
+ key: e,
344
+ value: t
345
+ }
346
+ };
347
+ return E(r), O(r, n);
348
+ }
349
+ function pe(e) {
350
+ for (let t = D(); t !== null; t = t.owner) if (t.kind === 3 && t.context?.key === e) return t.context.value;
351
+ return e.defaultValue;
352
+ }
353
+ // src/core/store.ts
354
+ var V = Symbol("raw"), H = Symbol("shape"), U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), G = 0;
355
+ function me(e, t) {
356
+ let n = J(e);
357
+ return [n, (e) => {
358
+ G++;
359
+ try {
360
+ T(() => x(() => e(n)));
361
+ } finally {
362
+ G--;
363
+ }
364
+ }];
365
+ }
366
+ function K(e) {
367
+ if (typeof e == "object" && e) {
368
+ let t = e[V];
369
+ if (t !== void 0) return t;
370
+ }
371
+ return e;
372
+ }
373
+ function q(e) {
374
+ if (typeof e != "object" || !e) return !1;
375
+ if (Array.isArray(e)) return !0;
376
+ let t = Object.getPrototypeOf(e);
377
+ return t === Object.prototype || t === null;
378
+ }
379
+ function J(e) {
380
+ if (!q(e)) return e;
381
+ let t = U.get(e);
382
+ return t === void 0 && (t = new Proxy(e, he), U.set(e, t)), t;
383
+ }
384
+ function Y(e, t) {
385
+ let n = W.get(e);
386
+ n === void 0 && W.set(e, n = /* @__PURE__ */ new Map());
387
+ let r = n.get(t);
388
+ return r === void 0 && n.set(t, r = {
389
+ kind: 0,
390
+ observers: [],
391
+ seenBy: 0
392
+ }), r;
393
+ }
394
+ function X(e, t) {
395
+ let n = W.get(e)?.get(t);
396
+ n !== void 0 && m(n);
397
+ }
398
+ function Z(e) {
399
+ return !1;
400
+ }
401
+ var he = {
402
+ get(e, t) {
403
+ if (t === V) return e;
404
+ let n = e[t];
405
+ return p() && (Object.hasOwn(e, t) || !(t in e)) && f(Y(e, t)), J(n);
406
+ },
407
+ has(e, t) {
408
+ return p() && f(Y(e, t)), t in e;
409
+ },
410
+ ownKeys(e) {
411
+ return p() && f(Y(e, H)), Reflect.ownKeys(e);
412
+ },
413
+ set(e, t, n) {
414
+ if (G === 0) {
415
+ let t = Z(e);
416
+ if (t) throw t;
417
+ return !1;
418
+ }
419
+ let r = e, i = K(n), a = Object.hasOwn(e, t), o = r[t], s = Array.isArray(e), c = s ? e.length : 0;
420
+ if (a && Object.is(o, i)) return !0;
421
+ if (r[t] = i, X(e, t), a || X(e, H), s) {
422
+ let n = e.length;
423
+ if (n !== c) {
424
+ t !== "length" && X(e, "length"), X(e, H);
425
+ for (let t = n; t < c; t++) X(e, String(t));
426
+ }
427
+ }
428
+ return !0;
429
+ },
430
+ deleteProperty(e, t) {
431
+ if (G === 0) {
432
+ let t = Z(e);
433
+ if (t) throw t;
434
+ return !1;
435
+ }
436
+ return Object.hasOwn(e, t) && (delete e[t], X(e, t), X(e, H)), !0;
437
+ }
438
+ };
439
+ function ge(e, t, n = {}) {
440
+ Q(J(K(e)), K(t), n.key);
441
+ }
442
+ function Q(e, t, n) {
443
+ let r = K(e), i = e;
444
+ if (Array.isArray(r) && Array.isArray(t)) {
445
+ let e = /* @__PURE__ */ new Map();
446
+ if (n !== void 0) for (let t of r) q(t) && e.set(t[n], t);
447
+ for (let a = 0; a < t.length; a++) {
448
+ let o = t[a], s = n !== void 0 && q(o) ? e.get(o[n]) : r[a];
449
+ i[a] = $(s, o, n);
450
+ }
451
+ r.length !== t.length && (i.length = t.length);
452
+ } else {
453
+ for (let e of Object.keys(t)) i[e] = $(r[e], t[e], n);
454
+ for (let e of Object.keys(r)) Object.hasOwn(t, e) || delete i[e];
455
+ }
456
+ }
457
+ function $(e, t, n) {
458
+ return q(e) && q(t) && Array.isArray(e) === Array.isArray(t) ? (Q(J(e), t, n), e) : t;
459
+ }
460
+ export { x as batch, L as catchError, le as computed, z as createContext, P as createRoot, ce as effect, fe as getOwner, de as isServer, M as isStaticRender, F as onCleanup, I as onMount, B as provide, ge as reconcile, R as renderStatic, N as runWithOwner, se as signal, me as store, T as untrack, K as unwrap, pe as useContext };
@@ -0,0 +1,6 @@
1
+ import type { Accessor } from "./types";
2
+ export interface ComputedOptions<T> {
3
+ equals?: false | ((prev: T, next: T) => boolean);
4
+ name?: string;
5
+ }
6
+ export declare function computed<T>(fn: (prev: T | undefined) => T, options?: ComputedOptions<T>): Accessor<T>;
@@ -0,0 +1,11 @@
1
+ export interface Context<T> {
2
+ readonly defaultValue: T;
3
+ readonly name?: string;
4
+ }
5
+ export interface ContextOptions {
6
+ name?: string;
7
+ }
8
+ export declare function createContext<T>(): Context<T | undefined>;
9
+ export declare function createContext<T>(defaultValue: T, options?: ContextOptions): Context<T>;
10
+ export declare function provide<T, R>(context: Context<T>, value: NoInfer<T>, fn: () => R): R;
11
+ export declare function useContext<T>(context: Context<T>): T;
@@ -0,0 +1,4 @@
1
+ export interface EffectOptions {
2
+ name?: string;
3
+ }
4
+ export declare function effect(fn: () => void, options?: EffectOptions): void;
@@ -0,0 +1 @@
1
+ export declare const isServer: boolean;
@@ -0,0 +1,73 @@
1
+ export declare const SIGNAL = 0;
2
+ export declare const EFFECT = 1;
3
+ export declare const COMPUTED = 2;
4
+ export declare const ROOT = 3;
5
+ export declare const CLEAN = 0;
6
+ export declare const CHECK = 1;
7
+ export declare const DIRTY = 2;
8
+ export type State = typeof CLEAN | typeof CHECK | typeof DIRTY;
9
+ interface SourceFields {
10
+ observers: Computation[];
11
+ seenBy: number;
12
+ name?: string;
13
+ }
14
+ interface OwnerFields {
15
+ owner: Owner | null;
16
+ children: Owner[] | null;
17
+ cleanups: (() => void)[] | null;
18
+ disposed: boolean;
19
+ }
20
+ interface ComputationFields extends OwnerFields {
21
+ state: State;
22
+ sources: Source[];
23
+ flushId: number;
24
+ flushRuns: number;
25
+ name?: string;
26
+ }
27
+ export interface SignalSource extends SourceFields {
28
+ kind: typeof SIGNAL;
29
+ }
30
+ export interface EffectNode extends ComputationFields {
31
+ kind: typeof EFFECT;
32
+ fn: () => void;
33
+ }
34
+ export interface ComputedNode extends SourceFields, ComputationFields {
35
+ kind: typeof COMPUTED;
36
+ fn: (prev: unknown) => unknown;
37
+ value: unknown;
38
+ equals: false | ((prev: unknown, next: unknown) => boolean);
39
+ hasValue: boolean;
40
+ hasError: boolean;
41
+ error: unknown;
42
+ computing: boolean;
43
+ }
44
+ export interface RootNode extends OwnerFields {
45
+ kind: typeof ROOT;
46
+ handler: ((error: unknown) => void) | null;
47
+ context?: {
48
+ key: object;
49
+ value: unknown;
50
+ };
51
+ }
52
+ export type Source = SignalSource | ComputedNode;
53
+ export type Computation = EffectNode | ComputedNode;
54
+ export type Owner = RootNode | Computation;
55
+ export declare function track(source: Source): void;
56
+ export declare function isTracking(): boolean;
57
+ export declare function notify(source: Source): void;
58
+ export declare function updateIfNeeded(node: Computation): void;
59
+ export declare function recompute(node: ComputedNode): void;
60
+ export declare function runEffect(node: EffectNode): void;
61
+ export declare function run<T>(node: Computation, fn: () => T): T;
62
+ export declare function batch<T>(fn: () => T): T;
63
+ export declare function untrack<T>(fn: () => T): T;
64
+ export declare function adopt(node: Owner): void;
65
+ export declare function getOwner(): Owner | null;
66
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
67
+ export declare function addCleanup(fn: () => void): boolean;
68
+ export declare function addMount(fn: () => void): void;
69
+ export declare function dispose(node: Owner): void;
70
+ export declare function handleError(error: unknown, owner: Owner | null): void;
71
+ export declare function isStaticRender(): boolean;
72
+ export declare function withStaticRender<T>(fn: () => T): T;
73
+ export {};
@@ -0,0 +1,12 @@
1
+ declare const OWNER: unique symbol;
2
+ export interface Owner {
3
+ readonly [OWNER]: true;
4
+ }
5
+ export declare function getOwner(): Owner | null;
6
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
7
+ export declare function createRoot<T>(fn: (dispose: () => void) => T): T;
8
+ export declare function onCleanup(fn: () => void): void;
9
+ export declare function onMount(fn: () => void): void;
10
+ export declare function catchError<T>(fn: () => T, handler: (error: unknown) => void): T | undefined;
11
+ export declare function renderStatic<T>(fn: () => T): T;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type SignalSource } from "./graph";
2
+ import type { Accessor } from "./types";
3
+ export interface Signal<T> extends Accessor<T> {
4
+ set(next: Exclude<T, Function> | ((prev: T) => T)): void;
5
+ }
6
+ export interface SignalOptions<T> {
7
+ equals?: false | ((prev: T, next: T) => boolean);
8
+ name?: string;
9
+ }
10
+ export interface SignalNode<T> extends SignalSource {
11
+ value: T;
12
+ equals: false | ((prev: T, next: T) => boolean);
13
+ }
14
+ export declare function signal<T>(): Signal<T | undefined>;
15
+ export declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
@@ -0,0 +1,13 @@
1
+ export type Store<T> = T extends (...args: never[]) => unknown ? T : T extends object ? {
2
+ readonly [K in keyof T]: Store<T[K]>;
3
+ } : T;
4
+ export type SetStore<T> = (fn: (draft: T) => void) => void;
5
+ export interface StoreOptions {
6
+ name?: string;
7
+ }
8
+ export declare function store<T extends object>(initial: T, options?: StoreOptions): [Store<T>, SetStore<T>];
9
+ export declare function unwrap<T>(value: T): T;
10
+ export interface ReconcileOptions {
11
+ key?: string;
12
+ }
13
+ export declare function reconcile<T extends object>(target: T, source: T, options?: ReconcileOptions): void;
@@ -0,0 +1 @@
1
+ export type Accessor<T> = () => T;
@@ -0,0 +1,9 @@
1
+ export type { Accessor } from "./core/types";
2
+ export { signal, type Signal, type SignalOptions } from "./core/signal";
3
+ export { effect, type EffectOptions } from "./core/effect";
4
+ export { computed, type ComputedOptions } from "./core/computed";
5
+ export { batch, isStaticRender, untrack } from "./core/graph";
6
+ export { isServer } from "./core/env";
7
+ export { catchError, createRoot, getOwner, onCleanup, onMount, renderStatic, runWithOwner, type Owner } from "./core/owner";
8
+ export { createContext, provide, useContext, type Context, type ContextOptions } from "./core/context";
9
+ export { reconcile, store, unwrap, type ReconcileOptions, type SetStore, type Store, type StoreOptions } from "./core/store";
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "keits",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "description": "Fine-grained reactive TypeScript framework. Real DOM, no virtual DOM, zero dependencies.",
5
+ "keywords": ["reactive", "signals", "framework", "typescript", "fine-grained", "no-vdom"],
6
+ "author": "Michael Ranni",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "files": ["dist"],
11
+ "types": "./dist/types/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "@keits/source": "./src/index.ts",
15
+ "types": "./dist/types/index.d.ts",
16
+ "development": "./dist/dev/index.js",
17
+ "default": "./dist/prod/index.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "node ../../scripts/build.mjs && tsc -p tsconfig.build.json",
22
+ "size": "node ../../scripts/size.mjs",
23
+ "prepublishOnly": "cd ../.. && npm run check"
24
+ },
25
+ "size-budget": {
26
+ "dist/prod/index.js": 2816,
27
+ "size/basic.js": 1792
28
+ }
6
29
  }