@solidjs/start 2.0.0-alpha.0 → 2.0.0-alpha.2

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/client/mount.d.ts +1 -7
  3. package/dist/client/mount.js +1 -99
  4. package/dist/config/constants.js +2 -2
  5. package/dist/config/dev-server.js +10 -0
  6. package/dist/config/fs-router.js +10 -22
  7. package/dist/config/fs-routes/fs-watcher.js +4 -4
  8. package/dist/config/fs-routes/index.js +4 -6
  9. package/dist/config/fs-routes/router.js +10 -11
  10. package/dist/config/fs-routes/tree-shake.js +12 -21
  11. package/dist/config/index.js +42 -42
  12. package/dist/config/lazy.js +42 -12
  13. package/dist/config/manifest.js +4 -3
  14. package/dist/config/vite-utils.d.ts +5 -0
  15. package/dist/config/vite-utils.js +7 -3
  16. package/dist/http/index.d.ts +1 -4
  17. package/dist/http/index.js +3 -5
  18. package/dist/index.d.ts +0 -1
  19. package/dist/middleware/index.d.ts +5 -2
  20. package/dist/middleware/index.js +6 -1
  21. package/dist/router.jsx +2 -2
  22. package/dist/server/StartServer.jsx +2 -0
  23. package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
  24. package/dist/server/assets/PatchVirtualDevStyles.jsx +28 -0
  25. package/dist/server/assets/index.js +1 -1
  26. package/dist/server/assets/render.jsx +2 -2
  27. package/dist/server/collect-styles.js +9 -21
  28. package/dist/server/fetchEvent.spec.js +1 -1
  29. package/dist/server/handler.js +30 -15
  30. package/dist/server/index.d.ts +1 -0
  31. package/dist/server/manifest/dev-client-manifest.js +1 -1
  32. package/dist/server/manifest/dev-ssr-manifest.js +1 -1
  33. package/dist/server/manifest/prod-ssr-manifest.js +7 -12
  34. package/dist/server/routes.js +3 -3
  35. package/dist/server/server-fns-runtime.js +2 -2
  36. package/dist/server/server-functions-handler.js +6 -11
  37. package/dist/server/server-runtime.js +8 -8
  38. package/dist/server/spa/StartServer.jsx +2 -0
  39. package/dist/shared/dev-overlay/CodeView.d.ts +1 -1
  40. package/dist/shared/dev-overlay/CodeView.jsx +23 -34
  41. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +4 -4
  42. package/dist/shared/dev-overlay/get-source-map.d.ts +1 -1
  43. package/dist/shared/dev-overlay/get-source-map.js +5 -5
  44. package/dist/shared/dev-overlay/icons.d.ts +10 -10
  45. package/dist/shared/dev-overlay/icons.jsx +91 -91
  46. package/dist/shared/dev-overlay/index.jsx +1 -1
  47. package/dist/shared/lazy.js +4 -2
  48. package/env.d.ts +9 -0
  49. package/package.json +5 -4
  50. package/scripts/build.js +3 -3
  51. package/scripts/validate-imports.js +8 -8
  52. package/src/client/mount.ts +1 -114
  53. package/src/config/constants.ts +3 -3
  54. package/src/config/dev-server.ts +107 -99
  55. package/src/config/fs-router.ts +140 -155
  56. package/src/config/fs-routes/fs-watcher.ts +57 -61
  57. package/src/config/fs-routes/index.ts +117 -119
  58. package/src/config/fs-routes/router.ts +12 -13
  59. package/src/config/fs-routes/tree-shake.ts +342 -363
  60. package/src/config/index.ts +42 -43
  61. package/src/config/lazy.ts +47 -16
  62. package/src/config/manifest.ts +8 -7
  63. package/src/config/vite-utils.ts +9 -9
  64. package/src/env.d.ts +10 -28
  65. package/src/http/index.ts +105 -142
  66. package/src/index.tsx +0 -12
  67. package/src/internal.d.ts +1 -1
  68. package/src/middleware/index.ts +42 -49
  69. package/src/router.tsx +4 -3
  70. package/src/server/StartServer.tsx +3 -7
  71. package/src/server/assets/PatchVirtualDevStyles.tsx +31 -0
  72. package/src/server/assets/index.ts +1 -1
  73. package/src/server/assets/render.tsx +6 -2
  74. package/src/server/collect-styles.ts +49 -73
  75. package/src/server/fetchEvent.spec.ts +71 -75
  76. package/src/server/fetchEvent.ts +17 -17
  77. package/src/server/handler.ts +138 -129
  78. package/src/server/index.tsx +13 -0
  79. package/src/server/manifest/client-manifest.ts +1 -1
  80. package/src/server/manifest/dev-client-manifest.ts +7 -5
  81. package/src/server/manifest/dev-ssr-manifest.ts +8 -6
  82. package/src/server/manifest/prod-client-manifest.ts +7 -4
  83. package/src/server/manifest/prod-ssr-manifest.ts +78 -94
  84. package/src/server/manifest/ssr-manifest.ts +4 -2
  85. package/src/server/routes.ts +96 -108
  86. package/src/server/server-fns-runtime.ts +3 -3
  87. package/src/server/server-functions-handler.ts +294 -319
  88. package/src/server/server-runtime.ts +13 -13
  89. package/src/server/spa/StartServer.tsx +2 -0
  90. package/src/server/spa/handler.ts +12 -12
  91. package/src/server/types.ts +46 -46
  92. package/src/server/util.ts +4 -4
  93. package/src/shared/ErrorBoundary.tsx +1 -1
  94. package/src/shared/HttpHeader.tsx +20 -20
  95. package/src/shared/HttpStatusCode.ts +14 -14
  96. package/src/shared/clientOnly.ts +3 -3
  97. package/src/shared/dev-overlay/CodeView.tsx +43 -46
  98. package/src/shared/dev-overlay/DevOverlayDialog.tsx +4 -4
  99. package/src/shared/dev-overlay/createStackFrame.ts +59 -62
  100. package/src/shared/dev-overlay/env.d.ts +2 -2
  101. package/src/shared/dev-overlay/get-source-map.ts +5 -7
  102. package/src/shared/dev-overlay/icons.tsx +289 -121
  103. package/src/shared/dev-overlay/index.tsx +1 -1
  104. package/src/shared/lazy.ts +4 -3
  105. package/src/shared/serverFunction.ts +1 -1
  106. package/src/virtual.d.ts +10 -10
  107. package/tsconfig.json +2 -2
  108. package/vitest.config.ts +2 -2
