@wavemaker/rn-codegen 11.7.0-rc.161 → 11.7.0-rc.162

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.
Files changed (135) hide show
  1. rn-codegen/command.js +19 -8
  2. rn-codegen/command.js.map +1 -1
  3. rn-codegen/index.js +26 -0
  4. rn-codegen/index.js.map +1 -1
  5. rn-codegen/package.json +42 -42
  6. rn-codegen/src/app.generator.js +4 -2
  7. rn-codegen/src/app.generator.js.map +1 -1
  8. rn-codegen/src/templates/app.template +50 -32
  9. rn-codegen/src/templates/babel.config.js.template +7 -1
  10. rn-codegen/src/templates/component/component.template +2 -3
  11. rn-codegen/src/templates/package.web.json +54 -53
  12. rn-codegen/src/templates/project/app.json +11 -1
  13. rn-codegen/src/templates/project/esbuild/@react-navigation/drawer/6.6.3/lib/module/views/modern/Drawer.js +303 -0
  14. rn-codegen/src/templates/project/esbuild/@react-navigation/drawer/6.6.3/lib/module/views/modern/Overlay.js +60 -0
  15. rn-codegen/src/templates/project/esbuild/esbuild.script.js +121 -5
  16. rn-codegen/src/templates/project/metro.config.js +8 -0
  17. rn-codegen/src/templates/project/package-lock.json +5717 -6002
  18. rn-codegen/src/templates/project/package.json +54 -54
  19. rn-codegen/src/templates/project/revert-to-1.0.styles.js +41 -7
  20. rn-codegen/src/templates/project/scripts/post-build.js +13 -0
  21. rn-codegen/src/templates/variables.template +16 -0
  22. rn-codegen/src/theme/components/advanced/carousel.styledef.js +15 -2
  23. rn-codegen/src/theme/components/advanced/carousel.styledef.js.map +1 -1
  24. rn-codegen/src/theme/components/basic/lottie.styledef.js +6 -0
  25. rn-codegen/src/theme/components/basic/lottie.styledef.js.map +1 -1
  26. rn-codegen/src/theme/components/chart/area-chart.styledef.js +30 -0
  27. rn-codegen/src/theme/components/chart/area-chart.styledef.js.map +1 -1
  28. rn-codegen/src/theme/components/chart/bar-chart.styledef.js +31 -2
  29. rn-codegen/src/theme/components/chart/bar-chart.styledef.js.map +1 -1
  30. rn-codegen/src/theme/components/chart/bubble-chart.styledef.js +31 -2
  31. rn-codegen/src/theme/components/chart/bubble-chart.styledef.js.map +1 -1
  32. rn-codegen/src/theme/components/chart/column-chart.styledef.js +30 -0
  33. rn-codegen/src/theme/components/chart/column-chart.styledef.js.map +1 -1
  34. rn-codegen/src/theme/components/chart/donut-chart.styledef.js +59 -1
  35. rn-codegen/src/theme/components/chart/donut-chart.styledef.js.map +1 -1
  36. rn-codegen/src/theme/components/chart/line-chart.styledef.js +31 -0
  37. rn-codegen/src/theme/components/chart/line-chart.styledef.js.map +1 -1
  38. rn-codegen/src/theme/components/chart/pie-chart.styledef.js +50 -0
  39. rn-codegen/src/theme/components/chart/pie-chart.styledef.js.map +1 -1
  40. rn-codegen/src/theme/components/container/accordion.styledef.js +5 -0
  41. rn-codegen/src/theme/components/container/accordion.styledef.js.map +1 -1
  42. rn-codegen/src/theme/components/container/layoutgrid.styledef.js +5 -0
  43. rn-codegen/src/theme/components/container/layoutgrid.styledef.js.map +1 -1
  44. rn-codegen/src/theme/components/container/tile.styledef.js +6 -0
  45. rn-codegen/src/theme/components/container/tile.styledef.js.map +1 -1
  46. rn-codegen/src/theme/components/container/wizard.styledef.js +4 -0
  47. rn-codegen/src/theme/components/container/wizard.styledef.js.map +1 -1
  48. rn-codegen/src/theme/components/container.styledef.js +7 -1
  49. rn-codegen/src/theme/components/container.styledef.js.map +1 -1
  50. rn-codegen/src/theme/components/data/card/card-content.styledef.js +5 -0
  51. rn-codegen/src/theme/components/data/card/card-content.styledef.js.map +1 -1
  52. rn-codegen/src/theme/components/data/card.styledef.js +5 -0
  53. rn-codegen/src/theme/components/data/card.styledef.js.map +1 -1
  54. rn-codegen/src/theme/components/data/list/list-action-template.styledef.js +18 -0
  55. rn-codegen/src/theme/components/data/list/list-action-template.styledef.js.map +1 -0
  56. rn-codegen/src/theme/components/data/list/list-template.styledef.js +5 -0
  57. rn-codegen/src/theme/components/data/list/list-template.styledef.js.map +1 -1
  58. rn-codegen/src/theme/components/data/list.styledef.js +5 -0
  59. rn-codegen/src/theme/components/data/list.styledef.js.map +1 -1
  60. rn-codegen/src/theme/components/input/epoch/datetime.styledef.js +9 -1
  61. rn-codegen/src/theme/components/input/epoch/datetime.styledef.js.map +1 -1
  62. rn-codegen/src/theme/components/input/slider.styledef.js +40 -0
  63. rn-codegen/src/theme/components/input/slider.styledef.js.map +1 -1
  64. rn-codegen/src/theme/components/input/switch.styledef.js +10 -0
  65. rn-codegen/src/theme/components/input/switch.styledef.js.map +1 -1
  66. rn-codegen/src/theme/components/page/page-content.styledef.js +5 -0
  67. rn-codegen/src/theme/components/page/page-content.styledef.js.map +1 -1
  68. rn-codegen/src/theme/components/page/partial.styledef.js +5 -0
  69. rn-codegen/src/theme/components/page/partial.styledef.js.map +1 -1
  70. rn-codegen/src/theme/components/prefab.styledef.js +6 -1
  71. rn-codegen/src/theme/components/prefab.styledef.js.map +1 -1
  72. rn-codegen/src/theme/components/style-definition.provider.js +2 -0
  73. rn-codegen/src/theme/components/style-definition.provider.js.map +1 -1
  74. rn-codegen/src/theme/variables.js +4 -0
  75. rn-codegen/src/theme/variables.js.map +1 -1
  76. rn-codegen/src/transpile/components/advanced/carousel/carousel-template.transformer.js +2 -2
  77. rn-codegen/src/transpile/components/advanced/carousel/carousel-template.transformer.js.map +1 -1
  78. rn-codegen/src/transpile/components/basic/search.transformer.js +3 -2
  79. rn-codegen/src/transpile/components/basic/search.transformer.js.map +1 -1
  80. rn-codegen/src/transpile/components/chart/area-chart.transformer.js +4 -1
  81. rn-codegen/src/transpile/components/chart/area-chart.transformer.js.map +1 -1
  82. rn-codegen/src/transpile/components/chart/bar-chart.transformer.js +4 -2
  83. rn-codegen/src/transpile/components/chart/bar-chart.transformer.js.map +1 -1
  84. rn-codegen/src/transpile/components/chart/bubble-chart.transformer.js +4 -2
  85. rn-codegen/src/transpile/components/chart/bubble-chart.transformer.js.map +1 -1
  86. rn-codegen/src/transpile/components/chart/column-chart.transformer.js +4 -2
  87. rn-codegen/src/transpile/components/chart/column-chart.transformer.js.map +1 -1
  88. rn-codegen/src/transpile/components/chart/donut-chart.transformer.js +8 -2
  89. rn-codegen/src/transpile/components/chart/donut-chart.transformer.js.map +1 -1
  90. rn-codegen/src/transpile/components/chart/line-chart.transformer.js +4 -2
  91. rn-codegen/src/transpile/components/chart/line-chart.transformer.js.map +1 -1
  92. rn-codegen/src/transpile/components/chart/pie-chart.transformer.js +4 -2
  93. rn-codegen/src/transpile/components/chart/pie-chart.transformer.js.map +1 -1
  94. rn-codegen/src/transpile/components/chart/stack-chart.transformer.js +4 -2
  95. rn-codegen/src/transpile/components/chart/stack-chart.transformer.js.map +1 -1
  96. rn-codegen/src/transpile/components/data/form/form-field.transformer.js +5 -1
  97. rn-codegen/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
  98. rn-codegen/src/transpile/components/data/list/list-action-template.transformer.js +15 -0
  99. rn-codegen/src/transpile/components/data/list/list-action-template.transformer.js.map +1 -0
  100. rn-codegen/src/transpile/components/data/list/list-content.transformer.js +35 -0
  101. rn-codegen/src/transpile/components/data/list/list-content.transformer.js.map +1 -0
  102. rn-codegen/src/transpile/components/data/list/list-template.transformer.js +0 -25
  103. rn-codegen/src/transpile/components/data/list/list-template.transformer.js.map +1 -1
  104. rn-codegen/src/transpile/components/data/list.transformer.js +29 -3
  105. rn-codegen/src/transpile/components/data/list.transformer.js.map +1 -1
  106. rn-codegen/src/transpile/components/input/checkboxset.transformer.js +4 -2
  107. rn-codegen/src/transpile/components/input/checkboxset.transformer.js.map +1 -1
  108. rn-codegen/src/transpile/components/input/radioset.transformer.js +3 -2
  109. rn-codegen/src/transpile/components/input/radioset.transformer.js.map +1 -1
  110. rn-codegen/src/transpile/components/input/slider.transformer.js +15 -1
  111. rn-codegen/src/transpile/components/input/slider.transformer.js.map +1 -1
  112. rn-codegen/src/transpile/components/page/partial-container.transformer.js +1 -1
  113. rn-codegen/src/transpile/components/page/partial-container.transformer.js.map +1 -1
  114. rn-codegen/src/transpile/components/page/partial.transformer.js +1 -1
  115. rn-codegen/src/transpile/components/page/partial.transformer.js.map +1 -1
  116. rn-codegen/src/transpile/components/prefab/prefab-container.transformer.js +1 -1
  117. rn-codegen/src/transpile/components/prefab/prefab-container.transformer.js.map +1 -1
  118. rn-codegen/src/transpile/components/prefab/prefab.transformer.js +6 -1
  119. rn-codegen/src/transpile/components/prefab/prefab.transformer.js.map +1 -1
  120. rn-codegen/src/transpile/components/transform-register.js +4 -0
  121. rn-codegen/src/transpile/components/transform-register.js.map +1 -1
  122. rn-codegen/src/transpile/components/utils.js +28 -3
  123. rn-codegen/src/transpile/components/utils.js.map +1 -1
  124. rn-codegen/src/transpile/property/property-parser.js +28 -9
  125. rn-codegen/src/transpile/property/property-parser.js.map +1 -1
  126. rn-codegen/src/transpile/style/background-image.parser.js +1 -1
  127. rn-codegen/src/transpile/style/background-image.parser.js.map +1 -1
  128. rn-codegen/src/transpile/style/dimension-style.parser.js +5 -0
  129. rn-codegen/src/transpile/style/dimension-style.parser.js.map +1 -1
  130. rn-codegen/src/transpile/transpile.js +12 -4
  131. rn-codegen/src/transpile/transpile.js.map +1 -1
  132. rn-codegen/src/utils.js +1 -20
  133. rn-codegen/src/utils.js.map +1 -1
  134. rn-codegen/src/variables/variable.transformer.js +10 -2
  135. rn-codegen/src/variables/variable.transformer.js.map +1 -1
