@fto-consult/expo-ui 7.4.36 → 7.4.38

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 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)
package/electron/index.js CHANGED
@@ -74,10 +74,11 @@ const setOSTheme = (theme) => {
74
74
  setOSTheme(session.get("os-theme"));
75
75
  const isObj = x => x && typeof x =='object';
76
76
 
77
+
77
78
  function createBrowserWindow (options){
78
79
  options = Object.assign({},options);
79
80
  let menu = options.menu;
80
- options.webPreferences = isObj(options.webPreferences)? options.webPreferences : {}
81
+ options.webPreferences = isObj(options.webPreferences)? options.webPreferences : {};
81
82
  options.webPreferences = {
82
83
  sandbox: false,
83
84
  ...options.webPreferences,
@@ -110,7 +111,7 @@ function createBrowserWindow (options){
110
111
  if(typeof mainProcess.beforeCreateWindow =='function'){
111
112
  mainProcess.beforeCreateWindow(options);
112
113
  }
113
- const _win = new BrowserWindow(options);
114
+ let _win = new BrowserWindow(options);
114
115
  if(!menu){
115
116
  _win.setMenu(null);
116
117
  _win.removeMenu();
@@ -118,6 +119,7 @@ function createBrowserWindow (options){
118
119
  _win.setAutoHideMenuBar(true)
119
120
  }
120
121
  const url = isValidUrl(options.loadURL) ? options.loadURL : isValidUrl(pUrl) ? pUrl : undefined;
122
+ console.log("will load file ",options.file,options);
121
123
  if(url){
122
124
  _win.loadURL(url);
123
125
  } else if(options.file && fs.existsSync(options.file)){
@@ -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="../../../node_modules/pdfjs-dist/web/pdf_viewer.css">
37
+ <link rel="stylesheet" href="./web/pdf_viewer.css">
38
38
 
39
- <script src="../../../node_modules/pdfjs-dist/build/pdf.min.mjs" type="module"></script>
40
- <script src="../../../node_modules/pdfjs-dist/web/pdf_viewer.mjs" type="module"></script>
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
 
@@ -381,6 +381,7 @@ const ELECTRON = {
381
381
  get printPDF (){
382
382
  return (options)=>{
383
383
  const urlPath = path.resolve("./pdf-viewer","viewer.html");
384
+ console.log("will create window ",urlPath);
384
385
  return createWindow({file:urlPath,modal:true,showOnLoad:true});
385
386
  return createPDFFile(options).then(({path,filePathUrl})=>{
386
387
  if(fs.existsSync(path)){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.4.36",
3
+ "version": "7.4.38",
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/print.js CHANGED
@@ -1,7 +1,3 @@
1
- import {isElectron} from "$cplatform";
2
1
  export default function print(pdfMakeInstance,options,...rest){
3
- if(isElectron() && ELECTRON.printPDF){
4
- return ELECTRON.printPDF(options);
5
- }
6
2
  return pdfMakeInstance.print(options,...rest);
7
3
  }
@@ -1,3 +1,7 @@
1
- export default function print(pdfMakeInstance,...rest){
2
- return pdfMakeInstance.print(...rest);
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
  }
@@ -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
- }