File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,24 @@ function decodeIZL3Bytes(bytes) {
191191 return untinyifyClone ( obj ) ;
192192}
193193
194+ function bytesToBase64 ( bytes ) {
195+ // Convert Uint8Array -> base64 without blowing the call stack.
196+ let binary = "" ;
197+ const chunkSize = 0x8000 ;
198+ for ( let i = 0 ; i < bytes . length ; i += chunkSize ) {
199+ const chunk = bytes . subarray ( i , i + chunkSize ) ;
200+ binary += String . fromCharCode ( ...chunk ) ;
201+ }
202+ return btoa ( binary ) ;
203+ }
204+
205+ function encodeStringIZL3 ( levelData ) {
206+ const bytes = encodeIZL3 ( levelData ) ;
207+ // Strip the "IZL3" header; strings store only the compressed payload.
208+ const compressed = bytes . slice ( 4 ) ;
209+ return "|" + bytesToBase64 ( compressed ) ;
210+ }
211+
194212function stringToBytesIZL3 ( str ) {
195213 // Remove "|" prefix if present
196214 const base64 = str [ 0 ] === "|" ? str . slice ( 1 ) : str ;
Original file line number Diff line number Diff line change 234234 levelDataElement . style . borderRadius = "10px" ;
235235 levelDataElement . style . fontSize = "large" ;
236236 levelDataElement . style . zIndex = "1000" ;
237- levelDataElement . value = stringifyCloneTiny ( cloneFromPlants ( l , f ) ) ;
237+ levelDataElement . value = encodeStringIZL3 ( cloneFromPlants ( l , f ) ) ;
238238 $ ( "dAll" ) . appendChild ( levelDataElement ) ;
239239 const copyButtonElement = document . createElement ( "button" ) ;
240240 copyButtonElement . style . position = "absolute" ;
You can’t perform that action at this time.
0 commit comments