react-nitro-yoga 0.0.0-stage → 0.0.1-alpha.7

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 (529) hide show
  1. package/Generated/.gitattributes +1 -0
  2. package/Generated/api.d.ts +100 -0
  3. package/Generated/ffigen_yoga_adapters.h +52 -0
  4. package/Generated/native.d.ts +84 -0
  5. package/Generated/native.ts +283 -0
  6. package/Generated/yoga.c +1087 -0
  7. package/LICENSE +21 -0
  8. package/Package.swift +57 -0
  9. package/README.md +61 -2
  10. package/Sources/ReactNitroYoga/InstallHermesBindings.cpp +11 -0
  11. package/Sources/ReactNitroYoga/SHUnit.h +16 -0
  12. package/include/ReactNitroYoga/InstallHermesBindings.hpp +12 -0
  13. package/package.json +26 -4
  14. package/yoga/.clang-format +109 -0
  15. package/yoga/.clang-tidy +217 -0
  16. package/yoga/.editorconfig +11 -0
  17. package/yoga/.eslintrc.cjs +84 -0
  18. package/yoga/.github/ISSUE_TEMPLATE.md +21 -0
  19. package/yoga/.github/actions/black/action.yml +25 -0
  20. package/yoga/.github/actions/cache-emsdk/action.yml +10 -0
  21. package/yoga/.github/actions/install-ninja/action.yml +14 -0
  22. package/yoga/.github/actions/setup-android/action.yml +12 -0
  23. package/yoga/.github/actions/setup-apple/action.yml +8 -0
  24. package/yoga/.github/actions/setup-cpp/action.yml +34 -0
  25. package/yoga/.github/actions/setup-js/action.yml +18 -0
  26. package/yoga/.github/workflows/publish-android-release.yml +38 -0
  27. package/yoga/.github/workflows/publish-android-snashot.yml +36 -0
  28. package/yoga/.github/workflows/publish-npm-release.yml +25 -0
  29. package/yoga/.github/workflows/validate-android.yml +30 -0
  30. package/yoga/.github/workflows/validate-cpp.yml +101 -0
  31. package/yoga/.github/workflows/validate-format.yml +36 -0
  32. package/yoga/.github/workflows/validate-js.yml +119 -0
  33. package/yoga/.github/workflows/validate-swiftpm.yml +29 -0
  34. package/yoga/.github/workflows/validate-tests.yml +35 -0
  35. package/yoga/.github/workflows/validate-website.yml +45 -0
  36. package/yoga/.prettierignore +3 -0
  37. package/yoga/.prettierrc.js +16 -0
  38. package/yoga/.vscode/extensions.json +7 -0
  39. package/yoga/.vscode/launch.json +25 -0
  40. package/yoga/.vscode/settings.json +20 -0
  41. package/yoga/.vscode/tasks.json +23 -0
  42. package/yoga/CMakeLists.txt +58 -0
  43. package/yoga/CODE_OF_CONDUCT.md +76 -0
  44. package/yoga/CONTRIBUTING.md +44 -0
  45. package/yoga/LICENSE +21 -0
  46. package/yoga/LICENSE-examples +9 -0
  47. package/yoga/Package.swift +32 -0
  48. package/yoga/README.md +36 -0
  49. package/yoga/benchmark/Benchmark.cpp +400 -0
  50. package/yoga/benchmark/Benchmark.h +39 -0
  51. package/yoga/benchmark/CMakeLists.txt +27 -0
  52. package/yoga/benchmark/TreeDeserialization.cpp +248 -0
  53. package/yoga/benchmark/TreeDeserialization.h +52 -0
  54. package/yoga/benchmark/YGBenchmark.c +183 -0
  55. package/yoga/benchmark/benchmark +15 -0
  56. package/yoga/benchmark/captures/chat-mac.json +24426 -0
  57. package/yoga/benchmark/captures/feed-android.json +10335 -0
  58. package/yoga/benchmark/captures/profile-ios.json +1955 -0
  59. package/yoga/benchmark/captures/rendering-sample-mac.json +1927 -0
  60. package/yoga/build.gradle +46 -0
  61. package/yoga/build_fuzz_tests +28 -0
  62. package/yoga/capture/CMakeLists.txt +23 -0
  63. package/yoga/capture/CaptureTree.cpp +100 -0
  64. package/yoga/capture/CaptureTree.h +47 -0
  65. package/yoga/capture/NodeToString.cpp +359 -0
  66. package/yoga/capture/NodeToString.h +40 -0
  67. package/yoga/cmake/project-defaults.cmake +50 -0
  68. package/yoga/cmake/yoga-config.cmake.in +10 -0
  69. package/yoga/enums.py +394 -0
  70. package/yoga/fuzz/CMakeLists.txt +21 -0
  71. package/yoga/fuzz/FuzzLayout.cpp +57 -0
  72. package/yoga/gentest/babel.config.cjs +12 -0
  73. package/yoga/gentest/fixtures/YGAbsolutePositionTest.html +168 -0
  74. package/yoga/gentest/fixtures/YGAlignContentTest.html +479 -0
  75. package/yoga/gentest/fixtures/YGAlignItemsTest.html +227 -0
  76. package/yoga/gentest/fixtures/YGAlignSelfTest.html +23 -0
  77. package/yoga/gentest/fixtures/YGAndroidNewsFeed.html +28 -0
  78. package/yoga/gentest/fixtures/YGAspectRatioTest.html +3 -0
  79. package/yoga/gentest/fixtures/YGAutoTest.html +25 -0
  80. package/yoga/gentest/fixtures/YGBorderTest.html +18 -0
  81. package/yoga/gentest/fixtures/YGBoxSizingTest.html +240 -0
  82. package/yoga/gentest/fixtures/YGDimensionTest.html +9 -0
  83. package/yoga/gentest/fixtures/YGDisplayTest.html +89 -0
  84. package/yoga/gentest/fixtures/YGFlexBasisFitContentTest.html +55 -0
  85. package/yoga/gentest/fixtures/YGFlexDirectionTest.html +391 -0
  86. package/yoga/gentest/fixtures/YGFlexTest.html +53 -0
  87. package/yoga/gentest/fixtures/YGFlexWrapTest.html +160 -0
  88. package/yoga/gentest/fixtures/YGGapTest.html +233 -0
  89. package/yoga/gentest/fixtures/YGIntrinsicSizeTest.html +295 -0
  90. package/yoga/gentest/fixtures/YGJustifyContentTest.html +164 -0
  91. package/yoga/gentest/fixtures/YGMarginTest.html +157 -0
  92. package/yoga/gentest/fixtures/YGMinMaxDimensionTest.html +116 -0
  93. package/yoga/gentest/fixtures/YGPaddingTest.html +29 -0
  94. package/yoga/gentest/fixtures/YGPercentageTest.html +125 -0
  95. package/yoga/gentest/fixtures/YGRoundingTest.html +95 -0
  96. package/yoga/gentest/fixtures/YGSizeOverflowTest.html +17 -0
  97. package/yoga/gentest/fixtures/YGStaticPositionTest.html +712 -0
  98. package/yoga/gentest/fonts/Ahem.ttf +0 -0
  99. package/yoga/gentest/gentest-driver.ts +141 -0
  100. package/yoga/gentest/gentest-validate.ts +43 -0
  101. package/yoga/gentest/package.json +24 -0
  102. package/yoga/gentest/scripts/gentest-validate.ts +43 -0
  103. package/yoga/gentest/signedsource.d.ts +10 -0
  104. package/yoga/gentest/src/ChromePool.ts +78 -0
  105. package/yoga/gentest/src/CssToYoga.ts +958 -0
  106. package/yoga/gentest/src/buildLayoutTree.ts +98 -0
  107. package/yoga/gentest/src/cli.ts +163 -0
  108. package/yoga/gentest/src/emitters/CppEmitter.ts +452 -0
  109. package/yoga/gentest/src/emitters/Emitter.ts +204 -0
  110. package/yoga/gentest/src/emitters/JavaEmitter.ts +469 -0
  111. package/yoga/gentest/src/emitters/JavascriptEmitter.ts +353 -0
  112. package/yoga/gentest/src/types.ts +41 -0
  113. package/yoga/gentest/test-template.html +42 -0
  114. package/yoga/gentest/tsconfig.json +13 -0
  115. package/yoga/gradle/wrapper/gradle-wrapper.jar +0 -0
  116. package/yoga/gradle/wrapper/gradle-wrapper.properties +7 -0
  117. package/yoga/gradle.properties +14 -0
  118. package/yoga/gradlew +251 -0
  119. package/yoga/gradlew.bat +94 -0
  120. package/yoga/java/AndroidManifest.xml +14 -0
  121. package/yoga/java/CMakeLists.txt +22 -0
  122. package/yoga/java/build.gradle.kts +127 -0
  123. package/yoga/java/com/facebook/yoga/LayoutPassReason.kt +35 -0
  124. package/yoga/java/com/facebook/yoga/YogaAlign.kt +45 -0
  125. package/yoga/java/com/facebook/yoga/YogaBaselineFunction.kt +16 -0
  126. package/yoga/java/com/facebook/yoga/YogaBoxSizing.kt +27 -0
  127. package/yoga/java/com/facebook/yoga/YogaConfig.kt +48 -0
  128. package/yoga/java/com/facebook/yoga/YogaConfigFactory.kt +12 -0
  129. package/yoga/java/com/facebook/yoga/YogaConfigJNIBase.kt +70 -0
  130. package/yoga/java/com/facebook/yoga/YogaConfigJNIFinalizer.kt +30 -0
  131. package/yoga/java/com/facebook/yoga/YogaConstants.kt +18 -0
  132. package/yoga/java/com/facebook/yoga/YogaDimension.kt +27 -0
  133. package/yoga/java/com/facebook/yoga/YogaDirection.kt +29 -0
  134. package/yoga/java/com/facebook/yoga/YogaDisplay.kt +31 -0
  135. package/yoga/java/com/facebook/yoga/YogaEdge.kt +41 -0
  136. package/yoga/java/com/facebook/yoga/YogaErrata.kt +39 -0
  137. package/yoga/java/com/facebook/yoga/YogaExperimentalFeature.kt +27 -0
  138. package/yoga/java/com/facebook/yoga/YogaFlexDirection.kt +31 -0
  139. package/yoga/java/com/facebook/yoga/YogaGridTrackType.kt +33 -0
  140. package/yoga/java/com/facebook/yoga/YogaGutter.kt +29 -0
  141. package/yoga/java/com/facebook/yoga/YogaJustify.kt +43 -0
  142. package/yoga/java/com/facebook/yoga/YogaLayoutType.kt +27 -0
  143. package/yoga/java/com/facebook/yoga/YogaLogLevel.kt +39 -0
  144. package/yoga/java/com/facebook/yoga/YogaLogger.kt +19 -0
  145. package/yoga/java/com/facebook/yoga/YogaMeasureFunction.kt +19 -0
  146. package/yoga/java/com/facebook/yoga/YogaMeasureMode.kt +29 -0
  147. package/yoga/java/com/facebook/yoga/YogaMeasureOutput.kt +29 -0
  148. package/yoga/java/com/facebook/yoga/YogaNative.kt +347 -0
  149. package/yoga/java/com/facebook/yoga/YogaNode.kt +254 -0
  150. package/yoga/java/com/facebook/yoga/YogaNodeFactory.kt +14 -0
  151. package/yoga/java/com/facebook/yoga/YogaNodeJNIBase.kt +762 -0
  152. package/yoga/java/com/facebook/yoga/YogaNodeJNIFinalizer.kt +33 -0
  153. package/yoga/java/com/facebook/yoga/YogaNodeType.kt +27 -0
  154. package/yoga/java/com/facebook/yoga/YogaOverflow.kt +29 -0
  155. package/yoga/java/com/facebook/yoga/YogaPositionType.kt +29 -0
  156. package/yoga/java/com/facebook/yoga/YogaProps.kt +205 -0
  157. package/yoga/java/com/facebook/yoga/YogaStyleInputs.kt +51 -0
  158. package/yoga/java/com/facebook/yoga/YogaUnit.kt +37 -0
  159. package/yoga/java/com/facebook/yoga/YogaValue.kt +66 -0
  160. package/yoga/java/com/facebook/yoga/YogaWrap.kt +29 -0
  161. package/yoga/java/com/facebook/yoga/annotations/DoNotStrip.kt +19 -0
  162. package/yoga/java/gen/com/facebook/yoga/BuildConfig.java +15 -0
  163. package/yoga/java/jni/LayoutContext.cpp +34 -0
  164. package/yoga/java/jni/LayoutContext.h +29 -0
  165. package/yoga/java/jni/ScopedGlobalRef.h +140 -0
  166. package/yoga/java/jni/ScopedLocalRef.h +141 -0
  167. package/yoga/java/jni/YGJNI.h +77 -0
  168. package/yoga/java/jni/YGJNIVanilla.cpp +1178 -0
  169. package/yoga/java/jni/YGJNIVanilla.h +12 -0
  170. package/yoga/java/jni/YGJTypesVanilla.h +52 -0
  171. package/yoga/java/jni/YogaJniException.cpp +49 -0
  172. package/yoga/java/jni/YogaJniException.h +35 -0
  173. package/yoga/java/jni/common.cpp +109 -0
  174. package/yoga/java/jni/common.h +73 -0
  175. package/yoga/java/jni/corefunctions.cpp +91 -0
  176. package/yoga/java/jni/corefunctions.h +50 -0
  177. package/yoga/java/jni/macros.h +23 -0
  178. package/yoga/java/jni/tests/corefunctionsTest.cpp +247 -0
  179. package/yoga/java/jni/yogajni.cpp +18 -0
  180. package/yoga/java/proguard-rules.pro +10 -0
  181. package/yoga/java/res/values/strings.xml +12 -0
  182. package/yoga/java/tests/com/facebook/yoga/TestParametrization.kt +29 -0
  183. package/yoga/java/tests/com/facebook/yoga/YGAlignBaselineTest.kt +117 -0
  184. package/yoga/java/tests/com/facebook/yoga/YogaExceptionTest.kt +140 -0
  185. package/yoga/java/tests/com/facebook/yoga/YogaLoggerTest.kt +77 -0
  186. package/yoga/java/tests/com/facebook/yoga/YogaNodeStylePropertiesTest.kt +1020 -0
  187. package/yoga/java/tests/com/facebook/yoga/YogaNodeTest.kt +319 -0
  188. package/yoga/java/tests/com/facebook/yoga/YogaValueTest.kt +23 -0
  189. package/yoga/java/tests/com/facebook/yoga/utils/TestUtils.kt +99 -0
  190. package/yoga/java/tests/generated/com/facebook/yoga/YGAbsolutePositionTest.java +1670 -0
  191. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignContentTest.java +5440 -0
  192. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignItemsTest.java +2132 -0
  193. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignSelfTest.java +271 -0
  194. package/yoga/java/tests/generated/com/facebook/yoga/YGAndroidNewsFeed.java +313 -0
  195. package/yoga/java/tests/generated/com/facebook/yoga/YGAspectRatioTest.java +73 -0
  196. package/yoga/java/tests/generated/com/facebook/yoga/YGAutoTest.java +326 -0
  197. package/yoga/java/tests/generated/com/facebook/yoga/YGBorderTest.java +222 -0
  198. package/yoga/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java +2165 -0
  199. package/yoga/java/tests/generated/com/facebook/yoga/YGDimensionTest.java +122 -0
  200. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayContentsTest.java +107 -0
  201. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayTest.java +1021 -0
  202. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexBasisFitContentTest.java +391 -0
  203. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexDirectionTest.java +4118 -0
  204. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexTest.java +630 -0
  205. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexWrapTest.java +1863 -0
  206. package/yoga/java/tests/generated/com/facebook/yoga/YGGapTest.java +2988 -0
  207. package/yoga/java/tests/generated/com/facebook/yoga/YGIntrinsicSizeTest.java +926 -0
  208. package/yoga/java/tests/generated/com/facebook/yoga/YGJustifyContentTest.java +1865 -0
  209. package/yoga/java/tests/generated/com/facebook/yoga/YGMarginTest.java +1796 -0
  210. package/yoga/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java +1210 -0
  211. package/yoga/java/tests/generated/com/facebook/yoga/YGPaddingTest.java +307 -0
  212. package/yoga/java/tests/generated/com/facebook/yoga/YGPercentageTest.java +1345 -0
  213. package/yoga/java/tests/generated/com/facebook/yoga/YGRoundingTest.java +1099 -0
  214. package/yoga/java/tests/generated/com/facebook/yoga/YGSizeOverflowTest.java +195 -0
  215. package/yoga/java/tests/generated/com/facebook/yoga/YGStaticPositionTest.java +5992 -0
  216. package/yoga/java/yogajni.version +13 -0
  217. package/yoga/javascript/CMakeLists.txt +59 -0
  218. package/yoga/javascript/README.md +27 -0
  219. package/yoga/javascript/babel.config.cjs +30 -0
  220. package/yoga/javascript/jest.config.js +14 -0
  221. package/yoga/javascript/jest.setup.js +12 -0
  222. package/yoga/javascript/just.config.cjs +258 -0
  223. package/yoga/javascript/package.json +52 -0
  224. package/yoga/javascript/src/generated/YGEnums.ts +249 -0
  225. package/yoga/javascript/src/index.ts +23 -0
  226. package/yoga/javascript/src/load.ts +25 -0
  227. package/yoga/javascript/src/wasm_bridge.c +155 -0
  228. package/yoga/javascript/src/wrapAssembly.ts +1025 -0
  229. package/yoga/javascript/tests/Benchmarks/YGBenchmark.test.ts +110 -0
  230. package/yoga/javascript/tests/YGAlignBaselineTest.test.ts +104 -0
  231. package/yoga/javascript/tests/YGComputedBorderTest.test.ts +25 -0
  232. package/yoga/javascript/tests/YGComputedMarginTest.test.ts +25 -0
  233. package/yoga/javascript/tests/YGComputedPaddingTest.test.ts +25 -0
  234. package/yoga/javascript/tests/YGDirtiedTest.test.ts +149 -0
  235. package/yoga/javascript/tests/YGErrataTest.test.ts +34 -0
  236. package/yoga/javascript/tests/YGFlexBasisAuto.test.ts +21 -0
  237. package/yoga/javascript/tests/YGHadOverflowTest.test.ts +110 -0
  238. package/yoga/javascript/tests/YGHasNewLayout.test.ts +81 -0
  239. package/yoga/javascript/tests/YGMeasureCacheTest.test.ts +29 -0
  240. package/yoga/javascript/tests/YGMeasureTest.test.ts +66 -0
  241. package/yoga/javascript/tests/bin/run-bench.ts +60 -0
  242. package/yoga/javascript/tests/generated/YGAbsolutePositionTest.test.ts +1531 -0
  243. package/yoga/javascript/tests/generated/YGAlignContentTest.test.ts +5181 -0
  244. package/yoga/javascript/tests/generated/YGAlignItemsTest.test.ts +2013 -0
  245. package/yoga/javascript/tests/generated/YGAlignSelfTest.test.ts +248 -0
  246. package/yoga/javascript/tests/generated/YGAndroidNewsFeed.test.ts +306 -0
  247. package/yoga/javascript/tests/generated/YGAspectRatioTest.test.ts +66 -0
  248. package/yoga/javascript/tests/generated/YGAutoTest.test.ts +303 -0
  249. package/yoga/javascript/tests/generated/YGBorderTest.test.ts +199 -0
  250. package/yoga/javascript/tests/generated/YGBoxSizingTest.test.ts +1978 -0
  251. package/yoga/javascript/tests/generated/YGDimensionTest.test.ts +111 -0
  252. package/yoga/javascript/tests/generated/YGDisplayContentsTest.test.ts +99 -0
  253. package/yoga/javascript/tests/generated/YGDisplayTest.test.ts +962 -0
  254. package/yoga/javascript/tests/generated/YGFlexBasisFitContentTest.test.ts +364 -0
  255. package/yoga/javascript/tests/generated/YGFlexDirectionTest.test.ts +3903 -0
  256. package/yoga/javascript/tests/generated/YGFlexTest.test.ts +587 -0
  257. package/yoga/javascript/tests/generated/YGFlexWrapTest.test.ts +1768 -0
  258. package/yoga/javascript/tests/generated/YGGapTest.test.ts +2857 -0
  259. package/yoga/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +843 -0
  260. package/yoga/javascript/tests/generated/YGJustifyContentTest.test.ts +1750 -0
  261. package/yoga/javascript/tests/generated/YGMarginTest.test.ts +1657 -0
  262. package/yoga/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +1111 -0
  263. package/yoga/javascript/tests/generated/YGPaddingTest.test.ts +276 -0
  264. package/yoga/javascript/tests/generated/YGPercentageTest.test.ts +1246 -0
  265. package/yoga/javascript/tests/generated/YGRoundingTest.test.ts +1044 -0
  266. package/yoga/javascript/tests/generated/YGSizeOverflowTest.test.ts +180 -0
  267. package/yoga/javascript/tests/generated/YGStaticPositionTest.test.ts +5741 -0
  268. package/yoga/javascript/tests/tools/MeasureCounter.ts +66 -0
  269. package/yoga/javascript/tests/tools/globals.ts +19 -0
  270. package/yoga/javascript/tests/tools/utils.ts +90 -0
  271. package/yoga/javascript/tsconfig.json +23 -0
  272. package/yoga/lib/jni/jni.h +13 -0
  273. package/yoga/lib/jni/real/jni.h +1141 -0
  274. package/yoga/lib/jsr-305/jsr305.jar +0 -0
  275. package/yoga/lib/nlohmann/json.hpp +24766 -0
  276. package/yoga/lib/soloader/soloader-0.5.1.aar +0 -0
  277. package/yoga/package.json +44 -0
  278. package/yoga/scripts/clang-format +52 -0
  279. package/yoga/scripts/clang-format.js +93 -0
  280. package/yoga/scripts/format-kotlin.js +88 -0
  281. package/yoga/scripts/format-python.js +150 -0
  282. package/yoga/scripts/format-utils.js +82 -0
  283. package/yoga/set-version.py +37 -0
  284. package/yoga/settings.gradle.kts +29 -0
  285. package/yoga/test/AssertFatalTest.cpp +70 -0
  286. package/yoga/tests/.clang-tidy +7 -0
  287. package/yoga/tests/CMakeLists.txt +35 -0
  288. package/yoga/tests/CacheTest.cpp +229 -0
  289. package/yoga/tests/EventPublisherTest.cpp +162 -0
  290. package/yoga/tests/EventsTest.cpp +362 -0
  291. package/yoga/tests/FlexGapTest.cpp +93 -0
  292. package/yoga/tests/FloatOptionalTest.cpp +214 -0
  293. package/yoga/tests/GridStyleTest.cpp +103 -0
  294. package/yoga/tests/OrdinalsTest.cpp +35 -0
  295. package/yoga/tests/SmallValueBufferTest.cpp +161 -0
  296. package/yoga/tests/StyleTest.cpp +48 -0
  297. package/yoga/tests/StyleValuePoolTest.cpp +146 -0
  298. package/yoga/tests/YGAlignBaselineTest.cpp +837 -0
  299. package/yoga/tests/YGAspectRatioTest.cpp +898 -0
  300. package/yoga/tests/YGAutoMinSizeTest.cpp +581 -0
  301. package/yoga/tests/YGBaselineFuncTest.cpp +62 -0
  302. package/yoga/tests/YGCloneNodeTest.cpp +131 -0
  303. package/yoga/tests/YGComputedMarginTest.cpp +117 -0
  304. package/yoga/tests/YGComputedPaddingTest.cpp +119 -0
  305. package/yoga/tests/YGConfigTest.cpp +239 -0
  306. package/yoga/tests/YGContentsNodeHasNewLayoutTest.cpp +190 -0
  307. package/yoga/tests/YGDefaultValuesTest.cpp +175 -0
  308. package/yoga/tests/YGDirtiedTest.cpp +110 -0
  309. package/yoga/tests/YGDirtyMarkingTest.cpp +341 -0
  310. package/yoga/tests/YGEdgeTest.cpp +161 -0
  311. package/yoga/tests/YGFirstChildMinWidthTest.cpp +133 -0
  312. package/yoga/tests/YGFlexBasisFitContentTest.cpp +241 -0
  313. package/yoga/tests/YGFlexShrinkBorderBugTest.cpp +48 -0
  314. package/yoga/tests/YGHadOverflowTest.cpp +135 -0
  315. package/yoga/tests/YGLayoutableChildrenTest.cpp +191 -0
  316. package/yoga/tests/YGMeasureCacheTest.cpp +178 -0
  317. package/yoga/tests/YGMeasureModeTest.cpp +332 -0
  318. package/yoga/tests/YGMeasureTest.cpp +1010 -0
  319. package/yoga/tests/YGNodeCallbackTest.cpp +80 -0
  320. package/yoga/tests/YGNodeChildTest.cpp +68 -0
  321. package/yoga/tests/YGPersistenceTest.cpp +291 -0
  322. package/yoga/tests/YGPersistentNodeCloningTest.cpp +214 -0
  323. package/yoga/tests/YGRelayoutTest.cpp +255 -0
  324. package/yoga/tests/YGRoundingFunctionTest.cpp +186 -0
  325. package/yoga/tests/YGRoundingMeasureFuncTest.cpp +139 -0
  326. package/yoga/tests/YGScaleChangeTest.cpp +176 -0
  327. package/yoga/tests/YGStyleTest.cpp +75 -0
  328. package/yoga/tests/YGTreeMutationTest.cpp +115 -0
  329. package/yoga/tests/YGValueTest.cpp +23 -0
  330. package/yoga/tests/YGZeroOutLayoutRecursivelyTest.cpp +37 -0
  331. package/yoga/tests/generated/YGAbsolutePositionTest.cpp +1685 -0
  332. package/yoga/tests/generated/YGAlignContentTest.cpp +5485 -0
  333. package/yoga/tests/generated/YGAlignItemsTest.cpp +2142 -0
  334. package/yoga/tests/generated/YGAlignSelfTest.cpp +257 -0
  335. package/yoga/tests/generated/YGAndroidNewsFeed.cpp +295 -0
  336. package/yoga/tests/generated/YGAspectRatioTest.cpp +55 -0
  337. package/yoga/tests/generated/YGAutoTest.cpp +312 -0
  338. package/yoga/tests/generated/YGBorderTest.cpp +208 -0
  339. package/yoga/tests/generated/YGBoxSizingTest.cpp +2192 -0
  340. package/yoga/tests/generated/YGDimensionTest.cpp +105 -0
  341. package/yoga/tests/generated/YGDisplayContentsTest.cpp +89 -0
  342. package/yoga/tests/generated/YGDisplayTest.cpp +1016 -0
  343. package/yoga/tests/generated/YGFlexBasisFitContentTest.cpp +378 -0
  344. package/yoga/tests/generated/YGFlexDirectionTest.cpp +4152 -0
  345. package/yoga/tests/generated/YGFlexTest.cpp +621 -0
  346. package/yoga/tests/generated/YGFlexWrapTest.cpp +1867 -0
  347. package/yoga/tests/generated/YGGapTest.cpp +3001 -0
  348. package/yoga/tests/generated/YGIntrinsicSizeTest.cpp +924 -0
  349. package/yoga/tests/generated/YGJustifyContentTest.cpp +1874 -0
  350. package/yoga/tests/generated/YGMarginTest.cpp +1811 -0
  351. package/yoga/tests/generated/YGMinMaxDimensionTest.cpp +1215 -0
  352. package/yoga/tests/generated/YGPaddingTest.cpp +295 -0
  353. package/yoga/tests/generated/YGPercentageTest.cpp +1350 -0
  354. package/yoga/tests/generated/YGRoundingTest.cpp +1093 -0
  355. package/yoga/tests/generated/YGSizeOverflowTest.cpp +179 -0
  356. package/yoga/tests/generated/YGStaticPositionTest.cpp +6035 -0
  357. package/yoga/tests/util/TestUtil.cpp +164 -0
  358. package/yoga/tests/util/TestUtil.h +43 -0
  359. package/yoga/unit_tests +25 -0
  360. package/yoga/unit_tests.bat +28 -0
  361. package/yoga/website/.eslintrc.cjs +26 -0
  362. package/yoga/website/README.md +41 -0
  363. package/yoga/website/babel.config.cjs +10 -0
  364. package/yoga/website/blog/2023-06-30-announcing-yoga-2.0.md +183 -0
  365. package/yoga/website/blog/2024-06-24-announcing-yoga-3.1.md +67 -0
  366. package/yoga/website/blog/2024-12-02-announcing-yoga-3.2.md +84 -0
  367. package/yoga/website/blog/authors.yml +10 -0
  368. package/yoga/website/blog/yoga-3-release/2024-03-14-announcing-yoga-3.0.md +586 -0
  369. package/yoga/website/blog/yoga-3-release/img/image1.png +0 -0
  370. package/yoga/website/blog/yoga-3-release/img/image10.png +0 -0
  371. package/yoga/website/blog/yoga-3-release/img/image11.png +0 -0
  372. package/yoga/website/blog/yoga-3-release/img/image12.png +0 -0
  373. package/yoga/website/blog/yoga-3-release/img/image13.png +0 -0
  374. package/yoga/website/blog/yoga-3-release/img/image14.png +0 -0
  375. package/yoga/website/blog/yoga-3-release/img/image15.png +0 -0
  376. package/yoga/website/blog/yoga-3-release/img/image16.png +0 -0
  377. package/yoga/website/blog/yoga-3-release/img/image17.png +0 -0
  378. package/yoga/website/blog/yoga-3-release/img/image2.png +0 -0
  379. package/yoga/website/blog/yoga-3-release/img/image3.png +0 -0
  380. package/yoga/website/blog/yoga-3-release/img/image4.png +0 -0
  381. package/yoga/website/blog/yoga-3-release/img/image5.png +0 -0
  382. package/yoga/website/blog/yoga-3-release/img/image6.png +0 -0
  383. package/yoga/website/blog/yoga-3-release/img/image7.png +0 -0
  384. package/yoga/website/blog/yoga-3-release/img/image8.png +0 -0
  385. package/yoga/website/blog/yoga-3-release/img/image9.png +0 -0
  386. package/yoga/website/docs/about-yoga.md +13 -0
  387. package/yoga/website/docs/advanced/_category_.json +4 -0
  388. package/yoga/website/docs/advanced/containing-block.md +89 -0
  389. package/yoga/website/docs/advanced/external-layout-systems.mdx +106 -0
  390. package/yoga/website/docs/advanced/incremental-layout.mdx +87 -0
  391. package/yoga/website/docs/getting-started/_category_.json +4 -0
  392. package/yoga/website/docs/getting-started/configuring-yoga.mdx +165 -0
  393. package/yoga/website/docs/getting-started/laying-out-a-tree.mdx +178 -0
  394. package/yoga/website/docs/img/config-contextual.svg +17 -0
  395. package/yoga/website/docs/img/config-per-node.svg +17 -0
  396. package/yoga/website/docs/img/config-uniform.svg +17 -0
  397. package/yoga/website/docs/img/invalidation-clean-tree.svg +17 -0
  398. package/yoga/website/docs/img/invalidation-dirtied-tree.svg +17 -0
  399. package/yoga/website/docs/img/invalidation-new-layout-tree.svg +17 -0
  400. package/yoga/website/docs/img/pixel-grid-after.png +0 -0
  401. package/yoga/website/docs/img/pixel-grid-before.png +0 -0
  402. package/yoga/website/docs/img/wireframe-example.svg +105 -0
  403. package/yoga/website/docs/styling/_category_.json +4 -0
  404. package/yoga/website/docs/styling/align-content.mdx +47 -0
  405. package/yoga/website/docs/styling/align-items-self.mdx +48 -0
  406. package/yoga/website/docs/styling/aspect-ratio.mdx +27 -0
  407. package/yoga/website/docs/styling/display.mdx +25 -0
  408. package/yoga/website/docs/styling/flex-basis-grow-shrink.mdx +65 -0
  409. package/yoga/website/docs/styling/flex-direction.mdx +37 -0
  410. package/yoga/website/docs/styling/flex-wrap.mdx +33 -0
  411. package/yoga/website/docs/styling/gap.mdx +49 -0
  412. package/yoga/website/docs/styling/index.md +48 -0
  413. package/yoga/website/docs/styling/insets.mdx +62 -0
  414. package/yoga/website/docs/styling/justify-content.mdx +43 -0
  415. package/yoga/website/docs/styling/layout-direction.mdx +34 -0
  416. package/yoga/website/docs/styling/margin-padding-border.mdx +41 -0
  417. package/yoga/website/docs/styling/min-max-width-height.mdx +52 -0
  418. package/yoga/website/docs/styling/position.mdx +37 -0
  419. package/yoga/website/docs/styling/width-height.mdx +37 -0
  420. package/yoga/website/docusaurus.config.js +113 -0
  421. package/yoga/website/package.json +43 -0
  422. package/yoga/website/sidebars.cjs +27 -0
  423. package/yoga/website/src/components/EditorToolbar.module.css +77 -0
  424. package/yoga/website/src/components/EditorToolbar.tsx +72 -0
  425. package/yoga/website/src/components/FlexStyle.ts +439 -0
  426. package/yoga/website/src/components/LayoutBox.module.css +68 -0
  427. package/yoga/website/src/components/LayoutBox.tsx +61 -0
  428. package/yoga/website/src/components/Playground.module.css +130 -0
  429. package/yoga/website/src/components/Playground.tsx +187 -0
  430. package/yoga/website/src/components/YogaViewer.tsx +128 -0
  431. package/yoga/website/src/css/custom.css +37 -0
  432. package/yoga/website/src/pages/index.module.css +34 -0
  433. package/yoga/website/src/pages/index.tsx +84 -0
  434. package/yoga/website/src/pages/markdown-page.md +7 -0
  435. package/yoga/website/src/pages/playground.module.css +11 -0
  436. package/yoga/website/src/pages/playground.tsx +56 -0
  437. package/yoga/website/static/.nojekyll +0 -0
  438. package/yoga/website/static/img/docusaurus.png +0 -0
  439. package/yoga/website/static/img/favicon.svg +17 -0
  440. package/yoga/website/static/img/link.svg +4 -0
  441. package/yoga/website/static/img/logo.svg +17 -0
  442. package/yoga/website/static/img/meta_oss.svg +1 -0
  443. package/yoga/website/static/img/opengraph.png +0 -0
  444. package/yoga/website/static/img/undraw_docusaurus_mountain.svg +171 -0
  445. package/yoga/website/static/img/undraw_docusaurus_react.svg +170 -0
  446. package/yoga/website/static/img/undraw_docusaurus_tree.svg +40 -0
  447. package/yoga/website/tsconfig.json +10 -0
  448. package/yoga/yarn.lock +11499 -0
  449. package/yoga/yoga/CMakeLists.txt +41 -0
  450. package/yoga/yoga/YGConfig.cpp +92 -0
  451. package/yoga/yoga/YGConfig.h +158 -0
  452. package/yoga/yoga/YGEnums.cpp +304 -0
  453. package/yoga/yoga/YGEnums.h +163 -0
  454. package/yoga/yoga/YGMacros.h +101 -0
  455. package/yoga/yoga/YGNode.cpp +407 -0
  456. package/yoga/yoga/YGNode.h +373 -0
  457. package/yoga/yoga/YGNodeLayout.cpp +100 -0
  458. package/yoga/yoga/YGNodeLayout.h +43 -0
  459. package/yoga/yoga/YGNodeStyle.cpp +774 -0
  460. package/yoga/yoga/YGNodeStyle.h +243 -0
  461. package/yoga/yoga/YGPixelGrid.cpp +22 -0
  462. package/yoga/yoga/YGPixelGrid.h +29 -0
  463. package/yoga/yoga/YGValue.cpp +20 -0
  464. package/yoga/yoga/YGValue.h +83 -0
  465. package/yoga/yoga/Yoga.h +21 -0
  466. package/yoga/yoga/algorithm/AbsoluteLayout.cpp +595 -0
  467. package/yoga/yoga/algorithm/AbsoluteLayout.h +41 -0
  468. package/yoga/yoga/algorithm/Align.h +83 -0
  469. package/yoga/yoga/algorithm/Baseline.cpp +78 -0
  470. package/yoga/yoga/algorithm/Baseline.h +21 -0
  471. package/yoga/yoga/algorithm/BoundAxis.h +79 -0
  472. package/yoga/yoga/algorithm/Cache.cpp +121 -0
  473. package/yoga/yoga/algorithm/Cache.h +30 -0
  474. package/yoga/yoga/algorithm/CalculateLayout.cpp +2968 -0
  475. package/yoga/yoga/algorithm/CalculateLayout.h +60 -0
  476. package/yoga/yoga/algorithm/FlexDirection.h +120 -0
  477. package/yoga/yoga/algorithm/FlexLine.cpp +124 -0
  478. package/yoga/yoga/algorithm/FlexLine.h +75 -0
  479. package/yoga/yoga/algorithm/PixelGrid.cpp +138 -0
  480. package/yoga/yoga/algorithm/PixelGrid.h +29 -0
  481. package/yoga/yoga/algorithm/SizingMode.h +73 -0
  482. package/yoga/yoga/algorithm/TrailingPosition.h +44 -0
  483. package/yoga/yoga/config/Config.cpp +135 -0
  484. package/yoga/yoga/config/Config.h +93 -0
  485. package/yoga/yoga/debug/AssertFatal.cpp +54 -0
  486. package/yoga/yoga/debug/AssertFatal.h +29 -0
  487. package/yoga/yoga/debug/Log.cpp +107 -0
  488. package/yoga/yoga/debug/Log.h +34 -0
  489. package/yoga/yoga/enums/Align.h +49 -0
  490. package/yoga/yoga/enums/BoxSizing.h +40 -0
  491. package/yoga/yoga/enums/Dimension.h +40 -0
  492. package/yoga/yoga/enums/Direction.h +41 -0
  493. package/yoga/yoga/enums/Display.h +42 -0
  494. package/yoga/yoga/enums/Edge.h +47 -0
  495. package/yoga/yoga/enums/Errata.h +43 -0
  496. package/yoga/yoga/enums/ExperimentalFeature.h +40 -0
  497. package/yoga/yoga/enums/FlexDirection.h +42 -0
  498. package/yoga/yoga/enums/GridTrackType.h +43 -0
  499. package/yoga/yoga/enums/Gutter.h +41 -0
  500. package/yoga/yoga/enums/Justify.h +48 -0
  501. package/yoga/yoga/enums/LogLevel.h +44 -0
  502. package/yoga/yoga/enums/MeasureMode.h +41 -0
  503. package/yoga/yoga/enums/NodeType.h +40 -0
  504. package/yoga/yoga/enums/Overflow.h +41 -0
  505. package/yoga/yoga/enums/PhysicalEdge.h +21 -0
  506. package/yoga/yoga/enums/PositionType.h +41 -0
  507. package/yoga/yoga/enums/Unit.h +45 -0
  508. package/yoga/yoga/enums/Wrap.h +41 -0
  509. package/yoga/yoga/enums/YogaEnums.h +84 -0
  510. package/yoga/yoga/event/event.cpp +89 -0
  511. package/yoga/yoga/event/event.h +131 -0
  512. package/yoga/yoga/module.modulemap +21 -0
  513. package/yoga/yoga/node/CachedMeasurement.h +53 -0
  514. package/yoga/yoga/node/LayoutResults.cpp +48 -0
  515. package/yoga/yoga/node/LayoutResults.h +136 -0
  516. package/yoga/yoga/node/LayoutableChildren.h +148 -0
  517. package/yoga/yoga/node/Node.cpp +509 -0
  518. package/yoga/yoga/node/Node.h +372 -0
  519. package/yoga/yoga/numeric/Comparison.h +81 -0
  520. package/yoga/yoga/numeric/FloatOptional.h +84 -0
  521. package/yoga/yoga/style/GridLine.h +53 -0
  522. package/yoga/yoga/style/GridStyle.h +80 -0
  523. package/yoga/yoga/style/GridTrack.h +63 -0
  524. package/yoga/yoga/style/SmallValueBuffer.h +133 -0
  525. package/yoga/yoga/style/Style.h +932 -0
  526. package/yoga/yoga/style/StyleLength.h +121 -0
  527. package/yoga/yoga/style/StyleSizeLength.h +152 -0
  528. package/yoga/yoga/style/StyleValueHandle.h +114 -0
  529. package/yoga/yoga/style/StyleValuePool.h +194 -0
