@solidjs/start 0.4.10 → 0.5.0

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.
@@ -9,6 +9,13 @@ export interface StackFrameSource {
9
9
  column: number;
10
10
  }
11
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
+
12
19
  export function createStackFrame(
13
20
  stackframe: StackFrame,
14
21
  isCompiled: () => boolean,
@@ -24,7 +31,7 @@ export function createStackFrame(
24
31
  if (!source.fileName) {
25
32
  return null;
26
33
  }
27
- const response = await fetch(source.fileName);
34
+ const response = await fetch(getActualFileSource(source.fileName));
28
35
  if (!response.ok) {
29
36
  return null;
30
37
  }
@@ -51,6 +58,7 @@ export function createStackFrame(
51
58
  line: source.line,
52
59
  column: source.column,
53
60
  });
61
+ console.log('sourcemap', result);
54
62
 
55
63
  return {
56
64
  ...result,
@@ -25,12 +25,16 @@
25
25
  width: 75vw;
26
26
  margin-top: 2rem;
27
27
  margin-bottom: 2rem;
28
- z-index: 10;
29
28
  gap: 0.5rem;
30
29
  color: rgb(17 24 39);
31
30
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
32
31
  }
33
32
 
33
+ .dev-overlay-panel-container {
34
+ margin: 2rem;
35
+ z-index: 10;
36
+ }
37
+
34
38
  .dev-overlay-navbar {
35
39
  display: flex;
36
40
  flex-direction: row;
package/shared/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
- export { default as clientOnly } from "./clientOnly";
2
1
  export { FileRoutes } from "./FileRoutes";
2
+ export { GET } from "./GET";
3
3
  export { HttpHeader } from "./HttpHeader";
4
4
  export { HttpStatusCode } from "./HttpStatusCode";
5
+ export { default as clientOnly } from "./clientOnly";
5
6
 
package/shared/routes.ts CHANGED
@@ -1,24 +1,12 @@
1
1
  import fileRoutes from "vinxi/routes";
2
- import { HTTPMethod } from "vinxi/server";
3
2
 
4
3
  interface Route {
5
4
  path: string;
6
5
  id: string;
7
- type: "api" | "page";
6
+ type: "page";
8
7
  children?: Route[];
9
8
  }
10
9
 
11
- type MatchRoute = Route & {
12
- score: number;
13
- params: {
14
- type: "*" | ":";
15
- name: string;
16
- index: number;
17
- }[];
18
- matchSegments: (string | null)[];
19
- wildcard: boolean;
20
- };
21
-
22
10
  declare module "vinxi/routes" {
23
11
  export interface Register {
24
12
  route: {
@@ -30,49 +18,6 @@ declare module "vinxi/routes" {
30
18
  }
31
19
 
32
20
  export const pageRoutes = defineRoutes((fileRoutes as unknown as Route[]).filter(o => o.type === "page"));
33
- const apiRoutes = defineAPIRoutes((fileRoutes as unknown as Route[]).filter(o => o.type === "api"));
34
-
35
- export function matchAPIRoute(path: string, method: HTTPMethod) {
36
- const segments = path.replace(import.meta.env.SERVER_BASE_URL, "").split("/").filter(Boolean);
37
-
38
- routeLoop: for (const route of apiRoutes) {
39
- const matchSegments = route.matchSegments;
40
-
41
- if (
42
- segments.length < matchSegments.length ||
43
- (!route.wildcard && segments.length > matchSegments.length)
44
- ) {
45
- continue;
46
- }
47
-
48
- for (let index = 0; index < matchSegments.length; index++) {
49
- const match = matchSegments[index];
50
- if (!match) {
51
- continue;
52
- }
53
-
54
- if (segments[index] !== match) {
55
- continue routeLoop;
56
- }
57
- }
58
-
59
- const handler = route[`$${method}`];
60
- if (handler === "skip" || handler === undefined) {
61
- return;
62
- }
63
-
64
- const params: Record<string, string> = {};
65
- for (const { type, name, index } of route.params) {
66
- if (type === ":") {
67
- params[name] = segments[index];
68
- } else {
69
- params[name] = segments.slice(index).join("/");
70
- }
71
- }
72
-
73
- return { handler, params };
74
- }
75
- }
76
21
 
77
22
  function defineRoutes(fileRoutes: Route[]) {
78
23
  function processRoute(routes: Route[], route: Route, id: string, full: string) {
@@ -101,79 +46,3 @@ function defineRoutes(fileRoutes: Route[]) {
101
46
  }, []);
102
47
  }
103
48
 
104
- function defineAPIRoutes(routes: Route[]) {
105
- return routes
106
- .flatMap(route => {
107
- const paths = expandOptionals(route.path);
108
- return paths.map(path => ({ ...route, path }));
109
- })
110
- .map(routeToMatchRoute)
111
- .sort((a, b) => b.score - a.score);
112
- }
113
-
114
- // This is copied from https://github.com/solidjs/solid-router/blob/main/src/utils.ts
115
- function expandOptionals(pattern: string): string[] {
116
- let match = /(\/?\:[^\/]+)\?/.exec(pattern);
117
- if (!match) return [pattern];
118
-
119
- let prefix = pattern.slice(0, match.index);
120
- let suffix = pattern.slice(match.index + match[0].length);
121
- const prefixes: string[] = [prefix, (prefix += match[1])];
122
-
123
- // This section handles adjacent optional params. We don't actually want all permuations since
124
- // that will lead to equivalent apiRwhich have the same number of params. For example
125
- // `/:a?/:b?/:c`? only has the unique expansion: `/`, `/:a`, `/:a/:b`, `/:a/:b/:c` and we can
126
- // discard `/:b`, `/:c`, `/:b/:c` by building them up in order and not recursing. This also helps
127
- // ensure predictability where earlier params have precidence.
128
- while ((match = /^(\/\:[^\/]+)\?/.exec(suffix))) {
129
- prefixes.push((prefix += match[1]));
130
- suffix = suffix.slice(match[0].length);
131
- }
132
-
133
- return expandOptionals(suffix).reduce<string[]>(
134
- (results, expansion) => [...results, ...prefixes.map(p => p + expansion)],
135
- []
136
- );
137
- }
138
-
139
- function routeToMatchRoute(route: Route): MatchRoute {
140
- const segments = route.path.split("/").filter(Boolean);
141
- const params: { type: "*" | ":"; name: string; index: number }[] = [];
142
- const matchSegments: (string | null)[] = [];
143
- let score = 0;
144
- let wildcard = false;
145
-
146
- for (const [index, segment] of segments.entries()) {
147
- if (segment[0] === ":") {
148
- const name = segment.slice(1);
149
- score += 3;
150
- params.push({
151
- type: ":",
152
- name,
153
- index
154
- });
155
- matchSegments.push(null);
156
- } else if (segment[0] === "*") {
157
- score -= 1;
158
- params.push({
159
- type: "*",
160
- name: segment.slice(1),
161
- index
162
- });
163
- wildcard = true;
164
- } else {
165
- score += 4;
166
- if (!segment.match(/^\(.+\)$/)) {
167
- matchSegments.push(segment);
168
- }
169
- }
170
- }
171
-
172
- return {
173
- ...route,
174
- score,
175
- params,
176
- matchSegments,
177
- wildcard
178
- };
179
- }