@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
@@ -0,0 +1,195 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+
7
+ /** Memory ceiling for this container in MB, falling back to host total. */
8
+ function containerMemoryLimitMB() {
9
+ for (const f of ['/sys/fs/cgroup/memory.max', '/sys/fs/cgroup/memory/memory.limit_in_bytes']) {
10
+ try {
11
+ const raw = fs.readFileSync(f, 'utf-8').trim();
12
+ if (raw && raw !== 'max') {
13
+ const mb = Math.floor(parseInt(raw, 10) / (1024 * 1024));
14
+ // cgroup v1 reports a near-2^63 sentinel when unlimited — ignore absurd values.
15
+ if (mb > 0 && mb < 1024 * 1024) {
16
+ return mb;
17
+ }
18
+ }
19
+ } catch {
20
+ // fall through to the next source
21
+ }
22
+ }
23
+ return Math.floor(os.totalmem() / (1024 * 1024));
24
+ }
25
+
26
+ /** Reclaimable page cache (inactive_file) in bytes, from cgroup v2 or v1 memory.stat; 0 if unreadable. */
27
+ function inactiveFileBytes() {
28
+ for (const [f, key] of [['/sys/fs/cgroup/memory.stat', 'inactive_file'],
29
+ ['/sys/fs/cgroup/memory/memory.stat', 'total_inactive_file']]) {
30
+ try {
31
+ const m = new RegExp(`^${key} (\\d+)$`, 'm').exec(fs.readFileSync(f, 'utf-8'));
32
+ if (m) {
33
+ return parseInt(m[1], 10);
34
+ }
35
+ } catch {
36
+ // fall through to the next source
37
+ }
38
+ }
39
+ return 0;
40
+ }
41
+
42
+ /**
43
+ * Current WORKING SET in MB (usage minus reclaimable page cache), or null when unreadable.
44
+ * Raw memory.current includes page cache: right after npm install and the vendor-store copy it
45
+ * sits near the cap while real process memory is ~130MB, and a gate reading it blocks forever,
46
+ * because the only process that would free the cache is the one waiting. The kernel reclaims
47
+ * inactive_file before OOM-killing, so the working set is what actually competes for the cap.
48
+ * NOTE the `> 0` guard: without it a blank/garbage read yields NaN, and every
49
+ * downstream `NaN <= budget` comparison is false. This was a real drift bug.
50
+ */
51
+ function containerMemoryUsedMB() {
52
+ for (const f of ['/sys/fs/cgroup/memory.current', '/sys/fs/cgroup/memory/memory.usage_in_bytes']) {
53
+ try {
54
+ const bytes = parseInt(fs.readFileSync(f, 'utf-8').trim(), 10);
55
+ if (bytes > 0) {
56
+ return Math.floor(Math.max(0, bytes - inactiveFileBytes()) / (1024 * 1024));
57
+ }
58
+ } catch {
59
+ // fall through to the next source
60
+ }
61
+ }
62
+ return null;
63
+ }
64
+
65
+ /**
66
+ * How many times the kernel has OOM-killed a process in this container's cgroup, or null when
67
+ * unreadable. Container-wide: a rise means SOME process here was killed, not necessarily ours.
68
+ */
69
+ function oomKillCount() {
70
+ for (const f of ['/sys/fs/cgroup/memory.events', '/sys/fs/cgroup/memory/memory.oom_control']) {
71
+ try {
72
+ const m = /^oom_kill (\d+)$/m.exec(fs.readFileSync(f, 'utf-8'));
73
+ if (m) {
74
+ return parseInt(m[1], 10);
75
+ }
76
+ } catch {
77
+ // fall through to the next source
78
+ }
79
+ }
80
+ return null;
81
+ }
82
+
83
+ /**
84
+ * Walk up from `start` while staying on the same filesystem device, and return the
85
+ * highest directory still on it. Used to find the volume root that a project and the
86
+ * shared vendor store have in common — which is also the boundary across which
87
+ * hardlinks stop working.
88
+ */
89
+ function findDeviceRoot(start) {
90
+ const resolvedStart = path.resolve(start);
91
+ let current = resolvedStart;
92
+ let best = current;
93
+ let startDev;
94
+ try {
95
+ startDev = fs.statSync(current).dev;
96
+ } catch {
97
+ return resolvedStart;
98
+ }
99
+ for (let depth = 0; depth < 12; depth++) {
100
+ const parent = path.dirname(current);
101
+ if (parent === current) {
102
+ break;
103
+ }
104
+ let parentDev;
105
+ try {
106
+ parentDev = fs.statSync(parent).dev;
107
+ } catch {
108
+ break;
109
+ }
110
+ if (parentDev !== startDev) {
111
+ break;
112
+ }
113
+ current = parent;
114
+ best = current;
115
+ }
116
+ // Reached the filesystem root (`/`, `C:\`) — not writable for a normal user. Fall back, in order, to
117
+ // the wm-reactnative-cli root (same expression as the CLI's global.rootDir), the home dir, then the
118
+ // start dir itself; each only if on the same filesystem, since the vendor store is hardlinked into
119
+ // projects. Mirrors findDeviceRoot() in shared-node-modules.ts.
120
+ if (best === path.parse(best).root) {
121
+ const candidates = [
122
+ process.env.WM_REACTNATIVE_CLI || path.join(os.homedir(), '.wm-reactnative-cli'),
123
+ os.homedir(),
124
+ ];
125
+ for (const dir of candidates) {
126
+ try {
127
+ if (fs.statSync(dir).dev === startDev) {
128
+ return dir;
129
+ }
130
+ } catch {
131
+ // missing — try the next one
132
+ }
133
+ }
134
+ return resolvedStart;
135
+ }
136
+ return best;
137
+ }
138
+
139
+ /**
140
+ * Block until the container drops below `safetyFraction` of its memory limit, or the
141
+ * deadline passes. Used to stop concurrent builds/installs from OOM-ing each other.
142
+ *
143
+ * Proceeds rather than throwing on timeout: a slow preview beats a failed one.
144
+ */
145
+ async function waitForHeadroom({
146
+ waitMs = 30 * 60 * 1000,
147
+ pollMs = 5000,
148
+ safetyFraction,
149
+ label = 'build',
150
+ } = {}) {
151
+ const fraction = (() => {
152
+ if (safetyFraction > 0 && safetyFraction <= 1) {
153
+ return safetyFraction;
154
+ }
155
+ const v = parseFloat(process.env.WM_BUILD_ADMISSION_SAFETY_FRACTION);
156
+ return v > 0 && v <= 1 ? v : 0.85;
157
+ })();
158
+ const deadline = Date.now() + waitMs;
159
+ const budgetMB = Math.floor(containerMemoryLimitMB() * fraction);
160
+ let announced = false;
161
+
162
+ for (;;) {
163
+ const usedMB = containerMemoryUsedMB();
164
+ if (usedMB === null) {
165
+ console.warn(`[${label}-admission] container memory unreadable — skipping the check.`);
166
+ return;
167
+ }
168
+ if (usedMB <= budgetMB) {
169
+ if (announced) {
170
+ console.log(`[${label}-admission] proceeding (${usedMB}MB used, budget ${budgetMB}MB)`);
171
+ }
172
+ return;
173
+ }
174
+ if (Date.now() >= deadline) {
175
+ console.warn(`[${label}-admission] still at ${usedMB}MB (budget ${budgetMB}MB) after `
176
+ + `${Math.round(waitMs / 60000)} minute(s) — proceeding anyway rather than failing.`);
177
+ return;
178
+ }
179
+ if (!announced) {
180
+ // Reports what was measured only: the code cannot know whether another build is running.
181
+ console.log(`[${label}-admission] working set ${usedMB}MB exceeds the ${budgetMB}MB budget `
182
+ + `(cap ${containerMemoryLimitMB()}MB) — waiting for memory to free up.`);
183
+ announced = true;
184
+ }
185
+ await new Promise((r) => setTimeout(r, pollMs));
186
+ }
187
+ }
188
+
189
+ module.exports = {
190
+ containerMemoryLimitMB,
191
+ containerMemoryUsedMB,
192
+ findDeviceRoot,
193
+ oomKillCount,
194
+ waitForHeadroom,
195
+ };