@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
@@ -1,6 +1,5 @@
1
1
  import middleware from "solid-start:middleware";
2
2
  import { defineHandler, getCookie, H3, redirect, setCookie } from "h3";
3
- import { join } from "pathe";
4
3
  import { sharedConfig } from "solid-js";
5
4
  import { getRequestEvent, renderToStream, renderToString } from "solid-js/web";
6
5
  import { createRoutes } from "../router.jsx";
@@ -16,9 +15,8 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
16
15
  handler: decorateHandler(async (e) => {
17
16
  const event = getRequestEvent();
18
17
  const url = new URL(event.request.url);
19
- const pathname = url.pathname;
20
- const serverFunctionTest = join(import.meta.env.BASE_URL, SERVER_FN_BASE);
21
- if (pathname.startsWith(serverFunctionTest)) {
18
+ const pathname = stripBaseUrl(url.pathname);
19
+ if (pathname.startsWith(SERVER_FN_BASE)) {
22
20
  const serverFnResponse = await handleServerFunction(e);
23
21
  if (serverFnResponse instanceof Response)
24
22
  return produceResponseWithEventHeaders(serverFnResponse);
@@ -29,9 +27,7 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
29
27
  const match = matchAPIRoute(pathname, event.request.method);
30
28
  if (match) {
31
29
  const mod = await match.handler.import();
32
- const fn = event.request.method === "HEAD"
33
- ? mod["HEAD"] || mod["GET"]
34
- : mod[event.request.method];
30
+ const fn = event.request.method === "HEAD" ? mod["HEAD"] || mod["GET"] : mod[event.request.method];
35
31
  event.params = match.params || {};
36
32
  // @ts-expect-error
37
33
  sharedConfig.context = { event };
@@ -56,12 +52,13 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
56
52
  const html = renderToString(() => {
57
53
  sharedConfig.context.event = context;
58
54
  return fn(context);
59
- });
55
+ }, resolvedOptions);
60
56
  context.complete = true;
61
57
  if (context.response && context.response.headers.get("Location")) {
62
58
  const status = getExpectedRedirectStatus(context.response);
63
59
  return redirect(context.response.headers.get("Location"), status);
64
60
  }
61
+ event.response.headers.set("content-type", "text/html");
65
62
  return html;
66
63
  }
67
64
  if (resolvedOptions.onCompleteAll) {
@@ -118,7 +115,7 @@ export async function createPageEvent(ctx) {
118
115
  const manifest = getSsrManifest(import.meta.env.SSR && import.meta.env.DEV ? "ssr" : "client");
119
116
  // Handle Vite build.cssCodeSplit
120
117
  // When build.cssCodeSplit is false, a single CSS file is generated with the key style.css
121
- const mergedCSS = import.meta.env.PROD ? await manifest.getAssets('style.css') : [];
118
+ const mergedCSS = import.meta.env.PROD ? await manifest.getAssets("style.css") : [];
122
119
  const assets = [
123
120
  ...mergedCSS,
124
121
  ...(await manifest.getAssets(import.meta.env.START_CLIENT_ENTRY)),
@@ -151,10 +148,7 @@ function initFromFlash(ctx) {
151
148
  const param = JSON.parse(flash);
152
149
  if (!param || !param.result)
153
150
  return;
154
- const input = [
155
- ...param.input.slice(0, -1),
156
- new Map(param.input[param.input.length - 1]),
157
- ];
151
+ const input = [...param.input.slice(0, -1), new Map(param.input[param.input.length - 1])];
158
152
  const result = param.error ? new Error(param.result) : param.result;
159
153
  return {
160
154
  input,
@@ -192,14 +186,35 @@ function produceResponseWithEventHeaders(res) {
192
186
  let ret = res;
193
187
  // Response.redirect returns an immutable value, so we clone on any redirect just in case
194
188
  if (300 <= res.status && res.status < 400) {
189
+ const cookies = res.headers.getSetCookie?.() ?? [];
190
+ const headers = new Headers();
191
+ res.headers.forEach((value, key) => {
192
+ if (key.toLowerCase() !== "set-cookie") {
193
+ headers.set(key, value);
194
+ }
195
+ });
196
+ for (const cookie of cookies) {
197
+ headers.append("Set-Cookie", cookie);
198
+ }
195
199
  ret = new Response(res.body, {
196
200
  status: res.status,
197
201
  statusText: res.statusText,
198
- headers: Object.fromEntries(res.headers.entries())
202
+ headers,
199
203
  });
200
204
  }
205
+ const eventCookies = event.response.headers.getSetCookie?.() ?? [];
206
+ for (const cookie of eventCookies) {
207
+ ret.headers.append("Set-Cookie", cookie);
208
+ }
201
209
  for (const [name, value] of event.response.headers) {
202
- ret.headers.set(name, value);
210
+ if (name.toLowerCase() !== "set-cookie") {
211
+ ret.headers.set(name, value);
212
+ }
203
213
  }
204
214
  return ret;
205
215
  }
216
+ function stripBaseUrl(path) {
217
+ if (import.meta.env.BASE_URL === "/" || import.meta.env.BASE_URL === "")
218
+ return path;
219
+ return path.slice(import.meta.env.BASE_URL.length);
220
+ }
@@ -2,6 +2,7 @@ export { default as lazy } from "../shared/lazy.ts";
2
2
  export { getServerFunctionMeta } from "../shared/serverFunction.ts";
3
3
  export { StartServer } from "./StartServer.tsx";
4
4
  export { createHandler } from "./handler.ts";
5
+ export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta, } from "./types.ts";
5
6
  /**
6
7
  * Checks if user has set a redirect status in the response.
7
8
  * If not, falls back to the 302 (temporary redirect)
@@ -17,7 +17,7 @@ export function getClientDevManifest() {
17
17
  const assets = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ assetsPath, true))).default;
18
18
  return await Promise.all(assets.map(async (v) => ({
19
19
  ...v,
20
- children: await v.children()
20
+ children: await v.children(),
21
21
  })));
22
22
  },
23
23
  };
@@ -15,7 +15,7 @@ export function getSsrDevManifest(environment) {
15
15
  const assets = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ assetsPath, true))).default;
16
16
  return await Promise.all(assets.map(async (v) => ({
17
17
  ...v,
18
- children: await v.children()
18
+ children: await v.children(),
19
19
  })));
20
20
  },
21
21
  };
@@ -20,8 +20,8 @@ export function getSsrProdManifest() {
20
20
  async json() {
21
21
  const json = {};
22
22
  const entryKeys = Object.keys(viteManifest)
23
- .filter((id) => viteManifest[id]?.isEntry || viteManifest[id]?.isDynamicEntry)
24
- .map((id) => id);
23
+ .filter(id => viteManifest[id]?.isEntry || viteManifest[id]?.isDynamicEntry)
24
+ .map(id => id);
25
25
  for (const entryKey of entryKeys) {
26
26
  json[entryKey] = {
27
27
  output: join("/", viteManifest[entryKey].file),
@@ -34,18 +34,16 @@ export function getSsrProdManifest() {
34
34
  }
35
35
  function createHtmlTagsForAssets(assets) {
36
36
  return assets
37
- .filter((asset) => asset.endsWith(".css") ||
37
+ .filter(asset => asset.endsWith(".css") ||
38
38
  asset.endsWith(".js") ||
39
39
  asset.endsWith(".ts") ||
40
40
  asset.endsWith(".mjs"))
41
- .map((asset) => ({
41
+ .map(asset => ({
42
42
  tag: "link",
43
43
  attrs: {
44
- href: '/' + asset,
44
+ href: "/" + asset,
45
45
  key: asset,
46
- ...(asset.endsWith(".css")
47
- ? { rel: "stylesheet" }
48
- : { rel: "modulepreload" }),
46
+ ...(asset.endsWith(".css") ? { rel: "stylesheet" } : { rel: "modulepreload" }),
49
47
  },
50
48
  }));
51
49
  }
@@ -64,10 +62,7 @@ function findAssetsInViteManifest(manifest, id, assetMap = new Map(), stack = []
64
62
  return [];
65
63
  }
66
64
  if (!entryImports) {
67
- entryImports = [
68
- entryId,
69
- ...(manifest[entryId]?.imports ?? [])
70
- ];
65
+ entryImports = [entryId, ...(manifest[entryId]?.imports ?? [])];
71
66
  }
72
67
  // Only include entry imports, if we are specifically crawling the entry
73
68
  // Chunks (e.g. routes) that import something from entry, should not render entry css redundantly
@@ -1,10 +1,10 @@
1
1
  // @ts-expect-error
2
2
  import fileRoutes from "solid-start:routes";
3
3
  import { createRouter } from "radix3";
4
- export const pageRoutes = defineRoutes(fileRoutes.filter((o) => o.page));
4
+ export const pageRoutes = defineRoutes(fileRoutes.filter(o => o.page));
5
5
  function defineRoutes(fileRoutes) {
6
6
  function processRoute(routes, route, id, full) {
7
- const parentRoute = Object.values(routes).find((o) => {
7
+ const parentRoute = Object.values(routes).find(o => {
8
8
  return id.startsWith(o.id + "/");
9
9
  });
10
10
  if (!parentRoute) {
@@ -33,7 +33,7 @@ const router = createRouter({
33
33
  .replace(/\/+/g, "/")
34
34
  .replace(/\*([^/]*)/g, (_, m) => `**:${m}`)
35
35
  .split("/")
36
- .map((s) => s.startsWith(":") || s.startsWith("*") ? s : encodeURIComponent(s))
36
+ .map(s => (s.startsWith(":") || s.startsWith("*") ? s : encodeURIComponent(s)))
37
37
  .join("/");
38
38
  if (/:[^/]*\?/g.test(path)) {
39
39
  throw new Error(`Optional parameters are not supported in API routes: ${path}`);
@@ -21,12 +21,12 @@ export function createServerReference(fn, id) {
21
21
  throw new Error("Cannot call server function outside of a request");
22
22
  const evt = { ...ogEvt };
23
23
  evt.locals.serverFunctionMeta = {
24
- id
24
+ id,
25
25
  };
26
26
  evt.serverOnly = true;
27
27
  return provideRequestEvent(evt, () => {
28
28
  return fn.apply(thisArg, args);
29
29
  });
30
- }
30
+ },
31
31
  });
32
32
  }
@@ -1,7 +1,7 @@
1
1
  import { getServerFnById } from "solidstart:server-fn-manifest";
2
2
  import { parseSetCookie } from "cookie-es";
3
3
  import { parseCookies } from "h3";
4
- import { crossSerializeStream, fromJSON, getCrossReferenceHeader, } from "seroval";
4
+ import { crossSerializeStream, fromJSON, getCrossReferenceHeader } from "seroval";
5
5
  import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin, } from "seroval-plugins/web";
6
6
  import { sharedConfig } from "solid-js";
7
7
  import { renderToString } from "solid-js/web";
@@ -125,7 +125,7 @@ export async function handleServerFunction(h3Event) {
125
125
  /* @ts-expect-error */
126
126
  sharedConfig.context = { event };
127
127
  event.locals.serverFunctionMeta = {
128
- id: functionId
128
+ id: functionId,
129
129
  };
130
130
  return serverFunction(...parsed);
131
131
  });
@@ -165,8 +165,7 @@ export async function handleServerFunction(h3Event) {
165
165
  if (x.headers)
166
166
  mergeResponseHeaders(h3Event, x.headers);
167
167
  // forward non-redirect statuses
168
- if (x.status &&
169
- (!instance || x.status < 300 || x.status >= 400))
168
+ if (x.status && (!instance || x.status < 300 || x.status >= 400))
170
169
  h3Event.res.status = x.status;
171
170
  if (x.customBody) {
172
171
  x = x.customBody();
@@ -211,10 +210,7 @@ function handleNoJS(result, request, parsed, thrown) {
211
210
  result: isError ? result.message : result,
212
211
  thrown: thrown,
213
212
  error: isError,
214
- input: [
215
- ...parsed.slice(0, -1),
216
- [...parsed[parsed.length - 1].entries()],
217
- ],
213
+ input: [...parsed.slice(0, -1), [...parsed[parsed.length - 1].entries()]],
218
214
  }))}; Secure; HttpOnly;`);
219
215
  }
220
216
  return new Response(null, {
@@ -236,7 +232,7 @@ function createSingleFlightHeaders(sourceEvent) {
236
232
  // useH3Internals = true;
237
233
  // sourceEvent.nativeEvent.node.req.headers.cookie = "";
238
234
  // }
239
- SetCookies.forEach((cookie) => {
235
+ SetCookies.forEach(cookie => {
240
236
  if (!cookie)
241
237
  return;
242
238
  const { maxAge, expires, name, value } = parseSetCookie(cookie);
@@ -264,8 +260,7 @@ async function handleSingleFlight(sourceEvent, result) {
264
260
  if (result.headers.has("X-Revalidate"))
265
261
  revalidate = result.headers.get("X-Revalidate").split(",");
266
262
  if (result.headers.has("Location"))
267
- url = new URL(result.headers.get("Location"), new URL(sourceEvent.request.url).origin +
268
- import.meta.env.BASE_URL).toString();
263
+ url = new URL(result.headers.get("Location"), new URL(sourceEvent.request.url).origin + import.meta.env.BASE_URL).toString();
269
264
  }
270
265
  const event = { ...sourceEvent };
271
266
  event.request = new Request(url, {
@@ -1,5 +1,5 @@
1
1
  import { deserialize, toJSONAsync } from "seroval";
2
- import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin } from "seroval-plugins/web";
2
+ import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin, } from "seroval-plugins/web";
3
3
  class SerovalChunkReader {
4
4
  reader;
5
5
  buffer;
@@ -30,7 +30,7 @@ class SerovalChunkReader {
30
30
  if (this.done) {
31
31
  return {
32
32
  done: true,
33
- value: undefined
33
+ value: undefined,
34
34
  };
35
35
  }
36
36
  // Otherwise, read a new chunk
@@ -60,7 +60,7 @@ class SerovalChunkReader {
60
60
  // Deserialize the chunk
61
61
  return {
62
62
  done: false,
63
- value: deserialize(partial)
63
+ value: deserialize(partial),
64
64
  };
65
65
  }
66
66
  async drain() {
@@ -96,8 +96,8 @@ function createRequest(base, id, instance, options) {
96
96
  headers: {
97
97
  ...options.headers,
98
98
  "X-Server-Id": id,
99
- "X-Server-Instance": instance
100
- }
99
+ "X-Server-Instance": instance,
100
+ },
101
101
  });
102
102
  }
103
103
  const plugins = [
@@ -110,7 +110,7 @@ const plugins = [
110
110
  RequestPlugin,
111
111
  ResponsePlugin,
112
112
  URLSearchParamsPlugin,
113
- URLPlugin
113
+ URLPlugin,
114
114
  ];
115
115
  async function fetchServerFunction(base, id, options, args) {
116
116
  const instance = `server-fn:${INSTANCE++}`;
@@ -122,12 +122,12 @@ async function fetchServerFunction(base, id, options, args) {
122
122
  ? createRequest(base, id, instance, {
123
123
  ...options,
124
124
  body: args[0],
125
- headers: { ...options.headers, "Content-Type": "application/x-www-form-urlencoded" }
125
+ headers: { ...options.headers, "Content-Type": "application/x-www-form-urlencoded" },
126
126
  })
127
127
  : createRequest(base, id, instance, {
128
128
  ...options,
129
129
  body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
130
- headers: { ...options.headers, "Content-Type": "application/json" }
130
+ headers: { ...options.headers, "Content-Type": "application/json" },
131
131
  }));
132
132
  if (response.headers.has("Location") ||
133
133
  response.headers.has("X-Revalidate") ||
@@ -2,6 +2,7 @@ import { NoHydration, getRequestEvent, ssr } from "solid-js/web";
2
2
  import { getSsrManifest } from "../manifest/ssr-manifest.js";
3
3
  import { TopErrorBoundary } from "../../shared/ErrorBoundary.jsx";
4
4
  import { useAssets } from "../assets/index.js";
5
+ import PatchVirtualDevStyles from "../assets/PatchVirtualDevStyles.jsx";
5
6
  const docType = ssr("<!DOCTYPE html>");
6
7
  /**
7
8
  *
@@ -16,6 +17,7 @@ export function StartServer(props) {
16
17
  {docType}
17
18
  <TopErrorBoundary>
18
19
  <props.document scripts={<>
20
+ <PatchVirtualDevStyles nonce={nonce}/>
19
21
  <script type="module" src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY)}/>
20
22
  </>}/>
21
23
  </TopErrorBoundary>
@@ -1,4 +1,4 @@
1
- import { type JSX } from 'solid-js';
1
+ import { type JSX } from "solid-js";
2
2
  export interface CodeViewProps {
3
3
  fileName: string;
4
4
  content: string;
@@ -1,56 +1,45 @@
1
1
  // @refresh skip
2
- import { getSingletonHighlighter } from 'shiki';
3
- import { loadWasm } from 'shiki/engine/oniguruma';
4
- import { createEffect, createResource } from 'solid-js';
5
- import url from 'shiki/onig.wasm?url';
6
- import langJS from 'shiki/langs/javascript.mjs';
7
- import langJSX from 'shiki/langs/jsx.mjs';
8
- import langTSX from 'shiki/langs/tsx.mjs';
9
- import langTS from 'shiki/langs/typescript.mjs';
10
- import darkPlus from 'shiki/themes/dark-plus.mjs';
2
+ import { getSingletonHighlighter } from "shiki";
3
+ import { loadWasm } from "shiki/engine/oniguruma";
4
+ import { createEffect, createResource } from "solid-js";
5
+ import url from "shiki/onig.wasm?url";
6
+ import langJS from "shiki/langs/javascript.mjs";
7
+ import langJSX from "shiki/langs/jsx.mjs";
8
+ import langTSX from "shiki/langs/tsx.mjs";
9
+ import langTS from "shiki/langs/typescript.mjs";
10
+ import darkPlus from "shiki/themes/dark-plus.mjs";
11
11
  let HIGHLIGHTER;
12
12
  async function loadHighlighter() {
13
13
  if (!HIGHLIGHTER) {
14
14
  await loadWasm(await fetch(url));
15
15
  HIGHLIGHTER = await getSingletonHighlighter({
16
- themes: [
17
- darkPlus,
18
- ],
19
- langs: [
20
- langJS,
21
- langJSX,
22
- langTS,
23
- langTSX,
24
- ],
16
+ themes: [darkPlus],
17
+ langs: [langJS, langJSX, langTS, langTSX],
25
18
  });
26
19
  }
27
20
  return HIGHLIGHTER;
28
21
  }
29
22
  const RANGE = 8;
30
23
  export function CodeView(props) {
31
- const lines = () => props.content.split('\n').map((item, index) => ({
24
+ const lines = () => props.content.split("\n").map((item, index) => ({
32
25
  index: index + 1,
33
26
  line: item,
34
27
  }));
35
28
  const minLine = () => Math.max(props.line - (1 + RANGE), 0);
36
29
  const maxLine = () => Math.min(props.line + RANGE, lines().length - 1);
37
30
  let ref;
38
- const [data] = createResource(() => (lines()
31
+ const [data] = createResource(() => lines()
39
32
  .slice(minLine(), maxLine())
40
33
  .map(item => item.line)
41
- .join('\n')), async (value) => {
34
+ .join("\n"), async (value) => {
42
35
  const highlighter = await loadHighlighter();
43
- const fileExtension = props.fileName
44
- .split(/[#?]/)[0]
45
- .split('.')
46
- .pop()
47
- ?.trim();
36
+ const fileExtension = props.fileName.split(/[#?]/)[0].split(".").pop()?.trim();
48
37
  let lang = fileExtension;
49
- if (fileExtension === 'mjs' || fileExtension === 'cjs') {
50
- lang = 'js';
38
+ if (fileExtension === "mjs" || fileExtension === "cjs") {
39
+ lang = "js";
51
40
  }
52
41
  return highlighter.codeToHtml(value, {
53
- theme: 'dark-plus',
42
+ theme: "dark-plus",
54
43
  lang,
55
44
  });
56
45
  });
@@ -61,13 +50,13 @@ export function CodeView(props) {
61
50
  const lines = ref.querySelectorAll('span[class="line"]');
62
51
  for (let i = 0, len = lines.length; i < len; i++) {
63
52
  const el = lines[i];
64
- if ((props.line - minLine() - 1) === i) {
65
- el.classList.add('dev-overlay-error-line');
53
+ if (props.line - minLine() - 1 === i) {
54
+ el.classList.add("dev-overlay-error-line");
66
55
  }
67
56
  }
68
57
  }
69
58
  });
70
- return <div ref={ref} class="dev-overlay-code-view" style={{
71
- '--dev-overlay-code-view-start': minLine() + 1,
72
- }}/>;
59
+ return (<div ref={ref} class="dev-overlay-code-view" style={{
60
+ "--dev-overlay-code-view-start": minLine() + 1,
61
+ }}/>);
73
62
  }
@@ -9,7 +9,7 @@ import info from "../../../package.json" with { type: "json" };
9
9
  import { CodeView } from "./CodeView.jsx";
10
10
  import { createStackFrame } from "./createStackFrame.js";
11
11
  import download from "./download.js";
12
- import { ArrowLeftIcon, ArrowRightIcon, CameraIcon, DiscordIcon, GithubIcon, RefreshIcon, SolidStartIcon, ViewCompiledIcon, ViewOriginalIcon } from "./icons.jsx";
12
+ import { ArrowLeftIcon, ArrowRightIcon, CameraIcon, DiscordIcon, GithubIcon, RefreshIcon, SolidStartIcon, ViewCompiledIcon, ViewOriginalIcon, } from "./icons.jsx";
13
13
  import "./styles.css";
14
14
  export function classNames(...classes) {
15
15
  return classes.filter(Boolean).join(" ");
@@ -83,7 +83,7 @@ function StackFramesContent(props) {
83
83
  content: "",
84
84
  line: current.getLineNumber(),
85
85
  column: current.getColumnNumber(),
86
- name: current.getFunctionName()
86
+ name: current.getFunctionName(),
87
87
  })}
88
88
  </span>
89
89
  </div>}>
@@ -145,8 +145,8 @@ export default function DevOverlayDialog(props) {
145
145
  htmlToImage
146
146
  .toPng(current, {
147
147
  style: {
148
- transform: "scale(0.75)"
149
- }
148
+ transform: "scale(0.75)",
149
+ },
150
150
  })
151
151
  .then(url => {
152
152
  download(url, "start-screenshot.png");
@@ -1,2 +1,2 @@
1
- import { SourceMapConsumer } from 'source-map-js';
1
+ import { SourceMapConsumer } from "source-map-js";
2
2
  export default function getSourceMap(url: string, content: string): Promise<SourceMapConsumer | null>;
@@ -1,8 +1,8 @@
1
- import { SourceMapConsumer } from 'source-map-js';
1
+ import { SourceMapConsumer } from "source-map-js";
2
2
  const INLINE_SOURCEMAP_REGEX = /^data:application\/json[^,]+base64,/;
3
3
  const SOURCEMAP_REGEX = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*(?:\*\/)[ \t]*$)/;
4
4
  export default async function getSourceMap(url, content) {
5
- const lines = content.split('\n');
5
+ const lines = content.split("\n");
6
6
  let sourceMapUrl;
7
7
  for (let i = lines.length - 1; i >= 0 && !sourceMapUrl; i--) {
8
8
  const result = lines[i].match(SOURCEMAP_REGEX);
@@ -13,11 +13,11 @@ export default async function getSourceMap(url, content) {
13
13
  if (!sourceMapUrl) {
14
14
  return null;
15
15
  }
16
- if (!(INLINE_SOURCEMAP_REGEX.test(sourceMapUrl) || sourceMapUrl.startsWith('/'))) {
16
+ if (!(INLINE_SOURCEMAP_REGEX.test(sourceMapUrl) || sourceMapUrl.startsWith("/"))) {
17
17
  // Resolve path if it's a relative access
18
- const parsedURL = url.split('/');
18
+ const parsedURL = url.split("/");
19
19
  parsedURL[parsedURL.length - 1] = sourceMapUrl;
20
- sourceMapUrl = parsedURL.join('/');
20
+ sourceMapUrl = parsedURL.join("/");
21
21
  }
22
22
  const response = await fetch(sourceMapUrl);
23
23
  const rawSourceMap = await response.json();
@@ -1,28 +1,28 @@
1
- import type { JSX } from 'solid-js';
2
- export declare function ArrowRightIcon(props: JSX.IntrinsicElements['svg'] & {
1
+ import type { JSX } from "solid-js";
2
+ export declare function ArrowRightIcon(props: JSX.IntrinsicElements["svg"] & {
3
3
  title: string;
4
4
  }): JSX.Element;
5
- export declare function ArrowLeftIcon(props: JSX.IntrinsicElements['svg'] & {
5
+ export declare function ArrowLeftIcon(props: JSX.IntrinsicElements["svg"] & {
6
6
  title: string;
7
7
  }): JSX.Element;
8
- export declare function RefreshIcon(props: JSX.IntrinsicElements['svg'] & {
8
+ export declare function RefreshIcon(props: JSX.IntrinsicElements["svg"] & {
9
9
  title: string;
10
10
  }): JSX.Element;
11
- export declare function ViewCompiledIcon(props: JSX.IntrinsicElements['svg'] & {
11
+ export declare function ViewCompiledIcon(props: JSX.IntrinsicElements["svg"] & {
12
12
  title: string;
13
13
  }): JSX.Element;
14
- export declare function ViewOriginalIcon(props: JSX.IntrinsicElements['svg'] & {
14
+ export declare function ViewOriginalIcon(props: JSX.IntrinsicElements["svg"] & {
15
15
  title: string;
16
16
  }): JSX.Element;
17
- export declare function CameraIcon(props: JSX.IntrinsicElements['svg'] & {
17
+ export declare function CameraIcon(props: JSX.IntrinsicElements["svg"] & {
18
18
  title: string;
19
19
  }): JSX.Element;
20
- export declare function DiscordIcon(props: JSX.IntrinsicElements['svg'] & {
20
+ export declare function DiscordIcon(props: JSX.IntrinsicElements["svg"] & {
21
21
  title: string;
22
22
  }): JSX.Element;
23
- export declare function GithubIcon(props: JSX.IntrinsicElements['svg'] & {
23
+ export declare function GithubIcon(props: JSX.IntrinsicElements["svg"] & {
24
24
  title: string;
25
25
  }): JSX.Element;
26
- export declare function SolidStartIcon(props: JSX.IntrinsicElements['svg'] & {
26
+ export declare function SolidStartIcon(props: JSX.IntrinsicElements["svg"] & {
27
27
  title: string;
28
28
  }): JSX.Element;