Skip to content

Commit 83bd861

Browse files
lxsmnsycatilafassinaCopilot
authored
feat(1.0): seroval json (#2043)
Co-authored-by: Atila Fassina <atila@fassina.eu> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7144da5 commit 83bd861

File tree

25 files changed

+924
-274
lines changed

25 files changed

+924
-274
lines changed

.changeset/icy-rings-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": minor
3+
---
4+
5+
seroval json mode
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Serialization checks
2+
3+
This fixture is designed to point out the differences between Seroval 2 modes.
4+
5+
```ts
6+
export default defineConfig({
7+
middleware: "./src/middleware.ts",
8+
serialization: {
9+
mode: "js" // "json"
10+
}
11+
});
12+
```
13+
14+
On JS mode, seroval will use a custom serializer, while this improves performance and reduces payload size, it runs an `eval()` on client-side,
15+
so a strict CSP will block deserialization. On JSON mode, the payload will be slightly larger, but deserialization happens via `JSON.parse` and thus CSP will not block it.
16+
17+
> [!IMPORTANT]
18+
> For backwards compatibility, `v1` has "js" as the default.
19+
> On `v2`, "json" is the new default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "@solidjs/start/config";
2+
3+
export default defineConfig({
4+
middleware: "./src/middleware.ts",
5+
serialization: {
6+
mode: "js"
7+
}
8+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "fixture-serialization-modes",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vinxi dev",
6+
"build": "vinxi build",
7+
"start": "vinxi start",
8+
"version": "vinxi version"
9+
},
10+
"dependencies": {
11+
"@solidjs/meta": "^0.29.4",
12+
"@solidjs/router": "^0.15.0",
13+
"@solidjs/start": "workspace:*",
14+
"shieldwall": "^0.4.0",
15+
"solid-js": "^1.9.5",
16+
"vinxi": "^0.5.7"
17+
},
18+
"engines": {
19+
"node": ">=22"
20+
}
21+
}
664 Bytes
Binary file not shown.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
body {
2+
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
3+
}
4+
5+
a {
6+
margin-right: 1rem;
7+
}
8+
9+
main {
10+
text-align: center;
11+
padding: 1em;
12+
margin: 0 auto;
13+
}
14+
15+
h1 {
16+
color: #335d92;
17+
text-transform: uppercase;
18+
font-size: 4rem;
19+
font-weight: 100;
20+
line-height: 1.1;
21+
margin: 4rem auto;
22+
max-width: 14rem;
23+
}
24+
25+
p {
26+
max-width: 14rem;
27+
margin: 2rem auto;
28+
line-height: 1.35;
29+
}
30+
31+
@media (min-width: 480px) {
32+
h1 {
33+
max-width: none;
34+
}
35+
36+
p {
37+
max-width: none;
38+
}
39+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { MetaProvider, Title } from "@solidjs/meta";
2+
import { Router } from "@solidjs/router";
3+
import { FileRoutes } from "@solidjs/start/router";
4+
import { Suspense } from "solid-js";
5+
import "./app.css";
6+
7+
export default function App() {
8+
return (
9+
<Router
10+
root={props => (
11+
<MetaProvider>
12+
<Title>SolidStart - Basic</Title>
13+
<a href="/">Index</a>
14+
<a href="/about">About</a>
15+
<Suspense>{props.children}</Suspense>
16+
</MetaProvider>
17+
)}
18+
>
19+
<FileRoutes />
20+
</Router>
21+
);
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.increment {
2+
font-family: inherit;
3+
font-size: inherit;
4+
padding: 1em 2em;
5+
color: #335d92;
6+
background-color: rgba(68, 107, 158, 0.1);
7+
border-radius: 2em;
8+
border: 2px solid rgba(68, 107, 158, 0);
9+
outline: none;
10+
width: 200px;
11+
font-variant-numeric: tabular-nums;
12+
cursor: pointer;
13+
}
14+
15+
.increment:focus {
16+
border: 2px solid #335d92;
17+
}
18+
19+
.increment:active {
20+
background-color: rgba(68, 107, 158, 0.2);
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createSignal } from "solid-js";
2+
import "./Counter.css";
3+
4+
export default function Counter() {
5+
const [count, setCount] = createSignal(0);
6+
return (
7+
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
8+
Clicks: {count()}
9+
</button>
10+
);
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @refresh reload
2+
import { mount, StartClient } from "@solidjs/start/client";
3+
4+
mount(() => <StartClient />, document.getElementById("app")!);

0 commit comments

Comments
 (0)