@solidjs/web 2.0.0-experimental.0

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/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@solidjs/web",
3
+ "description": "Solid's web runtime for the browser and the server",
4
+ "version": "2.0.0-experimental.0",
5
+ "author": "Ryan Carniato",
6
+ "license": "MIT",
7
+ "homepage": "https://solidjs.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/solidjs/solid-web"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "main": "./dist/server.cjs",
16
+ "module": "./dist/server.js",
17
+ "unpkg": "./dist/web.cjs",
18
+ "types": "./types/index.d.ts",
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "package.json",
25
+ "storage/dist",
26
+ "storage/types",
27
+ "storage/package.json"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "worker": {
32
+ "types": "./types/index.d.ts",
33
+ "import": "./dist/server.js",
34
+ "require": "./dist/server.cjs"
35
+ },
36
+ "browser": {
37
+ "development": {
38
+ "types": "./types/index.d.ts",
39
+ "import": "./dist/dev.js",
40
+ "require": "./dist/dev.cjs"
41
+ },
42
+ "types": "./types/index.d.ts",
43
+ "import": "./dist/web.js",
44
+ "require": "./dist/web.cjs"
45
+ },
46
+ "deno": {
47
+ "types": "./types/index.d.ts",
48
+ "import": "./dist/server.js",
49
+ "require": "./dist/server.cjs"
50
+ },
51
+ "node": {
52
+ "types": "./types/index.d.ts",
53
+ "import": "./dist/server.js",
54
+ "require": "./dist/server.cjs"
55
+ },
56
+ "development": {
57
+ "types": "./types/index.d.ts",
58
+ "import": "./dist/dev.js",
59
+ "require": "./dist/dev.cjs"
60
+ },
61
+ "types": "./types/index.d.ts",
62
+ "import": "./dist/web.js",
63
+ "require": "./dist/web.cjs"
64
+ },
65
+ "./storage": {
66
+ "types": "./storage/types/index.d.ts",
67
+ "import": "./storage/dist/storage.js",
68
+ "require": "./storage/dist/storage.cjs"
69
+ },
70
+ "./dist/*": "./dist/*",
71
+ "./types/*": "./types/*"
72
+ },
73
+ "dependencies": {
74
+ "seroval": "^1.1.0",
75
+ "seroval-plugins": "^1.1.0"
76
+ },
77
+ "peerDependencies": {
78
+ "solid-js": "^2.0.0-experimental.0"
79
+ },
80
+ "devDependencies": {
81
+ "solid-js": "2.0.0-experimental.0"
82
+ },
83
+ "scripts": {
84
+ "build": "npm-run-all -nl build:*",
85
+ "build:clean": "rimraf dist/",
86
+ "build:js": "rollup -c",
87
+ "link": "symlink-dir . node_modules/@solidjs/web",
88
+ "types": "npm-run-all -nl types:*",
89
+ "types:clean": "rimraf types/",
90
+ "types:web": "tsc --project ./tsconfig.build.json",
91
+ "types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./types/server.d.ts",
92
+ "types:web-storage": "tsc --project ./storage/tsconfig.build.json",
93
+ "test": "vitest run",
94
+ "coverage": "vitest run --coverage",
95
+ "test-types": "tsc --project tsconfig.test.json"
96
+ }
97
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var node_async_hooks = require('node:async_hooks');
4
+ var web = require('@solidjs/web');
5
+
6
+ function provideRequestEvent(init, cb) {
7
+ if (!web.isServer) throw new Error("Attempting to use server context in non-server build");
8
+ const ctx = globalThis[web.RequestContext] = globalThis[web.RequestContext] || new node_async_hooks.AsyncLocalStorage();
9
+ return ctx.run(init, cb);
10
+ }
11
+
12
+ exports.provideRequestEvent = provideRequestEvent;
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { isServer, RequestContext } from "@solidjs/web";
3
+
4
+ function provideRequestEvent(init, cb) {
5
+ if (!isServer) throw new Error("Attempting to use server context in non-server build");
6
+ const ctx = (globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage());
7
+ return ctx.run(init, cb);
8
+ }
9
+
10
+ export { provideRequestEvent };
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@solidjs/web/storage",
3
+ "main": "./dist/storage.cjs",
4
+ "module": "./dist/storage.js",
5
+ "types": "./types/index.d.ts",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "import": "./dist/storage.js",
12
+ "require": "./dist/storage.cjs"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ import type { RequestEvent } from "@solidjs/web";
2
+ export declare function provideRequestEvent<T extends RequestEvent, U>(init: T, cb: () => U): U;
@@ -0,0 +1,85 @@
1
+ import { JSX } from "./jsx.js";
2
+ export const Properties: Set<string>;
3
+ export const ChildProperties: Set<string>;
4
+ export const DelegatedEvents: Set<string>;
5
+ export const DOMElements: Set<string>;
6
+ export const SVGElements: Set<string>;
7
+ export const SVGNamespace: Record<string, string>;
8
+ export function getPropAlias(prop: string, tagName: string): string | undefined;
9
+
10
+ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
11
+ export function render(code: () => JSX.Element, element: MountableElement): () => void;
12
+ export function template(html: string, isCE?: boolean, isSVG?: boolean): () => Element;
13
+ export function effect<T>(
14
+ fn: (prev?: T) => T,
15
+ effect: (value: T, prev?: T) => void,
16
+ init?: T
17
+ ): void;
18
+ export function memo<T>(fn: () => T, equal: boolean): () => T;
19
+ export function untrack<T>(fn: () => T): T;
20
+ export function insert<T>(
21
+ parent: MountableElement,
22
+ accessor: (() => T) | T,
23
+ marker?: Node | null,
24
+ init?: JSX.Element
25
+ ): JSX.Element;
26
+ export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
27
+ export function delegateEvents(eventNames: string[], d?: Document): void;
28
+ export function clearDelegatedEvents(d?: Document): void;
29
+ export function spread<T>(
30
+ node: Element,
31
+ accessor: T,
32
+ isSVG?: Boolean,
33
+ skipChildren?: Boolean
34
+ ): void;
35
+ export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
36
+ export function setAttribute(node: Element, name: string, value: string): void;
37
+ export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
38
+ export function setBoolAttribute(node: Element, name: string, value: any): void;
39
+ type ClassList =
40
+ | Record<string, boolean>
41
+ | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
42
+ export function className(
43
+ node: Element,
44
+ value: string | ClassList,
45
+ isSvg?: boolean,
46
+ prev?: string | ClassList
47
+ ): void;
48
+ export function setProperty(node: Element, name: string, value: any): void;
49
+ export function addEventListener(
50
+ node: Element,
51
+ name: string,
52
+ handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
53
+ delegate: boolean
54
+ ): void;
55
+ export function style(
56
+ node: Element,
57
+ value: { [k: string]: string },
58
+ prev?: { [k: string]: string }
59
+ ): void;
60
+ export function getOwner(): unknown;
61
+ export function mergeProps(...sources: unknown[]): unknown;
62
+ export function dynamicProperty(props: unknown, key: string): unknown;
63
+
64
+ export function hydrate(
65
+ fn: () => JSX.Element,
66
+ node: MountableElement,
67
+ options?: { renderId?: string; owner?: unknown }
68
+ ): () => void;
69
+ export function getHydrationKey(): string;
70
+ export function getNextElement(template?: HTMLTemplateElement): Element;
71
+ export function getNextMatch(start: Node, elementName: string): Element;
72
+ export function getNextMarker(start: Node): [Node, Array<Node>];
73
+ export function useAssets(fn: () => JSX.Element): void;
74
+ export function getAssets(): string;
75
+ export function HydrationScript(): JSX.Element;
76
+ export function generateHydrationScript(): string;
77
+ export function Assets(props: { children?: JSX.Element }): JSX.Element;
78
+ export function Hydration(props: { children?: JSX.Element }): JSX.Element;
79
+ export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
80
+ export interface RequestEvent {
81
+ request: Request;
82
+ }
83
+ export declare const RequestContext: unique symbol;
84
+ export function getRequestEvent(): RequestEvent | undefined;
85
+ export function runHydrationEvents(): void;
@@ -0,0 +1,11 @@
1
+ export {
2
+ getOwner,
3
+ createComponent,
4
+ createRoot as root,
5
+ createRenderEffect as effect,
6
+ createMemo as memo,
7
+ sharedConfig,
8
+ untrack,
9
+ merge as mergeProps,
10
+ flatten
11
+ } from "solid-js";
@@ -0,0 +1,32 @@
1
+ import { hydrate as hydrateCore } from "./client.js";
2
+ import { JSX, ComponentProps, ValidComponent } from "solid-js";
3
+ export * from "./client.js";
4
+ export { For, Show, Suspense, Switch, Match, ErrorBoundary, merge as mergeProps } from "solid-js";
5
+ export * from "./server-mock.js";
6
+ export declare const isServer: boolean;
7
+ export declare const isDev: boolean;
8
+ export declare const hydrate: typeof hydrateCore;
9
+ /**
10
+ * Renders components somewhere else in the DOM
11
+ *
12
+ * Useful for inserting modals and tooltips outside of an cropping layout. If no mount point is given, the portal is inserted in document.body; it is wrapped in a `<div>` unless the target is document.head or `isSVG` is true. setting `useShadow` to true places the element in a shadow root to isolate styles.
13
+ *
14
+ * @description https://docs.solidjs.com/reference/components/portal
15
+ */
16
+ export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
17
+ mount?: Element;
18
+ children: JSX.Element;
19
+ }): Text;
20
+ export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
21
+ [K in keyof P]: P[K];
22
+ } & {
23
+ component: T | undefined;
24
+ };
25
+ /**
26
+ * Renders an arbitrary custom or native component and passes the other props
27
+ * ```typescript
28
+ * <Dynamic component={multiline() ? 'textarea' : 'input'} value={value()} />
29
+ * ```
30
+ * @description https://docs.solidjs.com/reference/components/dynamic
31
+ */
32
+ export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
package/types/jsx.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type { JSX } from "solid-js";
@@ -0,0 +1,47 @@
1
+ export declare function renderToString<T>(
2
+ fn: () => T,
3
+ options?: {
4
+ nonce?: string;
5
+ renderId?: string;
6
+ }
7
+ ): string;
8
+ export declare function renderToStringAsync<T>(
9
+ fn: () => T,
10
+ options?: {
11
+ timeoutMs?: number;
12
+ nonce?: string;
13
+ renderId?: string;
14
+ }
15
+ ): Promise<string>;
16
+ export declare 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
+ export declare function ssr(
29
+ template: string[] | string,
30
+ ...nodes: any[]
31
+ ): {
32
+ t: string;
33
+ };
34
+ export declare function ssrElement(
35
+ name: string,
36
+ props: any,
37
+ children: any,
38
+ needsId: boolean
39
+ ): {
40
+ t: string;
41
+ };
42
+ export declare function ssrClassList(value: { [k: string]: boolean }): string;
43
+ export declare function ssrStyle(value: { [k: string]: string }): string;
44
+ export declare function ssrAttribute(key: string, value: boolean): string;
45
+ export declare function ssrHydrationKey(): string;
46
+ export declare function resolveSSRNode(node: any): string;
47
+ export declare function escape(html: string): string;
@@ -0,0 +1,151 @@
1
+ import { JSX } from "./jsx.js";
2
+ export const Properties: Set<string>;
3
+ export const ChildProperties: Set<string>;
4
+ export const DelegatedEvents: Set<string>;
5
+ export const DOMElements: Set<string>;
6
+ export const SVGElements: Set<string>;
7
+ export const SVGNamespace: Record<string, string>;
8
+ export function getPropAlias(prop: string, tagName: string): string | undefined;
9
+
10
+ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
11
+
12
+ export function renderToString<T>(
13
+ fn: () => T,
14
+ options?: {
15
+ nonce?: string;
16
+ renderId?: string;
17
+ onError?: (err: any) => void;
18
+ }
19
+ ): string;
20
+ export function renderToStringAsync<T>(
21
+ fn: () => T,
22
+ options?: {
23
+ timeoutMs?: number;
24
+ nonce?: string;
25
+ renderId?: string;
26
+ noScripts?: boolean;
27
+ onError?: (err: any) => void;
28
+ }
29
+ ): Promise<string>;
30
+ export function renderToStream<T>(
31
+ fn: () => T,
32
+ options?: {
33
+ nonce?: string;
34
+ renderId?: string;
35
+ onCompleteShell?: (info: { write: (v: string) => void }) => void;
36
+ onCompleteAll?: (info: { write: (v: string) => void }) => void;
37
+ onError?: (err: any) => void;
38
+ }
39
+ ): {
40
+ pipe: (writable: { write: (v: string) => void }) => void;
41
+ pipeTo: (writable: WritableStream) => Promise<void>;
42
+ };
43
+
44
+ export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
45
+ export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
46
+ export function ssrElement(
47
+ name: string,
48
+ props: any,
49
+ children: any,
50
+ needsId: boolean
51
+ ): { t: string };
52
+ export function ssrClassList(value: { [k: string]: boolean }): string;
53
+ export function ssrStyle(value: { [k: string]: string }): string;
54
+ export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
55
+ export function ssrHydrationKey(): string;
56
+ export function resolveSSRNode(node: any): string;
57
+ export function escape(html: string): string;
58
+ export function useAssets(fn: () => JSX.Element): void;
59
+ export function getAssets(): string;
60
+ export function getHydrationKey(): string;
61
+ export function effect<T>(fn: (prev?: T) => T, init?: T): void;
62
+ export function memo<T>(fn: () => T, equal: boolean): () => T;
63
+ export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
64
+ export function mergeProps(...sources: unknown[]): unknown;
65
+ export function getOwner(): unknown;
66
+ export function generateHydrationScript(options: { nonce?: string; eventNames?: string[] }): string;
67
+ export declare const RequestContext: unique symbol;
68
+ export interface RequestEvent {
69
+ request: Request;
70
+ locals: Record<string | number | symbol, any>;
71
+ }
72
+ export function getRequestEvent(): RequestEvent | undefined;
73
+
74
+ export function Hydration(props: { children?: JSX.Element }): JSX.Element;
75
+ export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
76
+ export function Assets(props: { children?: JSX.Element }): JSX.Element;
77
+ export function untrack<T>(fn: () => T): T;
78
+
79
+ // client-only APIs
80
+
81
+ /** @deprecated not supported on the server side */
82
+ export function classList(
83
+ node: Element,
84
+ value: { [k: string]: boolean },
85
+ prev?: { [k: string]: boolean }
86
+ ): { [k: string]: boolean };
87
+
88
+ /** @deprecated not supported on the server side */
89
+ export function style(
90
+ node: Element,
91
+ value: { [k: string]: string },
92
+ prev?: { [k: string]: string }
93
+ ): void;
94
+
95
+ /** @deprecated not supported on the server side */
96
+ export function insert<T>(
97
+ parent: MountableElement,
98
+ accessor: (() => T) | T,
99
+ marker?: Node | null,
100
+ init?: JSX.Element
101
+ ): JSX.Element;
102
+
103
+ /** @deprecated not supported on the server side */
104
+ export function spread<T>(
105
+ node: Element,
106
+ accessor: T,
107
+ isSVG?: Boolean,
108
+ skipChildren?: Boolean
109
+ ): void;
110
+
111
+ /** @deprecated not supported on the server side */
112
+ export function delegateEvents(eventNames: string[], d?: Document): void;
113
+ /** @deprecated not supported on the server side */
114
+ export function dynamicProperty(props: unknown, key: string): unknown;
115
+ /** @deprecated not supported on the server side */
116
+ export function setAttribute(node: Element, name: string, value: string): void;
117
+ /** @deprecated not supported on the server side */
118
+ export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
119
+
120
+ /** @deprecated not supported on the server side */
121
+ export function addEventListener(
122
+ node: Element,
123
+ name: string,
124
+ handler: () => void,
125
+ delegate: boolean
126
+ ): void;
127
+
128
+ /** @deprecated not supported on the server side */
129
+ export function render(code: () => JSX.Element, element: MountableElement): () => void;
130
+ /** @deprecated not supported on the server side */
131
+ export function template(html: string, isCE?: boolean, isSVG?: boolean): () => Element;
132
+ /** @deprecated not supported on the server side */
133
+ export function setProperty(node: Element, name: string, value: any): void;
134
+ /** @deprecated not supported on the server side */
135
+ export function className(node: Element, value: string): void;
136
+ /** @deprecated not supported on the server side */
137
+ export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
138
+
139
+ /** @deprecated not supported on the server side */
140
+ export function hydrate(
141
+ fn: () => JSX.Element,
142
+ node: MountableElement,
143
+ options?: { renderId?: string; owner?: unknown }
144
+ ): () => void;
145
+
146
+ /** @deprecated not supported on the server side */
147
+ export function getNextElement(template?: HTMLTemplateElement): Element;
148
+ /** @deprecated not supported on the server side */
149
+ export function getNextMatch(start: Node, elementName: string): Element;
150
+ /** @deprecated not supported on the server side */
151
+ export function getNextMarker(start: Node): [Node, Array<Node>];