@solidjs/start 2.0.0-alpha.0 → 2.0.0-alpha.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +14 -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/fs-router.js +10 -22
  6. package/dist/config/fs-routes/fs-watcher.js +4 -4
  7. package/dist/config/fs-routes/index.js +4 -6
  8. package/dist/config/fs-routes/router.js +5 -5
  9. package/dist/config/fs-routes/tree-shake.js +12 -21
  10. package/dist/config/index.js +33 -36
  11. package/dist/config/lazy.js +9 -9
  12. package/dist/config/manifest.js +1 -1
  13. package/dist/http/index.d.ts +1 -4
  14. package/dist/http/index.js +3 -5
  15. package/dist/index.d.ts +0 -1
  16. package/dist/router.jsx +2 -2
  17. package/dist/server/assets/index.js +1 -1
  18. package/dist/server/assets/render.jsx +2 -2
  19. package/dist/server/fetchEvent.spec.js +1 -1
  20. package/dist/server/handler.js +29 -15
  21. package/dist/server/index.d.ts +1 -0
  22. package/dist/server/manifest/dev-client-manifest.js +1 -1
  23. package/dist/server/manifest/dev-ssr-manifest.js +1 -1
  24. package/dist/server/manifest/prod-ssr-manifest.js +7 -12
  25. package/dist/server/routes.js +3 -3
  26. package/dist/server/server-fns-runtime.js +2 -2
  27. package/dist/server/server-functions-handler.js +6 -11
  28. package/dist/server/server-runtime.js +8 -8
  29. package/dist/shared/dev-overlay/CodeView.d.ts +1 -1
  30. package/dist/shared/dev-overlay/CodeView.jsx +23 -34
  31. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +4 -4
  32. package/dist/shared/dev-overlay/get-source-map.d.ts +1 -1
  33. package/dist/shared/dev-overlay/get-source-map.js +5 -5
  34. package/dist/shared/dev-overlay/icons.d.ts +10 -10
  35. package/dist/shared/dev-overlay/icons.jsx +91 -91
  36. package/dist/shared/dev-overlay/index.jsx +1 -1
  37. package/dist/shared/lazy.js +4 -2
  38. package/env.d.ts +9 -0
  39. package/package.json +5 -4
  40. package/scripts/build.js +3 -3
  41. package/scripts/validate-imports.js +8 -8
  42. package/src/client/mount.ts +1 -114
  43. package/src/config/constants.ts +3 -3
  44. package/src/config/dev-server.ts +95 -99
  45. package/src/config/fs-router.ts +140 -155
  46. package/src/config/fs-routes/fs-watcher.ts +57 -61
  47. package/src/config/fs-routes/index.ts +117 -119
  48. package/src/config/fs-routes/router.ts +7 -7
  49. package/src/config/fs-routes/tree-shake.ts +342 -363
  50. package/src/config/index.ts +36 -39
  51. package/src/config/lazy.ts +13 -13
  52. package/src/config/manifest.ts +5 -5
  53. package/src/config/vite-utils.ts +2 -6
  54. package/src/env.d.ts +10 -28
  55. package/src/http/index.ts +105 -142
  56. package/src/index.tsx +0 -12
  57. package/src/internal.d.ts +1 -1
  58. package/src/middleware/index.ts +39 -49
  59. package/src/router.tsx +4 -3
  60. package/src/server/StartServer.tsx +1 -7
  61. package/src/server/assets/index.ts +1 -1
  62. package/src/server/assets/render.tsx +6 -2
  63. package/src/server/collect-styles.ts +63 -70
  64. package/src/server/fetchEvent.spec.ts +71 -75
  65. package/src/server/fetchEvent.ts +17 -17
  66. package/src/server/handler.ts +136 -129
  67. package/src/server/index.tsx +13 -0
  68. package/src/server/manifest/client-manifest.ts +1 -1
  69. package/src/server/manifest/dev-client-manifest.ts +7 -5
  70. package/src/server/manifest/dev-ssr-manifest.ts +8 -6
  71. package/src/server/manifest/prod-client-manifest.ts +7 -4
  72. package/src/server/manifest/prod-ssr-manifest.ts +78 -94
  73. package/src/server/manifest/ssr-manifest.ts +4 -2
  74. package/src/server/routes.ts +96 -108
  75. package/src/server/server-fns-runtime.ts +3 -3
  76. package/src/server/server-functions-handler.ts +294 -319
  77. package/src/server/server-runtime.ts +13 -13
  78. package/src/server/spa/handler.ts +12 -12
  79. package/src/server/types.ts +46 -46
  80. package/src/server/util.ts +4 -4
  81. package/src/shared/ErrorBoundary.tsx +1 -1
  82. package/src/shared/HttpHeader.tsx +20 -20
  83. package/src/shared/HttpStatusCode.ts +14 -14
  84. package/src/shared/clientOnly.ts +3 -3
  85. package/src/shared/dev-overlay/CodeView.tsx +43 -46
  86. package/src/shared/dev-overlay/DevOverlayDialog.tsx +4 -4
  87. package/src/shared/dev-overlay/createStackFrame.ts +59 -62
  88. package/src/shared/dev-overlay/env.d.ts +2 -2
  89. package/src/shared/dev-overlay/get-source-map.ts +5 -7
  90. package/src/shared/dev-overlay/icons.tsx +289 -121
  91. package/src/shared/dev-overlay/index.tsx +1 -1
  92. package/src/shared/lazy.ts +4 -3
  93. package/src/shared/serverFunction.ts +1 -1
  94. package/src/virtual.d.ts +10 -10
  95. package/tsconfig.json +2 -2
  96. package/vitest.config.ts +2 -2
