@solidjs/start 2.0.0-beta.0 → 2.0.0-beta.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 (91) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/config/dev-server.js +3 -1
  3. package/dist/config/fs-router.d.ts +1 -1
  4. package/dist/http/index.d.ts +4 -4
  5. package/package.json +11 -5
  6. package/scripts/build.js +0 -15
  7. package/scripts/validate-imports.js +0 -316
  8. package/src/client/StartClient.tsx +0 -34
  9. package/src/client/index.tsx +0 -2
  10. package/src/client/mount.ts +0 -1
  11. package/src/client/spa/index.tsx +0 -9
  12. package/src/config/constants.ts +0 -19
  13. package/src/config/dev-server.ts +0 -157
  14. package/src/config/env.ts +0 -105
  15. package/src/config/fs-router.ts +0 -162
  16. package/src/config/fs-routes/fs-watcher.ts +0 -66
  17. package/src/config/fs-routes/index.ts +0 -136
  18. package/src/config/fs-routes/router.ts +0 -184
  19. package/src/config/fs-routes/tree-shake.ts +0 -324
  20. package/src/config/index.ts +0 -239
  21. package/src/config/lazy.ts +0 -132
  22. package/src/config/manifest.ts +0 -120
  23. package/src/config/utils.ts +0 -5
  24. package/src/config/vite-utils.ts +0 -113
  25. package/src/directives/bubble-function-declaration.ts +0 -33
  26. package/src/directives/compile.ts +0 -54
  27. package/src/directives/generate-unique-name.ts +0 -22
  28. package/src/directives/get-descriptive-name.ts +0 -39
  29. package/src/directives/get-import-identifier.ts +0 -34
  30. package/src/directives/get-root-statement-path.ts +0 -14
  31. package/src/directives/index.ts +0 -233
  32. package/src/directives/is-statement-top-level.ts +0 -13
  33. package/src/directives/paths.ts +0 -63
  34. package/src/directives/plugin.ts +0 -389
  35. package/src/directives/remove-unused-variables.ts +0 -70
  36. package/src/directives/types.ts +0 -12
  37. package/src/directives/xxhash32.ts +0 -214
  38. package/src/env.d.ts +0 -17
  39. package/src/fns/client.ts +0 -141
  40. package/src/fns/handler.spec.ts +0 -85
  41. package/src/fns/handler.ts +0 -287
  42. package/src/fns/registration.ts +0 -19
  43. package/src/fns/serialization.ts +0 -250
  44. package/src/fns/server.ts +0 -46
  45. package/src/fns/shared.ts +0 -116
  46. package/src/http/index.ts +0 -216
  47. package/src/index.tsx +0 -7
  48. package/src/internal.d.ts +0 -14
  49. package/src/middleware/index.ts +0 -92
  50. package/src/router.tsx +0 -37
  51. package/src/server/StartServer.tsx +0 -58
  52. package/src/server/assets/PatchVirtualDevStyles.tsx +0 -31
  53. package/src/server/assets/index.ts +0 -70
  54. package/src/server/assets/render.tsx +0 -46
  55. package/src/server/collect-styles.ts +0 -70
  56. package/src/server/fetchEvent.spec.ts +0 -85
  57. package/src/server/fetchEvent.ts +0 -36
  58. package/src/server/handler.ts +0 -261
  59. package/src/server/index.tsx +0 -29
  60. package/src/server/manifest/client-manifest.ts +0 -8
  61. package/src/server/manifest/dev-client-manifest.ts +0 -21
  62. package/src/server/manifest/dev-ssr-manifest.ts +0 -23
  63. package/src/server/manifest/prod-client-manifest.ts +0 -21
  64. package/src/server/manifest/prod-ssr-manifest.ts +0 -109
  65. package/src/server/manifest/ssr-manifest.ts +0 -10
  66. package/src/server/routes.ts +0 -126
  67. package/src/server/spa/StartServer.tsx +0 -42
  68. package/src/server/spa/handler.ts +0 -29
  69. package/src/server/spa/index.tsx +0 -5
  70. package/src/server/types.ts +0 -82
  71. package/src/server/util.ts +0 -12
  72. package/src/shared/ErrorBoundary.tsx +0 -52
  73. package/src/shared/GET.ts +0 -8
  74. package/src/shared/HttpHeader.tsx +0 -42
  75. package/src/shared/HttpStatusCode.ts +0 -27
  76. package/src/shared/clientOnly.ts +0 -44
  77. package/src/shared/dev-overlay/CodeView.tsx +0 -90
  78. package/src/shared/dev-overlay/DevOverlayDialog.tsx +0 -316
  79. package/src/shared/dev-overlay/createStackFrame.ts +0 -74
  80. package/src/shared/dev-overlay/download.ts +0 -6
  81. package/src/shared/dev-overlay/env.d.ts +0 -4
  82. package/src/shared/dev-overlay/get-source-map.ts +0 -33
  83. package/src/shared/dev-overlay/icons.tsx +0 -456
  84. package/src/shared/dev-overlay/index.tsx +0 -63
  85. package/src/shared/dev-overlay/styles.css +0 -292
  86. package/src/shared/lazy.ts +0 -52
  87. package/src/shared/serverFunction.ts +0 -10
  88. package/src/utils/debounce.ts +0 -10
  89. package/src/virtual.d.ts +0 -27
  90. package/tsconfig.json +0 -24
  91. package/vitest.config.ts +0 -9
