File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 2626 "material-design-icons" : " ^3.0.1" ,
2727 "monaco-editor" : " ^0.10.1" ,
2828 "npm-run-all" : " ^4.1.2" ,
29+ "pako" : " ^1.0.6" ,
2930 "rimraf" : " ^2.6.2" ,
3031 "shelljs" : " ^0.7.8" ,
3132 "string-replace-loader" : " ^1.3.0" ,
Original file line number Diff line number Diff line change 1+ import pako from "pako"
12import defaultCode from "./default-code.js"
23import defaultConfig from "./default-config.js"
34
@@ -43,7 +44,10 @@ export function deserializeState(serializedText) {
4344 const state = createDefaultState ( )
4445
4546 try {
46- const jsonText = decodeFromBase64 ( serializedText )
47+ // For backward compatibility, it can address non-compressed data.
48+ const compressed = ! serializedText . startsWith ( "eyJj" )
49+ const decodedText = decodeFromBase64 ( serializedText )
50+ const jsonText = compressed ? pako . inflate ( decodedText , { to : "string" } ) : decodedText
4751 const json = JSON . parse ( jsonText )
4852
4953 if ( typeof json === "object" && json !== null ) {
@@ -81,5 +85,7 @@ export function serializeState(state) {
8185 } ,
8286 { }
8387 )
84- return encodeToBase64 ( JSON . stringify ( { code, rules } ) )
88+ const jsonText = JSON . stringify ( { code, rules } )
89+ const compressedText = pako . deflate ( jsonText , { to : "string" } )
90+ return encodeToBase64 ( compressedText )
8591}
You can’t perform that action at this time.
0 commit comments