@solidjs/start 1.0.0 → 1.0.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/config/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { Options } from "vite-plugin-solid";
6
6
  // atleast until we sort which server options are good to use
7
7
  type ViteCustomizableConfig = CustomizableConfig & {
8
8
  server?: InlineConfig["server"];
9
- }
9
+ };
10
10
 
11
11
  type SolidStartInlineConfig = {
12
12
  ssr?: boolean;
@@ -16,13 +16,19 @@ type SolidStartInlineConfig = {
16
16
  appRoot?: string;
17
17
  routeDir?: string;
18
18
  middleware?: string;
19
- devOverlay?: boolean;
19
+ devOverlay?: boolean;
20
20
  experimental?: {
21
21
  islands?: boolean;
22
- }
22
+ };
23
23
  vite?:
24
24
  | ViteCustomizableConfig
25
25
  | ((options: { router: "server" | "client" | "server-function" }) => ViteCustomizableConfig);
26
26
  };
27
27
 
28
- export declare function defineConfig(baseConfig?: SolidStartInlineConfig): ReturnType<typeof createApp>;
28
+ /**
29
+ *
30
+ * Read more: https://docs.solidjs.com/solid-start/reference/entrypoints/app-config
31
+ */
32
+ export declare function defineConfig(
33
+ baseConfig?: SolidStartInlineConfig
34
+ ): ReturnType<typeof createApp>;
@@ -1,3 +1,7 @@
1
1
  import type { JSX } from "solid-js";
2
2
  import "./mount";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
6
+ */
3
7
  export declare function StartClient(): JSX.Element;
@@ -6,6 +6,10 @@ import "./mount";
6
6
  function Dummy(props) {
7
7
  return props.children;
8
8
  }