@@ -1,316 +0,0 @@
1
- // @refresh skip
2
- import ErrorStackParser from "error-stack-parser";
3
- import * as htmlToImage from "html-to-image";
4
- import type { JSX } from "solid-js";
5
- import { createMemo, createSignal, ErrorBoundary, For, Show, Suspense } from "solid-js";
6
- import { Portal } from "solid-js/web";
7
- // @ts-ignore - terracotta module resolution issue with NodeNext
8
- import { Dialog, DialogOverlay, DialogPanel, Select, SelectOption } from "terracotta";
9
- import info from "../../../package.json" with { type: "json" };
10
- import { CodeView } from "./CodeView.tsx";
11
- import { createStackFrame, type StackFrameSource } from "./createStackFrame.ts";
12
- import download from "./download.ts";
13
- import {
14
- ArrowLeftIcon,
15
- ArrowRightIcon,
16
- CameraIcon,
17
- DiscordIcon,
18
- GithubIcon,
19
- RefreshIcon,
20
- SolidStartIcon,
21
- ViewCompiledIcon,
22
- ViewOriginalIcon,
23
- } from "./icons.tsx";
24
- import "./styles.css";
25
-
26
- export function classNames(...classes: (string | boolean | undefined)[]): string {
27
- return classes.filter(Boolean).join(" ");
28
- }
29
-
30
- interface ErrorInfoProps {
31
- error: unknown;
32
- }
33
-
34
- function ErrorInfo(props: ErrorInfoProps): JSX.Element {
35
- const error = createMemo(() => {
36
- const e = props.error;
37
-
38
- if (e instanceof Error) {
39
- return { name: e.name, message: e.message };
40
- }
41
-
42
- if (e instanceof ErrorEvent) {
43
- return { message: e.message };
44
- }
45
-
46
- return { message: (e as Error).toString() };
47
- });
48
-
49
- return (
50
- <span data-start-dev-overlay-error-info>
51
- <span data-start-dev-overlay-error-info-name>{error().name}</span>
52
- <span data-start-dev-overlay-error-info-message>{error().message}</span>
53
- </span>
54
- );
55
- }
56
-
57
- interface StackFramesContentProps {
58
- error: Error;
59
- isCompiled: boolean;
60
- }
61
-
62
- function getFileName(source: string): string {
63
- try {
64
- const path = source.startsWith("/") ? new URL(source, "file://") : new URL(source);
65
- const paths = path.pathname.split("/");
66
- return paths[paths.length - 1]!;
67
- } catch (error) {
68
- return getFileName(`/${source}`);
69
- }
70
- }
71
-
72
- function getFilePath(source: StackFrameSource) {
73
- const line = source.line ? `:${source.line}` : "";
74
- const column = source.column ? `:${source.column}` : "";
75
- return `${getFileName(source.source)}${line}${column}`;
76
- }
77
-
78
- function CodeFallback(): JSX.Element {
79
- return (
80
- <div data-start-dev-overlay-stack-frames-code-fallback>
81
- <span>Source not available.</span>
82
- </div>
83
- );
84
- }
85
-
86
- function StackFramesContent(props: StackFramesContentProps) {
87
- const stackframes = ErrorStackParser.parse(props.error);
88
-
89
- const [selectedFrame, setSelectedFrame] = createSignal(stackframes[0]!);
90
-
91
- return (
92
- <div data-start-dev-overlay-stack-frames-content>
93
- <div data-start-dev-overlay-stack-frames-code>
94
- <ErrorBoundary fallback={null}>
95
- {(() => {
96
- const data = createStackFrame(selectedFrame(), () => props.isCompiled);
97
- return (
98
- <Suspense fallback={<CodeFallback />}>
99
- <Show when={data()} keyed fallback={<CodeFallback />}>
100
- {source => (
101
- <>
102
- <span data-start-dev-overlay-stack-frames-code-source>{source.source}</span>
103
- <div data-start-dev-overlay-stack-frames-code-container>
104
- <CodeView
105
- fileName={source.source}
106
- line={source.line}
107
- content={source.content}
108
- />
109
- </div>
110
- </>
111
- )}
112
- </Show>
113
- </Suspense>
114
- );
115
- })()}
116
- </ErrorBoundary>
117
- </div>
118
- <Select<ErrorStackParser.StackFrame>
119
- data-start-dev-overlay-stack-frames
120
- value={selectedFrame()}
121
- onChange={setSelectedFrame}
122
- >
123
- <For each={stackframes}>
124
- {current => (
125
- <ErrorBoundary
126
- fallback={
127
- <div data-start-dev-overlay-stack-frame>
128
- <span data-start-dev-overlay-stack-frame-function>
129
- {current.functionName ?? "<anonymous>"}
130
- </span>
131
- <span data-start-dev-overlay-stack-frame-file>
132
- {getFilePath({
133
- source: current.getFileName()!,
134
- content: "",
135
- line: current.getLineNumber()!,
136
- column: current.getColumnNumber()!,
137
- name: current.getFunctionName(),
138
- })}
139
- </span>
140
- </div>
141
- }
142
- >
143
- {(() => {
144
- const data = createStackFrame(current, () => props.isCompiled);
145
- return (
146
- <Suspense>
147
- <Show when={data()} keyed>
148
- {source => (
149
- <SelectOption data-start-dev-overlay-stack-frame value={current}>
150
- <span data-start-dev-overlay-stack-frame-function>
151
- {source.name ?? "<anonymous>"}
152
- </span>
153
- <span data-start-dev-overlay-stack-frame-file>{getFilePath(source)}</span>
154
- </SelectOption>
155
- )}
156
- </Show>
157
- </Suspense>
158
- );
159
- })()}
160
- </ErrorBoundary>
161
- )}
162
- </For>
163
- </Select>
164
- </div>
165
- );
166
- }
167
-
168
- interface StackFramesProps {
169
- error: unknown;
170
- isCompiled: boolean;
171
- }
172
-
173
- function StackFrames(props: StackFramesProps) {
174
- return (
175
- <Show when={props.error instanceof Error && props.error} keyed>
176
- {current => <StackFramesContent error={current} isCompiled={props.isCompiled} />}
177
- </Show>
178
- );
179
- }
180
-
181
- interface DevOverlayDialogProps {
182
- errors: any[];
183
- resetError: () => void;
184
- }
185
-
186
- const ISSUE_THREAD = "https://github.com/solidjs/solid-start/issues/new";
187
- const DISCORD_INVITE = "https://discord.com/invite/solidjs";
188
-
189
- export default function DevOverlayDialog(props: DevOverlayDialogProps): JSX.Element {
190
- const [currentPage, setCurrentPage] = createSignal(1);
191
- const [isCompiled, setIsCompiled] = createSignal(false);
192
- const length = createMemo(() => props.errors.length);
193
-
194
- const truncated = createMemo(() => {
195
- return Math.min(currentPage(), length());
196
- });
197
-
198
- function goPrev() {
199
- setCurrentPage(c => {
200
- if (c > 1) {
201
- return c - 1;
202
- }
203
- return length();
204
- });
205
- }
206
-
207
- function goNext() {
208
- setCurrentPage(c => {
209
- if (c < length()) {
210
- return c + 1;
211
- }
212
- return 1;
213
- });
214
- }
215
-
216
- function toggleIsCompiled() {
217
- setIsCompiled(c => !c);
218
- }
219
-
220
- const [panel, setPanel] = createSignal<HTMLElement>();
221
-
222
- function downloadScreenshot() {
223
- const current = panel();
224
- if (current) {
225
- htmlToImage
226
- .toPng(current, {
227
- style: {
228
- transform: "scale(0.75)",
229
- },
230
- })
231
- .then(url => {
232
- download(url, "start-screenshot.png");
233
- });
234
- }
235
- }
236
-
237
- function redirectToGithub() {
238
- const url = new URL(ISSUE_THREAD);
239
- url.searchParams.append("labels", "bug");
240
- url.searchParams.append("labels", "needs+triage");
241
- url.searchParams.append("template", "bug.yml");
242
- url.searchParams.append("title", `[Bug?]:` + props.errors[truncated() - 1].toString());
243
- window.open(url, "_blank")!.focus();
244
- }
245
-
246
- function redirectToDiscord() {
247
- window.open(DISCORD_INVITE, "_blank")!.focus();
248
- }
249
-
250
- return (
251
- <Portal>
252
- <Dialog data-start-dev-overlay isOpen>
253
- <div>
254
- <DialogOverlay data-start-dev-overlay-background />
255
- <DialogPanel ref={setPanel} data-start-dev-overlay-panel-container>
256
- <div data-start-dev-overlay-panel>
257
- <div data-start-dev-overlay-navbar>
258
- <div data-start-dev-overlay-navbar-left>
259
- <div data-start-dev-overlay-version>
260
- <div>
261
- <SolidStartIcon title="Solid Start Version" />
262
- </div>
263
- <span>{info.version as string}</span>
264
- </div>
265
- <Show when={props.errors.length > 1}>
266
- <div data-start-dev-overlay-pagination>
267
- <button data-start-dev-overlay-button onClick={goPrev} type="button">
268
- <ArrowLeftIcon title="Go Previous" />
269
- </button>
270
- <div data-start-dev-overlay-page-counter>
271
- {`${truncated()} of ${props.errors.length}`}
272
- </div>
273
- <button data-start-dev-overlay-button onClick={goNext} type="button">
274
- <ArrowRightIcon title="Go Next" />
275
- </button>
276
- </div>
277
- </Show>
278
- </div>
279
- <div data-start-dev-overlay-controls>
280
- <button data-start-dev-overlay-button onClick={redirectToGithub} type="button">
281
- <GithubIcon title="Create an issue thread on Github" />
282
- </button>
283
- <button data-start-dev-overlay-button onClick={redirectToDiscord} type="button">
284
- <DiscordIcon title="Join our Discord Channel" />
285
- </button>
286
- <button data-start-dev-overlay-button onClick={downloadScreenshot} type="button">
287
- <CameraIcon title="Capture Error Overlay" />
288
- </button>
289
- <button data-start-dev-overlay-button onClick={toggleIsCompiled} type="button">
290
- <Show
291
- when={isCompiled()}
292
- fallback={<ViewOriginalIcon title="View Original Source" />}
293
- >
294
- <ViewCompiledIcon title="View Compiled Source" />
295
- </Show>
296
- </button>
297
- <button data-start-dev-overlay-button onClick={props.resetError} type="button">
298
- <RefreshIcon title="Reset Error" />
299
- </button>
300
- </div>
301
- </div>
302
- <Show when={props.errors[truncated() - 1]} keyed>
303
- {current => (
304
- <div data-start-dev-overlay-content>
305
- <ErrorInfo error={current} />
306
- <StackFrames error={current} isCompiled={isCompiled()} />
307
- </div>
308
- )}
309
- </Show>
310
- </div>
311
- </DialogPanel>
312
- </div>
313
- </Dialog>
314
- </Portal>
315
- );
316
- }
@@ -1,74 +0,0 @@
1
- import { type Accessor, createMemo, createResource } from "solid-js";
2
- import getSourceMap from "./get-source-map.ts";
3
-
4
- export interface StackFrameSource {
5
- content: string;
6
- source: string;
7
- name?: string;
8
- line: number;
9
- column: number;
10
- }
11
-
12
- function getActualFileSource(path: string): string {
13
- if (path.startsWith("file://")) {
14
- return "/_build/@fs" + path.substring("file://".length);
15
- }
16
- return path;
17
- }
18
-
19
- export function createStackFrame(stackframe: StackFrame, isCompiled: () => boolean) {
20
- const [data] = createResource(
21
- () => ({
22
- fileName: stackframe.fileName,
23
- line: stackframe.lineNumber,
24
- column: stackframe.columnNumber,
25
- functionName: stackframe.functionName,
26
- }),
27
- async source => {
28
- if (!source.fileName) {
29
- return null;
30
- }
31
- const response = await fetch(getActualFileSource(source.fileName));
32
- if (!response.ok) {
33
- return null;
34
- }
35
- const content = await response.text();
36
- const sourceMap = await getSourceMap(source.fileName, content);
37
- return {
38
- source,
39
- content,
40
- sourceMap,
41
- };
42
- },
43
- );
44
-
45
- const info = createMemo(() => {
46
- const current = data();
47
- if (!current) {
48
- return undefined;
49
- }
50
- const { source, content, sourceMap } = current;
51
-
52
- if (!isCompiled() && source.line && source.column && sourceMap) {
53
- const result = sourceMap.originalPositionFor({
54
- line: source.line,
55
- column: source.column,
56
- });
57
-
58
- return {
59
- ...result,
60
- content: sourceMap.sourceContentFor(result.source),
61
- } as StackFrameSource;
62
- }
63
-
64
- return {
65
- source: source.fileName,
66
- line: source.line,
67
- column: source.column,
68
- name: source.functionName,
69
- content,
70
- } as StackFrameSource;
71
- });
72
-
73
- return info as Accessor<StackFrameSource>;
74
- }
@@ -1,6 +0,0 @@
1
- export default function download(dataurl: string, filename: string) {
2
- const link = document.createElement("a");
3
- link.href = dataurl;
4
- link.download = filename;
5
- link.click();
6
- }
@@ -1,4 +0,0 @@
1
- declare module "*.json" {
2
- const data: Record<string, unknown>;
3
- export default data;
4
- }
@@ -1,33 +0,0 @@
1
- import { type RawSourceMap, SourceMapConsumer } from "source-map-js";
2
-
3
- const INLINE_SOURCEMAP_REGEX = /^data:application\/json[^,]+base64,/;
4
- const SOURCEMAP_REGEX =
5
- /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*(?:\*\/)[ \t]*$)/;
6
-
7
- export default async function getSourceMap(
8
- url: string,
9
- content: string,
10
- ): Promise<SourceMapConsumer | null> {
11
- const lines = content.split("\n");
12
- let sourceMapUrl: string | undefined;
13
- for (let i = lines.length - 1; i >= 0 && !sourceMapUrl; i--) {
14
- const result = lines[i]!.match(SOURCEMAP_REGEX);
15
- if (result) {
16
- sourceMapUrl = result[1];
17
- }
18
- }
19
-
20
- if (!sourceMapUrl) {
21
- return null;
22
- }
23
-
24
- if (!(INLINE_SOURCEMAP_REGEX.test(sourceMapUrl) || sourceMapUrl.startsWith("/"))) {
25
- // Resolve path if it's a relative access
26
- const parsedURL = url.split("/");
27
- parsedURL[parsedURL.length - 1] = sourceMapUrl;
28
- sourceMapUrl = parsedURL.join("/");
29
- }
30
- const response = await fetch(sourceMapUrl);
31
- const rawSourceMap: RawSourceMap = await response.json();
32
- return new SourceMapConsumer(rawSourceMap);
33
- }