fix profile export / import to support utf8 / unicode

This commit is contained in:
Stewart Allen 2021-02-11 09:23:22 -05:00
commit f98b0642c9
3 changed files with 5 additions and 3 deletions

1
app.js
View file

@ -246,6 +246,7 @@ const script = {
"ext/tween",
"ext/fsave",
"ext/earcut", // work.test
"ext/base64",
"add/array",
"add/three",
"geo/base",

View file

@ -21,6 +21,7 @@
"slicer"
],
"dependencies": {
"base64-js": "^1.5.1",
"buffer-crc32": "^0.2.13",
"compression": "^1.7.4",
"connect": "^3.7.0",

View file

@ -2194,7 +2194,7 @@
function settingsImport(data, ask) {
if (typeof(data) === 'string') {
try {
data = JSON.parse(atob(data));
data = JSON.parse(new TextDecoder().decode(base64js.toByteArray(data)));
} catch (e) {
UC.alert('invalid settings format');
console.log('data',data);
@ -2269,7 +2269,7 @@
const shot = opts.work || opts.screen ? SPACE.screenshot() : undefined;
const work = opts.work ? KIRI.codec.encode(WIDGETS,{_json_:true}) : undefined;
const view = opts.work ? SPACE.view.save() : undefined;
return btoa(JSON.stringify({
return base64js.fromByteArray(new TextEncoder().encode(JSON.stringify({
settings: settings,
version: KIRI.version,
screen: shot,
@ -2280,7 +2280,7 @@
moto: MOTO.id,
init: SDB.getItem('kiri-init'),
time: Date.now()
}));
})));
}
function platformLoadFiles(files,group) {