@farm.js/react 0.1.0-beta.0 → 0.1.0-beta.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/README.md +277 -11
- package/dist/compiler-runtime.cjs +1290 -17
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +132 -5
- package/dist/compiler-runtime.d.ts +132 -5
- package/dist/compiler-runtime.mjs +1290 -17
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +24 -2
- package/dist/index.mjs.map +1 -1
- package/dist/list.cjs +27 -0
- package/dist/list.cjs.map +1 -0
- package/dist/list.d.mts +20 -0
- package/dist/list.d.ts +20 -0
- package/dist/list.mjs +21 -0
- package/dist/list.mjs.map +1 -0
- package/dist/vite.cjs +2332 -140
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2332 -140
- package/dist/vite.mjs.map +1 -1
- package/package.json +10 -4
|
@@ -8,29 +8,156 @@ interface CompilerCell {
|
|
|
8
8
|
interface CompilerTextBinding<Props> {
|
|
9
9
|
kind: "text";
|
|
10
10
|
path: readonly number[];
|
|
11
|
+
/** Stable ref target emitted by newer compiler versions. */
|
|
12
|
+
target?: number;
|
|
11
13
|
dependencies: readonly number[];
|
|
12
14
|
read(props: Props, state: readonly CompilerCell[]): unknown;
|
|
13
15
|
}
|
|
14
16
|
interface CompilerAttributeBinding<Props> {
|
|
15
17
|
kind: "attribute";
|
|
16
18
|
path: readonly number[];
|
|
19
|
+
/** Stable ref target emitted by newer compiler versions. */
|
|
20
|
+
target?: number;
|
|
17
21
|
dependencies: readonly number[];
|
|
18
22
|
name: string;
|
|
19
23
|
read(props: Props, state: readonly CompilerCell[]): unknown;
|
|
20
24
|
}
|
|
21
|
-
|
|
25
|
+
interface CompilerStyleBinding<Props> {
|
|
26
|
+
kind: "style";
|
|
27
|
+
path: readonly number[];
|
|
28
|
+
/** Stable ref target emitted by newer compiler versions. */
|
|
29
|
+
target?: number;
|
|
30
|
+
dependencies: readonly number[];
|
|
31
|
+
name: string;
|
|
32
|
+
read(props: Props, state: readonly CompilerCell[]): unknown;
|
|
33
|
+
}
|
|
34
|
+
interface CompilerConditionalBlockBinding {
|
|
35
|
+
kind: "block";
|
|
36
|
+
id: number;
|
|
37
|
+
/** Nearest conditional boundary that owns this block, when nested. */
|
|
38
|
+
parent?: number;
|
|
39
|
+
dependencies: readonly number[];
|
|
40
|
+
}
|
|
41
|
+
interface CompilerConditionalBlockProps {
|
|
42
|
+
id: number;
|
|
43
|
+
render(): React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
interface CompilerKeyedListBlockProps {
|
|
46
|
+
id: number;
|
|
47
|
+
render(): React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
interface CompilerHostElement {
|
|
50
|
+
kind: "element";
|
|
51
|
+
tag: string;
|
|
52
|
+
attributes: readonly {
|
|
53
|
+
name: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
}[];
|
|
56
|
+
styles: readonly {
|
|
57
|
+
name: string;
|
|
58
|
+
value: unknown;
|
|
59
|
+
}[];
|
|
60
|
+
children: readonly (CompilerHostElement | unknown)[];
|
|
61
|
+
}
|
|
62
|
+
type CompilerKeyedRowElement = CompilerHostElement;
|
|
63
|
+
interface CompilerKeyedRowEvent {
|
|
64
|
+
name: string;
|
|
65
|
+
invoke(item: unknown, index: number, event: React.SyntheticEvent): unknown;
|
|
66
|
+
}
|
|
67
|
+
interface CompilerKeyedRowConditionalBranch {
|
|
68
|
+
bindings: readonly CompilerKeyedRowBinding[];
|
|
69
|
+
}
|
|
70
|
+
interface CompilerKeyedRowConditional {
|
|
71
|
+
id: number;
|
|
72
|
+
/** Host-container path relative to the keyed row root. */
|
|
73
|
+
path: readonly number[];
|
|
74
|
+
test(item: unknown, index: number): unknown;
|
|
75
|
+
logical: boolean;
|
|
76
|
+
truthy?: CompilerKeyedRowConditionalBranch;
|
|
77
|
+
falsy?: CompilerKeyedRowConditionalBranch;
|
|
78
|
+
}
|
|
79
|
+
interface CompilerHostConditionalBinding {
|
|
80
|
+
kind: "text" | "attribute" | "style";
|
|
81
|
+
path: readonly number[];
|
|
82
|
+
name?: string;
|
|
83
|
+
read(): unknown;
|
|
84
|
+
}
|
|
85
|
+
interface CompilerHostConditionalBranch {
|
|
86
|
+
create(): CompilerHostElement;
|
|
87
|
+
bindings: readonly CompilerHostConditionalBinding[];
|
|
88
|
+
}
|
|
89
|
+
interface CompilerHostConditionalBlockProps {
|
|
90
|
+
id: number;
|
|
91
|
+
render(): React.ReactElement;
|
|
92
|
+
test(): unknown;
|
|
93
|
+
/** Logical && can produce a visible number instead of an empty branch. */
|
|
94
|
+
logical?: boolean;
|
|
95
|
+
truthy?: CompilerHostConditionalBranch;
|
|
96
|
+
falsy?: CompilerHostConditionalBranch;
|
|
97
|
+
}
|
|
98
|
+
interface CompilerKeyedRowBinding {
|
|
99
|
+
kind: "text" | "attribute" | "style";
|
|
100
|
+
path: readonly number[];
|
|
101
|
+
name?: string;
|
|
102
|
+
read(item: unknown, index: number): unknown;
|
|
103
|
+
}
|
|
104
|
+
interface CompilerKeyedRowsBlockProps {
|
|
105
|
+
id: number;
|
|
106
|
+
render(event: (item: unknown, index: number, eventId: number) => React.EventHandler<React.SyntheticEvent>, conditional: (item: unknown, index: number, conditionalId: number, render: (item: unknown, index: number) => React.ReactNode) => React.ReactNode): React.ReactElement;
|
|
107
|
+
items(): Iterable<unknown> | null | undefined;
|
|
108
|
+
rowKey(item: unknown, index: number): React.Key;
|
|
109
|
+
create(item: unknown, index: number): CompilerKeyedRowElement;
|
|
110
|
+
bindings: readonly CompilerKeyedRowBinding[];
|
|
111
|
+
events?: readonly CompilerKeyedRowEvent[];
|
|
112
|
+
conditionals?: readonly CompilerKeyedRowConditional[];
|
|
113
|
+
}
|
|
114
|
+
interface CompilerKeyedRange {
|
|
115
|
+
/** Number of static direct host siblings between this range and the previous range. */
|
|
116
|
+
before: number;
|
|
117
|
+
items(): Iterable<unknown> | null | undefined;
|
|
118
|
+
rowKey(item: unknown, index: number): React.Key;
|
|
119
|
+
create(item: unknown, index: number): CompilerKeyedRowElement;
|
|
120
|
+
bindings: readonly CompilerKeyedRowBinding[];
|
|
121
|
+
}
|
|
122
|
+
interface CompilerKeyedRangesBlockProps {
|
|
123
|
+
id: number;
|
|
124
|
+
render(): React.ReactElement;
|
|
125
|
+
rootRef?: React.RefCallback<Element>;
|
|
126
|
+
ranges: readonly CompilerKeyedRange[];
|
|
127
|
+
/** Number of static direct host siblings after the final keyed range. */
|
|
128
|
+
trailing: number;
|
|
129
|
+
}
|
|
130
|
+
interface CompilerComponentBlockProps {
|
|
131
|
+
id: number;
|
|
132
|
+
render(): React.ReactNode;
|
|
133
|
+
}
|
|
134
|
+
interface CompilerBlockRuntime {
|
|
135
|
+
Conditional: React.ComponentType<CompilerConditionalBlockProps>;
|
|
136
|
+
HostConditional: React.ComponentType<CompilerHostConditionalBlockProps>;
|
|
137
|
+
KeyedList: React.ComponentType<CompilerKeyedListBlockProps>;
|
|
138
|
+
KeyedRows: React.ComponentType<CompilerKeyedRowsBlockProps>;
|
|
139
|
+
KeyedRanges: React.ComponentType<CompilerKeyedRangesBlockProps>;
|
|
140
|
+
Component: React.ComponentType<CompilerComponentBlockProps>;
|
|
141
|
+
target(id: number): React.RefCallback<Element>;
|
|
142
|
+
}
|
|
143
|
+
type CompilerBinding<Props> = CompilerTextBinding<Props> | CompilerAttributeBinding<Props> | CompilerStyleBinding<Props> | CompilerConditionalBlockBinding;
|
|
22
144
|
interface CompiledComponentDefinition<Props> {
|
|
23
145
|
displayName: string;
|
|
146
|
+
/** Stable development-only identity used to preserve state across compatible refreshes. */
|
|
147
|
+
hmrId?: string;
|
|
148
|
+
/** Changes when the compiler-owned state layout is no longer refresh-compatible. */
|
|
149
|
+
stateSignature?: string;
|
|
24
150
|
initialize(props: Props): readonly unknown[];
|
|
25
|
-
render(props: Props, state: readonly CompilerCell[]): React.ReactElement;
|
|
151
|
+
render(props: Props, state: readonly CompilerCell[], blocks: CompilerBlockRuntime): React.ReactElement;
|
|
26
152
|
bindings: readonly CompilerBinding<Props>[];
|
|
27
153
|
}
|
|
28
154
|
/**
|
|
29
155
|
* Runtime target emitted by the AOT transform.
|
|
30
156
|
*
|
|
31
|
-
* React owns
|
|
32
|
-
* Compiler cells own local
|
|
157
|
+
* React owns initial placement, SSR, hydration, props, and event semantics.
|
|
158
|
+
* Compiler cells own local updates and precomputed DOM paths. A proven host-only
|
|
159
|
+
* keyed container may transfer its child-row ownership after mount.
|
|
33
160
|
*/
|
|
34
161
|
declare function createCompiledComponent<Props>(definition: CompiledComponentDefinition<Props>): React.ComponentType<Props>;
|
|
35
162
|
|
|
36
|
-
export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerCell, type CompilerStateUpdater, type CompilerTextBinding, createCompiledComponent };
|
|
163
|
+
export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerBlockRuntime, type CompilerCell, type CompilerComponentBlockProps, type CompilerConditionalBlockBinding, type CompilerConditionalBlockProps, type CompilerHostConditionalBinding, type CompilerHostConditionalBlockProps, type CompilerHostConditionalBranch, type CompilerHostElement, type CompilerKeyedListBlockProps, type CompilerKeyedRange, type CompilerKeyedRangesBlockProps, type CompilerKeyedRowBinding, type CompilerKeyedRowConditional, type CompilerKeyedRowConditionalBranch, type CompilerKeyedRowElement, type CompilerKeyedRowEvent, type CompilerKeyedRowsBlockProps, type CompilerStateUpdater, type CompilerStyleBinding, type CompilerTextBinding, createCompiledComponent };
|