solid-js 1.3.11 → 1.3.12
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/server.cjs +15 -11
- package/dist/server.js +15 -11
- package/package.json +2 -2
- package/types/server/reactive.d.ts +2 -1
- package/types/server/rendering.d.ts +26 -12
- package/web/dist/dev.cjs +14 -3
- package/web/dist/dev.js +14 -3
- package/web/dist/server.cjs +1 -1
- package/web/dist/server.js +1 -1
- package/web/dist/web.cjs +14 -3
- package/web/dist/web.js +14 -3
- package/web/types/server-mock.d.ts +6 -2
package/dist/server.cjs
CHANGED
|
@@ -331,16 +331,16 @@ function ErrorBoundary(props) {
|
|
|
331
331
|
}
|
|
332
332
|
const SuspenseContext = createContext();
|
|
333
333
|
let resourceContext = null;
|
|
334
|
-
function createResource(
|
|
334
|
+
function createResource(source, fetcher, options = {}) {
|
|
335
335
|
if (arguments.length === 2) {
|
|
336
336
|
if (typeof fetcher === "object") {
|
|
337
337
|
options = fetcher;
|
|
338
|
-
fetcher =
|
|
339
|
-
|
|
338
|
+
fetcher = source;
|
|
339
|
+
source = true;
|
|
340
340
|
}
|
|
341
341
|
} else if (arguments.length === 1) {
|
|
342
|
-
fetcher =
|
|
343
|
-
|
|
342
|
+
fetcher = source;
|
|
343
|
+
source = true;
|
|
344
344
|
}
|
|
345
345
|
const contexts = new Set();
|
|
346
346
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
@@ -372,23 +372,27 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
372
372
|
read.error = undefined;
|
|
373
373
|
function load() {
|
|
374
374
|
const ctx = sharedConfig.context;
|
|
375
|
-
if (!ctx.async) return read.loading = !!(typeof
|
|
375
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
376
376
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
377
377
|
value = ctx.resources[id].data;
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
380
|
resourceContext = [];
|
|
381
|
-
const lookup = typeof
|
|
381
|
+
const lookup = typeof source === "function" ? source() : source;
|
|
382
382
|
if (resourceContext.length) {
|
|
383
|
-
p = Promise.all(resourceContext).then(() => fetcher(
|
|
383
|
+
p = Promise.all(resourceContext).then(() => fetcher(source(), {
|
|
384
|
+
value
|
|
385
|
+
}));
|
|
384
386
|
}
|
|
385
387
|
resourceContext = null;
|
|
386
388
|
if (!p) {
|
|
387
389
|
if (lookup == null || lookup === false) return;
|
|
388
|
-
p = fetcher(lookup,
|
|
390
|
+
p = fetcher(lookup, {
|
|
391
|
+
value
|
|
392
|
+
});
|
|
389
393
|
}
|
|
390
|
-
|
|
391
|
-
|
|
394
|
+
if (p && "then" in p) {
|
|
395
|
+
read.loading = true;
|
|
392
396
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
393
397
|
return p.then(res => {
|
|
394
398
|
read.loading = false;
|
package/dist/server.js
CHANGED
|
@@ -327,16 +327,16 @@ function ErrorBoundary(props) {
|
|
|
327
327
|
}
|
|
328
328
|
const SuspenseContext = createContext();
|
|
329
329
|
let resourceContext = null;
|
|
330
|
-
function createResource(
|
|
330
|
+
function createResource(source, fetcher, options = {}) {
|
|
331
331
|
if (arguments.length === 2) {
|
|
332
332
|
if (typeof fetcher === "object") {
|
|
333
333
|
options = fetcher;
|
|
334
|
-
fetcher =
|
|
335
|
-
|
|
334
|
+
fetcher = source;
|
|
335
|
+
source = true;
|
|
336
336
|
}
|
|
337
337
|
} else if (arguments.length === 1) {
|
|
338
|
-
fetcher =
|
|
339
|
-
|
|
338
|
+
fetcher = source;
|
|
339
|
+
source = true;
|
|
340
340
|
}
|
|
341
341
|
const contexts = new Set();
|
|
342
342
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
@@ -368,23 +368,27 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
368
368
|
read.error = undefined;
|
|
369
369
|
function load() {
|
|
370
370
|
const ctx = sharedConfig.context;
|
|
371
|
-
if (!ctx.async) return read.loading = !!(typeof
|
|
371
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
372
372
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
373
373
|
value = ctx.resources[id].data;
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
376
|
resourceContext = [];
|
|
377
|
-
const lookup = typeof
|
|
377
|
+
const lookup = typeof source === "function" ? source() : source;
|
|
378
378
|
if (resourceContext.length) {
|
|
379
|
-
p = Promise.all(resourceContext).then(() => fetcher(
|
|
379
|
+
p = Promise.all(resourceContext).then(() => fetcher(source(), {
|
|
380
|
+
value
|
|
381
|
+
}));
|
|
380
382
|
}
|
|
381
383
|
resourceContext = null;
|
|
382
384
|
if (!p) {
|
|
383
385
|
if (lookup == null || lookup === false) return;
|
|
384
|
-
p = fetcher(lookup,
|
|
386
|
+
p = fetcher(lookup, {
|
|
387
|
+
value
|
|
388
|
+
});
|
|
385
389
|
}
|
|
386
|
-
|
|
387
|
-
|
|
390
|
+
if (p && "then" in p) {
|
|
391
|
+
read.loading = true;
|
|
388
392
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
389
393
|
return p.then(res => {
|
|
390
394
|
read.loading = false;
|
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.3.
|
|
4
|
+
"version": "1.3.12",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"compiler",
|
|
145
145
|
"performance"
|
|
146
146
|
],
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "e7671349791bd239fbe20c54c266ae085a7f09f2"
|
|
148
148
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Accessor, Setter } from "../reactive/signal";
|
|
2
1
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
3
2
|
export declare const $PROXY: unique symbol;
|
|
4
3
|
export declare const $DEVCOMP: unique symbol;
|
|
5
4
|
export declare const DEV: {};
|
|
5
|
+
export declare type Accessor<T> = () => T;
|
|
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;
|
|
6
7
|
export declare let Owner: Owner | null;
|
|
7
8
|
interface Owner {
|
|
8
9
|
owner: Owner | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Setter } from "./reactive";
|
|
1
2
|
import type { JSX } from "../jsx";
|
|
2
3
|
declare type PropsWithChildren<P> = P & {
|
|
3
4
|
children?: JSX.Element;
|
|
@@ -72,19 +73,32 @@ declare type SuspenseContextType = {
|
|
|
72
73
|
}>;
|
|
73
74
|
completed: () => void;
|
|
74
75
|
};
|
|
75
|
-
declare type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export declare
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
export declare type ResourceActions<T> = {
|
|
77
|
+
mutate: Setter<T>;
|
|
78
|
+
refetch: (info?: unknown) => void;
|
|
79
|
+
};
|
|
80
|
+
export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
81
|
+
export declare type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
82
|
+
export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
83
|
+
export declare type ResourceFetcherInfo<T> = {
|
|
84
|
+
value: T | undefined;
|
|
85
|
+
refetching?: unknown;
|
|
86
|
+
};
|
|
87
|
+
export declare type ResourceOptions<T> = undefined extends T ? {
|
|
86
88
|
initialValue?: T;
|
|
87
|
-
|
|
89
|
+
name?: string;
|
|
90
|
+
globalRefetch?: boolean;
|
|
91
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
92
|
+
} : {
|
|
93
|
+
initialValue: T;
|
|
94
|
+
name?: string;
|
|
95
|
+
globalRefetch?: boolean;
|
|
96
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
97
|
+
};
|
|
98
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
99
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
100
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
101
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
88
102
|
export declare function refetchResources(info?: unknown): void;
|
|
89
103
|
export declare function lazy(fn: () => Promise<{
|
|
90
104
|
default: any;
|
package/web/dist/dev.cjs
CHANGED
|
@@ -357,6 +357,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
357
357
|
multi = marker !== undefined;
|
|
358
358
|
parent = multi && current[0] && current[0].parentNode || parent;
|
|
359
359
|
if (t === "string" || t === "number") {
|
|
360
|
+
if (solidJs.sharedConfig.context) return current;
|
|
360
361
|
if (t === "number") value = value.toString();
|
|
361
362
|
if (multi) {
|
|
362
363
|
let node = current[0];
|
|
@@ -474,9 +475,19 @@ function NoHydration(props) {
|
|
|
474
475
|
return solidJs.sharedConfig.context ? undefined : props.children;
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
function throwInBrowser(func) {
|
|
479
|
+
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
|
|
480
|
+
console.error(err);
|
|
481
|
+
}
|
|
482
|
+
function renderToString(fn, options) {
|
|
483
|
+
throwInBrowser(renderToString);
|
|
484
|
+
}
|
|
485
|
+
function renderToStringAsync(fn, options) {
|
|
486
|
+
throwInBrowser(renderToStringAsync);
|
|
487
|
+
}
|
|
488
|
+
function renderToStream(fn, options) {
|
|
489
|
+
throwInBrowser(renderToStream);
|
|
490
|
+
}
|
|
480
491
|
function ssr(template, ...nodes) {}
|
|
481
492
|
function resolveSSRNode(node) {}
|
|
482
493
|
function ssrClassList(value) {}
|
package/web/dist/dev.js
CHANGED
|
@@ -354,6 +354,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
354
354
|
multi = marker !== undefined;
|
|
355
355
|
parent = multi && current[0] && current[0].parentNode || parent;
|
|
356
356
|
if (t === "string" || t === "number") {
|
|
357
|
+
if (sharedConfig.context) return current;
|
|
357
358
|
if (t === "number") value = value.toString();
|
|
358
359
|
if (multi) {
|
|
359
360
|
let node = current[0];
|
|
@@ -471,9 +472,19 @@ function NoHydration(props) {
|
|
|
471
472
|
return sharedConfig.context ? undefined : props.children;
|
|
472
473
|
}
|
|
473
474
|
|
|
474
|
-
function
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
function throwInBrowser(func) {
|
|
476
|
+
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
|
|
477
|
+
console.error(err);
|
|
478
|
+
}
|
|
479
|
+
function renderToString(fn, options) {
|
|
480
|
+
throwInBrowser(renderToString);
|
|
481
|
+
}
|
|
482
|
+
function renderToStringAsync(fn, options) {
|
|
483
|
+
throwInBrowser(renderToStringAsync);
|
|
484
|
+
}
|
|
485
|
+
function renderToStream(fn, options) {
|
|
486
|
+
throwInBrowser(renderToStream);
|
|
487
|
+
}
|
|
477
488
|
function ssr(template, ...nodes) {}
|
|
478
489
|
function resolveSSRNode(node) {}
|
|
479
490
|
function ssrClassList(value) {}
|
package/web/dist/server.cjs
CHANGED
|
@@ -233,7 +233,7 @@ function stringifyString(str) {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
|
|
236
|
-
const FRAGMENT_REPLACE = /<!\[([\d
|
|
236
|
+
const FRAGMENT_REPLACE = /<!\[([\d-]+)\]>/;
|
|
237
237
|
function renderToString(code, options = {}) {
|
|
238
238
|
let scripts = "";
|
|
239
239
|
solidJs.sharedConfig.context = {
|
package/web/dist/server.js
CHANGED
|
@@ -230,7 +230,7 @@ function stringifyString(str) {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
|
|
233
|
-
const FRAGMENT_REPLACE = /<!\[([\d
|
|
233
|
+
const FRAGMENT_REPLACE = /<!\[([\d-]+)\]>/;
|
|
234
234
|
function renderToString(code, options = {}) {
|
|
235
235
|
let scripts = "";
|
|
236
236
|
sharedConfig.context = {
|
package/web/dist/web.cjs
CHANGED
|
@@ -356,6 +356,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
356
356
|
multi = marker !== undefined;
|
|
357
357
|
parent = multi && current[0] && current[0].parentNode || parent;
|
|
358
358
|
if (t === "string" || t === "number") {
|
|
359
|
+
if (solidJs.sharedConfig.context) return current;
|
|
359
360
|
if (t === "number") value = value.toString();
|
|
360
361
|
if (multi) {
|
|
361
362
|
let node = current[0];
|
|
@@ -473,9 +474,19 @@ function NoHydration(props) {
|
|
|
473
474
|
return solidJs.sharedConfig.context ? undefined : props.children;
|
|
474
475
|
}
|
|
475
476
|
|
|
476
|
-
function
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
function throwInBrowser(func) {
|
|
478
|
+
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
|
|
479
|
+
console.error(err);
|
|
480
|
+
}
|
|
481
|
+
function renderToString(fn, options) {
|
|
482
|
+
throwInBrowser(renderToString);
|
|
483
|
+
}
|
|
484
|
+
function renderToStringAsync(fn, options) {
|
|
485
|
+
throwInBrowser(renderToStringAsync);
|
|
486
|
+
}
|
|
487
|
+
function renderToStream(fn, options) {
|
|
488
|
+
throwInBrowser(renderToStream);
|
|
489
|
+
}
|
|
479
490
|
function ssr(template, ...nodes) {}
|
|
480
491
|
function resolveSSRNode(node) {}
|
|
481
492
|
function ssrClassList(value) {}
|
package/web/dist/web.js
CHANGED
|
@@ -353,6 +353,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
353
353
|
multi = marker !== undefined;
|
|
354
354
|
parent = multi && current[0] && current[0].parentNode || parent;
|
|
355
355
|
if (t === "string" || t === "number") {
|
|
356
|
+
if (sharedConfig.context) return current;
|
|
356
357
|
if (t === "number") value = value.toString();
|
|
357
358
|
if (multi) {
|
|
358
359
|
let node = current[0];
|
|
@@ -470,9 +471,19 @@ function NoHydration(props) {
|
|
|
470
471
|
return sharedConfig.context ? undefined : props.children;
|
|
471
472
|
}
|
|
472
473
|
|
|
473
|
-
function
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
function throwInBrowser(func) {
|
|
475
|
+
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
|
|
476
|
+
console.error(err);
|
|
477
|
+
}
|
|
478
|
+
function renderToString(fn, options) {
|
|
479
|
+
throwInBrowser(renderToString);
|
|
480
|
+
}
|
|
481
|
+
function renderToStringAsync(fn, options) {
|
|
482
|
+
throwInBrowser(renderToStringAsync);
|
|
483
|
+
}
|
|
484
|
+
function renderToStream(fn, options) {
|
|
485
|
+
throwInBrowser(renderToStream);
|
|
486
|
+
}
|
|
476
487
|
function ssr(template, ...nodes) {}
|
|
477
488
|
function resolveSSRNode(node) {}
|
|
478
489
|
function ssrClassList(value) {}
|
|
@@ -10,8 +10,12 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
10
10
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
11
11
|
nonce?: string;
|
|
12
12
|
renderId?: string;
|
|
13
|
-
onCompleteShell?: (
|
|
14
|
-
|
|
13
|
+
onCompleteShell?: (info: {
|
|
14
|
+
write: (v: string) => void;
|
|
15
|
+
}) => void;
|
|
16
|
+
onCompleteAll?: (info: {
|
|
17
|
+
write: (v: string) => void;
|
|
18
|
+
}) => void;
|
|
15
19
|
}): {
|
|
16
20
|
pipe: (writable: {
|
|
17
21
|
write: (v: string) => void;
|