@@ -0,0 +1,958 @@
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
+ * @format
8
+ */
9
+
10
+ import type Emitter from './emitters/Emitter.ts';
11
+ import type {ParsedStyles, ValueWithUnit} from './types.ts';
12
+
13
+ const INVISIBLE_BORDER_STYLES = new Set(['none', 'initial']);
14
+
15
+ /**
16
+ * Parse a raw inline style attribute string into a Map of property → value.
17
+ * Expands common shorthands used in fixtures so individual longhand
18
+ * properties are always present in the returned map.
19
+ */
20
+ export function parseStyleAttribute(styleAttr: string): ParsedStyles {
21
+ const styles: ParsedStyles = new Map();
22
+ if (!styleAttr) return styles;
23
+
24
+ const declarations = styleAttr.split(';');
25
+ for (const decl of declarations) {
26
+ const trimmed = decl.trim();
27
+ if (!trimmed) continue;
28
+
29
+ const colonIdx = trimmed.indexOf(':');
30
+ if (colonIdx === -1) continue;
31
+
32
+ const prop = trimmed.slice(0, colonIdx).trim();
33
+ let value = trimmed.slice(colonIdx + 1).trim();
34
+
35
+ // Strip single or double quotes from values (e.g., align-items: 'stretch')
36
+ if (
37
+ (value.startsWith("'") && value.endsWith("'")) ||
38
+ (value.startsWith('"') && value.endsWith('"'))
39
+ ) {
40
+ value = value.slice(1, -1);
41
+ }
42
+
43
+ expandShorthand(styles, prop, value);
44
+ }
45
+
46
+ return styles;
47
+ }
48
+
49
+ function expandShorthand(
50
+ styles: ParsedStyles,
51
+ prop: string,
52
+ value: string,
53
+ ): void {
54
+ switch (prop) {
55
+ case 'flex': {
56
+ // Only handle `flex: N` (single numeric value) as used in fixtures
57
+ const n = parseFloat(value);
58
+ if (!isNaN(n) && value.trim() === String(n)) {
59
+ styles.set('flex-grow', String(n));
60
+ styles.set('flex-shrink', '1');
61
+ styles.set('flex-basis', '0%');
62
+ } else {
63
+ // Pass through complex flex values as-is
64
+ styles.set(prop, value);
65
+ }
66
+ break;
67
+ }
68
+
69
+ default:
70
+ styles.set(prop, value);
71
+ break;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Map parsed CSS properties to Yoga emitter method calls.
77
+ */
78
+ export function applyStyles(
79
+ emitter: Emitter,
80
+ nodeName: string,
81
+ styles: ParsedStyles,
82
+ isRoot: boolean,
83
+ ): void {
84
+ // Root nodes get implicit absolute positioning from the template CSS.
85
+ if (isRoot && !styles.has('position')) {
86
+ emitter.setPositionType(nodeName, positionValue('absolute'));
87
+ }
88
+
89
+ for (const [prop, value] of styles) {
90
+ switch (prop) {
91
+ case 'direction':
92
+ emitter.setDirection(nodeName, directionValue(value));
93
+ break;
94
+
95
+ case 'position':
96
+ if (value !== 'relative') {
97
+ emitter.setPositionType(nodeName, positionValue(value));
98
+ }
99
+ break;
100
+
101
+ case 'flex-direction':
102
+ if (value !== 'column') {
103
+ emitter.setFlexDirection(nodeName, flexDirectionValue(value));
104
+ }
105
+ break;
106
+
107
+ case 'flex-wrap':
108
+ if (value !== 'nowrap') {
109
+ emitter.setFlexWrap(nodeName, wrapValue(value));
110
+ }
111
+ break;
112
+
113
+ case 'justify-content': {
114
+ const mapped = justifyValue(value);
115
+ if (mapped !== undefined && value !== 'flex-start') {
116
+ emitter.setJustifyContent(nodeName, mapped);
117
+ }
118
+ break;
119
+ }
120
+
121
+ case 'align-content': {
122
+ const mapped = alignValue(value);
123
+ if (mapped !== undefined && value !== 'flex-start') {
124
+ emitter.setAlignContent(nodeName, mapped);
125
+ }
126
+ break;
127
+ }
128
+
129
+ case 'align-items': {
130
+ const mapped = alignValue(value);
131
+ if (mapped !== undefined && value !== 'stretch') {
132
+ emitter.setAlignItems(nodeName, mapped);
133
+ }
134
+ break;
135
+ }
136
+
137
+ case 'align-self': {
138
+ const mapped = alignValue(value);
139
+ if (mapped !== undefined) {
140
+ emitter.setAlignSelf(nodeName, mapped);
141
+ }
142
+ break;
143
+ }
144
+
145
+ case 'overflow':
146
+ if (value !== 'visible') {
147
+ emitter.setOverflow(nodeName, overflowValue(value));
148
+ }
149
+ break;
150
+
151
+ case 'display':
152
+ if (value !== 'flex') {
153
+ emitter.setDisplay(nodeName, displayValue(value));
154
+ }
155
+ break;
156
+
157
+ case 'box-sizing':
158
+ if (value !== 'border-box') {
159
+ emitter.setBoxSizing(nodeName, boxSizingValue(value));
160
+ }
161
+ break;
162
+
163
+ case 'flex-grow':
164
+ if (value !== '0') {
165
+ emitter.setFlexGrow(nodeName, value);
166
+ }
167
+ break;
168
+
169
+ case 'flex-shrink':
170
+ if (value !== '0') {
171
+ emitter.setFlexShrink(nodeName, value);
172
+ }
173
+ break;
174
+
175
+ case 'flex-basis': {
176
+ const parsed = parseCssLength(value);
177
+ if (parsed != null) emitter.setFlexBasis(nodeName, parsed);
178
+ break;
179
+ }
180
+
181
+ case 'aspect-ratio':
182
+ emitter.setAspectRatio(nodeName, parseValueWithUnit(value));
183
+ break;
184
+
185
+ // Dimensions
186
+ case 'width': {
187
+ const parsed = parseCssLength(value);
188
+ if (parsed != null) emitter.setWidth(nodeName, parsed);
189
+ break;
190
+ }
191
+ case 'height': {
192
+ const parsed = parseCssLength(value);
193
+ if (parsed != null) emitter.setHeight(nodeName, parsed);
194
+ break;
195
+ }
196
+ case 'min-width': {
197
+ if (value !== '0' && value !== '0px' && value !== 'auto') {
198
+ const parsed = parseCssLength(value);
199
+ if (parsed != null) emitter.setMinWidth(nodeName, parsed);
200
+ }
201
+ break;
202
+ }
203
+ case 'min-height': {
204
+ if (value !== '0' && value !== '0px' && value !== 'auto') {
205
+ const parsed = parseCssLength(value);
206
+ if (parsed != null) emitter.setMinHeight(nodeName, parsed);
207
+ }
208
+ break;
209
+ }
210
+ case 'max-width': {
211
+ const parsed = parseCssLength(value);
212
+ if (parsed != null) emitter.setMaxWidth(nodeName, parsed);
213
+ break;
214
+ }
215
+ case 'max-height': {
216
+ const parsed = parseCssLength(value);
217
+ if (parsed != null) emitter.setMaxHeight(nodeName, parsed);
218
+ break;
219
+ }
220
+
221
+ // Insets - physical
222
+ case 'left': {
223
+ const parsed = parseCssLength(value);
224
+ if (parsed != null) {
225
+ emitter.setPosition(nodeName, edgeValue('left'), parsed);
226
+ }
227
+ break;
228
+ }
229
+ case 'top': {
230
+ const parsed = parseCssLength(value);
231
+ if (parsed != null) {
232
+ emitter.setPosition(nodeName, edgeValue('top'), parsed);
233
+ }
234
+ break;
235
+ }
236
+ case 'right': {
237
+ const parsed = parseCssLength(value);
238
+ if (parsed != null) {
239
+ emitter.setPosition(nodeName, edgeValue('right'), parsed);
240
+ }
241
+ break;
242
+ }
243
+ case 'bottom': {
244
+ const parsed = parseCssLength(value);
245
+ if (parsed != null) {
246
+ emitter.setPosition(nodeName, edgeValue('bottom'), parsed);
247
+ }
248
+ break;
249
+ }
250
+
251
+ // Insets - logical
252
+ case 'inset-inline-start': {
253
+ const parsed = parseCssLength(value);
254
+ if (parsed != null) {
255
+ emitter.setPosition(nodeName, edgeValue('start'), parsed);
256
+ }
257
+ break;
258
+ }
259
+ case 'inset-inline-end': {
260
+ const parsed = parseCssLength(value);
261
+ if (parsed != null) {
262
+ emitter.setPosition(nodeName, edgeValue('end'), parsed);
263
+ }
264
+ break;
265
+ }
266
+ case 'inset-block-start': {
267
+ const parsed = parseCssLength(value);
268
+ if (parsed != null) {
269
+ emitter.setPosition(nodeName, edgeValue('top'), parsed);
270
+ }
271
+ break;
272
+ }
273
+ case 'inset-block-end': {
274
+ const parsed = parseCssLength(value);
275
+ if (parsed != null) {
276
+ emitter.setPosition(nodeName, edgeValue('bottom'), parsed);
277
+ }
278
+ break;
279
+ }
280
+
281
+ // Box shorthands
282
+ case 'margin':
283
+ case 'padding':
284
+ case 'border-width': {
285
+ const parse =
286
+ prop === 'border-width' ? parseBorderWidth : parseCssLength;
287
+ const emit = (edge: string, v: ValueWithUnit) => {
288
+ if (prop === 'margin') emitter.setMargin(nodeName, edge, v);
289
+ else if (prop === 'padding') emitter.setPadding(nodeName, edge, v);
290
+ else emitter.setBorder(nodeName, edge, v);
291
+ };
292
+ const parts = value.split(/\s+/);
293
+ switch (parts.length) {
294
+ case 1: {
295
+ const parsed = parse(parts[0]);
296
+ if (parsed != null) {
297
+ emit(edgeValue('all'), parsed);
298
+ }
299
+ break;
300
+ }
301
+ case 2: {
302
+ const vertVal = parse(parts[0]);
303
+ const horizVal = parse(parts[1]);
304
+ if (vertVal != null) {
305
+ emit(edgeValue('vertical'), vertVal);
306
+ }
307
+ if (horizVal != null) {
308
+ emit(edgeValue('horizontal'), horizVal);
309
+ }
310
+ break;
311
+ }
312
+ case 3: {
313
+ const topVal = parse(parts[0]);
314
+ const horizVal = parse(parts[1]);
315
+ const bottomVal = parse(parts[2]);
316
+ if (topVal != null) {
317
+ emit(edgeValue('top'), topVal);
318
+ }
319
+ if (horizVal != null) {
320
+ emit(edgeValue('horizontal'), horizVal);
321
+ }
322
+ if (bottomVal != null) {
323
+ emit(edgeValue('bottom'), bottomVal);
324
+ }
325
+ break;
326
+ }
327
+ case 4: {
328
+ const topVal = parse(parts[0]);
329
+ const rightVal = parse(parts[1]);
330
+ const bottomVal = parse(parts[2]);
331
+ const leftVal = parse(parts[3]);
332
+ if (topVal != null) {
333
+ emit(edgeValue('top'), topVal);
334
+ }
335
+ if (rightVal != null) {
336
+ emit(edgeValue('right'), rightVal);
337
+ }
338
+ if (bottomVal != null) {
339
+ emit(edgeValue('bottom'), bottomVal);
340
+ }
341
+ if (leftVal != null) {
342
+ emit(edgeValue('left'), leftVal);
343
+ }
344
+ break;
345
+ }
346
+ }
347
+ break;
348
+ }
349
+
350
+ // Gap shorthand
351
+ case 'gap': {
352
+ const parts = value.split(/\s+/);
353
+ if (parts.length === 1) {
354
+ const parsed = parseCssLength(parts[0]);
355
+ if (parsed != null) {
356
+ emitter.setGap(nodeName, gutterValue('all'), parsed);
357
+ }
358
+ } else {
359
+ const rowVal = parseCssLength(parts[0]);
360
+ const colVal = parseCssLength(parts[1]);
361
+ if (rowVal != null) {
362
+ emitter.setGap(nodeName, gutterValue('row'), rowVal);
363
+ }
364
+ if (colVal != null) {
365
+ emitter.setGap(nodeName, gutterValue('column'), colVal);
366
+ }
367
+ }
368
+ break;
369
+ }
370
+
371
+ // Margins - shorthand logical
372
+ case 'margin-inline': {
373
+ const parts = value.split(/\s+/);
374
+ if (parts.length === 1) {
375
+ const parsed = parseCssLength(parts[0]);
376
+ if (parsed != null) {
377
+ emitter.setMargin(nodeName, edgeValue('horizontal'), parsed);
378
+ }
379
+ } else {
380
+ const startVal = parseCssLength(parts[0]);
381
+ const endVal = parseCssLength(parts[1]);
382
+ if (startVal != null) {
383
+ emitter.setMargin(nodeName, edgeValue('start'), startVal);
384
+ }
385
+ if (endVal != null) {
386
+ emitter.setMargin(nodeName, edgeValue('end'), endVal);
387
+ }
388
+ }
389
+ break;
390
+ }
391
+ case 'margin-block': {
392
+ const parts = value.split(/\s+/);
393
+ if (parts.length === 1) {
394
+ const parsed = parseCssLength(parts[0]);
395
+ if (parsed != null) {
396
+ emitter.setMargin(nodeName, edgeValue('vertical'), parsed);
397
+ }
398
+ } else {
399
+ const topVal = parseCssLength(parts[0]);
400
+ const bottomVal = parseCssLength(parts[1]);
401
+ if (topVal != null) {
402
+ emitter.setMargin(nodeName, edgeValue('top'), topVal);
403
+ }
404
+ if (bottomVal != null) {
405
+ emitter.setMargin(nodeName, edgeValue('bottom'), bottomVal);
406
+ }
407
+ }
408
+ break;
409
+ }
410
+
411
+ // Margins - physical
412
+ case 'margin-left': {
413
+ const parsed = parseCssLength(value);
414
+ if (parsed != null) {
415
+ emitter.setMargin(nodeName, edgeValue('left'), parsed);
416
+ }
417
+ break;
418
+ }
419
+ case 'margin-top': {
420
+ const parsed = parseCssLength(value);
421
+ if (parsed != null) {
422
+ emitter.setMargin(nodeName, edgeValue('top'), parsed);
423
+ }
424
+ break;
425
+ }
426
+ case 'margin-right': {
427
+ const parsed = parseCssLength(value);
428
+ if (parsed != null) {
429
+ emitter.setMargin(nodeName, edgeValue('right'), parsed);
430
+ }
431
+ break;
432
+ }
433
+ case 'margin-bottom': {
434
+ const parsed = parseCssLength(value);
435
+ if (parsed != null) {
436
+ emitter.setMargin(nodeName, edgeValue('bottom'), parsed);
437
+ }
438
+ break;
439
+ }
440
+
441
+ // Margins - logical
442
+ case 'margin-inline-start': {
443
+ const parsed = parseCssLength(value);
444
+ if (parsed != null) {
445
+ emitter.setMargin(nodeName, edgeValue('start'), parsed);
446
+ }
447
+ break;
448
+ }
449
+ case 'margin-inline-end': {
450
+ const parsed = parseCssLength(value);
451
+ if (parsed != null) {
452
+ emitter.setMargin(nodeName, edgeValue('end'), parsed);
453
+ }
454
+ break;
455
+ }
456
+ case 'margin-block-start': {
457
+ const parsed = parseCssLength(value);
458
+ if (parsed != null) {
459
+ emitter.setMargin(nodeName, edgeValue('top'), parsed);
460
+ }
461
+ break;
462
+ }
463
+ case 'margin-block-end': {
464
+ const parsed = parseCssLength(value);
465
+ if (parsed != null) {
466
+ emitter.setMargin(nodeName, edgeValue('bottom'), parsed);
467
+ }
468
+ break;
469
+ }
470
+
471
+ // Padding - physical
472
+ case 'padding-left': {
473
+ const parsed = parseCssLength(value);
474
+ if (parsed != null) {
475
+ emitter.setPadding(nodeName, edgeValue('left'), parsed);
476
+ }
477
+ break;
478
+ }
479
+ case 'padding-top': {
480
+ const parsed = parseCssLength(value);
481
+ if (parsed != null) {
482
+ emitter.setPadding(nodeName, edgeValue('top'), parsed);
483
+ }
484
+ break;
485
+ }
486
+ case 'padding-right': {
487
+ const parsed = parseCssLength(value);
488
+ if (parsed != null) {
489
+ emitter.setPadding(nodeName, edgeValue('right'), parsed);
490
+ }
491
+ break;
492
+ }
493
+ case 'padding-bottom': {
494
+ const parsed = parseCssLength(value);
495
+ if (parsed != null) {
496
+ emitter.setPadding(nodeName, edgeValue('bottom'), parsed);
497
+ }
498
+ break;
499
+ }
500
+
501
+ // Padding - logical
502
+ case 'padding-inline-start': {
503
+ const parsed = parseCssLength(value);
504
+ if (parsed != null) {
505
+ emitter.setPadding(nodeName, edgeValue('start'), parsed);
506
+ }
507
+ break;
508
+ }
509
+ case 'padding-inline-end': {
510
+ const parsed = parseCssLength(value);
511
+ if (parsed != null) {
512
+ emitter.setPadding(nodeName, edgeValue('end'), parsed);
513
+ }
514
+ break;
515
+ }
516
+ case 'padding-inline': {
517
+ const parts = value.split(/\s+/);
518
+ if (parts.length === 1) {
519
+ const parsed = parseCssLength(parts[0]);
520
+ if (parsed != null) {
521
+ emitter.setPadding(nodeName, edgeValue('horizontal'), parsed);
522
+ }
523
+ } else {
524
+ const startVal = parseCssLength(parts[0]);
525
+ const endVal = parseCssLength(parts[1]);
526
+ if (startVal != null) {
527
+ emitter.setPadding(nodeName, edgeValue('start'), startVal);
528
+ }
529
+ if (endVal != null) {
530
+ emitter.setPadding(nodeName, edgeValue('end'), endVal);
531
+ }
532
+ }
533
+ break;
534
+ }
535
+ case 'padding-block': {
536
+ const parts = value.split(/\s+/);
537
+ if (parts.length === 1) {
538
+ const parsed = parseCssLength(parts[0]);
539
+ if (parsed != null) {
540
+ emitter.setPadding(nodeName, edgeValue('vertical'), parsed);
541
+ }
542
+ } else {
543
+ const topVal = parseCssLength(parts[0]);
544
+ const bottomVal = parseCssLength(parts[1]);
545
+ if (topVal != null) {
546
+ emitter.setPadding(nodeName, edgeValue('top'), topVal);
547
+ }
548
+ if (bottomVal != null) {
549
+ emitter.setPadding(nodeName, edgeValue('bottom'), bottomVal);
550
+ }
551
+ }
552
+ break;
553
+ }
554
+ case 'padding-block-start': {
555
+ const parsed = parseCssLength(value);
556
+ if (parsed != null) {
557
+ emitter.setPadding(nodeName, edgeValue('top'), parsed);
558
+ }
559
+ break;
560
+ }
561
+ case 'padding-block-end': {
562
+ const parsed = parseCssLength(value);
563
+ if (parsed != null) {
564
+ emitter.setPadding(nodeName, edgeValue('bottom'), parsed);
565
+ }
566
+ break;
567
+ }
568
+
569
+ // Border - compound shorthands (e.g. `border: 10px solid black`)
570
+ case 'border': {
571
+ const width = extractBorderWidth(value);
572
+ if (width != null) {
573
+ emitter.setBorder(nodeName, edgeValue('all'), width);
574
+ }
575
+ break;
576
+ }
577
+ case 'border-top': {
578
+ const width = extractBorderWidth(value);
579
+ if (width != null) {
580
+ emitter.setBorder(nodeName, edgeValue('top'), width);
581
+ }
582
+ break;
583
+ }
584
+ case 'border-right': {
585
+ const width = extractBorderWidth(value);
586
+ if (width != null) {
587
+ emitter.setBorder(nodeName, edgeValue('right'), width);
588
+ }
589
+ break;
590
+ }
591
+ case 'border-bottom': {
592
+ const width = extractBorderWidth(value);
593
+ if (width != null) {
594
+ emitter.setBorder(nodeName, edgeValue('bottom'), width);
595
+ }
596
+ break;
597
+ }
598
+ case 'border-left': {
599
+ const width = extractBorderWidth(value);
600
+ if (width != null) {
601
+ emitter.setBorder(nodeName, edgeValue('left'), width);
602
+ }
603
+ break;
604
+ }
605
+ case 'border-block': {
606
+ const width = extractBorderWidth(value);
607
+ if (width != null) {
608
+ emitter.setBorder(nodeName, edgeValue('vertical'), width);
609
+ }
610
+ break;
611
+ }
612
+ case 'border-inline': {
613
+ const width = extractBorderWidth(value);
614
+ if (width != null) {
615
+ emitter.setBorder(nodeName, edgeValue('horizontal'), width);
616
+ }
617
+ break;
618
+ }
619
+ case 'border-block-start': {
620
+ const width = extractBorderWidth(value);
621
+ if (width != null) {
622
+ emitter.setBorder(nodeName, edgeValue('top'), width);
623
+ }
624
+ break;
625
+ }
626
+ case 'border-block-end': {
627
+ const width = extractBorderWidth(value);
628
+ if (width != null) {
629
+ emitter.setBorder(nodeName, edgeValue('bottom'), width);
630
+ }
631
+ break;
632
+ }
633
+ case 'border-inline-start': {
634
+ const width = extractBorderWidth(value);
635
+ if (width != null) {
636
+ emitter.setBorder(nodeName, edgeValue('start'), width);
637
+ }
638
+ break;
639
+ }
640
+ case 'border-inline-end': {
641
+ const width = extractBorderWidth(value);
642
+ if (width != null) {
643
+ emitter.setBorder(nodeName, edgeValue('end'), width);
644
+ }
645
+ break;
646
+ }
647
+
648
+ // Border - physical
649
+ case 'border-left-width': {
650
+ const borderStyle = styles.get('border-left-style');
651
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
652
+ const parsed = parseBorderWidth(value);
653
+ if (parsed != null) {
654
+ emitter.setBorder(nodeName, edgeValue('left'), parsed);
655
+ }
656
+ }
657
+ break;
658
+ }
659
+ case 'border-top-width': {
660
+ const borderStyle = styles.get('border-top-style');
661
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
662
+ const parsed = parseBorderWidth(value);
663
+ if (parsed != null) {
664
+ emitter.setBorder(nodeName, edgeValue('top'), parsed);
665
+ }
666
+ }
667
+ break;
668
+ }
669
+ case 'border-right-width': {
670
+ const borderStyle = styles.get('border-right-style');
671
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
672
+ const parsed = parseBorderWidth(value);
673
+ if (parsed != null) {
674
+ emitter.setBorder(nodeName, edgeValue('right'), parsed);
675
+ }
676
+ }
677
+ break;
678
+ }
679
+ case 'border-bottom-width': {
680
+ const borderStyle = styles.get('border-bottom-style');
681
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
682
+ const parsed = parseBorderWidth(value);
683
+ if (parsed != null) {
684
+ emitter.setBorder(nodeName, edgeValue('bottom'), parsed);
685
+ }
686
+ }
687
+ break;
688
+ }
689
+
690
+ // Border - logical
691
+ case 'border-inline-start-width': {
692
+ const borderStyle = styles.get('border-inline-start-style');
693
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
694
+ const parsed = parseBorderWidth(value);
695
+ if (parsed != null) {
696
+ emitter.setBorder(nodeName, edgeValue('start'), parsed);
697
+ }
698
+ }
699
+ break;
700
+ }
701
+ case 'border-inline-end-width': {
702
+ const borderStyle = styles.get('border-inline-end-style');
703
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
704
+ const parsed = parseBorderWidth(value);
705
+ if (parsed != null) {
706
+ emitter.setBorder(nodeName, edgeValue('end'), parsed);
707
+ }
708
+ }
709
+ break;
710
+ }
711
+ case 'border-block-start-width': {
712
+ const borderStyle = styles.get('border-block-start-style');
713
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
714
+ const parsed = parseBorderWidth(value);
715
+ if (parsed != null) {
716
+ emitter.setBorder(nodeName, edgeValue('top'), parsed);
717
+ }
718
+ }
719
+ break;
720
+ }
721
+ case 'border-block-end-width': {
722
+ const borderStyle = styles.get('border-block-end-style');
723
+ if (!borderStyle || !INVISIBLE_BORDER_STYLES.has(borderStyle)) {
724
+ const parsed = parseBorderWidth(value);
725
+ if (parsed != null) {
726
+ emitter.setBorder(nodeName, edgeValue('bottom'), parsed);
727
+ }
728
+ }
729
+ break;
730
+ }
731
+
732
+ // Gap
733
+ case 'row-gap': {
734
+ const parsed = parseCssLength(value);
735
+ if (parsed != null) {
736
+ emitter.setGap(nodeName, gutterValue('row'), parsed);
737
+ }
738
+ break;
739
+ }
740
+ case 'column-gap': {
741
+ const parsed = parseCssLength(value);
742
+ if (parsed != null) {
743
+ emitter.setGap(nodeName, gutterValue('column'), parsed);
744
+ }
745
+ break;
746
+ }
747
+ }
748
+ }
749
+ }
750
+
751
+ // Value parsers
752
+
753
+ export function parseValueWithUnit(value: string): ValueWithUnit {
754
+ if (value === 'auto') return {type: 'auto'};
755
+ if (value === 'undefined') return {type: 'undefined'};
756
+ if (value === 'max-content') return {type: 'max-content'};
757
+ if (value === 'fit-content') return {type: 'fit-content'};
758
+ if (value === 'stretch' || value === '-webkit-fill-available')
759
+ return {type: 'stretch'};
760
+ if (value.endsWith('%')) return {type: 'percent', value: parseFloat(value)};
761
+ return {type: 'points', value: parseFloat(value)};
762
+ }
763
+
764
+ /**
765
+ * Parse a CSS length value, rejecting unitless non-zero numbers.
766
+ * In CSS, only `0` is valid without a unit for length properties.
767
+ * Invalid values (e.g. `padding-top: 10` without `px`) return null.
768
+ */
769
+ export function parseCssLength(value: string): ValueWithUnit | null {
770
+ if (value === 'auto') return {type: 'auto'};
771
+ if (value === 'undefined') return {type: 'undefined'};
772
+ if (value === 'max-content') return {type: 'max-content'};
773
+ if (value === 'fit-content') return {type: 'fit-content'};
774
+ if (value === 'stretch' || value === '-webkit-fill-available')
775
+ return {type: 'stretch'};
776
+ if (value.endsWith('%')) return {type: 'percent', value: parseFloat(value)};
777
+ if (value.endsWith('px')) return {type: 'points', value: parseFloat(value)};
778
+ // Unitless 0 is valid
779
+ const num = parseFloat(value);
780
+ if (num === 0 && !isNaN(num)) return {type: 'points', value: 0};
781
+ // Unitless non-zero number is invalid CSS for length properties
782
+ return null;
783
+ }
784
+
785
+ /**
786
+ * Parse a CSS border-width value. Rejects unitless non-zero numbers
787
+ * and percentage values (CSS border-width does not accept percentages).
788
+ */
789
+ function parseBorderWidth(value: string): ValueWithUnit | null {
790
+ const parsed = parseCssLength(value);
791
+ if (parsed != null && parsed.type === 'percent') return null;
792
+ return parsed;
793
+ }
794
+
795
+ /**
796
+ * Extract the width component from a compound border shorthand value
797
+ * like `10px solid black` or `solid black 5px`. Returns null if the
798
+ * border style is invisible (none/initial) or no valid width is found.
799
+ */
800
+ function extractBorderWidth(value: string): ValueWithUnit | null {
801
+ const parts = value.split(/\s+/);
802
+ const BORDER_STYLES = new Set([
803
+ 'none',
804
+ 'hidden',
805
+ 'dotted',
806
+ 'dashed',
807
+ 'solid',
808
+ 'double',
809
+ 'groove',
810
+ 'ridge',
811
+ 'inset',
812
+ 'outset',
813
+ 'initial',
814
+ ]);
815
+
816
+ let widthStr: string | null = null;
817
+ let styleStr: string | null = null;
818
+
819
+ for (const part of parts) {
820
+ if (BORDER_STYLES.has(part)) {
821
+ styleStr = part;
822
+ } else if (/^[\d.]/.test(part)) {
823
+ widthStr = part;
824
+ }
825
+ // color values are ignored
826
+ }
827
+
828
+ if (styleStr && INVISIBLE_BORDER_STYLES.has(styleStr)) return null;
829
+ if (widthStr == null) return null;
830
+ return parseBorderWidth(widthStr);
831
+ }
832
+
833
+ // Enum value mappers
834
+
835
+ function directionValue(value: string): string {
836
+ const map: Record<string, string> = {
837
+ ltr: 'YGDirectionLTR',
838
+ rtl: 'YGDirectionRTL',
839
+ inherit: 'YGDirectionInherit',
840
+ };
841
+ return map[value] ?? value;
842
+ }
843
+
844
+ function flexDirectionValue(value: string): string {
845
+ const map: Record<string, string> = {
846
+ row: 'YGFlexDirectionRow',
847
+ 'row-reverse': 'YGFlexDirectionRowReverse',
848
+ column: 'YGFlexDirectionColumn',
849
+ 'column-reverse': 'YGFlexDirectionColumnReverse',
850
+ };
851
+ return map[value] ?? value;
852
+ }
853
+
854
+ function justifyValue(value: string): string | undefined {
855
+ const map: Record<string, string> = {
856
+ center: 'YGJustifyCenter',
857
+ 'space-around': 'YGJustifySpaceAround',
858
+ 'space-between': 'YGJustifySpaceBetween',
859
+ 'space-evenly': 'YGJustifySpaceEvenly',
860
+ 'flex-start': 'YGJustifyFlexStart',
861
+ 'flex-end': 'YGJustifyFlexEnd',
862
+ stretch: 'YGJustifyStretch',
863
+ start: 'YGJustifyStart',
864
+ end: 'YGJustifyEnd',
865
+ auto: 'YGJustifyAuto',
866
+ };
867
+ return map[value];
868
+ }
869
+
870
+ function alignValue(value: string): string | undefined {
871
+ const map: Record<string, string> = {
872
+ auto: 'YGAlignAuto',
873
+ center: 'YGAlignCenter',
874
+ stretch: 'YGAlignStretch',
875
+ 'flex-start': 'YGAlignFlexStart',
876
+ 'flex-end': 'YGAlignFlexEnd',
877
+ 'space-between': 'YGAlignSpaceBetween',
878
+ 'space-around': 'YGAlignSpaceAround',
879
+ 'space-evenly': 'YGAlignSpaceEvenly',
880
+ baseline: 'YGAlignBaseline',
881
+ start: 'YGAlignStart',
882
+ end: 'YGAlignEnd',
883
+ };
884
+ return map[value];
885
+ }
886
+
887
+ function positionValue(value: string): string {
888
+ const map: Record<string, string> = {
889
+ absolute: 'YGPositionTypeAbsolute',
890
+ static: 'YGPositionTypeStatic',
891
+ relative: 'YGPositionTypeRelative',
892
+ };
893
+ return map[value] ?? 'YGPositionTypeRelative';
894
+ }
895
+
896
+ function wrapValue(value: string): string {
897
+ const map: Record<string, string> = {
898
+ wrap: 'YGWrapWrap',
899
+ 'wrap-reverse': 'YGWrapWrapReverse',
900
+ nowrap: 'YGWrapNoWrap',
901
+ };
902
+ return map[value] ?? value;
903
+ }
904
+
905
+ function overflowValue(value: string): string {
906
+ const map: Record<string, string> = {
907
+ visible: 'YGOverflowVisible',
908
+ hidden: 'YGOverflowHidden',
909
+ scroll: 'YGOverflowScroll',
910
+ };
911
+ return map[value] ?? value;
912
+ }
913
+
914
+ function displayValue(value: string): string {
915
+ const map: Record<string, string> = {
916
+ flex: 'YGDisplayFlex',
917
+ none: 'YGDisplayNone',
918
+ contents: 'YGDisplayContents',
919
+ };
920
+ return map[value] ?? value;
921
+ }
922
+
923
+ function boxSizingValue(value: string): string {
924
+ const map: Record<string, string> = {
925
+ 'border-box': 'YGBoxSizingBorderBox',
926
+ 'content-box': 'YGBoxSizingContentBox',
927
+ };
928
+ return map[value] ?? value;
929
+ }
930
+
931
+ function edgeValue(edge: string): string {
932
+ const map: Record<string, string> = {
933
+ left: 'YGEdgeLeft',
934
+ right: 'YGEdgeRight',
935
+ top: 'YGEdgeTop',
936
+ bottom: 'YGEdgeBottom',
937
+ start: 'YGEdgeStart',
938
+ end: 'YGEdgeEnd',
939
+ all: 'YGEdgeAll',
940
+ vertical: 'YGEdgeVertical',
941
+ horizontal: 'YGEdgeHorizontal',
942
+ };
943
+ return map[edge] ?? edge;
944
+ }
945
+
946
+ function gutterValue(gutter: string): string {
947
+ const map: Record<string, string> = {
948
+ row: 'YGGutterRow',
949
+ column: 'YGGutterColumn',
950
+ all: 'YGGutterAll',
951
+ };
952
+ return map[gutter] ?? gutter;
953
+ }
954
+
955
+ export function getFlexDirectionForMeasure(styles: ParsedStyles): string {
956
+ const fd = styles.get('flex-direction');
957
+ return flexDirectionValue(fd ?? 'column');
958
+ }