@@ -11,7 +11,7 @@ import {
11
11
  RequestPlugin,
12
12
  ResponsePlugin,
13
13
  URLPlugin,
14
- URLSearchParamsPlugin
14
+ URLSearchParamsPlugin,
15
15
  } from "seroval-plugins/web";
16
16
  import { type Component } from "solid-js";
17
17
 
@@ -46,7 +46,7 @@ class SerovalChunkReader {
46
46
  if (this.done) {
47
47
  return {
48
48
  done: true,
49
- value: undefined
49
+ value: undefined,
50
50
  };
51
51
  }
52
52
  // Otherwise, read a new chunk
@@ -77,7 +77,7 @@ class SerovalChunkReader {
77
77
  // Deserialize the chunk
78
78
  return {
79
79
  done: false,
80
- value: deserialize(partial)
80
+ value: deserialize(partial),
81
81
  };
82
82
  }
83
83
 
@@ -107,7 +107,7 @@ async function deserializeStream(id: string, response: Response) {
107
107
  },
108
108
  () => {
109
109
  // no-op
110
- }
110
+ },
111
111
  );
112
112
  }
113
113
 
@@ -123,8 +123,8 @@ function createRequest(base: string, id: string, instance: string, options: Requ
123
123
  headers: {
124
124
  ...options.headers,
125
125
  "X-Server-Id": id,
126
- "X-Server-Instance": instance
127
- }
126
+ "X-Server-Instance": instance,
127
+ },
128
128
  });
129
129
  }
130
130
 
@@ -138,14 +138,14 @@ const plugins = [
138
138
  RequestPlugin,
139
139
  ResponsePlugin,
140
140
  URLSearchParamsPlugin,
141
- URLPlugin
141
+ URLPlugin,
142
142
  ];
