ilha 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -285
- package/dist/define.d.ts +5 -0
- package/dist/define.js +18 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.js +51 -3209
- package/dist/jsx-dev-runtime.d.ts +4 -2
- package/dist/jsx-dev-runtime.js +3 -2
- package/dist/jsx-runtime.d.ts +8 -2
- package/dist/jsx-runtime.js +11 -2
- package/dist/mount-Dcy4teaf.js +992 -0
- package/dist/types-DU46exHq.d.ts +33 -0
- package/dist/vnode-BZLcG8lC.d.ts +20 -0
- package/dist/vnode-DHN2EFHi.js +37 -0
- package/package.json +19 -15
- package/dist/index-CVOjC94p.d.ts +0 -395
- package/dist/internal.d.ts +0 -77
- package/dist/internal.js +0 -62
- package/dist/jsx-runtime-CzU-60tX.d.ts +0 -631
- package/dist/jsx-runtime-DreKruAt.js +0 -124
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "effect/Scope";
|
|
2
|
+
import { AtomRegistry } from "effect/unstable/reactivity/AtomRegistry";
|
|
3
|
+
import { Effect, Stream } from "effect";
|
|
4
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
type JsonText = string | number | bigint | boolean | null | undefined;
|
|
7
|
+
type View = VNode | JsonText | AtomHandle<any> | Stream.Stream<View, any, any> | GeneratorFn | Component | View[] | Iterable<View>;
|
|
8
|
+
declare const Fragment: unique symbol;
|
|
9
|
+
type Fragment = typeof Fragment;
|
|
10
|
+
interface VNode {
|
|
11
|
+
readonly $$ilha: 1;
|
|
12
|
+
readonly type: string | Fragment | ((props: Record<string, unknown>) => unknown);
|
|
13
|
+
readonly props: Record<string, unknown>;
|
|
14
|
+
readonly children: View[];
|
|
15
|
+
readonly key?: string | number;
|
|
16
|
+
}
|
|
17
|
+
type GeneratorFn = (this: void, ...args: any[]) => Generator<Yielded, View | void, unknown>;
|
|
18
|
+
type Yielded = View | Instruction<any> | Effect.Effect<any, any, any>;
|
|
19
|
+
interface Instruction<A, E = unknown> extends Iterable<Instruction<A, E>, A>, PromiseLike<A> {
|
|
20
|
+
readonly $$ilhaOp: 1;
|
|
21
|
+
readonly effect: Effect.Effect<A, E, AtomRegistry>;
|
|
22
|
+
}
|
|
23
|
+
type Component = (() => View | void | Promise<View | void>) | GeneratorFn;
|
|
24
|
+
interface AtomHandle<A> {
|
|
25
|
+
readonly $$atom: 1;
|
|
26
|
+
readonly atom: Atom.Atom<A>;
|
|
27
|
+
(): A;
|
|
28
|
+
set(next: A): void;
|
|
29
|
+
update(f: (current: A) => A): void;
|
|
30
|
+
}
|
|
31
|
+
type Done<A> = (value: A) => void;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Instruction as a, Yielded as c, Fragment as i, Component as n, VNode as o, Done as r, View as s, AtomHandle as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { i as Fragment, o as VNode, s as View } from "./types-DU46exHq.js";
|
|
2
|
+
//#region src/jsx-types.d.ts
|
|
3
|
+
declare namespace JSX {
|
|
4
|
+
type Element = View;
|
|
5
|
+
type ElementType = string | ((props: Record<string, unknown>) => View | Promise<View | void> | Generator<unknown, View | void, unknown>);
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
[tag: string]: {
|
|
8
|
+
ref?: (el: globalThis.Element | null) => void;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ElementChildrenAttribute {
|
|
13
|
+
children: {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/vnode.d.ts
|
|
18
|
+
declare function h(type: string | Fragment | ((props: Record<string, unknown>) => unknown), props: Record<string, unknown> | null | undefined, ...rest: View[]): VNode;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { JSX as n, h as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
const Fragment = Symbol("ilha.Fragment");
|
|
3
|
+
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/vnode.ts
|
|
6
|
+
function h(type, props, ...rest) {
|
|
7
|
+
const p = { ...props };
|
|
8
|
+
const fromProps = p.children;
|
|
9
|
+
delete p.children;
|
|
10
|
+
const children = flatten([...fromProps === void 0 ? [] : [fromProps], ...rest]);
|
|
11
|
+
const key = p.key;
|
|
12
|
+
delete p.key;
|
|
13
|
+
return {
|
|
14
|
+
$$ilha: 1,
|
|
15
|
+
type,
|
|
16
|
+
props: p,
|
|
17
|
+
children,
|
|
18
|
+
key
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function flatten(xs) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const x of xs) if (Array.isArray(x)) out.push(...flatten(x));
|
|
24
|
+
else out.push(x);
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function isVNode(x) {
|
|
28
|
+
return typeof x === "object" && x !== null && x.$$ilha === 1;
|
|
29
|
+
}
|
|
30
|
+
function isSetupFn(x) {
|
|
31
|
+
if (typeof x !== "function") return false;
|
|
32
|
+
const n = x.constructor?.name;
|
|
33
|
+
return n === "GeneratorFunction" || n === "AsyncFunction";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Fragment as i, isSetupFn as n, isVNode as r, h as t };
|
package/package.json
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilha",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "Generator-first island UI on Effect",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"effect",
|
|
7
7
|
"frontend",
|
|
8
8
|
"hydration",
|
|
9
9
|
"island-architecture",
|
|
10
10
|
"islands",
|
|
11
11
|
"jsx",
|
|
12
|
-
"
|
|
13
|
-
"signals",
|
|
14
|
-
"ssr",
|
|
15
|
-
"web-components"
|
|
12
|
+
"ssr"
|
|
16
13
|
],
|
|
17
14
|
"homepage": "https://github.com/ilhajs/ilha#readme",
|
|
18
15
|
"bugs": {
|
|
@@ -42,29 +39,36 @@
|
|
|
42
39
|
},
|
|
43
40
|
"./jsx-runtime": {
|
|
44
41
|
"types": "./dist/jsx-runtime.d.ts",
|
|
45
|
-
"import": "./dist/jsx-runtime.js"
|
|
42
|
+
"import": "./dist/jsx-runtime.js",
|
|
43
|
+
"default": "./src/jsx-runtime.ts"
|
|
46
44
|
},
|
|
45
|
+
"./jsx-runtime.ts": "./src/jsx-runtime.ts",
|
|
47
46
|
"./jsx-dev-runtime": {
|
|
48
47
|
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
49
|
-
"import": "./dist/jsx-dev-runtime.js"
|
|
48
|
+
"import": "./dist/jsx-dev-runtime.js",
|
|
49
|
+
"default": "./src/jsx-dev-runtime.ts"
|
|
50
50
|
},
|
|
51
|
-
"./
|
|
52
|
-
|
|
53
|
-
"
|
|
51
|
+
"./jsx-dev-runtime.ts": "./src/jsx-dev-runtime.ts",
|
|
52
|
+
"./define": {
|
|
53
|
+
"types": "./dist/define.d.ts",
|
|
54
|
+
"import": "./dist/define.js"
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
|
-
"build": "
|
|
61
|
+
"build": "tsdown",
|
|
61
62
|
"cleanup": "rimraf dist node_modules",
|
|
62
63
|
"test": "bun test"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"
|
|
66
|
+
"@happy-dom/global-registrator": "^20.11.2"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"
|
|
69
|
+
"effect": "^4.0.0-rc.112"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"effect": "^4.0.0-rc.112"
|
|
69
73
|
}
|
|
70
74
|
}
|
package/dist/index-CVOjC94p.d.ts
DELETED
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
|
-
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
4
|
-
}
|
|
5
|
-
declare namespace StandardSchemaV1 {
|
|
6
|
-
interface Props<Input = unknown, Output = Input> {
|
|
7
|
-
readonly version: 1;
|
|
8
|
-
readonly vendor: string;
|
|
9
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
10
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
11
|
-
}
|
|
12
|
-
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
13
|
-
interface SuccessResult<Output> {
|
|
14
|
-
readonly value: Output;
|
|
15
|
-
readonly issues?: undefined;
|
|
16
|
-
}
|
|
17
|
-
interface FailureResult {
|
|
18
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
19
|
-
}
|
|
20
|
-
interface Issue {
|
|
21
|
-
readonly message: string;
|
|
22
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
23
|
-
}
|
|
24
|
-
interface PathSegment {
|
|
25
|
-
readonly key: PropertyKey;
|
|
26
|
-
}
|
|
27
|
-
interface Types<Input = unknown, Output = Input> {
|
|
28
|
-
readonly input: Input;
|
|
29
|
-
readonly output: Output;
|
|
30
|
-
}
|
|
31
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
32
|
-
}
|
|
33
|
-
/** Strict single-URL check — all data: URLs rejected. */
|
|
34
|
-
declare function isSafeUrl(value: string): boolean;
|
|
35
|
-
/** Element- and attribute-aware URL policy for rendered attributes.
|
|
36
|
-
* `srcset`/`imagesrcset` validate each comma-separated candidate URL. */
|
|
37
|
-
declare function isSafeUrlAttrValue(tagName: string, attrName: string, value: string): boolean;
|
|
38
|
-
declare function isUrlAttributeName(name: string): boolean;
|
|
39
|
-
declare function serializeStyle(value: Record<string, unknown>): string;
|
|
40
|
-
declare const RAW: unique symbol;
|
|
41
|
-
declare const SIGNAL_ACCESSOR: unique symbol;
|
|
42
|
-
declare const ISLAND: unique symbol;
|
|
43
|
-
declare const ISLAND_CALL: unique symbol;
|
|
44
|
-
/** Hydration manifest mapping `${type}:${index}` event-sentinel pairs to the
|
|
45
|
-
* action keys that own them. Emitted by hydratable(); lets server-owned
|
|
46
|
-
* islands (whose render fn never ships to the client) reconnect their
|
|
47
|
-
* interactive surface. */
|
|
48
|
-
interface RawHtml {
|
|
49
|
-
[RAW]: true;
|
|
50
|
-
value: string;
|
|
51
|
-
}
|
|
52
|
-
/** Mapped list result — usable directly in templates; chain `.else()` for empty fallback. */
|
|
53
|
-
type EachResult<TItem, TOut> = TOut[] & {
|
|
54
|
-
else<TEmpty>(fn: (items: readonly TItem[]) => TEmpty): TOut[] | TEmpty;
|
|
55
|
-
else<TEmpty>(value: TEmpty): TOut[] | TEmpty;
|
|
56
|
-
};
|
|
57
|
-
interface EachKeyedBuilder<TItem, TKey> {
|
|
58
|
-
as<TOut>(fn: (item: TItem, index: number, key: TKey) => TOut): EachResult<TItem, TOut>;
|
|
59
|
-
}
|
|
60
|
-
interface EachBuilder<TItem> {
|
|
61
|
-
key<TKey>(fn: (item: TItem, index: number) => TKey): EachKeyedBuilder<TItem, TKey>;
|
|
62
|
-
as<TOut>(fn: (item: TItem, index: number) => TOut): EachResult<TItem, TOut>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Svelte-style `{#each}` helper for mapping collections to rendered output
|
|
66
|
-
* with an optional empty fallback.
|
|
67
|
-
*
|
|
68
|
-
* @example — plain list (empty → [])
|
|
69
|
-
* each(items).as((item) => html`<li>${item.name}</li>`)
|
|
70
|
-
*
|
|
71
|
-
* @example — keyed list feeding island.key(), with empty fallback
|
|
72
|
-
* each(items)
|
|
73
|
-
* .key((item) => item.id)
|
|
74
|
-
* .as((item, _i, id) => Row.key(id)({ item }))
|
|
75
|
-
* .else(() => html`<EmptyState />`)
|
|
76
|
-
*/
|
|
77
|
-
declare function each<TItem>(items: readonly TItem[]): EachBuilder<TItem>;
|
|
78
|
-
interface IslandCall {
|
|
79
|
-
[ISLAND_CALL]: true;
|
|
80
|
-
island: AnyIsland;
|
|
81
|
-
props: Record<string, unknown> | undefined;
|
|
82
|
-
key: string | undefined;
|
|
83
|
-
}
|
|
84
|
-
type NativeEventModifier = "abortable" | "once" | "capture" | "passive";
|
|
85
|
-
interface NativeEventContext {
|
|
86
|
-
readonly signal: AbortSignal;
|
|
87
|
-
}
|
|
88
|
-
type NativeEventHandler<E extends Event = Event> = (event: E, context: NativeEventContext) => unknown;
|
|
89
|
-
declare const SIGNAL_WRITER_TYPE: unique symbol;
|
|
90
|
-
/** @internal Type-level write target carried by signal accessors. */
|
|
91
|
-
interface SignalWriter<T> {
|
|
92
|
-
readonly [SIGNAL_WRITER_TYPE]?: (value: T) => void;
|
|
93
|
-
}
|
|
94
|
-
type PathValue<T, P extends readonly PathSegment[]> = P extends readonly [infer Head, ...infer Tail] ? Head extends keyof T ? Tail extends readonly PathSegment[] ? PathValue<T[Head], Tail> : never : unknown : T;
|
|
95
|
-
interface MarkedSignalAccessor<T> extends SignalWriter<T> {
|
|
96
|
-
(): T;
|
|
97
|
-
set(value: T): void;
|
|
98
|
-
update(fn: (previous: T) => T): void;
|
|
99
|
-
select<S>(selector: (state: T) => S): MarkedSignalAccessor<S>;
|
|
100
|
-
select<const P extends readonly PathSegment[]>(...path: P): MarkedSignalAccessor<PathValue<T, P>>;
|
|
101
|
-
[SIGNAL_ACCESSOR]: true;
|
|
102
|
-
}
|
|
103
|
-
type PathSegment = string | number;
|
|
104
|
-
declare function ilhaRaw(value: string): RawHtml;
|
|
105
|
-
/**
|
|
106
|
-
* Serialize a JSON-safe value into executable `<script>` content safely. `<`
|
|
107
|
-
* is escaped as `\u003C`, so a value can never close the script block or open
|
|
108
|
-
* the `<!--` escape hatch. Use it for script-element data:
|
|
109
|
-
*
|
|
110
|
-
* ```ts
|
|
111
|
-
* html`<script>const d = ${json(payload)};</script>`
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* Like `raw()`, `json()` is for element *content* only — interpolating it into
|
|
115
|
-
* an attribute is author error. It does not protect against values that are
|
|
116
|
-
* not valid JSON (functions, symbols, undefined, cyclic objects are dropped
|
|
117
|
-
* or throw, matching `JSON.stringify`).
|
|
118
|
-
*/
|
|
119
|
-
declare function json(value: unknown): RawHtml;
|
|
120
|
-
/**
|
|
121
|
-
* Escape text for a `<style>` element body. `<` becomes the CSS hex escape
|
|
122
|
-
* `\3C `, so the value can never close the style block or open the `<!--`
|
|
123
|
-
* escape hatch while surviving CSS parsing:
|
|
124
|
-
*
|
|
125
|
-
* ```ts
|
|
126
|
-
* html`<style>${css(cssSource)}</style>`
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* Like `raw()`, `css()` is for element *content* only — interpolating it into
|
|
130
|
-
* an attribute is author error.
|
|
131
|
-
*/
|
|
132
|
-
declare function css(value: string): RawHtml;
|
|
133
|
-
declare const TEMPLATE_PARTS: unique symbol;
|
|
134
|
-
interface TemplateParts {
|
|
135
|
-
[TEMPLATE_PARTS]: true;
|
|
136
|
-
values: unknown[];
|
|
137
|
-
}
|
|
138
|
-
type TemplateNode = {
|
|
139
|
-
kind: "fragment";
|
|
140
|
-
children: TemplateNode[];
|
|
141
|
-
} | {
|
|
142
|
-
kind: "element";
|
|
143
|
-
tag: string;
|
|
144
|
-
props: Record<string, unknown>;
|
|
145
|
-
children: TemplateNode[];
|
|
146
|
-
selfClosing?: boolean;
|
|
147
|
-
} | {
|
|
148
|
-
kind: "text";
|
|
149
|
-
value: string;
|
|
150
|
-
} | {
|
|
151
|
-
kind: "comment";
|
|
152
|
-
value: string | TemplateParts;
|
|
153
|
-
} | {
|
|
154
|
-
kind: "dynamic";
|
|
155
|
-
value: unknown;
|
|
156
|
-
};
|
|
157
|
-
declare function ilhaHtml(strings: TemplateStringsArray, ...values: unknown[]): RawHtml;
|
|
158
|
-
type ContextSignal<T> = SignalAccessor<T>;
|
|
159
|
-
declare function ilhaContextFn<T>(key: string, initial: T): ContextSignal<T>;
|
|
160
|
-
/**
|
|
161
|
-
* Run `fn` with reactive tracking suspended. Reading signals inside `fn`
|
|
162
|
-
* returns their current value without subscribing the surrounding scope.
|
|
163
|
-
* Use this in effects/deriveds when you want to peek at state without
|
|
164
|
-
* causing a re-run on its changes.
|
|
165
|
-
*/
|
|
166
|
-
declare function untrack<T>(fn: () => T): T;
|
|
167
|
-
/**
|
|
168
|
-
* Run `fn` as an atomic batch — multiple signal writes inside the callback
|
|
169
|
-
* produce a single propagation pass, so dependents (effects, deriveds,
|
|
170
|
-
* island re-renders) see the final state and run once instead of once per
|
|
171
|
-
* write. Returns whatever `fn` returns.
|
|
172
|
-
*
|
|
173
|
-
* Note: `.on()` handlers and `.effect()` runs are batched implicitly, so
|
|
174
|
-
* you only need this when triggering multiple writes from outside an
|
|
175
|
-
* island (e.g. from a top-level event listener or async callback).
|
|
176
|
-
*/
|
|
177
|
-
declare function batch<T>(fn: () => T): T;
|
|
178
|
-
/** Minimal storage surface — `localStorage`, `sessionStorage`, or a custom adapter. */
|
|
179
|
-
type PersistStorage = Pick<Storage, "getItem" | "setItem">;
|
|
180
|
-
interface PersistOptions<T> {
|
|
181
|
-
/** Storage backend. Default: `window.localStorage`. */
|
|
182
|
-
storage?: PersistStorage;
|
|
183
|
-
/**
|
|
184
|
-
* Mirror writes from other tabs via the window `storage` event. Only active
|
|
185
|
-
* for the default `localStorage` backend. Default: `true`.
|
|
186
|
-
*/
|
|
187
|
-
crossTab?: boolean;
|
|
188
|
-
/** Value → string. Default: `JSON.stringify`. */
|
|
189
|
-
serialize?: (value: T) => string;
|
|
190
|
-
/** String → value. Default: `JSON.parse` (malformed payloads are ignored). */
|
|
191
|
-
deserialize?: (raw: string) => T | null;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Keep a standalone signal in sync with persistent storage:
|
|
195
|
-
*
|
|
196
|
-
* 1. On call, reads `key` and writes the stored value into the signal.
|
|
197
|
-
* 2. Subscribes to the signal and writes its value back on every change.
|
|
198
|
-
* 3. Optionally mirrors writes from other tabs (`storage` events).
|
|
199
|
-
*
|
|
200
|
-
* No-op on the server (returns an inert unsubscribe). Call the returned
|
|
201
|
-
* unsubscribe to stop syncing.
|
|
202
|
-
*
|
|
203
|
-
* ```ts
|
|
204
|
-
* const cart = signal([] as string[]);
|
|
205
|
-
* persist(cart, "cart");
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
declare function persist<T>(accessor: SignalAccessor<T>, key: string, options?: PersistOptions<T>): () => void;
|
|
209
|
-
interface DerivedValue<T> {
|
|
210
|
-
loading: boolean;
|
|
211
|
-
value: T | undefined;
|
|
212
|
-
error: Error | undefined;
|
|
213
|
-
}
|
|
214
|
-
type DerivedAccessor<T> = {
|
|
215
|
-
readonly loading: boolean;
|
|
216
|
-
readonly value: T | undefined;
|
|
217
|
-
readonly error: Error | undefined;
|
|
218
|
-
(): T | undefined;
|
|
219
|
-
set(value: T): void;
|
|
220
|
-
update(fn: (previous: T | undefined) => T | undefined): void;
|
|
221
|
-
};
|
|
222
|
-
type ExternalSignal<T = unknown> = SignalAccessor<T>;
|
|
223
|
-
type SignalAccessor<T> = MarkedSignalAccessor<T>;
|
|
224
|
-
/** Island-local reactive state returned by the state() primitive. */
|
|
225
|
-
type StateAccessor<T> = MarkedSignalAccessor<T>;
|
|
226
|
-
/** A function component body: receives current props, returns HTML. */
|
|
227
|
-
type IslandComponent<P> = (props: P) => string | RawHtml;
|
|
228
|
-
interface HydratableOptions {
|
|
229
|
-
name: string;
|
|
230
|
-
as?: string;
|
|
231
|
-
snapshot?: boolean | {
|
|
232
|
-
state?: boolean;
|
|
233
|
-
derived?: boolean;
|
|
234
|
-
};
|
|
235
|
-
skipOnMount?: boolean;
|
|
236
|
-
}
|
|
237
|
-
interface Island<TInput = Record<string, unknown>> {
|
|
238
|
-
(props?: Partial<TInput>): IslandCall;
|
|
239
|
-
toString(props?: Partial<TInput>): string;
|
|
240
|
-
/**
|
|
241
|
-
* Async SSR: renders the island and awaits async derived values before
|
|
242
|
-
* returning the HTML string. Always returns a Promise.
|
|
243
|
-
*/
|
|
244
|
-
toStringAsync(props?: Partial<TInput>): Promise<string>;
|
|
245
|
-
mount(host: Element, props?: Partial<TInput>): () => void;
|
|
246
|
-
hydratable(props: Partial<TInput>, options: HydratableOptions): Promise<string>;
|
|
247
|
-
key(key: string): KeyedIsland<TInput>;
|
|
248
|
-
/**
|
|
249
|
-
* Register this island as a custom element, usable from plain HTML or any
|
|
250
|
-
* framework: `Counter.define("x-counter", { observe: ["label"] })` then
|
|
251
|
-
* `<x-counter label="hi"></x-counter>`. Observed attributes become string
|
|
252
|
-
* props and re-resolve on change; richer props can be assigned via the
|
|
253
|
-
* element's `props` property. Mounts on connect, unmounts on disconnect.
|
|
254
|
-
* No-op (with a dev warning) where customElements is missing.
|
|
255
|
-
*/
|
|
256
|
-
define(tagName: string, options?: {
|
|
257
|
-
observe?: string[];
|
|
258
|
-
}): void;
|
|
259
|
-
[ISLAND]: true;
|
|
260
|
-
}
|
|
261
|
-
interface KeyedIsland<TInput> {
|
|
262
|
-
(props?: Partial<TInput>): IslandCall;
|
|
263
|
-
[ISLAND_CALL]: true;
|
|
264
|
-
}
|
|
265
|
-
type AnyIsland = Island<any>;
|
|
266
|
-
type ActionCall<P> = [P] extends [undefined] ? () => void : unknown extends P ? () => void : (payload: P) => void;
|
|
267
|
-
/** A bound action can back native events or component callback props.
|
|
268
|
-
* Runtime arguments are ignored when `.with()` binds a payload. */
|
|
269
|
-
type BoundActionHandler = (...runtimeArgs: unknown[]) => unknown;
|
|
270
|
-
/**
|
|
271
|
-
* Reactive operation with execution state. `pending`, `data`, and `error`
|
|
272
|
-
* are reactive: reading them during render subscribes the island render.
|
|
273
|
-
*/
|
|
274
|
-
type ActionAccessor<P = undefined, R = void> = ActionCall<P> & {
|
|
275
|
-
readonly pending: boolean;
|
|
276
|
-
readonly data: Awaited<R> | undefined;
|
|
277
|
-
readonly error: Error | undefined;
|
|
278
|
-
/** Bind an explicit serializable payload into an RPC-replayable action
|
|
279
|
-
* reference for server-owned islands (`onclick={remove.with(id)}`).
|
|
280
|
-
* Arguments are validated JSON-safe (≤ 8 KiB serialized) at bind time and
|
|
281
|
-
* stored in the hydration manifest — never extracted by executing code. */
|
|
282
|
-
with: (...args: unknown[]) => BoundActionHandler;
|
|
283
|
-
};
|
|
284
|
-
interface EffectContext {
|
|
285
|
-
/**
|
|
286
|
-
* AbortSignal that aborts when the effect re-runs (a dependency changed)
|
|
287
|
-
* or when the island unmounts. Pass to `fetch` or check `signal.aborted`
|
|
288
|
-
* after `await` boundaries to bail out of stale work.
|
|
289
|
-
*/
|
|
290
|
-
signal: AbortSignal;
|
|
291
|
-
}
|
|
292
|
-
interface EffectOnceContext {
|
|
293
|
-
host: Element;
|
|
294
|
-
/** AbortSignal that aborts when the island unmounts. */
|
|
295
|
-
signal: AbortSignal;
|
|
296
|
-
/** True when hydration restored existing markup/state for this instance. */
|
|
297
|
-
hydrated: boolean;
|
|
298
|
-
}
|
|
299
|
-
type EffectFn = (ctx: EffectContext) => void | (() => void);
|
|
300
|
-
type EffectOnceFn = (ctx: EffectOnceContext) => void | (() => void);
|
|
301
|
-
type ErrorSource = "effect" | "once" | "event" | "action";
|
|
302
|
-
/**
|
|
303
|
-
* Register a global error handler invoked when any island reports an error
|
|
304
|
-
* and has no local onError() handler. Returns an unsubscribe function.
|
|
305
|
-
*/
|
|
306
|
-
declare function onUncaughtError(fn: (error: Error, source: ErrorSource) => void): () => void;
|
|
307
|
-
interface ErrorContext {
|
|
308
|
-
error: Error;
|
|
309
|
-
source: ErrorSource;
|
|
310
|
-
host: Element;
|
|
311
|
-
}
|
|
312
|
-
interface MountOptions {
|
|
313
|
-
root?: Element;
|
|
314
|
-
lazy?: boolean;
|
|
315
|
-
}
|
|
316
|
-
interface MountResult {
|
|
317
|
-
unmount: () => void | Promise<void>;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Declare island-local reactive state at this call position. The initializer
|
|
321
|
-
* applies only when the instance is created — later renders reuse the same
|
|
322
|
-
* underlying signal, so prop-driven initializers never reset user state.
|
|
323
|
-
*
|
|
324
|
-
* A function argument is treated as a lazy initializer:
|
|
325
|
-
* const count = state(() => expensiveInitialValue());
|
|
326
|
-
* To store a function VALUE, pass it to `.set`:
|
|
327
|
-
* onSave.set(nextCallback);
|
|
328
|
-
*/
|
|
329
|
-
declare function state<T>(init?: T | (() => T)): StateAccessor<T>;
|
|
330
|
-
/**
|
|
331
|
-
* Declare derived state at this call position: synchronous computations,
|
|
332
|
-
* Promises, or async generators. Reads track their dependencies; async work
|
|
333
|
-
* races latest-run-wins and aborts stale runs through `ctx.signal`.
|
|
334
|
-
*/
|
|
335
|
-
declare function derived<V>(fn: (ctx: {
|
|
336
|
-
signal: AbortSignal;
|
|
337
|
-
}) => V | Promise<V> | AsyncIterable<V>): DerivedAccessor<V>;
|
|
338
|
-
/**
|
|
339
|
-
* Declare a reactive operation at this call position. Use plain functions
|
|
340
|
-
* for ordinary operations; action() adds pending/data/error tracking,
|
|
341
|
-
* concurrent-invocation bookkeeping, and lifecycle cancellation.
|
|
342
|
-
*/
|
|
343
|
-
declare function action<P, R>(fn: (payload: P, ctx: {
|
|
344
|
-
signal: AbortSignal;
|
|
345
|
-
}) => R): ActionAccessor<P, R>;
|
|
346
|
-
/**
|
|
347
|
-
* Reactive side effect. Inside an island render, registers an ordered effect
|
|
348
|
-
* slot that tracks signals read in the body, reruns on change, cleans up
|
|
349
|
-
* before rerun and on unmount, and is client-only. Outside an island render,
|
|
350
|
-
* behaves as the standalone reactive effect and returns a stop function.
|
|
351
|
-
*
|
|
352
|
-
* @returns Inside an island render, `void` (an effect slot is registered and
|
|
353
|
-
* cleaned up automatically). At module scope, a stop function that disposes
|
|
354
|
-
* the effect and runs its final cleanup. The union return type is deliberate:
|
|
355
|
-
* the same call shape cannot be discriminated at the call site.
|
|
356
|
-
*/
|
|
357
|
-
declare const effect: ((fn: EffectFn) => void | (() => void)) & {
|
|
358
|
-
once(fn: EffectOnceFn): void;
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Register an error handler slot for this island. Handlers run in
|
|
362
|
-
* declaration order; state, derived values, actions, and props should be
|
|
363
|
-
* accessed through lexical closure rather than the context object.
|
|
364
|
-
*/
|
|
365
|
-
declare function onError(fn: (ctx: ErrorContext) => void): void;
|
|
366
|
-
type IlhaFactory = {
|
|
367
|
-
<P>(component: IslandComponent<P>): Island<P>;
|
|
368
|
-
<P>(component: IslandComponent<P>, options: {
|
|
369
|
-
as?: string;
|
|
370
|
-
}): Island<P>;
|
|
371
|
-
<S extends StandardSchemaV1>(schema: S, component: IslandComponent<StandardSchemaV1.InferOutput<S>>): Island<StandardSchemaV1.InferOutput<S>>;
|
|
372
|
-
<S extends StandardSchemaV1>(schema: S, component: IslandComponent<StandardSchemaV1.InferOutput<S>>, options: {
|
|
373
|
-
as?: string;
|
|
374
|
-
}): Island<StandardSchemaV1.InferOutput<S>>;
|
|
375
|
-
};
|
|
376
|
-
declare const ilha: IlhaFactory;
|
|
377
|
-
type IslandRegistry = Record<string, AnyIsland>;
|
|
378
|
-
declare function mountAll(registry: IslandRegistry, options?: MountOptions): MountResult;
|
|
379
|
-
/**
|
|
380
|
-
* Morph an element's children toward `html`, patching in place: surviving
|
|
381
|
-
* elements keep their identity, listeners, and focus (see the morph engine).
|
|
382
|
-
* Falls back to an innerHTML write when the root tags don't match.
|
|
383
|
-
*/
|
|
384
|
-
declare function morph(host: Element, html: string): void;
|
|
385
|
-
declare const html: typeof ilhaHtml;
|
|
386
|
-
declare const raw: typeof ilhaRaw;
|
|
387
|
-
declare const mount: typeof mountAll;
|
|
388
|
-
declare const context: typeof ilhaContextFn & {
|
|
389
|
-
/** Remove a context signal from the registry. Returns true if it existed. */
|
|
390
|
-
delete(key: string): boolean;
|
|
391
|
-
/** Remove all context signals from the registry (e.g. between tests). */
|
|
392
|
-
clear(): void;
|
|
393
|
-
};
|
|
394
|
-
//#endregion
|
|
395
|
-
export { action as A, isSafeUrlAttrValue as B, PersistOptions as C, SignalWriter as D, SignalAccessor as E, each as F, onError as G, json as H, effect as I, raw as J, onUncaughtError as K, html as L, context as M, css as N, StateAccessor as O, derived as P, ilha as R, NativeEventModifier as S, RawHtml as T, morph as U, isUrlAttributeName as V, mount as W, state as X, serializeStyle as Y, untrack as Z, KeyedIsland as _, EachKeyedBuilder as a, NativeEventContext as b, EffectFn as c, ErrorContext as d, ErrorSource as f, IslandComponent as g, Island as h, EachBuilder as i, batch as j, TemplateNode as k, EffectOnceContext as l, HydratableOptions as m, DerivedAccessor as n, EachResult as o, ExternalSignal as p, persist as q, DerivedValue as r, EffectContext as s, ActionAccessor as t, EffectOnceFn as u, MountOptions as v, PersistStorage as w, NativeEventHandler as x, MountResult as y, isSafeUrl as z };
|
package/dist/internal.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { S as NativeEventModifier, T as RawHtml, k as TemplateNode, x as NativeEventHandler } from "./index-CVOjC94p.js";
|
|
2
|
-
//#region src/internal.d.ts
|
|
3
|
-
type ServerAction<A extends unknown[] = unknown[], R = unknown> = ((...args: A) => R) & {
|
|
4
|
-
with: (...args: unknown[]) => (...runtimeArgs: unknown[]) => unknown;
|
|
5
|
-
};
|
|
6
|
-
type ServerActionBinder = <A extends unknown[], R>(fn: (...args: A) => R, manifestId?: string) => ServerAction<A, R>;
|
|
7
|
-
/** @internal Register core's action branding implementation. */
|
|
8
|
-
declare function setServerActionBinder(binder: ServerActionBinder): void;
|
|
9
|
-
/** @internal Brand an external server action for hydration-manifest replay. */
|
|
10
|
-
declare function bindServerAction<A extends unknown[], R>(fn: (...args: A) => R, manifestId?: string): ServerAction<A, R>;
|
|
11
|
-
/** Registry of live island mount handles keyed by host element. */
|
|
12
|
-
declare const ISLAND_MOUNT_HANDLES: WeakMap<Element, {
|
|
13
|
-
unmount: () => void | Promise<void>;
|
|
14
|
-
updateProps: (props?: Record<string, unknown>) => void;
|
|
15
|
-
}>;
|
|
16
|
-
/** Hook a parent's mountSlots uses to mount a child island and keep a handle
|
|
17
|
-
* for pushing updated props on later parent re-renders. */
|
|
18
|
-
declare const ISLAND_MOUNT_INTERNAL: unique symbol;
|
|
19
|
-
interface JsxEventRegistration {
|
|
20
|
-
type: string;
|
|
21
|
-
handler: NativeEventHandler;
|
|
22
|
-
modifier?: NativeEventModifier;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Bridge between the framework-agnostic JSX runtime and the active render.
|
|
26
|
-
* The core registers an implementation at module init; before that (or
|
|
27
|
-
* outside an island render) event registration yields no sentinel.
|
|
28
|
-
*/
|
|
29
|
-
interface JsxRuntimeBridge {
|
|
30
|
-
registerEvent(registration: JsxEventRegistration): number | undefined;
|
|
31
|
-
/** Compose a child-island slot marker for direct `<Island />` calls. */
|
|
32
|
-
slot(options: {
|
|
33
|
-
island: unknown;
|
|
34
|
-
props: Record<string, unknown> | undefined;
|
|
35
|
-
key: string | undefined;
|
|
36
|
-
}): RawHtml;
|
|
37
|
-
}
|
|
38
|
-
/** Register the core's bridge implementation. Internal — called once by ilha. */
|
|
39
|
-
declare function setJsxRuntimeBridge(implementation: JsxRuntimeBridge): void;
|
|
40
|
-
/** @internal Register a native event handler with the active render context. */
|
|
41
|
-
declare function __ilhaJsxEvent(registration: JsxEventRegistration): number | undefined;
|
|
42
|
-
/** @internal Preserve island slot composition from the JSX runtime. */
|
|
43
|
-
declare function __ilhaJsxSlot(options: {
|
|
44
|
-
island: unknown;
|
|
45
|
-
props: Record<string, unknown> | undefined;
|
|
46
|
-
key: string | undefined;
|
|
47
|
-
}): RawHtml;
|
|
48
|
-
type TemplateRenderer = (node: TemplateNode) => RawHtml;
|
|
49
|
-
/** Register the core's template→HTML renderer. Internal — called once by ilha. */
|
|
50
|
-
declare function setTemplateRenderer(renderer: TemplateRenderer): void;
|
|
51
|
-
/**
|
|
52
|
-
* @internal Render a template IR node to RawHtml. Used by the JSX runtime so
|
|
53
|
-
* elements skip the html`` string/parse round-trip.
|
|
54
|
-
*/
|
|
55
|
-
declare function __ilhaRenderTemplate(node: TemplateNode): RawHtml;
|
|
56
|
-
/** A hydration-manifest entry: sentinel key → action id or captured payload. */
|
|
57
|
-
type ManifestEntry = string | {
|
|
58
|
-
k: string;
|
|
59
|
-
a: unknown[];
|
|
60
|
-
};
|
|
61
|
-
interface ServerManifestSerializer {
|
|
62
|
-
/**
|
|
63
|
-
* Serialize one island's event→action manifest into markup hoisted ahead of
|
|
64
|
-
* the island HTML (e.g. a `<template data-ilha-actions>` element).
|
|
65
|
-
*/
|
|
66
|
-
template(manifest: Map<string, ManifestEntry>): string;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Register the server-manifest serializer. Owned by @ilha/router — core only
|
|
70
|
-
* collects manifest data and delegates all markup serialization to the
|
|
71
|
-
* registered adapter (no-op until one registers).
|
|
72
|
-
*/
|
|
73
|
-
declare function setServerManifestSerializer(serializer: ServerManifestSerializer | null): void;
|
|
74
|
-
/** @internal Used by island rendering to serialize nested child manifests. */
|
|
75
|
-
declare function serializeServerManifest(manifest: Map<string, ManifestEntry>): string;
|
|
76
|
-
//#endregion
|
|
77
|
-
export { ISLAND_MOUNT_HANDLES, ISLAND_MOUNT_INTERNAL, JsxEventRegistration, JsxRuntimeBridge, ManifestEntry, ServerAction, ServerManifestSerializer, __ilhaJsxEvent, __ilhaJsxSlot, __ilhaRenderTemplate, bindServerAction, serializeServerManifest, setJsxRuntimeBridge, setServerActionBinder, setServerManifestSerializer, setTemplateRenderer };
|