@fto-consult/expo-ui 7.4.32 → 7.4.34

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
@@ -10,7 +10,7 @@
10
10
  const { program } = require('commander');
11
11
  const path= require("path");
12
12
  const fs = require("fs");
13
- const {createDir,electronDir,copy,exec,throwError,paths:getPaths,writeFile} = require("./utils");
13
+ const {createDir,electronDir,copy,exec,throwError,paths:getPaths,writeFile,isValidUrl} = require("./utils");
14
14
 
15
15
 
16
16
  const dir = path.resolve(__dirname);
@@ -50,13 +50,13 @@ program.command('electron')
50
50
  //.option('-s, --splash [dir]', 'le chemin (relatif au project root) du fichier du splash screen de l\'application')
51
51
  .option('-o, --out [dir]', 'le chemin (relatif au project root) du répertoire qui contiendra les fichiers build')
52
52
  .option('-u, --url [url]', 'le lien url qui sera ouvert par l\'application')
53
- .option('-i, --compile [url]', 'le lien url qui sera ouvert par l\'application')
53
+ .option('-b, --build [boolean]', 'si ce flag est spécfifié alors l\'application sera compilée')
54
54
  .option('-a, --arch [architecture]', 'l\'architecture de la plateforme')
55
55
  .option('-p, --platform [platform]', 'la plateforme à utiliser pour la compilation')
56
56
  .action((script, options) => {
57
57
  const electronProjectRoot = path.resolve(projectRoot,"electron");
58
58
  const opts = Object.assign({},typeof options.opts =='function'? options.opts() : options);
59
- let {out,arch,url,compile,platform} = opts;
59
+ let {out,arch,url,build,platform} = opts;
60
60
  //let {projectRoot} = opts;
61
61
  if(projectRoot == dir){
62
62
  throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
@@ -122,7 +122,7 @@ program.command('electron')
122
122
  let cmd = undefined;
123
123
  const start = x=>{
124
124
  return new Promise((resolve,reject)=>{
125
- cmd = `electron "${electronProjectRoot}"${url? ` --url ${url}`:''} --paths ${pathsJSON} --root ${projectRoot}`;
125
+ cmd = `electron "${electronProjectRoot}" --paths ${pathsJSON} --root ${projectRoot} ${isValidUrl(url)? ` --url ${url}`:''}`;
126
126
  exec({
127
127
  cmd,
128
128
  projectRoot : electronProjectRoot,
@@ -143,7 +143,7 @@ program.command('electron')
143
143
  reject("dossier web-build exporté par electron innexistant!!");
144
144
  }
145
145
  }
146
- if(!url && (compile || script ==="build" || !fs.existsSync(path.resolve(webBuildDir,"index.html")))){
146
+ if(!url && (build || script ==="build" || !fs.existsSync(path.resolve(webBuildDir,"index.html")))){
147
147
  console.log("exporting expo web app ...");
148
148
  try {
149
149
  writeFile(packagePath,JSON.stringify({...packageObj,homepage:"./"},null,"\t"));
package/electron/index.js CHANGED
@@ -20,6 +20,7 @@ const projectRoot = mainProjectRoot && fs.existsSync(mainProjectRoot) ? mainProj
20
20
  const electronProjectRoot = projectRoot && fs.existsSync(path.resolve(projectRoot,"electron")) && path.resolve(projectRoot,"electron") || '';
21
21
  const ePathsJSON = path.resolve(electronProjectRoot,"paths.json");
22
22
  const packageJSONPath = path.resolve(projectRoot,"package.json");
23
+ const isValidUrl = require("./utils/isValidUrl");
23
24
  const packageJSON = fs.existsSync(packageJSONPath) ? require(`${packageJSONPath}`) : {};
24
25
  const eePaths = path.resolve(getPaths(projectRoot));
25
26
  if(!paths){
@@ -115,7 +116,7 @@ function createBrowserWindow (options){
115
116
  _win.setMenuBarVisibility(false)
116
117
  _win.setAutoHideMenuBar(true)
117
118
  }
118
- const url = options.loadURL && typeof options.loadURL ==='string'? options.loadURL : pUrl || undefined;
119
+ const url = isValidUrl(options.loadURL) ? options.loadURL : isValidUrl(pUrl) ? pUrl : undefined;
119
120
  if(url){
120
121
  _win.loadURL(url);
121
122
  }
@@ -129,7 +130,6 @@ function createBrowserWindow (options){
129
130
  });
130
131
  return _win;
131
132
  }
132
- const args = require("./utils/parseArgs")();
133
133
  function createWindow () {
134
134
  // Créer le browser window
135
135
  win = createBrowserWindow({
@@ -191,8 +191,8 @@ function createWindow () {
191
191
  win.webContents.send('before-app-exit');
192
192
  }
193
193
  });
194
- if(args.url){
195
- win.loadURL(args.url);
194
+ if(isValidUrl(pUrl)){
195
+ win.loadURL(pUrl);
196
196
  } else {
197
197
  win.loadFile(path.resolve(path.join(electronProjectRoot,"dist",'index.html')))
198
198
  }
@@ -437,9 +437,8 @@ ipcMain.on('close-main-render-process', _ => {
437
437
  function debounce(func, wait, immediate) {
438
438
  var timeout;
439
439
 
440
- return function executedFunction() {
440
+ return function executedFunction(...args) {
441
441
  var context = this;
442
- var args = arguments;
443
442
 
444
443
  var later = function() {
445
444
  timeout = null;
@@ -9,9 +9,10 @@
9
9
 
10
10
  module.exports = {
11
11
  /*****
12
- @must return Instance of Browser window
13
- width: 500, height: 400, transparent: true, frame: false,
14
- alwaysOnTop: true
12
+ must return an Instance of Browser window
13
+ width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true
14
+ @param {width{number|500},{height{number|400}},transparent{boolean|true}, frame{boolean|false}, alwaysOnTop{boolean|true}}
15
+ @return {InstanceOf(BrowserWindow)}
15
16
  */
16
17
  splashScreen : function({width, height, transparent, frame, alwaysOnTop}){
17
18
  return null;
@@ -10,6 +10,7 @@ module.exports = {
10
10
  console.error(...args);
11
11
  process.exit(-1);
12
12
  },
13
+ isValidUrl : require("./isValidUrl"),
13
14
  createDirSync : require("./createDirSync"),
14
15
  ...require("./dependencies"),
15
16
  isObj : x=> typeof x =="object" && x && !Array.isArray(x),
@@ -0,0 +1,4 @@
1
+ module.exports = (str)=>{
2
+ if(typeof str !=='string' || !str) return false;
3
+ return /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/.test(str);
4
+ };
@@ -13,7 +13,7 @@ module.exports = function(message,...params){
13
13
  const opts = message && typeof message =='object' && !Array.isArray(message) ? message : {};
14
14
  message = opts.message;
15
15
  if(!message || typeof message !='string') return null;
16
- opts.params = Array.isArray(opts.params) && opts.params || Array.isArray(params) && params || [];
16
+ opts.params = Array.isArray(opts.params) && opts.params || params;
17
17
  opts.message = "ELECTRON_MESSAGE/"+message.trim();
18
18
  return window.postMessage(opts);
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.4.32",
3
+ "version": "7.4.34",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",