@@ -28,9 +28,7 @@ function createWrapperFunction(h3Function) {
28
28
  }
29
29
  else {
30
30
  args[0] =
31
- event instanceof h3.H3Event || event.__is_event__
32
- ? event
33
- : event[HTTPEventSymbol];
31
+ event instanceof h3.H3Event || event.__is_event__ ? event : event[HTTPEventSymbol];
34
32
  }
35
33
  return h3Function(...args);
36
34
  });
@@ -69,7 +67,7 @@ export const setResponseHeaders = (values) => {
69
67
  };
70
68
  export const setResponseHeader = (name, value) => {
71
69
  const headers = getEvent().res.headers;
72
- (Array.isArray(value) ? value : [value]).forEach((value) => {
70
+ (Array.isArray(value) ? value : [value]).forEach(value => {
73
71
  headers.set(name, value);
74
72
  });
75
73
  };
@@ -81,7 +79,7 @@ export const appendResponseHeaders = (values) => {
81
79
  };
82
80
  export const appendResponseHeader = (name, value) => {
83
81
  const headers = getEvent().res.headers;
84
- (Array.isArray(value) ? value : [value]).forEach((value) => {
82
+ (Array.isArray(value) ? value : [value]).forEach(value => {
85
83
  headers.append(name, value);
86
84
  });
87
85
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta } from "./server/types.ts";
2
1
  export { default as clientOnly } from "./shared/clientOnly.ts";
3
2
  export { GET } from "./shared/GET.ts";
4
3
  export { HttpHeader } from "./shared/HttpHeader.tsx";
package/dist/router.jsx CHANGED
@@ -10,10 +10,10 @@ export function createRoutes() {
10
10
  ...(route.$$route ? route.$$route.require().route : undefined),
11
11
  info: {
12
12
  ...(route.$$route ? route.$$route.require().route.info : {}),
13
- filesystem: true
13
+ filesystem: true,
14
14
  },
15
15
  component,
16
- children: route.children ? route.children.map(createRoute) : undefined
16
+ children: route.children ? route.children.map(createRoute) : undefined,
17
17
  };
18
18
  }
19
19
  const routes = routeConfigs.map(createRoute);
@@ -13,7 +13,7 @@ const getEntity = (registry, asset) => {
13
13
  }
14
14
  const entity = (registry[key] ??= {
15
15
  key,
16
- consumers: 0
16
+ consumers: 0,
17
17
  });
18
18
  return entity;
19
19
  };
@@ -6,9 +6,9 @@ const assetMap = {
6
6
  {" "}
7
7
  </script>) : null;
8
8
  },
9
- noscript: (props) => (<noscript {...props.attrs}>{props.children}</noscript>)
9
+ noscript: (props) => (<noscript {...props.attrs}>{props.children}</noscript>),
10
10
  };
