@fto-consult/expo-ui 5.0.2 → 5.0.3

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
@@ -52,6 +52,8 @@ if(parsedArgs.electron){
52
52
  }
53
53
  const electronProjectRoot = path.resolve(projectRoot,"electron");
54
54
  const isElectionInitialized = require("../electron/is-initialized")(electronProjectRoot);
55
+ process.env.isElectron = true;
56
+ process.env.isElectronScript = true;
55
57
  if(!isElectionInitialized || script =='init'){
56
58
  if(script !=='init'){
57
59
  console.log("initializing electron application before ....");
@@ -2,6 +2,9 @@ const exec = require('child_process').exec;
2
2
  const fs = require("fs");
3
3
  const _exec = (cmd,cmdOpts,logMessages)=>{
4
4
  cmdOpts = typeof cmdOpts =='object' && cmdOpts || {};
5
+ cmdOpts.env = typeof cmdOpts.env =="object" && cmdOpts.env || {};
6
+ cmdOpts.env = {...process.env,...cmdOpts.env};
7
+ cmdOpts.env.platform = cmdOpts.env.platform || "electron";
5
8
  return new Promise((resolve,reject)=>{
6
9
  const timer = cmdOpts.loader !==false ? loaderTimer(cmd) : null;
7
10
  exec(cmd,cmdOpts, (error, stdout, stderr) => {
package/metro.config.js CHANGED
@@ -8,10 +8,11 @@ module.exports = function(opts){
8
8
  const projectRoot = process.cwd();
9
9
  const localDir = path.resolve(__dirname);
10
10
  const config = getDefaultConfig(projectRoot);
11
- config.watchFolders = [projectRoot];
11
+ config.watchFolders = Array.isArray(config.watchFolders) && config.watchFolders || [];
12
12
  if(projectRoot !== localDir){
13
13
  config.watchFolders.push(localDir);
14
14
  }
15
+ config.projectRoot = projectRoot;
15
16
  config.resolver.assetExts = [
16
17
  ...config.resolver.assetExts,
17
18
  ...assetExts,
@@ -25,5 +26,11 @@ module.exports = function(opts){
25
26
  ]
26
27
  // Remove all console logs in production...
27
28
  config.transformer.minifierConfig.compress.drop_console = false;
29
+ config.platforms = Array.isArray(config.platforms) && config.platforms || [];
30
+ ['ios', 'android', 'windows', 'web',"electron"].map(p=>{
31
+ if(!config.platforms.includes(p)){
32
+ config.platforms.push(p);
33
+ }
34
+ });
28
35
  return config;
29
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -85,6 +85,7 @@
85
85
  "google-libphonenumber": "^3.2.31",
86
86
  "htmlparser2-without-node-native": "^3.9.2",
87
87
  "mongo-parse": "^2.1.0",
88
+ "process": "^0.11.10",
88
89
  "prop-types": "^15.8.1",
89
90
  "react": "^18.2.0",
90
91
  "react-apexcharts": "^1.4.0",
@@ -113,7 +114,7 @@
113
114
  "devDependencies": {
114
115
  "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
115
116
  "@babel/preset-react": "^7.18.6",
116
- "@expo/metro-config": "^0.5.2",
117
+ "@expo/metro-config": "^0.7.1",
117
118
  "@expo/webpack-config": "^18.0.1",
118
119
  "babel-plugin-inline-dotenv": "^1.7.0",
119
120
  "babel-plugin-module-resolver": "^4.1.0",
package/webpack.config.js CHANGED
@@ -2,21 +2,30 @@
2
2
  const createExpoWebpackConfigAsync = require('@expo/webpack-config')
3
3
  const path = require("path");
4
4
  const isObj = x => x && typeof x =='object' && !Array.isArray(x);
5
+ const webpack = require("webpack");
6
+ const fs = require("fs");
7
+ const writeFile = require("./electron/utils/writeFile");
8
+ const supportedPlatforms = ["web","electron"];
5
9
  // Expo CLI will await this method so you can optionally return a promise.
6
10
  module.exports = async function(env, argv,opts) {
7
11
  env = env || {};
8
12
  opts = typeof opts =="object" && opts ? opts : {};
9
13
  const babel = isObj(opts.babel)? opts.babel : {};
10
- const isElectron = typeof env.platform =="string" && env.platform.toLowerCase().trim() ==='electron';
14
+ const isElectron = process.env.isElectron || process.env.platform =="electron" || typeof env.platform =="string" && env.platform.toLowerCase().trim() ==='electron';
11
15
  if(isElectron){
12
16
  env.platform = "electron";
13
17
  env.mode = env.mode =="production" && "production" || "development";
14
18
  env.pwa = false;
15
19
  }
20
+ const platform = isElectron && "electron" || process.env.platform && supportedPlatforms.includes(process.platform) && process.platform || typeof opts.platform =="string" && supportedPlatforms.includes(opts.platform)? opts.platform : "web";
21
+ //writeFile(path.resolve(__dirname,"is-electron-platform.txt"),`platform = ${process.env.platform} and is electron = true ${process.env.isElectron}`)
16
22
  const transpileModules = Array.isArray(opts.transpileModules)? opts.transpileModules : [];
23
+ const projectRoot = opts.projectRoot && typeof opts.projectRoot =="string" && fs.existsSync(opts.projectRoot) && opts.projectRoot || process.cwd();
17
24
  const config = await createExpoWebpackConfigAsync(
18
25
  {
19
26
  ...env,
27
+ platform,
28
+ projectRoot,
20
29
  babel: {
21
30
  ...babel,
22
31
  dangerouslyAddModulePathsToTranspile: [
@@ -51,6 +60,10 @@ module.exports = async function(env, argv,opts) {
51
60
  config.performance.maxAssetSize = typeof config.performance.maxAssetSize =='number'? config.performance.maxAssetSize : 512000;
52
61
  config.devtool = (config.mode === 'development') ? 'inline-source-map' : false;
53
62
  require("./compiler.config.js")({config,...opts});
63
+ // fix "process is not defined" error:
64
+ config.plugins.push(new webpack.ProvidePlugin({
65
+ process: 'process/browser',
66
+ }));
54
67
  if(isElectron){
55
68
  const electronPath = process.cwd();
56
69
  config.output = config.output || {};