ilha 0.16.0 → 0.16.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/AGENTS.md +1 -1
- package/MIGRATIONS.json +10 -0
- package/MIGRATIONS.md +21 -0
- package/README.md +1 -1
- package/dist/debug.d.ts +2 -4
- package/dist/debug.js +3 -4
- package/dist/index.d.ts +11 -18
- package/dist/index.js +18 -20
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.d.ts +2 -4
- package/dist/jsx-runtime.js +2 -3
- package/dist/{mount-3Ggg67T0.d.ts → mount-ChhKs7A2.d.ts} +1 -3
- package/dist/{mount-BwuJsiDH.js → mount-nRxVumCX.js} +9 -15
- package/dist/{paint-core-D1n4lbpF.js → paint-core-cWLlHxoA.js} +7 -11
- package/dist/renderer.d.ts +2 -8
- package/dist/renderer.js +3 -4
- package/dist/{runtime-BCdKBqYp.d.ts → runtime-3jr7FulJ.d.ts} +2 -6
- package/dist/{shared-vpgYXytd.js → shared-Bz14CT7Z.js} +1 -2
- package/dist/{snapshot-BDC74QwI.d.ts → snapshot-BFdyCq2T.d.ts} +1 -3
- package/dist/{start-B-e1dG5U.js → start-j8x3mJSh.js} +22 -17
- package/dist/test.d.ts +3 -5
- package/dist/test.js +3 -4
- package/dist/{types-NhEiBvwy.d.ts → types-a9_yNjbT.d.ts} +22 -7
- package/dist/{vnode-DJ25Jn3D.js → vnode-C_vM-l5s.js} +3 -5
- package/dist/{vnode-DskooLPD.d.ts → vnode-rJ7hy6yD.d.ts} +1 -5
- package/llms.txt +1 -1
- package/package.json +3 -4
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/README.md
CHANGED
|
@@ -73,8 +73,8 @@ Atoms hold data. Do not store JSX in an atom.
|
|
|
73
73
|
Paint [Effect `Stream`](https://www.effect.website/docs/v4/api/effect/Stream) values. Yield a stream of views from a generator, or return one from an async component:
|
|
74
74
|
|
|
75
75
|
```tsx
|
|
76
|
-
import * as Stream from "effect/Stream";
|
|
77
76
|
import * as Atom from "effect/reactivity/Atom";
|
|
77
|
+
import * as Stream from "effect/Stream";
|
|
78
78
|
import { atom } from "ilha";
|
|
79
79
|
|
|
80
80
|
function* List() {
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as SnapshotValue } from "./snapshot-
|
|
2
|
-
//#region src/debug.d.ts
|
|
1
|
+
import { t as SnapshotValue } from "./snapshot-BFdyCq2T.js";
|
|
3
2
|
/** An atom value made JSON-safe: functions and Effects become `<…>` strings. */
|
|
4
3
|
export type InspectValue = SnapshotValue | string;
|
|
5
4
|
export interface IlhaInspectAtom {
|
|
@@ -41,5 +40,4 @@ export declare const setAtom: <T extends SnapshotValue>(id: string, index: numbe
|
|
|
41
40
|
* runs synchronously, so coalesce in it if you re-read the whole tree.
|
|
42
41
|
* Returns an unsubscribe function.
|
|
43
42
|
*/
|
|
44
|
-
export declare const onChange: (listener: () => void) => (() => void);
|
|
45
|
-
//#endregion
|
|
43
|
+
export declare const onChange: (listener: () => void) => (() => void);
|
package/dist/debug.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { r as rootListeners, t as liveRoots } from "./start-
|
|
2
|
-
import { c as isObject, l as isString, o as isFunction, r as SLOT_ATTR } from "./shared-
|
|
1
|
+
import { r as rootListeners, t as liveRoots } from "./start-j8x3mJSh.js";
|
|
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
5
|
import * as Stream from "effect/Stream";
|
|
6
6
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/debug.ts
|
|
9
9
|
/**
|
|
10
10
|
* Introspection for tests, devtools, and coding agents (`ilha/debug`).
|
|
11
11
|
*
|
|
@@ -213,5 +213,4 @@ const onChange = (listener) => {
|
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
//#endregion
|
|
217
216
|
export { element, inspect, onChange, roots, setAtom };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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";
|
|
8
8
|
import { AtomRegistry } from "effect/reactivity/AtomRegistry";
|
|
9
9
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
10
|
-
//#region src/context.d.ts
|
|
11
10
|
interface ContextProviderProps<A> {
|
|
12
11
|
value: A;
|
|
13
12
|
children?: View;
|
|
@@ -20,8 +19,6 @@ interface IlhaContext<A> {
|
|
|
20
19
|
export declare const createContext: <A>(defaultValue: A) => IlhaContext<A>;
|
|
21
20
|
/** Read a context value as an atom handle. Subscribes the active fiber on read. */
|
|
22
21
|
export declare const context: <A>(ctx: IlhaContext<A>) => AtomHandle<A>;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/diagnostics.d.ts
|
|
25
22
|
/** Stable diagnostic codes. Each one has a page at `https://ilha.build/errors/<code>`. */
|
|
26
23
|
type IlhaCode = "ILHA001" | "ILHA002" | "ILHA003" | "ILHA004" | "ILHA005" | "ILHA006" | "ILHA007";
|
|
27
24
|
/** Error thrown by ilha with a stable `code`, a `fix` hint and a `docs` URL. */
|
|
@@ -31,8 +28,6 @@ export declare class IlhaError extends Error {
|
|
|
31
28
|
readonly docs: string;
|
|
32
29
|
constructor(code: IlhaCode, detail?: string);
|
|
33
30
|
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/error-boundary.d.ts
|
|
36
31
|
interface ErrorFallbackProps {
|
|
37
32
|
error: Error;
|
|
38
33
|
reset: () => void;
|
|
@@ -45,29 +40,28 @@ interface ErrorBoundaryProps {
|
|
|
45
40
|
}
|
|
46
41
|
/** Catch subtree failures and paint a fallback. Supports reset(). */
|
|
47
42
|
export declare const ErrorBoundary: (props: ErrorBoundaryProps) => View;
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/atom.d.ts
|
|
50
43
|
/** Read atoms inside `fn` without subscribing the active render. Sync only. */
|
|
51
44
|
export declare const untrack: <A>(fn: () => A) => A;
|
|
52
45
|
interface AtomFn {
|
|
53
46
|
/** An effect or stream runs once; the handle holds its `AsyncResult`. */
|
|
54
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>;
|
|
55
53
|
/**
|
|
56
54
|
* An existing Effect atom, or a plain value. Store a function with
|
|
57
55
|
* `atom.lazy(() => fn)`; the `ilha/oxlint` rule `function-in-atom` flags
|
|
58
56
|
* `atom(fn)`.
|
|
59
57
|
*/
|
|
60
58
|
<A>(init: Atom.Atom<A> | A, options?: AtomOptions<A>): AtomHandle<A>;
|
|
61
|
-
lazy: <A>(init: () => A, options?: AtomLazyOptions) => AtomHandle<A>;
|
|
59
|
+
lazy: <A>(init: () => A, options?: AtomLazyOptions<A>) => AtomHandle<A>;
|
|
62
60
|
}
|
|
63
61
|
export declare const atom: AtomFn;
|
|
64
62
|
export declare const batch: (f: () => void) => void;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/when.d.ts
|
|
67
63
|
/** Rerun `body` for every value of `stream`, replacing the previous run. */
|
|
68
|
-
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>;
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/unsafe.d.ts
|
|
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>;
|
|
71
65
|
/**
|
|
72
66
|
* Mark a string as pre-rendered HTML and paint it without escaping.
|
|
73
67
|
* Use it for markup you built or sanitized yourself — SVG from an external
|
|
@@ -77,5 +71,4 @@ export declare const when: <A, E = never, R = never>(stream: Stream.Stream<A, E,
|
|
|
77
71
|
* markup still apply.
|
|
78
72
|
*/
|
|
79
73
|
export declare const unsafe: (html: string) => UnsafeHtml;
|
|
80
|
-
//#endregion
|
|
81
74
|
export { type AtomEquality, type AtomHandle, type AtomLazyOptions, type AtomOptions, type Component, type ContextProviderProps, type ErrorBoundaryProps, type ErrorFallback, type ErrorFallbackProps, Fragment, type IlhaCode, type IlhaContext, type MountOptions, type RenderToStringOptions, type UnsafeHtml, type View, type WatchCallback, type WatchContext, type WatchOnceCleanup, h, mount, renderToString, watch };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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-
|
|
2
|
-
import { i as errorView, o as isFunction } from "./shared-
|
|
3
|
-
import { n as unsafe } from "./paint-core-
|
|
4
|
-
import { r as renderToString, t as mount } from "./mount-
|
|
5
|
-
import { r as Fragment, t as h } from "./vnode-
|
|
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
|
+
import { i as errorView, o as isFunction } from "./shared-Bz14CT7Z.js";
|
|
3
|
+
import { n as unsafe } from "./paint-core-cWLlHxoA.js";
|
|
4
|
+
import { r as renderToString, t as mount } from "./mount-nRxVumCX.js";
|
|
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";
|
|
8
8
|
import * as Stream from "effect/Stream";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/context.ts
|
|
11
11
|
const fallbacks = /* @__PURE__ */ new WeakMap();
|
|
12
12
|
const createContext = (defaultValue) => {
|
|
13
13
|
const id = Symbol("ilha.context");
|
|
@@ -40,8 +40,7 @@ const context = (ctx) => {
|
|
|
40
40
|
return wrapHandle(found ?? Atom.make(ctx.defaultValue), fiber);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
//#region src/error-boundary.ts
|
|
43
|
+
// src/error-boundary.ts
|
|
45
44
|
/** Catch subtree failures and paint a fallback. Supports reset(). */
|
|
46
45
|
const ErrorBoundary = (props) => {
|
|
47
46
|
const fiber = getFiber();
|
|
@@ -64,14 +63,14 @@ const ErrorBoundary = (props) => {
|
|
|
64
63
|
return props.children;
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
//#region src/watch.ts
|
|
66
|
+
// src/watch.ts
|
|
69
67
|
const ONCE = Symbol("ilha.watch.once");
|
|
70
68
|
/**
|
|
71
69
|
* Serial runs of one watch slot. Each run gets a fresh signal; starting the
|
|
72
|
-
* 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.
|
|
73
72
|
*/
|
|
74
|
-
const makeRunner = () => {
|
|
73
|
+
const makeRunner = (ssr) => {
|
|
75
74
|
let ctrl;
|
|
76
75
|
const cancel = () => ctrl?.abort();
|
|
77
76
|
return {
|
|
@@ -94,7 +93,8 @@ const makeRunner = () => {
|
|
|
94
93
|
};
|
|
95
94
|
const out = fn({
|
|
96
95
|
onCleanup,
|
|
97
|
-
signal
|
|
96
|
+
signal,
|
|
97
|
+
ssr
|
|
98
98
|
});
|
|
99
99
|
if (out instanceof Promise) settle(out);
|
|
100
100
|
else onCleanup(out);
|
|
@@ -126,7 +126,7 @@ const watch = Object.assign((source, fn) => {
|
|
|
126
126
|
const ref = { fn };
|
|
127
127
|
const key = isFunction(source) ? source.atom : source;
|
|
128
128
|
return useWatchSlot(key, ref, (fiber) => {
|
|
129
|
-
const runner = makeRunner();
|
|
129
|
+
const runner = makeRunner(fiber.runtime.ssr);
|
|
130
130
|
const emit = (value) => runner.run((ctx) => ref.fn(value, ctx));
|
|
131
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 });
|
|
132
132
|
return () => {
|
|
@@ -134,14 +134,13 @@ const watch = Object.assign((source, fn) => {
|
|
|
134
134
|
stop();
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
|
-
}, { once: (fn) => useWatchSlot(ONCE, {}, () => {
|
|
138
|
-
const runner = makeRunner();
|
|
137
|
+
}, { once: (fn) => useWatchSlot(ONCE, {}, (fiber) => {
|
|
138
|
+
const runner = makeRunner(fiber.runtime.ssr);
|
|
139
139
|
runner.run(fn);
|
|
140
140
|
return runner.cancel;
|
|
141
141
|
}) });
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
//#region src/when.ts
|
|
143
|
+
// src/when.ts
|
|
145
144
|
/** Rerun `body` for every value of `stream`, replacing the previous run. */
|
|
146
145
|
const when = (stream, body) => instr(Effect.suspend(() => {
|
|
147
146
|
const parent = getFiber();
|
|
@@ -154,9 +153,8 @@ const when = (stream, body) => instr(Effect.suspend(() => {
|
|
|
154
153
|
return Stream.runForEach(parent.runtime.ssr ? Stream.take(base, 1) : base, (value) => Effect.sync(() => {
|
|
155
154
|
stop();
|
|
156
155
|
child = makeFiber(parent.runtime, parent.root, parent.paintFn, { parent });
|
|
157
|
-
interpret(() => body(value), child);
|
|
156
|
+
interpret((() => body(value)), child);
|
|
158
157
|
})).pipe(Effect.asVoid);
|
|
159
158
|
}));
|
|
160
159
|
|
|
161
|
-
//#endregion
|
|
162
160
|
export { ErrorBoundary, Fragment, IlhaError, atom, batch, context, createContext, h, mount, renderToString, unsafe, untrack, watch, when };
|
|
@@ -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-dev-runtime.js
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
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-
|
|
3
|
-
//#region src/jsx-runtime.d.ts
|
|
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";
|
|
4
3
|
export declare const jsx: (type: string | Fragment | ComponentFn | JsxComponent, props: PropBag | null, key?: string | number) => ReturnType<typeof h>;
|
|
5
4
|
export declare const jsxs: typeof jsx;
|
|
6
5
|
export declare const jsxDEV: typeof jsx;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { Fragment, type JSX, type View, h };
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as Fragment, t as h } from "./vnode-
|
|
1
|
+
import { r as Fragment, t as h } from "./vnode-C_vM-l5s.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/jsx-runtime.ts
|
|
4
4
|
const jsx = (type, props, key) => h(type, key === void 0 ? props : {
|
|
5
5
|
...props,
|
|
6
6
|
key
|
|
@@ -8,5 +8,4 @@ const jsx = (type, props, key) => h(type, key === void 0 ? props : {
|
|
|
8
8
|
const jsxs = jsx;
|
|
9
9
|
const jsxDEV = jsx;
|
|
10
10
|
|
|
11
|
-
//#endregion
|
|
12
11
|
export { Fragment, h, jsx, jsxDEV, jsxs };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as Component, f as MountOptions } from "./types-
|
|
2
|
-
//#region src/mount.d.ts
|
|
1
|
+
import { a as Component, f as MountOptions } from "./types-a9_yNjbT.js";
|
|
3
2
|
interface RenderToStringOptions {
|
|
4
3
|
/** Embed atom state for hydration. Default `true`. */
|
|
5
4
|
snapshot?: boolean;
|
|
@@ -10,5 +9,4 @@ interface RenderToStringOptions {
|
|
|
10
9
|
}
|
|
11
10
|
declare const mount: (el: Element, fn: Component, opts?: MountOptions) => (() => void);
|
|
12
11
|
declare const renderToString: (fn: Component, opts?: RenderToStringOptions) => Promise<string>;
|
|
13
|
-
//#endregion
|
|
14
12
|
export { mount as n, renderToString as r, RenderToStringOptions as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as startRoot, v as ilhaError, y as ilhaWarn } from "./start-
|
|
2
|
-
import { c as isObject, n as KEY_ATTR, r as SLOT_ATTR } from "./shared-
|
|
3
|
-
import { i as bindEvents, r as adoptEvents, t as createPainter } from "./paint-core-
|
|
1
|
+
import { a as startRoot, v as ilhaError, y as ilhaWarn } from "./start-j8x3mJSh.js";
|
|
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-cWLlHxoA.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/morph.ts
|
|
6
6
|
const PRESERVE_ATTR = "data-morph-preserve";
|
|
7
7
|
const STAND_IN_ATTR = "data-ilha-reuse";
|
|
8
8
|
const FORM_ATTR = /^(?:value|checked|selected)$/u;
|
|
@@ -327,8 +327,7 @@ const hydrateInner = (from, to) => {
|
|
|
327
327
|
}
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
|
|
331
|
-
//#region src/paint.ts
|
|
330
|
+
// src/paint.ts
|
|
332
331
|
const toggleAttr = (el, name, on) => {
|
|
333
332
|
if (on) el.setAttribute(name, "");
|
|
334
333
|
else el.removeAttribute(name);
|
|
@@ -385,8 +384,7 @@ const { paint: paint$1 } = createPainter({
|
|
|
385
384
|
}
|
|
386
385
|
});
|
|
387
386
|
|
|
388
|
-
|
|
389
|
-
//#region src/snapshot.ts
|
|
387
|
+
// src/snapshot.ts
|
|
390
388
|
const MAX_SNAPSHOT_CHARS = 262144;
|
|
391
389
|
const MAX_SNAPSHOT_DEPTH = 32;
|
|
392
390
|
const UNSAFE_KEY = /^(?:__proto__|constructor|prototype)$/u;
|
|
@@ -412,8 +410,7 @@ const decodeSnapshot = (raw) => {
|
|
|
412
410
|
return Array.isArray(values) ? values : void 0;
|
|
413
411
|
};
|
|
414
412
|
|
|
415
|
-
|
|
416
|
-
//#region src/ssr-dom.ts
|
|
413
|
+
// src/ssr-dom.ts
|
|
417
414
|
const VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/u;
|
|
418
415
|
/** Tags whose children are raw text — content is not HTML-escaped. */
|
|
419
416
|
const RAW_TEXT = /^(?:script|style)$/u;
|
|
@@ -477,8 +474,7 @@ const serializeNode = (node, bare = false) => {
|
|
|
477
474
|
return `${open}${inner}</${tag}>`;
|
|
478
475
|
};
|
|
479
476
|
|
|
480
|
-
|
|
481
|
-
//#region src/ssr-paint.ts
|
|
477
|
+
// src/ssr-paint.ts
|
|
482
478
|
const WHITESPACE_RUN = /\s+/gu;
|
|
483
479
|
/**
|
|
484
480
|
* Mark the first option whose value is `value` selected and clear the rest,
|
|
@@ -527,8 +523,7 @@ const { paint } = createPainter({
|
|
|
527
523
|
}
|
|
528
524
|
});
|
|
529
525
|
|
|
530
|
-
|
|
531
|
-
//#region src/mount.ts
|
|
526
|
+
// src/mount.ts
|
|
532
527
|
const readSnapshot = (el) => {
|
|
533
528
|
const raw = (el.matches("[data-ilha]") ? el : el.querySelector("[data-ilha]"))?.getAttribute("data-ilha-state");
|
|
534
529
|
if (raw) return decodeSnapshot(raw);
|
|
@@ -581,5 +576,4 @@ const renderToString = async (fn, opts) => {
|
|
|
581
576
|
return state ? `<template${state}></template>${inner}` : inner;
|
|
582
577
|
};
|
|
583
578
|
|
|
584
|
-
//#endregion
|
|
585
579
|
export { mountWithRuntime as n, renderToString as r, mount as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
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-
|
|
3
|
-
import { n as isVNode, r as Fragment } from "./vnode-
|
|
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
|
+
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
|
+
import { n as isVNode, r as Fragment } from "./vnode-C_vM-l5s.js";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Stream from "effect/Stream";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/events.ts
|
|
8
8
|
const EVENT_PROP = /^on(?:[A-Z].{2,}|[a-z]{3,}$)/u;
|
|
9
9
|
/** `onClick` / `onclick` → `click`; non-event props → `undefined`. */
|
|
10
10
|
const eventTypeFromProp = (key) => EVENT_PROP.test(key) ? key.slice(2).toLowerCase() : void 0;
|
|
@@ -43,8 +43,7 @@ const adoptEvents = (live, fresh) => {
|
|
|
43
43
|
if (fresh.__ilhaFiber) install(live, fresh.__ilhaHandlers, fresh.__ilhaFiber);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
//#region src/security.ts
|
|
46
|
+
// src/security.ts
|
|
48
47
|
const SAFE_CSS_PROP = /^-{0,2}[a-zA-Z][a-zA-Z0-9-]*$/u;
|
|
49
48
|
const URL_ATTR = /(?:^|:)(?:href|src|srcset|imagesrcset|action|formaction|cite|data|poster)$/iu;
|
|
50
49
|
const SRCSET_ATTR = /^(?:srcset|imagesrcset)$/iu;
|
|
@@ -72,8 +71,7 @@ const serializeStyleAttr = (value) => {
|
|
|
72
71
|
}) : Object.entries(value)).filter(([k, v]) => k && v !== null && v !== void 0 && SAFE_CSS_PROP.test(k) && isSafeStyleValue(String(v))).map(([k, v]) => `${(k ?? "").replaceAll(/[A-Z]/gu, (m) => `-${m.toLowerCase()}`)}:${String(v)}`).join(";");
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
//#region src/unsafe.ts
|
|
74
|
+
// src/unsafe.ts
|
|
77
75
|
/**
|
|
78
76
|
* Mark a string as pre-rendered HTML and paint it without escaping.
|
|
79
77
|
* Use it for markup you built or sanitized yourself — SVG from an external
|
|
@@ -88,8 +86,7 @@ const unsafe = (html) => ({
|
|
|
88
86
|
});
|
|
89
87
|
const isUnsafeHtml = (x) => hasBrand(x, "$$ilhaUnsafe");
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
//#region src/paint-core.ts
|
|
89
|
+
// src/paint-core.ts
|
|
93
90
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
94
91
|
const MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
95
92
|
const elementNs = (lower, parent) => {
|
|
@@ -346,5 +343,4 @@ const createPainter = (ops) => {
|
|
|
346
343
|
return self;
|
|
347
344
|
};
|
|
348
345
|
|
|
349
|
-
//#endregion
|
|
350
346
|
export { bindEvents as i, unsafe as n, adoptEvents as r, createPainter as t };
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,6 +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-
|
|
3
|
-
//#region src/paint-core.d.ts
|
|
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";
|
|
4
3
|
/** Structural element API shared by DOM `Element`, the SSR shim, and custom hosts. */
|
|
5
4
|
interface PaintEl<Node> {
|
|
6
5
|
readonly tagName: string;
|
|
@@ -47,11 +46,7 @@ interface Painter<Node> {
|
|
|
47
46
|
paint: (fiber: FiberLocal, view: View) => void;
|
|
48
47
|
materialize: (view: View, fiber: FiberLocal) => Node[];
|
|
49
48
|
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/events.d.ts
|
|
52
49
|
export declare const bindEvents: (el: Element, props: PropBag, fiber: FiberLocal) => void;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/renderer.d.ts
|
|
55
50
|
export interface RendererMountOptions {
|
|
56
51
|
/**
|
|
57
52
|
* Called with a failing root component, and with a nested component no
|
|
@@ -79,5 +74,4 @@ export interface HostRenderer<Node> {
|
|
|
79
74
|
}
|
|
80
75
|
/** Build a renderer for a host described by `ops`. */
|
|
81
76
|
export declare const createRenderer: <Node, El extends PaintEl<Node> & Node>(ops: PaintOps<Node, El>) => HostRenderer<Node>;
|
|
82
|
-
//#endregion
|
|
83
77
|
export { type Component, type FiberLocal, type FormControlKey, type IlhaRuntime, type PaintEl, type PaintOps, type Painter, type PropBag, type PropValue, type View, getFiber };
|
package/dist/renderer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
/**
|
|
6
6
|
* Host renderer seam.
|
|
7
7
|
*
|
|
@@ -39,5 +39,4 @@ const createRenderer = (ops) => {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
//#endregion
|
|
43
42
|
export { bindEvents, createRenderer, getFiber };
|
|
@@ -1,11 +1,10 @@
|
|
|
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";
|
|
6
6
|
import { AtomRegistry } from "effect/reactivity/AtomRegistry";
|
|
7
7
|
import * as Scope from "effect/Scope";
|
|
8
|
-
//#region src/watch.d.ts
|
|
9
8
|
/** Values delivered to watch callbacks. */
|
|
10
9
|
type WatchValue = string | number | boolean | bigint | null | undefined | readonly WatchValue[] | WatchRecord;
|
|
11
10
|
interface WatchRecord {
|
|
@@ -31,8 +30,6 @@ interface WatchFn {
|
|
|
31
30
|
once: (fn: WatchRun) => Instruction<void>;
|
|
32
31
|
}
|
|
33
32
|
declare const watch: WatchFn;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/runtime.d.ts
|
|
36
33
|
/** A disposable a paint leaves behind: a child fiber, subscription, or ref. */
|
|
37
34
|
interface Hole {
|
|
38
35
|
dispose: () => void;
|
|
@@ -87,5 +84,4 @@ interface FiberLocal {
|
|
|
87
84
|
fail: <E>(e: E) => void;
|
|
88
85
|
}
|
|
89
86
|
declare const getFiber: () => FiberLocal;
|
|
90
|
-
//#endregion
|
|
91
87
|
export { getFiber as n, watch as r, FiberLocal as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/shared.ts
|
|
4
4
|
const KEY_ATTR = "data-ilha-key";
|
|
5
5
|
const SLOT_ATTR = "data-ilha-slot";
|
|
6
6
|
const isString = (value) => typeof value === "string";
|
|
@@ -32,5 +32,4 @@ const errorView = (e) => ({
|
|
|
32
32
|
type: "pre"
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { hasBrand as a, isObject as c, skip as d, toError as f, errorView as i, isString as l, KEY_ATTR as n, isFunction as o, unwrap as p, SLOT_ATTR as r, isIterable as s, KEEP as t, noop as u };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { u as JsonText } from "./types-
|
|
2
|
-
//#region src/snapshot.d.ts
|
|
1
|
+
import { u as JsonText } from "./types-a9_yNjbT.js";
|
|
3
2
|
/** JSON values accepted in SSR hydrate snapshots. */
|
|
4
3
|
type SnapshotValue = JsonText | SnapshotObject | readonly SnapshotValue[];
|
|
5
4
|
interface SnapshotObject {
|
|
6
5
|
readonly [key: string]: SnapshotValue | undefined;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
7
|
export { SnapshotValue as t };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { a as hasBrand, f as toError, i as errorView, o as isFunction, u as noop } from "./shared-
|
|
1
|
+
import { a as hasBrand, f as toError, i as errorView, o as isFunction, u as noop } from "./shared-Bz14CT7Z.js";
|
|
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";
|
|
@@ -9,7 +11,7 @@ import * as Exit from "effect/Exit";
|
|
|
9
11
|
import * as Registry from "effect/reactivity/AtomRegistry";
|
|
10
12
|
import * as Scope from "effect/Scope";
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
// src/diagnostics.ts
|
|
13
15
|
const DOCS_ORIGIN = "https://ilha.build/errors";
|
|
14
16
|
const CATALOG = {
|
|
15
17
|
ILHA001: {
|
|
@@ -68,8 +70,7 @@ const ilhaWarn = (code, detail) => {
|
|
|
68
70
|
console.warn(ilhaError(code, detail).message);
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
//#region src/runtime.ts
|
|
73
|
+
// src/runtime.ts
|
|
73
74
|
const stack = [];
|
|
74
75
|
const getActiveFiber = () => stack.findLast((x) => !x.closed);
|
|
75
76
|
const getFiber = () => {
|
|
@@ -200,8 +201,7 @@ const makeFiber = (runtime, root, paint, opts) => {
|
|
|
200
201
|
return fiber;
|
|
201
202
|
};
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
//#region src/atom.ts
|
|
204
|
+
// src/atom.ts
|
|
205
205
|
/** Wrap an effect as a `yield*`-able, awaitable instruction bound to the active fiber. */
|
|
206
206
|
const instr = (effect) => {
|
|
207
207
|
const fiber = getFiber();
|
|
@@ -349,9 +349,11 @@ const wrapHandle = (atom, fiber) => {
|
|
|
349
349
|
/**
|
|
350
350
|
* Claim the fiber's next primitive slot. A fresh slot is built by `make`,
|
|
351
351
|
* seeded from the hydration snapshot when `snapshotted`; SSR records its
|
|
352
|
-
* 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.
|
|
353
355
|
*/
|
|
354
|
-
const useSlot = (snapshotted, make) => {
|
|
356
|
+
const useSlot = (snapshotted, make, schema) => {
|
|
355
357
|
const fiber = getFiber();
|
|
356
358
|
const { runtime } = fiber;
|
|
357
359
|
const i = fiber.primitiveI ?? 0;
|
|
@@ -359,14 +361,20 @@ const useSlot = (snapshotted, make) => {
|
|
|
359
361
|
fiber.primitives ??= [];
|
|
360
362
|
let a = fiber.primitives[i];
|
|
361
363
|
if (!a) {
|
|
364
|
+
const codec = snapshotted && schema ? Schema.toCodecJson(schema) : void 0;
|
|
362
365
|
let hydrated;
|
|
363
366
|
if (snapshotted && runtime.hydrateValues) {
|
|
364
|
-
|
|
367
|
+
const seed = runtime.hydrateValues[runtime.hydrateI];
|
|
365
368
|
runtime.hydrateI += 1;
|
|
369
|
+
if (codec === void 0) hydrated = seed;
|
|
370
|
+
else if (seed !== void 0) hydrated = Option.getOrUndefined(Schema.decodeUnknownOption(codec)(seed));
|
|
366
371
|
}
|
|
367
372
|
a = make(fiber, hydrated);
|
|
368
373
|
fiber.primitives[i] = a;
|
|
369
|
-
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
|
+
}
|
|
370
378
|
}
|
|
371
379
|
return wrapHandle(a, fiber);
|
|
372
380
|
};
|
|
@@ -390,12 +398,11 @@ const atom = Object.assign((init, options) => {
|
|
|
390
398
|
const made = Atom.make(seed === void 0 ? init : seed);
|
|
391
399
|
const eq = options?.equals;
|
|
392
400
|
return holdState(fiber, eq ? Atom.withEquality(made, eq === "structural" ? Equal.equals : eq) : made);
|
|
393
|
-
});
|
|
394
|
-
}, { 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) });
|
|
395
403
|
const { batch } = Atom;
|
|
396
404
|
|
|
397
|
-
|
|
398
|
-
//#region src/interpret.ts
|
|
405
|
+
// src/interpret.ts
|
|
399
406
|
/** Drive a generator component: paint yielded views, run yielded effects. */
|
|
400
407
|
const interpret = (gen, fiber) => {
|
|
401
408
|
const iter = gen();
|
|
@@ -434,8 +441,7 @@ const interpret = (gen, fiber) => {
|
|
|
434
441
|
resume();
|
|
435
442
|
};
|
|
436
443
|
|
|
437
|
-
|
|
438
|
-
//#region src/start.ts
|
|
444
|
+
// src/start.ts
|
|
439
445
|
/** Render `fn` into `fiber` and rerender when an atom it read changes. */
|
|
440
446
|
const runSetup = (fiber, fn) => {
|
|
441
447
|
const render = () => {
|
|
@@ -511,5 +517,4 @@ const startRoot = ({ fn, root, paint, ssr, hydrate, snapshot, onError, onIdle, o
|
|
|
511
517
|
};
|
|
512
518
|
};
|
|
513
519
|
|
|
514
|
-
//#endregion
|
|
515
520
|
export { IlhaError as _, startRoot as a, batch as c, untrack as d, wrapHandle as f, makeFiber as g, getFiber as h, runSetup as i, instr as l, closeFiber as m, notifyRoots as n, interpret as o, clearFiberView as p, rootListeners as r, atom as s, liveRoots as t, isAtomHandle as u, ilhaError as v, ilhaWarn as y };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,8 +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-
|
|
5
|
-
//#region src/test.d.ts
|
|
4
|
+
import { t as RenderToStringOptions } from "./mount-ChhKs7A2.js";
|
|
6
5
|
export interface RenderOptions {
|
|
7
6
|
/** Render on the server first and inject the HTML into the container. Default `false`. */
|
|
8
7
|
ssr?: boolean;
|
|
@@ -62,5 +61,4 @@ export declare const renderHtml: (fn: Component, opts?: RenderToStringOptions) =
|
|
|
62
61
|
* `await ui.settled()` before reading `html()`.
|
|
63
62
|
*/
|
|
64
63
|
export declare const render: (fn: Component, opts?: RenderOptions) => TestUi;
|
|
65
|
-
//#endregion
|
|
66
64
|
export type { IlhaInspectNode };
|
package/dist/test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as toError, l as isString } from "./shared-
|
|
2
|
-
import { n as mountWithRuntime, r as renderToString } from "./mount-
|
|
1
|
+
import { f as toError, l as isString } from "./shared-Bz14CT7Z.js";
|
|
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
|
|
6
6
|
const MICROTASK_TURNS = 4;
|
|
7
7
|
const SNIPPET_LENGTH = 400;
|
|
8
8
|
const requireDocument = () => {
|
|
@@ -175,5 +175,4 @@ const render = (fn, opts = {}) => {
|
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
//#endregion
|
|
179
178
|
export { render, renderHtml };
|
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
4
5
|
import { Atom } from "effect/reactivity";
|
|
5
|
-
//#region src/types.d.ts
|
|
6
6
|
type JsonText = string | number | bigint | boolean | null | undefined;
|
|
7
7
|
/** Runtime prop bag values painted onto elements / passed to components. */
|
|
8
8
|
type PropValue = JsonText | PropBag | StyleObject | EventHandler | AtomHandle<JsonText> | readonly PropValue[];
|
|
@@ -64,12 +64,12 @@ interface AtomView {
|
|
|
64
64
|
readonly $$atom: 1;
|
|
65
65
|
readonly atom: Atom.Atom<unknown>;
|
|
66
66
|
}
|
|
67
|
-
interface AtomHandle<A> {
|
|
67
|
+
interface AtomHandle<A, W = A> {
|
|
68
68
|
readonly $$atom: 1;
|
|
69
69
|
readonly atom: Atom.Atom<A>;
|
|
70
70
|
(): A;
|
|
71
|
-
set: (next:
|
|
72
|
-
update: (f: (current: A) =>
|
|
71
|
+
set: (next: W) => void;
|
|
72
|
+
update: (f: (current: A) => W) => void;
|
|
73
73
|
}
|
|
74
74
|
/** Equality for plain-value atoms. `"structural"` deep-compares JSON-shaped values. */
|
|
75
75
|
type AtomEquality<A> = "structural" | ((prev: A, next: A) => boolean);
|
|
@@ -81,24 +81,40 @@ interface AtomOptions<A = unknown> {
|
|
|
81
81
|
* starts from its initial value on hydration. Default `true`.
|
|
82
82
|
*/
|
|
83
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>;
|
|
84
91
|
}
|
|
85
92
|
/** Options for `atom.lazy()`. */
|
|
86
|
-
interface AtomLazyOptions {
|
|
93
|
+
interface AtomLazyOptions<A = unknown> {
|
|
87
94
|
/**
|
|
88
95
|
* Set `false` to keep the slot out of the SSR snapshot, for timers,
|
|
89
96
|
* observers, and other mutable refs. Default `true`.
|
|
90
97
|
*/
|
|
91
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>;
|
|
92
106
|
}
|
|
93
107
|
/** Optional disposer returned from `watch.once`. */
|
|
94
108
|
type WatchOnceCleanup = () => void;
|
|
95
109
|
/**
|
|
96
110
|
* Cancellation context handed to watch callbacks. `signal` aborts when the
|
|
97
111
|
* run goes stale (a newer value arrives), on unmount, or on slot disposal.
|
|
98
|
-
* 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.
|
|
99
114
|
*/
|
|
100
115
|
interface WatchContext {
|
|
101
116
|
readonly signal: AbortSignal;
|
|
117
|
+
readonly ssr: boolean;
|
|
102
118
|
onCleanup: (fn: () => void) => void;
|
|
103
119
|
}
|
|
104
120
|
type WatchCallback<A> = (value: A, ctx: WatchContext) => WatchOnceCleanup | undefined | Promise<WatchOnceCleanup | undefined>;
|
|
@@ -116,5 +132,4 @@ interface MountOptions {
|
|
|
116
132
|
*/
|
|
117
133
|
onIdle?: () => void;
|
|
118
134
|
}
|
|
119
|
-
//#endregion
|
|
120
135
|
export { View as _, Component as a, WatchOnceCleanup as b, IlhaRuntime as c, JsxComponent as d, MountOptions as f, VNode as g, UnsafeHtml as h, AtomOptions as i, Instruction as l, PropValue as m, AtomHandle as n, ComponentFn as o, PropBag as p, AtomLazyOptions as r, Fragment as s, AtomEquality as t, JsonText as u, WatchCallback as v, Yielded as x, WatchContext as y };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { a as hasBrand } from "./shared-
|
|
1
|
+
import { a as hasBrand } from "./shared-Bz14CT7Z.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/types.ts
|
|
4
4
|
const Fragment = Symbol("ilha.Fragment");
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
//#region src/vnode.ts
|
|
6
|
+
// src/vnode.ts
|
|
8
7
|
const createVNode = (type, props, ...rest) => {
|
|
9
8
|
const { key, children, ...own } = props ?? {};
|
|
10
9
|
return {
|
|
@@ -18,5 +17,4 @@ const createVNode = (type, props, ...rest) => {
|
|
|
18
17
|
const h = createVNode;
|
|
19
18
|
const isVNode = (x) => hasBrand(x, "$$ilha");
|
|
20
19
|
|
|
21
|
-
//#endregion
|
|
22
20
|
export { isVNode as n, Fragment as r, h as t };
|
|
@@ -1,5 +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-
|
|
2
|
-
//#region src/jsx-types.d.ts
|
|
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";
|
|
3
2
|
declare namespace JSX {
|
|
4
3
|
export type Element = View;
|
|
5
4
|
export type ElementType = string | ((props: never) => View | Promise<View | undefined> | Generator<View, View | undefined, View> | undefined);
|
|
@@ -590,8 +589,6 @@ declare namespace JSX {
|
|
|
590
589
|
}
|
|
591
590
|
export {};
|
|
592
591
|
}
|
|
593
|
-
//#endregion
|
|
594
|
-
//#region src/vnode.d.ts
|
|
595
592
|
/**
|
|
596
593
|
* Build a vnode. A component with typed props gets its props checked against
|
|
597
594
|
* that type; elements and untyped components take a plain prop bag.
|
|
@@ -601,5 +598,4 @@ interface HFn {
|
|
|
601
598
|
(type: string | Fragment | ComponentFn | JsxComponent, props: PropBag | null | undefined, ...rest: View[]): VNode;
|
|
602
599
|
}
|
|
603
600
|
declare const h: HFn;
|
|
604
|
-
//#endregion
|
|
605
601
|
export { JSX as n, h as t };
|
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.2.
|
|
4
4
|
|
|
5
5
|
Start with the canonical-usage table: exactly one API per task, plus a never-do list.
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilha",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Generator-first island UI on Effect",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect",
|
|
@@ -74,10 +74,9 @@
|
|
|
74
74
|
"typecheck": "tsc -p tsconfig.types.json --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"
|
|
78
|
-
"effect": "^4.0.0"
|
|
77
|
+
"effect": "^4.1.0"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
|
-
"effect": "^4.
|
|
80
|
+
"effect": "^4.1.0"
|
|
82
81
|
}
|
|
83
82
|
}
|