@wavemaker/rn-codegen 11.15.5-rc.647771 → 11.15.5-rc.647878

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 (147) hide show
  1. package/command.js +94 -262
  2. package/command.js.map +1 -1
  3. package/index.js +131 -125
  4. package/index.js.map +1 -1
  5. package/npm-shrinkwrap.json +575 -556
  6. package/package-lock.json +575 -556
  7. package/package.json +14 -10
  8. package/scripts/check-deps-compat.js +579 -0
  9. package/src/app.generator.js +438 -159
  10. package/src/app.generator.js.map +1 -1
  11. package/src/increment-builder.js +2 -1
  12. package/src/increment-builder.js.map +1 -1
  13. package/src/pipeline/build-common.js +63 -0
  14. package/src/pipeline/build-common.js.map +1 -0
  15. package/src/pipeline/build-pipeline.js +169 -0
  16. package/src/pipeline/build-pipeline.js.map +1 -0
  17. package/src/pipeline/generation-store.js +309 -0
  18. package/src/pipeline/generation-store.js.map +1 -0
  19. package/src/pipeline/shared-node-modules.js +934 -0
  20. package/src/pipeline/shared-node-modules.js.map +1 -0
  21. package/src/pipeline/web-preview-templates.js +80 -0
  22. package/src/pipeline/web-preview-templates.js.map +1 -0
  23. package/src/pipeline/working-set.js +103 -0
  24. package/src/pipeline/working-set.js.map +1 -0
  25. package/src/profiles/legacy-web-preview.profile.js +15 -0
  26. package/src/profiles/legacy-web-preview.profile.js.map +1 -0
  27. package/src/project.service.js +14 -0
  28. package/src/project.service.js.map +1 -1
  29. package/src/templates/app.template +74 -2
  30. package/src/templates/babel.config.js.template +3 -6
  31. package/src/templates/bootstrap.template +10 -1
  32. package/src/templates/component/component.template +1 -0
  33. package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/date.less +8 -1
  34. package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/datetime.less +8 -1
  35. package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/time.less +8 -1
  36. package/src/templates/foundation-theme/build/android/wavemaker/components/input/number.less +14 -0
  37. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/button.less +2 -2
  38. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/checkboxset.less +1 -0
  39. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/chips.less +12 -0
  40. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/radioset.less +1 -1
  41. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/currency.less +6 -2
  42. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/tokens.light.css +3 -2
  43. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/button.variant.less +2 -2
  44. package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/date.less +8 -1
  45. package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/datetime.less +8 -1
  46. package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/time.less +8 -1
  47. package/src/templates/foundation-theme/build/ios/wavemaker/components/input/number.less +14 -0
  48. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/button.less +2 -2
  49. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/checkboxset.less +1 -0
  50. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/chips.less +12 -0
  51. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/radioset.less +1 -1
  52. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/currency.less +6 -2
  53. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/tokens.light.css +3 -2
  54. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/button.variant.less +2 -2
  55. package/src/templates/foundation-theme/dist/android/style.css +5 -4
  56. package/src/templates/foundation-theme/dist/android/style.js +22 -9
  57. package/src/templates/foundation-theme/dist/android/tokens.js +3 -2
  58. package/src/templates/foundation-theme/dist/ios/style.css +5 -4
  59. package/src/templates/foundation-theme/dist/ios/style.js +22 -9
  60. package/src/templates/foundation-theme/dist/ios/tokens.js +3 -2
  61. package/src/templates/foundation-theme/wavemaker/components/input/epoch/date.less +8 -1
  62. package/src/templates/foundation-theme/wavemaker/components/input/epoch/datetime.less +8 -1
  63. package/src/templates/foundation-theme/wavemaker/components/input/epoch/time.less +8 -1
  64. package/src/templates/foundation-theme/wavemaker/components/input/number.less +14 -0
  65. package/src/templates/foundation-theme/wavemaker/design-tokens/basic/button.less +2 -2
  66. package/src/templates/foundation-theme/wavemaker/design-tokens/input/checkboxset.less +1 -0
  67. package/src/templates/foundation-theme/wavemaker/design-tokens/input/chips.less +12 -0
  68. package/src/templates/foundation-theme/wavemaker/design-tokens/input/radioset.less +1 -1
  69. package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/currency.less +6 -2
  70. package/src/templates/foundation-theme/wavemaker/design-tokens/tokens.light.css +3 -2
  71. package/src/templates/foundation-theme/wavemaker/design-tokens/variables/button.variant.less +2 -2
  72. package/src/templates/package.web.json +17 -7
  73. package/src/templates/page-stub.template +27 -0
  74. package/src/templates/project/.npmrc +1 -0
  75. package/src/templates/project/app.json +2 -1
  76. package/src/templates/project/esbuild/esbuild.script.js +56 -16
  77. package/src/templates/project/metro/container-limits.js +195 -0
  78. package/src/templates/project/metro/metro.script.js +850 -0
  79. package/src/templates/project/metro/module-path.js +237 -0
  80. package/src/templates/project/metro/split.serializer.js +184 -0
  81. package/src/templates/project/metro/split.static.js +633 -0
  82. package/src/templates/project/metro/stable-module-ids.js +54 -0
  83. package/src/templates/project/metro/vendor-cache.js +475 -0
  84. package/src/templates/project/metro/wm-boundary.js +150 -0
  85. package/src/templates/project/metro/wm-crawl-override.js +161 -0
  86. package/src/templates/project/metro/wm-fastbuild.js +196 -0
  87. package/src/templates/project/metro/wm-live-reload.js +482 -0
  88. package/src/templates/project/metro/wm-metro-adapter.js +25 -0
  89. package/src/templates/project/metro/wm-prebuilt.js +31 -0
  90. package/src/templates/project/metro.config.js +13 -2
  91. package/src/templates/project/package-lock.json +15308 -0
  92. package/src/templates/project/package.json +14 -6
  93. package/src/templates/project/patch-utils.js +331 -0
  94. package/src/templates/project/plugins/expo-pull-to-refresh/android/build.gradle +15 -0
  95. package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshModule.kt +21 -0
  96. package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshView.kt +221 -0
  97. package/src/templates/project/plugins/expo-pull-to-refresh/expo-module.config.json +16 -0
  98. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefresh.podspec +24 -0
  99. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift +17 -0
  100. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift +92 -0
  101. package/src/templates/project/plugins/expo-pull-to-refresh/package.json +15 -0
  102. package/src/templates/project/scripts/wm-babel.transform.plugin.js +11 -1
  103. package/src/templates/project/wavepulse/rn2css.json +5 -0
  104. package/src/theme/app-override-css.generator.js +10 -4
  105. package/src/theme/app-override-css.generator.js.map +1 -1
  106. package/src/theme/components/input/epoch/datetime.styledef.js +5 -0
  107. package/src/theme/components/input/epoch/datetime.styledef.js.map +1 -1
  108. package/src/theme/components/input/number.styledef.js +10 -0
  109. package/src/theme/components/input/number.styledef.js.map +1 -1
  110. package/src/theme/rn-stylesheet.transpiler.js +30 -6
  111. package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
  112. package/src/theme/theme.service.js +3 -2
  113. package/src/theme/theme.service.js.map +1 -1
  114. package/src/transpile/bind.ex.transformer.js +55 -37
  115. package/src/transpile/bind.ex.transformer.js.map +1 -1
  116. package/src/transpile/components/container/wizard/wizardstep.transformer.js +10 -2
  117. package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
  118. package/src/transpile/components/data/form/form-field.transformer.js +36 -1
  119. package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
  120. package/src/transpile/components/page/page.transformer.js +11 -1
  121. package/src/transpile/components/page/page.transformer.js.map +1 -1
  122. package/src/transpile/property/property-parser.js +4 -1
  123. package/src/transpile/property/property-parser.js.map +1 -1
  124. package/src/transpile/style.transformer.js +1 -0
  125. package/src/transpile/style.transformer.js.map +1 -1
  126. package/src/transpile/transpile.js +10 -1
  127. package/src/transpile/transpile.js.map +1 -1
  128. package/src/utils.js +8 -1
  129. package/src/utils.js.map +1 -1
  130. package/src/wm-namespace.js +14 -0
  131. package/src/wm-namespace.js.map +1 -0
  132. package/test/pipeline/build-leftovers.test.js +172 -0
  133. package/test/pipeline/build-leftovers.test.js.map +1 -0
  134. package/test/pipeline/chmod-tree.test.js +54 -0
  135. package/test/pipeline/chmod-tree.test.js.map +1 -0
  136. package/test/pipeline/crawl-override.test.js +53 -0
  137. package/test/pipeline/crawl-override.test.js.map +1 -0
  138. package/test/pipeline/live-reload-pacing.test.js +76 -0
  139. package/test/pipeline/live-reload-pacing.test.js.map +1 -0
  140. package/test/pipeline/npm-install-retry.test.js +57 -0
  141. package/test/pipeline/npm-install-retry.test.js.map +1 -0
  142. package/test/pipeline/repair-vendor-packages.test.js +134 -0
  143. package/test/pipeline/repair-vendor-packages.test.js.map +1 -0
  144. package/test/pipeline/web-preview-files.test.js +48 -0
  145. package/test/pipeline/web-preview-files.test.js.map +1 -0
  146. package/web-preview.js +155 -0
  147. package/web-preview.js.map +1 -0
