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 26
26
"material-design-icons" : " ^3.0.1" ,
27
27
"monaco-editor" : " ^0.10.1" ,
28
28
"npm-run-all" : " ^4.1.2" ,
29
+ "pako" : " ^1.0.6" ,
29
30
"rimraf" : " ^2.6.2" ,
30
31
"shelljs" : " ^0.7.8" ,
31
32
"string-replace-loader" : " ^1.3.0" ,
Original file line number Diff line number Diff line change
1
+ import pako from "pako"
1
2
import defaultCode from "./default-code.js"
2
3
import defaultConfig from "./default-config.js"
3
4
@@ -43,7 +44,10 @@ export function deserializeState(serializedText) {
43
44
const state = createDefaultState ( )
44
45
45
46
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
47
51
const json = JSON . parse ( jsonText )
48
52
49
53
if ( typeof json === "object" && json !== null ) {
@@ -81,5 +85,7 @@ export function serializeState(state) {
81
85
} ,
82
86
{ }
83
87
)
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 )
85
91
}
You can’t perform that action at this time.
0 commit comments