@@ -0,0 +1,60 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import * as React from 'react';
3
+ import { Platform, Pressable, StyleSheet } from 'react-native';
4
+ import Animated, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
5
+ const PROGRESS_EPSILON = 0.05;
6
+ const Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, ref) {
7
+ let {
8
+ progress,
9
+ onPress,
10
+ style,
11
+ accessibilityLabel = 'Close drawer',
12
+ ...props
13
+ } = _ref;
14
+ const animatedStyle = useAnimatedStyle(() => {
15
+ return {
16
+ opacity: progress.value,
17
+ // We don't want the user to be able to press through the overlay when drawer is open
18
+ // We can send the overlay behind the screen to avoid it
19
+ zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1
20
+ };
21
+ }, [progress, PROGRESS_EPSILON]);
22
+ const animatedProps = useAnimatedProps(() => {
23
+ const active = progress.value > PROGRESS_EPSILON;
24
+ return {
25
+ pointerEvents: active ? 'auto' : 'none',
26
+ accessibilityElementsHidden: !active,
27
+ importantForAccessibility: active ? 'auto' : 'no-hide-descendants'
28
+ };
29
+ }, [progress, PROGRESS_EPSILON]);
30
+ return /*#__PURE__*/React.createElement(Animated.View, _extends({}, props, {
31
+ ref: ref,
32
+ style: [styles.overlay, overlayStyle, animatedStyle, style],
33
+ animatedProps: animatedProps
34
+ }), /*#__PURE__*/React.createElement(Pressable, {
35
+ onPress: onPress,
36
+ style: styles.pressable,
37
+ accessibilityRole: "button",
38
+ accessibilityLabel: accessibilityLabel
39
+ }));
40
+ });
41
+ const overlayStyle = Platform.select({
42
+ web: {
43
+ // Disable touch highlight on mobile Safari.
44
+ // WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.
45
+ WebkitTapHighlightColor: 'transparent'
46
+ },
47
+ default: {}
48
+ });
49
+ const styles = StyleSheet.create({
50
+ overlay: {
51
+ ...StyleSheet.absoluteFillObject,
52
+ backgroundColor: 'rgba(0, 0, 0, 0.5)'
53
+ },
54
+ pressable: {
55
+ flex: 1,
56
+ pointerEvents: 'auto'
57
+ }
58
+ });
59
+ export default Overlay;
60
+ //# sourceMappingURL=Overlay.js.map
@@ -27,13 +27,16 @@ class EsBuilder {
27
27
  }