@@ -11,9 +11,9 @@
11
11
  "postinstall": "node ./scripts/post-build.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wavemaker/app-rn-runtime": "11.15.5-rc.647771",
15
- "@wavemaker/variables": "11.15.5-rc.647771",
16
- "@wavemaker/rn-codegen": "11.15.5-rc.647771",
14
+ "@wavemaker/app-rn-runtime": "11.15.5-rc.647878",
15
+ "@wavemaker/variables": "11.15.5-rc.647878",
16
+ "@wavemaker/rn-codegen": "11.15.5-rc.647878",
17
17
  "@wavemaker/wavepulse-agent": "1.0.11",
18
18
  "expo": "54.0.12",
19
19
  "expo-build-properties": "1.0.9",
@@ -42,7 +42,7 @@
42
42
  "react": "19.1.0",
43
43
  "react-dom": "19.1.0",
44
44
  "react-native": "0.81.4",
45
- "react-native-web": "0.21.0",
45
+ "react-native-web": "0.21.4",
46
46
  "@react-native/assets-registry": "0.76.3",
47
47
  "@react-native-async-storage/async-storage": "2.2.0",
48
48
  "@react-native-community/netinfo": "11.4.1",
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "metro-minify-terser": "0.80.10",
89
- "webpack-dev-middleware": "6.1.2",
89
+ "webpack-dev-middleware": "7.4.6",
90
90
  "react-devtools-core": "4.28.5",
