@fto-consult/expo-ui 3.3.0 → 3.3.2

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.
@@ -113,20 +113,23 @@ module.exports = (opts)=>{
113
113
  });
114
114
  const $assets = r.$assets;
115
115
  const electronPaths = {
116
+ ...r,
117
+ sourceCode : r.$src,
116
118
  assets : $assets,
117
119
  images : r.$images,
118
120
  projectRoot : base,//la racine au projet
119
121
  };
120
122
  const electronAssetsPath = path.resolve(dir,"electron","assets");
121
123
  if($assets){
122
- const l1 = path.resolve($assets,"logo.png"), l2 = path.resolve($assets,"images","logo.png");
124
+ const l1 = path.resolve($assets,"logo.png"), l2 = path.resolve($assets,"logo.png");
123
125
  const logoPath = fs.existsSync(l1)? l1 : fs.existsSync(l2)? l2 : undefined;
124
- if(logoPath){
125
- fs.copyFileSync(logoPath,path.resolve(electronAssetsPath,"images","logo.png"),fs.constants.COPYFILE_FICLONE);
126
+ const ePath = path.resolve(electronAssetsPath,"images","logo.png");
127
+ if(logoPath && require("./electron/createDir")(ePath)){
128
+ fs.copyFileSync(logoPath,ePath,fs.constants.COPYFILE_FICLONE);
126
129
  electronPaths.logo = logoPath;
127
130
  }
128
131
  }
129
132
  ///on sauvegarde les chemins des fichiers utiles, qui seront utilisées par la variable electron plus tard
130
- require("./writeFile")(path.resolve(dir,"electron","paths.json"),JSON.stringify(electronPaths));
133
+ require("./electron/writeFile")(path.resolve(dir,"electron","paths.json"),JSON.stringify(electronPaths));
131
134
  return r;
132
135
  }
