@fto-consult/expo-ui 7.4.34 → 7.4.35
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 +2 -0
- package/electron/index.js +25 -24
- package/electron/pdf-viewer/locale/en-CA/viewer.ftl +311 -0
- package/electron/pdf-viewer/locale/en-GB/viewer.ftl +351 -0
- package/electron/pdf-viewer/locale/en-US/viewer.ftl +377 -0
- package/electron/pdf-viewer/locale/fr/viewer.ftl +347 -0
- package/electron/pdf-viewer/locale/locale.json +6 -0
- package/electron/pdf-viewer/pdf.min.mjs +21 -0
- package/electron/pdf-viewer/viewer.css +3718 -0
- package/electron/pdf-viewer/viewer.html +491 -0
- package/electron/pdf-viewer/web/images/altText_add.svg +3 -0
- package/electron/pdf-viewer/web/images/altText_done.svg +3 -0
- package/electron/pdf-viewer/web/images/annotation-check.svg +11 -0
- package/electron/pdf-viewer/web/images/annotation-comment.svg +16 -0
- package/electron/pdf-viewer/web/images/annotation-help.svg +26 -0
- package/electron/pdf-viewer/web/images/annotation-insert.svg +10 -0
- package/electron/pdf-viewer/web/images/annotation-key.svg +11 -0
- package/electron/pdf-viewer/web/images/annotation-newparagraph.svg +11 -0
- package/electron/pdf-viewer/web/images/annotation-noicon.svg +7 -0
- package/electron/pdf-viewer/web/images/annotation-note.svg +42 -0
- package/electron/pdf-viewer/web/images/annotation-paperclip.svg +6 -0
- package/electron/pdf-viewer/web/images/annotation-paragraph.svg +16 -0
- package/electron/pdf-viewer/web/images/annotation-pushpin.svg +7 -0
- package/electron/pdf-viewer/web/images/editor-toolbar-delete.svg +5 -0
- package/electron/pdf-viewer/web/images/loading-icon.gif +0 -0
- package/electron/pdf-viewer/web/pdf_viewer.css +2120 -0
- package/electron/pdf-viewer/web/pdf_viewer.mjs +8598 -0
- package/electron/pload.js +1 -22
- package/electron/preload.js +104 -6
- package/electron/utils/index.js +4 -0
- package/electron/utils/isBase64.js +14 -0
- package/electron/utils/isDataURL.js +13 -0
- package/electron/utils/replaceAll.js +12 -0
- package/package.json +6 -1
- package/src/pdf/index.js +2 -2
- package/src/pdf/print.electron.js +4 -0
- package/src/pdf/print.js +3 -0
- package/src/pdf/print.web.js +3 -0
package/electron/pload.js
CHANGED
@@ -32,7 +32,7 @@ module.exports = (ELECTRON,paths)=>{
|
|
32
32
|
}
|
33
33
|
const ext = {
|
34
34
|
toggleDevTools : (value)=>{
|
35
|
-
ipcRenderer.send("
|
35
|
+
ipcRenderer.send("toggle-dev-tools",defaultBool(value,true));
|
36
36
|
},
|
37
37
|
gc : x =>{
|
38
38
|
if(typeof global.gc =='function') return global.gc();
|
@@ -50,27 +50,6 @@ module.exports = (ELECTRON,paths)=>{
|
|
50
50
|
getFreeRAM : (unit)=> getMem(unit,"freemem"),
|
51
51
|
getTotalRAM : (unit)=> getMem(unit,'totalmem')
|
52
52
|
},
|
53
|
-
setTitle : (title) =>{
|
54
|
-
if(title && typeof title =="string"){
|
55
|
-
ipcRenderer.send("electron-set-main-window-title",title);
|
56
|
-
}
|
57
|
-
},
|
58
|
-
createWindow : (options)=>{
|
59
|
-
options = defaultObj(options);
|
60
|
-
options.showOnLoad = defaultBool(options.showOnLoad,true);
|
61
|
-
return ipcRenderer.invoke("electron-create-browser-windows",options);
|
62
|
-
},
|
63
|
-
createPDFWindow :(options)=>{
|
64
|
-
options = defaultObj(options);
|
65
|
-
options.modal = true;
|
66
|
-
return ELECTRON.createWindow(options);
|
67
|
-
},
|
68
|
-
createProgressBar : (options)=>{
|
69
|
-
if(!options || typeof options != 'object' || Array.isArray(options)){
|
70
|
-
options = {};
|
71
|
-
}
|
72
|
-
return //new ProgressBar(options,app);
|
73
|
-
},
|
74
53
|
getAutoUpdaterEvents : ()=> [
|
75
54
|
//'checking-for-update',
|
76
55
|
'update-available',
|
package/electron/preload.js
CHANGED
@@ -4,10 +4,14 @@ const { contextBridge, ipcRenderer, shell } = require('electron')
|
|
4
4
|
const appInstance = require("./app/instance");
|
5
5
|
const path = require("path");
|
6
6
|
const fs = require("fs");
|
7
|
+
const isDataURL = require("./utils/isDataURL");
|
8
|
+
const isBase64 = require("./utils/isBase64");
|
7
9
|
const isNonNullString = x=>x && typeof x =='string';
|
10
|
+
const replaceAll = require("./utils/replaceAll");
|
8
11
|
const pathsStr = ipcRenderer.sendSync("get-paths.json");
|
9
12
|
const paths = typeof pathsStr ==='string' && pathsStr ? JSON.parse(pathsStr) : {};
|
10
13
|
const appName = ipcRenderer.sendSync("get-app-name");
|
14
|
+
const sanitize = require("sanitize-filename");
|
11
15
|
if(!appName || typeof appName !=='string'){
|
12
16
|
throw {message : "Nom de l'application invalide!! Veuillez spécifier un nom valide d'application"}
|
13
17
|
}
|
@@ -24,6 +28,12 @@ const APP_PATH = path.join(getPath("appData"),APP_NAME).toLowerCase();
|
|
24
28
|
let databasePath = path.join(APP_PATH,"databases");
|
25
29
|
let ROOT_APP_FOLDER = undefined;
|
26
30
|
let appBackupPathRef = undefined;
|
31
|
+
const defaultStr = (...args)=>{
|
32
|
+
for(let i in args){
|
33
|
+
if(args[i] && typeof args[i] ==='string') return args[i];
|
34
|
+
}
|
35
|
+
return "";
|
36
|
+
}
|
27
37
|
const separator = (path.sep)
|
28
38
|
if(typeof separator != 'string' || !separator){
|
29
39
|
separator = (()=>{
|
@@ -87,6 +97,52 @@ const removeListener = (channel, callback) => {
|
|
87
97
|
ipcRenderer.removeAllListeners(channel)
|
88
98
|
}
|
89
99
|
};
|
100
|
+
|
101
|
+
const createWindow = (options)=>{
|
102
|
+
options = Object.assign({},options);
|
103
|
+
options.showOnLoad = typeof options.showOnLoad =='boolean'? options.showOnLoad : true;
|
104
|
+
return ipcRenderer.invoke("create-browser-windows",options);
|
105
|
+
};
|
106
|
+
|
107
|
+
const createPDFFile = (options)=>{
|
108
|
+
return new Promise((resolve,reject)=>{
|
109
|
+
const dir = getPath("temp");
|
110
|
+
options = Object.assign({},options);
|
111
|
+
let {content,filename,fileName,charset,success,fileExtension,extension,type} = options;
|
112
|
+
filename = defaultStr(filename,fileName)
|
113
|
+
if(isDataURL(content)){
|
114
|
+
content = isDataURL.toBase64(content);
|
115
|
+
}
|
116
|
+
if(isBase64(content)){
|
117
|
+
content = Buffer.from(content,'base64');
|
118
|
+
} else {
|
119
|
+
content = null;
|
120
|
+
}
|
121
|
+
if(!content){
|
122
|
+
console.warn('type de contenu invalide!! impression création fichier electron');
|
123
|
+
return null;
|
124
|
+
}
|
125
|
+
filename = defaultStr(filename,uniqid("print-salite-file-name"))
|
126
|
+
fileExtension = defaultStr(fileExtension,extension,'pdf');
|
127
|
+
charset = defaultStr(charset,'utf-8')
|
128
|
+
filename = sanitize(filename);
|
129
|
+
if(!fileName.endsWith(`.${fileExtension}`)){
|
130
|
+
fileName += "."+fileExtension
|
131
|
+
}
|
132
|
+
return fs.writeFile(_path.join(dir,filename), content,{charset},(err)=>{
|
133
|
+
if(!err) {
|
134
|
+
const fileUrl = 'file://'+(dir+'/'+filename).replaceAll("\\","/");
|
135
|
+
const p = _path.join(dir,filename);
|
136
|
+
const filePathUrl = 'file://'+p;
|
137
|
+
resolve({content,fileName:filename,filename,path:p,filePathUrl,filePathUri:filePathUrl,fileUrl,filePath:p,fileUri:fileUrl})
|
138
|
+
} else {
|
139
|
+
reject(err);
|
140
|
+
}
|
141
|
+
})
|
142
|
+
})
|
143
|
+
}
|
144
|
+
|
145
|
+
|
90
146
|
const ELECTRON = {
|
91
147
|
get getPouchdb(){
|
92
148
|
return ({PouchDB,sqlPouch})=> {
|
@@ -135,18 +191,18 @@ const ELECTRON = {
|
|
135
191
|
get showOpenDialog(){
|
136
192
|
return (options)=>{
|
137
193
|
options = typeof options =='object' && options && !Array.isArray(options)? options : {};
|
138
|
-
return ipcRenderer.invoke("
|
194
|
+
return ipcRenderer.invoke("show-open-dialog",options);
|
139
195
|
}
|
140
196
|
},
|
141
197
|
get showSaveDialog(){
|
142
198
|
return (options)=>{
|
143
199
|
options = typeof options =='object' && options && !Array.isArray(options)? options : {};
|
144
|
-
return ipcRenderer.invoke("
|
200
|
+
return ipcRenderer.invoke("show-save-dialog",options);
|
145
201
|
};
|
146
202
|
},
|
147
203
|
get restartApp(){
|
148
204
|
return ()=>{
|
149
|
-
ipcRenderer.sendSync("
|
205
|
+
ipcRenderer.sendSync("restart-app")
|
150
206
|
};
|
151
207
|
},
|
152
208
|
get is() {
|
@@ -190,7 +246,7 @@ const ELECTRON = {
|
|
190
246
|
},
|
191
247
|
get updateSystemTheme(){
|
192
248
|
return (theme)=>{
|
193
|
-
return ipcRenderer.invoke("
|
249
|
+
return ipcRenderer.invoke("set-system-theme:toggle",theme);
|
194
250
|
};
|
195
251
|
},
|
196
252
|
get SESSION (){
|
@@ -290,9 +346,51 @@ const ELECTRON = {
|
|
290
346
|
},
|
291
347
|
get toggleDevTools(){
|
292
348
|
return async (toggle)=>{
|
293
|
-
return await ipcRenderer.send("
|
349
|
+
return await ipcRenderer.send("toggle-dev-tools",toggle);
|
350
|
+
}
|
351
|
+
},
|
352
|
+
get createWindow (){
|
353
|
+
return createWindow;
|
354
|
+
},
|
355
|
+
get createPDFWindow(){
|
356
|
+
return (options)=>{
|
357
|
+
options = Object.assign({},options);
|
358
|
+
options.modal = true;
|
359
|
+
return createWindow(options);
|
360
|
+
}
|
361
|
+
},
|
362
|
+
get createPDFFile(){
|
363
|
+
return createPDFFile;
|
364
|
+
},
|
365
|
+
get createPdfFile(){
|
366
|
+
return createPDFFile;
|
367
|
+
},
|
368
|
+
createProgressBar : (options)=>{
|
369
|
+
if(!options || typeof options != 'object' || Array.isArray(options)){
|
370
|
+
options = {};
|
294
371
|
}
|
295
|
-
|
372
|
+
return //new ProgressBar(options,app);
|
373
|
+
},
|
374
|
+
get setTitle(){
|
375
|
+
return (title) =>{
|
376
|
+
if(title && typeof title =="string"){
|
377
|
+
ipcRenderer.send("set-main-window-title",title);
|
378
|
+
}
|
379
|
+
};
|
380
|
+
},
|
381
|
+
get printPDF (){
|
382
|
+
return (options)=>{
|
383
|
+
const urlPath = path.resolve("./pdf-viewer","viewer.html");
|
384
|
+
return createWindow({file:urlPath,modal:true,showOnLoad:true});
|
385
|
+
return createPDFFile(options).then(({path,filePathUrl})=>{
|
386
|
+
if(fs.existsSync(path)){
|
387
|
+
opts.loadURL = `file://${urlPath}?file=${decodeURIComponent(filePathUrl)}&locale=fr`;
|
388
|
+
opts.showOnLoad = true;
|
389
|
+
return this.createPDFWindow(opts)
|
390
|
+
}
|
391
|
+
})
|
392
|
+
}
|
393
|
+
}
|
296
394
|
};
|
297
395
|
|
298
396
|
require("./pload")(ELECTRON,paths || {});
|
package/electron/utils/index.js
CHANGED
@@ -10,6 +10,10 @@ module.exports = {
|
|
10
10
|
console.error(...args);
|
11
11
|
process.exit(-1);
|
12
12
|
},
|
13
|
+
replaceAll : require("./replaceAll"),
|
14
|
+
isBase64 : require("./isBase64"),
|
15
|
+
isDataURL : require("./isDataURL"),
|
16
|
+
dataURLToBase64 : require("./isDataURL").toBase64,
|
13
17
|
isValidUrl : require("./isValidUrl"),
|
14
18
|
createDirSync : require("./createDirSync"),
|
15
19
|
...require("./dependencies"),
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module.exports = function isBase64(str, options) {
|
2
|
+
if(!str || typeof str !=='string') return false;
|
3
|
+
options = Object.assign({},options);
|
4
|
+
options.urlSafe = typeof options.urlSafe =='boolean'? options.urlSafe: false;
|
5
|
+
const len = str.length;
|
6
|
+
if (options.urlSafe) {
|
7
|
+
return /^[A-Z0-9_\-]*$/i.test(str);
|
8
|
+
}
|
9
|
+
if (len % 4 !== 0 || /[^A-Z0-9+\/=]/i.test(str)) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
const firstPaddingChar = str.indexOf('=');
|
13
|
+
return firstPaddingChar === -1 || firstPaddingChar === len - 1 || (firstPaddingChar === len - 2 && str[len - 1] === '=');
|
14
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const isDataURLRegex = /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)$/i;
|
2
|
+
|
3
|
+
function isDataURL(s) {
|
4
|
+
return s && typeof s ==='string' && !s.includes("data:image/x-icon") && !!s.match(isDataURLRegex);
|
5
|
+
}
|
6
|
+
|
7
|
+
isDataURL.toBase64 = (dataURLStr)=>{
|
8
|
+
if(!isDataURL(dataURLStr)) return undefined;
|
9
|
+
return dataURLStr.replace(/^data:.+;base64,/, '')
|
10
|
+
}
|
11
|
+
|
12
|
+
module.exports = isDataURL;
|
13
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
function replaceAll (value,find,replace){
|
2
|
+
if(typeof value !=='string' || typeof find !=='string' || typeof replace !=='string') return "";
|
3
|
+
return value.split(find).join(replace)
|
4
|
+
}
|
5
|
+
|
6
|
+
if(typeof String.prototype.replaceAll !== 'function'){
|
7
|
+
String.prototype.replaceAll = function(find,replace){
|
8
|
+
return replaceAll(this.toString(),find,replace);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
module.exports = replaceAll;
|
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.35",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"scripts": {
|
6
6
|
"clear-npx-cache": "npx clear-npx-cache",
|
@@ -99,9 +99,12 @@
|
|
99
99
|
"fs-extra": "^11.2.0",
|
100
100
|
"google-libphonenumber": "^3.2.33",
|
101
101
|
"htmlparser2-without-node-native": "^3.9.2",
|
102
|
+
"i": "^0.3.7",
|
102
103
|
"is-plain-obj": "^4.1.0",
|
103
104
|
"js-base64": "^3.7.5",
|
104
105
|
"node-machine-id": "^1.1.12",
|
106
|
+
"npm": "^10.2.5",
|
107
|
+
"pdfjs-dist": "^4.0.269",
|
105
108
|
"pdfmake": "^0.2.8",
|
106
109
|
"process": "^0.11.10",
|
107
110
|
"prop-types": "^15.8.1",
|
@@ -123,8 +126,10 @@
|
|
123
126
|
"react-native-web": "^0.19.9",
|
124
127
|
"react-native-webview": "13.2.2",
|
125
128
|
"react-virtuoso": "^4.6.2",
|
129
|
+
"sanitize-filename": "^1.6.3",
|
126
130
|
"sharp-cli": "^2.1.0",
|
127
131
|
"tippy.js": "^6.3.7",
|
132
|
+
"uninstall": "^0.0.0",
|
128
133
|
"websql": "^2.0.3",
|
129
134
|
"xlsx": "^0.18.5"
|
130
135
|
},
|
package/src/pdf/index.js
CHANGED
@@ -6,14 +6,14 @@ import notify from "$cnotify";
|
|
6
6
|
import DialogProvider from "$ecomponents/Form/FormData/DialogProvider";
|
7
7
|
import {isNonNullString,defaultObj,defaultStr} from "$cutils";
|
8
8
|
import session from "$session";
|
9
|
+
import printPdfMake from "./print";
|
9
10
|
|
10
11
|
const {createPdf} = pdfMake;
|
11
12
|
pdfMake.createPdf = (docDefinition,...rest)=>{
|
12
13
|
try {
|
13
14
|
//@see : https://pdfmake.github.io/docs/0.1/getting-started/client-side/methods/
|
14
15
|
const pdf = createPdf(docDefinition,...rest);
|
15
|
-
pdf
|
16
|
-
//pdf.open({}, window)
|
16
|
+
printPdfMake(pdf);
|
17
17
|
return pdf;
|
18
18
|
} catch(e){
|
19
19
|
console.log(e," generating pdf make create eerrror");
|
package/src/pdf/print.js
ADDED