react-nitro-hermes 0.0.1-alpha.8 → 0.0.1-alpha.9

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 (181) hide show
  1. package/hermes/CMakeLists.txt +874 -0
  2. package/hermes/android/HostObjectJniTest.cpp +178 -0
  3. package/hermes/android/build-logic/build.gradle.kts +31 -0
  4. package/hermes/android/build-logic/settings.gradle.kts +17 -0
  5. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
  6. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
  7. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
  8. package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
  9. package/hermes/android/build.gradle.kts +332 -0
  10. package/hermes/android/cppruntime/build.gradle +72 -0
  11. package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
  12. package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
  13. package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
  14. package/hermes/android/cross-compile/swift-libicu.patch +13 -0
  15. package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
  16. package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
  17. package/hermes/android/gradle/libs.versions.toml +30 -0
  18. package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  19. package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  20. package/hermes/android/gradle.properties +3 -0
  21. package/hermes/android/gradlew +248 -0
  22. package/hermes/android/gradlew.bat +93 -0
  23. package/hermes/android/intltest/build.gradle +147 -0
  24. package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
  25. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
  26. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
  27. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
  28. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
  29. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
  30. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
  31. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
  32. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
  33. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
  34. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
  35. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
  36. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
  37. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
  38. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
  39. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
  40. package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
  41. package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
  42. package/hermes/android/settings.gradle.kts +27 -0
  43. package/hermes/cmake/modules/Hermes.cmake +481 -0
  44. package/hermes/cmake/modules/Lit.cmake +96 -0
  45. package/hermes/doc/Branches.md +38 -0
  46. package/hermes/doc/BuildingAndRunning.md +121 -0
  47. package/hermes/doc/CodingStandards.md +112 -0
  48. package/hermes/doc/CrossCompilation.md +79 -0
  49. package/hermes/doc/Design.md +217 -0
  50. package/hermes/doc/Emscripten.md +156 -0
  51. package/hermes/doc/Features.md +143 -0
  52. package/hermes/doc/GCSafeCoding.md +563 -0
  53. package/hermes/doc/GenGC.md +300 -0
  54. package/hermes/doc/Hades.md +344 -0
  55. package/hermes/doc/HighLevelOptimizations.md +37 -0
  56. package/hermes/doc/IR.md +1306 -0
  57. package/hermes/doc/IntlAPIs.md +196 -0
  58. package/hermes/doc/JIT.md +999 -0
  59. package/hermes/doc/LazyEvalCompilation.md +84 -0
  60. package/hermes/doc/MemoryProfilers.md +316 -0
  61. package/hermes/doc/Modules.md +144 -0
  62. package/hermes/doc/Optimizer.md +83 -0
  63. package/hermes/doc/PerfProfiling.md +29 -0
  64. package/hermes/doc/ProhibitInvoke.md +329 -0
  65. package/hermes/doc/ReactNative.md +40 -0
  66. package/hermes/doc/ReactNativeIntegration.md +94 -0
  67. package/hermes/doc/RegExp.md +24 -0
  68. package/hermes/doc/SpecIncompat.md +85 -0
  69. package/hermes/doc/Strings.md +140 -0
  70. package/hermes/doc/TypedLanguage.md +432 -0
  71. package/hermes/doc/VM.md +174 -0
  72. package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
  73. package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
  74. package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
  75. package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
  76. package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
  77. package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
  78. package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
  79. package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
  80. package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
  81. package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
  82. package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
  83. package/hermes/doc/blog/README.md +25 -0
  84. package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
  85. package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
  86. package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
  87. package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
  88. package/hermes/doc/icu_license.txt +420 -0
  89. package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
  90. package/hermes/doc/img/logo.svg +1 -0
  91. package/hermes/doc/img/object_captured_by_environment.png +0 -0
  92. package/hermes/doc/img/root_categories.png +0 -0
  93. package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
  94. package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
  95. package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
  96. package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
  97. package/hermes/doc/plans/ir-type/memory.md +48 -0
  98. package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
  99. package/hermes/doc/plans/ir-type/progress.md +239 -0
  100. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
  101. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
  102. package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
  103. package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
  104. package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
  105. package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
  106. package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
  107. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
  108. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
  109. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
  110. package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
  111. package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
  112. package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
  113. package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
  114. package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
  115. package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
  116. package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
  117. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
  118. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
  119. package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
  120. package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
  121. package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
  122. package/hermes/doc/typescript-stripping.md +90 -0
  123. package/hermes/external/CMakeLists.txt +20 -0
  124. package/hermes/utils/IntlGen/IntlGen.java +531 -0
  125. package/hermes/utils/bench_with_stats.py +827 -0
  126. package/hermes/utils/build-apple-framework.sh +323 -0
  127. package/hermes/utils/chrome_snapshot_parser.py +210 -0
  128. package/hermes/utils/cmake-dev-build.sh +18 -0
  129. package/hermes/utils/commons.sh +55 -0
  130. package/hermes/utils/dump-cpp-funcs.sh +3 -0
  131. package/hermes/utils/es5objects.js +198 -0
  132. package/hermes/utils/format.sh +145 -0
  133. package/hermes/utils/gen-promise-internal-bc.sh +66 -0
  134. package/hermes/utils/genUnicodeTable.py +2503 -0
  135. package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
  136. package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
  137. package/hermes/utils/jit/README.md +134 -0
  138. package/hermes/utils/jit/jit-diff.sh +160 -0
  139. package/hermes/utils/jit/jit-dump.sh +193 -0
  140. package/hermes/utils/lit-expect-gen/generate.py +217 -0
  141. package/hermes/utils/promise/index.js +15 -0
  142. package/hermes/utils/promise/package.json +13 -0
  143. package/hermes/utils/promise/rollup.config.js +19 -0
  144. package/hermes/utils/promise/yarn.lock +247 -0
  145. package/hermes/utils/scripts/hermes/consts.js +26 -0
  146. package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
  147. package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
  148. package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
  149. package/hermes/utils/scripts/hermes/package.json +6 -0
  150. package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
  151. package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
  152. package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
  153. package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
  154. package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
  155. package/hermes/utils/scripts/hermes/version-utils.js +98 -0
  156. package/hermes/utils/scripts/hermes/yarn.lock +240 -0
  157. package/hermes/utils/summarize_sizes.py +184 -0
  158. package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
  159. package/hermes/utils/test_runner.py +13 -0
  160. package/hermes/utils/testsuite/README.facebook +3 -0
  161. package/hermes/utils/testsuite/README.md +69 -0
  162. package/hermes/utils/testsuite/cli.py +547 -0
  163. package/hermes/utils/testsuite/es_ast.py +337 -0
  164. package/hermes/utils/testsuite/external/LICENSE +28 -0
  165. package/hermes/utils/testsuite/external/README.facebook +8 -0
  166. package/hermes/utils/testsuite/external/__init__.py +0 -0
  167. package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
  168. package/hermes/utils/testsuite/external/parse_test262.py +141 -0
  169. package/hermes/utils/testsuite/hermes.py +522 -0
  170. package/hermes/utils/testsuite/preprocess.py +365 -0
  171. package/hermes/utils/testsuite/progress.py +377 -0
  172. package/hermes/utils/testsuite/skiplist.json +4356 -0
  173. package/hermes/utils/testsuite/skiplist.py +270 -0
  174. package/hermes/utils/testsuite/test_run_defs.py +435 -0
  175. package/hermes/utils/testsuite/typing_defs.py +52 -0
  176. package/hermes/utils/testsuite/utils.py +214 -0
  177. package/hermes/utils/tidy.sh +22 -0
  178. package/hermes/utils/update-fbcode-hermes.sh +53 -0
  179. package/hermes/utils/updateErrorTest.py +193 -0
  180. package/hermes/utils/wasm-compile.sh +65 -0
  181. package/package.json +1 -1
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ var verbose = false;
9
+ var indirectEval = eval;
10
+ var global = indirectEval("this");
11
+
12
+ if (typeof print === "undefined")
13
+ var print = console.log;
14
+
15
+ function check(objStr, propStr, type) {
16
+ var x = objStr + "." + propStr;
17
+ var obj = indirectEval(objStr);
18
+ if (typeof obj === "undefined")
19
+ print("Missing", objStr);
20
+ else if (!obj.hasOwnProperty(propStr))
21
+ print("Missing", x);
22
+ else if (typeof obj[propStr] !== type)
23
+ print("Wrong type of", x);
24
+ else if (verbose)
25
+ print("OK", x);
26
+ }
27
+
28
+ check("global", "NaN", "number");
29
+ check("global", "Infinity", "number");
30
+ check("global", "undefined", "undefined");
31
+ check("global", "eval", "function");
32
+ check("global", "parseInt", "function");
33
+ check("global", "parseFloat", "function");
34
+ check("global", "isNaN", "function");
35
+ check("global", "isFinite", "function");
36
+ check("global", "decodeURI", "function");
37
+ check("global", "decodeURIComponent", "function");
38
+ check("global", "encodeURI", "function");
39
+ check("global", "encodeURIComponent", "function");
40
+ check("global", "Object", "function");
41
+ check("global", "Function", "function");
42
+ check("global", "Array", "function");
43
+ check("global", "String", "function");
44
+ check("global", "Boolean", "function");
45
+ check("global", "Number", "function");
46
+ check("global", "Date", "function");
47
+ check("global", "RegExp", "function");
48
+ check("global", "Error", "function");
49
+ check("global", "EvalError", "function");
50
+ check("global", "TypeError", "function");
51
+ check("global", "URIError", "function");
52
+ check("global", "Math", "object");
53
+ check("global", "JSON", "object");
54
+ check("global", "escape", "function");
55
+ check("global", "unescape", "function");
56
+
57
+ // Object
58
+ check("global.Object", "getPrototypeOf", "function");
59
+ check("global.Object", "getOwnPropertyDescriptor", "function");
60
+ check("global.Object", "getOwnPropertyNames", "function");
61
+ check("global.Object", "create", "function");
62
+ check("global.Object", "defineProperty", "function");
63
+ check("global.Object", "defineProperties", "function");
64
+ check("global.Object", "seal", "function");
65
+ check("global.Object", "freeze", "function");
66
+ check("global.Object", "preventExtensions", "function");
67
+ check("global.Object", "isSealed", "function");
68
+ check("global.Object", "isFrozen", "function");
69
+ check("global.Object", "isExtensible", "function");
70
+ check("global.Object", "keys", "function");
71
+ check("global.Object", "prototype", "object");
72
+ check("global.Object.prototype", "constructor", "function");
73
+ check("global.Object.prototype", "toString", "function");
74
+ check("global.Object.prototype", "toLocaleString", "function");
75
+ check("global.Object.prototype", "valueOf", "function");
76
+ check("global.Object.prototype", "hasOwnProperty", "function");
77
+ check("global.Object.prototype", "isPrototypeOf", "function");
78
+ check("global.Object.prototype", "propertyIsEnumerable", "function");
79
+
80
+ // Function.
81
+ check("global", "Function", "function");
82
+ check("global.Function", "length", "number");
83
+ check("global.Function", "prototype", "function");
84
+ check("global.Function.prototype", "constructor", "function");
85
+ check("global.Function.prototype", "toString", "function");
86
+ check("global.Function.prototype", "apply", "function");
87
+ check("global.Function.prototype", "call", "function");
88
+ check("global.Function.prototype", "bind", "function");
89
+ global.testFunc = function() {}
90
+ check("global.testFunc", "length", "number");
91
+ check("global.testFunc", "prototype", "object");
92
+
93
+ // Array.
94
+ check("global", "Array", "function");
95
+ check("global.Array", "prototype", "object");
96
+ check("global.Array", "isArray", "function");
97
+ check("global.Array.prototype", "constructor", "function");
98
+ check("global.Array.prototype", "toString", "function");
99
+ check("global.Array.prototype", "toLocaleString", "function");
100
+ check("global.Array.prototype", "concat", "function");
101
+ check("global.Array.prototype", "join", "function");
102
+ check("global.Array.prototype", "pop", "function");
103
+ check("global.Array.prototype", "push", "function");
104
+ check("global.Array.prototype", "reverse", "function");
105
+ check("global.Array.prototype", "shift", "function");
106
+ check("global.Array.prototype", "slice", "function");
107
+ check("global.Array.prototype", "sort", "function");
108
+ check("global.Array.prototype", "splice", "function");
109
+ check("global.Array.prototype", "unshift", "function");
110
+ check("global.Array.prototype", "indexOf", "function");
111
+ check("global.Array.prototype", "lastIndexOf", "function");
112
+ check("global.Array.prototype", "every", "function");
113
+ check("global.Array.prototype", "some", "function");
114
+ check("global.Array.prototype", "forEach", "function");
115
+ check("global.Array.prototype", "map", "function");
116
+ check("global.Array.prototype", "filter", "function");
117
+ check("global.Array.prototype", "reduce", "function");
118
+ check("global.Array.prototype", "reduceRight", "function");
119
+ global.testArray = [];
120
+ check("global.testArray", "length", "number");
121
+
122
+ // String.
123
+ check("global", "String", "function");
124
+ check("global.String", "length", "number");
125
+ check("global.String", "prototype", "object");
126
+ check("global.String", "fromCharCode", "function");
127
+ check("global.String.prototype", "constructor", "function");
128
+ check("global.String.prototype", "toString", "function");
129
+ check("global.String.prototype", "valueOf", "function");
130
+ check("global.String.prototype", "charAt", "function");
131
+ check("global.String.prototype", "charCodeAt", "function");
132
+ check("global.String.prototype", "concat", "function");
133
+ check("global.String.prototype", "indexOf", "function");
134
+ check("global.String.prototype", "lastIndexOf", "function");
135
+ check("global.String.prototype", "localeCompare", "function");
136
+ check("global.String.prototype", "match", "function");
137
+ check("global.String.prototype", "replace", "function");
138
+ check("global.String.prototype", "search", "function");
139
+ check("global.String.prototype", "slice", "function");
140
+ check("global.String.prototype", "split", "function");
141
+ check("global.String.prototype", "substring", "function");
142
+ check("global.String.prototype", "toLowerCase", "function");
143
+ check("global.String.prototype", "toLocaleLowerCase", "function");
144
+ check("global.String.prototype", "toUpperCase", "function");
145
+ check("global.String.prototype", "toLocaleUpperCase", "function");
146
+ check("global.String.prototype", "trim", "function");
147
+ check("global.String.prototype", "substr", "function");
148
+
149
+ // Date.
150
+ check("global", "Date", "function");
151
+ check("global.Date", "length", "number");
152
+ check("global.Date", "prototype", "object");
153
+ check("global.Date", "parse", "function");
154
+ check("global.Date", "UTC", "function");
155
+ check("global.Date", "now", "function");
156
+ check("global.Date.prototype", "toString", "function");
157
+ check("global.Date.prototype", "toDateString", "function");
158
+ check("global.Date.prototype", "toTimeString", "function");
159
+ check("global.Date.prototype", "toLocaleString", "function");
160
+ check("global.Date.prototype", "toLocaleDateString", "function");
161
+ check("global.Date.prototype", "toLocaleTimeString", "function");
162
+ check("global.Date.prototype", "valueOf", "function");
163
+ check("global.Date.prototype", "getTime", "function");
164
+ check("global.Date.prototype", "getFullYear", "function");
165
+ check("global.Date.prototype", "getMonth", "function");
166
+ check("global.Date.prototype", "getDate", "function");
167
+ check("global.Date.prototype", "getDay", "function");
168
+ check("global.Date.prototype", "getHours", "function");
169
+ check("global.Date.prototype", "getMinutes", "function");
170
+ check("global.Date.prototype", "getSeconds", "function");
171
+ check("global.Date.prototype", "getMilliseconds", "function");
172
+ check("global.Date.prototype", "getUTCFullYear", "function");
173
+ check("global.Date.prototype", "getUTCMonth", "function");
174
+ check("global.Date.prototype", "getUTCDate", "function");
175
+ check("global.Date.prototype", "getUTCDay", "function");
176
+ check("global.Date.prototype", "getUTCHours", "function");
177
+ check("global.Date.prototype", "getUTCMinutes", "function");
178
+ check("global.Date.prototype", "getUTCSeconds", "function");
179
+ check("global.Date.prototype", "getUTCMilliseconds", "function");
180
+ check("global.Date.prototype", "getTimezoneOffset", "function");
181
+ check("global.Date.prototype", "setTime", "function");
182
+ check("global.Date.prototype", "setFullYear", "function");
183
+ check("global.Date.prototype", "setMonth", "function");
184
+ check("global.Date.prototype", "setDate", "function");
185
+ check("global.Date.prototype", "setHours", "function");
186
+ check("global.Date.prototype", "setMinutes", "function");
187
+ check("global.Date.prototype", "setSeconds", "function");
188
+ check("global.Date.prototype", "setMilliseconds", "function");
189
+ check("global.Date.prototype", "setUTCFullYear", "function");
190
+ check("global.Date.prototype", "setUTCMonth", "function");
191
+ check("global.Date.prototype", "setUTCDate", "function");
192
+ check("global.Date.prototype", "setUTCHours", "function");
193
+ check("global.Date.prototype", "setUTCMinutes", "function");
194
+ check("global.Date.prototype", "setUTCSeconds", "function");
195
+ check("global.Date.prototype", "setUTCMilliseconds", "function");
196
+ check("global.Date.prototype", "toUTCString", "function");
197
+ check("global.Date.prototype", "toISOString", "function");
198
+ check("global.Date.prototype", "toJSON", "function");
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ #
4
+ # This source code is licensed under the MIT license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ IFS=$'\n'
8
+ set -f
9
+
10
+ all=0
11
+ force=0
12
+ interactive=0
13
+ if [ "$1" == "-a" ]; then
14
+ shift
15
+ all=1
16
+ elif [ "$1" == "-f" ]; then
17
+ shift
18
+ force=1
19
+ elif [ "$1" == "-i" ]; then
20
+ shift
21
+ interactive=1
22
+ fi
23
+
24
+ [ -n "$1" ] && {
25
+ echo "Usage: $0 [-a|-f|-i]" >&2
26
+ echo " -a: Format all files" >&2
27
+ echo " -f: Force format files in last commit without prompting" >&2
28
+ echo " -i: Interactive mode, show diff and ask before applying changes" >&2
29
+ exit 1
30
+ }
31
+
32
+ # Look for clang-format at a fixed path relative to the script.
33
+ script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
34
+ clang_format_path="${script_path}/../../../tools/third-party/clang-format"
35
+ if [ "$(uname)" == Linux ]; then
36
+ clang_format="${clang_format_path}/linux/x86_64/clang-format"
37
+ else
38
+ clang_format="${clang_format_path}/macos/clang-format"
39
+ fi
40
+
41
+ # Fall back to one in $PATH if not found.
42
+ [ -x "${clang_format}" ] || clang_format="$(which clang-format)"
43
+
44
+ if [ ! -x "$clang_format" ]; then
45
+ echo "ERROR: Must have clang-format in PATH"
46
+ exit 1
47
+ fi
48
+
49
+ # Determine which diff command to use
50
+ if [ -t 1 ] && diff --color=always /dev/null /dev/null >/dev/null 2>&1; then
51
+ # Terminal supports color and GNU diff with color is available
52
+ diff_cmd=(diff --color=always -u)
53
+ elif which colordiff >/dev/null 2>&1; then
54
+ # Use colordiff as alternative
55
+ diff_cmd=(colordiff -u)
56
+ else
57
+ # Fallback to plain diff
58
+ diff_cmd=(diff -u)
59
+ fi
60
+
61
+ THIS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
62
+ cd "$THIS_DIR"/../ || exit 1
63
+
64
+ have_changes=0 # We have uncommitted changes
65
+ authored_previous=0 # We authored the most recent commit on this branch
66
+
67
+ if [[ $(git status --porcelain 2>/dev/null) ]]; then
68
+ have_changes=1
69
+ fi
70
+
71
+ if git log -1 --pretty=format:"%an <%ae>" | grep -q -e "<$USER@" -e "^$USER" -e "<$USER>" -e "$USER@"
72
+ then
73
+ authored_previous=1
74
+ fi
75
+
76
+ files=()
77
+
78
+ if (( all )); then
79
+ echo "Formatting all files..."
80
+ files=(
81
+ $(find lib include tools unittests \
82
+ -name \*.h -print -o -name \*.cpp -print)
83
+ )
84
+ elif (( have_changes )); then
85
+ echo "Formatting only modified files..."
86
+ files=( $(git diff --name-only --diff-filter=ACMR | grep -E '\.(h|cpp|inc|def|mm|m)$') )
87
+
88
+ elif (( authored_previous )) || (( force )); then
89
+ last_commit_files=( $(git diff-tree --no-commit-id --name-only -r HEAD | grep -E '\.(h|cpp|inc|def|mm|m)$') )
90
+ echo "There are no modified files, but you authored the last commit:"
91
+ printf ' %s\n' "${last_commit_files[@]}"
92
+ if (( !force )); then
93
+ read -r -p "Format files in that commit? [y/N]" reply
94
+ if [[ $reply != [Yy] ]]; then
95
+ echo "Not doing anything."
96
+ exit 0
97
+ fi
98
+ fi
99
+ files=( "${last_commit_files[@]}" )
100
+ else
101
+ echo "You have no modified files and you didn't recently commit on this branch."
102
+ echo "To format all files: $0 -a"
103
+ exit 1
104
+ fi
105
+
106
+ for f in "${files[@]}"; do
107
+ if [ ! -f "$f" ]; then
108
+ echo "File not found: $f (skipping)"
109
+ continue
110
+ fi
111
+
112
+ # Create a temporary file for the formatted content
113
+ temp_file=$(mktemp)
114
+ "$clang_format" -style=file "$f" > "$temp_file"
115
+
116
+ # Check if the file would be modified
117
+ if ! diff -q "$f" "$temp_file" >/dev/null 2>&1; then
118
+ echo "File would be reformatted: $f"
119
+
120
+ # Always show the differences with color
121
+ "${diff_cmd[@]}" "$f" "$temp_file" | sed "s|$temp_file|$f (formatted)|"
122
+
123
+ if (( interactive )); then
124
+ # Ask user whether to apply changes
125
+ read -r -p "Apply these changes? [y/N] " reply
126
+ if [[ $reply == [Yy] ]]; then
127
+ cp "$temp_file" "$f"
128
+ echo "Changes applied to $f"
129
+ else
130
+ echo "Changes not applied to $f"
131
+ fi
132
+ else
133
+ # Apply changes without asking
134
+ cp "$temp_file" "$f"
135
+ echo "Reformatted: $f"
136
+ fi
137
+ else
138
+ echo "No changes needed for $f"
139
+ fi
140
+
141
+ # Clean up the temporary file
142
+ rm -f "$temp_file"
143
+ done
144
+
145
+ echo "Done"
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env sh
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ #
4
+ # This source code is licensed under the MIT license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ # This script generated the `lib/InternalBytecode/Promise.js` by performing the
8
+ # below steps:
9
+ #
10
+ # 0. It copies the `util/promise/` to a tmp dir to run `yarn` and `rollup`. The
11
+ # tmp dir is always wiped away on Bash's trap exit so we can keep our source
12
+ # tree clean regardless of whether the script was success or not.
13
+ #
14
+ # 1. The Rollup is configured to build the `util/promise/index.js`, which
15
+ # imports the `promise` polyfill that we installed with `yarn`, exposes it to
16
+ # Hermes's globalThis, and then setup Hermes promise rejection tracking.
17
+ #
18
+ # 2. It adds `@nolint` to the start of the file and append a snippet to
19
+ # initialize Promise.
20
+ #
21
+ # 3. Finally, it moved the resulted file to the `InternalBytecode`.
22
+
23
+
24
+ if [ "$1" != "--force" ]; then
25
+ echo "ERROR: This script is deprecated." >&2
26
+ echo "The upstream 'promise' npm package (v8.3.0) is no longer maintained." >&2
27
+ echo "Make changes directly in lib/InternalJavaScript/01-Promise.js instead." >&2
28
+ echo "To force execution anyway, pass --force." >&2
29
+ exit 1
30
+ fi
31
+
32
+ SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33
+
34
+ BC_DIR="${SCRIPT}/../lib/InternalJavaScript"
35
+ TMP_DIR=$(mktemp -d)
36
+ PROMISE_DIR="${SCRIPT}/promise"
37
+ TMP_PROMISE_DIR="${TMP_DIR}/promise"
38
+
39
+ TMP_PROMISE_JS="${TMP_PROMISE_DIR}/Promise.js"
40
+ BC_PROMISE_JS="${BC_DIR}/01-Promise.js"
41
+
42
+ NOLINT="/* @nolint */"
43
+ PATCH1=" var useEngineQueue = HermesInternal.useEngineQueue()\;"
44
+ PATCH2='(useEngineQueue ? HermesInternal.enqueueJob : setImmediate)'
45
+
46
+ gen() {
47
+ # It's tricky to ensure `sed -i` work on both GNU and macOS consistently.
48
+ # https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
49
+ sed -i.bak "1s;^;${NOLINT};" $TMP_PROMISE_JS && \
50
+ sed -i.bak "3s;^;${PATCH1};" $TMP_PROMISE_JS && \
51
+ sed -i.bak "s/setImmediate/${PATCH2}/g" $TMP_PROMISE_JS && \
52
+ sed -i.bak '$ d' $TMP_PROMISE_JS && \
53
+ cat <<EOT >> $TMP_PROMISE_JS
54
+ });
55
+ initPromise();
56
+ EOT
57
+ }
58
+
59
+ cleanup() {
60
+ rm -rf $TMP_DIR
61
+ }
62
+
63
+ trap cleanup EXIT
64
+ cp -r $PROMISE_DIR $TMP_DIR
65
+ cd $TMP_PROMISE_DIR
66
+ yarn && yarn start && gen && mv $TMP_PROMISE_JS $BC_PROMISE_JS