ilha 0.16.1 → 0.16.3
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/AGENTS.md +1 -1
- package/MIGRATIONS.json +10 -0
- package/MIGRATIONS.md +21 -0
- package/dist/debug.d.ts +17 -1
- package/dist/debug.js +30 -2
- package/dist/index.d.ts +11 -6
- package/dist/index.js +12 -10
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/{mount-DWQcWHqc.d.ts → mount-ChhKs7A2.d.ts} +1 -1
- package/dist/{mount-CLPxbsAX.js → mount-nRxVumCX.js} +2 -2
- package/dist/{paint-core-BDV_pKgC.js → paint-core-cWLlHxoA.js} +1 -1
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js +2 -2
- package/dist/{runtime-Z5KugPXX.d.ts → runtime-3jr7FulJ.d.ts} +2 -2
- package/dist/{snapshot-rTWQB3iQ.d.ts → snapshot-BFdyCq2T.d.ts} +1 -1
- package/dist/{start-KNXoCAb9.js → start-j8x3mJSh.js} +16 -6
- package/dist/test.d.ts +3 -3
- package/dist/test.js +1 -1
- package/dist/{types-PD4B3pFq.d.ts → types-a9_yNjbT.d.ts} +22 -5
- package/dist/{vnode-R5QcXzyp.d.ts → vnode-rJ7hy6yD.d.ts} +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
package/MIGRATIONS.json
CHANGED
|
@@ -91,6 +91,16 @@
|
|
|
91
91
|
"docs": "https://ilha.build/reference/ilha",
|
|
92
92
|
"before": "const ops: PaintOps<Node, El> = { createElement, createText, createRaw, placeChildren, appendRoot, asRoot, asNode, asElement, createSlotHost, disconnect, /* ... */ };",
|
|
93
93
|
"after": "const ops: PaintOps<Node, El> = { createElement, createText, createRaw, placeChildren, morph /* optional: reuseNode, committed, setStyle, setFormControl, bindEvents */ };"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "atom-writable-handle",
|
|
97
|
+
"kind": "changed",
|
|
98
|
+
"api": "AtomHandle, atom",
|
|
99
|
+
"import": "ilha",
|
|
100
|
+
"replacement": "AtomHandle<A, W = A> types .set and .update with the atom's write type. atom(Atom.fn(...)) returns AtomHandle<AsyncResult<A, E>, Arg>, so .set takes the fn argument; drop casts like `as never`. Annotations written as AtomHandle<AsyncResult<...>> for a writable atom need the second parameter.",
|
|
101
|
+
"docs": "https://ilha.build/guide/ui/state",
|
|
102
|
+
"before": "const save = atom(Atom.fn((draft: Draft) => saveDraft(draft)));\nsave.set(draft as never);",
|
|
103
|
+
"after": "const save = atom(Atom.fn((draft: Draft) => saveDraft(draft)));\nsave.set(draft);"
|
|
94
104
|
}
|
|
95
105
|
]
|
|
96
106
|
}
|
package/MIGRATIONS.md
CHANGED
|
@@ -196,3 +196,24 @@ const ops: PaintOps<Node, El> = {
|
|
|
196
196
|
morph /* optional: reuseNode, committed, setStyle, setFormControl, bindEvents */,
|
|
197
197
|
};
|
|
198
198
|
```
|
|
199
|
+
|
|
200
|
+
## AtomHandle, atom
|
|
201
|
+
|
|
202
|
+
- Status: changed
|
|
203
|
+
- Import: `ilha`
|
|
204
|
+
- Replacement: AtomHandle<A, W = A> types .set and .update with the atom's write type. atom(Atom.fn(...)) returns AtomHandle<AsyncResult<A, E>, Arg>, so .set takes the fn argument; drop casts like `as never`. Annotations written as AtomHandle<AsyncResult<...>> for a writable atom need the second parameter.
|
|
205
|
+
- Docs: https://ilha.build/guide/ui/state
|
|
206
|
+
|
|
207
|
+
Before:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
const save = atom(Atom.fn((draft: Draft) => saveDraft(draft)));
|
|
211
|
+
save.set(draft as never);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
After:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
const save = atom(Atom.fn((draft: Draft) => saveDraft(draft)));
|
|
218
|
+
save.set(draft);
|
|
219
|
+
```
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { t as SnapshotValue } from "./snapshot-
|
|
1
|
+
import { t as SnapshotValue } from "./snapshot-BFdyCq2T.js";
|
|
2
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
2
3
|
/** An atom value made JSON-safe: functions and Effects become `<…>` strings. */
|
|
3
4
|
export type InspectValue = SnapshotValue | string;
|
|
4
5
|
export interface IlhaInspectAtom {
|
|
@@ -21,6 +22,13 @@ export type SetAtomResult = {
|
|
|
21
22
|
ok: false;
|
|
22
23
|
reason: string;
|
|
23
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Reduce any value to JSON, naming what JSON cannot carry. Powers
|
|
27
|
+
* `inspect()` and the `@ilha/model` message log: functions, Effects, and
|
|
28
|
+
* class instances become `<…>` strings, `Option` becomes a tagged record,
|
|
29
|
+
* cycles become `"<circular>"`, and containers deeper than 6 stay folded.
|
|
30
|
+
*/
|
|
31
|
+
export declare const summarizeValue: <T>(value: T) => InspectValue;
|
|
24
32
|
/**
|
|
25
33
|
* JSON-serializable trees of the live roots: component names, atom values,
|
|
26
34
|
* and child components. Pass `host` to inspect one root or component host.
|
|
@@ -30,6 +38,14 @@ export declare const inspect: (host?: Element) => IlhaInspectNode[];
|
|
|
30
38
|
export declare const roots: () => Element[];
|
|
31
39
|
/** The element an inspected component paints into, to highlight or measure. */
|
|
32
40
|
export declare const element: (id: string) => Element | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Live primitive atoms of component `id`, in declaration order, or
|
|
43
|
+
* `undefined` for an unknown id. Devtools bridges join these against their
|
|
44
|
+
* own registries — `@ilha/model` keys its message log by the state atom —
|
|
45
|
+
* because summarized JSON cannot carry object identity. `inspect()` itself
|
|
46
|
+
* is unchanged: no new fields, no new cost.
|
|
47
|
+
*/
|
|
48
|
+
export declare const atomsOf: (id: string) => readonly Atom.Atom<unknown>[] | undefined;
|
|
33
49
|
/**
|
|
34
50
|
* Replace atom `index` of component `id` with a JSON `value`. Only writable
|
|
35
51
|
* state atoms accept it; derived atoms and Effect atoms report why they cannot.
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { r as rootListeners, t as liveRoots } from "./start-
|
|
1
|
+
import { r as rootListeners, t as liveRoots } from "./start-j8x3mJSh.js";
|
|
2
2
|
import { c as isObject, l as isString, o as isFunction, r as SLOT_ATTR } from "./shared-Bz14CT7Z.js";
|
|
3
3
|
import * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
5
6
|
import * as Stream from "effect/Stream";
|
|
6
7
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
7
8
|
|
|
@@ -44,6 +45,13 @@ const summarizeAsync = (value, depth, seen) => {
|
|
|
44
45
|
if (payload._tag === "Some") return walk.summarize(payload.value, depth, seen);
|
|
45
46
|
return AsyncResult.isWaiting(value) ? "<AsyncResult waiting>" : "<AsyncResult initial>";
|
|
46
47
|
};
|
|
48
|
+
const summarizeOption = (value, depth, seen) => {
|
|
49
|
+
if (depth >= MAX_DEPTH) return "<Option>";
|
|
50
|
+
return Option.isSome(value) ? {
|
|
51
|
+
_tag: "Some",
|
|
52
|
+
value: walk.summarize(value.value, depth + 1, seen)
|
|
53
|
+
} : { _tag: "None" };
|
|
54
|
+
};
|
|
47
55
|
const summarizeList = (items, depth, seen) => {
|
|
48
56
|
if (depth >= MAX_DEPTH) return `<Array(${items.length})>`;
|
|
49
57
|
const out = items.slice(0, MAX_ITEMS).map((item) => walk.summarize(item, depth + 1, seen));
|
|
@@ -86,6 +94,7 @@ const summarizeContainer = (value, depth, seen) => {
|
|
|
86
94
|
if (seen.has(value)) return "<circular>";
|
|
87
95
|
seen.add(value);
|
|
88
96
|
try {
|
|
97
|
+
if (Option.isOption(value)) return summarizeOption(value, depth, seen);
|
|
89
98
|
if (Array.isArray(value)) return summarizeList(value, depth, seen);
|
|
90
99
|
return isPlainObject(value) ? summarizeRecord(value, depth, seen) : `<${constructorName(value)}>`;
|
|
91
100
|
} finally {
|
|
@@ -95,6 +104,13 @@ const summarizeContainer = (value, depth, seen) => {
|
|
|
95
104
|
/** Reduce any value to JSON, naming what JSON cannot carry. */
|
|
96
105
|
const summarize = (value, depth, seen) => isObject(value) || Array.isArray(value) ? summarizeContainer(value, depth, seen) : summarizeLeaf(value);
|
|
97
106
|
walk.summarize = summarize;
|
|
107
|
+
/**
|
|
108
|
+
* Reduce any value to JSON, naming what JSON cannot carry. Powers
|
|
109
|
+
* `inspect()` and the `@ilha/model` message log: functions, Effects, and
|
|
110
|
+
* class instances become `<…>` strings, `Option` becomes a tagged record,
|
|
111
|
+
* cycles become `"<circular>"`, and containers deeper than 6 stay folded.
|
|
112
|
+
*/
|
|
113
|
+
const summarizeValue = (value) => summarize(value, 0, /* @__PURE__ */ new WeakSet());
|
|
98
114
|
const ids = /* @__PURE__ */ new WeakMap();
|
|
99
115
|
let lastId = 0;
|
|
100
116
|
const idOf = (fiber) => {
|
|
@@ -173,6 +189,18 @@ const element = (id) => {
|
|
|
173
189
|
return isDomElement(root) ? root : void 0;
|
|
174
190
|
};
|
|
175
191
|
/**
|
|
192
|
+
* Live primitive atoms of component `id`, in declaration order, or
|
|
193
|
+
* `undefined` for an unknown id. Devtools bridges join these against their
|
|
194
|
+
* own registries — `@ilha/model` keys its message log by the state atom —
|
|
195
|
+
* because summarized JSON cannot carry object identity. `inspect()` itself
|
|
196
|
+
* is unchanged: no new fields, no new cost.
|
|
197
|
+
*/
|
|
198
|
+
const atomsOf = (id) => {
|
|
199
|
+
const fiber = findFiber(id);
|
|
200
|
+
if (fiber === void 0) return;
|
|
201
|
+
return [...fiber.primitives ?? []];
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
176
204
|
* Replace atom `index` of component `id` with a JSON `value`. Only writable
|
|
177
205
|
* state atoms accept it; derived atoms and Effect atoms report why they cannot.
|
|
178
206
|
*/
|
|
@@ -213,4 +241,4 @@ const onChange = (listener) => {
|
|
|
213
241
|
};
|
|
214
242
|
};
|
|
215
243
|
|
|
216
|
-
export { element, inspect, onChange, roots, setAtom };
|
|
244
|
+
export { atomsOf, element, inspect, onChange, roots, setAtom, summarizeValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as View, a as Component, b as WatchOnceCleanup, f as MountOptions, h as UnsafeHtml, i as AtomOptions, l as Instruction, n as AtomHandle, r as AtomLazyOptions, s as Fragment, t as AtomEquality, v as WatchCallback, x as Yielded, y as WatchContext } from "./types-
|
|
2
|
-
import { t as h } from "./vnode-
|
|
3
|
-
import { r as watch } from "./runtime-
|
|
4
|
-
import { n as mount, r as renderToString, t as RenderToStringOptions } from "./mount-
|
|
1
|
+
import { _ as View, a as Component, b as WatchOnceCleanup, f as MountOptions, h as UnsafeHtml, i as AtomOptions, l as Instruction, n as AtomHandle, r as AtomLazyOptions, s as Fragment, t as AtomEquality, v as WatchCallback, x as Yielded, y as WatchContext } from "./types-a9_yNjbT.js";
|
|
2
|
+
import { t as h } from "./vnode-rJ7hy6yD.js";
|
|
3
|
+
import { r as watch } from "./runtime-3jr7FulJ.js";
|
|
4
|
+
import { n as mount, r as renderToString, t as RenderToStringOptions } from "./mount-ChhKs7A2.js";
|
|
5
5
|
import * as Atom from "effect/reactivity/Atom";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Stream from "effect/Stream";
|
|
@@ -45,18 +45,23 @@ export declare const untrack: <A>(fn: () => A) => A;
|
|
|
45
45
|
interface AtomFn {
|
|
46
46
|
/** An effect or stream runs once; the handle holds its `AsyncResult`. */
|
|
47
47
|
<A, E>(init: Effect.Effect<A, E, AtomRegistry> | Stream.Stream<A, E, AtomRegistry>, options?: AtomOptions<AsyncResult.AsyncResult<A, E>>): AtomHandle<AsyncResult.AsyncResult<A, E>>;
|
|
48
|
+
/**
|
|
49
|
+
* A writable Effect atom (`Atom.fn`, `Atom.make`, …). `.set` and `.update`
|
|
50
|
+
* take the atom's write type — the `Atom.fn` argument — not the read type.
|
|
51
|
+
*/
|
|
52
|
+
<R, W>(init: Atom.Writable<R, W>, options?: AtomOptions<R>): AtomHandle<R, W>;
|
|
48
53
|
/**
|
|
49
54
|
* An existing Effect atom, or a plain value. Store a function with
|
|
50
55
|
* `atom.lazy(() => fn)`; the `ilha/oxlint` rule `function-in-atom` flags
|
|
51
56
|
* `atom(fn)`.
|
|
52
57
|
*/
|
|
53
58
|
<A>(init: Atom.Atom<A> | A, options?: AtomOptions<A>): AtomHandle<A>;
|
|
54
|
-
lazy: <A>(init: () => A, options?: AtomLazyOptions) => AtomHandle<A>;
|
|
59
|
+
lazy: <A>(init: () => A, options?: AtomLazyOptions<A>) => AtomHandle<A>;
|
|
55
60
|
}
|
|
56
61
|
export declare const atom: AtomFn;
|
|
57
62
|
export declare const batch: (f: () => void) => void;
|
|
58
63
|
/** Rerun `body` for every value of `stream`, replacing the previous run. */
|
|
59
|
-
export declare const when: <A, E = never, R = never>(stream: Stream.Stream<A, E, R>, body: (value: A) => Generator<Yielded, View | undefined, View>) => Instruction<void, E>;
|
|
64
|
+
export declare const when: <A, E = never, R = never>(stream: Stream.Stream<A, E, R>, body: (value: A) => Generator<Yielded, View | undefined, View> | Generator<Yielded, void, View>) => Instruction<void, E>;
|
|
60
65
|
/**
|
|
61
66
|
* Mark a string as pre-rendered HTML and paint it without escaping.
|
|
62
67
|
* Use it for markup you built or sanitized yourself — SVG from an external
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as IlhaError, c as batch, d as untrack, f as wrapHandle, g as makeFiber, h as getFiber, i as runSetup, l as instr, m as closeFiber, o as interpret, p as clearFiberView, s as atom } from "./start-
|
|
1
|
+
import { _ as IlhaError, c as batch, d as untrack, f as wrapHandle, g as makeFiber, h as getFiber, i as runSetup, l as instr, m as closeFiber, o as interpret, p as clearFiberView, s as atom } from "./start-j8x3mJSh.js";
|
|
2
2
|
import { i as errorView, o as isFunction } from "./shared-Bz14CT7Z.js";
|
|
3
|
-
import { n as unsafe } from "./paint-core-
|
|
4
|
-
import { r as renderToString, t as mount } from "./mount-
|
|
3
|
+
import { n as unsafe } from "./paint-core-cWLlHxoA.js";
|
|
4
|
+
import { r as renderToString, t as mount } from "./mount-nRxVumCX.js";
|
|
5
5
|
import { r as Fragment, t as h } from "./vnode-C_vM-l5s.js";
|
|
6
6
|
import * as Atom from "effect/reactivity/Atom";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
@@ -67,9 +67,10 @@ const ErrorBoundary = (props) => {
|
|
|
67
67
|
const ONCE = Symbol("ilha.watch.once");
|
|
68
68
|
/**
|
|
69
69
|
* Serial runs of one watch slot. Each run gets a fresh signal; starting the
|
|
70
|
-
* next run or cancelling aborts it, which also runs its cleanups.
|
|
70
|
+
* next run or cancelling aborts it, which also runs its cleanups. `ssr`
|
|
71
|
+
* reports whether the slot's fiber renders on the server.
|
|
71
72
|
*/
|
|
72
|
-
const makeRunner = () => {
|
|
73
|
+
const makeRunner = (ssr) => {
|
|
73
74
|
let ctrl;
|
|
74
75
|
const cancel = () => ctrl?.abort();
|
|
75
76
|
return {
|
|
@@ -92,7 +93,8 @@ const makeRunner = () => {
|
|
|
92
93
|
};
|
|
93
94
|
const out = fn({
|
|
94
95
|
onCleanup,
|
|
95
|
-
signal
|
|
96
|
+
signal,
|
|
97
|
+
ssr
|
|
96
98
|
});
|
|
97
99
|
if (out instanceof Promise) settle(out);
|
|
98
100
|
else onCleanup(out);
|
|
@@ -124,7 +126,7 @@ const watch = Object.assign((source, fn) => {
|
|
|
124
126
|
const ref = { fn };
|
|
125
127
|
const key = isFunction(source) ? source.atom : source;
|
|
126
128
|
return useWatchSlot(key, ref, (fiber) => {
|
|
127
|
-
const runner = makeRunner();
|
|
129
|
+
const runner = makeRunner(fiber.runtime.ssr);
|
|
128
130
|
const emit = (value) => runner.run((ctx) => ref.fn(value, ctx));
|
|
129
131
|
const stop = Stream.isStream(source) ? fiber.run(Stream.runForEach(source, (v) => Effect.sync(() => emit(v)))) : fiber.registry.subscribe(isFunction(source) ? source.atom : source, emit, { immediate: true });
|
|
130
132
|
return () => {
|
|
@@ -132,8 +134,8 @@ const watch = Object.assign((source, fn) => {
|
|
|
132
134
|
stop();
|
|
133
135
|
};
|
|
134
136
|
});
|
|
135
|
-
}, { once: (fn) => useWatchSlot(ONCE, {}, () => {
|
|
136
|
-
const runner = makeRunner();
|
|
137
|
+
}, { once: (fn) => useWatchSlot(ONCE, {}, (fiber) => {
|
|
138
|
+
const runner = makeRunner(fiber.runtime.ssr);
|
|
137
139
|
runner.run(fn);
|
|
138
140
|
return runner.cancel;
|
|
139
141
|
}) });
|
|
@@ -151,7 +153,7 @@ const when = (stream, body) => instr(Effect.suspend(() => {
|
|
|
151
153
|
return Stream.runForEach(parent.runtime.ssr ? Stream.take(base, 1) : base, (value) => Effect.sync(() => {
|
|
152
154
|
stop();
|
|
153
155
|
child = makeFiber(parent.runtime, parent.root, parent.paintFn, { parent });
|
|
154
|
-
interpret(() => body(value), child);
|
|
156
|
+
interpret((() => body(value)), child);
|
|
155
157
|
})).pipe(Effect.asVoid);
|
|
156
158
|
}));
|
|
157
159
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as Fragment } from "./types-
|
|
2
|
-
import { n as JSX } from "./vnode-
|
|
1
|
+
import { s as Fragment } from "./types-a9_yNjbT.js";
|
|
2
|
+
import { n as JSX } from "./vnode-rJ7hy6yD.js";
|
|
3
3
|
import { jsx, jsxDEV, jsxs } from "./jsx-runtime.js";
|
|
4
4
|
export { Fragment, type JSX, jsx, jsxDEV, jsxs };
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as View, d as JsxComponent, o as ComponentFn, p as PropBag, s as Fragment } from "./types-
|
|
2
|
-
import { n as JSX, t as h } from "./vnode-
|
|
1
|
+
import { _ as View, d as JsxComponent, o as ComponentFn, p as PropBag, s as Fragment } from "./types-a9_yNjbT.js";
|
|
2
|
+
import { n as JSX, t as h } from "./vnode-rJ7hy6yD.js";
|
|
3
3
|
export declare const jsx: (type: string | Fragment | ComponentFn | JsxComponent, props: PropBag | null, key?: string | number) => ReturnType<typeof h>;
|
|
4
4
|
export declare const jsxs: typeof jsx;
|
|
5
5
|
export declare const jsxDEV: typeof jsx;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as startRoot, v as ilhaError, y as ilhaWarn } from "./start-
|
|
1
|
+
import { a as startRoot, v as ilhaError, y as ilhaWarn } from "./start-j8x3mJSh.js";
|
|
2
2
|
import { c as isObject, n as KEY_ATTR, r as SLOT_ATTR } from "./shared-Bz14CT7Z.js";
|
|
3
|
-
import { i as bindEvents, r as adoptEvents, t as createPainter } from "./paint-core-
|
|
3
|
+
import { i as bindEvents, r as adoptEvents, t as createPainter } from "./paint-core-cWLlHxoA.js";
|
|
4
4
|
|
|
5
5
|
// src/morph.ts
|
|
6
6
|
const PRESERVE_ATTR = "data-morph-preserve";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as makeFiber, i as runSetup, m as closeFiber, n as notifyRoots, r as rootListeners, u as isAtomHandle, y as ilhaWarn } from "./start-
|
|
1
|
+
import { g as makeFiber, i as runSetup, m as closeFiber, n as notifyRoots, r as rootListeners, u as isAtomHandle, y as ilhaWarn } from "./start-j8x3mJSh.js";
|
|
2
2
|
import { a as hasBrand, c as isObject, d as skip, l as isString, n as KEY_ATTR, o as isFunction, p as unwrap, r as SLOT_ATTR, s as isIterable, t as KEEP, u as noop } from "./shared-Bz14CT7Z.js";
|
|
3
3
|
import { n as isVNode, r as Fragment } from "./vnode-C_vM-l5s.js";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as View, a as Component, c as IlhaRuntime, m as PropValue, p as PropBag } from "./types-
|
|
2
|
-
import { n as getFiber, t as FiberLocal } from "./runtime-
|
|
1
|
+
import { _ as View, a as Component, c as IlhaRuntime, m as PropValue, p as PropBag } from "./types-a9_yNjbT.js";
|
|
2
|
+
import { n as getFiber, t as FiberLocal } from "./runtime-3jr7FulJ.js";
|
|
3
3
|
/** Structural element API shared by DOM `Element`, the SSR shim, and custom hosts. */
|
|
4
4
|
interface PaintEl<Node> {
|
|
5
5
|
readonly tagName: string;
|
package/dist/renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as startRoot, h as getFiber } from "./start-
|
|
2
|
-
import { i as bindEvents, t as createPainter } from "./paint-core-
|
|
1
|
+
import { a as startRoot, h as getFiber } from "./start-j8x3mJSh.js";
|
|
2
|
+
import { i as bindEvents, t as createPainter } from "./paint-core-cWLlHxoA.js";
|
|
3
3
|
|
|
4
4
|
// src/renderer.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as View, b as WatchOnceCleanup, c as IlhaRuntime, l as Instruction, n as AtomHandle, p as PropBag, v as WatchCallback, y as WatchContext } from "./types-
|
|
2
|
-
import "./snapshot-
|
|
1
|
+
import { _ as View, b as WatchOnceCleanup, c as IlhaRuntime, l as Instruction, n as AtomHandle, p as PropBag, v as WatchCallback, y as WatchContext } from "./types-a9_yNjbT.js";
|
|
2
|
+
import "./snapshot-BFdyCq2T.js";
|
|
3
3
|
import * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Stream from "effect/Stream";
|
|
@@ -2,6 +2,8 @@ import { a as hasBrand, f as toError, i as errorView, o as isFunction, u as noop
|
|
|
2
2
|
import * as Atom from "effect/reactivity/Atom";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Equal from "effect/Equal";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
5
7
|
import * as Stream from "effect/Stream";
|
|
6
8
|
import * as Cause from "effect/Cause";
|
|
7
9
|
import * as Context from "effect/Context";
|
|
@@ -347,9 +349,11 @@ const wrapHandle = (atom, fiber) => {
|
|
|
347
349
|
/**
|
|
348
350
|
* Claim the fiber's next primitive slot. A fresh slot is built by `make`,
|
|
349
351
|
* seeded from the hydration snapshot when `snapshotted`; SSR records its
|
|
350
|
-
* value so hydration can restore it in the same order.
|
|
352
|
+
* value so hydration can restore it in the same order. `schema` encodes the
|
|
353
|
+
* recorded value and decodes the seed; an undecodable seed falls back to
|
|
354
|
+
* the initial value.
|
|
351
355
|
*/
|
|
352
|
-
const useSlot = (snapshotted, make) => {
|
|
356
|
+
const useSlot = (snapshotted, make, schema) => {
|
|
353
357
|
const fiber = getFiber();
|
|
354
358
|
const { runtime } = fiber;
|
|
355
359
|
const i = fiber.primitiveI ?? 0;
|
|
@@ -357,14 +361,20 @@ const useSlot = (snapshotted, make) => {
|
|
|
357
361
|
fiber.primitives ??= [];
|
|
358
362
|
let a = fiber.primitives[i];
|
|
359
363
|
if (!a) {
|
|
364
|
+
const codec = snapshotted && schema ? Schema.toCodecJson(schema) : void 0;
|
|
360
365
|
let hydrated;
|
|
361
366
|
if (snapshotted && runtime.hydrateValues) {
|
|
362
|
-
|
|
367
|
+
const seed = runtime.hydrateValues[runtime.hydrateI];
|
|
363
368
|
runtime.hydrateI += 1;
|
|
369
|
+
if (codec === void 0) hydrated = seed;
|
|
370
|
+
else if (seed !== void 0) hydrated = Option.getOrUndefined(Schema.decodeUnknownOption(codec)(seed));
|
|
364
371
|
}
|
|
365
372
|
a = make(fiber, hydrated);
|
|
366
373
|
fiber.primitives[i] = a;
|
|
367
|
-
if (snapshotted && runtime.ssr)
|
|
374
|
+
if (snapshotted && runtime.ssr) {
|
|
375
|
+
const value = fiber.registry.get(a);
|
|
376
|
+
runtime.ssrValues.push(codec ? Schema.encodeSync(codec)(value) : value);
|
|
377
|
+
}
|
|
368
378
|
}
|
|
369
379
|
return wrapHandle(a, fiber);
|
|
370
380
|
};
|
|
@@ -388,8 +398,8 @@ const atom = Object.assign((init, options) => {
|
|
|
388
398
|
const made = Atom.make(seed === void 0 ? init : seed);
|
|
389
399
|
const eq = options?.equals;
|
|
390
400
|
return holdState(fiber, eq ? Atom.withEquality(made, eq === "structural" ? Equal.equals : eq) : made);
|
|
391
|
-
});
|
|
392
|
-
}, { lazy: (init, options) => useSlot(options?.snapshot !== false, (fiber, seed) => holdState(fiber, Atom.make(seed === void 0 ? init() : seed))) });
|
|
401
|
+
}, options?.schema);
|
|
402
|
+
}, { lazy: (init, options) => useSlot(options?.snapshot !== false, (fiber, seed) => holdState(fiber, Atom.make(seed === void 0 ? init() : seed)), options?.schema) });
|
|
393
403
|
const { batch } = Atom;
|
|
394
404
|
|
|
395
405
|
// src/interpret.ts
|
package/dist/test.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as Component } from "./types-
|
|
2
|
-
import { t as SnapshotValue } from "./snapshot-
|
|
1
|
+
import { a as Component } from "./types-a9_yNjbT.js";
|
|
2
|
+
import { t as SnapshotValue } from "./snapshot-BFdyCq2T.js";
|
|
3
3
|
import { IlhaInspectNode } from "./debug.js";
|
|
4
|
-
import { t as RenderToStringOptions } from "./mount-
|
|
4
|
+
import { t as RenderToStringOptions } from "./mount-ChhKs7A2.js";
|
|
5
5
|
export interface RenderOptions {
|
|
6
6
|
/** Render on the server first and inject the HTML into the container. Default `false`. */
|
|
7
7
|
ssr?: boolean;
|
package/dist/test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as toError, l as isString } from "./shared-Bz14CT7Z.js";
|
|
2
|
-
import { n as mountWithRuntime, r as renderToString } from "./mount-
|
|
2
|
+
import { n as mountWithRuntime, r as renderToString } from "./mount-nRxVumCX.js";
|
|
3
3
|
import { inspect } from "./debug.js";
|
|
4
4
|
|
|
5
5
|
// src/test.ts
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
1
2
|
import { AtomRegistry } from "effect/reactivity/AtomRegistry";
|
|
2
3
|
import { Closeable } from "effect/Scope";
|
|
3
4
|
import { Effect, Stream } from "effect";
|
|
@@ -63,12 +64,12 @@ interface AtomView {
|
|
|
63
64
|
readonly $$atom: 1;
|
|
64
65
|
readonly atom: Atom.Atom<unknown>;
|
|
65
66
|
}
|
|
66
|
-
interface AtomHandle<A> {
|
|
67
|
+
interface AtomHandle<A, W = A> {
|
|
67
68
|
readonly $$atom: 1;
|
|
68
69
|
readonly atom: Atom.Atom<A>;
|
|
69
70
|
(): A;
|
|
70
|
-
set: (next:
|
|
71
|
-
update: (f: (current: A) =>
|
|
71
|
+
set: (next: W) => void;
|
|
72
|
+
update: (f: (current: A) => W) => void;
|
|
72
73
|
}
|
|
73
74
|
/** Equality for plain-value atoms. `"structural"` deep-compares JSON-shaped values. */
|
|
74
75
|
type AtomEquality<A> = "structural" | ((prev: A, next: A) => boolean);
|
|
@@ -80,24 +81,40 @@ interface AtomOptions<A = unknown> {
|
|
|
80
81
|
* starts from its initial value on hydration. Default `true`.
|
|
81
82
|
*/
|
|
82
83
|
readonly snapshot?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Codec for the SSR snapshot entry, for values plain JSON cannot
|
|
86
|
+
* round-trip (dates, maps, branded types). SSR encodes the snapshot value
|
|
87
|
+
* and hydration decodes the seed; a seed that fails to decode falls back
|
|
88
|
+
* to the initial value. Plain values only.
|
|
89
|
+
*/
|
|
90
|
+
readonly schema?: Schema.ConstraintCodec<NoInfer<A>, unknown>;
|
|
83
91
|
}
|
|
84
92
|
/** Options for `atom.lazy()`. */
|
|
85
|
-
interface AtomLazyOptions {
|
|
93
|
+
interface AtomLazyOptions<A = unknown> {
|
|
86
94
|
/**
|
|
87
95
|
* Set `false` to keep the slot out of the SSR snapshot, for timers,
|
|
88
96
|
* observers, and other mutable refs. Default `true`.
|
|
89
97
|
*/
|
|
90
98
|
readonly snapshot?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Codec for the SSR snapshot entry, for values plain JSON cannot
|
|
101
|
+
* round-trip (dates, maps, branded types). SSR encodes the snapshot value
|
|
102
|
+
* and hydration decodes the seed; a seed that fails to decode falls back
|
|
103
|
+
* to the initial value.
|
|
104
|
+
*/
|
|
105
|
+
readonly schema?: Schema.ConstraintCodec<NoInfer<A>, unknown>;
|
|
91
106
|
}
|
|
92
107
|
/** Optional disposer returned from `watch.once`. */
|
|
93
108
|
type WatchOnceCleanup = () => void;
|
|
94
109
|
/**
|
|
95
110
|
* Cancellation context handed to watch callbacks. `signal` aborts when the
|
|
96
111
|
* run goes stale (a newer value arrives), on unmount, or on slot disposal.
|
|
97
|
-
* Register extra teardowns with `onCleanup`.
|
|
112
|
+
* Register extra teardowns with `onCleanup`. `ssr` is `true` while
|
|
113
|
+
* `renderToString` runs the callback; skip browser-only work then.
|
|
98
114
|
*/
|
|
99
115
|
interface WatchContext {
|
|
100
116
|
readonly signal: AbortSignal;
|
|
117
|
+
readonly ssr: boolean;
|
|
101
118
|
onCleanup: (fn: () => void) => void;
|
|
102
119
|
}
|
|
103
120
|
type WatchCallback<A> = (value: A, ctx: WatchContext) => WatchOnceCleanup | undefined | Promise<WatchOnceCleanup | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as View, d as JsxComponent, g as VNode, n as AtomHandle, o as ComponentFn, p as PropBag, s as Fragment } from "./types-
|
|
1
|
+
import { _ as View, d as JsxComponent, g as VNode, n as AtomHandle, o as ComponentFn, p as PropBag, s as Fragment } from "./types-a9_yNjbT.js";
|
|
2
2
|
declare namespace JSX {
|
|
3
3
|
export type Element = View;
|
|
4
4
|
export type ElementType = string | ((props: never) => View | Promise<View | undefined> | Generator<View, View | undefined, View> | undefined);
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ilha
|
|
2
2
|
|
|
3
|
-
> Tiny, isomorphic islands UI library on Effect 4. Function components, order-based `atom()` slots, JSX, SSR via `renderToString`, hydration via `mount(host, C, { hydrate: true })`. Version 0.16.
|
|
3
|
+
> Tiny, isomorphic islands UI library on Effect 4. Function components, order-based `atom()` slots, JSX, SSR via `renderToString`, hydration via `mount(host, C, { hydrate: true })`. Version 0.16.3.
|
|
4
4
|
|
|
5
5
|
Start with the canonical-usage table: exactly one API per task, plus a never-do list.
|
|
6
6
|
|