solid-js 1.5.0-beta.0 → 1.5.0-beta.1
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 +38 -9
- package/dist/server.js +38 -9
- package/h/types/hyperscript.d.ts +17 -0
- package/html/types/lit.d.ts +37 -0
- package/package.json +23 -21
- package/store/dist/dev.js +1 -1
- package/types/server/reactive.d.ts +5 -1
- package/types/server/rendering.d.ts +1 -0
- package/web/types/core.d.ts +2 -2
- package/web/types/index.d.ts +2 -2
- package/web/types/server.d.ts +70 -0
- package/h/README.md +0 -99
- package/h/jsx-runtime/package.json +0 -8
- package/h/package.json +0 -8
- package/html/README.md +0 -84
- package/html/package.json +0 -8
- package/store/README.md +0 -23
- package/store/package.json +0 -35
- package/universal/README.md +0 -102
- package/universal/package.json +0 -18
- package/web/README.md +0 -7
- package/web/package.json +0 -35
package/dist/server.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const $PROXY = Symbol("solid-proxy");
|
|
|
7
7
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
8
8
|
const DEV = {};
|
|
9
9
|
const ERROR = Symbol("error");
|
|
10
|
+
const BRANCH = Symbol("branch");
|
|
10
11
|
function castError(err) {
|
|
11
12
|
if (err instanceof Error || typeof err === "string") return err;
|
|
12
13
|
return new Error("Unknown error");
|
|
@@ -104,11 +105,25 @@ function on(deps, fn, options = {}) {
|
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
function onMount(fn) {}
|
|
107
|
-
function onCleanup(fn) {
|
|
108
|
+
function onCleanup(fn) {
|
|
109
|
+
let node;
|
|
110
|
+
if (Owner && (node = lookup(Owner, BRANCH))) {
|
|
111
|
+
if (!node.cleanups) node.cleanups = [fn];else node.cleanups.push(fn);
|
|
112
|
+
}
|
|
113
|
+
return fn;
|
|
114
|
+
}
|
|
115
|
+
function cleanNode(node) {
|
|
116
|
+
if (node.cleanups) {
|
|
117
|
+
for (let i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
|
|
118
|
+
node.cleanups = undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
108
121
|
function onError(fn) {
|
|
109
|
-
if (Owner
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
if (Owner) {
|
|
123
|
+
if (Owner.context === null) Owner.context = {
|
|
124
|
+
[ERROR]: [fn]
|
|
125
|
+
};else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
|
|
126
|
+
}
|
|
112
127
|
}
|
|
113
128
|
function getListener() {
|
|
114
129
|
return null;
|
|
@@ -213,9 +228,11 @@ function observable(input) {
|
|
|
213
228
|
function from(producer) {
|
|
214
229
|
const [s, set] = createSignal(undefined);
|
|
215
230
|
if ("subscribe" in producer) {
|
|
216
|
-
producer.subscribe(v => set(() => v));
|
|
231
|
+
const unsub = producer.subscribe(v => set(() => v));
|
|
232
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
217
233
|
} else {
|
|
218
|
-
producer(set);
|
|
234
|
+
const clean = producer(set);
|
|
235
|
+
onCleanup(clean);
|
|
219
236
|
}
|
|
220
237
|
return s;
|
|
221
238
|
}
|
|
@@ -230,7 +247,7 @@ function resolveSSRNode(node) {
|
|
|
230
247
|
for (let i = 0, len = node.length; i < len; i++) mapped += resolveSSRNode(node[i]);
|
|
231
248
|
return mapped;
|
|
232
249
|
}
|
|
233
|
-
if (t === "object") return
|
|
250
|
+
if (t === "object") return node.t;
|
|
234
251
|
if (t === "function") return resolveSSRNode(node());
|
|
235
252
|
return String(node);
|
|
236
253
|
}
|
|
@@ -321,12 +338,19 @@ function Match(props) {
|
|
|
321
338
|
}
|
|
322
339
|
function resetErrorBoundaries() {}
|
|
323
340
|
function ErrorBoundary(props) {
|
|
324
|
-
let error, res;
|
|
341
|
+
let error, res, clean;
|
|
325
342
|
const ctx = sharedConfig.context;
|
|
326
343
|
const id = ctx.id + ctx.count;
|
|
327
344
|
onError(err => error = err);
|
|
328
|
-
|
|
345
|
+
onCleanup(() => cleanNode(clean));
|
|
346
|
+
createMemo(() => {
|
|
347
|
+
Owner.context = {
|
|
348
|
+
[BRANCH]: clean = {}
|
|
349
|
+
};
|
|
350
|
+
return res = props.children;
|
|
351
|
+
});
|
|
329
352
|
if (error) {
|
|
353
|
+
cleanNode(clean);
|
|
330
354
|
ctx.writeResource(id, error, true);
|
|
331
355
|
setHydrateContext({ ...ctx,
|
|
332
356
|
count: 0
|
|
@@ -490,9 +514,13 @@ function SuspenseList(props) {
|
|
|
490
514
|
}
|
|
491
515
|
function Suspense(props) {
|
|
492
516
|
let done;
|
|
517
|
+
let clean;
|
|
493
518
|
const ctx = sharedConfig.context;
|
|
494
519
|
const id = ctx.id + ctx.count;
|
|
495
520
|
const o = Owner;
|
|
521
|
+
if (o.context) o.context[BRANCH] = clean = {};else o.context = {
|
|
522
|
+
[BRANCH]: clean = {}
|
|
523
|
+
};
|
|
496
524
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
497
525
|
resources: new Map(),
|
|
498
526
|
completed: () => {
|
|
@@ -510,6 +538,7 @@ function Suspense(props) {
|
|
|
510
538
|
return createComponent(SuspenseContext.Provider, {
|
|
511
539
|
value,
|
|
512
540
|
get children() {
|
|
541
|
+
cleanNode(clean);
|
|
513
542
|
return props.children;
|
|
514
543
|
}
|
|
515
544
|
});
|
package/dist/server.js
CHANGED
|
@@ -3,6 +3,7 @@ const $PROXY = Symbol("solid-proxy");
|
|
|
3
3
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
4
4
|
const DEV = {};
|
|
5
5
|
const ERROR = Symbol("error");
|
|
6
|
+
const BRANCH = Symbol("branch");
|
|
6
7
|
function castError(err) {
|
|
7
8
|
if (err instanceof Error || typeof err === "string") return err;
|
|
8
9
|
return new Error("Unknown error");
|
|
@@ -100,11 +101,25 @@ function on(deps, fn, options = {}) {
|
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
103
|
function onMount(fn) {}
|
|
103
|
-
function onCleanup(fn) {
|
|
104
|
+
function onCleanup(fn) {
|
|
105
|
+
let node;
|
|
106
|
+
if (Owner && (node = lookup(Owner, BRANCH))) {
|
|
107
|
+
if (!node.cleanups) node.cleanups = [fn];else node.cleanups.push(fn);
|
|
108
|
+
}
|
|
109
|
+
return fn;
|
|
110
|
+
}
|
|
111
|
+
function cleanNode(node) {
|
|
112
|
+
if (node.cleanups) {
|
|
113
|
+
for (let i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
|
|
114
|
+
node.cleanups = undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
104
117
|
function onError(fn) {
|
|
105
|
-
if (Owner
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
if (Owner) {
|
|
119
|
+
if (Owner.context === null) Owner.context = {
|
|
120
|
+
[ERROR]: [fn]
|
|
121
|
+
};else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
|
|
122
|
+
}
|
|
108
123
|
}
|
|
109
124
|
function getListener() {
|
|
110
125
|
return null;
|
|
@@ -209,9 +224,11 @@ function observable(input) {
|
|
|
209
224
|
function from(producer) {
|
|
210
225
|
const [s, set] = createSignal(undefined);
|
|
211
226
|
if ("subscribe" in producer) {
|
|
212
|
-
producer.subscribe(v => set(() => v));
|
|
227
|
+
const unsub = producer.subscribe(v => set(() => v));
|
|
228
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
213
229
|
} else {
|
|
214
|
-
producer(set);
|
|
230
|
+
const clean = producer(set);
|
|
231
|
+
onCleanup(clean);
|
|
215
232
|
}
|
|
216
233
|
return s;
|
|
217
234
|
}
|
|
@@ -226,7 +243,7 @@ function resolveSSRNode(node) {
|
|
|
226
243
|
for (let i = 0, len = node.length; i < len; i++) mapped += resolveSSRNode(node[i]);
|
|
227
244
|
return mapped;
|
|
228
245
|
}
|
|
229
|
-
if (t === "object") return
|
|
246
|
+
if (t === "object") return node.t;
|
|
230
247
|
if (t === "function") return resolveSSRNode(node());
|
|
231
248
|
return String(node);
|
|
232
249
|
}
|
|
@@ -317,12 +334,19 @@ function Match(props) {
|
|
|
317
334
|
}
|
|
318
335
|
function resetErrorBoundaries() {}
|
|
319
336
|
function ErrorBoundary(props) {
|
|
320
|
-
let error, res;
|
|
337
|
+
let error, res, clean;
|
|
321
338
|
const ctx = sharedConfig.context;
|
|
322
339
|
const id = ctx.id + ctx.count;
|
|
323
340
|
onError(err => error = err);
|
|
324
|
-
|
|
341
|
+
onCleanup(() => cleanNode(clean));
|
|
342
|
+
createMemo(() => {
|
|
343
|
+
Owner.context = {
|
|
344
|
+
[BRANCH]: clean = {}
|
|
345
|
+
};
|
|
346
|
+
return res = props.children;
|
|
347
|
+
});
|
|
325
348
|
if (error) {
|
|
349
|
+
cleanNode(clean);
|
|
326
350
|
ctx.writeResource(id, error, true);
|
|
327
351
|
setHydrateContext({ ...ctx,
|
|
328
352
|
count: 0
|
|
@@ -486,9 +510,13 @@ function SuspenseList(props) {
|
|
|
486
510
|
}
|
|
487
511
|
function Suspense(props) {
|
|
488
512
|
let done;
|
|
513
|
+
let clean;
|
|
489
514
|
const ctx = sharedConfig.context;
|
|
490
515
|
const id = ctx.id + ctx.count;
|
|
491
516
|
const o = Owner;
|
|
517
|
+
if (o.context) o.context[BRANCH] = clean = {};else o.context = {
|
|
518
|
+
[BRANCH]: clean = {}
|
|
519
|
+
};
|
|
492
520
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
493
521
|
resources: new Map(),
|
|
494
522
|
completed: () => {
|
|
@@ -506,6 +534,7 @@ function Suspense(props) {
|
|
|
506
534
|
return createComponent(SuspenseContext.Provider, {
|
|
507
535
|
value,
|
|
508
536
|
get children() {
|
|
537
|
+
cleanNode(clean);
|
|
509
538
|
return props.children;
|
|
510
539
|
}
|
|
511
540
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
|
+
interface Runtime {
|
|
3
|
+
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
4
|
+
spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
5
|
+
assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
6
|
+
createComponent(Comp: (props: any) => any, props: any): any;
|
|
7
|
+
dynamicProperty(props: any, key: string): any;
|
|
8
|
+
SVGElements: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
declare type ExpandableNode = Node & {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export declare type HyperScript = {
|
|
14
|
+
(...args: any[]): () => ExpandableNode | ExpandableNode[];
|
|
15
|
+
};
|
|
16
|
+
export declare function createHyperScript(r: Runtime): HyperScript;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
|
+
interface Runtime {
|
|
3
|
+
effect<T>(fn: (prev?: T) => T, init?: T): any;
|
|
4
|
+
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
5
|
+
spread<T>(node: Element, accessor: (() => T) | T, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
6
|
+
createComponent(Comp: (props: any) => any, props: any): any;
|
|
7
|
+
addEventListener(node: Element, name: string, handler: () => void, delegate: boolean): void;
|
|
8
|
+
delegateEvents(eventNames: string[]): void;
|
|
9
|
+
classList(node: Element, value: {
|
|
10
|
+
[k: string]: boolean;
|
|
11
|
+
}, prev?: {
|
|
12
|
+
[k: string]: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
style(node: Element, value: {
|
|
15
|
+
[k: string]: string;
|
|
16
|
+
}, prev?: {
|
|
17
|
+
[k: string]: string;
|
|
18
|
+
}): void;
|
|
19
|
+
mergeProps(...sources: unknown[]): unknown;
|
|
20
|
+
dynamicProperty(props: any, key: string): any;
|
|
21
|
+
setAttribute(node: Element, name: string, value: any): void;
|
|
22
|
+
setAttributeNS(node: Element, namespace: string, name: string, value: any): void;
|
|
23
|
+
Aliases: Record<string, string>;
|
|
24
|
+
PropAliases: Record<string, string>;
|
|
25
|
+
Properties: Set<string>;
|
|
26
|
+
ChildProperties: Set<string>;
|
|
27
|
+
DelegatedEvents: Set<string>;
|
|
28
|
+
SVGElements: Set<string>;
|
|
29
|
+
SVGNamespace: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export declare type HTMLTag = {
|
|
32
|
+
(statics: TemplateStringsArray, ...args: unknown[]): Node | Node[];
|
|
33
|
+
};
|
|
34
|
+
export declare function createHTML(r: Runtime, { delegateEvents }?: {
|
|
35
|
+
delegateEvents?: boolean | undefined;
|
|
36
|
+
}): HTMLTag;
|
|
37
|
+
export {};
|
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.1",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -124,24 +124,6 @@
|
|
|
124
124
|
},
|
|
125
125
|
"./html/dist/*": "./html/dist/*"
|
|
126
126
|
},
|
|
127
|
-
"scripts": {
|
|
128
|
-
"prebuild": "npm run clean",
|
|
129
|
-
"clean": "rimraf dist/ types/ coverage/ store/dist/ store/types/ web/dist/ web/types/ h/dist/ h/types/ h/jsx-runtime/dist h/jsx-runtime/types html/dist/ html/types/",
|
|
130
|
-
"build": "npm-run-all -cnl build:*",
|
|
131
|
-
"build:link": "symlink-dir . node_modules/solid-js",
|
|
132
|
-
"build:js": "ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/src/jsx.d.ts && rollup -c",
|
|
133
|
-
"build:types": "tsc --project ./tsconfig.build.json",
|
|
134
|
-
"build:types-store": "tsc --project ./store/tsconfig.build.json && tsconfig-replace-paths --project ./store/tsconfig.types.json",
|
|
135
|
-
"build:types-web": "tsc --project ./web/tsconfig.build.json && tsconfig-replace-paths --project ./web/tsconfig.types.json",
|
|
136
|
-
"build:types-html": "tsc --project ./html/tsconfig.json",
|
|
137
|
-
"build:types-h": "tsc --project ./h/tsconfig.json",
|
|
138
|
-
"build:types-jsx": "tsc --project ./h/jsx-runtime/tsconfig.json",
|
|
139
|
-
"build:types-universal": "tsc --project ./universal/tsconfig.json",
|
|
140
|
-
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
141
|
-
"test": "jest && npm run test:types",
|
|
142
|
-
"test:coverage": "jest --coverage && npm run test:types",
|
|
143
|
-
"test:types": "tsc --project tsconfig.test.json"
|
|
144
|
-
},
|
|
145
127
|
"keywords": [
|
|
146
128
|
"solid",
|
|
147
129
|
"solidjs",
|
|
@@ -151,5 +133,25 @@
|
|
|
151
133
|
"compiler",
|
|
152
134
|
"performance"
|
|
153
135
|
],
|
|
154
|
-
"
|
|
155
|
-
|
|
136
|
+
"scripts": {
|
|
137
|
+
"build": "npm-run-all -nl build:*",
|
|
138
|
+
"build:clean": "rimraf dist/ coverage/ store/dist/ web/dist/ h/dist/ h/jsx-runtime/dist html/dist/",
|
|
139
|
+
"build:js": "rollup -c",
|
|
140
|
+
"types": "npm-run-all -nl types:*",
|
|
141
|
+
"types:clean": "rimraf types/ store/types/ web/types/ h/types/ h/jsx-runtime/types html/types/",
|
|
142
|
+
"types:copy": "ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/src/jsx.d.ts",
|
|
143
|
+
"types:src": "tsc --project ./tsconfig.build.json && ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./types/jsx.d.ts",
|
|
144
|
+
"types:web": "tsc --project ./web/tsconfig.build.json",
|
|
145
|
+
"types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./web/types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./web/types/server.d.ts",
|
|
146
|
+
"types:store": "tsc --project ./store/tsconfig.build.json",
|
|
147
|
+
"types:html": "tsc --project ./html/tsconfig.json && ncp ../../node_modules/lit-dom-expressions/types/index.d.ts ./html/types/lit.d.ts",
|
|
148
|
+
"types:h": "tsc --project ./h/tsconfig.json && ncp ../../node_modules/hyper-dom-expressions/types/index.d.ts ./h/types/hyperscript.d.ts",
|
|
149
|
+
"types:jsx": "rimraf ./h/jsx-runtime/types && tsc --project ./h/jsx-runtime/tsconfig.json && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/types/jsx.d.ts",
|
|
150
|
+
"types:universal": "tsc --project ./universal/tsconfig.json && ncp ../../node_modules/dom-expressions/src/universal.d.ts ./universal/types/universal.d.ts",
|
|
151
|
+
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
152
|
+
"link": "symlink-dir . node_modules/solid-js",
|
|
153
|
+
"test": "jest",
|
|
154
|
+
"coverage": "jest --coverage",
|
|
155
|
+
"test-types": "tsc --project tsconfig.test.json"
|
|
156
|
+
}
|
|
157
|
+
}
|
package/store/dist/dev.js
CHANGED
|
@@ -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 const BRANCH: unique symbol;
|
|
7
8
|
export declare function castError(err: any): string | Error;
|
|
8
9
|
export declare let Owner: Owner | null;
|
|
9
10
|
interface Owner {
|
|
@@ -28,7 +29,10 @@ export declare function on<T, U>(deps: Array<() => T> | (() => T), fn: (value: A
|
|
|
28
29
|
defer?: boolean;
|
|
29
30
|
}): (prev?: U) => U | undefined;
|
|
30
31
|
export declare function onMount(fn: () => void): void;
|
|
31
|
-
export declare function onCleanup(fn: () => void): void;
|
|
32
|
+
export declare function onCleanup(fn: () => void): () => void;
|
|
33
|
+
export declare function cleanNode(node: {
|
|
34
|
+
cleanups?: Function[] | null;
|
|
35
|
+
}): void;
|
|
32
36
|
export declare function onError(fn: (err: any) => void): void;
|
|
33
37
|
export declare function getListener(): null;
|
|
34
38
|
export interface Context<T> {
|
package/web/types/core.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig } from "
|
|
2
|
-
declare function memo<T>(fn: () => T, equals: boolean): import("
|
|
1
|
+
import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig } from "solid-js";
|
|
2
|
+
declare function memo<T>(fn: () => T, equals: boolean): import("solid-js").Accessor<T>;
|
|
3
3
|
export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, memo, sharedConfig };
|
package/web/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hydrate as hydrateCore } from "./client";
|
|
2
|
-
import { JSX, Accessor, ComponentProps, ValidComponent } from "
|
|
2
|
+
import { JSX, Accessor, ComponentProps, ValidComponent } from "solid-js";
|
|
3
3
|
export * from "./client";
|
|
4
|
-
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "
|
|
4
|
+
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "solid-js";
|
|
5
5
|
export * from "./server-mock";
|
|
6
6
|
export declare const isServer = false;
|
|
7
7
|
export declare const hydrate: typeof hydrateCore;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function renderToString<T>(
|
|
2
|
+
fn: () => T,
|
|
3
|
+
options?: {
|
|
4
|
+
nonce?: string;
|
|
5
|
+
renderId?: string;
|
|
6
|
+
}
|
|
7
|
+
): string;
|
|
8
|
+
export function renderToStringAsync<T>(
|
|
9
|
+
fn: () => T,
|
|
10
|
+
options?: {
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
nonce?: string;
|
|
13
|
+
renderId?: string;
|
|
14
|
+
}
|
|
15
|
+
): Promise<string>;
|
|
16
|
+
export function renderToStream<T>(
|
|
17
|
+
fn: () => T,
|
|
18
|
+
options?: {
|
|
19
|
+
nonce?: string;
|
|
20
|
+
renderId?: string;
|
|
21
|
+
onCompleteShell?: (info: { write: (v: string) => void }) => void;
|
|
22
|
+
onCompleteAll?: (info: { write: (v: string) => void }) => void;
|
|
23
|
+
}
|
|
24
|
+
): {
|
|
25
|
+
pipe: (writable: { write: (v: string) => void }) => void;
|
|
26
|
+
pipeTo: (writable: WritableStream) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function Assets(props: { children?: JSX.Element }): JSX.Element;
|
|
30
|
+
export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
|
|
31
|
+
export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
|
|
32
|
+
export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
|
|
33
|
+
export function ssrElement(name: string, props: any, children: any, needsId: boolean): { t: string };
|
|
34
|
+
export function ssrClassList(value: { [k: string]: boolean }): string;
|
|
35
|
+
export function ssrStyle(value: { [k: string]: string }): string;
|
|
36
|
+
export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
|
|
37
|
+
export function ssrHydrationKey(): string;
|
|
38
|
+
export function resolveSSRNode(node: any): string;
|
|
39
|
+
export function escape(html: string): string;
|
|
40
|
+
export function getHydrationKey(): string;
|
|
41
|
+
export function effect<T>(fn: (prev?: T) => T, init?: T): void;
|
|
42
|
+
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
43
|
+
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
44
|
+
export function mergeProps(...sources: unknown[]): unknown;
|
|
45
|
+
export function getOwner(): unknown;
|
|
46
|
+
export function generateHydrationScript(options: { nonce?: string; eventNames?: string[] }): string;
|
|
47
|
+
|
|
48
|
+
// deprecated
|
|
49
|
+
export type LegacyResults = {
|
|
50
|
+
write: (text: string) => void;
|
|
51
|
+
startWriting: () => void;
|
|
52
|
+
};
|
|
53
|
+
export function pipeToWritable<T>(
|
|
54
|
+
fn: () => T,
|
|
55
|
+
writable: WritableStream,
|
|
56
|
+
options?: {
|
|
57
|
+
nonce?: string;
|
|
58
|
+
onReady?: (res: LegacyResults) => void;
|
|
59
|
+
onCompleteAll?: () => void;
|
|
60
|
+
}
|
|
61
|
+
): void;
|
|
62
|
+
export function pipeToNodeWritable<T>(
|
|
63
|
+
fn: () => T,
|
|
64
|
+
writable: { write: (v: string) => void },
|
|
65
|
+
options?: {
|
|
66
|
+
nonce?: string;
|
|
67
|
+
onReady?: (res: LegacyResults) => void;
|
|
68
|
+
onCompleteAll?: () => void;
|
|
69
|
+
}
|
|
70
|
+
): void;
|
package/h/README.md
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# Solid HyperScript
|
|
2
|
-
|
|
3
|
-
This sub module provides a HyperScript method for Solid. This is useful to use Solid in non-compiled environments or in some environments where you can only use a standard JSX transform. This method can be used as the JSX factory function.
|
|
4
|
-
|
|
5
|
-
HyperScript function takes a few forms. The 2nd props argument is optional. Children may be passed as either an array to the 2nd/3rd argument or as every argument past the 2nd.
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
// create an element with a title attribute
|
|
9
|
-
h("button", { title: "My button" }, "Click Me")
|
|
10
|
-
|
|
11
|
-
// create a component with a title prop
|
|
12
|
-
h(Button, { title: "My button" }, "Click Me")
|
|
13
|
-
|
|
14
|
-
// create an element with many children
|
|
15
|
-
h("div", { title: "My button" }, h("span", "1"), h("span", "2"), h("span", "3"))
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
This is the least efficient way to use Solid as it requires a slightly larger runtime that isn't treeshakebable, and cannot leverage anything in the way of analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
|
|
19
|
-
|
|
20
|
-
## Example
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
import { render } from "solid-js/web";
|
|
24
|
-
import h from "solid-js/h";
|
|
25
|
-
import { createSignal } from "solid-js";
|
|
26
|
-
|
|
27
|
-
function Button(props) {
|
|
28
|
-
return h("button.btn-primary", props)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function Counter() {
|
|
32
|
-
const [count, setCount] = createSignal(0);
|
|
33
|
-
const increment = (e) => setCount(c => c + 1);
|
|
34
|
-
|
|
35
|
-
return h(Button, { type: "button", onClick: increment }, count);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
render(Counter, document.getElementById("app"));
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Differences from JSX
|
|
42
|
-
|
|
43
|
-
There are a few differences from Solid's JSX that are important to note. And also apply when attempting use any transformation that would compile to HyperScript.
|
|
44
|
-
|
|
45
|
-
1. Reactive expression must be manually wrapped in functions to be reactive.
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
// jsx
|
|
49
|
-
<div id={props.id}>{firstName() + lastName()}</div>
|
|
50
|
-
|
|
51
|
-
// hyperscript
|
|
52
|
-
h("div", { id: () => props.id }, () => firstName() + lastName())
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
2. Merging spreads requires using the merge props helper to keep reactivity
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
// jsx
|
|
59
|
-
<div class={selectedClass()} {...props} />
|
|
60
|
-
|
|
61
|
-
// hyperscript
|
|
62
|
-
import { mergeProps } from "solid-js"
|
|
63
|
-
|
|
64
|
-
h("div", mergeProps({ class: selectedClass }, props))
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
3. Events on components require explicit event in the arguments
|
|
68
|
-
|
|
69
|
-
Solid's HyperScript automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
// good
|
|
73
|
-
h(Button, { onClick: (e) => console.log("Hi")});
|
|
74
|
-
|
|
75
|
-
// bad
|
|
76
|
-
h(Button, { onClick: () => console.log("Hi")})
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
4. All refs are callback form
|
|
80
|
-
|
|
81
|
-
We can't do the compiled assigment trick so only the callback form is supported.
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
let myEl;
|
|
85
|
-
|
|
86
|
-
h(div, { ref: (el) => myEl = el });
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
5. There is a shorthand for static id and classes
|
|
90
|
-
|
|
91
|
-
```js
|
|
92
|
-
h("div#some-id.my-class")
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
6. Fragments are just arrays
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
[h("span", "1"), h("span", "2")]
|
|
99
|
-
```
|
package/h/package.json
DELETED
package/html/README.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Solid Tagged Template Literals
|
|
2
|
-
|
|
3
|
-
This sub module provides a Tagged Template Literal `html` method for Solid. This is useful to use Solid in non-compiled environments. This method can be used as replacement for JSX.
|
|
4
|
-
|
|
5
|
-
`html` uses `${}` to escape into JavaScript expressions. Components are closed with `<//>`
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
// create an element with a title attribute
|
|
9
|
-
html`<button title="My button">Click Me</button>`
|
|
10
|
-
|
|
11
|
-
// create a component with a title prop
|
|
12
|
-
html`<${Button} title="My button">Click me<//>`
|
|
13
|
-
|
|
14
|
-
// create an element with dynamic attribute and spread
|
|
15
|
-
html`<div title=${() => selectedClass()} ...${props} />`
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Using `html` is slightly less efficient than JSX(but more than HyperScript), requires a larger runtime that isn't treeshakebable, and cannot leverage expression analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
|
|
19
|
-
|
|
20
|
-
## Example
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
import { render } from "solid-js/web";
|
|
24
|
-
import html from "solid-js/html";
|
|
25
|
-
import { createSignal } from "solid-js";
|
|
26
|
-
|
|
27
|
-
function Button(props) {
|
|
28
|
-
return html`<button class="btn-primary" ...${props} />`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function Counter() {
|
|
32
|
-
const [count, setCount] = createSignal(0);
|
|
33
|
-
const increment = (e) => setCount((c) => c + 1);
|
|
34
|
-
|
|
35
|
-
return html`<${Button} type="button" onClick=${increment}>${count}<//>`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
render(Counter, document.getElementById("app"));
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Differences from JSX
|
|
42
|
-
|
|
43
|
-
There are a few differences from Solid's JSX that are important to note.
|
|
44
|
-
|
|
45
|
-
1. Reactive expression must be manually wrapped in functions to be reactive.
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
// jsx
|
|
49
|
-
<div id={props.id}>{firstName() + lastName()}</div>
|
|
50
|
-
|
|
51
|
-
// hyperscript
|
|
52
|
-
html`<div id=${() => props.id}>${() => firstName() + lastName()}</div>`
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
2. Events on components require explicit event in the arguments
|
|
56
|
-
|
|
57
|
-
Solid's Tagged Template Literals automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
|
|
58
|
-
|
|
59
|
-
```js
|
|
60
|
-
// good
|
|
61
|
-
html`<${Button} onClick=${(e) => console.log("Hi")} />`;
|
|
62
|
-
|
|
63
|
-
// bad
|
|
64
|
-
html`<${Button} onClick=${() => console.log("Hi")} />`;
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
4. All refs are callback form
|
|
68
|
-
|
|
69
|
-
We can't do the compiled assigment trick so only the callback form is supported.
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
let myEl;
|
|
73
|
-
html`<div ref=${(el) => myEl = el} />`;
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
5. There can be multiple top level elements
|
|
77
|
-
|
|
78
|
-
No need for fragments just:
|
|
79
|
-
```js
|
|
80
|
-
html`
|
|
81
|
-
<div>1</div>
|
|
82
|
-
<div>2</div>
|
|
83
|
-
`
|
|
84
|
-
```
|
package/html/package.json
DELETED
package/store/README.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Solid Store
|
|
2
|
-
|
|
3
|
-
This submodules contains the means for handling deeps nested reactivity. It provides 2 main primitives `createStore` and `createMutable` which leverage proxies to create dynamic nested reactive structures.
|
|
4
|
-
|
|
5
|
-
This also contains helper methods `produce` and `reconcile` which augment the behavior of the store setter method to allow for localized mutation and data diffing.
|
|
6
|
-
|
|
7
|
-
For full documentation, check out the [website](https://www.solidjs.com/docs/latest/api).
|
|
8
|
-
|
|
9
|
-
## Example
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
import { createStore } from "solid-js/store";
|
|
13
|
-
|
|
14
|
-
const [store, setStore] = createStore({
|
|
15
|
-
user: {
|
|
16
|
-
firstName: "John",
|
|
17
|
-
lastName: "Smith"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// update store.user.firstName
|
|
22
|
-
setStore("user", "firstName", "Will");
|
|
23
|
-
```
|
package/store/package.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "solid-js/store",
|
|
3
|
-
"main": "./dist/server.cjs",
|
|
4
|
-
"module": "./dist/server.js",
|
|
5
|
-
"browser": {
|
|
6
|
-
"./dist/server.cjs": "./dist/store.cjs",
|
|
7
|
-
"./dist/server.js": "./dist/store.js"
|
|
8
|
-
},
|
|
9
|
-
"unpkg": "./dist/store.cjs",
|
|
10
|
-
"types": "./types/index.d.ts",
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"browser": {
|
|
16
|
-
"development": {
|
|
17
|
-
"import": "./dist/dev.js",
|
|
18
|
-
"require": "./dist/dev.cjs"
|
|
19
|
-
},
|
|
20
|
-
"import": "./dist/store.js",
|
|
21
|
-
"require": "./dist/store.cjs"
|
|
22
|
-
},
|
|
23
|
-
"node": {
|
|
24
|
-
"import": "./dist/server.js",
|
|
25
|
-
"require": "./dist/server.cjs"
|
|
26
|
-
},
|
|
27
|
-
"development": {
|
|
28
|
-
"import": "./dist/dev.js",
|
|
29
|
-
"require": "./dist/dev.cjs"
|
|
30
|
-
},
|
|
31
|
-
"import": "./dist/store.js",
|
|
32
|
-
"require": "./dist/store.cjs"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
package/universal/README.md
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Solid Universal
|
|
2
|
-
|
|
3
|
-
This contains the means to create the runtime for a custom renderer for Solid. This can enable using Solid to render to different platforms like native mobile and desktop, canvas or WebGL, or even the terminal. It relies on custom compilation from `babel-preset-solid` and exporting the result of `createRenderer` at a referenceable location.
|
|
4
|
-
|
|
5
|
-
## Example
|
|
6
|
-
|
|
7
|
-
To use a custom renderer available in the (fictional) `solid-custom-dom` package you'd configure your babelrc as:
|
|
8
|
-
```json
|
|
9
|
-
{
|
|
10
|
-
"presets": [
|
|
11
|
-
[
|
|
12
|
-
"babel-preset-solid",
|
|
13
|
-
{
|
|
14
|
-
"moduleName": "solid-custom-dom",
|
|
15
|
-
"generate": "universal"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
To create a custom renderer you must implement certain methods and export (as named exports) the results. You may also want to forward `solid-js` control flow to allow them to be auto imported as well.
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
// example custom dom renderer
|
|
26
|
-
import { createRenderer } from "solid-js/universal";
|
|
27
|
-
|
|
28
|
-
const PROPERTIES = new Set(["className", "textContent"]);
|
|
29
|
-
|
|
30
|
-
export const {
|
|
31
|
-
render,
|
|
32
|
-
effect,
|
|
33
|
-
memo,
|
|
34
|
-
createComponent,
|
|
35
|
-
createElement,
|
|
36
|
-
createTextNode,
|
|
37
|
-
insertNode,
|
|
38
|
-
insert,
|
|
39
|
-
spread,
|
|
40
|
-
setProp,
|
|
41
|
-
mergeProps
|
|
42
|
-
} = createRenderer({
|
|
43
|
-
createElement(string) {
|
|
44
|
-
return document.createElement(string);
|
|
45
|
-
},
|
|
46
|
-
createTextNode(value) {
|
|
47
|
-
return document.createTextNode(value);
|
|
48
|
-
},
|
|
49
|
-
replaceText(textNode, value) {
|
|
50
|
-
textNode.data = value;
|
|
51
|
-
},
|
|
52
|
-
setProperty(node, name, value) {
|
|
53
|
-
if (name === "style") Object.assign(node.style, value);
|
|
54
|
-
else if (name.startsWith("on")) node[name.toLowerCase()] = value;
|
|
55
|
-
else if (PROPERTIES.has(name)) node[name] = value;
|
|
56
|
-
else node.setAttribute(name, value);
|
|
57
|
-
},
|
|
58
|
-
insertNode(parent, node, anchor) {
|
|
59
|
-
parent.insertBefore(node, anchor);
|
|
60
|
-
},
|
|
61
|
-
isTextNode(node) {
|
|
62
|
-
return node.type === 3;
|
|
63
|
-
},
|
|
64
|
-
removeNode(parent, node) {
|
|
65
|
-
parent.removeChild(node);
|
|
66
|
-
},
|
|
67
|
-
getParentNode(node) {
|
|
68
|
-
return node.parentNode;
|
|
69
|
-
},
|
|
70
|
-
getFirstChild(node) {
|
|
71
|
-
return node.firstChild;
|
|
72
|
-
},
|
|
73
|
-
getNextSibling(node) {
|
|
74
|
-
return node.nextSibling;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Forward Solid control flow
|
|
79
|
-
export {
|
|
80
|
-
For,
|
|
81
|
-
Show,
|
|
82
|
-
Suspense,
|
|
83
|
-
SuspenseList,
|
|
84
|
-
Switch,
|
|
85
|
-
Match,
|
|
86
|
-
Index,
|
|
87
|
-
ErrorBoundary
|
|
88
|
-
} from "solid-js";
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Then to consume:
|
|
92
|
-
```js
|
|
93
|
-
import { render } from "solid-custom-dom";
|
|
94
|
-
|
|
95
|
-
function App() {
|
|
96
|
-
// the skies the limits
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
render(() => <App />, mountNode)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
> Note: For TypeScript support of non-standard JSX you will need to provide your own types at a jsx-runtime entry on your package so that it can be set as the `jsxImportSource`. If mixing and matching different JSX implementations you will need use the per file pragmas.
|
package/universal/package.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "solid-js/universal",
|
|
3
|
-
"main": "./dist/universal.cjs",
|
|
4
|
-
"module": "./dist/universal.js",
|
|
5
|
-
"types": "./types/index.d.ts",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"development": {
|
|
11
|
-
"import": "./dist/dev.js",
|
|
12
|
-
"require": "./dist/dev.cjs"
|
|
13
|
-
},
|
|
14
|
-
"import": "./dist/universal.js",
|
|
15
|
-
"require": "./dist/universal.cjs"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/web/README.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Solid Web
|
|
2
|
-
|
|
3
|
-
This submodule contains the web specific APIs for Solid that are mostly internal methods imported during compilation. It has all the code to render for the web on the server and the browser.
|
|
4
|
-
|
|
5
|
-
In addition this modules provides the primary entry point methods `render`, `hydrate`, `renderToString`, `renderToStringAsync`, `pipeToNodeWritable`, and `pipeToWritable`. As well as a few web specific control flow components `<Portal>` and `<Dynamic>`.
|
|
6
|
-
|
|
7
|
-
Refer to the [website](https://www.solidjs.com/docs/latest/api) for documentation.
|
package/web/package.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "solid-js/web",
|
|
3
|
-
"main": "./dist/server.cjs",
|
|
4
|
-
"module": "./dist/server.js",
|
|
5
|
-
"browser": {
|
|
6
|
-
"./dist/server.cjs": "./dist/web.cjs",
|
|
7
|
-
"./dist/server.js": "./dist/web.js"
|
|
8
|
-
},
|
|
9
|
-
"unpkg": "./dist/web.cjs",
|
|
10
|
-
"types": "./types/index.d.ts",
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"browser": {
|
|
16
|
-
"development": {
|
|
17
|
-
"import": "./dist/dev.js",
|
|
18
|
-
"require": "./dist/dev.cjs"
|
|
19
|
-
},
|
|
20
|
-
"import": "./dist/web.js",
|
|
21
|
-
"require": "./dist/web.cjs"
|
|
22
|
-
},
|
|
23
|
-
"node": {
|
|
24
|
-
"import": "./dist/server.js",
|
|
25
|
-
"require": "./dist/server.cjs"
|
|
26
|
-
},
|
|
27
|
-
"development": {
|
|
28
|
-
"import": "./dist/dev.js",
|
|
29
|
-
"require": "./dist/dev.cjs"
|
|
30
|
-
},
|
|
31
|
-
"import": "./dist/web.js",
|
|
32
|
-
"require": "./dist/web.cjs"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|