Skip to content

Commit 415009f

Browse files
committed
bring back json5 for now
1 parent 35d04f6 commit 415009f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

reflex/.templates/web/utils/helpers/upload.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import JSON5 from "json5";
12
import env from "$/env.json";
23

34
/**
@@ -47,7 +48,7 @@ export const uploadFiles = async (
4748
// So only process _new_ chunks beyond resp_idx.
4849
chunks.slice(resp_idx).map((chunk_json) => {
4950
try {
50-
const chunk = JSON.parse(chunk_json);
51+
const chunk = JSON5.parse(chunk_json);
5152
event_callbacks.map((f, ix) => {
5253
f(chunk)
5354
.then(() => {

reflex/.templates/web/utils/state.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// State management for Reflex web apps.
22
import io from "socket.io-client";
3+
import JSON5 from "json5";
34
import env from "$/env.json";
45
import reflexEnvironment from "$/reflex.json";
56
import Cookies from "universal-cookie";
@@ -542,6 +543,13 @@ export const connect = async (
542543
});
543544
// Ensure undefined fields in events are sent as null instead of removed
544545
socket.current.io.encoder.replacer = (k, v) => (v === undefined ? null : v);
546+
socket.current.io.decoder.tryParse = (str) => {
547+
try {
548+
return JSON5.parse(str);
549+
} catch (e) {
550+
return false;
551+
}
552+
};
545553

546554
function checkVisibility() {
547555
if (document.visibilityState === "visible") {

reflex/constants/installer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def DEPENDENCIES(cls) -> dict[str, str]:
123123
A dictionary of dependencies with their versions.
124124
"""
125125
return {
126+
"json5": "2.2.3",
126127
"react-router": cls._react_router_version,
127128
"react-router-dom": cls._react_router_version,
128129
"@react-router/node": cls._react_router_version,
@@ -142,11 +143,11 @@ def DEPENDENCIES(cls) -> dict[str, str]:
142143
"postcss-import": "16.1.1",
143144
"@react-router/dev": _react_router_version,
144145
"@react-router/fs-routes": _react_router_version,
145-
"vite": "npm:[email protected].9",
146+
"vite": "npm:[email protected].12",
146147
}
147148
OVERRIDES = {
148149
# This should always match the `react` version in DEPENDENCIES for recharts compatibility.
149150
"react-is": _react_version,
150151
"cookie": "1.0.2",
151-
"vite": "npm:[email protected].9",
152+
"vite": "npm:[email protected].12",
152153
}

0 commit comments

Comments
 (0)