package/bin/index.js ADDED
@@ -0,0 +1,99 @@
1
+ //#!/usr/bin/env node
2
+ /**@see : https://blog.shahednasser.com/how-to-create-a-npx-tool/ */
3
+ 'use strict';
4
+ process.on('unhandledRejection', err => {
5
+ throw err;
6
+ });
7
+ const supportedScript = {
8
+ "start" : true,//start electron
9
+ "build" : true, //script pour faire un build
10
+ }
11
+ const path= require("path");
12
+ const fs = require("fs");
13
+ const dir = path.resolve(__dirname);
14
+ const electronDir = path.resolve(dir, "..","electron");
15
+ const exec = require("../electron/exec");
16
+ const args = process.argv.slice(2);
17
+ let projectRoot = process.cwd();
18
+ const createDir = require("../electron/createDir");
19
+ const copyDir = require("../electron/copyDir");
20
+ const parsedArgs = require("./parseArgs")(args,supportedScript);
21
+ if(!parsedArgs.script || !(parsedArgs.script in supportedScript)){
22
+ console.error ("Erreur : script invalide, vous devez spécifier script figurant parmi les script : ["+Object.keys(supportedScript).join(", ")+"]");
23
+ process.exit();
24
+ }
25
+ const {script} = parsedArgs;
26
+ let cmd = null;
27
+ /****
28
+ * 1. installer electron globallement : npm i -g electron@latest
29
+ * cmde : [cmd] start electron config=[path-to-config-relative-to-project-dir]
30
+ * splash=[path-to-splashcreen-relative-to-project-root]
31
+ * output-dir|out = [path-to-output-dir-relative-to-root-project]
32
+ * */
33
+ if(parsedArgs.electron){
34
+ const pathsJSON = path.resolve(electronDir,"paths.json");
35
+ if(!fs.existsSync(pathsJSON)){
36
+ throw "Le fichier des chemins d'accès à l'application est innexistant, rassurez vous de tester l'application en environnement web, via la cmde <npx expo start>, avant l'exécution du script electron."
37
+ }
38
+ const paths = require(`${pathsJSON}`);
39
+ if(typeof paths !=='object' || !paths || !paths.projectRoot){
40
+ throw "Fichiers des chemins d'application invalide!!! merci d'exécuter l'application en environnement web|android|ios puis réessayez"
41
+ }
42
+ projectRoot = path.resolve(projectRoot);
43
+ const out = parsedArgs.out || parsedArgs["output-dir"];
44
+ const outDir = out && path.dirname(out) && path.resolve(projectRoot,path.dirname(out),"electron") || path.resolve(projectRoot,"dist","electron")
45
+ if(!createDir(outDir)){
46
+ throw "Impossible de créer le répertoire <<"+outDir+">> du fichier binaire!!";
47
+ }
48
+ const logoPath = paths.logo || paths.$assets && path.resolve(paths.$assets,"logo.png") || paths.$images && path.resolve(paths.$images,"logo.png");
49
+ if(!logoPath || !fs.existsSync(logoPath)){
50
+ if(logoPath){
51
+ console.warn("Logo de l'application innexistant!! Vous devez spécifier le logo de votre application, fichier ["+(logoPath)+"]")
52
+ }
53
+ }
54
+ const buildOutDir = path.resolve(electronDir,"dist");
55
+ const indexFile = path.resolve(buildOutDir,"index.html");
56
+ const webBuildDir = path.resolve(projectRoot,"web-build");
57
+ const promise = new Promise((resolve,reject)=>{
58
+ const next = ()=>{
59
+ if(fs.existsSync(webBuildDir)){
60
+ return copyDir(webBuildDir,buildOutDir).catch(reject).then(resolve);
61
+ } else {
62
+ reject("fichier web-build exporté par electron innexistant!!");
63
+ }
64
+ }
65
+ if(parsedArgs.compile || !fs.existsSync(path.resolve(webBuildDir,"index.html"))){
66
+ cmd = "npx expo export:web";
67
+ console.log("******************** exporting app : "+cmd);
68
+ return exec({cmd,projectRoot}).then(next).catch(reject);
69
+ }
70
+ next();
71
+ });
72
+ return promise.then(()=>{
73
+ if(!fs.existsSync(buildOutDir) || !fs.existsSync(indexFile)){
74
+ throw "répertoire d'export web invalide où innexistant ["+buildOutDir+"]"
75
+ }
76
+ switch(script){
77
+ case "start":
78
+ cmd = "electron "+electronDir;
79
+ return new Promise((resolve,reject)=>{
80
+ exec({
81
+ cmd,
82
+ projectRoot : electronDir,
83
+ }).finally(()=>{
84
+ console.log("ant to exit");
85
+ })
86
+ setTimeout(resolve,1000)
87
+ })
88
+ break;
89
+ case "build":
90
+ break;
91
+ }
92
+ }).catch((e)=>{
93
+ console.log(e," is cathing ggg");
94
+ }).finally(()=>{
95
+ process.exit();
96
+ });
97
+ } else {
98
+ process.exit();
99
+ }
@@ -0,0 +1,18 @@
1
+ module.exports = (argv,supportedScript)=>{
2
+ const args = {};
3
+ if(!Array.isArray(argv) || !supportedScript || typeof supportedScript !=='object') return {};
4
+ argv.map(arg=>{
5
+ if(!arg || typeof arg != 'string') return;
6
+ arg = arg.trim();
7
+ if(arg in supportedScript){
8
+ args.script = arg;
9
+ } else if(arg.includes("=")){
10
+ const split = arg.split("=");
11
+ if(split.length !=2) return;
12
+ args[split[0].trim()] = split[1].trim();
13
+ } else {
14
+ args[arg] = true;
15
+ }
16
+ })
17
+ return args;
18
+ }
@@ -0,0 +1,18 @@
1
+ const fse = require('fs-extra');
2
+ const createDir = require("./createDir");
3
+ module.exports = (srcDir,destDir,options)=>{
4
+ options = typeof options =='object' && options ? options : {};
5
+ options.overwrite = typeof options.overwrite =='boolean'? options.overwrite : true;
6
+ return new Promise((resolve,reject)=>{
7
+ try {
8
+ if(!createDir(destDir)){
9
+ throw "Chemin destination invalide!!\n impossible de créer le repertoire destination pour la copie du dossier|fichier(s)";
10
+ }
11
+ fse.copySync(srcDir, destDir, options);
12
+ resolve(destDir);
13
+ } catch (err) {
14
+ console.error(err)
15
+ reject(err);
16
+ }
17
+ })
18
+ }
@@ -0,0 +1,14 @@
1
+ const getDirName = require('path').dirname;
2
+ const fs = require("fs");
3
+ module.exports = function createDir(path) {
4
+ if(!path || typeof path !='string') return false;
5
+ const p = getDirName(path);
6
+ if(!fs.existsSync(p)){
7
+ try {
8
+ fs.mkdirSync(p,{ recursive: true});
9
+ } catch(e){
10
+ console.log(e," making write file directory")
11
+ }
12
+ }
13
+ return fs.existsSync(p);
14
+ }
@@ -0,0 +1,55 @@
1
+ const exec = require('child_process').exec;
2
+ const fs = require("fs");
3
+ const _exec = (cmd,cmdOpts,logMessages)=>{
4
+ cmdOpts = typeof cmdOpts =='object' && cmdOpts || {};
5
+ return new Promise((resolve,reject)=>{
6
+ const timer = cmdOpts.loader !==false ? loaderTimer(cmd) : null;
7
+ exec(cmd,cmdOpts, (error, stdout, stderr) => {
8
+ if (error) {
9
+ logMessages !== false && console.log(`error: ${error.message}`);;
10
+ reject(error);
11
+ clearInterval(timer);
12
+ return;
13
+ }
14
+ if (stderr) {
15
+ logMessages !== false && console.error(`stderr: ${stderr}`);
16
+ reject(stderr);
17
+ clearInterval(timer);
18
+ return;
19
+ }
20
+ if(stdout && logMessages !== false){
21
+ console.log(`stdout: ${stdout}`);
22
+ }
23
+ clearInterval(timer);
24
+ resolve(stdout);
25
+ });
26
+ })
27
+ }
28
+ const loaderTimer = function(timout) {
29
+ const text = typeof timout =='string' && timout ||'';
30
+ timout = typeof timout =='number'? timout : 250;
31
+ var P = ["\\", "|", "/", "-"];
32
+ var x = 0;
33
+ return setInterval(function() {
34
+ process.stdout.write("\r"+text+" "+P[x++]);
35
+ x &= 3;
36
+ }, timout);
37
+ };
38
+ module.exports = function(cmdOpts,options){
39
+ if(typeof cmdOpts =='string'){
40
+ cmdOpts = {cmd:cmdOpts};
41
+ }
42
+ options = typeof options =='object' && options ? options : {};
43
+ cmdOpts = cmdOpts && typeof cmdOpts =="object"? cmdOpts : {};
44
+ cmdOpts = {...cmdOpts,...options,cmd:cmdOpts.cmd|| cmdOpts.command};
45
+ const {cmd,projectRoot,logMessages} = cmdOpts;
46
+ if(!cmd|| typeof cmd !='string'){
47
+ return Promise.reject("Commande de script invalide, veuillez spécifier une chaine de caractère non nulle");
48
+ }
49
+ if(typeof projectRoot =='string' && projectRoot && fs.existsSync(projectRoot)){
50
+ return _exec('cd '+projectRoot).then((r)=>{
51
+ return _exec(cmd,cmdOpts,logMessages);
52
+ })
53
+ }
54
+ return _exec(cmd,cmdOpts,logMessages);
55
+ }
package/electron/index.js CHANGED
@@ -1,21 +1,44 @@
1
1
  const {app, BrowserWindow,Tray,Menu,MenuItem,systemPreferences,powerMonitor,dialog, nativeTheme} = require('electron')