11
11
  export function renderAsset(asset, nonce) {
12
- let { tag, attrs: { key, ...attrs } = { key: undefined }, children } = asset;
12
+ let { tag, attrs: { key, ...attrs } = { key: undefined }, children, } = asset;
13
13
  return assetMap[tag]({ attrs: { ...attrs, nonce }, key, children });
14
14
  }
@@ -1,6 +1,6 @@
1
1
  import * as h3 from "h3";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
- import { createFetchEvent, getFetchEvent, mergeResponseHeaders, } from "./fetchEvent.js";
3
+ import { createFetchEvent, getFetchEvent, mergeResponseHeaders } from "./fetchEvent.js";
4
4
  vi.mock(import("h3"), async (mod) => {
5
5
  return {
6
6
  ...(await mod()),
@@ -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,7 +52,7 @@ 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);
@@ -118,7 +114,7 @@ export async function createPageEvent(ctx) {
118
114
  const manifest = getSsrManifest(import.meta.env.SSR && import.meta.env.DEV ? "ssr" : "client");
119
115
  // Handle Vite build.cssCodeSplit
120
116
  // 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') : [];
117
+ const mergedCSS = import.meta.env.PROD ? await manifest.getAssets("style.css") : [];
122
118
  const assets = [
123
119
  ...mergedCSS,
124
120
  ...(await manifest.getAssets(import.meta.env.START_CLIENT_ENTRY)),
@@ -151,10 +147,7 @@ function initFromFlash(ctx) {
151
147
  const param = JSON.parse(flash);
152
148
  if (!param || !param.result)
153
149
  return;
154
- const input = [
155
- ...param.input.slice(0, -1),
156
- new Map(param.input[param.input.length - 1]),
157
- ];
150
+ const input = [...param.input.slice(0, -1), new Map(param.input[param.input.length - 1])];
158
151
  const result = param.error ? new Error(param.result) : param.result;
159
152
  return {
160
153
  input,
@@ -192,14 +185,35 @@ function produceResponseWithEventHeaders(res) {
192
185
  let ret = res;
193
186
  // Response.redirect returns an immutable value, so we clone on any redirect just in case
194
187
  if (300 <= res.status && res.status < 400) {
188
+ const cookies = res.headers.getSetCookie?.() ?? [];
189
+ const headers = new Headers();
190
+ res.headers.forEach((value, key) => {
191
+ if (key.toLowerCase() !== "set-cookie") {
192
+ headers.set(key, value);
193
+ }
194
+ });
195
+ for (const cookie of cookies) {
196
+ headers.append("Set-Cookie", cookie);
197
+ }
195
198
  ret = new Response(res.body, {
196
199
  status: res.status,
197
200
  statusText: res.statusText,
198
- headers: Object.fromEntries(res.headers.entries())
201
+ headers,
199
202
  });
200
203
  }
204
+ const eventCookies = event.response.headers.getSetCookie?.() ?? [];
205
+ for (const cookie of eventCookies) {
206
+ ret.headers.append("Set-Cookie", cookie);
207
+ }
201
208
  for (const [name, value] of event.response.headers) {
202
- ret.headers.set(name, value);
209
+ if (name.toLowerCase() !== "set-cookie") {
210
+ ret.headers.set(name, value);
211
+ }
203
212
  }
204
213
  return ret;
205
214
  }
215
+ function stripBaseUrl(path) {
216
+ if (import.meta.env.BASE_URL === "/" || import.meta.env.BASE_URL === "")
217
+ return path;
218
+ return path.slice(import.meta.env.BASE_URL.length);
219
+ }
@@ -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") ||
@@ -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;