@fto-consult/expo-ui 7.4.62 → 7.4.64
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 -4
- package/electron/preload.js +4 -23
- package/electron/utils/index.js +1 -0
- package/electron/utils/json.js +57 -0
- package/package.json +1 -2
- package/electron/pdf-viewer/preload.js +0 -29
- package/electron/pdf-viewer/viewer.css +0 -14
- package/electron/pdf-viewer/wiewer.html +0 -14
package/electron/index.js
CHANGED
@@ -127,10 +127,7 @@ function createBrowserWindow (options){
|
|
127
127
|
if(showOnLoad){
|
128
128
|
_win.once('ready-to-show', () => {
|
129
129
|
_win.show();
|
130
|
-
|
131
|
-
if(options.devTools){
|
132
|
-
_win.webContents.openDevTools();
|
133
|
-
}
|
130
|
+
_win.webContents.send("window-ready-to-show",JSON.stringify(options.readyToShowOptions));
|
134
131
|
});
|
135
132
|
}
|
136
133
|
_win.on('closed', function() {
|
package/electron/preload.js
CHANGED
@@ -383,36 +383,17 @@ const ELECTRON = {
|
|
383
383
|
return (options)=>{
|
384
384
|
options = Object.assign({},options);
|
385
385
|
return createPDFFile(options).then(({path:mainPath,filePathUrl,fileName})=>{
|
386
|
-
const urlPath = path.resolve(__dirname,"pdf-viewer","viewer.html");
|
387
386
|
if(fs.existsSync(mainPath)){
|
388
|
-
const queryString = `file=${filePathUrl}&locale=fr&fileName=${fileName}`;
|
389
387
|
const opts = {
|
390
|
-
//loadURL : `file://${urlPath}?${queryString}`,
|
391
388
|
file : mainPath,
|
392
389
|
fileName,
|
393
|
-
filePathUrl,
|
394
|
-
queryString,
|
395
390
|
pdfFilePath : mainPath,
|
396
391
|
showOnLoad : true,
|
397
|
-
|
398
|
-
|
399
|
-
devTools : true,
|
400
|
-
//webSecurity: false,
|
401
|
-
preload : path.resolve(__dirname,"pdf-viewer",'preload.js'),
|
402
|
-
...Object.assign({},options.webPreferences),
|
403
|
-
},
|
404
|
-
fileName
|
405
|
-
};
|
406
|
-
["width","height"].map((v)=>{
|
407
|
-
if(v in options){
|
408
|
-
opts[v] = options;
|
392
|
+
webPreferences: {
|
393
|
+
plugins: true
|
409
394
|
}
|
410
|
-
}
|
411
|
-
|
412
|
-
return this.createPDFWindow({
|
413
|
-
...opts,
|
414
|
-
readyToShowOptions : opts,
|
415
|
-
})
|
395
|
+
};
|
396
|
+
return this.createPDFWindow(opts)
|
416
397
|
}
|
417
398
|
})
|
418
399
|
}
|
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
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "7.4.
|
3
|
+
"version": "7.4.64",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"scripts": {
|
6
6
|
"clear-npx-cache": "npx clear-npx-cache",
|
@@ -103,7 +103,6 @@
|
|
103
103
|
"js-base64": "^3.7.5",
|
104
104
|
"node-machine-id": "^1.1.12",
|
105
105
|
"pdfmake": "^0.2.8",
|
106
|
-
"pdfobject": "^2.2.12",
|
107
106
|
"process": "^0.11.10",
|
108
107
|
"prop-types": "^15.8.1",
|
109
108
|
"react": "^18.2.0",
|
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
const {ipcRenderer} = require('electron')
|
3
|
-
|
4
|
-
ipcRenderer.on('print-document', (...args) => {
|
5
|
-
console.log("willl print document ",window.PDFObject)
|
6
|
-
});
|
7
|
-
ipcRenderer.on("window-ready-to-show",(...args)=>{
|
8
|
-
console.log("window is ready to show ",...args,window.PDFObject);
|
9
|
-
});
|
10
|
-
function test(){
|
11
|
-
const container = `#pdf-container`;
|
12
|
-
const title = document.querySelector(`document-title`)
|
13
|
-
// Get a URLSearchParams object from the URL object
|
14
|
-
const params = Object.assign({},url.searchParams);
|
15
|
-
params.width = params.width ||"100%";
|
16
|
-
params.height = params.height || "100%";
|
17
|
-
if(params.fileName && title){
|
18
|
-
title.innerHTML = `${params.fileName}`
|
19
|
-
} else if(params.title && title){
|
20
|
-
title.innerHTML = `${params.title}`
|
21
|
-
}
|
22
|
-
alert(JSON.stringify(params)," is params heeein");
|
23
|
-
alert(params.file," is paraments fieleeeeee");
|
24
|
-
if(params.file){
|
25
|
-
PDFObject.embed(params.file,container,params);
|
26
|
-
} else if(params.dataURL){
|
27
|
-
PDFObject.embed(params.dataURL,container,params);
|
28
|
-
}
|
29
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
width: 100vh!important;
|
3
|
-
height: 100%!important;
|
4
|
-
padding: 0!important;
|
5
|
-
margin: 0!important;
|
6
|
-
}
|
7
|
-
|
8
|
-
#pdf-container{
|
9
|
-
width: 100vh!important;
|
10
|
-
height: 100%!important;
|
11
|
-
padding: 0!important;
|
12
|
-
margin: 0!important;
|
13
|
-
position: relative!important;
|
14
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html dir="ltr">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
6
|
-
<title id="document-title">PDF Viewer</title>
|
7
|
-
<link rel="stylesheet" type="text/css" href="./viewer.css">
|
8
|
-
<script src="../../node_modules/pdfobject/pdfobject.min.js"></script>
|
9
|
-
</head>
|
10
|
-
|
11
|
-
<body>
|
12
|
-
<div id="pdf-container"></div>
|
13
|
-
</body>
|
14
|
-
</html>
|