@fto-consult/expo-ui 7.4.62 → 7.4.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/electron/index.js +1 -1
- package/electron/utils/index.js +1 -0
- package/electron/utils/json.js +57 -0
- package/package.json +1 -1
package/electron/index.js
CHANGED
@@ -127,7 +127,7 @@ function createBrowserWindow (options){
|
|
127
127
|
if(showOnLoad){
|
128
128
|
_win.once('ready-to-show', () => {
|
129
129
|
_win.show();
|
130
|
-
|
130
|
+
_win.webContents.send("window-ready-to-show",JSON.stringify(options.readyToShowOptions));
|
131
131
|
if(options.devTools){
|
132
132
|
_win.webContents.openDevTools();
|
133
133
|
}
|
package/electron/utils/index.js
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
// Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style
|
3
|
+
// license that can be found in the LICENSE file.
|
4
|
+
|
5
|
+
|
6
|
+
module.exports.decycle = function decycle(obj, stack = []) {
|
7
|
+
if(typeof obj ==='function') return undefined;
|
8
|
+
if (!obj || typeof obj !== 'object')
|
9
|
+
return obj;
|
10
|
+
|
11
|
+
if (stack.includes(obj))
|
12
|
+
return null;
|
13
|
+
|
14
|
+
let s = stack.concat([obj]);
|
15
|
+
return Array.isArray(obj)
|
16
|
+
? obj.map(x => decycle(x, s))
|
17
|
+
: Object.fromEntries(
|
18
|
+
Object.entries(obj)
|
19
|
+
.map(([k, v]) => [k, decycle(v, s)]));
|
20
|
+
}
|
21
|
+
|
22
|
+
module.exports.stringify = function(jsonObj,decylcleVal){
|
23
|
+
return isJSON(jsonObj) ? jsonObj : JSON.stringify(decylcleVal !== false ? decycle(jsonObj) : jsonObj);
|
24
|
+
}
|
25
|
+
|
26
|
+
module.exports.isJSON = function (json_string){
|
27
|
+
if(!json_string || typeof json_string != 'string') return false;
|
28
|
+
var text = json_string;
|
29
|
+
return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, '')));
|
30
|
+
}
|
31
|
+
|
32
|
+
/***
|
33
|
+
* parse JSON string recursively
|
34
|
+
* @param {string} json string to parse
|
35
|
+
* @return {object} or null, parse json
|
36
|
+
*/
|
37
|
+
module.exports. parseJSON = function(jsonStr){
|
38
|
+
if(!isJSON(jsonStr)) {
|
39
|
+
if(jsonStr && typeof(jsonStr) == 'object'){
|
40
|
+
for(var i in jsonStr){
|
41
|
+
jsonStr[i] = parseJSON(jsonStr[i]);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return jsonStr;
|
45
|
+
}
|
46
|
+
try {
|
47
|
+
jsonStr = JSON.parse(jsonStr);
|
48
|
+
if(jsonStr && typeof(jsonStr) == 'object'){
|
49
|
+
for(var i in jsonStr){
|
50
|
+
jsonStr[i] = parseJSON(jsonStr[i]);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
} catch(e){
|
54
|
+
return jsonStr;
|
55
|
+
}
|
56
|
+
return jsonStr;
|
57
|
+
}
|