@solidjs/start 0.7.6 → 0.7.7

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.
@@ -68,8 +68,25 @@ async function handleServerFunction(h3Event) {
68
68
  // grab bound arguments from url when no JS
69
69
  if (!instance || h3Event.method === "GET") {
70
70
  const args = url.searchParams.get("args");
71
- if (args)
72
- JSON.parse(args).forEach((arg) => parsed.push(arg));
71
+ if (args) {
72
+ const json = JSON.parse(args);
73
+ (json.t
74
+ ? fromJSON(json, {
75
+ plugins: [
76
+ CustomEventPlugin,
77
+ DOMExceptionPlugin,
78
+ EventPlugin,
79
+ FormDataPlugin,
80
+ HeadersPlugin,
81
+ ReadableStreamPlugin,
82
+ RequestPlugin,
83
+ ResponsePlugin,
84
+ URLSearchParamsPlugin,
85
+ URLPlugin
86
+ ]
87
+ })
88
+ : json).forEach((arg) => parsed.push(arg));
89
+ }
73
90
  }
74
91
  if (h3Event.method === "POST") {
75
92
  const contentType = request.headers.get("content-type");
@@ -108,7 +125,7 @@ async function handleServerFunction(h3Event) {
108
125
  /* @ts-ignore */
109
126
  sharedConfig.context = { event };
110
127
  event.locals.serverFunctionMeta = {
111
- id: filepath + "#" + name,
128
+ id: filepath + "#" + name
112
129
  };
113
130
  return serverFunction(...parsed);
114
131
  });
@@ -97,6 +97,18 @@ function createRequest(base, id, instance, options) {
97
97
  }
98
98
  });
99
99
  }
100
+ const plugins = [
101
+ CustomEventPlugin,
102
+ DOMExceptionPlugin,
103
+ EventPlugin,
104
+ FormDataPlugin,
105
+ HeadersPlugin,
106
+ ReadableStreamPlugin,
107
+ RequestPlugin,
108
+ ResponsePlugin,
109
+ URLSearchParamsPlugin,
110
+ URLPlugin
111
+ ];
100
112
  async function fetchServerFunction(base, id, options, args) {
101
113
  const instance = `server-fn:${INSTANCE++}`;
102
114
  const response = await (args.length === 0
@@ -105,20 +117,7 @@ async function fetchServerFunction(base, id, options, args) {
105
117
  ? createRequest(base, id, instance, { ...options, body: args[0] })
106
118
  : createRequest(base, id, instance, {
107
119
  ...options,
108
- body: JSON.stringify(await Promise.resolve(toJSONAsync(args, {
109
- plugins: [
110
- CustomEventPlugin,
111
- DOMExceptionPlugin,
112
- EventPlugin,
113
- FormDataPlugin,
114
- HeadersPlugin,
115
- ReadableStreamPlugin,
116
- RequestPlugin,
117
- ResponsePlugin,
118
- URLSearchParamsPlugin,
119
- URLPlugin
120
- ]
121
- }))),
120
+ body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
122
121
  headers: { ...options.headers, "Content-Type": "application/json" }
123
122
  }));
124
123
  if (response.headers.get("Location") ||
@@ -161,10 +160,10 @@ export function createServerReference(fn, id, name) {
161
160
  if (prop === "withOptions") {
162
161
  const url = `${baseURL}/_server/?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
163
162
  return (options) => {
164
- const fn = (...args) => {
163
+ const fn = async (...args) => {
165
164
  const encodeArgs = options.method && options.method.toUpperCase() === "GET";
166
165
  return fetchServerFunction(encodeArgs
167
- ? url + (args.length ? `&args=${JSON.stringify(args)}` : "")
166
+ ? url + (args.length ? `&args=${JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins })))}` : "")
168
167
  : `${baseURL}/_server`, `${id}#${name}`, options, encodeArgs ? [] : args);
169
168
  };
170
169
  fn.url = url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",