91
91
  "esbuild": "0.15.15",
92
92
  "esbuild-plugin-resolve": "1.0.3",
@@ -102,7 +102,15 @@
102
102
  "@expo/config-plugins": "54.0.1"
103
103
  },
104
104
  "overrides": {
105
- "@react-navigation/core": "7.16.1"
105
+ "babel-plugin-react-native-web": "0.21.4",
106
+ "@react-navigation/core": "7.21.2",
107
+ "postcss": "8.5.26",
108
+ "decode-uri-component": "0.5.1",
109
+ "fast-xml-parser": "4.5.7",
110
+ "axios": "1.20.0",
111
+ "@expo/mcp-tunnel": {
112
+ "zod": "4.6.7"
113
+ }
106
114
  },
107
115
  "private": true
108
116
  }
@@ -0,0 +1,331 @@
1
+ // patch-utils.js
2
+ //
3
+ // node_modules library patches shared by esbuild.script.js (legacy/expo-web-preview
4
+ // build) and metro/metro.script.js (web-preview split-bundle build) — both call
5
+ // buildLibraries() with the same set of third-party package quirks to work around.
6
+
7
+ const fs = require('fs-extra');
8
+ const WM_NPM_SCOPE = process.env.WM_NPM_SCOPE || '@wavemaker';
9
+
10
+ async function readAndReplaceFileContent(path, writeFn) {
11
+ if (!fs.existsSync(path)) {
12
+ return Promise.resolve(null);
13
+ }
14
+ const content = fs.readFileSync(path, 'utf-8');
15
+ return Promise.resolve().then(() => {
16
+ return writeFn && writeFn(content);
17
+ }).then((modifiedContent) => {
18
+ if (modifiedContent !== undefined && modifiedContent !== null) {
19
+ fs.writeFileSync(path, modifiedContent);
20
+ return modifiedContent;
21
+ }
22
+ return content;
23
+ });
24
+ }
25
+
26
+ function patchPackageLib(paths, baseDir = __dirname) {
27
+ paths.forEach((path) => {
28
+ const packageFile = `${baseDir}/node_modules/${path}/package.json`;
29
+ if (fs.existsSync(packageFile)) {
30
+ const _package = fs.readJSONSync(packageFile);
31
+ console.log('patch applied on package at.. ', packageFile);
32
+ delete _package['module'];
33
+ delete _package['type'];
34
+ fs.writeFileSync(packageFile, JSON.stringify(_package, null, 4));
35
+ }
36
+ });
37
+ }
38
+
39
+ function patchTouchableRipple(baseDir = __dirname){
40
+ const path = `${baseDir}/node_modules/react-native-paper/lib/module/core/PaperProvider.js`;
41
+ const updateProps = (content) => {
42
+ if (content.includes("const getTheme = () => {")) {
43
+ content = content.replace(`const getTheme = () => {`, `const themeValue = React.useMemo(() => {`);
44
+ content = content.replace(/\};\n.*const.*\{/g,`}, [props.theme, colorScheme, reduceMotionEnabled]);\n const {`);
45
+ content = content.replace(/\} = props;/,`\} = props;
46
+ const settingsValue = React.useMemo(() => ({
47
+ icon: MaterialCommunityIcon,
48
+ rippleEffectEnabled: true,
49
+ ...settings
50
+ }), [settings]);`);
51
+ content = content.replace(/value:\s*\{[\s\S]*?\}/g, `value: settingsValue`);
52
+ content = content.replace(/theme:\s*getTheme\(\)/g, `theme: themeValue`);
53
+ }
54
+ return content;
55
+ }
56
+ console.log('Applied TouchableRipple patch.');
57
+ return readAndReplaceFileContent(path, updateProps);
58
+ }
59
+
60
+ async function patchCamera(baseDir = __dirname) {
61
+ return readAndReplaceFileContent(`${baseDir}/node_modules/expo-camera/build/useWebQRScanner.js`, (c) => {
62
+ if (c.indexOf('@koale/useworker') > 0) {
63
+ return fs.readFileSync(`${baseDir}/esbuild/expo-camera-patch/useWebQRScanner.js`, {
64
+ encoding: 'utf-8'
65
+ })
66
+ }
67
+ return c;
68
+ });
69
+ }
70
+
71
+ async function patchReactNativeAssets(baseDir = __dirname) {
72
+ const path = `${baseDir}/node_modules/@react-native/assets-registry/`
73
+ fs.removeSync(path+'registry.js');
74
+ const registry_content = `
75
+ 'use strict';
76
+
77
+ export type PackagerAsset = {
78
+ __packager_asset: boolean,
79
+ fileSystemLocation: string,
80
+ httpServerLocation: string,
81
+ width?: number,
82
+ height?: number,
83
+ scales: Array<number>,
84
+ hash: string,
85
+ name: string,
86
+ type: string,
87
+ };
88
+
89
+ const assets: Array<PackagerAsset> = [];
90
+
91
+ export function registerAsset(asset: PackagerAsset): number {
92
+ // push returns new array length, so the first asset will
93
+ // get id 1 (not 0) to make the value truthy
94
+ return assets.push(asset);
95
+ }
96
+
97
+ export function getAssetByID(assetId: number): PackagerAsset {
98
+ return assets[assetId - 1];
99
+ }
100
+ `;
101
+ fs.writeFileSync(path+'registry.ts', registry_content);
102
+ const content = fs.readFileSync(path+'path-support.js', 'utf-8');
103
+ fs.removeSync(path+'path-support.js')
104
+ fs.writeFileSync(path+'path-support.ts', content);
105
+ await readAndReplaceFileContent(path+'path-support.ts', (content)=>{
106
+ return content.replace(`import type {PackagerAsset} from './registry.js';`,`import type {PackagerAsset} from './registry.ts';`)
107
+ .replace(` | $TEMPORARY$string<'raw'> `, '');
108
+ });
109
+ }
110
+
111
+ async function patchReactNativeWeb(baseDir = __dirname) {
112
+ const path = `${baseDir}/node_modules/react-native-web/dist/cjs/exports/render/index.js`;
113
+ await readAndReplaceFileContent(path, (content) => {
114
+ return content.replace(
115
+ 'var _reactDom = require("react-dom");',
116
+ `var React = require("react");
117
+ var _reactDom = require("react-dom");
118
+ var _reactDomClient = require("react-dom/client");`
119
+ ).replace('hydrate(element', 'hydrateOld(element')
120
+ .replace('render(element', 'renderOld(element') +
121
+ `
122
+ function hydrate(element, root, callback) {
123
+ (0, _dom.createSheet)(root);
124
+ return (0, _reactDomClient.hydrateRoot)(element, root, callback);
125
+ }
126
+
127
+ function AppWithCallbackAfterRender(props) {
128
+ React.useEffect(() => {props.callback && props.callback()});
129
+ return props.element;
130
+ }
131
+
132
+ function render(element, root, callback) {
133
+ (0, _dom.createSheet)(root);
134
+ return (0, _reactDomClient.createRoot)(root).render(
135
+ React.createElement(AppWithCallbackAfterRender,
136
+ {
137
+ "callback": callback,
138
+ element: element
139
+ }
140
+ )
141
+ );
142
+ }`;
143
+ });
144
+ const target = `${baseDir}/node_modules/react-native-web/dist/cjs/exports/BackHandler/index.js`;
145
+ await readAndReplaceFileContent(target, content => {
146
+ return content.replace('console.error', '// console.error');
147
+ });
148
+ console.log('Patched react-native-web');
149
+ }
150
+
151
+ function patchWithDevTools(path, baseDir = __dirname) {
152
+ const packageFile = `${baseDir}/node_modules/${path}`;
153
+ if (fs.existsSync(packageFile)) {
154
+ const _package = "import * as React from 'react';export function withDevTools(AppRootComponent) {return (props) => React.createElement(AppRootComponent, { ...props });}"
155
+ fs.writeFileSync(packageFile, _package);
156
+ }
157
+ }
158
+
159
+ async function patchReactNativeAssetRegistry(baseDir = __dirname) {
160
+ const content = `
161
+ /**
162
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
163
+ *
164
+ * This source code is licensed under the MIT license found in the
165
+ * LICENSE file in the root directory of this source tree.
166
+ *
167
+ * @flow strict
168
+ * @format
169
+ */
170
+
171
+ 'use strict';
172
+
173
+ const assets = [];
174
+
175
+ function registerAsset(asset) {
176
+ // push returns new array length, so the first asset will
177
+ // get id 1 (not 0) to make the value truthy
178
+ return assets.push(asset);
179
+ }
180
+
181
+ function getAssetByID(assetId) {
182
+ return assets[assetId - 1];
183
+ }
184
+
185
+ module.exports = {registerAsset, getAssetByID};
186
+
187
+ `;
188
+ fs.writeFileSync(`${baseDir}/node_modules/@react-native/assets-registry/registry.js`, content);
189
+ const expoAssetRegistry = `${baseDir}/node_modules/expo-asset/node_modules/@react-native/assets-registry/registry.js`;
190
+ readAndReplaceFileContent(expoAssetRegistry, () => content);
191
+ console.log('Patched @react-native/assets-registry');
192
+ }
193
+
194
+ async function patchBabelExpoPreset(baseDir = __dirname) {
195
+ const target = `${baseDir}/node_modules/babel-preset-expo/build/index.js`;
196
+ await readAndReplaceFileContent(target, content => {
197
+ return content.replace(
198
+ `(0, common_1.hasModule)('react-native-reanimated') &&`,
199
+ `//(0, common_1.hasModule)('react-native-reanimated') &&`)
200
+ .replace(
201
+ `platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`,
202
+ `//platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`
203
+ )
204
+ });
205
+ console.log('Patched babel-expo-preset');
206
+ }
207
+
208
+ async function patchUUID(baseDir = __dirname) {
209
+ const target = `${baseDir}/node_modules/expo-modules-core/build/uuid/uuid.web.js`;
210
+ await readAndReplaceFileContent(target, content => {
211
+ return content.replace(`require('crypto')`, 'crypto');
212
+ });
213
+ console.log('Patched UUID.');
214
+ }
215
+
216
+ async function patchExpoRootComponent(baseDir = __dirname) {
217
+ const target = `${baseDir}/node_modules/expo/build/launch/registerRootComponent.js`;
218
+ await readAndReplaceFileContent(target, content => {
219
+ return content.replace(`export default`,
220
+ `
221
+ const process = {env: {
222
+ NODE_ENV: 'development',
223
+ EXPO_PUBLIC_USE_STATIC: '0'
224
+ }};
225
+ export default `);
226
+ });
227
+ console.log('Patched Expo Root Component.');
228
+ }
229
+
230
+ async function patchReactNativeReanimated(baseDir = __dirname) {
231
+ // Check and patch PlatformChecker.js
232
+ const platformCheckerPath = `${baseDir}/node_modules/react-native-reanimated/lib/module/reanimated2/PlatformChecker.js`;
233
+ if (fs.existsSync(platformCheckerPath)) {
234
+ await readAndReplaceFileContent(platformCheckerPath, (c) => {
235
+ return c.replace(
236
+ '!!process.env.JEST_WORKER_ID',
237
+ 'false; // !!process.env.JEST_WORKER_ID'
238
+ )
239
+ });
240
+ console.log('Applied PlatformChecker.js patch.');
241
+ }
242
+
243
+ // Check and patch useSharedValue.ts
244
+ const useSharedValuePath = `${baseDir}/node_modules/react-native-reanimated/src/reanimated2/hook/useSharedValue.ts`;
245
+ if (fs.existsSync(useSharedValuePath)) {
246
+ await readAndReplaceFileContent(useSharedValuePath, (c) => {
247
+ return c.replace(
248
+ 'useRef<SharedValue<Value>>',
249
+ 'useRef'
250
+ )
251
+ });
252
+ console.log('Applied useSharedValue.ts patch.');
253
+ }
254
+
255
+ // Patch useHandler to handle web worklets
256
+ const useHandlerPath = `${baseDir}/node_modules/react-native-reanimated/lib/module/hook/useHandler.js`;
257
+ if (fs.existsSync(useHandlerPath)) {
258
+ await readAndReplaceFileContent(useHandlerPath, (c) => {
259
+ return c.replace(
260
+ `throw new ReanimatedError('Passed a function that is not a worklet. Please provide a worklet function.');`,
261
+ `// Web fallback: skip worklet validation on web
262
+ if (typeof window !== "undefined") {
263
+ continue;
264
+ }
265
+ throw new ReanimatedError('Passed a function that is not a worklet. Please provide a worklet function.');`
266
+ )
267
+ });
268
+ console.log('Applied useHandler.js web worklet patch.');
269
+ }
270
+
271
+ // Patch useAnimatedScrollHandler for web compatibility
272
+ const useAnimatedScrollHandlerPath = `${baseDir}/node_modules/react-native-reanimated/lib/module/hook/useAnimatedScrollHandler.js`;
273
+ if (fs.existsSync(useAnimatedScrollHandlerPath)) {
274
+ await readAndReplaceFileContent(useAnimatedScrollHandlerPath, (c) => {
275
+ return c.replace(
276
+ 'export function useAnimatedScrollHandler(handler, dependencies) {',
277
+ `export function useAnimatedScrollHandler(handler, dependencies) {
278
+ // Web fallback for scroll handlers
279
+ if (typeof window !== "undefined" && handler && typeof handler === "object" && handler.onScroll) {
280
+ return handler.onScroll;
281
+ }`
282
+ )
283
+ });
284
+ console.log('Applied useAnimatedScrollHandler.js web patch.');
285
+ }
286
+
287
+ // Patch worklet detection for web
288
+ const workletPath = `${baseDir}/node_modules/react-native-reanimated/lib/module/reanimated2/commonTypes.js`;
289
+ if (fs.existsSync(workletPath)) {
290
+ await readAndReplaceFileContent(workletPath, (c) => {
291
+ return c.replace(
292
+ 'export function isWorklet(fun) {',
293
+ `export function isWorklet(fun) {
294
+ // Always return true on web to bypass worklet checks
295
+ if (typeof window !== "undefined") {
296
+ return true;
297
+ }`
298
+ )
299
+ });
300
+ console.log('Applied worklet detection web patch.');
301
+ }
302
+
303
+ console.log('Patched React Native Reanimated.');
304
+ }
305
+
306
+ async function patchExpoVideo(baseDir = __dirname) {
307
+ await readAndReplaceFileContent(`${baseDir}/node_modules/expo-video/build/index.js`, (c) => {
308
+ return c.replace(
309
+ '{ VideoThumbnail }',
310
+ '{ default as VideoThumbnail }'
311
+ )
312
+ });
313
+ console.log('Patched Expo video.')
314
+ }
315
+
316
+ module.exports = {
317
+ WM_NPM_SCOPE,
318
+ readAndReplaceFileContent,
319
+ patchPackageLib,
320
+ patchTouchableRipple,
321
+ patchCamera,
322
+ patchReactNativeAssets,
323
+ patchReactNativeWeb,
324
+ patchWithDevTools,
325
+ patchReactNativeAssetRegistry,
326
+ patchBabelExpoPreset,
327
+ patchUUID,
328
+ patchExpoRootComponent,
329
+ patchReactNativeReanimated,
330
+ patchExpoVideo,
331
+ };
@@ -0,0 +1,15 @@
1
+ plugins {
2
+ id 'com.android.library'
3
+ id 'expo-module-gradle-plugin'
4
+ }
5
+
6
+ group = 'expo.modules.pulltorefresh'
7
+ version = '0.1.0'
8
+
9
+ android {
10
+ namespace "expo.modules.pulltorefresh"
11
+ defaultConfig {
12
+ versionCode 1
13
+ versionName "0.1.0"
14
+ }
15
+ }
@@ -0,0 +1,21 @@
1
+ package expo.modules.pulltorefresh
2
+
3
+ import expo.modules.kotlin.modules.Module
4
+ import expo.modules.kotlin.modules.ModuleDefinition
5
+
6
+ // Android pull-to-refresh view: hosts the scrollable content and reports drag progress to JS.
7
+ class ExpoPullToRefreshModule : Module() {
8
+ override fun definition() = ModuleDefinition {
9
+ Name("ExpoPullToRefresh")
10
+
11
+ View(ExpoPullToRefreshView::class) {
12
+ // Controlled, same contract as RN's RefreshControl.refreshing.
13
+ Prop("refreshing") { view: ExpoPullToRefreshView, refreshing: Boolean? ->
14
+ view.setRefreshingProp(refreshing ?: false)
15
+ }
16
+
17
+ // onPullProgress is 0..1+ (above 1 in the slingshot phase); JS draws the spinner from it.
18
+ Events("onPullProgress", "onRefresh")
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,221 @@
1
+ /*
2
+ * Copyright 2018 The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * Modified by WaveMaker: drag math and touch arbitration ported from AndroidX
17
+ * SwipeRefreshLayout to Kotlin, hosting one React child and reporting progress.
18
+ */
19
+ package expo.modules.pulltorefresh
20
+
21
+ import android.content.Context
22
+ import android.view.MotionEvent
23
+ import android.view.View
24
+ import android.view.ViewConfiguration
25
+ import expo.modules.kotlin.AppContext
26
+ import expo.modules.kotlin.viewevent.EventDispatcher
27
+ import expo.modules.kotlin.views.ExpoView
28
+ import kotlin.math.abs
29
+ import kotlin.math.max
30
+ import kotlin.math.min
31
+ import kotlin.math.pow
32
+
33
+ class ExpoPullToRefreshView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
34
+
35
+ companion object {
36
+ private const val INVALID_POINTER = -1
37
+ private const val DRAG_RATE = .5f
38
+ // Matches SwipeRefreshLayout.DEFAULT_CIRCLE_TARGET.
39
+ private const val DEFAULT_CIRCLE_TARGET_DP = 64f
40
+ }
41
+
42
+ private val onPullProgress by EventDispatcher()
43
+ private val onRefresh by EventDispatcher()
44
+
45
+ // The single React child: the wrapper around the scrollable content.
46
+ private var contentView: View? = null
47
+
48
+ private val touchSlop = ViewConfiguration.get(context).scaledTouchSlop
49
+ private val totalDragDistance = dpToPx(DEFAULT_CIRCLE_TARGET_DP)
50
+ private val spinnerOffsetEnd = totalDragDistance
51
+ private var customSlingshotDistance = 0f
52
+
53
+ private var initialMotionY = 0f
54
+ private var initialDownY = 0f
55
+ private var isBeingDragged = false
56
+ private var activePointerId = INVALID_POINTER
57
+ private var refreshing = false
58
+
59
+ override fun addView(child: View, index: Int, params: android.view.ViewGroup.LayoutParams?) {
60
+ super.addView(child, index, params)
61
+ if (contentView == null) {
62
+ contentView = child
63
+ }
64
+ }
65
+
66
+ // Controlled `refreshing` prop, same contract as RN's RefreshControl.
67
+ fun setRefreshingProp(refreshing: Boolean) {
68
+ if (this.refreshing == refreshing) return
69
+ this.refreshing = refreshing
70
+ if (!refreshing) {
71
+ emitProgress(0f)
72
+ }
73
+ }
74
+
75
+ // The real scrollable inside the wrapper (the wrapper itself never scrolls).
76
+ private var scrollableChild: View? = null
77
+
78
+ private fun findScrollable(view: View?): View? {
79
+ if (view == null) return null
80
+ if (view is android.widget.ScrollView ||
81
+ view is android.widget.HorizontalScrollView ||
82
+ view is androidx.core.widget.NestedScrollView ||
83
+ view.javaClass.name.contains("ReactScrollView")
84
+ ) {
85
+ return view
86
+ }
87
+ if (view is android.view.ViewGroup) {
88
+ for (i in 0 until view.childCount) {
89
+ val found = findScrollable(view.getChildAt(i))
90
+ if (found != null) return found
91
+ }
92
+ }
93
+ return null
94
+ }
95
+
96
+ private fun canChildScrollUp(): Boolean {
97
+ if (scrollableChild == null) {
98
+ scrollableChild = findScrollable(contentView)
99
+ }
100
+ return scrollableChild?.canScrollVertically(-1) ?: false
101
+ }
102
+
103
+ // ---- Touch arbitration --------------------------------------------------
104
+ override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
105
+ if (!isEnabled || canChildScrollUp() || refreshing) {
106
+ isBeingDragged = false
107
+ return false
108
+ }
109
+ when (ev.actionMasked) {
110
+ MotionEvent.ACTION_DOWN -> {
111
+ activePointerId = ev.getPointerId(0)
112
+ isBeingDragged = false
113
+ val pointerIndex = ev.findPointerIndex(activePointerId)
114
+ if (pointerIndex < 0) return false
115
+ initialDownY = ev.getY(pointerIndex)
116
+ }
117
+ MotionEvent.ACTION_MOVE -> {
118
+ if (activePointerId == INVALID_POINTER) return false
119
+ val pointerIndex = ev.findPointerIndex(activePointerId)
120
+ if (pointerIndex < 0) return false
121
+ startDragging(ev.getY(pointerIndex))
122
+ }
123
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
124
+ isBeingDragged = false
125
+ activePointerId = INVALID_POINTER
126
+ }
127
+ }
128
+ return isBeingDragged
129
+ }
130
+
131
+ override fun onTouchEvent(ev: MotionEvent): Boolean {
132
+ if (!isEnabled || canChildScrollUp() || refreshing) {
133
+ return false
134
+ }
135
+ when (ev.actionMasked) {
136
+ MotionEvent.ACTION_DOWN -> {
137
+ activePointerId = ev.getPointerId(0)
138
+ isBeingDragged = false
139
+ }
140
+ MotionEvent.ACTION_MOVE -> {
141
+ val pointerIndex = ev.findPointerIndex(activePointerId)
142
+ if (pointerIndex < 0) return false
143
+ val y = ev.getY(pointerIndex)
144
+ startDragging(y)
145
+ if (isBeingDragged) {
146
+ val overscrollTop = (y - initialMotionY) * DRAG_RATE
147
+ if (overscrollTop > 0) {
148
+ // Stop the child ScrollView reclaiming the gesture mid-drag.
149
+ parent?.requestDisallowInterceptTouchEvent(true)
150
+ moveSpinner(overscrollTop)
151
+ } else {
152
+ return false
153
+ }
154
+ }
155
+ }
156
+ MotionEvent.ACTION_UP -> {
157
+ val pointerIndex = ev.findPointerIndex(activePointerId)
158
+ if (pointerIndex < 0) return false
159
+ if (isBeingDragged) {
160
+ val y = ev.getY(pointerIndex)
161
+ val overscrollTop = (y - initialMotionY) * DRAG_RATE
162
+ isBeingDragged = false
163
+ finishSpinner(overscrollTop)
164
+ }
165
+ activePointerId = INVALID_POINTER
166
+ return false
167
+ }
168
+ MotionEvent.ACTION_CANCEL -> {
169
+ isBeingDragged = false
170
+ emitProgress(0f)
171
+ return false
172
+ }
173
+ }
174
+ return true
175
+ }
176
+
177
+ private fun startDragging(y: Float) {
178
+ val yDiff = y - initialDownY
179
+ if (yDiff > touchSlop && !isBeingDragged) {
180
+ initialMotionY = initialDownY + touchSlop
181
+ isBeingDragged = true
182
+ }
183
+ }
184
+
185
+ override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
186
+ if (isBeingDragged) return
187
+ super.requestDisallowInterceptTouchEvent(disallowIntercept)
188
+ }
189
+
190
+ // Ported moveSpinner/finishSpinner math; reports progress to JS instead of moving views.
191
+ private fun moveSpinner(overscrollTop: Float) {
192
+ val originalDragPercent = overscrollTop / totalDragDistance
193
+ val dragPercent = min(1f, abs(originalDragPercent))
194
+ val extraOS = abs(overscrollTop) - totalDragDistance
195
+ val slingshotDist = if (customSlingshotDistance > 0) customSlingshotDistance else spinnerOffsetEnd
196
+ val tensionSlingshotPercent = max(0f, min(extraOS, slingshotDist * 2) / slingshotDist)
197
+ val tensionPercent = ((tensionSlingshotPercent / 4) - (tensionSlingshotPercent / 4).toDouble().pow(2.0).toFloat()) * 2f
198
+
199
+ // Same composition as moveSpinner's targetY math, normalised to 0..1+.
200
+ val extraMove = tensionPercent * 2
201
+ val progress = dragPercent + extraMove
202
+ emitProgress(progress)
203
+ }
204
+
205
+ private fun finishSpinner(overscrollTop: Float) {
206
+ if (overscrollTop > totalDragDistance) {
207
+ refreshing = true
208
+ emitProgress(1f)
209
+ onRefresh(emptyMap<String, Any>())
210
+ } else {
211
+ // Released below the threshold: retract.
212
+ emitProgress(0f)
213
+ }
214
+ }
215
+
216
+ private fun emitProgress(progress: Float) {
217
+ onPullProgress(mapOf("progress" to progress))
218
+ }
219
+
220
+ private fun dpToPx(dp: Float): Float = dp * resources.displayMetrics.density
221
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "platforms": [
3
+ "apple",
4
+ "android"
5
+ ],
6
+ "apple": {
7
+ "modules": [
8
+ "ExpoPullToRefreshControlModule"
9
+ ]
10
+ },
11
+ "android": {
12
+ "modules": [
13
+ "expo.modules.pulltorefresh.ExpoPullToRefreshModule"
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ExpoPullToRefresh'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.author = package['author']
11
+ s.homepage = 'https://www.wavemaker.com'
12
+ s.platforms = { :ios => '15.1' }
13
+ s.swift_version = '5.9'
14
+ s.source = { git: '' }
15
+ s.static_framework = true
16
+
17
+ s.dependency 'ExpoModulesCore'
18
+
19
+ s.pod_target_xcconfig = {
20
+ 'DEFINES_MODULE' => 'YES'
21
+ }
22
+
23
+ s.source_files = '**/*.swift'
24
+ end