@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20
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.
- package/README.md +1 -1
- package/dist/server.dev.js +5065 -0
- package/dist/server.js +1757 -355
- package/dist/{server.cjs → server.observe.js} +1951 -558
- package/dist/{dev.cjs → web.dev.js} +945 -550
- package/dist/web.js +635 -332
- package/dist/{dev.js → web.observe.js} +688 -403
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2549 -0
- package/frames/dist/server.js +1688 -3005
- package/frames/dist/server.observe.js +2548 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +242 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +85 -158
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +109 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +2714 -297
- package/server-functions/dist/server.js +2595 -271
- package/server-functions/dist/server.observe.js +3594 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +85 -158
- package/types/frames/server.d.ts +2 -2
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +85 -158
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +238 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +539 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-mock.d.ts +120 -13
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +571 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -262
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
|
@@ -1,8 +1,91 @@
|
|
|
1
1
|
import { configureServerFunctionsClient, serializeString, getServerFunctionsCodec } from '@solidjs/web/server-functions/client';
|
|
2
2
|
|
|
3
|
+
const REFUSED_ARGUMENT = Symbol("solid.serverFunction.refusedArgument");
|
|
4
|
+
function refusedArgumentError(name = "Response or Request") {
|
|
5
|
+
const error = new TypeError(`Server function arguments cannot carry Response or Request values (got a ${name}). ` + "Pass the data it holds — its body, headers or url — instead.");
|
|
6
|
+
error[REFUSED_ARGUMENT] = true;
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
function encodeRefusal(name) {
|
|
10
|
+
const refuse = () => {
|
|
11
|
+
throw refusedArgumentError(name);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
tag: `seroval-plugins/web/${name}`,
|
|
15
|
+
test: value => typeof globalThis[name] === "function" && value instanceof globalThis[name],
|
|
16
|
+
parse: {
|
|
17
|
+
sync: refuse,
|
|
18
|
+
async: refuse,
|
|
19
|
+
stream: refuse
|
|
20
|
+
},
|
|
21
|
+
serialize: refuse,
|
|
22
|
+
deserialize: refuse
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let encodeRefusals;
|
|
26
|
+
function argumentEncodeCodec(codec, extra = []) {
|
|
27
|
+
if (!encodeRefusals) encodeRefusals = [encodeRefusal("Response"), encodeRefusal("Request")];
|
|
28
|
+
const refusals = extra.length ? [...extra, ...encodeRefusals] : encodeRefusals;
|
|
29
|
+
return {
|
|
30
|
+
...codec,
|
|
31
|
+
plugins: codec && codec.plugins ? [...refusals, ...codec.plugins] : refusals
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const UPLOAD_ARGS_PART = "args";
|
|
36
|
+
const UPLOAD_FILE_PART = "file";
|
|
37
|
+
const UPLOAD_TAG = "solid/server-function-upload";
|
|
38
|
+
function isBlob(value) {
|
|
39
|
+
if (typeof Blob !== "undefined" && value instanceof Blob) return true;
|
|
40
|
+
return typeof value === "object" && value !== null && typeof value.size === "number" && typeof value.type === "string" && typeof value.arrayBuffer === "function" && typeof value.slice === "function";
|
|
41
|
+
}
|
|
42
|
+
function malformed() {
|
|
43
|
+
return new TypeError("Malformed server function upload");
|
|
44
|
+
}
|
|
45
|
+
function createUploadSerializer(files) {
|
|
46
|
+
const indexOf = value => {
|
|
47
|
+
const index = files.indexOf(value);
|
|
48
|
+
return index === -1 ? files.push(value) - 1 : index;
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
tag: UPLOAD_TAG,
|
|
52
|
+
test: isBlob,
|
|
53
|
+
parse: {
|
|
54
|
+
sync: (value, ctx) => ({
|
|
55
|
+
i: ctx.parse(indexOf(value))
|
|
56
|
+
}),
|
|
57
|
+
async: async (value, ctx) => ({
|
|
58
|
+
i: await ctx.parse(indexOf(value))
|
|
59
|
+
}),
|
|
60
|
+
stream: (value, ctx) => ({
|
|
61
|
+
i: ctx.parse(indexOf(value))
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
serialize: (node, ctx) => ctx.serialize(node.i),
|
|
65
|
+
deserialize: () => {
|
|
66
|
+
throw malformed();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function createUploadBody(serialized, files) {
|
|
71
|
+
const form = new FormData();
|
|
72
|
+
form.set(UPLOAD_ARGS_PART, serialized);
|
|
73
|
+
const blobs = await Promise.all(files.map(async file => file instanceof Blob ? file : new Blob([await file.arrayBuffer()], {
|
|
74
|
+
type: file.type
|
|
75
|
+
})));
|
|
76
|
+
for (let i = 0; i < blobs.length; i++) {
|
|
77
|
+
form.set(UPLOAD_FILE_PART + i, blobs[i], files[i].name ?? "blob");
|
|
78
|
+
}
|
|
79
|
+
return form;
|
|
80
|
+
}
|
|
81
|
+
|
|
3
82
|
function enableRichArguments() {
|
|
4
83
|
configureServerFunctionsClient({
|
|
5
|
-
serializeArgs: args =>
|
|
84
|
+
serializeArgs: async args => {
|
|
85
|
+
const files = [];
|
|
86
|
+
const serialized = await serializeString(args, argumentEncodeCodec(getServerFunctionsCodec(), [createUploadSerializer(files)]));
|
|
87
|
+
return files.length ? await createUploadBody(serialized, files) : serialized;
|
|
88
|
+
}
|
|
6
89
|
});
|
|
7
90
|
}
|
|
8
91
|
|