solid-js 1.3.17 → 1.4.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/dist/dev.cjs +31 -27
- package/dist/dev.js +31 -27
- package/dist/server.cjs +8 -5
- package/dist/server.js +9 -5
- package/dist/solid.cjs +31 -27
- package/dist/solid.js +31 -27
- package/package.json +2 -2
- package/store/dist/dev.cjs +38 -28
- package/store/dist/dev.js +39 -30
- package/store/dist/store.cjs +38 -28
- package/store/dist/store.js +39 -30
- package/store/types/mutable.d.ts +1 -0
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +19 -5
- package/types/reactive/signal.d.ts +14 -13
- package/types/render/component.d.ts +62 -14
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -1
- package/types/server/rendering.d.ts +27 -13
- package/web/dist/dev.cjs +5 -1
- package/web/dist/dev.js +5 -2
- package/web/dist/server.cjs +83 -48
- package/web/dist/server.js +83 -48
- package/web/dist/web.cjs +5 -1
- package/web/dist/web.js +5 -2
- package/web/types/client.d.ts +1 -0
package/store/dist/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $PROXY, getListener, batch, createSignal } from 'solid-js';
|
|
1
|
+
import { $PROXY, $TRACK, getListener, batch, createSignal } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
4
|
$NODE = Symbol("store-node"),
|
|
@@ -64,11 +64,14 @@ function proxyDescriptor(target, property) {
|
|
|
64
64
|
desc.get = () => target[$PROXY][property];
|
|
65
65
|
return desc;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function trackSelf(target) {
|
|
68
68
|
if (getListener()) {
|
|
69
69
|
const nodes = getDataNodes(target);
|
|
70
70
|
(nodes._ || (nodes._ = createDataNode()))();
|
|
71
71
|
}
|
|
72
|
+
}
|
|
73
|
+
function ownKeys(target) {
|
|
74
|
+
trackSelf(target);
|
|
72
75
|
return Reflect.ownKeys(target);
|
|
73
76
|
}
|
|
74
77
|
function createDataNode() {
|
|
@@ -85,18 +88,12 @@ const proxyTraps$1 = {
|
|
|
85
88
|
if (property === $PROXY) return receiver;
|
|
86
89
|
const value = target[property];
|
|
87
90
|
if (property === $NODE || property === "__proto__") return value;
|
|
88
|
-
|
|
91
|
+
if (property === $TRACK) return trackSelf(target);
|
|
89
92
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
node = nodes._ || (nodes._ = createDataNode());
|
|
93
|
-
node();
|
|
94
|
-
}
|
|
95
|
-
nodes = getDataNodes(target);
|
|
96
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
97
|
-
node();
|
|
93
|
+
const nodes = getDataNodes(target);
|
|
94
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
98
95
|
}
|
|
99
|
-
return
|
|
96
|
+
return isWrappable(value) ? wrap$1(value) : value;
|
|
100
97
|
},
|
|
101
98
|
set() {
|
|
102
99
|
return true;
|
|
@@ -111,16 +108,14 @@ function setProperty(state, property, value) {
|
|
|
111
108
|
if (state[property] === value) return;
|
|
112
109
|
const array = Array.isArray(state);
|
|
113
110
|
const len = state.length;
|
|
114
|
-
|
|
115
|
-
const notify = array || isUndefined === property in state;
|
|
116
|
-
if (isUndefined) {
|
|
111
|
+
if (value === undefined) {
|
|
117
112
|
delete state[property];
|
|
118
113
|
} else state[property] = value;
|
|
119
114
|
let nodes = getDataNodes(state),
|
|
120
115
|
node;
|
|
121
116
|
(node = nodes[property]) && node.$();
|
|
122
117
|
if (array && state.length !== len) (node = nodes.length) && node.$();
|
|
123
|
-
|
|
118
|
+
(node = nodes._) && node.$();
|
|
124
119
|
}
|
|
125
120
|
function mergeStoreNode(state, value) {
|
|
126
121
|
const keys = Object.keys(value);
|
|
@@ -129,6 +124,18 @@ function mergeStoreNode(state, value) {
|
|
|
129
124
|
setProperty(state, key, value[key]);
|
|
130
125
|
}
|
|
131
126
|
}
|
|
127
|
+
function updateArray(current, next) {
|
|
128
|
+
if (typeof next === "function") next = next(current);
|
|
129
|
+
next = unwrap(next);
|
|
130
|
+
if (current === next) return;
|
|
131
|
+
let i = 0,
|
|
132
|
+
len = next.length;
|
|
133
|
+
for (; i < len; i++) {
|
|
134
|
+
const value = next[i];
|
|
135
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
136
|
+
}
|
|
137
|
+
setProperty(current, "length", len);
|
|
138
|
+
}
|
|
132
139
|
function updatePath(current, path, traversed = []) {
|
|
133
140
|
let part,
|
|
134
141
|
prev = current;
|
|
@@ -176,9 +183,12 @@ function updatePath(current, path, traversed = []) {
|
|
|
176
183
|
}
|
|
177
184
|
function createStore(store, options) {
|
|
178
185
|
const unwrappedStore = unwrap(store || {});
|
|
186
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
179
187
|
const wrappedStore = wrap$1(unwrappedStore);
|
|
180
188
|
function setStore(...args) {
|
|
181
|
-
batch(() =>
|
|
189
|
+
batch(() => {
|
|
190
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
|
|
191
|
+
});
|
|
182
192
|
}
|
|
183
193
|
return [wrappedStore, setStore];
|
|
184
194
|
}
|
|
@@ -189,18 +199,14 @@ const proxyTraps = {
|
|
|
189
199
|
if (property === $PROXY) return receiver;
|
|
190
200
|
const value = target[property];
|
|
191
201
|
if (property === $NODE || property === "__proto__") return value;
|
|
192
|
-
|
|
202
|
+
if (property === $TRACK) return trackSelf(target);
|
|
193
203
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
nodes = getDataNodes(target);
|
|
200
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
201
|
-
node();
|
|
204
|
+
const nodes = getDataNodes(target);
|
|
205
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
206
|
+
} else if (value != null && typeof value === "function" && value === Array.prototype[property]) {
|
|
207
|
+
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
202
208
|
}
|
|
203
|
-
return
|
|
209
|
+
return isWrappable(value) ? wrap(value) : value;
|
|
204
210
|
},
|
|
205
211
|
set(target, property, value) {
|
|
206
212
|
setProperty(target, property, unwrap(value));
|
|
@@ -245,6 +251,9 @@ function createMutable(state, options) {
|
|
|
245
251
|
const wrappedStore = wrap(unwrappedStore);
|
|
246
252
|
return wrappedStore;
|
|
247
253
|
}
|
|
254
|
+
function modifyMutable(state, modifier) {
|
|
255
|
+
batch(() => modifier(unwrap(state)));
|
|
256
|
+
}
|
|
248
257
|
|
|
249
258
|
function applyState(target, parent, property, merge, key) {
|
|
250
259
|
const previous = parent[property];
|
|
@@ -322,9 +331,9 @@ function reconcile(value, options = {}) {
|
|
|
322
331
|
v = unwrap(value);
|
|
323
332
|
return state => {
|
|
324
333
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
325
|
-
applyState(v, {
|
|
334
|
+
batch(() => applyState(v, {
|
|
326
335
|
state
|
|
327
|
-
}, "state", merge, key);
|
|
336
|
+
}, "state", merge, key));
|
|
328
337
|
return state;
|
|
329
338
|
};
|
|
330
339
|
}
|
|
@@ -350,4 +359,4 @@ function produce(fn) {
|
|
|
350
359
|
};
|
|
351
360
|
}
|
|
352
361
|
|
|
353
|
-
export { $RAW, createMutable, createStore, produce, reconcile, unwrap };
|
|
362
|
+
export { $RAW, createMutable, createStore, modifyMutable, produce, reconcile, unwrap };
|
package/store/types/mutable.d.ts
CHANGED
package/store/types/store.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function isWrappable(obj: any): any;
|
|
|
11
11
|
export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
|
|
12
12
|
export declare function getDataNodes(target: StoreNode): any;
|
|
13
13
|
export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
|
|
14
|
+
export declare function trackSelf(target: StoreNode): void;
|
|
14
15
|
export declare function ownKeys(target: StoreNode): (string | symbol)[];
|
|
15
16
|
export declare function createDataNode(): Accessor<void> & {
|
|
16
17
|
$: () => void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition,
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY, $TRACK } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Signal, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
package/types/jsx.d.ts
CHANGED
|
@@ -58,7 +58,11 @@ export namespace JSX {
|
|
|
58
58
|
};
|
|
59
59
|
$ServerOnly?: boolean;
|
|
60
60
|
}
|
|
61
|
+
type Accessor<T> = () => T
|
|
61
62
|
interface Directives {}
|
|
63
|
+
interface DirectiveFunctions {
|
|
64
|
+
[x: string]: (el: Element, accessor: Accessor<any>) => void;
|
|
65
|
+
}
|
|
62
66
|
interface ExplicitProperties {}
|
|
63
67
|
interface ExplicitAttributes {}
|
|
64
68
|
interface CustomEvents {}
|
|
@@ -66,6 +70,20 @@ export namespace JSX {
|
|
|
66
70
|
type DirectiveAttributes = {
|
|
67
71
|
[Key in keyof Directives as `use:${Key}`]?: Directives[Key];
|
|
68
72
|
};
|
|
73
|
+
type DirectiveFunctionAttributes<T> = {
|
|
74
|
+
[K in keyof DirectiveFunctions as string extends K ? never : `use:${K}`]?: DirectiveFunctions[K] extends (
|
|
75
|
+
el: infer E, // will be unknown if not provided
|
|
76
|
+
...rest: infer R // use rest so that we can check whether it's provided or not
|
|
77
|
+
) => void
|
|
78
|
+
? T extends E // everything extends unknown if E is unknown
|
|
79
|
+
? R extends [infer A] // check if has accessor provided
|
|
80
|
+
? A extends Accessor<infer V>
|
|
81
|
+
? V // it's an accessor
|
|
82
|
+
: never // it isn't, type error
|
|
83
|
+
: true // no accessor provided
|
|
84
|
+
: never // T is the wrong element
|
|
85
|
+
: never; // it isn't a function
|
|
86
|
+
};
|
|
69
87
|
type PropAttributes = {
|
|
70
88
|
[Key in keyof ExplicitProperties as `prop:${Key}`]?: ExplicitProperties[Key];
|
|
71
89
|
};
|
|
@@ -78,7 +96,7 @@ export namespace JSX {
|
|
|
78
96
|
type OnCaptureAttributes<T> = {
|
|
79
97
|
[Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<T, CustomCaptureEvents[Key]>;
|
|
80
98
|
}
|
|
81
|
-
interface DOMAttributes<T> extends CustomAttributes<T>, DirectiveAttributes, PropAttributes, AttrAttributes, OnAttributes<T>, OnCaptureAttributes<T> {
|
|
99
|
+
interface DOMAttributes<T> extends CustomAttributes<T>, DirectiveAttributes, DirectiveFunctionAttributes<T>, PropAttributes, AttrAttributes, OnAttributes<T>, OnCaptureAttributes<T> {
|
|
82
100
|
children?: Element;
|
|
83
101
|
innerHTML?: string;
|
|
84
102
|
innerText?: string | number;
|
|
@@ -1905,7 +1923,6 @@ export namespace JSX {
|
|
|
1905
1923
|
|
|
1906
1924
|
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
|
1907
1925
|
accessKey?: string;
|
|
1908
|
-
className?: string;
|
|
1909
1926
|
class?: string;
|
|
1910
1927
|
contenteditable?: boolean | "inherit";
|
|
1911
1928
|
contextmenu?: string;
|
|
@@ -2206,7 +2223,6 @@ export namespace JSX {
|
|
|
2206
2223
|
name?: string;
|
|
2207
2224
|
}
|
|
2208
2225
|
interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
2209
|
-
htmlFor?: string;
|
|
2210
2226
|
for?: string;
|
|
2211
2227
|
form?: string;
|
|
2212
2228
|
}
|
|
@@ -2293,7 +2309,6 @@ export namespace JSX {
|
|
|
2293
2309
|
}
|
|
2294
2310
|
interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
2295
2311
|
form?: string;
|
|
2296
|
-
htmlFor?: string;
|
|
2297
2312
|
for?: string;
|
|
2298
2313
|
name?: string;
|
|
2299
2314
|
}
|
|
@@ -2467,7 +2482,6 @@ export namespace JSX {
|
|
|
2467
2482
|
}
|
|
2468
2483
|
interface StylableSVGAttributes {
|
|
2469
2484
|
class?: string;
|
|
2470
|
-
className?: string;
|
|
2471
2485
|
style?: CSSProperties | string;
|
|
2472
2486
|
}
|
|
2473
2487
|
interface TransformableSVGAttributes {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { requestCallback } from "./scheduler";
|
|
2
2
|
import type { JSX } from "../jsx";
|
|
3
|
+
import type { FlowComponent } from "../render";
|
|
3
4
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
4
5
|
export declare const $PROXY: unique symbol;
|
|
6
|
+
export declare const $TRACK: unique symbol;
|
|
5
7
|
export declare const $DEVCOMP: unique symbol;
|
|
6
8
|
export declare const NOTPENDING: {};
|
|
7
9
|
export declare var Owner: Owner | null;
|
|
@@ -70,7 +72,7 @@ export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
|
70
72
|
*/
|
|
71
73
|
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
|
|
72
74
|
export declare type Accessor<T> = () => T;
|
|
73
|
-
export declare type Setter<T> = (undefined extends T ? (
|
|
75
|
+
export declare type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
|
|
74
76
|
export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
75
77
|
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
76
78
|
internal?: boolean;
|
|
@@ -122,8 +124,8 @@ export declare type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) =
|
|
|
122
124
|
*
|
|
123
125
|
* @description https://www.solidjs.com/docs/latest/api#createcomputed
|
|
124
126
|
*/
|
|
127
|
+
export declare function createComputed<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
|
|
125
128
|
export declare function createComputed<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
126
|
-
export declare function createComputed<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
127
129
|
/**
|
|
128
130
|
* Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
|
|
129
131
|
* ```typescript
|
|
@@ -139,8 +141,8 @@ export declare function createComputed<Next, Init = undefined>(..._: undefined e
|
|
|
139
141
|
*
|
|
140
142
|
* @description https://www.solidjs.com/docs/latest/api#createrendereffect
|
|
141
143
|
*/
|
|
144
|
+
export declare function createRenderEffect<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
|
|
142
145
|
export declare function createRenderEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
143
|
-
export declare function createRenderEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
144
146
|
/**
|
|
145
147
|
* Creates a reactive computation that runs after the render phase
|
|
146
148
|
* ```typescript
|
|
@@ -156,8 +158,8 @@ export declare function createRenderEffect<Next, Init = undefined>(..._: undefin
|
|
|
156
158
|
*
|
|
157
159
|
* @description https://www.solidjs.com/docs/latest/api#createeffect
|
|
158
160
|
*/
|
|
161
|
+
export declare function createEffect<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
|
|
159
162
|
export declare function createEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
160
|
-
export declare function createEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
161
163
|
/**
|
|
162
164
|
* Creates a reactive computation that runs after the render phase with flexible tracking
|
|
163
165
|
* ```typescript
|
|
@@ -193,11 +195,12 @@ export interface MemoOptions<T> extends EffectOptions {
|
|
|
193
195
|
*
|
|
194
196
|
* @description https://www.solidjs.com/docs/latest/api#creatememo
|
|
195
197
|
*/
|
|
196
|
-
export declare function createMemo<Next extends
|
|
197
|
-
export declare function createMemo<Next extends
|
|
198
|
+
export declare function createMemo<Next extends Prev, Prev = Next>(fn: EffectFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
|
|
199
|
+
export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(fn: EffectFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
|
|
198
200
|
export interface Resource<T> extends Accessor<T> {
|
|
199
201
|
loading: boolean;
|
|
200
202
|
error: any;
|
|
203
|
+
latest: T | undefined;
|
|
201
204
|
}
|
|
202
205
|
export declare type ResourceActions<T> = {
|
|
203
206
|
mutate: Setter<T>;
|
|
@@ -213,12 +216,12 @@ export declare type ResourceFetcherInfo<T> = {
|
|
|
213
216
|
export declare type ResourceOptions<T> = undefined extends T ? {
|
|
214
217
|
initialValue?: T;
|
|
215
218
|
name?: string;
|
|
216
|
-
|
|
219
|
+
deferStream?: boolean;
|
|
217
220
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
218
221
|
} : {
|
|
219
222
|
initialValue: T;
|
|
220
223
|
name?: string;
|
|
221
|
-
|
|
224
|
+
deferStream?: boolean;
|
|
222
225
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
223
226
|
};
|
|
224
227
|
/**
|
|
@@ -250,7 +253,6 @@ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S,
|
|
|
250
253
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
251
254
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
252
255
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
253
|
-
export declare function refetchResources(info?: unknown): Promise<any[]>;
|
|
254
256
|
export interface DeferredOptions<T> {
|
|
255
257
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
256
258
|
name?: string;
|
|
@@ -402,10 +404,9 @@ interface GraphRecord {
|
|
|
402
404
|
[k: string]: GraphRecord | unknown;
|
|
403
405
|
}
|
|
404
406
|
export declare function serializeGraph(owner?: Owner | null): GraphRecord;
|
|
405
|
-
export declare type ContextProviderComponent<T> =
|
|
407
|
+
export declare type ContextProviderComponent<T> = FlowComponent<{
|
|
406
408
|
value: T;
|
|
407
|
-
|
|
408
|
-
}) => any;
|
|
409
|
+
}>;
|
|
409
410
|
export interface Context<T> {
|
|
410
411
|
id: symbol;
|
|
411
412
|
Provider: ContextProviderComponent<T>;
|
|
@@ -416,7 +417,7 @@ export interface Context<T> {
|
|
|
416
417
|
* ```typescript
|
|
417
418
|
* interface Context<T> {
|
|
418
419
|
* id: symbol;
|
|
419
|
-
* Provider:
|
|
420
|
+
* Provider: FlowComponent<{ value: T }>;
|
|
420
421
|
* defaultValue: T;
|
|
421
422
|
* }
|
|
422
423
|
* export function createContext<T>(defaultValue?: T): Context<T | undefined>;
|
|
@@ -1,9 +1,56 @@
|
|
|
1
1
|
import type { JSX } from "../jsx";
|
|
2
2
|
export declare function enableHydration(): void;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A general `Component` has no implicit `children` prop. If desired, you can
|
|
5
|
+
* specify one as in `Component<{name: String, children: JSX.Element>}`.
|
|
6
|
+
*/
|
|
7
|
+
export declare type Component<P = {}> = (props: P) => JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Extend props to forbid the `children` prop.
|
|
10
|
+
* Use this to prevent accidentally passing `children` to components that
|
|
11
|
+
* would silently throw them away.
|
|
12
|
+
*/
|
|
13
|
+
export declare type VoidProps<P = {}> = P & {
|
|
14
|
+
children?: never;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* `VoidComponent` forbids the `children` prop.
|
|
18
|
+
* Use this to prevent accidentally passing `children` to components that
|
|
19
|
+
* would silently throw them away.
|
|
20
|
+
*/
|
|
21
|
+
export declare type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
22
|
+
/**
|
|
23
|
+
* Extend props to allow an optional `children` prop with the usual
|
|
24
|
+
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
25
|
+
* Use this for components that you want to accept children.
|
|
26
|
+
*/
|
|
27
|
+
export declare type ParentProps<P = {}> = P & {
|
|
4
28
|
children?: JSX.Element;
|
|
5
29
|
};
|
|
6
|
-
|
|
30
|
+
/**
|
|
31
|
+
* `ParentComponent` allows an optional `children` prop with the usual
|
|
32
|
+
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
33
|
+
* Use this for components that you want to accept children.
|
|
34
|
+
*/
|
|
35
|
+
export declare type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
36
|
+
/**
|
|
37
|
+
* Extend props to require a `children` prop with the specified type.
|
|
38
|
+
* Use this for components where you need a specific child type,
|
|
39
|
+
* typically a function that receives specific argument types.
|
|
40
|
+
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
41
|
+
*/
|
|
42
|
+
export declare type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
43
|
+
children: C;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `FlowComponent` requires a `children` prop with the specified type.
|
|
47
|
+
* Use this for components where you need a specific child type,
|
|
48
|
+
* typically a function that receives specific argument types.
|
|
49
|
+
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
50
|
+
*/
|
|
51
|
+
export declare type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
52
|
+
/** @deprecated: use `ParentProps` instead */
|
|
53
|
+
export declare type PropsWithChildren<P = {}> = ParentProps<P>;
|
|
7
54
|
/**
|
|
8
55
|
* Takes the props of the passed component and returns its type
|
|
9
56
|
*
|
|
@@ -12,7 +59,13 @@ export declare type Component<P = {}> = (props: PropsWithChildren<P>) => JSX.Ele
|
|
|
12
59
|
* ComponentProps<'div'> // JSX.HTMLAttributes<HTMLDivElement>
|
|
13
60
|
*/
|
|
14
61
|
export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Component<any>> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {};
|
|
15
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Type of `props.ref`, for use in `Component` or `props` typing.
|
|
64
|
+
*
|
|
65
|
+
* @example Component<{ref: Ref<Element>}>
|
|
66
|
+
*/
|
|
67
|
+
export declare type Ref<T> = T | ((val: T) => void);
|
|
68
|
+
export declare function createComponent<T>(Comp: Component<T>, props: T): JSX.Element;
|
|
16
69
|
declare type UnboxLazy<T> = T extends () => infer U ? U : T;
|
|
17
70
|
declare type BoxedTupleTypes<T extends any[]> = {
|
|
18
71
|
[P in keyof T]: [UnboxLazy<T[P]>];
|
|
@@ -23,18 +76,13 @@ declare type UnboxIntersection<T> = T extends {
|
|
|
23
76
|
} ? U : never;
|
|
24
77
|
declare type MergeProps<T extends any[]> = UnboxIntersection<UnionToIntersection<BoxedTupleTypes<T>>>;
|
|
25
78
|
export declare function mergeProps<T extends any[]>(...sources: T): MergeProps<T>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Pick<T, K1>,
|
|
32
|
-
Pick<T, K2>,
|
|
33
|
-
Pick<T, K3>,
|
|
34
|
-
Pick<T, K4>,
|
|
35
|
-
Pick<T, K5>,
|
|
36
|
-
Omit<T, K1 | K2 | K3 | K4 | K5>
|
|
79
|
+
declare type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
80
|
+
...{
|
|
81
|
+
[P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : K[P];
|
|
82
|
+
},
|
|
83
|
+
Omit<T, K[number][number]>
|
|
37
84
|
];
|
|
85
|
+
export declare function splitProps<T, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]]>(props: T, ...keys: K): SplitProps<T, K>;
|
|
38
86
|
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
39
87
|
default: T;
|
|
40
88
|
}>): T & {
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createReaction, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, $DEVCOMP, DEV, enableExternalSource } from "./reactive";
|
|
2
|
-
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource,
|
|
2
|
+
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, resetErrorBoundaries, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
3
3
|
export type { Component, Resource } from "./rendering";
|
|
@@ -42,7 +42,7 @@ export declare function createContext<T>(defaultValue?: T): Context<T>;
|
|
|
42
42
|
export declare function useContext<T>(context: Context<T>): T;
|
|
43
43
|
export declare function getOwner(): Owner | null;
|
|
44
44
|
export declare function children(fn: () => any): () => unknown;
|
|
45
|
-
export declare function runWithOwner(o: Owner, fn: () =>
|
|
45
|
+
export declare function runWithOwner<T>(o: Owner, fn: () => T): T;
|
|
46
46
|
export declare function lookup(owner: Owner | null, key: symbol | string): any;
|
|
47
47
|
export interface Task {
|
|
48
48
|
id: number;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Setter } from "./reactive";
|
|
2
2
|
import type { JSX } from "../jsx";
|
|
3
|
-
declare type
|
|
3
|
+
export declare type Component<P = {}> = (props: P) => JSX.Element;
|
|
4
|
+
export declare type VoidProps<P = {}> = P & {
|
|
5
|
+
children?: never;
|
|
6
|
+
};
|
|
7
|
+
export declare type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
8
|
+
export declare type ParentProps<P = {}> = P & {
|
|
4
9
|
children?: JSX.Element;
|
|
5
10
|
};
|
|
6
|
-
export declare type
|
|
7
|
-
declare type
|
|
8
|
-
|
|
11
|
+
export declare type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
12
|
+
export declare type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
13
|
+
children: C;
|
|
9
14
|
};
|
|
15
|
+
export declare type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
16
|
+
export declare type Ref<T> = T | ((val: T) => void);
|
|
17
|
+
export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Component> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {};
|
|
10
18
|
declare type SharedConfig = {
|
|
11
19
|
context?: HydrationContext;
|
|
12
20
|
};
|
|
13
21
|
export declare const sharedConfig: SharedConfig;
|
|
14
22
|
export declare function createUniqueId(): string;
|
|
15
|
-
export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props:
|
|
23
|
+
export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
16
24
|
export declare function mergeProps<T, U>(source: T, source1: U): T & U;
|
|
17
25
|
export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
|
|
18
26
|
export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
@@ -61,6 +69,7 @@ export interface Resource<T> {
|
|
|
61
69
|
(): T | undefined;
|
|
62
70
|
loading: boolean;
|
|
63
71
|
error: any;
|
|
72
|
+
latest: T | undefined;
|
|
64
73
|
}
|
|
65
74
|
declare type SuspenseContextType = {
|
|
66
75
|
resources: Map<string, {
|
|
@@ -83,22 +92,25 @@ export declare type ResourceFetcherInfo<T> = {
|
|
|
83
92
|
export declare type ResourceOptions<T> = undefined extends T ? {
|
|
84
93
|
initialValue?: T;
|
|
85
94
|
name?: string;
|
|
86
|
-
|
|
95
|
+
deferStream?: boolean;
|
|
87
96
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
88
97
|
} : {
|
|
89
98
|
initialValue: T;
|
|
90
99
|
name?: string;
|
|
91
|
-
|
|
100
|
+
deferStream?: boolean;
|
|
92
101
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
93
102
|
};
|
|
94
103
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
95
104
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
96
105
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
97
106
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
98
|
-
export declare function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
108
|
+
default: T;
|
|
109
|
+
}>): T & {
|
|
110
|
+
preload: () => Promise<{
|
|
111
|
+
default: T;
|
|
112
|
+
}>;
|
|
113
|
+
};
|
|
102
114
|
export declare function enableScheduling(): void;
|
|
103
115
|
export declare function enableHydration(): void;
|
|
104
116
|
export declare function startTransition(fn: () => any): void;
|
|
@@ -106,7 +118,7 @@ export declare function useTransition(): [() => boolean, (fn: () => any) => void
|
|
|
106
118
|
declare type HydrationContext = {
|
|
107
119
|
id: string;
|
|
108
120
|
count: number;
|
|
109
|
-
writeResource?: (id: string, v: Promise<any> | any, error?: boolean) => void;
|
|
121
|
+
writeResource?: (id: string, v: Promise<any> | any, error?: boolean, deferStream?: boolean) => void;
|
|
110
122
|
resources: Record<string, any>;
|
|
111
123
|
suspense: Record<string, SuspenseContextType>;
|
|
112
124
|
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
@@ -122,5 +134,7 @@ export declare function SuspenseList(props: {
|
|
|
122
134
|
export declare function Suspense(props: {
|
|
123
135
|
fallback?: string;
|
|
124
136
|
children: string;
|
|
125
|
-
}):
|
|
137
|
+
}): string | number | boolean | Node | JSX.ArrayElement | JSX.FunctionElement | {
|
|
138
|
+
t: string;
|
|
139
|
+
} | null | undefined;
|
|
126
140
|
export {};
|
package/web/dist/dev.cjs
CHANGED
|
@@ -136,6 +136,9 @@ function setAttribute(node, name, value) {
|
|
|
136
136
|
function setAttributeNS(node, namespace, name, value) {
|
|
137
137
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
138
138
|
}
|
|
139
|
+
function className(node, value) {
|
|
140
|
+
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
141
|
+
}
|
|
139
142
|
function addEventListener(node, name, handler, delegate) {
|
|
140
143
|
if (delegate) {
|
|
141
144
|
if (Array.isArray(handler)) {
|
|
@@ -316,7 +319,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
316
319
|
addEventListener(node, name, value, delegate);
|
|
317
320
|
delegate && delegateEvents([name]);
|
|
318
321
|
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
|
|
319
|
-
if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
322
|
+
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
320
323
|
} else {
|
|
321
324
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
322
325
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
@@ -639,6 +642,7 @@ exports.SVGNamespace = SVGNamespace;
|
|
|
639
642
|
exports.addEventListener = addEventListener;
|
|
640
643
|
exports.assign = assign;
|
|
641
644
|
exports.classList = classList;
|
|
645
|
+
exports.className = className;
|
|
642
646
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
643
647
|
exports.delegateEvents = delegateEvents;
|
|
644
648
|
exports.dynamicProperty = dynamicProperty;
|
package/web/dist/dev.js
CHANGED
|
@@ -133,6 +133,9 @@ function setAttribute(node, name, value) {
|
|
|
133
133
|
function setAttributeNS(node, namespace, name, value) {
|
|
134
134
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
135
135
|
}
|
|
136
|
+
function className(node, value) {
|
|
137
|
+
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
138
|
+
}
|
|
136
139
|
function addEventListener(node, name, handler, delegate) {
|
|
137
140
|
if (delegate) {
|
|
138
141
|
if (Array.isArray(handler)) {
|
|
@@ -313,7 +316,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
313
316
|
addEventListener(node, name, value, delegate);
|
|
314
317
|
delegate && delegateEvents([name]);
|
|
315
318
|
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
|
|
316
|
-
if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
319
|
+
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
317
320
|
} else {
|
|
318
321
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
319
322
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
@@ -572,4 +575,4 @@ function Dynamic(props) {
|
|
|
572
575
|
});
|
|
573
576
|
}
|
|
574
577
|
|
|
575
|
-
export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
|
|
578
|
+
export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
|