solid-js 1.6.10 → 1.6.11
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 +15 -6
- package/dist/dev.js +15 -6
- package/dist/server.cjs +1 -2
- package/dist/server.js +1 -2
- package/dist/solid.cjs +15 -6
- package/dist/solid.js +15 -6
- package/h/jsx-runtime/dist/jsx.cjs +6 -3
- package/h/jsx-runtime/dist/jsx.js +5 -2
- package/h/jsx-runtime/types/index.d.ts +6 -2
- package/h/jsx-runtime/types/jsx.d.ts +1 -0
- package/package.json +3 -2
- package/store/types/modifiers.d.ts +1 -1
- package/store/types/server.d.ts +2 -2
- package/store/types/store.d.ts +21 -21
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +1 -0
- package/types/reactive/observable.d.ts +1 -1
- package/types/reactive/signal.d.ts +31 -31
- package/types/render/component.d.ts +18 -18
- package/types/render/flow.d.ts +1 -1
- package/types/render/hydration.d.ts +2 -2
- package/types/server/reactive.d.ts +7 -7
- package/types/server/rendering.d.ts +20 -20
- package/web/dist/server.cjs +8 -1
- package/web/dist/server.js +8 -1
- package/web/types/index.d.ts +1 -1
- package/web/types/server-mock.d.ts +1 -1
package/dist/dev.cjs
CHANGED
|
@@ -169,7 +169,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
169
169
|
owned: null,
|
|
170
170
|
cleanups: null,
|
|
171
171
|
context: null,
|
|
172
|
-
owner: detachedOwner
|
|
172
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
173
173
|
},
|
|
174
174
|
updateFn = unowned ? () => fn(() => {
|
|
175
175
|
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
@@ -299,8 +299,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
299
299
|
}
|
|
300
300
|
function completeLoad(v, err) {
|
|
301
301
|
runUpdates(() => {
|
|
302
|
-
if (
|
|
303
|
-
setState(err ? "errored" : "ready");
|
|
302
|
+
if (err === undefined) setValue(() => v);
|
|
303
|
+
setState(err !== undefined ? "errored" : "ready");
|
|
304
304
|
setError(err);
|
|
305
305
|
for (const c of contexts.keys()) c.decrement();
|
|
306
306
|
contexts.clear();
|
|
@@ -310,7 +310,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
310
310
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
311
311
|
v = value(),
|
|
312
312
|
err = error();
|
|
313
|
-
if (err && !pr) throw err;
|
|
313
|
+
if (err !== undefined && !pr) throw err;
|
|
314
314
|
if (Listener && !Listener.user && c) {
|
|
315
315
|
createComputed(() => {
|
|
316
316
|
track();
|
|
@@ -423,6 +423,7 @@ function batch(fn) {
|
|
|
423
423
|
return runUpdates(fn, false);
|
|
424
424
|
}
|
|
425
425
|
function untrack(fn) {
|
|
426
|
+
if (Listener === null) return fn();
|
|
426
427
|
const listener = Listener;
|
|
427
428
|
Listener = null;
|
|
428
429
|
try {
|
|
@@ -813,7 +814,7 @@ function runUpdates(fn, init) {
|
|
|
813
814
|
completeUpdates(wait);
|
|
814
815
|
return res;
|
|
815
816
|
} catch (err) {
|
|
816
|
-
if (!
|
|
817
|
+
if (!wait) Effects = null;
|
|
817
818
|
Updates = null;
|
|
818
819
|
handleError(err);
|
|
819
820
|
}
|
|
@@ -965,11 +966,19 @@ function castError(err) {
|
|
|
965
966
|
if (err instanceof Error || typeof err === "string") return err;
|
|
966
967
|
return new Error("Unknown error");
|
|
967
968
|
}
|
|
969
|
+
function runErrors(fns, err) {
|
|
970
|
+
for (const f of fns) f(err);
|
|
971
|
+
}
|
|
968
972
|
function handleError(err) {
|
|
969
973
|
err = castError(err);
|
|
970
974
|
const fns = ERROR && lookup(Owner, ERROR);
|
|
971
975
|
if (!fns) throw err;
|
|
972
|
-
|
|
976
|
+
if (Effects) Effects.push({
|
|
977
|
+
fn() {
|
|
978
|
+
runErrors(fns, err);
|
|
979
|
+
},
|
|
980
|
+
state: STALE
|
|
981
|
+
});else runErrors(fns, err);
|
|
973
982
|
}
|
|
974
983
|
function lookup(owner, key) {
|
|
975
984
|
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
package/dist/dev.js
CHANGED
|
@@ -167,7 +167,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
167
167
|
owned: null,
|
|
168
168
|
cleanups: null,
|
|
169
169
|
context: null,
|
|
170
|
-
owner: detachedOwner
|
|
170
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
171
171
|
},
|
|
172
172
|
updateFn = unowned ? () => fn(() => {
|
|
173
173
|
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
@@ -297,8 +297,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
297
297
|
}
|
|
298
298
|
function completeLoad(v, err) {
|
|
299
299
|
runUpdates(() => {
|
|
300
|
-
if (
|
|
301
|
-
setState(err ? "errored" : "ready");
|
|
300
|
+
if (err === undefined) setValue(() => v);
|
|
301
|
+
setState(err !== undefined ? "errored" : "ready");
|
|
302
302
|
setError(err);
|
|
303
303
|
for (const c of contexts.keys()) c.decrement();
|
|
304
304
|
contexts.clear();
|
|
@@ -308,7 +308,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
308
308
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
309
309
|
v = value(),
|
|
310
310
|
err = error();
|
|
311
|
-
if (err && !pr) throw err;
|
|
311
|
+
if (err !== undefined && !pr) throw err;
|
|
312
312
|
if (Listener && !Listener.user && c) {
|
|
313
313
|
createComputed(() => {
|
|
314
314
|
track();
|
|
@@ -421,6 +421,7 @@ function batch(fn) {
|
|
|
421
421
|
return runUpdates(fn, false);
|
|
422
422
|
}
|
|
423
423
|
function untrack(fn) {
|
|
424
|
+
if (Listener === null) return fn();
|
|
424
425
|
const listener = Listener;
|
|
425
426
|
Listener = null;
|
|
426
427
|
try {
|
|
@@ -811,7 +812,7 @@ function runUpdates(fn, init) {
|
|
|
811
812
|
completeUpdates(wait);
|
|
812
813
|
return res;
|
|
813
814
|
} catch (err) {
|
|
814
|
-
if (!
|
|
815
|
+
if (!wait) Effects = null;
|
|
815
816
|
Updates = null;
|
|
816
817
|
handleError(err);
|
|
817
818
|
}
|
|
@@ -963,11 +964,19 @@ function castError(err) {
|
|
|
963
964
|
if (err instanceof Error || typeof err === "string") return err;
|
|
964
965
|
return new Error("Unknown error");
|
|
965
966
|
}
|
|
967
|
+
function runErrors(fns, err) {
|
|
968
|
+
for (const f of fns) f(err);
|
|
969
|
+
}
|
|
966
970
|
function handleError(err) {
|
|
967
971
|
err = castError(err);
|
|
968
972
|
const fns = ERROR && lookup(Owner, ERROR);
|
|
969
973
|
if (!fns) throw err;
|
|
970
|
-
|
|
974
|
+
if (Effects) Effects.push({
|
|
975
|
+
fn() {
|
|
976
|
+
runErrors(fns, err);
|
|
977
|
+
},
|
|
978
|
+
state: STALE
|
|
979
|
+
});else runErrors(fns, err);
|
|
971
980
|
}
|
|
972
981
|
function lookup(owner, key) {
|
|
973
982
|
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
package/dist/server.cjs
CHANGED
|
@@ -23,11 +23,10 @@ const UNOWNED = {
|
|
|
23
23
|
};
|
|
24
24
|
let Owner = null;
|
|
25
25
|
function createRoot(fn, detachedOwner) {
|
|
26
|
-
detachedOwner && (Owner = detachedOwner);
|
|
27
26
|
const owner = Owner,
|
|
28
27
|
root = fn.length === 0 ? UNOWNED : {
|
|
29
28
|
context: null,
|
|
30
|
-
owner
|
|
29
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
31
30
|
};
|
|
32
31
|
Owner = root;
|
|
33
32
|
let result;
|
package/dist/server.js
CHANGED
|
@@ -21,11 +21,10 @@ const UNOWNED = {
|
|
|
21
21
|
};
|
|
22
22
|
let Owner = null;
|
|
23
23
|
function createRoot(fn, detachedOwner) {
|
|
24
|
-
detachedOwner && (Owner = detachedOwner);
|
|
25
24
|
const owner = Owner,
|
|
26
25
|
root = fn.length === 0 ? UNOWNED : {
|
|
27
26
|
context: null,
|
|
28
|
-
owner
|
|
27
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
29
28
|
};
|
|
30
29
|
Owner = root;
|
|
31
30
|
let result;
|
package/dist/solid.cjs
CHANGED
|
@@ -163,7 +163,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
163
163
|
owned: null,
|
|
164
164
|
cleanups: null,
|
|
165
165
|
context: null,
|
|
166
|
-
owner: detachedOwner
|
|
166
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
167
167
|
},
|
|
168
168
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
169
169
|
Owner = root;
|
|
@@ -286,8 +286,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
286
286
|
}
|
|
287
287
|
function completeLoad(v, err) {
|
|
288
288
|
runUpdates(() => {
|
|
289
|
-
if (
|
|
290
|
-
setState(err ? "errored" : "ready");
|
|
289
|
+
if (err === undefined) setValue(() => v);
|
|
290
|
+
setState(err !== undefined ? "errored" : "ready");
|
|
291
291
|
setError(err);
|
|
292
292
|
for (const c of contexts.keys()) c.decrement();
|
|
293
293
|
contexts.clear();
|
|
@@ -297,7 +297,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
297
297
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
298
298
|
v = value(),
|
|
299
299
|
err = error();
|
|
300
|
-
if (err && !pr) throw err;
|
|
300
|
+
if (err !== undefined && !pr) throw err;
|
|
301
301
|
if (Listener && !Listener.user && c) {
|
|
302
302
|
createComputed(() => {
|
|
303
303
|
track();
|
|
@@ -410,6 +410,7 @@ function batch(fn) {
|
|
|
410
410
|
return runUpdates(fn, false);
|
|
411
411
|
}
|
|
412
412
|
function untrack(fn) {
|
|
413
|
+
if (Listener === null) return fn();
|
|
413
414
|
const listener = Listener;
|
|
414
415
|
Listener = null;
|
|
415
416
|
try {
|
|
@@ -743,7 +744,7 @@ function runUpdates(fn, init) {
|
|
|
743
744
|
completeUpdates(wait);
|
|
744
745
|
return res;
|
|
745
746
|
} catch (err) {
|
|
746
|
-
if (!
|
|
747
|
+
if (!wait) Effects = null;
|
|
747
748
|
Updates = null;
|
|
748
749
|
handleError(err);
|
|
749
750
|
}
|
|
@@ -894,11 +895,19 @@ function castError(err) {
|
|
|
894
895
|
if (err instanceof Error || typeof err === "string") return err;
|
|
895
896
|
return new Error("Unknown error");
|
|
896
897
|
}
|
|
898
|
+
function runErrors(fns, err) {
|
|
899
|
+
for (const f of fns) f(err);
|
|
900
|
+
}
|
|
897
901
|
function handleError(err) {
|
|
898
902
|
err = castError(err);
|
|
899
903
|
const fns = ERROR && lookup(Owner, ERROR);
|
|
900
904
|
if (!fns) throw err;
|
|
901
|
-
|
|
905
|
+
if (Effects) Effects.push({
|
|
906
|
+
fn() {
|
|
907
|
+
runErrors(fns, err);
|
|
908
|
+
},
|
|
909
|
+
state: STALE
|
|
910
|
+
});else runErrors(fns, err);
|
|
902
911
|
}
|
|
903
912
|
function lookup(owner, key) {
|
|
904
913
|
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
package/dist/solid.js
CHANGED
|
@@ -161,7 +161,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
161
161
|
owned: null,
|
|
162
162
|
cleanups: null,
|
|
163
163
|
context: null,
|
|
164
|
-
owner: detachedOwner
|
|
164
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
165
165
|
},
|
|
166
166
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
167
167
|
Owner = root;
|
|
@@ -284,8 +284,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
284
284
|
}
|
|
285
285
|
function completeLoad(v, err) {
|
|
286
286
|
runUpdates(() => {
|
|
287
|
-
if (
|
|
288
|
-
setState(err ? "errored" : "ready");
|
|
287
|
+
if (err === undefined) setValue(() => v);
|
|
288
|
+
setState(err !== undefined ? "errored" : "ready");
|
|
289
289
|
setError(err);
|
|
290
290
|
for (const c of contexts.keys()) c.decrement();
|
|
291
291
|
contexts.clear();
|
|
@@ -295,7 +295,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
295
295
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
296
296
|
v = value(),
|
|
297
297
|
err = error();
|
|
298
|
-
if (err && !pr) throw err;
|
|
298
|
+
if (err !== undefined && !pr) throw err;
|
|
299
299
|
if (Listener && !Listener.user && c) {
|
|
300
300
|
createComputed(() => {
|
|
301
301
|
track();
|
|
@@ -408,6 +408,7 @@ function batch(fn) {
|
|
|
408
408
|
return runUpdates(fn, false);
|
|
409
409
|
}
|
|
410
410
|
function untrack(fn) {
|
|
411
|
+
if (Listener === null) return fn();
|
|
411
412
|
const listener = Listener;
|
|
412
413
|
Listener = null;
|
|
413
414
|
try {
|
|
@@ -741,7 +742,7 @@ function runUpdates(fn, init) {
|
|
|
741
742
|
completeUpdates(wait);
|
|
742
743
|
return res;
|
|
743
744
|
} catch (err) {
|
|
744
|
-
if (!
|
|
745
|
+
if (!wait) Effects = null;
|
|
745
746
|
Updates = null;
|
|
746
747
|
handleError(err);
|
|
747
748
|
}
|
|
@@ -892,11 +893,19 @@ function castError(err) {
|
|
|
892
893
|
if (err instanceof Error || typeof err === "string") return err;
|
|
893
894
|
return new Error("Unknown error");
|
|
894
895
|
}
|
|
896
|
+
function runErrors(fns, err) {
|
|
897
|
+
for (const f of fns) f(err);
|
|
898
|
+
}
|
|
895
899
|
function handleError(err) {
|
|
896
900
|
err = castError(err);
|
|
897
901
|
const fns = ERROR && lookup(Owner, ERROR);
|
|
898
902
|
if (!fns) throw err;
|
|
899
|
-
|
|
903
|
+
if (Effects) Effects.push({
|
|
904
|
+
fn() {
|
|
905
|
+
runErrors(fns, err);
|
|
906
|
+
},
|
|
907
|
+
state: STALE
|
|
908
|
+
});else runErrors(fns, err);
|
|
900
909
|
}
|
|
901
910
|
function lookup(owner, key) {
|
|
902
911
|
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
|
@@ -5,8 +5,11 @@ var h = require('solid-js/h');
|
|
|
5
5
|
function Fragment(props) {
|
|
6
6
|
return props.children;
|
|
7
7
|
}
|
|
8
|
+
function jsx(type, props) {
|
|
9
|
+
return h(type, props);
|
|
10
|
+
}
|
|
8
11
|
|
|
9
|
-
exports.jsx = h;
|
|
10
|
-
exports.jsxDEV = h;
|
|
11
|
-
exports.jsxs = h;
|
|
12
12
|
exports.Fragment = Fragment;
|
|
13
|
+
exports.jsx = jsx;
|
|
14
|
+
exports.jsxDEV = jsx;
|
|
15
|
+
exports.jsxs = jsx;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import h from 'solid-js/h';
|
|
2
2
|
|
|
3
3
|
function Fragment(props) {
|
|
4
4
|
return props.children;
|
|
5
5
|
}
|
|
6
|
+
function jsx(type, props) {
|
|
7
|
+
return h(type, props);
|
|
8
|
+
}
|
|
6
9
|
|
|
7
|
-
export { Fragment };
|
|
10
|
+
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import h from "solid-js/h";
|
|
2
1
|
export type { JSX } from "./jsx";
|
|
3
2
|
import type { JSX } from "./jsx";
|
|
4
3
|
declare function Fragment(props: {
|
|
5
4
|
children: JSX.Element;
|
|
6
5
|
}): JSX.Element;
|
|
7
|
-
|
|
6
|
+
declare function jsx(type: any, props: any): () => (Node & {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}) | (Node & {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
})[];
|
|
11
|
+
export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
|
|
@@ -1692,6 +1692,7 @@ export namespace JSX {
|
|
|
1692
1692
|
patternUnits?: FunctionMaybe<SVGUnits>;
|
|
1693
1693
|
patternContentUnits?: FunctionMaybe<SVGUnits>;
|
|
1694
1694
|
patternTransform?: FunctionMaybe<string>;
|
|
1695
|
+
href?: string;
|
|
1695
1696
|
}
|
|
1696
1697
|
interface PolygonSVGAttributes<T>
|
|
1697
1698
|
extends GraphicsElementSVGAttributes<T>,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.11",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -246,7 +246,8 @@
|
|
|
246
246
|
},
|
|
247
247
|
"require": "./html/dist/html.cjs"
|
|
248
248
|
},
|
|
249
|
-
"./html/dist/*": "./html/dist/*"
|
|
249
|
+
"./html/dist/*": "./html/dist/*",
|
|
250
|
+
"./package.json": "./package.json"
|
|
250
251
|
},
|
|
251
252
|
"keywords": [
|
|
252
253
|
"solid",
|
package/store/types/server.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export declare function setProperty(state: any, property: PropertyKey, value: an
|
|
|
6
6
|
export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
|
|
7
7
|
export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
|
|
8
8
|
export declare function createMutable<T>(state: T | Store<T>): T;
|
|
9
|
-
|
|
9
|
+
type ReconcileOptions = {
|
|
10
10
|
key?: string | null;
|
|
11
11
|
merge?: boolean;
|
|
12
12
|
};
|
|
13
|
-
export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
|
|
13
|
+
export declare function reconcile<T extends U, U extends object>(value: T, options?: ReconcileOptions): (state: U) => T;
|
|
14
14
|
export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
|
|
15
15
|
export declare const DEV: undefined;
|
|
16
16
|
export {};
|
package/store/types/store.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ export declare const $RAW: unique symbol, $NODE: unique symbol, $NAME: unique sy
|
|
|
2
2
|
declare global {
|
|
3
3
|
var _$onStoreNodeUpdate: OnStoreNodeUpdate | undefined;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
type DataNode = {
|
|
6
6
|
(): any;
|
|
7
7
|
$(value?: any): void;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
export
|
|
9
|
+
type DataNodes = Record<PropertyKey, DataNode>;
|
|
10
|
+
export type OnStoreNodeUpdate = (state: StoreNode, property: PropertyKey, value: StoreNode | NotWrappable, prev: StoreNode | NotWrappable) => void;
|
|
11
11
|
export interface StoreNode {
|
|
12
12
|
[$NAME]?: string;
|
|
13
13
|
[$NODE]?: DataNodes;
|
|
@@ -17,8 +17,8 @@ export declare namespace SolidStore {
|
|
|
17
17
|
interface Unwrappable {
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
export
|
|
20
|
+
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
|
|
21
|
+
export type Store<T> = T;
|
|
22
22
|
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
23
23
|
/**
|
|
24
24
|
* Returns the underlying data in the store without a proxy.
|
|
@@ -34,45 +34,45 @@ export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
|
34
34
|
export declare function unwrap<T>(item: T, set?: Set<unknown>): T;
|
|
35
35
|
export declare function getDataNodes(target: StoreNode): DataNodes;
|
|
36
36
|
export declare function getDataNode(nodes: DataNodes, property: PropertyKey, value: any): DataNode;
|
|
37
|
-
export declare function proxyDescriptor(target: StoreNode, property: PropertyKey):
|
|
37
|
+
export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): TypedPropertyDescriptor<any> | undefined;
|
|
38
38
|
export declare function trackSelf(target: StoreNode): void;
|
|
39
39
|
export declare function ownKeys(target: StoreNode): (string | symbol)[];
|
|
40
40
|
export declare function setProperty(state: StoreNode, property: PropertyKey, value: any, deleting?: boolean): void;
|
|
41
41
|
export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
|
|
42
42
|
/** @deprecated */
|
|
43
|
-
export
|
|
43
|
+
export type DeepReadonly<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
|
|
44
44
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
45
45
|
};
|
|
46
46
|
/** @deprecated */
|
|
47
|
-
export
|
|
47
|
+
export type DeepMutable<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
|
|
48
48
|
-readonly [K in keyof T]: DeepMutable<T[K]>;
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type CustomPartial<T> = T extends readonly unknown[] ? "0" extends keyof T ? {
|
|
51
51
|
[K in Extract<keyof T, `${number}`>]?: T[K];
|
|
52
52
|
} : {
|
|
53
53
|
[x: number]: T[number];
|
|
54
54
|
} : Partial<T>;
|
|
55
|
-
export
|
|
55
|
+
export type PickMutable<T> = {
|
|
56
56
|
[K in keyof T as (<U>() => U extends {
|
|
57
57
|
[V in K]: T[V];
|
|
58
58
|
} ? 1 : 2) extends <U>() => U extends {
|
|
59
59
|
-readonly [V in K]: T[V];
|
|
60
60
|
} ? 1 : 2 ? K : never]: T[K];
|
|
61
61
|
};
|
|
62
|
-
export
|
|
62
|
+
export type StorePathRange = {
|
|
63
63
|
from?: number;
|
|
64
64
|
to?: number;
|
|
65
65
|
by?: number;
|
|
66
66
|
};
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
export type ArrayFilterFn<T> = (item: T, index: number) => boolean;
|
|
68
|
+
export type StoreSetter<T, U extends PropertyKey[] = []> = T | CustomPartial<T> | ((prevState: T, traversed: U) => T | CustomPartial<T>);
|
|
69
|
+
export type Part<T, K extends KeyOf<T> = KeyOf<T>> = K | ([K] extends [never] ? never : readonly K[]) | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
|
|
70
|
+
type W<T> = Exclude<T, NotWrappable>;
|
|
71
|
+
type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [readonly unknown[]] ? number : [T] extends [never] ? never : keyof T : keyof T;
|
|
72
|
+
type MutableKeyOf<T> = KeyOf<T> & keyof PickMutable<T>;
|
|
73
|
+
type Rest<T, U extends PropertyKey[], K extends KeyOf<T> = KeyOf<T>> = [T] extends [never] ? never : K extends MutableKeyOf<T> ? [Part<T, K>, ...RestSetterOrContinue<T[K], [K, ...U]>] : K extends KeyOf<T> ? [Part<T, K>, ...RestContinue<T[K], [K, ...U]>] : never;
|
|
74
|
+
type RestContinue<T, U extends PropertyKey[]> = 0 extends 1 & T ? [...Part<any>[], StoreSetter<any, PropertyKey[]>] : Rest<W<T>, U>;
|
|
75
|
+
type RestSetterOrContinue<T, U extends PropertyKey[]> = [StoreSetter<T, U>] | RestContinue<T, U>;
|
|
76
76
|
export interface SetStoreFunction<T> {
|
|
77
77
|
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>, K7 extends MutableKeyOf<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, k7: Part<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>, K7>, setter: StoreSetter<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>[K7], [
|
|
78
78
|
K7,
|
|
@@ -83,7 +83,7 @@ export interface SetStoreFunction<T> {
|
|
|
83
83
|
K2,
|
|
84
84
|
K1
|
|
85
85
|
]>): void;
|
|
86
|
-
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends
|
|
86
|
+
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends MutableKeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, setter: StoreSetter<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6], [K6, K5, K4, K3, K2, K1]>): void;
|
|
87
87
|
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends MutableKeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, setter: StoreSetter<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5], [K5, K4, K3, K2, K1]>): void;
|
|
88
88
|
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends MutableKeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, setter: StoreSetter<W<W<W<W<T>[K1]>[K2]>[K3]>[K4], [K4, K3, K2, K1]>): void;
|
|
89
89
|
<K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends MutableKeyOf<W<W<W<T>[K1]>[K2]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, setter: StoreSetter<W<W<W<T>[K1]>[K2]>[K3], [K3, K2, K1]>): void;
|
package/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./reactive/scheduler.js";
|
|
|
5
5
|
export * from "./reactive/array.js";
|
|
6
6
|
export * from "./render/index.js";
|
|
7
7
|
import type { JSX } from "./jsx.js";
|
|
8
|
-
|
|
8
|
+
type JSXElement = JSX.Element;
|
|
9
9
|
export type { JSXElement, JSX };
|
|
10
10
|
import { hashValue, registerGraph, serializeGraph, writeSignal } from "./reactive/signal.js";
|
|
11
11
|
declare let DEV: {
|
package/types/jsx.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface Observable<T> {
|
|
|
10
10
|
};
|
|
11
11
|
[Symbol.observable](): Observable<T>;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type ObservableObserver<T> = ((v: T) => void) | {
|
|
14
14
|
next?: (v: T) => void;
|
|
15
15
|
error?: (v: any) => void;
|
|
16
16
|
complete?: (v: boolean) => void;
|
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
var _$afterUpdate: (() => void) | undefined;
|
|
13
13
|
var _$afterCreateRoot: ((root: Owner) => void) | undefined;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export type ComputationState = 0 | 1 | 2;
|
|
16
16
|
export interface SourceMapValue {
|
|
17
17
|
value: unknown;
|
|
18
18
|
graph?: Owner;
|
|
@@ -57,12 +57,12 @@ export interface TransitionState {
|
|
|
57
57
|
done?: Promise<void>;
|
|
58
58
|
resolve?: () => void;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
|
|
61
61
|
export interface ExternalSource {
|
|
62
62
|
track: EffectFunction<any, any>;
|
|
63
63
|
dispose: () => void;
|
|
64
64
|
}
|
|
65
|
-
export
|
|
65
|
+
export type RootFunction<T> = (dispose: () => void) => T;
|
|
66
66
|
/**
|
|
67
67
|
* Creates a new non-tracked reactive context that doesn't auto-dispose
|
|
68
68
|
*
|
|
@@ -72,10 +72,10 @@ export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
|
72
72
|
*
|
|
73
73
|
* @description https://www.solidjs.com/docs/latest/api#createroot
|
|
74
74
|
*/
|
|
75
|
-
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
75
|
+
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner): T;
|
|
76
|
+
export type Accessor<T> = () => T;
|
|
77
|
+
export type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
|
|
78
|
+
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
79
79
|
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
80
80
|
internal?: boolean;
|
|
81
81
|
}
|
|
@@ -107,10 +107,10 @@ export declare function createSignal<T>(value: T, options?: SignalOptions<T>): S
|
|
|
107
107
|
export interface BaseOptions {
|
|
108
108
|
name?: string;
|
|
109
109
|
}
|
|
110
|
-
export
|
|
110
|
+
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
111
111
|
export interface EffectOptions extends BaseOptions {
|
|
112
112
|
}
|
|
113
|
-
export
|
|
113
|
+
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
|
|
114
114
|
/**
|
|
115
115
|
* Creates a reactive computation that runs immediately before render, mainly used to write to other reactive primitives
|
|
116
116
|
* ```typescript
|
|
@@ -235,19 +235,19 @@ interface Errored {
|
|
|
235
235
|
latest: never;
|
|
236
236
|
(): never;
|
|
237
237
|
}
|
|
238
|
-
export
|
|
239
|
-
export
|
|
240
|
-
export
|
|
238
|
+
export type Resource<T> = Unresolved | Pending | Ready<T> | Refreshing<T> | Errored;
|
|
239
|
+
export type InitializedResource<T> = Ready<T> | Refreshing<T> | Errored;
|
|
240
|
+
export type ResourceActions<T, R = unknown> = {
|
|
241
241
|
mutate: Setter<T>;
|
|
242
242
|
refetch: (info?: R) => T | Promise<T> | undefined | null;
|
|
243
243
|
};
|
|
244
|
-
export
|
|
245
|
-
export
|
|
246
|
-
export
|
|
244
|
+
export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
245
|
+
export type ResourceFetcher<S, T, R = unknown> = (k: S, info: ResourceFetcherInfo<T, R>) => T | Promise<T>;
|
|
246
|
+
export type ResourceFetcherInfo<T, R = unknown> = {
|
|
247
247
|
value: T | undefined;
|
|
248
248
|
refetching: R | boolean;
|
|
249
249
|
};
|
|
250
|
-
export
|
|
250
|
+
export type ResourceOptions<T, S = unknown> = {
|
|
251
251
|
initialValue?: T;
|
|
252
252
|
name?: string;
|
|
253
253
|
deferStream?: boolean;
|
|
@@ -257,11 +257,11 @@ export declare type ResourceOptions<T, S = unknown> = {
|
|
|
257
257
|
value: T | undefined;
|
|
258
258
|
}) => void;
|
|
259
259
|
};
|
|
260
|
-
export
|
|
260
|
+
export type InitializedResourceOptions<T, S = unknown> = ResourceOptions<T, S> & {
|
|
261
261
|
initialValue: T;
|
|
262
262
|
};
|
|
263
|
-
export
|
|
264
|
-
export
|
|
263
|
+
export type ResourceReturn<T, R = unknown> = [Resource<T>, ResourceActions<T | undefined, R>];
|
|
264
|
+
export type InitializedResourceReturn<T, R = unknown> = [
|
|
265
265
|
InitializedResource<T>,
|
|
266
266
|
ResourceActions<T, R>
|
|
267
267
|
];
|
|
@@ -316,7 +316,7 @@ export interface DeferredOptions<T> {
|
|
|
316
316
|
* @description https://www.solidjs.com/docs/latest/api#createdeferred
|
|
317
317
|
*/
|
|
318
318
|
export declare function createDeferred<T>(source: Accessor<T>, options?: DeferredOptions<T>): Accessor<T>;
|
|
319
|
-
export
|
|
319
|
+
export type EqualityCheckerFunction<T, U> = (a: U, b: T) => boolean;
|
|
320
320
|
/**
|
|
321
321
|
* Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value
|
|
322
322
|
* ```typescript
|
|
@@ -359,13 +359,13 @@ export declare function batch<T>(fn: Accessor<T>): T;
|
|
|
359
359
|
*/
|
|
360
360
|
export declare function untrack<T>(fn: Accessor<T>): T;
|
|
361
361
|
/** @deprecated */
|
|
362
|
-
export
|
|
362
|
+
export type ReturnTypes<T> = T extends readonly Accessor<unknown>[] ? {
|
|
363
363
|
[K in keyof T]: T[K] extends Accessor<infer I> ? I : never;
|
|
364
364
|
} : T extends Accessor<infer I> ? I : never;
|
|
365
|
-
export
|
|
365
|
+
export type AccessorArray<T> = [...Extract<{
|
|
366
366
|
[K in keyof T]: Accessor<T[K]>;
|
|
367
367
|
}, readonly unknown[]>];
|
|
368
|
-
export
|
|
368
|
+
export type OnEffectFunction<S, Prev, Next extends Prev = Prev> = (input: S, prevInput: S | undefined, prev: Prev) => Next;
|
|
369
369
|
export interface OnOptions {
|
|
370
370
|
defer?: boolean;
|
|
371
371
|
}
|
|
@@ -428,7 +428,7 @@ export declare function onCleanup<T extends () => any>(fn: T): T;
|
|
|
428
428
|
export declare function onError(fn: (err: any) => void): void;
|
|
429
429
|
export declare function getListener(): Computation<any, any> | null;
|
|
430
430
|
export declare function getOwner(): Owner | null;
|
|
431
|
-
export declare function runWithOwner<T>(o: Owner, fn: () => T): T | undefined;
|
|
431
|
+
export declare function runWithOwner<T>(o: typeof Owner, fn: () => T): T | undefined;
|
|
432
432
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
433
433
|
/**
|
|
434
434
|
* ```typescript
|
|
@@ -437,7 +437,7 @@ export declare function enableScheduling(scheduler?: typeof requestCallback): vo
|
|
|
437
437
|
* @description https://www.solidjs.com/docs/latest/api#usetransition
|
|
438
438
|
*/
|
|
439
439
|
export declare function startTransition(fn: () => unknown): Promise<void>;
|
|
440
|
-
export
|
|
440
|
+
export type Transition = [Accessor<boolean>, (fn: () => void) => Promise<void>];
|
|
441
441
|
/**
|
|
442
442
|
* ```typescript
|
|
443
443
|
* export function useTransition(): [
|
|
@@ -461,7 +461,7 @@ interface GraphRecord {
|
|
|
461
461
|
[k: string]: GraphRecord | unknown;
|
|
462
462
|
}
|
|
463
463
|
export declare function serializeGraph(owner?: Owner | null): GraphRecord;
|
|
464
|
-
export
|
|
464
|
+
export type ContextProviderComponent<T> = FlowComponent<{
|
|
465
465
|
value: T;
|
|
466
466
|
}>;
|
|
467
467
|
export interface Context<T> {
|
|
@@ -499,9 +499,9 @@ export declare function createContext<T>(defaultValue: T, options?: EffectOption
|
|
|
499
499
|
* @description https://www.solidjs.com/docs/latest/api#usecontext
|
|
500
500
|
*/
|
|
501
501
|
export declare function useContext<T>(context: Context<T>): T;
|
|
502
|
-
export
|
|
503
|
-
export
|
|
504
|
-
export
|
|
502
|
+
export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement | JSX.FunctionElement>;
|
|
503
|
+
export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
|
|
504
|
+
export type ChildrenReturn = Accessor<ResolvedChildren> & {
|
|
505
505
|
toArray: () => ResolvedJSXElement[];
|
|
506
506
|
};
|
|
507
507
|
/**
|
|
@@ -513,14 +513,14 @@ export declare type ChildrenReturn = Accessor<ResolvedChildren> & {
|
|
|
513
513
|
* @description https://www.solidjs.com/docs/latest/api#children
|
|
514
514
|
*/
|
|
515
515
|
export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
|
|
516
|
-
export
|
|
516
|
+
export type SuspenseContextType = {
|
|
517
517
|
increment?: () => void;
|
|
518
518
|
decrement?: () => void;
|
|
519
519
|
inFallback?: () => boolean;
|
|
520
520
|
effects?: Computation<any>[];
|
|
521
521
|
resolved?: boolean;
|
|
522
522
|
};
|
|
523
|
-
|
|
523
|
+
type SuspenseContext = Context<SuspenseContextType> & {
|
|
524
524
|
active?(): boolean;
|
|
525
525
|
increment?(): void;
|
|
526
526
|
decrement?(): void;
|
|
@@ -4,13 +4,13 @@ export declare function enableHydration(): void;
|
|
|
4
4
|
* A general `Component` has no implicit `children` prop. If desired, you can
|
|
5
5
|
* specify one as in `Component<{name: String, children: JSX.Element}>`.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Component<P = {}> = (props: P) => JSX.Element;
|
|
8
8
|
/**
|
|
9
9
|
* Extend props to forbid the `children` prop.
|
|
10
10
|
* Use this to prevent accidentally passing `children` to components that
|
|
11
11
|
* would silently throw them away.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type VoidProps<P = {}> = P & {
|
|
14
14
|
children?: never;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
@@ -18,13 +18,13 @@ export declare type VoidProps<P = {}> = P & {
|
|
|
18
18
|
* Use this to prevent accidentally passing `children` to components that
|
|
19
19
|
* would silently throw them away.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
22
22
|
/**
|
|
23
23
|
* Extend props to allow an optional `children` prop with the usual
|
|
24
24
|
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
25
25
|
* Use this for components that you want to accept children.
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export type ParentProps<P = {}> = P & {
|
|
28
28
|
children?: JSX.Element;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -32,14 +32,14 @@ export declare type ParentProps<P = {}> = P & {
|
|
|
32
32
|
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
33
33
|
* Use this for components that you want to accept children.
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
36
36
|
/**
|
|
37
37
|
* Extend props to require a `children` prop with the specified type.
|
|
38
38
|
* Use this for components where you need a specific child type,
|
|
39
39
|
* typically a function that receives specific argument types.
|
|
40
40
|
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
43
43
|
children: C;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
@@ -48,10 +48,10 @@ export declare type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
|
48
48
|
* typically a function that receives specific argument types.
|
|
49
49
|
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
50
50
|
*/
|
|
51
|
-
export
|
|
51
|
+
export type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
52
52
|
/** @deprecated: use `ParentProps` instead */
|
|
53
|
-
export
|
|
54
|
-
export
|
|
53
|
+
export type PropsWithChildren<P = {}> = ParentProps<P>;
|
|
54
|
+
export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
|
|
55
55
|
/**
|
|
56
56
|
* Takes the props of the passed component and returns its type
|
|
57
57
|
*
|
|
@@ -59,21 +59,21 @@ export declare type ValidComponent = keyof JSX.IntrinsicElements | Component<any
|
|
|
59
59
|
* ComponentProps<typeof Portal> // { mount?: Node; useShadow?: boolean; children: JSX.Element }
|
|
60
60
|
* ComponentProps<'div'> // JSX.HTMLAttributes<HTMLDivElement>
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
63
63
|
/**
|
|
64
64
|
* Type of `props.ref`, for use in `Component` or `props` typing.
|
|
65
65
|
*
|
|
66
66
|
* @example Component<{ref: Ref<Element>}>
|
|
67
67
|
*/
|
|
68
|
-
export
|
|
68
|
+
export type Ref<T> = T | ((val: T) => void);
|
|
69
69
|
export declare function createComponent<T>(Comp: Component<T>, props: T): JSX.Element;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
type DistributeOverride<T, F> = T extends undefined ? F : T;
|
|
71
|
+
type Override<T, U> = T extends any ? U extends any ? {
|
|
72
72
|
[K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
|
|
73
73
|
} & {
|
|
74
74
|
[K in keyof U]: K extends keyof T ? DistributeOverride<U[K], T[K]> : U[K];
|
|
75
75
|
} : T & U : T & U;
|
|
76
|
-
|
|
76
|
+
type OverrideSpread<T, U> = T extends any ? {
|
|
77
77
|
[K in keyof ({
|
|
78
78
|
[K in keyof T]: any;
|
|
79
79
|
} & {
|
|
@@ -82,16 +82,16 @@ declare type OverrideSpread<T, U> = T extends any ? {
|
|
|
82
82
|
[K in U extends any ? keyof U : keyof U]?: any;
|
|
83
83
|
})]: K extends keyof T ? Exclude<U extends any ? U[K & keyof U] : never, undefined> | T[K] : U extends any ? U[K & keyof U] : never;
|
|
84
84
|
} : T & U;
|
|
85
|
-
|
|
85
|
+
type Simplify<T> = T extends any ? {
|
|
86
86
|
[K in keyof T]: T[K];
|
|
87
87
|
} : T;
|
|
88
|
-
|
|
88
|
+
type _MergeProps<T extends unknown[], Curr = {}> = T extends [
|
|
89
89
|
infer Next | (() => infer Next),
|
|
90
90
|
...infer Rest
|
|
91
91
|
] ? _MergeProps<Rest, Override<Curr, Next>> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_MergeProps<Rest, Curr>, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread<Curr, I> : Curr;
|
|
92
|
-
export
|
|
92
|
+
export type MergeProps<T extends unknown[]> = Simplify<_MergeProps<T>>;
|
|
93
93
|
export declare function mergeProps<T extends unknown[]>(...sources: T): MergeProps<T>;
|
|
94
|
-
export
|
|
94
|
+
export type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
95
95
|
...{
|
|
96
96
|
[P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
|
|
97
97
|
},
|
package/types/render/flow.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare function Switch(props: {
|
|
|
70
70
|
fallback?: JSX.Element;
|
|
71
71
|
children: JSX.Element;
|
|
72
72
|
}): Accessor<JSX.Element>;
|
|
73
|
-
export
|
|
73
|
+
export type MatchProps<T> = {
|
|
74
74
|
when: T | undefined | null | false;
|
|
75
75
|
keyed?: boolean;
|
|
76
76
|
children: JSX.Element | ((item: NonNullable<T>) => JSX.Element);
|
|
@@ -3,9 +3,9 @@ export declare const $PROXY: unique symbol;
|
|
|
3
3
|
export declare const $TRACK: unique symbol;
|
|
4
4
|
export declare const $DEVCOMP: unique symbol;
|
|
5
5
|
export declare const DEV: {};
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
6
|
+
export type Accessor<T> = () => T;
|
|
7
|
+
export type Setter<T> = undefined extends T ? <U extends T>(value?: (U extends Function ? never : U) | ((prev?: T) => U)) => U : <U extends T>(value: (U extends Function ? never : U) | ((prev: T) => U)) => U;
|
|
8
|
+
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
9
9
|
export declare const BRANCH: unique symbol;
|
|
10
10
|
export declare function castError(err: any): string | Error;
|
|
11
11
|
export declare let Owner: Owner | null;
|
|
@@ -13,7 +13,7 @@ interface Owner {
|
|
|
13
13
|
owner: Owner | null;
|
|
14
14
|
context: any | null;
|
|
15
15
|
}
|
|
16
|
-
export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Owner): T;
|
|
16
|
+
export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: typeof Owner): T;
|
|
17
17
|
export declare function createSignal<T>(value: T, options?: {
|
|
18
18
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
19
19
|
name?: string;
|
|
@@ -48,11 +48,11 @@ export interface Context<T> {
|
|
|
48
48
|
export declare function createContext<T>(defaultValue?: T): Context<T>;
|
|
49
49
|
export declare function useContext<T>(context: Context<T>): T;
|
|
50
50
|
export declare function getOwner(): Owner | null;
|
|
51
|
-
|
|
51
|
+
type ChildrenReturn = Accessor<any> & {
|
|
52
52
|
toArray: () => any[];
|
|
53
53
|
};
|
|
54
54
|
export declare function children(fn: () => any): ChildrenReturn;
|
|
55
|
-
export declare function runWithOwner<T>(o: Owner, fn: () => T): T | undefined;
|
|
55
|
+
export declare function runWithOwner<T>(o: typeof Owner, fn: () => T): T | undefined;
|
|
56
56
|
export declare function lookup(owner: Owner | null, key: symbol | string): any;
|
|
57
57
|
export interface Task {
|
|
58
58
|
id: number;
|
|
@@ -67,7 +67,7 @@ export declare function cancelCallback(task: Task): void;
|
|
|
67
67
|
export declare function mapArray<T, U>(list: () => T[], mapFn: (v: T, i: () => number) => U, options?: {
|
|
68
68
|
fallback?: () => any;
|
|
69
69
|
}): () => U[];
|
|
70
|
-
export
|
|
70
|
+
export type ObservableObserver<T> = ((v: T) => void) | {
|
|
71
71
|
next: (v: T) => void;
|
|
72
72
|
error?: (v: any) => void;
|
|
73
73
|
complete?: (v: boolean) => void;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Setter, Signal } from "./reactive.js";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type Component<P = {}> = (props: P) => JSX.Element;
|
|
4
|
+
export type VoidProps<P = {}> = P & {
|
|
5
5
|
children?: never;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
8
|
+
export type ParentProps<P = {}> = P & {
|
|
9
9
|
children?: JSX.Element;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
12
|
+
export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
13
13
|
children: C;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
|
|
15
|
+
export type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
16
|
+
export type Ref<T> = T | ((val: T) => void);
|
|
17
|
+
export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
|
|
18
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
19
|
+
type SharedConfig = {
|
|
20
20
|
context?: HydrationContext;
|
|
21
21
|
};
|
|
22
22
|
export declare const sharedConfig: SharedConfig;
|
|
@@ -57,7 +57,7 @@ export declare function Switch(props: {
|
|
|
57
57
|
fallback?: string;
|
|
58
58
|
children: MatchProps<unknown> | MatchProps<unknown>[];
|
|
59
59
|
}): string;
|
|
60
|
-
|
|
60
|
+
type MatchProps<T> = {
|
|
61
61
|
when: T | false;
|
|
62
62
|
keyed?: boolean;
|
|
63
63
|
children: string | ((item: T) => string);
|
|
@@ -77,25 +77,25 @@ export interface Resource<T> {
|
|
|
77
77
|
error: any;
|
|
78
78
|
latest: T | undefined;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
type SuspenseContextType = {
|
|
81
81
|
resources: Map<string, {
|
|
82
82
|
loading: boolean;
|
|
83
83
|
error: any;
|
|
84
84
|
}>;
|
|
85
85
|
completed: () => void;
|
|
86
86
|
};
|
|
87
|
-
export
|
|
87
|
+
export type ResourceActions<T> = {
|
|
88
88
|
mutate: Setter<T>;
|
|
89
89
|
refetch: (info?: unknown) => void;
|
|
90
90
|
};
|
|
91
|
-
export
|
|
92
|
-
export
|
|
93
|
-
export
|
|
94
|
-
export
|
|
91
|
+
export type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
92
|
+
export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
93
|
+
export type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
94
|
+
export type ResourceFetcherInfo<T> = {
|
|
95
95
|
value: T | undefined;
|
|
96
96
|
refetching?: unknown;
|
|
97
97
|
};
|
|
98
|
-
export
|
|
98
|
+
export type ResourceOptions<T> = undefined extends T ? {
|
|
99
99
|
initialValue?: T;
|
|
100
100
|
name?: string;
|
|
101
101
|
deferStream?: boolean;
|
|
@@ -125,7 +125,7 @@ export declare function enableScheduling(): void;
|
|
|
125
125
|
export declare function enableHydration(): void;
|
|
126
126
|
export declare function startTransition(fn: () => any): void;
|
|
127
127
|
export declare function useTransition(): [() => boolean, (fn: () => any) => void];
|
|
128
|
-
|
|
128
|
+
type HydrationContext = {
|
|
129
129
|
id: string;
|
|
130
130
|
count: number;
|
|
131
131
|
writeResource: (id: string, v: Promise<any> | any, error?: boolean, deferStream?: boolean) => void;
|
package/web/dist/server.cjs
CHANGED
|
@@ -261,6 +261,7 @@ function toRefParam(index) {
|
|
|
261
261
|
return ref;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
264
265
|
const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
|
|
265
266
|
function renderToString(code, options = {}) {
|
|
266
267
|
let scripts = "";
|
|
@@ -522,13 +523,14 @@ function ssrStyle(value) {
|
|
|
522
523
|
}
|
|
523
524
|
function ssrElement(tag, props, children, needsId) {
|
|
524
525
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
526
|
+
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
525
527
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
526
528
|
const keys = Object.keys(props);
|
|
527
529
|
let classResolved;
|
|
528
530
|
for (let i = 0; i < keys.length; i++) {
|
|
529
531
|
const prop = keys[i];
|
|
530
532
|
if (ChildProperties.has(prop)) {
|
|
531
|
-
if (children === undefined) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
533
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
532
534
|
continue;
|
|
533
535
|
}
|
|
534
536
|
const value = props[prop];
|
|
@@ -548,6 +550,11 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
548
550
|
}
|
|
549
551
|
if (i !== keys.length - 1) result += " ";
|
|
550
552
|
}
|
|
553
|
+
if (skipChildren) {
|
|
554
|
+
return {
|
|
555
|
+
t: result + '/>'
|
|
556
|
+
};
|
|
557
|
+
}
|
|
551
558
|
return {
|
|
552
559
|
t: result + `>${resolveSSRNode(children)}</${tag}>`
|
|
553
560
|
};
|
package/web/dist/server.js
CHANGED
|
@@ -260,6 +260,7 @@ function toRefParam(index) {
|
|
|
260
260
|
return ref;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
263
264
|
const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
|
|
264
265
|
function renderToString(code, options = {}) {
|
|
265
266
|
let scripts = "";
|
|
@@ -521,13 +522,14 @@ function ssrStyle(value) {
|
|
|
521
522
|
}
|
|
522
523
|
function ssrElement(tag, props, children, needsId) {
|
|
523
524
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
525
|
+
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
524
526
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
525
527
|
const keys = Object.keys(props);
|
|
526
528
|
let classResolved;
|
|
527
529
|
for (let i = 0; i < keys.length; i++) {
|
|
528
530
|
const prop = keys[i];
|
|
529
531
|
if (ChildProperties.has(prop)) {
|
|
530
|
-
if (children === undefined) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
532
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
531
533
|
continue;
|
|
532
534
|
}
|
|
533
535
|
const value = props[prop];
|
|
@@ -547,6 +549,11 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
547
549
|
}
|
|
548
550
|
if (i !== keys.length - 1) result += " ";
|
|
549
551
|
}
|
|
552
|
+
if (skipChildren) {
|
|
553
|
+
return {
|
|
554
|
+
t: result + '/>'
|
|
555
|
+
};
|
|
556
|
+
}
|
|
550
557
|
return {
|
|
551
558
|
t: result + `>${resolveSSRNode(children)}</${tag}>`
|
|
552
559
|
};
|
package/web/types/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
|
|
|
21
21
|
} : {}) & (S extends true ? SVGGElement : HTMLDivElement)) => void);
|
|
22
22
|
children: JSX.Element;
|
|
23
23
|
}): Text;
|
|
24
|
-
export
|
|
24
|
+
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
25
25
|
[K in keyof P]: P[K];
|
|
26
26
|
} & {
|
|
27
27
|
component: T | undefined;
|
|
@@ -42,7 +42,7 @@ export declare function escape(html: string): string;
|
|
|
42
42
|
* @deprecated Replaced by ssrElement
|
|
43
43
|
*/
|
|
44
44
|
export declare function ssrSpread(props: any, isSVG: boolean, skipChildren: boolean): void;
|
|
45
|
-
export
|
|
45
|
+
export type LegacyResults = {
|
|
46
46
|
startWriting: () => void;
|
|
47
47
|
};
|
|
48
48
|
/**
|