9
+ /**
10
+ *
11
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
12
+ */
9
13
  export function StartClient() {
10
14
  return (<Dummy>
11
15
  <Dummy>
@@ -1,3 +1,7 @@
1
1
  import "vinxi/client";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
5
+ */
2
6
  export declare function StartClient(): null;
3
7
  export { mount } from "./mount";
@@ -1,5 +1,9 @@
1
1
  // @refresh skip
2
2
  import "vinxi/client";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/start-client
6
+ */
3
7
  export function StartClient() {
4
8
  return null;
5
9
  }
@@ -1,3 +1,7 @@
1
1
  import type { JSX } from "solid-js";
2
2
  import { type MountableElement } from "solid-js/web";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/mount
6
+ */
3
7
  export declare function mount(fn: () => JSX.Element, el: MountableElement): (() => void) | undefined;
@@ -1,5 +1,9 @@
1
1
  import { createStore } from "solid-js/store";
2
2
  import { createComponent, getHydrationKey, getOwner, hydrate } from "solid-js/web";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/mount
6
+ */
3
7
  export function mount(fn, el) {
4
8
  if (import.meta.env.START_ISLANDS) {
5
9
  const map = new WeakMap();
@@ -17,7 +21,8 @@ export function mount(fn, el) {
17
21
  }
18
22
  let mod = await import(
19
23
  /* @vite-ignore */
20
- import.meta.env.MANIFEST["client"].chunks[el.dataset.id.split("#")[0]].output.path);
24
+ import.meta.env.MANIFEST["client"].chunks[el.dataset.id.split("#")[0]].output
25
+ .path);
21
26
  if (!mod || !el.dataset.hk)
22
27
  return;
23
28
  let Component = mod[el.dataset.id.split("#")[1]];
@@ -58,7 +63,8 @@ export function mount(fn, el) {
58
63
  const islands = document.querySelectorAll("solid-island[data-hk]");
59
64
  const assets = new Set();
60
65
  islands.forEach((el) => el.dataset.id && assets.add(el.dataset.id));
61
- Promise.all([...assets].map(asset => import(/* @vite-ignore */ import.meta.env.MANIFEST["client"].chunks[asset.split("#")[0]].output.path)))
66
+ Promise.all([...assets].map(asset => import(
67
+ /* @vite-ignore */ import.meta.env.MANIFEST["client"].chunks[asset.split("#")[0]].output.path)))
62
68
  .then(() => {
63
69
  islands.forEach((el) => {
64
70
  if (el.dataset.when === "idle" && "requestIdleCallback" in window) {
@@ -1,2 +1,6 @@
1
1
  export declare function createRoutes(): any[];
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/routing/file-routes
5
+ */
2
6
  export declare const FileRoutes: () => any[];
@@ -10,9 +10,10 @@ export function createRoutes() {
10
10
  ...(route.$$route ? route.$$route.require().route.info : {}),
11
11
  filesystem: true
12
12
  },
13
- component: route.$component && lazyRoute(route.$component, import.meta.env.START_ISLANDS
14
- ? import.meta.env.MANIFEST["ssr"]
15
- : import.meta.env.MANIFEST["client"], import.meta.env.MANIFEST["ssr"]),
13
+ component: route.$component &&
14
+ lazyRoute(route.$component, import.meta.env.START_ISLANDS
15
+ ? import.meta.env.MANIFEST["ssr"]
16
+ : import.meta.env.MANIFEST["client"], import.meta.env.MANIFEST["ssr"]),
16
17
  children: route.children ? route.children.map(createRoute) : undefined
17
18
  };
18
19
  }
@@ -20,6 +21,10 @@ export function createRoutes() {
20
21
  return routes;
21
22
  }
22
23
  let routes;
24
+ /**
25
+ *
26
+ * Read more: https://docs.solidjs.com/solid-start/reference/routing/file-routes
27
+ */
23
28
  export const FileRoutes = isServer
24
29
  ? () => getRequestEvent().routes
25
30
  : () => routes || (routes = createRoutes());
@@ -6,11 +6,16 @@ export default function lazyRoute(component, clientManifest, serverManifest, exp
6
6
  return lazy(async () => {
7
7
  if (import.meta.env.DEV) {
8
8
  let manifest = import.meta.env.SSR ? serverManifest : clientManifest;
9
- const mod = await manifest.inputs[component.src].import();
9
+ // import() throws if a module doesn't exist, which includes any
10
+ // modules loaded by the route itself, so it's important we catch here
11
+ const mod = await manifest.inputs[component.src].import().catch(() => null);
12
+ // fallback to an empty component as any errors will surface in the vite overlay
13
+ if (!mod)
14
+ return { default: () => [] };
10
15
  if (!mod[exported])
11
16
  console.error(`Module ${component.src} does not export ${exported}`);
12
17
  const Component = mod[exported];
13
- let assets = await clientManifest.inputs?.[component.src].assets();
18
+ let assets = await clientManifest.inputs?.[component.src]?.assets();
14
19
  const styles = assets.filter((asset) => asset.tag === "style");
15
20
  if (typeof window !== "undefined" && import.meta.hot) {
16
21
  import.meta.hot.on("css-update", data => {
@@ -1,5 +1,9 @@
1
1
  import type { Component, JSX } from "solid-js";
2
2
  import type { DocumentComponentProps } from "./types";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
6
+ */
3
7
  export declare function StartServer(props: {
4
8
  document: Component<DocumentComponentProps>;
5
9
  }): JSX.Element;
@@ -2,7 +2,7 @@
2
2
  // @ts-ignore
3
3
  import App from "#start/app";
4
4
  import { Hydration, HydrationScript, NoHydration, getRequestEvent, ssr, useAssets } from "solid-js/web";
5
- import { ErrorBoundary } from "../shared/ErrorBoundary";
5
+ import { ErrorBoundary, TopErrorBoundary } from "../shared/ErrorBoundary";
6
6
  import { renderAsset } from "./renderAsset";
7
7
  const docType = ssr("<!DOCTYPE html>");
8
8
  function matchRoute(matches, routes, matched = []) {
@@ -22,11 +22,15 @@ function matchRoute(matches, routes, matched = []) {
22
22
  return next;
23
23
  }
24
24
  }
25
+ /**
26
+ *
27
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
28
+ */
25
29
  export function StartServer(props) {
26
30
  const context = getRequestEvent();
27
31
  // @ts-ignore
28
32
  const nonce = context.nonce;
29
- let assets;
33
+ let assets = [];
30
34
  Promise.resolve().then(async () => {
31
35
  let assetPromises = [];
32
36
  // @ts-ignore
@@ -57,23 +61,25 @@ export function StartServer(props) {
57
61
  useAssets(() => (assets.length ? assets.map(m => renderAsset(m)) : undefined));
58
62
  return (<NoHydration>
59
63
  {docType}
60
- <props.document assets={<>
61
- <HydrationScript />
62
- {context.assets.map((m) => renderAsset(m, nonce))}
63
- </>} scripts={nonce ? (<>
64
- <script nonce={nonce} innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
65
- <script type="module" nonce={nonce} async src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
66
- </>) : (<>
67
- <script innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
68
- <script type="module" async src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
69
- </>)}>
70
- {!import.meta.env.START_ISLANDS ? (<Hydration>
71
- <ErrorBoundary>
64
+ <TopErrorBoundary>
65
+ <props.document assets={<>
66
+ <HydrationScript />
67
+ {context.assets.map((m) => renderAsset(m, nonce))}
68
+ </>} scripts={nonce ? (<>
69
+ <script nonce={nonce} innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
70
+ <script type="module" nonce={nonce} async src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
71
+ </>) : (<>
72
+ <script innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
73
+ <script type="module" async src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
74
+ </>)}>
75
+ {!import.meta.env.START_ISLANDS ? (<Hydration>
76
+ <ErrorBoundary>
77
+ <App />
78
+ </ErrorBoundary>
79
+ </Hydration>) : (<ErrorBoundary>
72
80
  <App />
73
- </ErrorBoundary>
74
- </Hydration>) : (<ErrorBoundary>
75
- <App />
76
- </ErrorBoundary>)}
77
- </props.document>
81
+ </ErrorBoundary>)}
82
+ </props.document>
83
+ </TopErrorBoundary>
78
84
  </NoHydration>);
79
85
  }
@@ -5,4 +5,8 @@ import type { FetchEvent, HandlerOptions, PageEvent, ResponseStub } from "./type
5
5
  */
6
6
  export declare function getExpectedRedirectStatus(response: ResponseStub): number;
7
7
  export declare function createBaseHandler(fn: (context: PageEvent) => unknown, createPageEvent: (event: FetchEvent) => Promise<PageEvent>, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
8
+ /**
9
+ *
10
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
11
+ */
8
12
  export declare function createHandler(fn: (context: PageEvent) => unknown, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -108,6 +108,10 @@ function handleStreamCompleteRedirect(context) {
108
108
  to && write(`<script>window.location="${to}"</script>`);
109
109
  };
110
110
  }
111
+ /**
112
+ *
113
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
114
+ */
111
115
  export function createHandler(fn, options) {
112
116
  return createBaseHandler(fn, createPageEvent, options);
113
117
  }
@@ -1,2 +1,6 @@
1
1
  import type { ServerFunctionMeta } from "./types";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get-server-function-meta
5
+ */
2
6
  export declare function getServerFunctionMeta(): ServerFunctionMeta | undefined;
@@ -1,4 +1,8 @@
1
1
  import { getRequestEvent } from "solid-js/web";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get-server-function-meta
5
+ */
2
6
  export function getServerFunctionMeta() {
3
7
  return getRequestEvent()?.locals.serverFunctionMeta;
4
8
  }
@@ -1,5 +1,9 @@
1
1
  import type { Component } from "solid-js";
2
2
  import type { DocumentComponentProps } from "../types";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
6
+ */
3
7
  export declare function StartServer(props: {
4
8
  document: Component<DocumentComponentProps>;
5
9
  }): import("solid-js").JSX.Element;
@@ -1,18 +1,25 @@
1
1
  import { NoHydration, getRequestEvent, ssr } from "solid-js/web";
2
+ import { TopErrorBoundary } from "../../shared/ErrorBoundary";
2
3
  import { renderAsset } from "../renderAsset";
3
4
  const docType = ssr("<!DOCTYPE html>");
5
+ /**
6
+ *
7
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
8
+ */
4
9
  export function StartServer(props) {
5
10
  const context = getRequestEvent();
6
11
  // @ts-ignore
7
12
  const nonce = context.nonce;
8
13
  return (<NoHydration>
9
14
  {docType}
10
- <props.document assets={<>{context.assets.map((m) => renderAsset(m))}</>} scripts={nonce ? (<>
11
- <script nonce={nonce} innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
12
- <script type="module" src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
13
- </>) : (<>
14
- <script innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
15
- <script type="module" src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
16
- </>)}/>
15
+ <TopErrorBoundary>
16
+ <props.document assets={<>{context.assets.map((m) => renderAsset(m))}</>} scripts={nonce ? (<>
17
+ <script nonce={nonce} innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
18
+ <script type="module" src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
19
+ </>) : (<>
20
+ <script innerHTML={`window.manifest = ${JSON.stringify(context.manifest)}`}/>
21
+ <script type="module" src={import.meta.env.MANIFEST["client"].inputs[import.meta.env.MANIFEST["client"].handler].output.path}/>
22
+ </>)}/>
23
+ </TopErrorBoundary>
17
24
  </NoHydration>);
18
25
  }
@@ -1,3 +1,7 @@
1
1
  import { FetchEvent, HandlerOptions, PageEvent } from "../types";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
5
+ */
2
6
  export declare function createHandler(fn: (context: PageEvent) => unknown, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions)): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
7
  export declare function createPageEvent(ctx: FetchEvent): Promise<PageEvent>;
@@ -1,4 +1,8 @@
1
1
  import { createBaseHandler } from "../handler";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
5
+ */
2
6
  export function createHandler(fn, options) {
3
7
  return createBaseHandler(fn, createPageEvent, options);
4
8
  }
@@ -1,2 +1,3 @@
1
1
  import { type ParentProps } from "solid-js";
2
2
  export declare const ErrorBoundary: (props: ParentProps) => import("solid-js").JSX.Element;
3
+ export declare const TopErrorBoundary: (props: ParentProps) => import("solid-js").JSX.Element;
@@ -1,16 +1,36 @@
1
1
  // @refresh skip
2
- import { ErrorBoundary as DefaultErrorBoundary } from "solid-js";
2
+ import { ErrorBoundary as DefaultErrorBoundary, catchError } from "solid-js";
3
3
  import { isServer } from "solid-js/web";
4
4
  import { HttpStatusCode } from "./HttpStatusCode";
5
5
  import { DevOverlay } from "./dev-overlay";
6
6
  export const ErrorBoundary = import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY
7
7
  ? (props) => <DevOverlay>{props.children}</DevOverlay>
8
8
  : (props) => {
9
- const message = isServer ? "500 | Internal Server Error" : "Error | Uncaught Client Exception";
10
- return (<DefaultErrorBoundary fallback={<>
11
- <span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">{message}</span>
12
- <HttpStatusCode code={500}/>
13
- </>}>
14
- {props.children}
15
- </DefaultErrorBoundary>);
9
+ const message = isServer
10
+ ? "500 | Internal Server Error"
11
+ : "Error | Uncaught Client Exception";
12
+ return (<DefaultErrorBoundary fallback={error => {
13
+ console.error(error);
14
+ return (<>
15
+ <span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">
16
+ {message}
17
+ </span>
18
+ <HttpStatusCode code={500}/>
19
+ </>);
20
+ }}>
21
+ {props.children}
22
+ </DefaultErrorBoundary>);
16
23
  };
24
+ export const TopErrorBoundary = (props) => {
25
+ let isError = false;
26
+ const res = catchError(() => props.children, err => {
27
+ console.error(err);
28
+ isError = !!err;
29
+ });
30
+ return isError ? (<>
31
+ <span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">
32
+ 500 | Internal Server Error
33
+ </span>
34
+ <HttpStatusCode code={500}/>
35
+ </>) : (res);
36
+ };
@@ -1 +1,5 @@
1
+ /**
2
+ *
3
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get
4
+ */
1
5
  export declare function GET<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get
4
+ */
1
5
  export function GET(fn) {
2
6
  return (...args) => {
3
7
  return fn.GET(...args);
@@ -3,4 +3,8 @@ export interface HttpHeaderProps {
3
3
  value: string;
4
4
  append?: boolean;
5
5
  }
6
+ /**
7
+ *
8
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/http-header
9
+ */
6
10
  export declare const HttpHeader: (props: HttpHeaderProps) => null;
@@ -1,6 +1,10 @@
1
1
  // @refresh skip
2
2
  import { onCleanup } from "solid-js";
3
3
  import { getRequestEvent, isServer } from "solid-js/web";
4
+ /**
5
+ *
6
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/http-header
7
+ */
4
8
  export const HttpHeader = isServer
5
9
  ? (props) => {
6
10
  const event = getRequestEvent();
@@ -2,4 +2,8 @@ export interface HttpStatusCodeProps {
2
2
  code: number;
3
3
  text?: string;
4
4
  }
5
+ /**
6
+ *
7
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/http-status-code
8
+ */
5
9
  export declare const HttpStatusCode: (props: HttpStatusCodeProps) => null;
@@ -1,6 +1,10 @@
1
1
  // @refresh skip
2
2
  import { onCleanup } from "solid-js";
3
3
  import { getRequestEvent, isServer } from "solid-js/web";
4
+ /**
5
+ *
6
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/http-status-code
7
+ */
4
8
  export const HttpStatusCode = isServer
5
9
  ? (props) => {
6
10
  const event = getRequestEvent();
@@ -1,4 +1,8 @@
1
1
  import type { Component, ComponentProps, JSX } from "solid-js";
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
5
+ */
2
6
  export default function clientOnly<T extends Component<any>>(fn: () => Promise<{
3
7
  default: T;
4
8
  }>): (props: ComponentProps<T> & {
@@ -1,5 +1,9 @@
1
1
  import { createMemo, createSignal, onMount, sharedConfig, splitProps, untrack } from "solid-js";
2
2
  import { isServer } from "solid-js/web";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
6
+ */
3
7
  // not using Suspense
4
8
  export default function clientOnly(fn) {
5
9
  if (isServer)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
@@ -29,7 +29,11 @@
29
29
  "./server/spa": "./dist/server/spa/index.jsx",
30
30
  "./client": "./dist/client/index.jsx",
31
31
  "./client/islands": "./dist/client/islands.jsx",
32
- "./client/spa": "./dist/client/spa/index.jsx"
32
+ "./client/spa": "./dist/client/spa/index.jsx",
33
+ "./env": {
34
+ "types": "./env.d.ts",
35
+ "import": null
36
+ }
33
37
  },
34
38
  "typesVersions": {
35
39
  "*": {