@farm.js/react 0.1.0-beta.3 → 0.1.0-beta.4

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.
@@ -1,12 +1,15 @@
1
1
  import React from 'react';
2
2
 
3
3
  type CompilerStateUpdater = unknown | ((previous: unknown) => unknown);
4
+ type CompilerRuntimeReactivity = "static" | "hybrid";
4
5
  interface CompilerCell {
5
6
  get(): unknown;
6
7
  set(next: CompilerStateUpdater): void;
7
8
  }
8
9
  interface CompilerTextBinding<Props> {
9
10
  kind: "text";
11
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
12
+ tracking?: "dynamic";
10
13
  path: readonly number[];
11
14
  /** Stable ref target emitted by newer compiler versions. */
12
15
  target?: number;
@@ -15,6 +18,8 @@ interface CompilerTextBinding<Props> {
15
18
  }
16
19
  interface CompilerAttributeBinding<Props> {
17
20
  kind: "attribute";
21
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
22
+ tracking?: "dynamic";
18
23
  path: readonly number[];
19
24
  /** Stable ref target emitted by newer compiler versions. */
20
25
  target?: number;
@@ -24,6 +29,8 @@ interface CompilerAttributeBinding<Props> {
24
29
  }
25
30
  interface CompilerStyleBinding<Props> {
26
31
  kind: "style";
32
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
33
+ tracking?: "dynamic";
27
34
  path: readonly number[];
28
35
  /** Stable ref target emitted by newer compiler versions. */
29
36
  target?: number;
@@ -58,10 +65,14 @@ interface CompilerHostElement {
58
65
  value: unknown;
59
66
  }[];
60
67
  children: readonly (CompilerHostElement | unknown)[];
68
+ /** Direct-child structure owned without creating another React fiber. */
69
+ block?: CompilerHostBlock;
61
70
  }
62
71
  type CompilerKeyedRowElement = CompilerHostElement;
63
72
  interface CompilerKeyedRowEvent {
64
73
  name: string;
74
+ /** Host-element path relative to the keyed row root. */
75
+ path?: readonly number[];
65
76
  invoke(item: unknown, index: number, event: React.SyntheticEvent): unknown;
66
77
  }
67
78
  interface CompilerKeyedRowConditionalBranch {
@@ -82,10 +93,45 @@ interface CompilerHostConditionalBinding {
82
93
  name?: string;
83
94
  read(): unknown;
84
95
  }
96
+ interface CompilerStaticRangeBinding {
97
+ kind: "text" | "attribute" | "style";
98
+ /** Static segment before range N, or the trailing segment at ranges.length. */
99
+ segment: number;
100
+ /** Direct host sibling inside that static segment. */
101
+ sibling: number;
102
+ /** Host-element path relative to the selected static sibling. */
103
+ path: readonly number[];
104
+ name?: string;
105
+ read(): unknown;
106
+ }
85
107
  interface CompilerHostConditionalBranch {
86
108
  create(): CompilerHostElement;
87
109
  bindings: readonly CompilerHostConditionalBinding[];
88
110
  }
111
+ interface CompilerHostConditionalRanges {
112
+ kind: "conditional-ranges";
113
+ id: number;
114
+ ranges: readonly CompilerConditionalRange[];
115
+ trailing: number;
116
+ bindings?: readonly CompilerStaticRangeBinding[];
117
+ }
118
+ interface CompilerHostKeyedRanges {
119
+ kind: "keyed-ranges";
120
+ id: number;
121
+ ranges: readonly CompilerKeyedRange[];
122
+ trailing: number;
123
+ bindings?: readonly CompilerStaticRangeBinding[];
124
+ /** Compiler output may store only static direct children and materialize rows from the ranges. */
125
+ staticChildrenOnly?: boolean;
126
+ }
127
+ interface CompilerHostMixedRanges {
128
+ kind: "mixed-ranges";
129
+ id: number;
130
+ ranges: readonly CompilerMixedRange[];
131
+ trailing: number;
132
+ bindings?: readonly CompilerStaticRangeBinding[];
133
+ }
134
+ type CompilerHostBlock = CompilerHostConditionalRanges | CompilerHostKeyedRanges | CompilerHostMixedRanges;
89
135
  interface CompilerHostConditionalBlockProps {
90
136
  id: number;
91
137
  render(): React.ReactElement;
@@ -111,22 +157,31 @@ interface CompilerConditionalRangesBlockProps {
111
157
  ranges: readonly CompilerConditionalRange[];
112
158
  /** Number of static direct host siblings after the final conditional slot. */
113
159
  trailing: number;
160
+ bindings?: readonly CompilerStaticRangeBinding[];
114
161
  }
115
162
  interface CompilerKeyedRowBinding {
116
163
  kind: "text" | "attribute" | "style";
117
164
  path: readonly number[];
118
165
  name?: string;
166
+ /** Component state cells read by this binding, when emitted by the compiler. */
167
+ dependencies?: readonly number[];
119
168
  read(item: unknown, index: number): unknown;
120
169
  }
121
170
  interface CompilerKeyedRowsBlockProps {
122
171
  id: number;
123
172
  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;
124
173
  items(): Iterable<unknown> | null | undefined;
174
+ /** State cells that can change the row collection or its key projection. */
175
+ structureDependencies?: readonly number[];
125
176
  rowKey(item: unknown, index: number): React.Key;
126
177
  create(item: unknown, index: number): CompilerKeyedRowElement;
127
178
  bindings: readonly CompilerKeyedRowBinding[];
128
179
  events?: readonly CompilerKeyedRowEvent[];
180
+ /** Route compiler-proven bubbling row events through the stable React container. */
181
+ delegateEvents?: boolean;
129
182
  conditionals?: readonly CompilerKeyedRowConditional[];
183
+ /** Row descriptors contain compiler-owned nested host scopes. */
184
+ hostBlocks?: boolean;
130
185
  }
131
186
  interface CompilerKeyedRange {
132
187
  /** Number of static direct host siblings between this range and the previous range. */
@@ -136,6 +191,17 @@ interface CompilerKeyedRange {
136
191
  create(item: unknown, index: number): CompilerKeyedRowElement;
137
192
  bindings: readonly CompilerKeyedRowBinding[];
138
193
  }
194
+ type CompilerMixedRange = ({
195
+ kind: "conditional";
196
+ } & CompilerConditionalRange) | ({
197
+ kind: "keyed";
198
+ } & CompilerKeyedRange);
199
+ interface CompilerMixedRangesBlockProps {
200
+ id: number;
201
+ render(): React.ReactElement;
202
+ create(): CompilerHostElement;
203
+ rootRef?: React.RefCallback<Element>;
204
+ }
139
205
  interface CompilerKeyedRangesBlockProps {
140
206
  id: number;
141
207
  render(): React.ReactElement;
@@ -143,6 +209,7 @@ interface CompilerKeyedRangesBlockProps {
143
209
  ranges: readonly CompilerKeyedRange[];
144
210
  /** Number of static direct host siblings after the final keyed range. */
145
211
  trailing: number;
212
+ bindings?: readonly CompilerStaticRangeBinding[];
146
213
  }
147
214
  interface CompilerComponentBlockProps {
148
215
  id: number;
@@ -155,17 +222,25 @@ interface CompilerBlockRuntime {
155
222
  KeyedList: React.ComponentType<CompilerKeyedListBlockProps>;
156
223
  KeyedRows: React.ComponentType<CompilerKeyedRowsBlockProps>;
157
224
  KeyedRanges: React.ComponentType<CompilerKeyedRangesBlockProps>;
225
+ MixedRanges: React.ComponentType<CompilerMixedRangesBlockProps>;
158
226
  Component: React.ComponentType<CompilerComponentBlockProps>;
159
227
  target(id: number): React.RefCallback<Element>;
160
228
  }
161
229
  type CompilerBinding<Props> = CompilerTextBinding<Props> | CompilerAttributeBinding<Props> | CompilerStyleBinding<Props> | CompilerConditionalBlockBinding;
162
230
  interface CompiledComponentDefinition<Props> {
163
231
  displayName: string;
232
+ /** Scheduler selected by the compiler. Hand-authored definitions default to `static`. */
233
+ reactivity?: CompilerRuntimeReactivity;
164
234
  /** Stable development-only identity used to preserve state across compatible refreshes. */
165
235
  hmrId?: string;
166
236
  /** Changes when the compiler-owned state layout is no longer refresh-compatible. */
167
237
  stateSignature?: string;
168
238
  initialize(props: Props): readonly unknown[];
239
+ /**
240
+ * Compiler-emitted flat prop reads. Primitive values can share the local
241
+ * dependency graph; identity-bearing values retain normal React rendering.
242
+ */
243
+ readProps?(props: Props): readonly unknown[];
169
244
  render(props: Props, state: readonly CompilerCell[], blocks: CompilerBlockRuntime): React.ReactElement;
170
245
  bindings: readonly CompilerBinding<Props>[];
171
246
  }
@@ -178,4 +253,4 @@ interface CompiledComponentDefinition<Props> {
178
253
  */
179
254
  declare function createCompiledComponent<Props>(definition: CompiledComponentDefinition<Props>): React.ComponentType<Props>;
180
255
 
181
- export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerBlockRuntime, type CompilerCell, type CompilerComponentBlockProps, type CompilerConditionalBlockBinding, type CompilerConditionalBlockProps, type CompilerConditionalRange, type CompilerConditionalRangesBlockProps, 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 };
256
+ export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerBlockRuntime, type CompilerCell, type CompilerComponentBlockProps, type CompilerConditionalBlockBinding, type CompilerConditionalBlockProps, type CompilerConditionalRange, type CompilerConditionalRangesBlockProps, type CompilerHostBlock, type CompilerHostConditionalBinding, type CompilerHostConditionalBlockProps, type CompilerHostConditionalBranch, type CompilerHostConditionalRanges, type CompilerHostElement, type CompilerHostKeyedRanges, type CompilerHostMixedRanges, type CompilerKeyedListBlockProps, type CompilerKeyedRange, type CompilerKeyedRangesBlockProps, type CompilerKeyedRowBinding, type CompilerKeyedRowConditional, type CompilerKeyedRowConditionalBranch, type CompilerKeyedRowElement, type CompilerKeyedRowEvent, type CompilerKeyedRowsBlockProps, type CompilerMixedRange, type CompilerMixedRangesBlockProps, type CompilerRuntimeReactivity, type CompilerStateUpdater, type CompilerStaticRangeBinding, type CompilerStyleBinding, type CompilerTextBinding, createCompiledComponent };
@@ -1,12 +1,15 @@
1
1
  import React from 'react';
2
2
 
3
3
  type CompilerStateUpdater = unknown | ((previous: unknown) => unknown);
4
+ type CompilerRuntimeReactivity = "static" | "hybrid";
4
5
  interface CompilerCell {
5
6
  get(): unknown;
6
7
  set(next: CompilerStateUpdater): void;
7
8
  }
8
9
  interface CompilerTextBinding<Props> {
9
10
  kind: "text";
11
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
12
+ tracking?: "dynamic";
10
13
  path: readonly number[];
11
14
  /** Stable ref target emitted by newer compiler versions. */
12
15
  target?: number;
@@ -15,6 +18,8 @@ interface CompilerTextBinding<Props> {
15
18
  }
16
19
  interface CompilerAttributeBinding<Props> {
17
20
  kind: "attribute";
21
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
22
+ tracking?: "dynamic";
18
23
  path: readonly number[];
19
24
  /** Stable ref target emitted by newer compiler versions. */
20
25
  target?: number;
@@ -24,6 +29,8 @@ interface CompilerAttributeBinding<Props> {
24
29
  }
25
30
  interface CompilerStyleBinding<Props> {
26
31
  kind: "style";
32
+ /** Runtime tracking is useful only for compiler-proven short-circuiting readers. */
33
+ tracking?: "dynamic";
27
34
  path: readonly number[];
28
35
  /** Stable ref target emitted by newer compiler versions. */
29
36
  target?: number;
@@ -58,10 +65,14 @@ interface CompilerHostElement {
58
65
  value: unknown;
59
66
  }[];
60
67
  children: readonly (CompilerHostElement | unknown)[];
68
+ /** Direct-child structure owned without creating another React fiber. */
69
+ block?: CompilerHostBlock;
61
70
  }
62
71
  type CompilerKeyedRowElement = CompilerHostElement;
63
72
  interface CompilerKeyedRowEvent {
64
73
  name: string;
74
+ /** Host-element path relative to the keyed row root. */
75
+ path?: readonly number[];
65
76
  invoke(item: unknown, index: number, event: React.SyntheticEvent): unknown;
66
77
  }
67
78
  interface CompilerKeyedRowConditionalBranch {
@@ -82,10 +93,45 @@ interface CompilerHostConditionalBinding {
82
93
  name?: string;
83
94
  read(): unknown;
84
95
  }
96
+ interface CompilerStaticRangeBinding {
97
+ kind: "text" | "attribute" | "style";
98
+ /** Static segment before range N, or the trailing segment at ranges.length. */
99
+ segment: number;
100
+ /** Direct host sibling inside that static segment. */
101
+ sibling: number;
102
+ /** Host-element path relative to the selected static sibling. */
103
+ path: readonly number[];
104
+ name?: string;
105
+ read(): unknown;
106
+ }
85
107
  interface CompilerHostConditionalBranch {
86
108
  create(): CompilerHostElement;
87
109
  bindings: readonly CompilerHostConditionalBinding[];
88
110
  }
111
+ interface CompilerHostConditionalRanges {
112
+ kind: "conditional-ranges";
113
+ id: number;
114
+ ranges: readonly CompilerConditionalRange[];
115
+ trailing: number;
116
+ bindings?: readonly CompilerStaticRangeBinding[];
117
+ }
118
+ interface CompilerHostKeyedRanges {
119
+ kind: "keyed-ranges";
120
+ id: number;
121
+ ranges: readonly CompilerKeyedRange[];
122
+ trailing: number;
123
+ bindings?: readonly CompilerStaticRangeBinding[];
124
+ /** Compiler output may store only static direct children and materialize rows from the ranges. */
125
+ staticChildrenOnly?: boolean;
126
+ }
127
+ interface CompilerHostMixedRanges {
128
+ kind: "mixed-ranges";
129
+ id: number;
130
+ ranges: readonly CompilerMixedRange[];
131
+ trailing: number;
132
+ bindings?: readonly CompilerStaticRangeBinding[];
133
+ }
134
+ type CompilerHostBlock = CompilerHostConditionalRanges | CompilerHostKeyedRanges | CompilerHostMixedRanges;
89
135
  interface CompilerHostConditionalBlockProps {
90
136
  id: number;
91
137
  render(): React.ReactElement;
@@ -111,22 +157,31 @@ interface CompilerConditionalRangesBlockProps {
111
157
  ranges: readonly CompilerConditionalRange[];
112
158
  /** Number of static direct host siblings after the final conditional slot. */
113
159
  trailing: number;
160
+ bindings?: readonly CompilerStaticRangeBinding[];
114
161
  }
115
162
  interface CompilerKeyedRowBinding {
116
163
  kind: "text" | "attribute" | "style";
117
164
  path: readonly number[];
118
165
  name?: string;
166
+ /** Component state cells read by this binding, when emitted by the compiler. */
167
+ dependencies?: readonly number[];
119
168
  read(item: unknown, index: number): unknown;
120
169
  }
121
170
  interface CompilerKeyedRowsBlockProps {
122
171
  id: number;
123
172
  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;
124
173
  items(): Iterable<unknown> | null | undefined;
174
+ /** State cells that can change the row collection or its key projection. */
175
+ structureDependencies?: readonly number[];
125
176
  rowKey(item: unknown, index: number): React.Key;
126
177
  create(item: unknown, index: number): CompilerKeyedRowElement;
127
178
  bindings: readonly CompilerKeyedRowBinding[];
128
179
  events?: readonly CompilerKeyedRowEvent[];
180
+ /** Route compiler-proven bubbling row events through the stable React container. */
181
+ delegateEvents?: boolean;
129
182
  conditionals?: readonly CompilerKeyedRowConditional[];
183
+ /** Row descriptors contain compiler-owned nested host scopes. */
184
+ hostBlocks?: boolean;
130
185
  }
131
186
  interface CompilerKeyedRange {
132
187
  /** Number of static direct host siblings between this range and the previous range. */
@@ -136,6 +191,17 @@ interface CompilerKeyedRange {
136
191
  create(item: unknown, index: number): CompilerKeyedRowElement;
137
192
  bindings: readonly CompilerKeyedRowBinding[];
138
193
  }
194
+ type CompilerMixedRange = ({
195
+ kind: "conditional";
196
+ } & CompilerConditionalRange) | ({
197
+ kind: "keyed";
198
+ } & CompilerKeyedRange);
199
+ interface CompilerMixedRangesBlockProps {
200
+ id: number;
201
+ render(): React.ReactElement;
202
+ create(): CompilerHostElement;
203
+ rootRef?: React.RefCallback<Element>;
204
+ }
139
205
  interface CompilerKeyedRangesBlockProps {
140
206
  id: number;
141
207
  render(): React.ReactElement;
@@ -143,6 +209,7 @@ interface CompilerKeyedRangesBlockProps {
143
209
  ranges: readonly CompilerKeyedRange[];
144
210
  /** Number of static direct host siblings after the final keyed range. */
145
211
  trailing: number;
212
+ bindings?: readonly CompilerStaticRangeBinding[];
146
213
  }
147
214
  interface CompilerComponentBlockProps {
148
215
  id: number;
@@ -155,17 +222,25 @@ interface CompilerBlockRuntime {
155
222
  KeyedList: React.ComponentType<CompilerKeyedListBlockProps>;
156
223
  KeyedRows: React.ComponentType<CompilerKeyedRowsBlockProps>;
157
224
  KeyedRanges: React.ComponentType<CompilerKeyedRangesBlockProps>;
225
+ MixedRanges: React.ComponentType<CompilerMixedRangesBlockProps>;
158
226
  Component: React.ComponentType<CompilerComponentBlockProps>;
159
227
  target(id: number): React.RefCallback<Element>;
160
228
  }
161
229
  type CompilerBinding<Props> = CompilerTextBinding<Props> | CompilerAttributeBinding<Props> | CompilerStyleBinding<Props> | CompilerConditionalBlockBinding;
162
230
  interface CompiledComponentDefinition<Props> {
163
231
  displayName: string;
232
+ /** Scheduler selected by the compiler. Hand-authored definitions default to `static`. */
233
+ reactivity?: CompilerRuntimeReactivity;
164
234
  /** Stable development-only identity used to preserve state across compatible refreshes. */
165
235
  hmrId?: string;
166
236
  /** Changes when the compiler-owned state layout is no longer refresh-compatible. */
167
237
  stateSignature?: string;
168
238
  initialize(props: Props): readonly unknown[];
239
+ /**
240
+ * Compiler-emitted flat prop reads. Primitive values can share the local
241
+ * dependency graph; identity-bearing values retain normal React rendering.
242
+ */
243
+ readProps?(props: Props): readonly unknown[];
169
244
  render(props: Props, state: readonly CompilerCell[], blocks: CompilerBlockRuntime): React.ReactElement;
170
245
  bindings: readonly CompilerBinding<Props>[];
171
246
  }
@@ -178,4 +253,4 @@ interface CompiledComponentDefinition<Props> {
178
253
  */
179
254
  declare function createCompiledComponent<Props>(definition: CompiledComponentDefinition<Props>): React.ComponentType<Props>;
180
255
 
181
- export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerBlockRuntime, type CompilerCell, type CompilerComponentBlockProps, type CompilerConditionalBlockBinding, type CompilerConditionalBlockProps, type CompilerConditionalRange, type CompilerConditionalRangesBlockProps, 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 };
256
+ export { type CompiledComponentDefinition, type CompilerAttributeBinding, type CompilerBinding, type CompilerBlockRuntime, type CompilerCell, type CompilerComponentBlockProps, type CompilerConditionalBlockBinding, type CompilerConditionalBlockProps, type CompilerConditionalRange, type CompilerConditionalRangesBlockProps, type CompilerHostBlock, type CompilerHostConditionalBinding, type CompilerHostConditionalBlockProps, type CompilerHostConditionalBranch, type CompilerHostConditionalRanges, type CompilerHostElement, type CompilerHostKeyedRanges, type CompilerHostMixedRanges, type CompilerKeyedListBlockProps, type CompilerKeyedRange, type CompilerKeyedRangesBlockProps, type CompilerKeyedRowBinding, type CompilerKeyedRowConditional, type CompilerKeyedRowConditionalBranch, type CompilerKeyedRowElement, type CompilerKeyedRowEvent, type CompilerKeyedRowsBlockProps, type CompilerMixedRange, type CompilerMixedRangesBlockProps, type CompilerRuntimeReactivity, type CompilerStateUpdater, type CompilerStaticRangeBinding, type CompilerStyleBinding, type CompilerTextBinding, createCompiledComponent };