2
2
  const appConfig = {}//require("../src/app/config");
3
- const session = require("./session");
3
+ const session = require("./src/session");
4
4
  const path = require("path");
5
+ const paths = require("./paths.json");
6
+ const images = paths.$images, assets = paths.$assets, logo = paths.logo;
5
7
  // Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
6
8
  // fermee automatiquement quand l'objet JavaScript sera garbage collected.
7
9
  let win = undefined;
8
10
  let fs = require("fs");
9
- let icon = undefined;
10
- const imagesPath = path.join(__dirname,"assets/images")
11
- if(process.platform =="win32" && fs.existsSync(path.join(imagesPath, "icon.ico"))){
12
- icon = path.join(imagesPath, "icon.ico");
13
- } else if(process.platform =="linux" && fs.existsSync(path.join(imagesPath, "icon.png"))){
14
- icon = path.join(imagesPath, "icon.png");
15
- } else if(process.platform =='darwin' && fs.existsSync(path.join(imagesPath, "icon.incs"))){
16
- icon = path.join(imagesPath, "icon.incs");
11
+ const isWindow = process.platform =="win32",
12
+ isMac = process.platform =='darwin',
13
+ isLinux = process.platform =="linux";
14
+ const getIcon = (p)=>{
15
+ if(Array.isArray(p)){
16
+ for(let i in p){
17
+ const r = getIcon(p[i]);
18
+ if(r) return r;
19
+ }
20
+ } else if(typeof p =='string' && p && fs.existsSync(p)){
21
+ const ext = isWindow ? ".ico" : isMac ? ".incs" : ".png";
22
+ const possibles = ["icon","logo","favicon"];
23
+ for(let i in possibles){
24
+ const icon = path.join(p,possibles[i]+ext);
25
+ if(fs.existsSync(icon)){
26
+ return icon;
27
+ }
28
+ }
29
+ }
30
+ return undefined;
17
31
  }
18
-
32
+ const icon = isLinux && logo && fs.existsSync(logo) && logo || getIcon(
33
+ logo && fs.existsSync(logo) && path.dirname(logo),
34
+ images,
35
+ assets,
36
+ )
37
+ /*console.log(icon," is iccccccc");
38
+ console.log(logo," is logo ",images,assets);
39
+ throw {
40
+ message : "icon is "+icon+" logo is "+logo+" image is "+images+" assets is "+assets
41
+ }*/
19
42
  Menu.setApplicationMenu(null);
20
43
  let clipboadContextMenu = (_, props) => {
21
44
  if (props.isEditable || props.selectionText) {
@@ -248,7 +271,7 @@ app.whenReady().then(() => {
248
271
  });
249
272
  })
250
273
 
251
- let {ipcMain} = require("electron");
274
+ const {ipcMain} = require("electron");
252
275
 
253
276
  ipcMain.on("electron-restart-app",x =>{
254
277
  app.relaunch();
@@ -291,7 +314,7 @@ ipcMain.on("update-system-tray",(event,opts)=>{
291
314
  tray.setContextMenu(contextMenu)
292
315
  })
293
316
  ipcMain.on("electron-get-path",(event,pathName)=>{
294
- let p = app.getPath(pathName);
317
+ const p = app.getPath(pathName);
295
318
  event.returnValue = p;
296
319
  return p;
297
320
  });
@@ -1,7 +1,6 @@
1
1
  (function(window) {
2
2
  let showingExitApp = undefined;
3
- let sudo = require('sudo-prompt');
4
- const { exec } = require('child_process');
3
+ const exec = require("../exec");
5
4
  if(typeof window.isElectron != 'function'){
6
5
  Object.defineProperties(window,{
7
6
  ELECTRON : {
@@ -23,8 +22,7 @@
23
22
  },
24
23
  })
25
24
  }
26
- ELECTRON;
27
- let fs = require("fs");
25
+ const fs = require("fs");
28
26
  let _app = require("./app.config");
29
27
  require("./pload")(ELECTRON);
30
28
  const {ipcRenderer} = require('electron')
@@ -286,65 +284,7 @@
286
284
  value : getPath, override:false,writable:false
287
285
  },
288
286
  exec : {
289
- value : (opts,successCB,errorCB)=>{
290
- if(isNonNullString(opts)){
291
- opts = {cmd:opts};
292
- }
293
- let {cmd} = opts;
294
- opts = defaultObj(opts);
295
- successCB = defaultFunc(successCB,opts.onSuccess)
296
- errorCB = defaultFunc(errorCB,opts.onError);
297
- return new Promise((resolve,reject)=>{
298
- let handle = function(error, stdout, stderr) {
299
- if(error){
300
- errorCB({error,stderr})
301
- return reject({error,stderr})
302
- }
303
- successCB(stdout);
304
- resolve(stdout);
305
- }
306
- if(opts.sudo || opts.runAsAdmin){
307
- sudo.exec(cmd, opts,handle)
308
- } else {
309
- exec(cmd,handle);
310
- }
311
- })
312
- }
313
- },
314
- installNewAppVersion : {
315
- value : (conf,successCB,errorCB)=>{
316
- if(isNonNullString(conf)){
317
- conf = {filePath:conf}
318
- }
319
- conf = defaultObj(conf);
320
- let {notify} = APP.require("$dialog");
321
-
322
- if(isNonNullString(conf.filePath) && fs.existsSync(conf.filePath)){
323
- let cmd = conf.filePath;
324
- if(ELECTRON.DEVICE.isLinux){
325
- cmd = "dpkg -i "+cmd;
326
- }
327
- let rootPath = path.join(__dirname,'..')
328
- let incs = path.join(rootPath, ELECTRON.DEVICE.isWindows?'icon.ico':ELECTRON.DEVICE.isLinux?'icon.png':'incs');
329
- const options = {
330
- title : "Authorisez "+APP.getName()+"",
331
- name: APP.getName(),
332
- incs,
333
- icon : incs,
334
- cmd,
335
- sudo:true,
336
- onSoucces : (stdout)=>{
337
- let message = "Le processus d'installation de la mise à jour de l'application a été exécutée evec succès. Veuillez relancer l'application";
338
- notify.success(message);
339
- },
340
- onError: ({error})=>{
341
- notify.error("Erreur lors de l'exécution du fichier d'installation : "+defaultStr(error.message));
342
- }
343
- //icns: '/Applications/Electron.app/Contents/Resources/Electron.icns'
344
- };
345
- return ELECTRON.exec(options,successCB,errorCB)
346
- }
347
- }, override : false, writable : false
287
+ value : exec,
348
288
  },
349
289
  updateSystemTheme : {
350
290
  value : (theme)=>{
@@ -0,0 +1,7 @@
1
+ const fs = require("fs");
2
+ module.exports = function writeFile(path, contents, cb) {
3
+ if(require("./createDir")(path)){
4
+ return fs.writeFileSync(path, contents, cb);
5
+ }
6
+ throw {message : 'impossible de créer le repertoire associé au fichier'+path};
7
+ }
package/metro.config.js CHANGED
@@ -24,6 +24,6 @@ module.exports = function(opts){
24
24
  'jsx', 'js','tsx',
25
25
  ]
26
26
  // Remove all console logs in production...
27
- //config.transformer.minifierConfig.compress.drop_console = false;
27
+ config.transformer.minifierConfig.compress.drop_console = false;
28
28
  return config;
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,9 +42,7 @@
42
42
  "delete-node-modules": "rimraf ./**/node_modules",
43
43
  "modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'"
44
44
  },
45
- "bin": {
46
- "electron": "bin/electron/index.js"
47
- },
45
+ "bin": "./bin/index.js",
48
46
  "repository": {
49
47
  "type": "git",
50
48
  "url": "git+https://github.com/borispipo/expo-ui.git"
@@ -72,6 +70,7 @@
72
70
  "@react-navigation/native-stack": "^6.9.7",
73
71
  "@shopify/flash-list": "1.3.1",
74
72
  "conf": "^10.2.0",
73
+ "electron": "^22.1.0",
75
74
  "expo": "^47.0.8",
76
75
  "expo-camera": "~13.1.0",
77
76
  "expo-clipboard": "~4.0.1",
@@ -83,6 +82,7 @@
83
82
  "expo-system-ui": "~2.0.1",
84
83
  "expo-web-browser": "~12.0.0",
85
84
  "file-saver": "^2.0.5",
85
+ "fs-extra": "^11.1.0",
86
86
  "google-libphonenumber": "^3.2.31",
87
87
  "htmlparser2-without-node-native": "^3.9.2",
88
88
  "mongo-parse": "^2.1.0",
package/src/auth/Login.js CHANGED
@@ -20,7 +20,7 @@ import {getTitle} from "$escreens/Auth/utils";
20
20
  import {isWeb} from "$cplatform";
21
21
  import ProviderSelector from "./ProviderSelector";
22
22
  import { ScrollView } from "react-native";
23
-
23
+ import PropTypes from "prop-types";
24
24
  import getLoginProps from "$getLoginProps";
25
25
  const getProps = typeof getLoginProps =='function'? getLoginProps : x=>null;
26
26
 
@@ -89,7 +89,8 @@ export default function LoginComponent(props){
89
89
  const {header,
90
90
  headerTopContent:HeaderTopContent,
91
91
  containerProps : customContainerProps,
92
- contentProp,
92
+ withHeaderAvatar,
93
+ contentProps : customContentProps,
93
94
  withScrollView:customWithScrollView,children,initialize,contentTop,data:loginData,canGoToNext,keyboardEvents,onSuccess:onLoginSuccess,mutateData,beforeSubmit:beforeSubmitForm,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
94
95
  ...state,
95
96
  setState,
@@ -106,6 +107,7 @@ export default function LoginComponent(props){
106
107
  previousButtonRef,
107
108
  }));
108
109
  const containerProps = defaultObj(customContainerProps);
110
+ const contentProps = defaultObj(customContentProps);
109
111
 
110
112
  React.useEffect(()=>{
111
113
  Preloader.closeAll();
@@ -198,9 +200,9 @@ export default function LoginComponent(props){
198
200
  const withScrollView = typeof customWithScrollView =='boolean'? customWithScrollView : true;
199
201
  const Wrapper = withPortal ? ScreenWithoutAuthContainer : withScrollView ? ScrollView: View;
200
202
  const mQueryUpdateProps = (a)=>{
201
- const style = StyleSheet.flatten([updateMediaQueryStyle(),containerProps.style]);
202
- if(typeof containerProps.updateMediaQueryStyle =='function'){
203
- return containerProps.updateMediaQueryStyle({style})
203
+ const style = StyleSheet.flatten([updateMediaQueryStyle(),contentProps.style]);
204
+ if(typeof contentProps.updateMediaQueryStyle =='function'){
205
+ return contentProps.updateMediaQueryStyle({style})
204
206
  }
205
207
  return {style};
206
208
  };
@@ -211,14 +213,14 @@ export default function LoginComponent(props){
211
213
  return <Wrapper testID = {testID+"_Wrapper" }{...wrapperProps}>
212
214
  <DialogProvider ref={dialogProviderRef}/>
213
215
  {sH}
214
- <Surface style={[styles.container,{backgroundColor}]} testID={testID}>
215
- <Surface elevation = {0} {...containerProps} mediaQueryUpdateNativeProps = {mQueryUpdateProps} {...containerProps} testID={testID+"_Content"} style={[styles.content,updateMediaQueryStyle(),{backgroundColor},containerProps.style]}>
216
+ <Surface style={[styles.container,{backgroundColor}]} {...containerProps} testID={testID}>
217
+ <Surface elevation = {0} {...contentProps} mediaQueryUpdateNativeProps = {mQueryUpdateProps} {...contentProps} testID={testID+"_Content"} style={[styles.content,updateMediaQueryStyle(),{backgroundColor},contentProps.style]}>
216
218
  <FormData
217
219
  formName = {formName}
218
220
  testID = {testID+"_FormData"}
219
221
  style = {[styles.formData,{backgroundColor}]}
220
222
  header = {<View style = {[styles.header]}>
221
- <Avatar testID={testID+"_Avatar"} size={50} secondary icon = 'lock'/>
223
+ {withHeaderAvatar !== false && <Avatar testID={testID+"_Avatar"} size={50} secondary icon = 'lock'/> || null}
222
224
  {
223
225
  React.isValidElement(header)? header :
224
226
  <Label testID={testID+"_HeaderText"} bool style={{color:theme.colors.primaryOnSurface,fontSize:18,paddingTop:10}}>Connectez vous SVP</Label>
@@ -333,3 +335,15 @@ const styles = StyleSheet.create({
333
335
  }
334
336
  });
335
337
 
338
+ LoginComponent.propTypes = {
339
+ withHeaderAvatar:PropTypes.bool,//si l'on affichera l'avatar de connexion
340
+ headerTopContent : PropTypes.oneOfType([
341
+ PropTypes.func,
342
+ PropTypes.node,
343
+ PropTypes.element,
344
+ ]),
345
+ header : PropTypes.oneOfType([
346
+ PropTypes.node,
347
+ PropTypes.element,
348
+ ]),
349
+ }
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
- /**@see : https://blog.shahednasser.com/how-to-create-a-npx-tool/ */
3
- 'use strict';
4
- process.on('unhandledRejection', err => {
5
- throw err;
6
- });
7
- const spawnAsync = require('cross-spawn').spawn;
8
- const { realpathSync } = require('fs-extra');
9
-
10
- //const { ensureMinProjectSetupAsync } = require('../build/Config');
11
-
12
- const args = process.argv.slice(2);
13
-
14
- const scriptIndex = args.findIndex(x => x === 'start' || x === 'customize');
15
- const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
16
- const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
17
- console.log(args," is argggggg",script);
18
- if (['start', 'customize'].includes(script)) {
19
- spawnAsync(
20
- 'node',
21
- nodeArgs.concat(require.resolve('./scripts/' + script)).concat(args.slice(scriptIndex + 1)),
22
- { stdio: 'inherit' }
23
- ).then(result => {
24
- if (result.signal) {
25
- if (result.signal === 'SIGKILL') {
26
- console.log(
27
- 'The build failed because the process exited too early. ' +
28
- 'This probably means the system ran out of memory or someone called ' +
29
- '`kill -9` on the process.'
30
- );
31
- } else if (result.signal === 'SIGTERM') {
32
- console.log(
33
- 'The build failed because the process exited too early. ' +
34
- 'Someone might have called `kill` or `killall`, or the system could ' +
35
- 'be shutting down.'
36
- );
37
- }
38
- process.exit(1);
39
- }
40
- process.exit(result.status);
41
- });
42
- } else if (script === undefined) {
43
- const projectRoot = realpathSync(process.cwd());
44
-
45
- //ensureMinProjectSetupAsync(projectRoot);
46
- } else {
47
- console.log('Invalid command "' + script + '".');
48
- }
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- /**@see : https://blog.shahednasser.com/how-to-create-a-npx-tool/ */
3
- 'use strict';
4
- process.on('unhandledRejection', err => {
5
- throw err;
6
- });
7
- const args = process.argv.slice(2);
8
-
9
- console.log(args," is arggggg");
10
-
11
- process.exist();
@@ -1,21 +0,0 @@
1
- const chalk = require('chalk');
2
- const fs = require('fs-extra');
3
-
4
- const { copyTemplateToProject, ensureMinProjectSetupAsync } = require('..');
5
- process.on('unhandledRejection', err => {
6
- throw err;
7
- });
8
-
9
- const projectRoot = fs.realpathSync(process.cwd());
10
-
11
- console.log();
12
- console.log(chalk.magenta('\u203A Copying Expo Electron main process to local project...'));
13
-
14
- copyTemplateToProject(projectRoot);
15
- ensureMinProjectSetupAsync(projectRoot);
16
-
17
- console.log(
18
- chalk.magenta(
19
- '\u203A You can now edit the Electron main process in the `electron/main` folder of your project...'
20
- )
21
- );
@@ -1,8 +0,0 @@
1
- const { ensureElectronConfig } = require('..');
2
-
3
- ensureElectronConfig(process.cwd());
4
-
5
- process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 1;
6
- process.env.platform = "electron";
7
-
8
- require('electron-webpack/out/dev/dev-runner');
@@ -1,84 +0,0 @@
1
- /**@see : https://www.npmjs.com/package/@expo/webpack-config/v/0.11.4 */
2
- const createExpoWebpackConfigAsync = require('@expo/webpack-config')
3
- const path = require("path");
4
- const isObj = x => x && typeof x =='object' && !Array.isArray(x);
5
- // Expo CLI will await this method so you can optionally return a promise.
6
- module.exports = async function(env, argv,opts) {
7
- const dir = path.resolve(__dirname);
8
- env = env || {};
9
- opts = typeof opts =="object" && opts ? opts : {};
10
- const babel = isObj(opts.babel)? opts.babel : {};
11
- const isElectron = typeof env.platform =="string" && env.platform.toLowerCase().trim() ==='electron';
12
- if(isElectron){
13
- env.platform = "electron";
14
- env.mode = env.mode =="production" && "production" || "development";
15
- env.pwa = false;
16
- }
17
- const transpileModules = Array.isArray(opts.transpileModules)? opts.transpileModules : [];
18
- const config = await createExpoWebpackConfigAsync(
19
- {
20
- ...env,
21
- babel: {
22
- ...babel,
23
- dangerouslyAddModulePathsToTranspile: [
24
- // Ensure that all packages starting with @fto-consult are transpiled.
25
- '@fto-consult',
26
- ...transpileModules,
27
- ],
28
- },
29
- },
30
- argv
31
- );
32
- config.module.rules.push(
33
- {
34
- test: /.mjs$/,
35
- include: /node_modules/,
36
- include: /node_modules/,
37
- type: "javascript/auto",
38
- use: {loader: 'babel-loader'}
39
- });
40
- //config.resolve.alias['moduleA'] = 'moduleB';
41
- config.mode = (config.mode =="development" || config.mode =='production') ? config.mode : "development";
42
- // Maybe you want to turn off compression in dev mode.
43
- if (config.mode === 'development') {
44
- config.devServer.compress = false;
45
- }
46
- // Or prevent minimizing the bundle when you build.
47
- if (config.mode === 'production') {
48
- config.optimization.minimize = true;
49
- }
50
- config.performance = typeof config.performance =="object" && config.performance ? config.performance : {};
51
- config.performance.hints = "hints" in config.performance ? config.performance.hints : false;
52
- config.performance.maxEntrypointSize = typeof config.performance.maxEntrypointSize =='number'? config.performance.maxEntrypointSize : 512000;
53
- config.performance.maxAssetSize = typeof config.performance.maxAssetSize =='number'? config.performance.maxAssetSize : 512000;
54
- config.devtool = (config.mode === 'development') ? 'inline-source-map' : false;
55
- require("./compiler.config.js")({config,...opts,dir});
56
- if(isElectron){
57
- const electronPath = process.cwd();
58
- config.output = config.output || {};
59
- config.output.publicPath = "./";
60
- config.output.path = path.join(electronPath,"dist");
61
- if(isObj(config.node)){
62
- config.resolve.fallback = isObj(config.resolve.fallback)? config.resolve.fallback : {};
63
- for(let i in config.node){
64
- if(config.node[i] =="empty"){
65
- config.resolve.fallback[i] = false;
66
- } else config.resolve.fallback[i] = config.node[i];
67
- delete config.node[i];
68
- }
69
- config.resolve.byDependency = {
70
- // ...
71
- esm: {
72
- mainFields: ['browser', 'module'],
73
- },
74
- commonjs: {
75
- aliasFields: ['browser'],
76
- },
77
- url: {
78
- preferRelative: true,
79
- },
80
- }
81
- }
82
- }
83
- return config;
84
- };
@@ -1,45 +0,0 @@
1
- const createExpoWebpackConfigAsync = require('@expo/webpack-config');
2
- const envManager = require("@expo/webpack-config/env");
3
- const addons = require("@expo/webpack-config/addons");
4
- const jsonfile = require('jsonfile');
5
- const path = require("path");
6
- const mode = 'development';
7
- const isObj = x => x && typeof x =='object' && !Array.isArray(x);
8
- /***@see : https://www.npmjs.com/package/@expo/webpack-config */
9
- module.exports = async function(env, argv) {
10
- const projectRoot = process.cwd()
11
- const electronPath = path.join(projectRoot,'electron');
12
- env = env || {};
13
- env.projectRoot = projectRoot;
14
- env.platform = "electron";//isObj(env.platform)? env.platform : {};//'web'///electron;
15
- //env.platform.type = "electron";
16
- env.locations = (0, envManager.getPaths)(projectRoot)
17
- env.pwa = false;
18
- let config = (0, addons.withAlias)({}, (0, envManager.getAliases)(projectRoot));
19
- if(argv && typeof argv =='object' && (argv.mode =='production' || argv.mode =="development")){
20
- env.mode = argv.mode;
21
- } else {
22
- env.mode = mode;
23
- }
24
- config = await createExpoWebpackConfigAsync(env, argv);
25
- config.output = config.output || {};
26
- config.output.publicPath = "./";
27
- config.output.path = path.join(electronPath,"dist");
28
- if (!config.plugins) config.plugins = [];
29
- if (!config.resolve) config.resolve = {};
30
- for(let i in config.plugins){
31
- let pl = config.plugins[i];
32
- //on recherche le fichier html build de webpack
33
- if(pl && typeof pl =='object' && pl.options && typeof pl.options =='object'){
34
- if(typeof pl.options.filename =="string" && pl.options.filename.toLowerCase().includes("index.html")){
35
- pl.options.filename = path.join(config.output.path,"index.html");
36
- break;
37
- }
38
- }
39
- }
40
- //console.log(config.resolve.extensions, "is r extensions")
41
- config.resolve.extensions = (0, envManager.getModuleFileExtensions)('electron', 'web');
42
- //jsonfile.writeFileSync("electron/config.back.json", config, {spaces: 4});
43
- console.log("******electron config file generated**********");
44
- return config;
45
- };
@@ -1,27 +0,0 @@
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
- const path = require("path");
6
- const dir = path.resolve(__dirname);
7
- const fs = require("fs");
8
-
9
- /*** check weather os is case sensitive
10
- * @see : https://stackoverflow.com/questions/27367261/check-if-file-exists-case-sensitive/52908385#52908385
11
- */
12
- function fileExistsWithCaseSync(filepath) {
13
- var dir = path.dirname(filepath);
14
- if (dir === '/' || dir === '.') return true;
15
- var filenames = fs.readdirSync(dir);
16
- if (filenames.indexOf(path.basename(filepath)) === -1) {
17
- return false;
18
- }
19
- return fileExistsWithCaseSync(dir);
20
- }
21
-
22
- /***vérifie si le système supporte la cassse où non
23
- * c'est à dire si 2 noms de fichiers ayant la case différentes sont considérés comme le même où pas
24
- */
25
- module.exports = (()=>{
26
- return fileExistsWithCaseSync(path.resolve(dir,"metro.config.js")) == fileExistsWithCaseSync(path.resolve(dir,"Metro.config.js"))
27
- })();
package/writeFile.js DELETED
@@ -1,16 +0,0 @@
1
- const path = require("path");
2
- const getDirName = require('path').dirname;
3
- module.exports = function writeFile(path, contents, cb) {
4
- const p = getDirName(path);
5
- if(!fs.existsSync(p)){
6
- try {
7
- fs.mkdirSync(p,{ recursive: true});
8
- } catch(e){
9
- console.log(e," making write file directory")
10
- }
11
- }
12
- if(fs.existsSync(p)){
13
- return fs.writeFileSync(path, contents, cb);
14
- }
15
- throw {message : 'impossible de créer le repertoire '+p};
16
- }