28
28
  }
29
29
 
30
- prepareIndexHtml() {
30
+ prepareIndexHtml(result) {
31
31
  console.log('build success');
32
32
  try {
33
33
  const bundleName = fs.readdirSync('./web-build').find(n => /^bundle.*js$/.test(n));
34
34
  let content = fs.readFileSync(__dirname + '/index.html', 'utf-8');
35
35
  content = content.replace(/".\/bundle.js"/, `"./${bundleName}"`);
36
36
  fs.writeFileSync('./web-build/index.html', content);
37
+
38
+ const metafilePath = path.join(__dirname, './', 'metafile.json');
39
+ fs.writeFileSync(metafilePath, JSON.stringify(result.metafile));
37
40
  } catch (err) {
38
41
  console.error(err);
39
42
  }
@@ -136,6 +139,10 @@ class EsBuilder {
136
139
  );
137
140
  }`;
138
141
  });
142
+ const target = `${__dirname}/../node_modules/react-native-web/dist/cjs/exports/BackHandler/index.js`;
143
+ await readAndReplaceFileContent(target, content => {
144
+ return content.replace('console.error', '// console.error');
145
+ });
139
146
  console.log('Patched react-native-web');
140
147
  }
141
148
 
@@ -147,6 +154,101 @@ class EsBuilder {
147
154
  }
148
155
  }
149
156
 
157
+ async patchReactNativeAssetRegistry() {
158
+ const content = `
159
+ /**
160
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
161
+ *
162
+ * This source code is licensed under the MIT license found in the
163
+ * LICENSE file in the root directory of this source tree.
164
+ *
165
+ * @flow strict
166
+ * @format
167
+ */
168
+
169
+ 'use strict';
170
+
171
+ const assets = [];
172
+
173
+ function registerAsset(asset) {
174
+ // push returns new array length, so the first asset will
175
+ // get id 1 (not 0) to make the value truthy
176
+ return assets.push(asset);
177
+ }
178
+
179
+ function getAssetByID(assetId) {
180
+ return assets[assetId - 1];
181
+ }
182
+
183
+ module.exports = {registerAsset, getAssetByID};
184
+
185
+ `;
186
+ fs.writeFileSync(`${__dirname}/../node_modules/@react-native/assets-registry/registry.js`, content);
187
+ const expoAssetRegistry = `${__dirname}/../node_modules/expo-asset/node_modules/@react-native/assets-registry/registry.js`;
188
+ readAndReplaceFileContent(expoAssetRegistry, () => content);
189
+ console.log('Patched @react-native/assets-registry');
190
+ }
191
+
192
+ async patchBabelExpoPreset() {
193
+ const target = `${__dirname}/../node_modules/babel-preset-expo/build/index.js`;
194
+ await readAndReplaceFileContent(target, content => {
195
+ return content.replace(
196
+ `(0, common_1.hasModule)('react-native-reanimated') &&`,
197
+ `//(0, common_1.hasModule)('react-native-reanimated') &&`)
198
+ .replace(
199
+ `platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`,
200
+ `//platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`
201
+ )
202
+ });
203
+ console.log('Patched babel-expo-preset');
204
+ }
205
+
206
+ async patchUUID() {
207
+ const target = `${__dirname}/../node_modules/expo-modules-core/build/uuid/uuid.web.js`;
208
+ await readAndReplaceFileContent(target, content => {
209
+ return content.replace(`require('crypto')`, 'crypto');
210
+ });
211
+ console.log('Patched UUID.');
212
+ }
213
+
214
+ async patchExpoRootComponent() {
215
+ const target = `${__dirname}/../node_modules/expo/build/launch/registerRootComponent.js`;
216
+ await readAndReplaceFileContent(target, content => {
217
+ return content.replace(`export default`,
218
+ `
219
+ const process = {env: {
220
+ NODE_ENV: 'development',
221
+ EXPO_PUBLIC_USE_STATIC: '0'
222
+ }};
223
+ export default `);
224
+ });
225
+ console.log('Patched Expo Root Component.');
226
+ }
227
+
228
+ async patchReactNavigation() {
229
+ // https://github.com/react-navigation/react-navigation/pull/11496/files
230
+ fs.copyFileSync(
231
+ `${__dirname}/@react-navigation/drawer/6.6.3/lib/module/views/modern/Drawer.js`,
232
+ `${__dirname}/../node_modules/@react-navigation/drawer/lib/module/views/modern/Drawer.js`
233
+ );
234
+ fs.copyFileSync(
235
+ `${__dirname}/@react-navigation/drawer/6.6.3/lib/module/views/modern/Overlay.js`,
236
+ `${__dirname}/../node_modules/@react-navigation/drawer/lib/module/views/modern/Overlay.js`
237
+ );
238
+ console.log('Patched React Navigation.');
239
+ }
240
+
241
+ async patchReactNativeReanimated() {
242
+ await readAndReplaceFileContent(`${__dirname}/../node_modules/react-native-reanimated/lib/module/reanimated2/PlatformChecker.js`, (c) => {
243
+ return c.replace(
244
+ '!!process.env.JEST_WORKER_ID',
245
+ 'false; // !!process.env.JEST_WORKER_ID'
246
+ )
247
+ });
248
+ console.log('Patched React Native Reanimated.');
249
+ }
250
+
251
+
150
252
  buildLibraries() {
151
253
  const promises = [{
152
254
  name: 'expo-web-browser',
@@ -182,6 +284,12 @@ class EsBuilder {
182
284
  .then(() => this.patchReactNativeWeb())
183
285
  .then(() => this.patchReactNativeAssets())
184
286
  .then(() => this.patchCamera())
287
+ .then(() => this.patchReactNativeAssetRegistry())
288
+ .then(() => this.patchBabelExpoPreset())
289
+ .then(() => this.patchUUID())
290
+ .then(() => this.patchExpoRootComponent())
291
+ .then(() => this.patchReactNavigation())
292
+ .then(() => this.patchReactNativeReanimated())
185
293
  .then(() => {
186
294
  console.log('*********** LIBRARIES ARE BUILT FOR ESBUILD **************');
187
295
  }, (e) => {
@@ -202,7 +310,9 @@ class EsBuilder {
202
310
  define: {'process.env.NODE_ENV': '"development"', '__DEV__': false, global:'window'},
203
311
  resolveExtensions: ['.web.tsx','.web.ts','.web.jsx','.web.js','.tsx','.ts','.jsx','.js',],
204
312
  loader: {".png": "file", ".jpeg": "file", ".ttf": "file", ".js": "jsx", ".gif": "file", ".svg": "file" },
205
- minify: false,
313
+ minifyWhitespace: true,
314
+ minifySyntax: true,
315
+ metafile: true,
206
316
  sourcemap: true,
207
317
  plugins: [babel({
208
318
  filter: /\/src\/.*jsx?/,
@@ -212,7 +322,11 @@ class EsBuilder {
212
322
  esmodules: true
213
323
  },
214
324
  sourceMaps: 'inline',
215
- plugins: [__dirname + '/../scripts/wm-babel.transform.plugin.js']
325
+ plugins: [
326
+ __dirname + '/../scripts/wm-babel.transform.plugin.js',
327
+ '@babel/plugin-proposal-export-namespace-from',
328
+ 'react-native-reanimated/plugin',
329
+ ]
216
330
  }
217
331
  }), resolve({
218
332
  'victory-native': 'victory'
@@ -225,11 +339,13 @@ class EsBuilder {
225
339
  console.time('react native with esbuild');
226
340
  this.cleanBuildDir();
227
341
  this.build()
228
- .then(() => this.prepareIndexHtml())
342
+ .then((result) => this.prepareIndexHtml(result))
229
343
  .then(() => {
230
344
  console.timeEnd('react native with esbuild');
231
345
  console.log('*********** REACT NATIVE ESBUILD SUCCESSFUL **************');
232
- }).catch(() => {
346
+ }).catch((error) => {
347
+ console.log('*********** REACT PROJECT ESBUILD ERROR **************');
348
+ console.error(error);
233
349
  console.timeEnd('react native with esbuild');
234
350
  console.log('*********** REACT PROJECT ESBUILD FAILED **************');
235
351
  });
@@ -11,6 +11,13 @@ module.exports = (async () => {
11
11
  ];
12
12
  config.resolver.disableHierarchicalLookup = true;
13
13
  config.transformer = {
14
+ ...config.transformer,
15
+ minifierPath: 'metro-minify-terser',
16
+ minifierConfig: {
17
+ compress:{
18
+ drop_debugger: false
19
+ }
20
+ },
14
21
  babelTransformerPath: require.resolve('react-native-svg-transformer'),
15
22
  getTransformOptions: async () => ({
16
23
  transform: {
@@ -20,6 +27,7 @@ module.exports = (async () => {
20
27
  })
21
28
  }
22
29
  config.resolver = {
30
+ ...config.resolver,
23
31
  assetExts: config.resolver.assetExts.filter(ext => ext !== 'svg'),
24
32
  sourceExts: [...config.resolver.sourceExts, 'svg']
25
33
  }