143
143
 
144
144
  async function fetchServerFunction(
145
145
  base: string,
146
146
  id: string,
147
147
  options: Omit<RequestInit, "body">,
148
- args: any[]
148
+ args: any[],
149
149
  ) {
150
150
  const instance = `server-fn:${INSTANCE++}`;
151
151
  const response = await (args.length === 0
@@ -156,12 +156,12 @@ async function fetchServerFunction(
156
156
  ? createRequest(base, id, instance, {
157
157
  ...options,
158
158
  body: args[0],
159
- headers: { ...options.headers, "Content-Type": "application/x-www-form-urlencoded" }
159
+ headers: { ...options.headers, "Content-Type": "application/x-www-form-urlencoded" },
160
160
  })
161
161
  : createRequest(base, id, instance, {
162
162
  ...options,
163
163
  body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
164
- headers: { ...options.headers, "Content-Type": "application/json" }
164
+ headers: { ...options.headers, "Content-Type": "application/json" },
165
165
  }));
166
166
 
167
167
  if (
@@ -195,7 +195,7 @@ async function fetchServerFunction(
195
195
 
196
196
  export function createServerReference(id: string) {
197
197
  let baseURL = import.meta.env.BASE_URL ?? "/";
198
- if(!baseURL.endsWith("/")) baseURL += "/"
198
+ if (!baseURL.endsWith("/")) baseURL += "/";
199
199
 
200
200
  const fn = (...args: any[]) => fetchServerFunction(`${baseURL}_server`, id, {}, args);
201
201
 
@@ -217,13 +217,13 @@ export function createServerReference(id: string) {
217
217
  ? url +
218
218
  (args.length
219
219
  ? `&args=${encodeURIComponent(
220
- JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins })))
220
+ JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
221
221
  )}`
222
222
  : "")
223
223
  : `${baseURL}_server`,
224
224
  id,
225
225
  options,
226
- encodeArgs ? [] : args
226
+ encodeArgs ? [] : args,
227
227
  );
228
228
  };
229
229
  fn.url = url;
@@ -6,6 +6,7 @@ import { getSsrManifest } from "../manifest/ssr-manifest.ts";
6
6
 
7
7
  import { TopErrorBoundary } from "../../shared/ErrorBoundary.tsx";
8
8
  import { useAssets } from "../assets/index.ts";
9
+ import PatchVirtualDevStyles from "../assets/PatchVirtualDevStyles.tsx";
9
10
  import type { DocumentComponentProps, PageEvent } from "../types.ts";
10
11
 
11
12
  const docType = ssr("<!DOCTYPE html>");
@@ -27,6 +28,7 @@ export function StartServer(props: { document: Component<DocumentComponentProps>
27
28
  <props.document
28
29
  scripts={
29
30
  <>
31
+ <PatchVirtualDevStyles nonce={nonce} />
30
32
  <script
31
33
  type="module"
32
34
  src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY)}
@@ -9,21 +9,21 @@ import type { FetchEvent, HandlerOptions, PageEvent } from "../types.ts";
9
9
  * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
10
10
  */
11
11
  export function createHandler(
12
- fn: (context: PageEvent) => JSX.Element,
13
- options?: HandlerOptions | ((context: PageEvent) => HandlerOptions),
12
+ fn: (context: PageEvent) => JSX.Element,
13
+ options?: HandlerOptions | ((context: PageEvent) => HandlerOptions),
14
14
  ) {
15
- return createBaseHandler(createPageEvent, fn, options);
15
+ return createBaseHandler(createPageEvent, fn, options);
16
16
  }
17
17
 
18
18
  async function createPageEvent(ctx: FetchEvent) {
19
- const manifest = getSsrManifest("ssr");
20
- const pageEvent: PageEvent = Object.assign(ctx, {
21
- manifest: "json" in manifest ? await manifest.json() : {},
22
- assets: await manifest.getAssets(import.meta.env.START_CLIENT_ENTRY),
23
- routes: [],
24
- complete: false,
25
- $islands: new Set<string>(),
26
- });
19
+ const manifest = getSsrManifest("ssr");
20
+ const pageEvent: PageEvent = Object.assign(ctx, {
21
+ manifest: "json" in manifest ? await manifest.json() : {},
22
+ assets: await manifest.getAssets(import.meta.env.START_CLIENT_ENTRY),
23
+ routes: [],
24
+ complete: false,
25
+ $islands: new Set<string>(),
26
+ });
27
27
 
28
- return pageEvent;
28
+ return pageEvent;
29
29
  }
@@ -5,78 +5,78 @@ import type { RequestEvent } from "solid-js/web";
5
5
  // export const FETCH_EVENT = "$FETCH";
6
6
 
7
7
  export type DocumentComponentProps = {
8
- assets?: JSX.Element;
9
- scripts: JSX.Element;
10
- children?: JSX.Element;
8
+ assets?: JSX.Element;
9
+ scripts: JSX.Element;
10
+ children?: JSX.Element;
11
11
  };
12
12
 
13
13
  export type Asset =
14
- | {
15
- tag: "style";
16
- attrs: JSX.StyleHTMLAttributes<HTMLStyleElement> & { key?: string };
17
- children?: JSX.Element;
18
- }
19
- | {
20
- tag: "script";
21
- attrs: JSX.ScriptHTMLAttributes<HTMLScriptElement> & { key?: string };
22
- }
23
- | {
24
- tag: "link";
25
- attrs: JSX.LinkHTMLAttributes<HTMLLinkElement> & { key?: string };
26
- };
14
+ | {
15
+ tag: "style";
16
+ attrs: JSX.StyleHTMLAttributes<HTMLStyleElement> & { key?: string };
17
+ children?: JSX.Element;
18
+ }
19
+ | {
20
+ tag: "script";
21
+ attrs: JSX.ScriptHTMLAttributes<HTMLScriptElement> & { key?: string };
22
+ }
23
+ | {
24
+ tag: "link";
25
+ attrs: JSX.LinkHTMLAttributes<HTMLLinkElement> & { key?: string };
26
+ };
27
27
 
28
28
  export type HandlerOptions = {
29
- mode?: "sync" | "async" | "stream";
30
- nonce?: string;
31
- renderId?: string;
32
- onCompleteAll?: (options: { write: (v: any) => void }) => void;
33
- onCompleteShell?: (options: { write: (v: any) => void }) => void;
29
+ mode?: "sync" | "async" | "stream";
30
+ nonce?: string;
31
+ renderId?: string;
32
+ onCompleteAll?: (options: { write: (v: any) => void }) => void;
33
+ onCompleteShell?: (options: { write: (v: any) => void }) => void;
34
34
  };
35
35
 
36
36
  export type ContextMatches = {
37
- originalPath: string;
38
- pattern: string;
39
- path: string;
40
- params: unknown;
37
+ originalPath: string;
38
+ pattern: string;
39
+ path: string;
40
+ params: unknown;
41
41
  };
42
42
 
43
43
  export interface ResponseStub {
44
- status?: number;
45
- statusText?: string;
46
- headers: Headers;
44
+ status?: number;
45
+ statusText?: string;
46
+ headers: Headers;
47
47
  }
48
48
 
49
49
  export interface FetchEvent {
50
- request: Request;
51
- response: ResponseStub;
52
- clientAddress?: string;
53
- locals: App.RequestEventLocals;
54
- nativeEvent: H3Event;
50
+ request: Request;
51
+ response: ResponseStub;
52
+ clientAddress?: string;
53
+ locals: App.RequestEventLocals;
54
+ nativeEvent: H3Event;
55
55
  }
56
56
 
57
57
  export interface PageEvent extends RequestEvent {
58
- assets: any[];
59
- routes: any[];
60
- // prevUrl: string | null;
61
- // $type: typeof FETCH_EVENT;
62
- $islands: Set<string>;
63
- complete: boolean;
64
- nonce?: string;
65
- // mutation: boolean;
58
+ assets: any[];
59
+ routes: any[];
60
+ // prevUrl: string | null;
61
+ // $type: typeof FETCH_EVENT;
62
+ $islands: Set<string>;
63
+ complete: boolean;
64
+ nonce?: string;
65
+ // mutation: boolean;
66
66
  }
67
67
 
68
68
  export interface APIEvent extends FetchEvent {
69
- params: { [key: string]: string };
69
+ params: { [key: string]: string };
70
70
  }
71
71
 
72
72
  export type APIHandler = (event: APIEvent) => Promise<any>;
73
73
 
74
74
  export interface ServerFunctionMeta {
75
- id: string;
75
+ id: string;
76
76
  }
77
77
 
78
78
  declare module "solid-js/web" {
79
- interface RequestEvent extends FetchEvent {
80
- serverOnly?: boolean;
81
- }
79
+ interface RequestEvent extends FetchEvent {
80
+ serverOnly?: boolean;
81
+ }
82
82
  }
@@ -4,9 +4,9 @@ import type { ResponseStub } from "./types.ts";
4
4
  const validRedirectStatuses = new Set([301, 302, 303, 307, 308]);
5
5
 
6
6
  export function getExpectedRedirectStatus(response: ResponseStub): number {
7
- if (response.status && validRedirectStatuses.has(response.status)) {
8
- return response.status;
9
- }
7
+ if (response.status && validRedirectStatuses.has(response.status)) {
8
+ return response.status;
9
+ }
10
10
 
11
- return 302;
11
+ return 302;
12
12
  }
@@ -37,7 +37,7 @@ export const TopErrorBoundary = (props: ParentProps) => {
37
37
  err => {
38
38
  console.error(err);
39
39
  isError = !!err;
40
- }
40
+ },
41
41
  );
42
42
  return isError ? (
43
43
  <>
@@ -17,26 +17,26 @@ export interface HttpHeaderProps {
17
17
  */
18
18
  export const HttpHeader = isServer
19
19
  ? (props: HttpHeaderProps) => {
20
- const event = getRequestEvent() as PageEvent;
20
+ const event = getRequestEvent() as PageEvent;
21
21
 
22
- if (props.append) appendHeader(props.name, props.value);
23
- else setHeader(props.name, props.value);
22
+ if (props.append) appendHeader(props.name, props.value);
23
+ else setHeader(props.name, props.value);
24
24
 
25
- onCleanup(() => {
26
- // @ts-expect-error
27
- if (event.nativeEvent.handled || event.complete) return;
28
- const value = event.response.headers.get(props.name);
29
- if (!value) return;
30
- if (!value.includes(", ")) {
31
- if (value === props.value) event.response.headers.delete(props.name);
32
- return;
33
- }
34
- const values = value.split(", ");
35
- const index = values.indexOf(props.value);
36
- index !== -1 && values.splice(index, 1);
37
- if (values.length) event.response.headers.set(props.name, values.join(","));
38
- else event.response.headers.delete(props.name);
39
- });
40
- return null;
41
- }
25
+ onCleanup(() => {
26
+ // @ts-expect-error
27
+ if (event.nativeEvent.handled || event.complete) return;
28
+ const value = event.response.headers.get(props.name);
29
+ if (!value) return;
30
+ if (!value.includes(", ")) {
31
+ if (value === props.value) event.response.headers.delete(props.name);
32
+ return;
33
+ }
34
+ const values = value.split(", ");
35
+ const index = values.indexOf(props.value);
36
+ index !== -1 && values.splice(index, 1);
37
+ if (values.length) event.response.headers.set(props.name, values.join(","));
38
+ else event.response.headers.delete(props.name);
39
+ });
40
+ return null;
41
+ }
42
42
  : (_props: HttpHeaderProps) => null;
@@ -4,8 +4,8 @@ import { getRequestEvent, isServer } from "solid-js/web";
4
4
  import type { PageEvent } from "../server/types.ts";
5
5
 
6
6
  export interface HttpStatusCodeProps {
7
- code: number;
8
- text?: string;
7
+ code: number;
8
+ text?: string;
9
9
  }
10
10
 
11
11
  /**
@@ -13,15 +13,15 @@ export interface HttpStatusCodeProps {
13
13
  * Read more: https://docs.solidjs.com/solid-start/reference/server/http-status-code
14
14
  */
15
15
  export const HttpStatusCode = isServer
16
- ? (props: HttpStatusCodeProps) => {
17
- const event = getRequestEvent() as PageEvent;
18
- event.response.status = props.code;
19
- event.response.statusText = props.text;
20
- onCleanup(
21
- () =>
22
- // !event.nativeEvent.handled &&
23
- !event.complete && (event.response.status = 200),
24
- );
25
- return null;
26
- }
27
- : (_props: HttpStatusCodeProps) => null;
16
+ ? (props: HttpStatusCodeProps) => {
17
+ const event = getRequestEvent() as PageEvent;
18
+ event.response.status = props.code;
19
+ event.response.statusText = props.text;
20
+ onCleanup(
21
+ () =>
22
+ // !event.nativeEvent.handled &&
23
+ !event.complete && (event.response.status = 200),
24
+ );
25
+ return null;
26
+ }
27
+ : (_props: HttpStatusCodeProps) => null;
@@ -12,7 +12,7 @@ export default function clientOnly<T extends Component<any>>(
12
12
  fn: () => Promise<{
13
13
  default: T;
14
14
  }>,
15
- options: { lazy?: boolean } = {}
15
+ options: { lazy?: boolean } = {},
16
16
  ) {
17
17
  if (isServer) return (props: ComponentProps<T> & { fallback?: JSX.Element }) => props.fallback;
18
18
 
@@ -29,7 +29,7 @@ export default function clientOnly<T extends Component<any>>(
29
29
  return createMemo(
30
30
  () => (
31
31
  (Comp = comp()), (m = mounted()), untrack(() => (Comp && m ? Comp(rest) : props.fallback))
32
- )
32
+ ),
33
33
  );
34
34
  };
35
35
  }
@@ -38,7 +38,7 @@ function load<T>(
38
38
  fn: () => Promise<{
39
39
  default: T;
40
40
  }>,
41
- setComp: Setter<T>
41
+ setComp: Setter<T>,
42
42
  ) {
43
43
  fn().then(m => setComp(() => m.default));
44
44
  }
@@ -1,31 +1,24 @@
1
1
  // @refresh skip
2
- import { getSingletonHighlighter, type BuiltinLanguage, type Highlighter } from 'shiki';
3
- import { loadWasm } from 'shiki/engine/oniguruma';
4
- import { createEffect, createResource, type JSX } from 'solid-js';
2
+ import { getSingletonHighlighter, type BuiltinLanguage, type Highlighter } from "shiki";
3
+ import { loadWasm } from "shiki/engine/oniguruma";
4
+ import { createEffect, createResource, type JSX } from "solid-js";
5
5
 
6
- import url from 'shiki/onig.wasm?url';
6
+ import url from "shiki/onig.wasm?url";
7
7
 
8
- import langJS from 'shiki/langs/javascript.mjs';
9
- import langJSX from 'shiki/langs/jsx.mjs';
10
- import langTSX from 'shiki/langs/tsx.mjs';
11
- import langTS from 'shiki/langs/typescript.mjs';
12
- import darkPlus from 'shiki/themes/dark-plus.mjs';
8
+ import langJS from "shiki/langs/javascript.mjs";
9
+ import langJSX from "shiki/langs/jsx.mjs";
10
+ import langTSX from "shiki/langs/tsx.mjs";
11
+ import langTS from "shiki/langs/typescript.mjs";
12
+ import darkPlus from "shiki/themes/dark-plus.mjs";
13
13
 
14
14
  let HIGHLIGHTER: Highlighter;
15
15
 
16
16
  async function loadHighlighter() {
17
17
  if (!HIGHLIGHTER) {
18
- await loadWasm(await fetch(url))
18
+ await loadWasm(await fetch(url));
19
19
  HIGHLIGHTER = await getSingletonHighlighter({
20
- themes: [
21
- darkPlus,
22
- ],
23
- langs: [
24
- langJS,
25
- langJSX,
26
- langTS,
27
- langTSX,
28
- ],
20
+ themes: [darkPlus],
21
+ langs: [langJS, langJSX, langTS, langTSX],
29
22
  });
30
23
  }
31
24
  return HIGHLIGHTER;
@@ -41,7 +34,7 @@ const RANGE = 8;
41
34
 
42
35
  export function CodeView(props: CodeViewProps): JSX.Element | null {
43
36
  const lines = () =>
44
- props.content.split('\n').map((item, index) => ({
37
+ props.content.split("\n").map((item, index) => ({
45
38
  index: index + 1,
46
39
  line: item,
47
40
  }));
@@ -51,27 +44,25 @@ export function CodeView(props: CodeViewProps): JSX.Element | null {
51
44
 
52
45
  let ref: HTMLDivElement | undefined;
53
46
 
54
- const [data] = createResource(() => (
55
- lines()
56
- .slice(minLine(), maxLine())
57
- .map(item => item.line)
58
- .join('\n')
59
- ) ,async (value) => {
60
- const highlighter = await loadHighlighter();
61
- const fileExtension = props.fileName
62
- .split(/[#?]/)[0]!
63
- .split('.')
64
- .pop()
65
- ?.trim();
66
- let lang = fileExtension as BuiltinLanguage;
67
- if (fileExtension === 'mjs' || fileExtension === 'cjs') {
68
- lang = 'js';
69
- }
70
- return highlighter.codeToHtml(value, {
71
- theme: 'dark-plus',
72
- lang,
73
- });
74
- });
47
+ const [data] = createResource(
48
+ () =>
49
+ lines()
50
+ .slice(minLine(), maxLine())
51
+ .map(item => item.line)
52
+ .join("\n"),
53
+ async value => {
54
+ const highlighter = await loadHighlighter();
55
+ const fileExtension = props.fileName.split(/[#?]/)[0]!.split(".").pop()?.trim();
56
+ let lang = fileExtension as BuiltinLanguage;
57
+ if (fileExtension === "mjs" || fileExtension === "cjs") {
58
+ lang = "js";
59
+ }
60
+ return highlighter.codeToHtml(value, {
61
+ theme: "dark-plus",
62
+ lang,
63
+ });
64
+ },
65
+ );
75
66
 
76
67
  createEffect(() => {
77
68
  const result = data();
@@ -82,14 +73,20 @@ export function CodeView(props: CodeViewProps): JSX.Element | null {
82
73
 
83
74
  for (let i = 0, len = lines.length; i < len; i++) {
84
75
  const el = lines[i] as HTMLElement;
85
- if ((props.line - minLine() - 1) === i) {
86
- el.classList.add('dev-overlay-error-line');
76
+ if (props.line - minLine() - 1 === i) {
77
+ el.classList.add("dev-overlay-error-line");
87
78
  }
88
79
  }
89
80
  }
90
81
  });
91
82
 
92
- return <div ref={ref} class="dev-overlay-code-view" style={{
93
- '--dev-overlay-code-view-start': minLine() + 1,
94
- }} />;
83
+ return (
84
+ <div
85
+ ref={ref}
86
+ class="dev-overlay-code-view"
87
+ style={{
88
+ "--dev-overlay-code-view-start": minLine() + 1,
89
+ }}
90
+ />
91
+ );
95
92
  }
@@ -19,7 +19,7 @@ import {
19
19
  RefreshIcon,
20
20
  SolidStartIcon,
21
21
  ViewCompiledIcon,
22
- ViewOriginalIcon
22
+ ViewOriginalIcon,
23
23
  } from "./icons.tsx";
24
24
  import "./styles.css";
25
25
 
@@ -134,7 +134,7 @@ function StackFramesContent(props: StackFramesContentProps) {
134
134
  content: "",
135
135
  line: current.getLineNumber()!,
136
136
  column: current.getColumnNumber()!,
137
- name: current.getFunctionName()
137
+ name: current.getFunctionName(),
138
138
  })}
139
139
  </span>
140
140
  </div>
@@ -225,8 +225,8 @@ export default function DevOverlayDialog(props: DevOverlayDialogProps): JSX.Elem
225
225
  htmlToImage
226
226
  .toPng(current, {
227
227
  style: {
228
- transform: "scale(0.75)"
229
- }
228
+ transform: "scale(0.75)",
229
+ },
230
230
  })
231
231
  .then(url => {
232
232
  download(url, "start-screenshot.png");