solid-js 1.5.0-beta.4 → 1.5.0-beta.5
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 +2 -5
- package/dist/dev.js +2 -5
- package/dist/server.cjs +7 -10
- package/dist/server.js +7 -10
- package/dist/solid.cjs +2 -5
- package/dist/solid.js +2 -5
- package/package.json +5 -1
- package/types/reactive/signal.d.ts +2 -7
- package/types/server/reactive.d.ts +1 -0
- package/types/server/rendering.d.ts +5 -4
- package/jsx-runtime.d.ts +0 -1
package/dist/dev.cjs
CHANGED
|
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
264
|
resolved = ("initialValue" in options),
|
|
265
265
|
dynamic = typeof source === "function" && createMemo(source);
|
|
266
266
|
const contexts = new Set(),
|
|
267
|
-
[value, setValue] =
|
|
267
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
268
268
|
[track, trigger] = createSignal(undefined, {
|
|
269
269
|
equals: false
|
|
270
270
|
}),
|
|
@@ -272,7 +272,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
272
272
|
if (sharedConfig.context) {
|
|
273
273
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
274
274
|
let v;
|
|
275
|
-
if (options.
|
|
275
|
+
if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
276
276
|
}
|
|
277
277
|
function loadEnd(p, v, success, key) {
|
|
278
278
|
if (pr === p) {
|
|
@@ -352,9 +352,6 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
352
352
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
353
353
|
}
|
|
354
354
|
Object.defineProperties(read, {
|
|
355
|
-
value: {
|
|
356
|
-
get: () => value()
|
|
357
|
-
},
|
|
358
355
|
state: {
|
|
359
356
|
get: () => state()
|
|
360
357
|
},
|
package/dist/dev.js
CHANGED
|
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
260
260
|
resolved = ("initialValue" in options),
|
|
261
261
|
dynamic = typeof source === "function" && createMemo(source);
|
|
262
262
|
const contexts = new Set(),
|
|
263
|
-
[value, setValue] =
|
|
263
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
264
264
|
[track, trigger] = createSignal(undefined, {
|
|
265
265
|
equals: false
|
|
266
266
|
}),
|
|
@@ -268,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
268
268
|
if (sharedConfig.context) {
|
|
269
269
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
270
270
|
let v;
|
|
271
|
-
if (options.
|
|
271
|
+
if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
272
272
|
}
|
|
273
273
|
function loadEnd(p, v, success, key) {
|
|
274
274
|
if (pr === p) {
|
|
@@ -348,9 +348,6 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
348
348
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
349
349
|
}
|
|
350
350
|
Object.defineProperties(read, {
|
|
351
|
-
value: {
|
|
352
|
-
get: () => value()
|
|
353
|
-
},
|
|
354
351
|
state: {
|
|
355
352
|
get: () => state()
|
|
356
353
|
},
|
package/dist/server.cjs
CHANGED
|
@@ -396,10 +396,10 @@ function createResource(source, fetcher, options = {}) {
|
|
|
396
396
|
const contexts = new Set();
|
|
397
397
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
398
398
|
let resource = {};
|
|
399
|
-
let value = options.initialValue;
|
|
399
|
+
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
400
400
|
let p;
|
|
401
401
|
let error;
|
|
402
|
-
if (sharedConfig.context.async &&
|
|
402
|
+
if (sharedConfig.context.async && options.ssrValue !== "initial") {
|
|
403
403
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
404
404
|
if (resource.ref) {
|
|
405
405
|
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
@@ -409,7 +409,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
409
409
|
const read = () => {
|
|
410
410
|
if (error) throw error;
|
|
411
411
|
if (resourceContext && p) resourceContext.push(p);
|
|
412
|
-
const resolved =
|
|
412
|
+
const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
413
413
|
if (!resolved && read.loading) {
|
|
414
414
|
const ctx = useContext(SuspenseContext);
|
|
415
415
|
if (ctx) {
|
|
@@ -422,12 +422,9 @@ function createResource(source, fetcher, options = {}) {
|
|
|
422
422
|
read.loading = false;
|
|
423
423
|
read.error = undefined;
|
|
424
424
|
read.state = "initialValue" in options ? "resolved" : "unresolved";
|
|
425
|
-
Object.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
},
|
|
429
|
-
latest: {
|
|
430
|
-
get: () => read()
|
|
425
|
+
Object.defineProperty(read, "latest", {
|
|
426
|
+
get() {
|
|
427
|
+
return read();
|
|
431
428
|
}
|
|
432
429
|
});
|
|
433
430
|
function load() {
|
|
@@ -475,7 +472,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
475
472
|
p = null;
|
|
476
473
|
return ctx.resources[id].data;
|
|
477
474
|
}
|
|
478
|
-
if (
|
|
475
|
+
if (options.ssrValue !== "initial") load();
|
|
479
476
|
return resource.ref = [read, {
|
|
480
477
|
refetch: load,
|
|
481
478
|
mutate: v => value = v
|
package/dist/server.js
CHANGED
|
@@ -392,10 +392,10 @@ function createResource(source, fetcher, options = {}) {
|
|
|
392
392
|
const contexts = new Set();
|
|
393
393
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
394
394
|
let resource = {};
|
|
395
|
-
let value = options.initialValue;
|
|
395
|
+
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
396
396
|
let p;
|
|
397
397
|
let error;
|
|
398
|
-
if (sharedConfig.context.async &&
|
|
398
|
+
if (sharedConfig.context.async && options.ssrValue !== "initial") {
|
|
399
399
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
400
400
|
if (resource.ref) {
|
|
401
401
|
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
@@ -405,7 +405,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
405
405
|
const read = () => {
|
|
406
406
|
if (error) throw error;
|
|
407
407
|
if (resourceContext && p) resourceContext.push(p);
|
|
408
|
-
const resolved =
|
|
408
|
+
const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
409
409
|
if (!resolved && read.loading) {
|
|
410
410
|
const ctx = useContext(SuspenseContext);
|
|
411
411
|
if (ctx) {
|
|
@@ -418,12 +418,9 @@ function createResource(source, fetcher, options = {}) {
|
|
|
418
418
|
read.loading = false;
|
|
419
419
|
read.error = undefined;
|
|
420
420
|
read.state = "initialValue" in options ? "resolved" : "unresolved";
|
|
421
|
-
Object.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
},
|
|
425
|
-
latest: {
|
|
426
|
-
get: () => read()
|
|
421
|
+
Object.defineProperty(read, "latest", {
|
|
422
|
+
get() {
|
|
423
|
+
return read();
|
|
427
424
|
}
|
|
428
425
|
});
|
|
429
426
|
function load() {
|
|
@@ -471,7 +468,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
471
468
|
p = null;
|
|
472
469
|
return ctx.resources[id].data;
|
|
473
470
|
}
|
|
474
|
-
if (
|
|
471
|
+
if (options.ssrValue !== "initial") load();
|
|
475
472
|
return resource.ref = [read, {
|
|
476
473
|
refetch: load,
|
|
477
474
|
mutate: v => value = v
|
package/dist/solid.cjs
CHANGED
|
@@ -256,7 +256,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
256
256
|
resolved = ("initialValue" in options),
|
|
257
257
|
dynamic = typeof source === "function" && createMemo(source);
|
|
258
258
|
const contexts = new Set(),
|
|
259
|
-
[value, setValue] =
|
|
259
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
260
260
|
[track, trigger] = createSignal(undefined, {
|
|
261
261
|
equals: false
|
|
262
262
|
}),
|
|
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
264
|
if (sharedConfig.context) {
|
|
265
265
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
266
266
|
let v;
|
|
267
|
-
if (options.
|
|
267
|
+
if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
268
268
|
}
|
|
269
269
|
function loadEnd(p, v, success, key) {
|
|
270
270
|
if (pr === p) {
|
|
@@ -344,9 +344,6 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
344
344
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
345
345
|
}
|
|
346
346
|
Object.defineProperties(read, {
|
|
347
|
-
value: {
|
|
348
|
-
get: () => value()
|
|
349
|
-
},
|
|
350
347
|
state: {
|
|
351
348
|
get: () => state()
|
|
352
349
|
},
|
package/dist/solid.js
CHANGED
|
@@ -252,7 +252,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
252
252
|
resolved = ("initialValue" in options),
|
|
253
253
|
dynamic = typeof source === "function" && createMemo(source);
|
|
254
254
|
const contexts = new Set(),
|
|
255
|
-
[value, setValue] =
|
|
255
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
256
256
|
[track, trigger] = createSignal(undefined, {
|
|
257
257
|
equals: false
|
|
258
258
|
}),
|
|
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
260
260
|
if (sharedConfig.context) {
|
|
261
261
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
262
262
|
let v;
|
|
263
|
-
if (options.
|
|
263
|
+
if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
264
264
|
}
|
|
265
265
|
function loadEnd(p, v, success, key) {
|
|
266
266
|
if (pr === p) {
|
|
@@ -340,9 +340,6 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
340
340
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
341
341
|
}
|
|
342
342
|
Object.defineProperties(read, {
|
|
343
|
-
value: {
|
|
344
|
-
get: () => value()
|
|
345
|
-
},
|
|
346
343
|
state: {
|
|
347
344
|
get: () => state()
|
|
348
345
|
},
|
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.5.0-beta.
|
|
4
|
+
"version": "1.5.0-beta.5",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
"require": "./dist/solid.cjs"
|
|
74
74
|
},
|
|
75
75
|
"./dist/*": "./dist/*",
|
|
76
|
+
"./jsx-runtime": {
|
|
77
|
+
"types": "./types/jsx.d.ts",
|
|
78
|
+
"default": "./dist/solid.js"
|
|
79
|
+
},
|
|
76
80
|
"./store": {
|
|
77
81
|
"browser": {
|
|
78
82
|
"development": {
|
|
@@ -197,7 +197,6 @@ export interface MemoOptions<T> extends EffectOptions {
|
|
|
197
197
|
export declare function createMemo<Next extends Prev, Prev = Next>(fn: EffectFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
|
|
198
198
|
export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(fn: EffectFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
|
|
199
199
|
interface Unresolved {
|
|
200
|
-
value: undefined;
|
|
201
200
|
state: "unresolved";
|
|
202
201
|
loading: false;
|
|
203
202
|
error: undefined;
|
|
@@ -205,7 +204,6 @@ interface Unresolved {
|
|
|
205
204
|
(): undefined;
|
|
206
205
|
}
|
|
207
206
|
interface Pending {
|
|
208
|
-
value: undefined;
|
|
209
207
|
state: "pending";
|
|
210
208
|
loading: true;
|
|
211
209
|
error: undefined;
|
|
@@ -213,7 +211,6 @@ interface Pending {
|
|
|
213
211
|
(): undefined;
|
|
214
212
|
}
|
|
215
213
|
interface Ready<T> {
|
|
216
|
-
value: T;
|
|
217
214
|
state: "ready";
|
|
218
215
|
loading: false;
|
|
219
216
|
error: undefined;
|
|
@@ -221,7 +218,6 @@ interface Ready<T> {
|
|
|
221
218
|
(): T;
|
|
222
219
|
}
|
|
223
220
|
interface Refreshing<T> {
|
|
224
|
-
value: T;
|
|
225
221
|
state: "refreshing";
|
|
226
222
|
loading: true;
|
|
227
223
|
error: undefined;
|
|
@@ -229,7 +225,6 @@ interface Refreshing<T> {
|
|
|
229
225
|
(): T;
|
|
230
226
|
}
|
|
231
227
|
interface Errored {
|
|
232
|
-
value: never;
|
|
233
228
|
state: "errored";
|
|
234
229
|
loading: false;
|
|
235
230
|
error: any;
|
|
@@ -252,8 +247,8 @@ export declare type ResourceOptions<T, S = unknown> = {
|
|
|
252
247
|
initialValue?: T;
|
|
253
248
|
name?: string;
|
|
254
249
|
deferStream?: boolean;
|
|
255
|
-
|
|
256
|
-
|
|
250
|
+
ssrValue?: "initial" | "server";
|
|
251
|
+
storage?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
|
|
257
252
|
onHydrated?: (k: S | undefined, info: {
|
|
258
253
|
value: T | undefined;
|
|
259
254
|
}) => void;
|
|
@@ -4,6 +4,7 @@ export declare const $DEVCOMP: unique symbol;
|
|
|
4
4
|
export declare const DEV: {};
|
|
5
5
|
export declare type Accessor<T> = () => T;
|
|
6
6
|
export declare 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;
|
|
7
|
+
export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
7
8
|
export declare const BRANCH: unique symbol;
|
|
8
9
|
export declare function castError(err: any): string | Error;
|
|
9
10
|
export declare let Owner: Owner | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Setter } from "./reactive.js";
|
|
1
|
+
import { Setter, Signal } from "./reactive.js";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
3
|
export declare type Component<P = {}> = (props: P) => JSX.Element;
|
|
4
4
|
export declare type VoidProps<P = {}> = P & {
|
|
@@ -72,7 +72,6 @@ export declare function ErrorBoundary(props: {
|
|
|
72
72
|
};
|
|
73
73
|
export interface Resource<T> {
|
|
74
74
|
(): T | undefined;
|
|
75
|
-
value: T | undefined;
|
|
76
75
|
state: "unresolved" | "pending" | "ready" | "refreshing" | "errored";
|
|
77
76
|
loading: boolean;
|
|
78
77
|
error: any;
|
|
@@ -101,13 +100,15 @@ export declare type ResourceOptions<T> = undefined extends T ? {
|
|
|
101
100
|
initialValue?: T;
|
|
102
101
|
name?: string;
|
|
103
102
|
deferStream?: boolean;
|
|
104
|
-
|
|
103
|
+
ssrValue?: "initial" | "server";
|
|
104
|
+
storage?: () => Signal<T | undefined>;
|
|
105
105
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
106
106
|
} : {
|
|
107
107
|
initialValue: T;
|
|
108
108
|
name?: string;
|
|
109
109
|
deferStream?: boolean;
|
|
110
|
-
|
|
110
|
+
ssrValue?: "initial" | "server";
|
|
111
|
+
storage?: (v?: T) => Signal<T | undefined>;
|
|
111
112
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
112
113
|
};
|
|
113
114
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
package/jsx-runtime.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./types/jsx"
|