@fto-consult/expo-ui 7.4.35 → 7.4.37
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/bin/index.js +0 -1
- package/electron/pdf-viewer/viewer.html +3 -3
- package/package.json +1 -2
- package/src/pdf/index.js +1 -1
- package/src/pdf/print.js +6 -2
- package/electron/app/printer.js +0 -52
package/bin/index.js
CHANGED
@@ -21,7 +21,6 @@ const description = packageObj.description;
|
|
21
21
|
const packageName = packageObj.name;
|
22
22
|
const localElectronPackage = path.resolve(projectRoot,"node_modules",packageName)
|
23
23
|
const localElectronPackageElectron = path.resolve(localElectronPackage,"electron");
|
24
|
-
//const pdfJSPath = path.resolve(projectRoot,"node_modules","pdfjs-dist");
|
25
24
|
|
26
25
|
program
|
27
26
|
.name(packageName)
|
@@ -34,10 +34,10 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|
34
34
|
<link rel="stylesheet" href="./viewer.css">
|
35
35
|
|
36
36
|
|
37
|
-
<link rel="stylesheet" href="
|
37
|
+
<link rel="stylesheet" href="./web/pdf_viewer.css">
|
38
38
|
|
39
|
-
<script src="
|
40
|
-
<script src="
|
39
|
+
<script src="./pdf.min.mjs" type="module"></script>
|
40
|
+
<script src="./web/pdf_viewer.mjs" type="module"></script>
|
41
41
|
|
42
42
|
</head>
|
43
43
|
|
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.37",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"scripts": {
|
6
6
|
"clear-npx-cache": "npx clear-npx-cache",
|
@@ -104,7 +104,6 @@
|
|
104
104
|
"js-base64": "^3.7.5",
|
105
105
|
"node-machine-id": "^1.1.12",
|
106
106
|
"npm": "^10.2.5",
|
107
|
-
"pdfjs-dist": "^4.0.269",
|
108
107
|
"pdfmake": "^0.2.8",
|
109
108
|
"process": "^0.11.10",
|
110
109
|
"prop-types": "^15.8.1",
|
package/src/pdf/index.js
CHANGED
@@ -13,7 +13,7 @@ pdfMake.createPdf = (docDefinition,...rest)=>{
|
|
13
13
|
try {
|
14
14
|
//@see : https://pdfmake.github.io/docs/0.1/getting-started/client-side/methods/
|
15
15
|
const pdf = createPdf(docDefinition,...rest);
|
16
|
-
printPdfMake(pdf);
|
16
|
+
printPdfMake(pdf,{...Object.assign({},docDefinition),...Object.assign({},rest[0])});
|
17
17
|
return pdf;
|
18
18
|
} catch(e){
|
19
19
|
console.log(e," generating pdf make create eerrror");
|
package/src/pdf/print.js
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import {isElectron} from "$cplatform";
|
2
|
+
export default function print(pdfMakeInstance,options,...rest){
|
3
|
+
if(isElectron() && ELECTRON.printPDF){
|
4
|
+
return ELECTRON.printPDF(options);
|
5
|
+
}
|
6
|
+
return pdfMakeInstance.print(options,...rest);
|
3
7
|
}
|
package/electron/app/printer.js
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
const fs = require('fs')
|
2
|
-
const path = require('path')
|
3
|
-
const _path = path;
|
4
|
-
const createFile = (arg)=>{
|
5
|
-
let dir = ELECTRON.getPath("temp");
|
6
|
-
arg = defaultObj(arg);
|
7
|
-
let {content,filename,fileName,charset,success,fileExtension,extension,type} = arg;
|
8
|
-
filename = defaultStr(filename,fileName)
|
9
|
-
if(isDataURL(content)){
|
10
|
-
content = dataURLToBase64(content);
|
11
|
-
}
|
12
|
-
if(isBase64(content)){
|
13
|
-
content = Buffer.from ? Buffer.from(content,'base64') : new Buffer(content,'base64')
|
14
|
-
} else {
|
15
|
-
content = null;
|
16
|
-
}
|
17
|
-
if(!content){
|
18
|
-
console.warn('type de contenu invalide!! impression création fichier electron');
|
19
|
-
return null;
|
20
|
-
}
|
21
|
-
success = defaultFunc(success)
|
22
|
-
filename = defaultStr(filename,uniqid("print-salite-file-name"))
|
23
|
-
fileExtension = defaultStr(fileExtension,extension,'pdf');
|
24
|
-
charset = defaultStr(charset,'utf-8')
|
25
|
-
filename = sanitizeFileName(filename+"."+fileExtension);
|
26
|
-
fs.writeFile(path.join(dir,filename), content,{charset},(err)=>{
|
27
|
-
if(!err) {
|
28
|
-
let fileUrl = 'file://'+(dir+'/'+filename).replaceAll("\\","/");
|
29
|
-
let p = _path.join(dir,filename);
|
30
|
-
let filePathUrl = 'file://'+p.replaceAll("\\","/");
|
31
|
-
success({content,fileName:filename,filename,path:p,filePathUrl,filePathUri:filePathUrl,fileUrl,filePath:p,fileUri:fileUrl})
|
32
|
-
}
|
33
|
-
})
|
34
|
-
}
|
35
|
-
|
36
|
-
function preview(arg){
|
37
|
-
createFile({...defaultObj(arg),success:(opts)=>{
|
38
|
-
let {path,filePathUrl} = opts;
|
39
|
-
if(fs.existsSync(path)){
|
40
|
-
let urlPath = _path.join(require.resolve("pdfjs-dist-viewer-min/package.json").replaceAll("package.json",""),'build','minified','web', 'viewer.html')
|
41
|
-
opts.loadURL = `file://${urlPath}?file=${decodeURIComponent(filePathUrl)}&locale=fr`;
|
42
|
-
opts.showOnLoad = true;
|
43
|
-
ELECTRON.createPDFWindow(opts)
|
44
|
-
}
|
45
|
-
}});
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
module.exports = {
|
50
|
-
preview,
|
51
|
-
createFile
|
52
|
-
}
|