@xincli/opentui-core 0.4.6

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 (476) hide show
  1. package/README.md +63 -0
  2. package/dev/keypress-debug-renderer.ts +148 -0
  3. package/dev/keypress-debug.ts +43 -0
  4. package/dev/print-env-vars.ts +32 -0
  5. package/dev/test-tmux-graphics-334.sh +68 -0
  6. package/dev/test-tmux-theme-queries.sh +151 -0
  7. package/dev/thai-debug-test.ts +68 -0
  8. package/dev/theme-mode.ts +290 -0
  9. package/docs/development.md +144 -0
  10. package/package.json +102 -0
  11. package/prebuilt/aarch64-android/libopentui.so +0 -0
  12. package/scripts/build-android.ts +226 -0
  13. package/scripts/build-native-termux.sh +525 -0
  14. package/scripts/build.ts +530 -0
  15. package/scripts/dist-test.ts +312 -0
  16. package/scripts/package-prebuilt.ts +110 -0
  17. package/scripts/publish.ts +60 -0
  18. package/scripts/test-node-hook.mjs +16 -0
  19. package/scripts/test-node.ts +241 -0
  20. package/scripts/vendor-deps.sh +73 -0
  21. package/src/NativeSpanFeed.ts +375 -0
  22. package/src/Renderable.ts +1878 -0
  23. package/src/__snapshots__/buffer.test.ts.snap +28 -0
  24. package/src/animation/Timeline.test.ts +2709 -0
  25. package/src/animation/Timeline.ts +598 -0
  26. package/src/ansi.ts +22 -0
  27. package/src/audio.ts +479 -0
  28. package/src/benchmark/attenuation-benchmark.ts +81 -0
  29. package/src/benchmark/audio-playback-benchmark.ts +344 -0
  30. package/src/benchmark/box-draw-benchmark.ts +1042 -0
  31. package/src/benchmark/colormatrix-benchmark.ts +123 -0
  32. package/src/benchmark/gain-benchmark.ts +80 -0
  33. package/src/benchmark/latest-all-bench-run.json +707 -0
  34. package/src/benchmark/latest-async-bench-run.json +336 -0
  35. package/src/benchmark/latest-default-bench-run.json +657 -0
  36. package/src/benchmark/latest-large-bench-run.json +707 -0
  37. package/src/benchmark/latest-quick-bench-run.json +207 -0
  38. package/src/benchmark/layout-benchmark.ts +2547 -0
  39. package/src/benchmark/markdown-benchmark.ts +1796 -0
  40. package/src/benchmark/native-span-feed-async-benchmark.ts +355 -0
  41. package/src/benchmark/native-span-feed-benchmark.md +56 -0
  42. package/src/benchmark/native-span-feed-benchmark.ts +596 -0
  43. package/src/benchmark/native-span-feed-compare.ts +280 -0
  44. package/src/benchmark/render-traversal-benchmark.ts +928 -0
  45. package/src/benchmark/text-buffer-render-benchmark.ts +874 -0
  46. package/src/benchmark/text-table-benchmark.ts +948 -0
  47. package/src/buffer.test.ts +292 -0
  48. package/src/buffer.ts +564 -0
  49. package/src/console.test.ts +629 -0
  50. package/src/console.ts +1253 -0
  51. package/src/edit-buffer.test.ts +1852 -0
  52. package/src/edit-buffer.ts +417 -0
  53. package/src/editor-view.test.ts +1056 -0
  54. package/src/editor-view.ts +290 -0
  55. package/src/index.ts +25 -0
  56. package/src/lib/KeyHandler.integration.test.ts +292 -0
  57. package/src/lib/KeyHandler.stopPropagation.test.ts +289 -0
  58. package/src/lib/KeyHandler.test.ts +662 -0
  59. package/src/lib/KeyHandler.ts +222 -0
  60. package/src/lib/RGBA.test.ts +60 -0
  61. package/src/lib/RGBA.ts +343 -0
  62. package/src/lib/ascii.font.ts +330 -0
  63. package/src/lib/border.test.ts +83 -0
  64. package/src/lib/border.ts +170 -0
  65. package/src/lib/bunfs.test.ts +27 -0
  66. package/src/lib/bunfs.ts +18 -0
  67. package/src/lib/clipboard.test.ts +63 -0
  68. package/src/lib/clipboard.ts +41 -0
  69. package/src/lib/clock.ts +35 -0
  70. package/src/lib/data-paths.test.ts +133 -0
  71. package/src/lib/data-paths.ts +109 -0
  72. package/src/lib/debounce.ts +106 -0
  73. package/src/lib/detect-links.test.ts +98 -0
  74. package/src/lib/detect-links.ts +56 -0
  75. package/src/lib/env.test.ts +228 -0
  76. package/src/lib/env.ts +209 -0
  77. package/src/lib/extmarks-history.ts +51 -0
  78. package/src/lib/extmarks-multiwidth.test.ts +324 -0
  79. package/src/lib/extmarks.test.ts +3547 -0
  80. package/src/lib/extmarks.ts +861 -0
  81. package/src/lib/fonts/block.json +405 -0
  82. package/src/lib/fonts/grid.json +265 -0
  83. package/src/lib/fonts/huge.json +741 -0
  84. package/src/lib/fonts/pallet.json +314 -0
  85. package/src/lib/fonts/shade.json +591 -0
  86. package/src/lib/fonts/slick.json +321 -0
  87. package/src/lib/fonts/tiny.json +69 -0
  88. package/src/lib/hast-styled-text.ts +59 -0
  89. package/src/lib/index.ts +22 -0
  90. package/src/lib/keybinding.internal.test.ts +342 -0
  91. package/src/lib/keybinding.internal.ts +182 -0
  92. package/src/lib/objects-in-viewport.test.ts +789 -0
  93. package/src/lib/objects-in-viewport.ts +153 -0
  94. package/src/lib/output.capture.ts +58 -0
  95. package/src/lib/parse.keypress-kitty.protocol.test.ts +347 -0
  96. package/src/lib/parse.keypress-kitty.test.ts +712 -0
  97. package/src/lib/parse.keypress-kitty.ts +470 -0
  98. package/src/lib/parse.keypress.test.ts +2020 -0
  99. package/src/lib/parse.keypress.ts +480 -0
  100. package/src/lib/parse.mouse.test.ts +552 -0
  101. package/src/lib/parse.mouse.ts +232 -0
  102. package/src/lib/paste.ts +18 -0
  103. package/src/lib/queue.ts +65 -0
  104. package/src/lib/render-geometry.ts +36 -0
  105. package/src/lib/renderable.validations.test.ts +87 -0
  106. package/src/lib/renderable.validations.ts +83 -0
  107. package/src/lib/scroll-acceleration.ts +98 -0
  108. package/src/lib/selection.ts +261 -0
  109. package/src/lib/singleton.ts +34 -0
  110. package/src/lib/stdin-parser.test.ts +2439 -0
  111. package/src/lib/stdin-parser.ts +2007 -0
  112. package/src/lib/styled-text.ts +178 -0
  113. package/src/lib/terminal-capability-detection.test.ts +226 -0
  114. package/src/lib/terminal-capability-detection.ts +98 -0
  115. package/src/lib/terminal-palette.test.ts +954 -0
  116. package/src/lib/terminal-palette.ts +441 -0
  117. package/src/lib/tree-sitter/assets/README.md +119 -0
  118. package/src/lib/tree-sitter/assets/javascript/highlights.scm +205 -0
  119. package/src/lib/tree-sitter/assets/javascript/tree-sitter-javascript.wasm +0 -0
  120. package/src/lib/tree-sitter/assets/markdown/highlights.scm +150 -0
  121. package/src/lib/tree-sitter/assets/markdown/injections.scm +27 -0
  122. package/src/lib/tree-sitter/assets/markdown/tree-sitter-markdown.wasm +0 -0
  123. package/src/lib/tree-sitter/assets/markdown_inline/highlights.scm +115 -0
  124. package/src/lib/tree-sitter/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
  125. package/src/lib/tree-sitter/assets/typescript/highlights.scm +604 -0
  126. package/src/lib/tree-sitter/assets/typescript/tree-sitter-typescript.wasm +0 -0
  127. package/src/lib/tree-sitter/assets/update.ts +360 -0
  128. package/src/lib/tree-sitter/assets/zig/highlights.scm +284 -0
  129. package/src/lib/tree-sitter/assets/zig/tree-sitter-zig.wasm +0 -0
  130. package/src/lib/tree-sitter/assets.d.ts +9 -0
  131. package/src/lib/tree-sitter/cache.test.ts +291 -0
  132. package/src/lib/tree-sitter/client.test.ts +1434 -0
  133. package/src/lib/tree-sitter/client.ts +847 -0
  134. package/src/lib/tree-sitter/default-parsers.ts +133 -0
  135. package/src/lib/tree-sitter/download-utils.ts +148 -0
  136. package/src/lib/tree-sitter/index.ts +75 -0
  137. package/src/lib/tree-sitter/parser.worker.ts +1098 -0
  138. package/src/lib/tree-sitter/parsers-config.ts +81 -0
  139. package/src/lib/tree-sitter/resolve-ft.test.ts +55 -0
  140. package/src/lib/tree-sitter/resolve-ft.ts +189 -0
  141. package/src/lib/tree-sitter/types.ts +132 -0
  142. package/src/lib/tree-sitter/update-assets.ts +10 -0
  143. package/src/lib/tree-sitter-styled-text.test.ts +1253 -0
  144. package/src/lib/tree-sitter-styled-text.ts +314 -0
  145. package/src/lib/validate-dir-name.ts +55 -0
  146. package/src/lib/yoga.options.test.ts +628 -0
  147. package/src/lib/yoga.options.ts +346 -0
  148. package/src/native-event-worker-repro.test.ts +48 -0
  149. package/src/native-event-worker-repro.worker.ts +9 -0
  150. package/src/native-handle.test.ts +221 -0
  151. package/src/platform/ffi.test.ts +516 -0
  152. package/src/platform/ffi.ts +653 -0
  153. package/src/platform/runtime.test.ts +52 -0
  154. package/src/platform/runtime.ts +121 -0
  155. package/src/platform/test.ts +45 -0
  156. package/src/platform/worker-handler-cleanup.fixture.ts +12 -0
  157. package/src/platform/worker-onmessage-startup.fixture.ts +10 -0
  158. package/src/platform/worker-startup.fixture.ts +9 -0
  159. package/src/platform/worker.node-test.ts +153 -0
  160. package/src/platform/worker.ts +425 -0
  161. package/src/plugins/core-slot.ts +579 -0
  162. package/src/plugins/registry.ts +402 -0
  163. package/src/plugins/types.ts +46 -0
  164. package/src/post/effects.ts +948 -0
  165. package/src/post/filters.ts +512 -0
  166. package/src/post/matrices.ts +288 -0
  167. package/src/renderables/ASCIIFont.ts +219 -0
  168. package/src/renderables/Box.test.ts +474 -0
  169. package/src/renderables/Box.ts +353 -0
  170. package/src/renderables/Code.test.ts +2388 -0
  171. package/src/renderables/Code.ts +555 -0
  172. package/src/renderables/Diff.regression.test.ts +381 -0
  173. package/src/renderables/Diff.test.ts +3212 -0
  174. package/src/renderables/Diff.ts +1278 -0
  175. package/src/renderables/EditBufferRenderable.test.ts +288 -0
  176. package/src/renderables/EditBufferRenderable.ts +1152 -0
  177. package/src/renderables/FrameBuffer.ts +47 -0
  178. package/src/renderables/Input.test.ts +1310 -0
  179. package/src/renderables/Input.ts +273 -0
  180. package/src/renderables/LineNumberRenderable.ts +725 -0
  181. package/src/renderables/Markdown.ts +2144 -0
  182. package/src/renderables/ScrollBar.ts +423 -0
  183. package/src/renderables/ScrollBox.ts +903 -0
  184. package/src/renderables/Select.test.ts +1134 -0
  185. package/src/renderables/Select.ts +535 -0
  186. package/src/renderables/Slider.test.ts +456 -0
  187. package/src/renderables/Slider.ts +342 -0
  188. package/src/renderables/TabSelect.test.ts +238 -0
  189. package/src/renderables/TabSelect.ts +447 -0
  190. package/src/renderables/Text.selection-buffer.test.ts +118 -0
  191. package/src/renderables/Text.test.ts +2662 -0
  192. package/src/renderables/Text.ts +147 -0
  193. package/src/renderables/TextBufferRenderable.ts +504 -0
  194. package/src/renderables/TextNode.test.ts +1137 -0
  195. package/src/renderables/TextNode.ts +379 -0
  196. package/src/renderables/TextTable.test.ts +1411 -0
  197. package/src/renderables/TextTable.ts +1434 -0
  198. package/src/renderables/Textarea.ts +425 -0
  199. package/src/renderables/TimeToFirstDraw.ts +89 -0
  200. package/src/renderables/__snapshots__/Code.test.ts.snap +13 -0
  201. package/src/renderables/__snapshots__/Diff.test.ts.snap +785 -0
  202. package/src/renderables/__snapshots__/Text.test.ts.snap +421 -0
  203. package/src/renderables/__snapshots__/TextTable.test.ts.snap +215 -0
  204. package/src/renderables/__tests__/Code.test.ts +55 -0
  205. package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +144 -0
  206. package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +827 -0
  207. package/src/renderables/__tests__/LineNumberRenderable.test.ts +1906 -0
  208. package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +85 -0
  209. package/src/renderables/__tests__/Markdown.code-colors.test.ts +288 -0
  210. package/src/renderables/__tests__/Markdown.test.ts +4175 -0
  211. package/src/renderables/__tests__/MultiRenderable.selection.test.ts +87 -0
  212. package/src/renderables/__tests__/Textarea.buffer.test.ts +683 -0
  213. package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +675 -0
  214. package/src/renderables/__tests__/Textarea.editing.test.ts +2120 -0
  215. package/src/renderables/__tests__/Textarea.error-handling.test.ts +35 -0
  216. package/src/renderables/__tests__/Textarea.events.test.ts +738 -0
  217. package/src/renderables/__tests__/Textarea.highlights.test.ts +590 -0
  218. package/src/renderables/__tests__/Textarea.keybinding.test.ts +3275 -0
  219. package/src/renderables/__tests__/Textarea.paste.test.ts +357 -0
  220. package/src/renderables/__tests__/Textarea.rendering.test.ts +1927 -0
  221. package/src/renderables/__tests__/Textarea.scroll.test.ts +733 -0
  222. package/src/renderables/__tests__/Textarea.selection.test.ts +1589 -0
  223. package/src/renderables/__tests__/Textarea.stress.test.ts +670 -0
  224. package/src/renderables/__tests__/Textarea.undo-redo.test.ts +383 -0
  225. package/src/renderables/__tests__/Textarea.visual-lines.test.ts +310 -0
  226. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +221 -0
  227. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +89 -0
  228. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +457 -0
  229. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +158 -0
  230. package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +387 -0
  231. package/src/renderables/__tests__/markdown-parser.test.ts +241 -0
  232. package/src/renderables/__tests__/renderable-test-utils.ts +60 -0
  233. package/src/renderables/composition/README.md +8 -0
  234. package/src/renderables/composition/VRenderable.ts +32 -0
  235. package/src/renderables/composition/constructs.ts +127 -0
  236. package/src/renderables/composition/vnode.ts +277 -0
  237. package/src/renderables/index.ts +23 -0
  238. package/src/renderables/markdown-parser.ts +79 -0
  239. package/src/renderer-theme-mode.ts +199 -0
  240. package/src/renderer.ts +4975 -0
  241. package/src/runtime-plugin-support-configure.ts +63 -0
  242. package/src/runtime-plugin-support.ts +13 -0
  243. package/src/runtime-plugin.ts +626 -0
  244. package/src/specs/terminal-startup.md +64 -0
  245. package/src/syntax-style.test.ts +841 -0
  246. package/src/syntax-style.ts +274 -0
  247. package/src/testing/README.md +219 -0
  248. package/src/testing/bun-test-node.ts +880 -0
  249. package/src/testing/capture-spans.test.ts +216 -0
  250. package/src/testing/integration.test.ts +276 -0
  251. package/src/testing/manual-clock.ts +117 -0
  252. package/src/testing/mock-keys.test.ts +1378 -0
  253. package/src/testing/mock-keys.ts +457 -0
  254. package/src/testing/mock-mouse.test.ts +218 -0
  255. package/src/testing/mock-mouse.ts +247 -0
  256. package/src/testing/mock-tree-sitter-client.ts +81 -0
  257. package/src/testing/spy.ts +13 -0
  258. package/src/testing/terminal-capabilities.ts +47 -0
  259. package/src/testing/test-recorder.test.ts +410 -0
  260. package/src/testing/test-recorder.ts +133 -0
  261. package/src/testing/test-renderer.ts +375 -0
  262. package/src/testing/test-renderer.wait.test.ts +278 -0
  263. package/src/testing/test-streams.ts +31 -0
  264. package/src/testing.ts +9 -0
  265. package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +481 -0
  266. package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +19 -0
  267. package/src/tests/__snapshots__/scrollbox.test.ts.snap +29 -0
  268. package/src/tests/absolute-positioning.snapshot.test.ts +638 -0
  269. package/src/tests/allocator-stats.test.ts +53 -0
  270. package/src/tests/audio.test.ts +303 -0
  271. package/src/tests/destroy-during-render.test.ts +200 -0
  272. package/src/tests/destroy-on-exit.fixture.ts +36 -0
  273. package/src/tests/destroy-on-exit.test.ts +62 -0
  274. package/src/tests/ffi-borrowed-pointer-callsites.test.ts +153 -0
  275. package/src/tests/hover-cursor.test.ts +98 -0
  276. package/src/tests/native-backed-measurement-lifecycle.test.ts +133 -0
  277. package/src/tests/native-backed-measurement-parity.test.ts +322 -0
  278. package/src/tests/native-span-feed-async.test.ts +173 -0
  279. package/src/tests/native-span-feed-close.test.ts +120 -0
  280. package/src/tests/native-span-feed-coverage.test.ts +227 -0
  281. package/src/tests/native-span-feed-edge-cases.test.ts +384 -0
  282. package/src/tests/native-span-feed-use-after-free.test.ts +45 -0
  283. package/src/tests/opacity.test.ts +123 -0
  284. package/src/tests/renderable.snapshot.test.ts +524 -0
  285. package/src/tests/renderable.test.ts +1851 -0
  286. package/src/tests/renderer.clock.test.ts +270 -0
  287. package/src/tests/renderer.console-startup.test.ts +2151 -0
  288. package/src/tests/renderer.control.test.ts +458 -0
  289. package/src/tests/renderer.core-slot-binding.test.ts +962 -0
  290. package/src/tests/renderer.cursor.test.ts +26 -0
  291. package/src/tests/renderer.custom-stdout.test.ts +1112 -0
  292. package/src/tests/renderer.destroy-during-render.test.ts +147 -0
  293. package/src/tests/renderer.focus-restore.test.ts +257 -0
  294. package/src/tests/renderer.focus.test.ts +329 -0
  295. package/src/tests/renderer.idle.test.ts +219 -0
  296. package/src/tests/renderer.input.test.ts +2615 -0
  297. package/src/tests/renderer.kitty-flags.test.ts +195 -0
  298. package/src/tests/renderer.lifecycle.test.ts +34 -0
  299. package/src/tests/renderer.mouse.test.ts +1315 -0
  300. package/src/tests/renderer.notifications.test.ts +27 -0
  301. package/src/tests/renderer.palette.test.ts +1199 -0
  302. package/src/tests/renderer.remote.test.ts +247 -0
  303. package/src/tests/renderer.render-stats.test.ts +146 -0
  304. package/src/tests/renderer.scrollback-surface.test.ts +474 -0
  305. package/src/tests/renderer.selection.test.ts +138 -0
  306. package/src/tests/renderer.slot-registry.test.ts +684 -0
  307. package/src/tests/renderer.tracker.test.ts +202 -0
  308. package/src/tests/renderer.useMouse.test.ts +83 -0
  309. package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +76 -0
  310. package/src/tests/runtime-plugin-node-modules-import-like-string.fixture.ts +48 -0
  311. package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +43 -0
  312. package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +67 -0
  313. package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +72 -0
  314. package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +44 -0
  315. package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +85 -0
  316. package/src/tests/runtime-plugin-path-alias.fixture.ts +43 -0
  317. package/src/tests/runtime-plugin-resolve-roots.fixture.ts +65 -0
  318. package/src/tests/runtime-plugin-support-configure.fixture.ts +31 -0
  319. package/src/tests/runtime-plugin-support-late-addition.fixture.ts +17 -0
  320. package/src/tests/runtime-plugin-support.fixture.ts +11 -0
  321. package/src/tests/runtime-plugin-support.test.ts +54 -0
  322. package/src/tests/runtime-plugin-windows-file-url.fixture.ts +30 -0
  323. package/src/tests/runtime-plugin.fixture.ts +40 -0
  324. package/src/tests/runtime-plugin.test.ts +369 -0
  325. package/src/tests/scrollbox-culling-bug.test.ts +114 -0
  326. package/src/tests/scrollbox-hitgrid-resize.test.ts +136 -0
  327. package/src/tests/scrollbox-hitgrid.test.ts +909 -0
  328. package/src/tests/scrollbox.test.ts +1895 -0
  329. package/src/tests/wrap-resize-perf.test.ts +276 -0
  330. package/src/tests/yoga-api-coverage.test.ts +409 -0
  331. package/src/tests/yoga-callback-stress.test.ts +122 -0
  332. package/src/tests/yoga-ffi.test.ts +117 -0
  333. package/src/tests/yoga-setters.test.ts +921 -0
  334. package/src/tests/yoga-upstream/YGAlignBaselineTest.test.ts +124 -0
  335. package/src/tests/yoga-upstream/YGComputedBorderTest.test.ts +27 -0
  336. package/src/tests/yoga-upstream/YGComputedMarginTest.test.ts +27 -0
  337. package/src/tests/yoga-upstream/YGComputedPaddingTest.test.ts +27 -0
  338. package/src/tests/yoga-upstream/YGDirtiedTest.test.ts +157 -0
  339. package/src/tests/yoga-upstream/YGErrataTest.test.ts +40 -0
  340. package/src/tests/yoga-upstream/YGFlexBasisAuto.test.ts +23 -0
  341. package/src/tests/yoga-upstream/YGHasNewLayout.test.ts +81 -0
  342. package/src/tests/yoga-upstream/YGMeasureCacheTest.test.ts +31 -0
  343. package/src/tests/yoga-upstream/YGMeasureTest.test.ts +70 -0
  344. package/src/tests/yoga-upstream/generated/YGAbsolutePositionTest.test.ts +1864 -0
  345. package/src/tests/yoga-upstream/generated/YGAlignContentTest.test.ts +5829 -0
  346. package/src/tests/yoga-upstream/generated/YGAlignItemsTest.test.ts +2444 -0
  347. package/src/tests/yoga-upstream/generated/YGAlignSelfTest.test.ts +293 -0
  348. package/src/tests/yoga-upstream/generated/YGAndroidNewsFeed.test.ts +315 -0
  349. package/src/tests/yoga-upstream/generated/YGAspectRatioTest.test.ts +231 -0
  350. package/src/tests/yoga-upstream/generated/YGAutoTest.test.ts +347 -0
  351. package/src/tests/yoga-upstream/generated/YGBorderTest.test.ts +256 -0
  352. package/src/tests/yoga-upstream/generated/YGBoxSizingTest.test.ts +2747 -0
  353. package/src/tests/yoga-upstream/generated/YGDimensionTest.test.ts +129 -0
  354. package/src/tests/yoga-upstream/generated/YGDisplayContentsTest.test.ts +109 -0
  355. package/src/tests/yoga-upstream/generated/YGDisplayTest.test.ts +1097 -0
  356. package/src/tests/yoga-upstream/generated/YGFlexDirectionTest.test.ts +4562 -0
  357. package/src/tests/yoga-upstream/generated/YGFlexTest.test.ts +677 -0
  358. package/src/tests/yoga-upstream/generated/YGFlexWrapTest.test.ts +2071 -0
  359. package/src/tests/yoga-upstream/generated/YGGapTest.test.ts +3303 -0
  360. package/src/tests/yoga-upstream/generated/YGIntrinsicSizeTest.test.ts +582 -0
  361. package/src/tests/yoga-upstream/generated/YGJustifyContentTest.test.ts +2150 -0
  362. package/src/tests/yoga-upstream/generated/YGMarginTest.test.ts +1963 -0
  363. package/src/tests/yoga-upstream/generated/YGMinMaxDimensionTest.test.ts +1446 -0
  364. package/src/tests/yoga-upstream/generated/YGPaddingTest.test.ts +354 -0
  365. package/src/tests/yoga-upstream/generated/YGPercentageTest.test.ts +1760 -0
  366. package/src/tests/yoga-upstream/generated/YGRoundingTest.test.ts +1161 -0
  367. package/src/tests/yoga-upstream/generated/YGSizeOverflowTest.test.ts +207 -0
  368. package/src/tests/yoga-upstream/generated/YGStaticPositionTest.test.ts +6338 -0
  369. package/src/tests/yoga-upstream/tools/MeasureCounter.ts +54 -0
  370. package/src/tests/yoga-upstream/tools/utils.ts +81 -0
  371. package/src/text-buffer-view.test.ts +722 -0
  372. package/src/text-buffer-view.ts +193 -0
  373. package/src/text-buffer.test.ts +512 -0
  374. package/src/text-buffer.ts +250 -0
  375. package/src/types.ts +199 -0
  376. package/src/utils.ts +88 -0
  377. package/src/yoga.ts +1146 -0
  378. package/src/zig/ansi.zig +502 -0
  379. package/src/zig/audio.zig +1206 -0
  380. package/src/zig/bench/README.md +50 -0
  381. package/src/zig/bench/buffer-color-blending_bench.zig +350 -0
  382. package/src/zig/bench/buffer-draw-box_bench.zig +786 -0
  383. package/src/zig/bench/buffer-draw-text-buffer_bench.zig +894 -0
  384. package/src/zig/bench/edit-buffer_bench.zig +476 -0
  385. package/src/zig/bench/editor-view_bench.zig +169 -0
  386. package/src/zig/bench/native-span-feed_bench.zig +107 -0
  387. package/src/zig/bench/rope-markers_bench.zig +713 -0
  388. package/src/zig/bench/rope_bench.zig +514 -0
  389. package/src/zig/bench/styled-text_bench.zig +476 -0
  390. package/src/zig/bench/text-buffer-coords_bench.zig +362 -0
  391. package/src/zig/bench/text-buffer-view_bench.zig +459 -0
  392. package/src/zig/bench/text-chunk-graphemes_bench.zig +272 -0
  393. package/src/zig/bench/utf8_bench.zig +799 -0
  394. package/src/zig/bench-utils.zig +431 -0
  395. package/src/zig/bench.zig +223 -0
  396. package/src/zig/buffer-methods.zig +215 -0
  397. package/src/zig/buffer.zig +2515 -0
  398. package/src/zig/build.zig +700 -0
  399. package/src/zig/build.zig.zon +19 -0
  400. package/src/zig/edit-buffer.zig +900 -0
  401. package/src/zig/editor-view.zig +812 -0
  402. package/src/zig/event-bus.zig +28 -0
  403. package/src/zig/event-emitter.zig +65 -0
  404. package/src/zig/file-logger.zig +92 -0
  405. package/src/zig/grapheme.zig +838 -0
  406. package/src/zig/handles.zig +267 -0
  407. package/src/zig/lib.zig +2813 -0
  408. package/src/zig/link.zig +349 -0
  409. package/src/zig/logger.zig +43 -0
  410. package/src/zig/mem-registry.zig +126 -0
  411. package/src/zig/miniaudio_shim.c +21 -0
  412. package/src/zig/native-renderable.zig +112 -0
  413. package/src/zig/native-span-feed-bench-lib.zig +7 -0
  414. package/src/zig/native-span-feed.zig +747 -0
  415. package/src/zig/renderer-output.zig +677 -0
  416. package/src/zig/renderer.zig +2106 -0
  417. package/src/zig/rope.zig +1220 -0
  418. package/src/zig/split-scrollback.zig +88 -0
  419. package/src/zig/syntax-style.zig +174 -0
  420. package/src/zig/terminal.zig +1652 -0
  421. package/src/zig/test.zig +82 -0
  422. package/src/zig/tests/README.md +18 -0
  423. package/src/zig/tests/ansi_test.zig +18 -0
  424. package/src/zig/tests/audio_test.zig +439 -0
  425. package/src/zig/tests/buffer-methods_test.zig +1111 -0
  426. package/src/zig/tests/buffer_test.zig +2926 -0
  427. package/src/zig/tests/edit-buffer-history_test.zig +299 -0
  428. package/src/zig/tests/edit-buffer_test.zig +1688 -0
  429. package/src/zig/tests/editor-view_test.zig +3454 -0
  430. package/src/zig/tests/event-emitter_test.zig +249 -0
  431. package/src/zig/tests/grapheme_test.zig +1329 -0
  432. package/src/zig/tests/handles_test.zig +123 -0
  433. package/src/zig/tests/link_test.zig +220 -0
  434. package/src/zig/tests/mem-registry_test.zig +473 -0
  435. package/src/zig/tests/memory_leak_regression_test.zig +234 -0
  436. package/src/zig/tests/native-renderable_test.zig +16 -0
  437. package/src/zig/tests/native-span-feed_test.zig +1266 -0
  438. package/src/zig/tests/renderer_test.zig +2604 -0
  439. package/src/zig/tests/rope-nested_test.zig +712 -0
  440. package/src/zig/tests/rope_fuzz_test.zig +238 -0
  441. package/src/zig/tests/rope_test.zig +2362 -0
  442. package/src/zig/tests/segment-merge.test.zig +148 -0
  443. package/src/zig/tests/split-scrollback_test.zig +70 -0
  444. package/src/zig/tests/syntax-style_test.zig +558 -0
  445. package/src/zig/tests/terminal_test.zig +1489 -0
  446. package/src/zig/tests/test-renderer.zig +126 -0
  447. package/src/zig/tests/text-buffer-drawing_test.zig +3291 -0
  448. package/src/zig/tests/text-buffer-highlights_test.zig +706 -0
  449. package/src/zig/tests/text-buffer-iterators_test.zig +776 -0
  450. package/src/zig/tests/text-buffer-segment_test.zig +320 -0
  451. package/src/zig/tests/text-buffer-selection_test.zig +1056 -0
  452. package/src/zig/tests/text-buffer-selection_viewport_test.zig +358 -0
  453. package/src/zig/tests/text-buffer-view_test.zig +3672 -0
  454. package/src/zig/tests/text-buffer_test.zig +2191 -0
  455. package/src/zig/tests/unicode-width-map.zon +3909 -0
  456. package/src/zig/tests/utf8_no_zwj_test.zig +260 -0
  457. package/src/zig/tests/utf8_test.zig +4060 -0
  458. package/src/zig/tests/utf8_wcwidth_cursor_test.zig +267 -0
  459. package/src/zig/tests/utf8_wcwidth_test.zig +357 -0
  460. package/src/zig/tests/word-wrap-editing_test.zig +498 -0
  461. package/src/zig/tests/wrap-cache-perf_test.zig +113 -0
  462. package/src/zig/tests/yoga_test.zig +65 -0
  463. package/src/zig/text-buffer-iterators.zig +496 -0
  464. package/src/zig/text-buffer-segment.zig +403 -0
  465. package/src/zig/text-buffer-view.zig +1428 -0
  466. package/src/zig/text-buffer.zig +1272 -0
  467. package/src/zig/utf8.zig +1954 -0
  468. package/src/zig/utils.zig +12 -0
  469. package/src/zig/uucode-stub.zig +76 -0
  470. package/src/zig/vendor/miniaudio/miniaudio.h +93468 -0
  471. package/src/zig/yoga.zig +658 -0
  472. package/src/zig-structs.ts +381 -0
  473. package/src/zig.ts +5260 -0
  474. package/tsconfig.build.json +17 -0
  475. package/tsconfig.json +27 -0
  476. package/tsconfig.node-test.json +138 -0
@@ -0,0 +1,1760 @@
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
+ * @generated SignedSource<<091fb5c6d9004e40211bba58ac19d686>>
8
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
9
+ */
10
+
11
+ import { instrinsicSizeMeasureFunc } from "../tools/utils.ts"
12
+ import Yoga from "../../../yoga.js"
13
+ import {
14
+ Align,
15
+ BoxSizing,
16
+ Direction,
17
+ Display,
18
+ Edge,
19
+ Errata,
20
+ ExperimentalFeature,
21
+ FlexDirection,
22
+ Gutter,
23
+ Justify,
24
+ MeasureMode,
25
+ Overflow,
26
+ PositionType,
27
+ Unit,
28
+ Wrap,
29
+ } from "../../../yoga.js"
30
+
31
+ test("percentage_width_height", () => {
32
+ const config = Yoga.Config.create()
33
+ let root
34
+
35
+ try {
36
+ root = Yoga.Node.create(config)
37
+ root.setFlexDirection(FlexDirection.Row)
38
+ root.setPositionType(PositionType.Absolute)
39
+ root.setWidth(200)
40
+ root.setHeight(200)
41
+
42
+ const root_child0 = Yoga.Node.create(config)
43
+ root_child0.setWidth("30%")
44
+ root_child0.setHeight("30%")
45
+ root.insertChild(root_child0, 0)
46
+ root.calculateLayout(undefined, undefined, Direction.LTR)
47
+
48
+ expect(root.getComputedLeft()).toBe(0)
49
+ expect(root.getComputedTop()).toBe(0)
50
+ expect(root.getComputedWidth()).toBe(200)
51
+ expect(root.getComputedHeight()).toBe(200)
52
+
53
+ expect(root_child0.getComputedLeft()).toBe(0)
54
+ expect(root_child0.getComputedTop()).toBe(0)
55
+ expect(root_child0.getComputedWidth()).toBe(60)
56
+ expect(root_child0.getComputedHeight()).toBe(60)
57
+
58
+ root.calculateLayout(undefined, undefined, Direction.RTL)
59
+
60
+ expect(root.getComputedLeft()).toBe(0)
61
+ expect(root.getComputedTop()).toBe(0)
62
+ expect(root.getComputedWidth()).toBe(200)
63
+ expect(root.getComputedHeight()).toBe(200)
64
+
65
+ expect(root_child0.getComputedLeft()).toBe(140)
66
+ expect(root_child0.getComputedTop()).toBe(0)
67
+ expect(root_child0.getComputedWidth()).toBe(60)
68
+ expect(root_child0.getComputedHeight()).toBe(60)
69
+ } finally {
70
+ if (typeof root !== "undefined") {
71
+ root.freeRecursive()
72
+ }
73
+
74
+ config.free()
75
+ }
76
+ })
77
+ test("percentage_position_left_top", () => {
78
+ const config = Yoga.Config.create()
79
+ let root
80
+
81
+ try {
82
+ root = Yoga.Node.create(config)
83
+ root.setFlexDirection(FlexDirection.Row)
84
+ root.setPositionType(PositionType.Absolute)
85
+ root.setWidth(400)
86
+ root.setHeight(400)
87
+
88
+ const root_child0 = Yoga.Node.create(config)
89
+ root_child0.setPosition(Edge.Left, "10%")
90
+ root_child0.setPosition(Edge.Top, "20%")
91
+ root_child0.setWidth("45%")
92
+ root_child0.setHeight("55%")
93
+ root.insertChild(root_child0, 0)
94
+ root.calculateLayout(undefined, undefined, Direction.LTR)
95
+
96
+ expect(root.getComputedLeft()).toBe(0)
97
+ expect(root.getComputedTop()).toBe(0)
98
+ expect(root.getComputedWidth()).toBe(400)
99
+ expect(root.getComputedHeight()).toBe(400)
100
+
101
+ expect(root_child0.getComputedLeft()).toBe(40)
102
+ expect(root_child0.getComputedTop()).toBe(80)
103
+ expect(root_child0.getComputedWidth()).toBe(180)
104
+ expect(root_child0.getComputedHeight()).toBe(220)
105
+
106
+ root.calculateLayout(undefined, undefined, Direction.RTL)
107
+
108
+ expect(root.getComputedLeft()).toBe(0)
109
+ expect(root.getComputedTop()).toBe(0)
110
+ expect(root.getComputedWidth()).toBe(400)
111
+ expect(root.getComputedHeight()).toBe(400)
112
+
113
+ expect(root_child0.getComputedLeft()).toBe(260)
114
+ expect(root_child0.getComputedTop()).toBe(80)
115
+ expect(root_child0.getComputedWidth()).toBe(180)
116
+ expect(root_child0.getComputedHeight()).toBe(220)
117
+ } finally {
118
+ if (typeof root !== "undefined") {
119
+ root.freeRecursive()
120
+ }
121
+
122
+ config.free()
123
+ }
124
+ })
125
+ test("percentage_position_bottom_right", () => {
126
+ const config = Yoga.Config.create()
127
+ let root
128
+
129
+ try {
130
+ root = Yoga.Node.create(config)
131
+ root.setFlexDirection(FlexDirection.Row)
132
+ root.setPositionType(PositionType.Absolute)
133
+ root.setWidth(500)
134
+ root.setHeight(500)
135
+
136
+ const root_child0 = Yoga.Node.create(config)
137
+ root_child0.setPosition(Edge.Right, "20%")
138
+ root_child0.setPosition(Edge.Bottom, "10%")
139
+ root_child0.setWidth("55%")
140
+ root_child0.setHeight("15%")
141
+ root.insertChild(root_child0, 0)
142
+ root.calculateLayout(undefined, undefined, Direction.LTR)
143
+
144
+ expect(root.getComputedLeft()).toBe(0)
145
+ expect(root.getComputedTop()).toBe(0)
146
+ expect(root.getComputedWidth()).toBe(500)
147
+ expect(root.getComputedHeight()).toBe(500)
148
+
149
+ expect(root_child0.getComputedLeft()).toBe(-100)
150
+ expect(root_child0.getComputedTop()).toBe(-50)
151
+ expect(root_child0.getComputedWidth()).toBe(275)
152
+ expect(root_child0.getComputedHeight()).toBe(75)
153
+
154
+ root.calculateLayout(undefined, undefined, Direction.RTL)
155
+
156
+ expect(root.getComputedLeft()).toBe(0)
157
+ expect(root.getComputedTop()).toBe(0)
158
+ expect(root.getComputedWidth()).toBe(500)
159
+ expect(root.getComputedHeight()).toBe(500)
160
+
161
+ expect(root_child0.getComputedLeft()).toBe(125)
162
+ expect(root_child0.getComputedTop()).toBe(-50)
163
+ expect(root_child0.getComputedWidth()).toBe(275)
164
+ expect(root_child0.getComputedHeight()).toBe(75)
165
+ } finally {
166
+ if (typeof root !== "undefined") {
167
+ root.freeRecursive()
168
+ }
169
+
170
+ config.free()
171
+ }
172
+ })
173
+ test("percentage_flex_basis", () => {
174
+ const config = Yoga.Config.create()
175
+ let root
176
+
177
+ try {
178
+ root = Yoga.Node.create(config)
179
+ root.setFlexDirection(FlexDirection.Row)
180
+ root.setPositionType(PositionType.Absolute)
181
+ root.setWidth(200)
182
+ root.setHeight(200)
183
+
184
+ const root_child0 = Yoga.Node.create(config)
185
+ root_child0.setFlexGrow(1)
186
+ root_child0.setFlexBasis("50%")
187
+ root.insertChild(root_child0, 0)
188
+
189
+ const root_child1 = Yoga.Node.create(config)
190
+ root_child1.setFlexGrow(1)
191
+ root_child1.setFlexBasis("25%")
192
+ root.insertChild(root_child1, 1)
193
+ root.calculateLayout(undefined, undefined, Direction.LTR)
194
+
195
+ expect(root.getComputedLeft()).toBe(0)
196
+ expect(root.getComputedTop()).toBe(0)
197
+ expect(root.getComputedWidth()).toBe(200)
198
+ expect(root.getComputedHeight()).toBe(200)
199
+
200
+ expect(root_child0.getComputedLeft()).toBe(0)
201
+ expect(root_child0.getComputedTop()).toBe(0)
202
+ expect(root_child0.getComputedWidth()).toBe(125)
203
+ expect(root_child0.getComputedHeight()).toBe(200)
204
+
205
+ expect(root_child1.getComputedLeft()).toBe(125)
206
+ expect(root_child1.getComputedTop()).toBe(0)
207
+ expect(root_child1.getComputedWidth()).toBe(75)
208
+ expect(root_child1.getComputedHeight()).toBe(200)
209
+
210
+ root.calculateLayout(undefined, undefined, Direction.RTL)
211
+
212
+ expect(root.getComputedLeft()).toBe(0)
213
+ expect(root.getComputedTop()).toBe(0)
214
+ expect(root.getComputedWidth()).toBe(200)
215
+ expect(root.getComputedHeight()).toBe(200)
216
+
217
+ expect(root_child0.getComputedLeft()).toBe(75)
218
+ expect(root_child0.getComputedTop()).toBe(0)
219
+ expect(root_child0.getComputedWidth()).toBe(125)
220
+ expect(root_child0.getComputedHeight()).toBe(200)
221
+
222
+ expect(root_child1.getComputedLeft()).toBe(0)
223
+ expect(root_child1.getComputedTop()).toBe(0)
224
+ expect(root_child1.getComputedWidth()).toBe(75)
225
+ expect(root_child1.getComputedHeight()).toBe(200)
226
+ } finally {
227
+ if (typeof root !== "undefined") {
228
+ root.freeRecursive()
229
+ }
230
+
231
+ config.free()
232
+ }
233
+ })
234
+ test("percentage_flex_basis_cross", () => {
235
+ const config = Yoga.Config.create()
236
+ let root
237
+
238
+ try {
239
+ root = Yoga.Node.create(config)
240
+ root.setPositionType(PositionType.Absolute)
241
+ root.setWidth(200)
242
+ root.setHeight(200)
243
+
244
+ const root_child0 = Yoga.Node.create(config)
245
+ root_child0.setFlexGrow(1)
246
+ root_child0.setFlexBasis("50%")
247
+ root.insertChild(root_child0, 0)
248
+
249
+ const root_child1 = Yoga.Node.create(config)
250
+ root_child1.setFlexGrow(1)
251
+ root_child1.setFlexBasis("25%")
252
+ root.insertChild(root_child1, 1)
253
+ root.calculateLayout(undefined, undefined, Direction.LTR)
254
+
255
+ expect(root.getComputedLeft()).toBe(0)
256
+ expect(root.getComputedTop()).toBe(0)
257
+ expect(root.getComputedWidth()).toBe(200)
258
+ expect(root.getComputedHeight()).toBe(200)
259
+
260
+ expect(root_child0.getComputedLeft()).toBe(0)
261
+ expect(root_child0.getComputedTop()).toBe(0)
262
+ expect(root_child0.getComputedWidth()).toBe(200)
263
+ expect(root_child0.getComputedHeight()).toBe(125)
264
+
265
+ expect(root_child1.getComputedLeft()).toBe(0)
266
+ expect(root_child1.getComputedTop()).toBe(125)
267
+ expect(root_child1.getComputedWidth()).toBe(200)
268
+ expect(root_child1.getComputedHeight()).toBe(75)
269
+
270
+ root.calculateLayout(undefined, undefined, Direction.RTL)
271
+
272
+ expect(root.getComputedLeft()).toBe(0)
273
+ expect(root.getComputedTop()).toBe(0)
274
+ expect(root.getComputedWidth()).toBe(200)
275
+ expect(root.getComputedHeight()).toBe(200)
276
+
277
+ expect(root_child0.getComputedLeft()).toBe(0)
278
+ expect(root_child0.getComputedTop()).toBe(0)
279
+ expect(root_child0.getComputedWidth()).toBe(200)
280
+ expect(root_child0.getComputedHeight()).toBe(125)
281
+
282
+ expect(root_child1.getComputedLeft()).toBe(0)
283
+ expect(root_child1.getComputedTop()).toBe(125)
284
+ expect(root_child1.getComputedWidth()).toBe(200)
285
+ expect(root_child1.getComputedHeight()).toBe(75)
286
+ } finally {
287
+ if (typeof root !== "undefined") {
288
+ root.freeRecursive()
289
+ }
290
+
291
+ config.free()
292
+ }
293
+ })
294
+ test.skip("percentage_flex_basis_cross_min_height", () => {
295
+ const config = Yoga.Config.create()
296
+ let root
297
+
298
+ try {
299
+ root = Yoga.Node.create(config)
300
+ root.setPositionType(PositionType.Absolute)
301
+ root.setWidth(200)
302
+ root.setHeight(200)
303
+
304
+ const root_child0 = Yoga.Node.create(config)
305
+ root_child0.setFlexGrow(1)
306
+ root_child0.setMinHeight("60%")
307
+ root.insertChild(root_child0, 0)
308
+
309
+ const root_child1 = Yoga.Node.create(config)
310
+ root_child1.setFlexGrow(2)
311
+ root_child1.setMinHeight("10%")
312
+ root.insertChild(root_child1, 1)
313
+ root.calculateLayout(undefined, undefined, Direction.LTR)
314
+
315
+ expect(root.getComputedLeft()).toBe(0)
316
+ expect(root.getComputedTop()).toBe(0)
317
+ expect(root.getComputedWidth()).toBe(200)
318
+ expect(root.getComputedHeight()).toBe(200)
319
+
320
+ expect(root_child0.getComputedLeft()).toBe(0)
321
+ expect(root_child0.getComputedTop()).toBe(0)
322
+ expect(root_child0.getComputedWidth()).toBe(200)
323
+ expect(root_child0.getComputedHeight()).toBe(120)
324
+
325
+ expect(root_child1.getComputedLeft()).toBe(0)
326
+ expect(root_child1.getComputedTop()).toBe(120)
327
+ expect(root_child1.getComputedWidth()).toBe(200)
328
+ expect(root_child1.getComputedHeight()).toBe(80)
329
+
330
+ root.calculateLayout(undefined, undefined, Direction.RTL)
331
+
332
+ expect(root.getComputedLeft()).toBe(0)
333
+ expect(root.getComputedTop()).toBe(0)
334
+ expect(root.getComputedWidth()).toBe(200)
335
+ expect(root.getComputedHeight()).toBe(200)
336
+
337
+ expect(root_child0.getComputedLeft()).toBe(0)
338
+ expect(root_child0.getComputedTop()).toBe(0)
339
+ expect(root_child0.getComputedWidth()).toBe(200)
340
+ expect(root_child0.getComputedHeight()).toBe(120)
341
+
342
+ expect(root_child1.getComputedLeft()).toBe(0)
343
+ expect(root_child1.getComputedTop()).toBe(120)
344
+ expect(root_child1.getComputedWidth()).toBe(200)
345
+ expect(root_child1.getComputedHeight()).toBe(80)
346
+ } finally {
347
+ if (typeof root !== "undefined") {
348
+ root.freeRecursive()
349
+ }
350
+
351
+ config.free()
352
+ }
353
+ })
354
+ test("percentage_flex_basis_main_max_height", () => {
355
+ const config = Yoga.Config.create()
356
+ let root
357
+
358
+ try {
359
+ root = Yoga.Node.create(config)
360
+ root.setFlexDirection(FlexDirection.Row)
361
+ root.setPositionType(PositionType.Absolute)
362
+ root.setWidth(200)
363
+ root.setHeight(200)
364
+
365
+ const root_child0 = Yoga.Node.create(config)
366
+ root_child0.setFlexGrow(1)
367
+ root_child0.setFlexBasis("10%")
368
+ root_child0.setMaxHeight("60%")
369
+ root.insertChild(root_child0, 0)
370
+
371
+ const root_child1 = Yoga.Node.create(config)
372
+ root_child1.setFlexGrow(4)
373
+ root_child1.setFlexBasis("10%")
374
+ root_child1.setMaxHeight("20%")
375
+ root.insertChild(root_child1, 1)
376
+ root.calculateLayout(undefined, undefined, Direction.LTR)
377
+
378
+ expect(root.getComputedLeft()).toBe(0)
379
+ expect(root.getComputedTop()).toBe(0)
380
+ expect(root.getComputedWidth()).toBe(200)
381
+ expect(root.getComputedHeight()).toBe(200)
382
+
383
+ expect(root_child0.getComputedLeft()).toBe(0)
384
+ expect(root_child0.getComputedTop()).toBe(0)
385
+ expect(root_child0.getComputedWidth()).toBe(52)
386
+ expect(root_child0.getComputedHeight()).toBe(120)
387
+
388
+ expect(root_child1.getComputedLeft()).toBe(52)
389
+ expect(root_child1.getComputedTop()).toBe(0)
390
+ expect(root_child1.getComputedWidth()).toBe(148)
391
+ expect(root_child1.getComputedHeight()).toBe(40)
392
+
393
+ root.calculateLayout(undefined, undefined, Direction.RTL)
394
+
395
+ expect(root.getComputedLeft()).toBe(0)
396
+ expect(root.getComputedTop()).toBe(0)
397
+ expect(root.getComputedWidth()).toBe(200)
398
+ expect(root.getComputedHeight()).toBe(200)
399
+
400
+ expect(root_child0.getComputedLeft()).toBe(148)
401
+ expect(root_child0.getComputedTop()).toBe(0)
402
+ expect(root_child0.getComputedWidth()).toBe(52)
403
+ expect(root_child0.getComputedHeight()).toBe(120)
404
+
405
+ expect(root_child1.getComputedLeft()).toBe(0)
406
+ expect(root_child1.getComputedTop()).toBe(0)
407
+ expect(root_child1.getComputedWidth()).toBe(148)
408
+ expect(root_child1.getComputedHeight()).toBe(40)
409
+ } finally {
410
+ if (typeof root !== "undefined") {
411
+ root.freeRecursive()
412
+ }
413
+
414
+ config.free()
415
+ }
416
+ })
417
+ test("percentage_flex_basis_cross_max_height", () => {
418
+ const config = Yoga.Config.create()
419
+ let root
420
+
421
+ try {
422
+ root = Yoga.Node.create(config)
423
+ root.setPositionType(PositionType.Absolute)
424
+ root.setWidth(200)
425
+ root.setHeight(200)
426
+
427
+ const root_child0 = Yoga.Node.create(config)
428
+ root_child0.setFlexGrow(1)
429
+ root_child0.setFlexBasis("10%")
430
+ root_child0.setMaxHeight("60%")
431
+ root.insertChild(root_child0, 0)
432
+
433
+ const root_child1 = Yoga.Node.create(config)
434
+ root_child1.setFlexGrow(4)
435
+ root_child1.setFlexBasis("10%")
436
+ root_child1.setMaxHeight("20%")
437
+ root.insertChild(root_child1, 1)
438
+ root.calculateLayout(undefined, undefined, Direction.LTR)
439
+
440
+ expect(root.getComputedLeft()).toBe(0)
441
+ expect(root.getComputedTop()).toBe(0)
442
+ expect(root.getComputedWidth()).toBe(200)
443
+ expect(root.getComputedHeight()).toBe(200)
444
+
445
+ expect(root_child0.getComputedLeft()).toBe(0)
446
+ expect(root_child0.getComputedTop()).toBe(0)
447
+ expect(root_child0.getComputedWidth()).toBe(200)
448
+ expect(root_child0.getComputedHeight()).toBe(120)
449
+
450
+ expect(root_child1.getComputedLeft()).toBe(0)
451
+ expect(root_child1.getComputedTop()).toBe(120)
452
+ expect(root_child1.getComputedWidth()).toBe(200)
453
+ expect(root_child1.getComputedHeight()).toBe(40)
454
+
455
+ root.calculateLayout(undefined, undefined, Direction.RTL)
456
+
457
+ expect(root.getComputedLeft()).toBe(0)
458
+ expect(root.getComputedTop()).toBe(0)
459
+ expect(root.getComputedWidth()).toBe(200)
460
+ expect(root.getComputedHeight()).toBe(200)
461
+
462
+ expect(root_child0.getComputedLeft()).toBe(0)
463
+ expect(root_child0.getComputedTop()).toBe(0)
464
+ expect(root_child0.getComputedWidth()).toBe(200)
465
+ expect(root_child0.getComputedHeight()).toBe(120)
466
+
467
+ expect(root_child1.getComputedLeft()).toBe(0)
468
+ expect(root_child1.getComputedTop()).toBe(120)
469
+ expect(root_child1.getComputedWidth()).toBe(200)
470
+ expect(root_child1.getComputedHeight()).toBe(40)
471
+ } finally {
472
+ if (typeof root !== "undefined") {
473
+ root.freeRecursive()
474
+ }
475
+
476
+ config.free()
477
+ }
478
+ })
479
+ test("percentage_flex_basis_main_max_width", () => {
480
+ const config = Yoga.Config.create()
481
+ let root
482
+
483
+ try {
484
+ root = Yoga.Node.create(config)
485
+ root.setFlexDirection(FlexDirection.Row)
486
+ root.setPositionType(PositionType.Absolute)
487
+ root.setWidth(200)
488
+ root.setHeight(200)
489
+
490
+ const root_child0 = Yoga.Node.create(config)
491
+ root_child0.setFlexGrow(1)
492
+ root_child0.setFlexBasis("15%")
493
+ root_child0.setMaxWidth("60%")
494
+ root.insertChild(root_child0, 0)
495
+
496
+ const root_child1 = Yoga.Node.create(config)
497
+ root_child1.setFlexGrow(4)
498
+ root_child1.setFlexBasis("10%")
499
+ root_child1.setMaxWidth("20%")
500
+ root.insertChild(root_child1, 1)
501
+ root.calculateLayout(undefined, undefined, Direction.LTR)
502
+
503
+ expect(root.getComputedLeft()).toBe(0)
504
+ expect(root.getComputedTop()).toBe(0)
505
+ expect(root.getComputedWidth()).toBe(200)
506
+ expect(root.getComputedHeight()).toBe(200)
507
+
508
+ expect(root_child0.getComputedLeft()).toBe(0)
509
+ expect(root_child0.getComputedTop()).toBe(0)
510
+ expect(root_child0.getComputedWidth()).toBe(120)
511
+ expect(root_child0.getComputedHeight()).toBe(200)
512
+
513
+ expect(root_child1.getComputedLeft()).toBe(120)
514
+ expect(root_child1.getComputedTop()).toBe(0)
515
+ expect(root_child1.getComputedWidth()).toBe(40)
516
+ expect(root_child1.getComputedHeight()).toBe(200)
517
+
518
+ root.calculateLayout(undefined, undefined, Direction.RTL)
519
+
520
+ expect(root.getComputedLeft()).toBe(0)
521
+ expect(root.getComputedTop()).toBe(0)
522
+ expect(root.getComputedWidth()).toBe(200)
523
+ expect(root.getComputedHeight()).toBe(200)
524
+
525
+ expect(root_child0.getComputedLeft()).toBe(80)
526
+ expect(root_child0.getComputedTop()).toBe(0)
527
+ expect(root_child0.getComputedWidth()).toBe(120)
528
+ expect(root_child0.getComputedHeight()).toBe(200)
529
+
530
+ expect(root_child1.getComputedLeft()).toBe(40)
531
+ expect(root_child1.getComputedTop()).toBe(0)
532
+ expect(root_child1.getComputedWidth()).toBe(40)
533
+ expect(root_child1.getComputedHeight()).toBe(200)
534
+ } finally {
535
+ if (typeof root !== "undefined") {
536
+ root.freeRecursive()
537
+ }
538
+
539
+ config.free()
540
+ }
541
+ })
542
+ test("percentage_flex_basis_cross_max_width", () => {
543
+ const config = Yoga.Config.create()
544
+ let root
545
+
546
+ try {
547
+ root = Yoga.Node.create(config)
548
+ root.setPositionType(PositionType.Absolute)
549
+ root.setWidth(200)
550
+ root.setHeight(200)
551
+
552
+ const root_child0 = Yoga.Node.create(config)
553
+ root_child0.setFlexGrow(1)
554
+ root_child0.setFlexBasis("10%")
555
+ root_child0.setMaxWidth("60%")
556
+ root.insertChild(root_child0, 0)
557
+
558
+ const root_child1 = Yoga.Node.create(config)
559
+ root_child1.setFlexGrow(4)
560
+ root_child1.setFlexBasis("15%")
561
+ root_child1.setMaxWidth("20%")
562
+ root.insertChild(root_child1, 1)
563
+ root.calculateLayout(undefined, undefined, Direction.LTR)
564
+
565
+ expect(root.getComputedLeft()).toBe(0)
566
+ expect(root.getComputedTop()).toBe(0)
567
+ expect(root.getComputedWidth()).toBe(200)
568
+ expect(root.getComputedHeight()).toBe(200)
569
+
570
+ expect(root_child0.getComputedLeft()).toBe(0)
571
+ expect(root_child0.getComputedTop()).toBe(0)
572
+ expect(root_child0.getComputedWidth()).toBe(120)
573
+ expect(root_child0.getComputedHeight()).toBe(50)
574
+
575
+ expect(root_child1.getComputedLeft()).toBe(0)
576
+ expect(root_child1.getComputedTop()).toBe(50)
577
+ expect(root_child1.getComputedWidth()).toBe(40)
578
+ expect(root_child1.getComputedHeight()).toBe(150)
579
+
580
+ root.calculateLayout(undefined, undefined, Direction.RTL)
581
+
582
+ expect(root.getComputedLeft()).toBe(0)
583
+ expect(root.getComputedTop()).toBe(0)
584
+ expect(root.getComputedWidth()).toBe(200)
585
+ expect(root.getComputedHeight()).toBe(200)
586
+
587
+ expect(root_child0.getComputedLeft()).toBe(80)
588
+ expect(root_child0.getComputedTop()).toBe(0)
589
+ expect(root_child0.getComputedWidth()).toBe(120)
590
+ expect(root_child0.getComputedHeight()).toBe(50)
591
+
592
+ expect(root_child1.getComputedLeft()).toBe(160)
593
+ expect(root_child1.getComputedTop()).toBe(50)
594
+ expect(root_child1.getComputedWidth()).toBe(40)
595
+ expect(root_child1.getComputedHeight()).toBe(150)
596
+ } finally {
597
+ if (typeof root !== "undefined") {
598
+ root.freeRecursive()
599
+ }
600
+
601
+ config.free()
602
+ }
603
+ })
604
+ test("percentage_flex_basis_main_min_width", () => {
605
+ const config = Yoga.Config.create()
606
+ let root
607
+
608
+ try {
609
+ root = Yoga.Node.create(config)
610
+ root.setFlexDirection(FlexDirection.Row)
611
+ root.setPositionType(PositionType.Absolute)
612
+ root.setWidth(200)
613
+ root.setHeight(200)
614
+
615
+ const root_child0 = Yoga.Node.create(config)
616
+ root_child0.setFlexGrow(1)
617
+ root_child0.setFlexBasis("15%")
618
+ root_child0.setMinWidth("60%")
619
+ root.insertChild(root_child0, 0)
620
+
621
+ const root_child1 = Yoga.Node.create(config)
622
+ root_child1.setFlexGrow(4)
623
+ root_child1.setFlexBasis("10%")
624
+ root_child1.setMinWidth("20%")
625
+ root.insertChild(root_child1, 1)
626
+ root.calculateLayout(undefined, undefined, Direction.LTR)
627
+
628
+ expect(root.getComputedLeft()).toBe(0)
629
+ expect(root.getComputedTop()).toBe(0)
630
+ expect(root.getComputedWidth()).toBe(200)
631
+ expect(root.getComputedHeight()).toBe(200)
632
+
633
+ expect(root_child0.getComputedLeft()).toBe(0)
634
+ expect(root_child0.getComputedTop()).toBe(0)
635
+ expect(root_child0.getComputedWidth()).toBe(120)
636
+ expect(root_child0.getComputedHeight()).toBe(200)
637
+
638
+ expect(root_child1.getComputedLeft()).toBe(120)
639
+ expect(root_child1.getComputedTop()).toBe(0)
640
+ expect(root_child1.getComputedWidth()).toBe(80)
641
+ expect(root_child1.getComputedHeight()).toBe(200)
642
+
643
+ root.calculateLayout(undefined, undefined, Direction.RTL)
644
+
645
+ expect(root.getComputedLeft()).toBe(0)
646
+ expect(root.getComputedTop()).toBe(0)
647
+ expect(root.getComputedWidth()).toBe(200)
648
+ expect(root.getComputedHeight()).toBe(200)
649
+
650
+ expect(root_child0.getComputedLeft()).toBe(80)
651
+ expect(root_child0.getComputedTop()).toBe(0)
652
+ expect(root_child0.getComputedWidth()).toBe(120)
653
+ expect(root_child0.getComputedHeight()).toBe(200)
654
+
655
+ expect(root_child1.getComputedLeft()).toBe(0)
656
+ expect(root_child1.getComputedTop()).toBe(0)
657
+ expect(root_child1.getComputedWidth()).toBe(80)
658
+ expect(root_child1.getComputedHeight()).toBe(200)
659
+ } finally {
660
+ if (typeof root !== "undefined") {
661
+ root.freeRecursive()
662
+ }
663
+
664
+ config.free()
665
+ }
666
+ })
667
+ test("percentage_flex_basis_cross_min_width", () => {
668
+ const config = Yoga.Config.create()
669
+ let root
670
+
671
+ try {
672
+ root = Yoga.Node.create(config)
673
+ root.setPositionType(PositionType.Absolute)
674
+ root.setWidth(200)
675
+ root.setHeight(200)
676
+
677
+ const root_child0 = Yoga.Node.create(config)
678
+ root_child0.setFlexGrow(1)
679
+ root_child0.setFlexBasis("10%")
680
+ root_child0.setMinWidth("60%")
681
+ root.insertChild(root_child0, 0)
682
+
683
+ const root_child1 = Yoga.Node.create(config)
684
+ root_child1.setFlexGrow(4)
685
+ root_child1.setFlexBasis("15%")
686
+ root_child1.setMinWidth("20%")
687
+ root.insertChild(root_child1, 1)
688
+ root.calculateLayout(undefined, undefined, Direction.LTR)
689
+
690
+ expect(root.getComputedLeft()).toBe(0)
691
+ expect(root.getComputedTop()).toBe(0)
692
+ expect(root.getComputedWidth()).toBe(200)
693
+ expect(root.getComputedHeight()).toBe(200)
694
+
695
+ expect(root_child0.getComputedLeft()).toBe(0)
696
+ expect(root_child0.getComputedTop()).toBe(0)
697
+ expect(root_child0.getComputedWidth()).toBe(200)
698
+ expect(root_child0.getComputedHeight()).toBe(50)
699
+
700
+ expect(root_child1.getComputedLeft()).toBe(0)
701
+ expect(root_child1.getComputedTop()).toBe(50)
702
+ expect(root_child1.getComputedWidth()).toBe(200)
703
+ expect(root_child1.getComputedHeight()).toBe(150)
704
+
705
+ root.calculateLayout(undefined, undefined, Direction.RTL)
706
+
707
+ expect(root.getComputedLeft()).toBe(0)
708
+ expect(root.getComputedTop()).toBe(0)
709
+ expect(root.getComputedWidth()).toBe(200)
710
+ expect(root.getComputedHeight()).toBe(200)
711
+
712
+ expect(root_child0.getComputedLeft()).toBe(0)
713
+ expect(root_child0.getComputedTop()).toBe(0)
714
+ expect(root_child0.getComputedWidth()).toBe(200)
715
+ expect(root_child0.getComputedHeight()).toBe(50)
716
+
717
+ expect(root_child1.getComputedLeft()).toBe(0)
718
+ expect(root_child1.getComputedTop()).toBe(50)
719
+ expect(root_child1.getComputedWidth()).toBe(200)
720
+ expect(root_child1.getComputedHeight()).toBe(150)
721
+ } finally {
722
+ if (typeof root !== "undefined") {
723
+ root.freeRecursive()
724
+ }
725
+
726
+ config.free()
727
+ }
728
+ })
729
+ test("percentage_multiple_nested_with_padding_margin_and_percentage_values", () => {
730
+ const config = Yoga.Config.create()
731
+ let root
732
+
733
+ try {
734
+ root = Yoga.Node.create(config)
735
+ root.setPositionType(PositionType.Absolute)
736
+ root.setWidth(200)
737
+ root.setHeight(200)
738
+
739
+ const root_child0 = Yoga.Node.create(config)
740
+ root_child0.setFlexGrow(1)
741
+ root_child0.setFlexBasis("10%")
742
+ root_child0.setMargin(Edge.Left, 5)
743
+ root_child0.setMargin(Edge.Top, 5)
744
+ root_child0.setMargin(Edge.Right, 5)
745
+ root_child0.setMargin(Edge.Bottom, 5)
746
+ root_child0.setPadding(Edge.Left, 3)
747
+ root_child0.setPadding(Edge.Top, 3)
748
+ root_child0.setPadding(Edge.Right, 3)
749
+ root_child0.setPadding(Edge.Bottom, 3)
750
+ root_child0.setMinWidth("60%")
751
+ root.insertChild(root_child0, 0)
752
+
753
+ const root_child0_child0 = Yoga.Node.create(config)
754
+ root_child0_child0.setMargin(Edge.Left, 5)
755
+ root_child0_child0.setMargin(Edge.Top, 5)
756
+ root_child0_child0.setMargin(Edge.Right, 5)
757
+ root_child0_child0.setMargin(Edge.Bottom, 5)
758
+ root_child0_child0.setPadding(Edge.Left, "3%")
759
+ root_child0_child0.setPadding(Edge.Top, "3%")
760
+ root_child0_child0.setPadding(Edge.Right, "3%")
761
+ root_child0_child0.setPadding(Edge.Bottom, "3%")
762
+ root_child0_child0.setWidth("50%")
763
+ root_child0.insertChild(root_child0_child0, 0)
764
+
765
+ const root_child0_child0_child0 = Yoga.Node.create(config)
766
+ root_child0_child0_child0.setMargin(Edge.Left, "5%")
767
+ root_child0_child0_child0.setMargin(Edge.Top, "5%")
768
+ root_child0_child0_child0.setMargin(Edge.Right, "5%")
769
+ root_child0_child0_child0.setMargin(Edge.Bottom, "5%")
770
+ root_child0_child0_child0.setPadding(Edge.Left, 3)
771
+ root_child0_child0_child0.setPadding(Edge.Top, 3)
772
+ root_child0_child0_child0.setPadding(Edge.Right, 3)
773
+ root_child0_child0_child0.setPadding(Edge.Bottom, 3)
774
+ root_child0_child0_child0.setWidth("45%")
775
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
776
+
777
+ const root_child1 = Yoga.Node.create(config)
778
+ root_child1.setFlexGrow(4)
779
+ root_child1.setFlexBasis("15%")
780
+ root_child1.setMinWidth("20%")
781
+ root.insertChild(root_child1, 1)
782
+ root.calculateLayout(undefined, undefined, Direction.LTR)
783
+
784
+ expect(root.getComputedLeft()).toBe(0)
785
+ expect(root.getComputedTop()).toBe(0)
786
+ expect(root.getComputedWidth()).toBe(200)
787
+ expect(root.getComputedHeight()).toBe(200)
788
+
789
+ expect(root_child0.getComputedLeft()).toBe(5)
790
+ expect(root_child0.getComputedTop()).toBe(5)
791
+ expect(root_child0.getComputedWidth()).toBe(190)
792
+ expect(root_child0.getComputedHeight()).toBe(48)
793
+
794
+ expect(root_child0_child0.getComputedLeft()).toBe(8)
795
+ expect(root_child0_child0.getComputedTop()).toBe(8)
796
+ expect(root_child0_child0.getComputedWidth()).toBe(92)
797
+ expect(root_child0_child0.getComputedHeight()).toBe(25)
798
+
799
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(10)
800
+ expect(root_child0_child0_child0.getComputedTop()).toBe(10)
801
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(36)
802
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(6)
803
+
804
+ expect(root_child1.getComputedLeft()).toBe(0)
805
+ expect(root_child1.getComputedTop()).toBe(58)
806
+ expect(root_child1.getComputedWidth()).toBe(200)
807
+ expect(root_child1.getComputedHeight()).toBe(142)
808
+
809
+ root.calculateLayout(undefined, undefined, Direction.RTL)
810
+
811
+ expect(root.getComputedLeft()).toBe(0)
812
+ expect(root.getComputedTop()).toBe(0)
813
+ expect(root.getComputedWidth()).toBe(200)
814
+ expect(root.getComputedHeight()).toBe(200)
815
+
816
+ expect(root_child0.getComputedLeft()).toBe(5)
817
+ expect(root_child0.getComputedTop()).toBe(5)
818
+ expect(root_child0.getComputedWidth()).toBe(190)
819
+ expect(root_child0.getComputedHeight()).toBe(48)
820
+
821
+ expect(root_child0_child0.getComputedLeft()).toBe(90)
822
+ expect(root_child0_child0.getComputedTop()).toBe(8)
823
+ expect(root_child0_child0.getComputedWidth()).toBe(92)
824
+ expect(root_child0_child0.getComputedHeight()).toBe(25)
825
+
826
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(46)
827
+ expect(root_child0_child0_child0.getComputedTop()).toBe(10)
828
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(36)
829
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(6)
830
+
831
+ expect(root_child1.getComputedLeft()).toBe(0)
832
+ expect(root_child1.getComputedTop()).toBe(58)
833
+ expect(root_child1.getComputedWidth()).toBe(200)
834
+ expect(root_child1.getComputedHeight()).toBe(142)
835
+ } finally {
836
+ if (typeof root !== "undefined") {
837
+ root.freeRecursive()
838
+ }
839
+
840
+ config.free()
841
+ }
842
+ })
843
+ test("percentage_margin_should_calculate_based_only_on_width", () => {
844
+ const config = Yoga.Config.create()
845
+ let root
846
+
847
+ try {
848
+ root = Yoga.Node.create(config)
849
+ root.setPositionType(PositionType.Absolute)
850
+ root.setWidth(200)
851
+ root.setHeight(100)
852
+
853
+ const root_child0 = Yoga.Node.create(config)
854
+ root_child0.setFlexGrow(1)
855
+ root_child0.setMargin(Edge.Left, "10%")
856
+ root_child0.setMargin(Edge.Top, "10%")
857
+ root_child0.setMargin(Edge.Right, "10%")
858
+ root_child0.setMargin(Edge.Bottom, "10%")
859
+ root.insertChild(root_child0, 0)
860
+
861
+ const root_child0_child0 = Yoga.Node.create(config)
862
+ root_child0_child0.setWidth(10)
863
+ root_child0_child0.setHeight(10)
864
+ root_child0.insertChild(root_child0_child0, 0)
865
+ root.calculateLayout(undefined, undefined, Direction.LTR)
866
+
867
+ expect(root.getComputedLeft()).toBe(0)
868
+ expect(root.getComputedTop()).toBe(0)
869
+ expect(root.getComputedWidth()).toBe(200)
870
+ expect(root.getComputedHeight()).toBe(100)
871
+
872
+ expect(root_child0.getComputedLeft()).toBe(20)
873
+ expect(root_child0.getComputedTop()).toBe(20)
874
+ expect(root_child0.getComputedWidth()).toBe(160)
875
+ expect(root_child0.getComputedHeight()).toBe(60)
876
+
877
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
878
+ expect(root_child0_child0.getComputedTop()).toBe(0)
879
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
880
+ expect(root_child0_child0.getComputedHeight()).toBe(10)
881
+
882
+ root.calculateLayout(undefined, undefined, Direction.RTL)
883
+
884
+ expect(root.getComputedLeft()).toBe(0)
885
+ expect(root.getComputedTop()).toBe(0)
886
+ expect(root.getComputedWidth()).toBe(200)
887
+ expect(root.getComputedHeight()).toBe(100)
888
+
889
+ expect(root_child0.getComputedLeft()).toBe(20)
890
+ expect(root_child0.getComputedTop()).toBe(20)
891
+ expect(root_child0.getComputedWidth()).toBe(160)
892
+ expect(root_child0.getComputedHeight()).toBe(60)
893
+
894
+ expect(root_child0_child0.getComputedLeft()).toBe(150)
895
+ expect(root_child0_child0.getComputedTop()).toBe(0)
896
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
897
+ expect(root_child0_child0.getComputedHeight()).toBe(10)
898
+ } finally {
899
+ if (typeof root !== "undefined") {
900
+ root.freeRecursive()
901
+ }
902
+
903
+ config.free()
904
+ }
905
+ })
906
+ test("percentage_padding_should_calculate_based_only_on_width", () => {
907
+ const config = Yoga.Config.create()
908
+ let root
909
+
910
+ try {
911
+ root = Yoga.Node.create(config)
912
+ root.setPositionType(PositionType.Absolute)
913
+ root.setWidth(200)
914
+ root.setHeight(100)
915
+
916
+ const root_child0 = Yoga.Node.create(config)
917
+ root_child0.setFlexGrow(1)
918
+ root_child0.setPadding(Edge.Left, "10%")
919
+ root_child0.setPadding(Edge.Top, "10%")
920
+ root_child0.setPadding(Edge.Right, "10%")
921
+ root_child0.setPadding(Edge.Bottom, "10%")
922
+ root.insertChild(root_child0, 0)
923
+
924
+ const root_child0_child0 = Yoga.Node.create(config)
925
+ root_child0_child0.setWidth(10)
926
+ root_child0_child0.setHeight(10)
927
+ root_child0.insertChild(root_child0_child0, 0)
928
+ root.calculateLayout(undefined, undefined, Direction.LTR)
929
+
930
+ expect(root.getComputedLeft()).toBe(0)
931
+ expect(root.getComputedTop()).toBe(0)
932
+ expect(root.getComputedWidth()).toBe(200)
933
+ expect(root.getComputedHeight()).toBe(100)
934
+
935
+ expect(root_child0.getComputedLeft()).toBe(0)
936
+ expect(root_child0.getComputedTop()).toBe(0)
937
+ expect(root_child0.getComputedWidth()).toBe(200)
938
+ expect(root_child0.getComputedHeight()).toBe(100)
939
+
940
+ expect(root_child0_child0.getComputedLeft()).toBe(20)
941
+ expect(root_child0_child0.getComputedTop()).toBe(20)
942
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
943
+ expect(root_child0_child0.getComputedHeight()).toBe(10)
944
+
945
+ root.calculateLayout(undefined, undefined, Direction.RTL)
946
+
947
+ expect(root.getComputedLeft()).toBe(0)
948
+ expect(root.getComputedTop()).toBe(0)
949
+ expect(root.getComputedWidth()).toBe(200)
950
+ expect(root.getComputedHeight()).toBe(100)
951
+
952
+ expect(root_child0.getComputedLeft()).toBe(0)
953
+ expect(root_child0.getComputedTop()).toBe(0)
954
+ expect(root_child0.getComputedWidth()).toBe(200)
955
+ expect(root_child0.getComputedHeight()).toBe(100)
956
+
957
+ expect(root_child0_child0.getComputedLeft()).toBe(170)
958
+ expect(root_child0_child0.getComputedTop()).toBe(20)
959
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
960
+ expect(root_child0_child0.getComputedHeight()).toBe(10)
961
+ } finally {
962
+ if (typeof root !== "undefined") {
963
+ root.freeRecursive()
964
+ }
965
+
966
+ config.free()
967
+ }
968
+ })
969
+ test("percentage_absolute_position", () => {
970
+ const config = Yoga.Config.create()
971
+ let root
972
+
973
+ try {
974
+ root = Yoga.Node.create(config)
975
+ root.setPositionType(PositionType.Absolute)
976
+ root.setWidth(200)
977
+ root.setHeight(100)
978
+
979
+ const root_child0 = Yoga.Node.create(config)
980
+ root_child0.setPositionType(PositionType.Absolute)
981
+ root_child0.setPosition(Edge.Left, "30%")
982
+ root_child0.setPosition(Edge.Top, "10%")
983
+ root_child0.setWidth(10)
984
+ root_child0.setHeight(10)
985
+ root.insertChild(root_child0, 0)
986
+ root.calculateLayout(undefined, undefined, Direction.LTR)
987
+
988
+ expect(root.getComputedLeft()).toBe(0)
989
+ expect(root.getComputedTop()).toBe(0)
990
+ expect(root.getComputedWidth()).toBe(200)
991
+ expect(root.getComputedHeight()).toBe(100)
992
+
993
+ expect(root_child0.getComputedLeft()).toBe(60)
994
+ expect(root_child0.getComputedTop()).toBe(10)
995
+ expect(root_child0.getComputedWidth()).toBe(10)
996
+ expect(root_child0.getComputedHeight()).toBe(10)
997
+
998
+ root.calculateLayout(undefined, undefined, Direction.RTL)
999
+
1000
+ expect(root.getComputedLeft()).toBe(0)
1001
+ expect(root.getComputedTop()).toBe(0)
1002
+ expect(root.getComputedWidth()).toBe(200)
1003
+ expect(root.getComputedHeight()).toBe(100)
1004
+
1005
+ expect(root_child0.getComputedLeft()).toBe(60)
1006
+ expect(root_child0.getComputedTop()).toBe(10)
1007
+ expect(root_child0.getComputedWidth()).toBe(10)
1008
+ expect(root_child0.getComputedHeight()).toBe(10)
1009
+ } finally {
1010
+ if (typeof root !== "undefined") {
1011
+ root.freeRecursive()
1012
+ }
1013
+
1014
+ config.free()
1015
+ }
1016
+ })
1017
+ test("percentage_width_height_undefined_parent_size", () => {
1018
+ const config = Yoga.Config.create()
1019
+ let root
1020
+
1021
+ try {
1022
+ root = Yoga.Node.create(config)
1023
+ root.setPositionType(PositionType.Absolute)
1024
+
1025
+ const root_child0 = Yoga.Node.create(config)
1026
+ root_child0.setWidth("50%")
1027
+ root_child0.setHeight("50%")
1028
+ root.insertChild(root_child0, 0)
1029
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1030
+
1031
+ expect(root.getComputedLeft()).toBe(0)
1032
+ expect(root.getComputedTop()).toBe(0)
1033
+ expect(root.getComputedWidth()).toBe(0)
1034
+ expect(root.getComputedHeight()).toBe(0)
1035
+
1036
+ expect(root_child0.getComputedLeft()).toBe(0)
1037
+ expect(root_child0.getComputedTop()).toBe(0)
1038
+ expect(root_child0.getComputedWidth()).toBe(0)
1039
+ expect(root_child0.getComputedHeight()).toBe(0)
1040
+
1041
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1042
+
1043
+ expect(root.getComputedLeft()).toBe(0)
1044
+ expect(root.getComputedTop()).toBe(0)
1045
+ expect(root.getComputedWidth()).toBe(0)
1046
+ expect(root.getComputedHeight()).toBe(0)
1047
+
1048
+ expect(root_child0.getComputedLeft()).toBe(0)
1049
+ expect(root_child0.getComputedTop()).toBe(0)
1050
+ expect(root_child0.getComputedWidth()).toBe(0)
1051
+ expect(root_child0.getComputedHeight()).toBe(0)
1052
+ } finally {
1053
+ if (typeof root !== "undefined") {
1054
+ root.freeRecursive()
1055
+ }
1056
+
1057
+ config.free()
1058
+ }
1059
+ })
1060
+ test("percent_within_flex_grow", () => {
1061
+ const config = Yoga.Config.create()
1062
+ let root
1063
+
1064
+ try {
1065
+ root = Yoga.Node.create(config)
1066
+ root.setFlexDirection(FlexDirection.Row)
1067
+ root.setPositionType(PositionType.Absolute)
1068
+ root.setWidth(350)
1069
+ root.setHeight(100)
1070
+
1071
+ const root_child0 = Yoga.Node.create(config)
1072
+ root_child0.setWidth(100)
1073
+ root.insertChild(root_child0, 0)
1074
+
1075
+ const root_child1 = Yoga.Node.create(config)
1076
+ root_child1.setFlexGrow(1)
1077
+ root.insertChild(root_child1, 1)
1078
+
1079
+ const root_child1_child0 = Yoga.Node.create(config)
1080
+ root_child1_child0.setWidth("100%")
1081
+ root_child1.insertChild(root_child1_child0, 0)
1082
+
1083
+ const root_child2 = Yoga.Node.create(config)
1084
+ root_child2.setWidth(100)
1085
+ root.insertChild(root_child2, 2)
1086
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1087
+
1088
+ expect(root.getComputedLeft()).toBe(0)
1089
+ expect(root.getComputedTop()).toBe(0)
1090
+ expect(root.getComputedWidth()).toBe(350)
1091
+ expect(root.getComputedHeight()).toBe(100)
1092
+
1093
+ expect(root_child0.getComputedLeft()).toBe(0)
1094
+ expect(root_child0.getComputedTop()).toBe(0)
1095
+ expect(root_child0.getComputedWidth()).toBe(100)
1096
+ expect(root_child0.getComputedHeight()).toBe(100)
1097
+
1098
+ expect(root_child1.getComputedLeft()).toBe(100)
1099
+ expect(root_child1.getComputedTop()).toBe(0)
1100
+ expect(root_child1.getComputedWidth()).toBe(150)
1101
+ expect(root_child1.getComputedHeight()).toBe(100)
1102
+
1103
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1104
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1105
+ expect(root_child1_child0.getComputedWidth()).toBe(150)
1106
+ expect(root_child1_child0.getComputedHeight()).toBe(0)
1107
+
1108
+ expect(root_child2.getComputedLeft()).toBe(250)
1109
+ expect(root_child2.getComputedTop()).toBe(0)
1110
+ expect(root_child2.getComputedWidth()).toBe(100)
1111
+ expect(root_child2.getComputedHeight()).toBe(100)
1112
+
1113
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1114
+
1115
+ expect(root.getComputedLeft()).toBe(0)
1116
+ expect(root.getComputedTop()).toBe(0)
1117
+ expect(root.getComputedWidth()).toBe(350)
1118
+ expect(root.getComputedHeight()).toBe(100)
1119
+
1120
+ expect(root_child0.getComputedLeft()).toBe(250)
1121
+ expect(root_child0.getComputedTop()).toBe(0)
1122
+ expect(root_child0.getComputedWidth()).toBe(100)
1123
+ expect(root_child0.getComputedHeight()).toBe(100)
1124
+
1125
+ expect(root_child1.getComputedLeft()).toBe(100)
1126
+ expect(root_child1.getComputedTop()).toBe(0)
1127
+ expect(root_child1.getComputedWidth()).toBe(150)
1128
+ expect(root_child1.getComputedHeight()).toBe(100)
1129
+
1130
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1131
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1132
+ expect(root_child1_child0.getComputedWidth()).toBe(150)
1133
+ expect(root_child1_child0.getComputedHeight()).toBe(0)
1134
+
1135
+ expect(root_child2.getComputedLeft()).toBe(0)
1136
+ expect(root_child2.getComputedTop()).toBe(0)
1137
+ expect(root_child2.getComputedWidth()).toBe(100)
1138
+ expect(root_child2.getComputedHeight()).toBe(100)
1139
+ } finally {
1140
+ if (typeof root !== "undefined") {
1141
+ root.freeRecursive()
1142
+ }
1143
+
1144
+ config.free()
1145
+ }
1146
+ })
1147
+ test("percentage_container_in_wrapping_container", () => {
1148
+ const config = Yoga.Config.create()
1149
+ let root
1150
+
1151
+ try {
1152
+ root = Yoga.Node.create(config)
1153
+ root.setJustifyContent(Justify.Center)
1154
+ root.setAlignItems(Align.Center)
1155
+ root.setPositionType(PositionType.Absolute)
1156
+ root.setWidth(200)
1157
+ root.setHeight(200)
1158
+
1159
+ const root_child0 = Yoga.Node.create(config)
1160
+ root.insertChild(root_child0, 0)
1161
+
1162
+ const root_child0_child0 = Yoga.Node.create(config)
1163
+ root_child0_child0.setFlexDirection(FlexDirection.Row)
1164
+ root_child0_child0.setJustifyContent(Justify.Center)
1165
+ root_child0_child0.setWidth("100%")
1166
+ root_child0.insertChild(root_child0_child0, 0)
1167
+
1168
+ const root_child0_child0_child0 = Yoga.Node.create(config)
1169
+ root_child0_child0_child0.setWidth(50)
1170
+ root_child0_child0_child0.setHeight(50)
1171
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
1172
+
1173
+ const root_child0_child0_child1 = Yoga.Node.create(config)
1174
+ root_child0_child0_child1.setWidth(50)
1175
+ root_child0_child0_child1.setHeight(50)
1176
+ root_child0_child0.insertChild(root_child0_child0_child1, 1)
1177
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1178
+
1179
+ expect(root.getComputedLeft()).toBe(0)
1180
+ expect(root.getComputedTop()).toBe(0)
1181
+ expect(root.getComputedWidth()).toBe(200)
1182
+ expect(root.getComputedHeight()).toBe(200)
1183
+
1184
+ expect(root_child0.getComputedLeft()).toBe(50)
1185
+ expect(root_child0.getComputedTop()).toBe(75)
1186
+ expect(root_child0.getComputedWidth()).toBe(100)
1187
+ expect(root_child0.getComputedHeight()).toBe(50)
1188
+
1189
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1190
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1191
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
1192
+ expect(root_child0_child0.getComputedHeight()).toBe(50)
1193
+
1194
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
1195
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
1196
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(50)
1197
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(50)
1198
+
1199
+ expect(root_child0_child0_child1.getComputedLeft()).toBe(50)
1200
+ expect(root_child0_child0_child1.getComputedTop()).toBe(0)
1201
+ expect(root_child0_child0_child1.getComputedWidth()).toBe(50)
1202
+ expect(root_child0_child0_child1.getComputedHeight()).toBe(50)
1203
+
1204
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1205
+
1206
+ expect(root.getComputedLeft()).toBe(0)
1207
+ expect(root.getComputedTop()).toBe(0)
1208
+ expect(root.getComputedWidth()).toBe(200)
1209
+ expect(root.getComputedHeight()).toBe(200)
1210
+
1211
+ expect(root_child0.getComputedLeft()).toBe(50)
1212
+ expect(root_child0.getComputedTop()).toBe(75)
1213
+ expect(root_child0.getComputedWidth()).toBe(100)
1214
+ expect(root_child0.getComputedHeight()).toBe(50)
1215
+
1216
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1217
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1218
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
1219
+ expect(root_child0_child0.getComputedHeight()).toBe(50)
1220
+
1221
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(50)
1222
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
1223
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(50)
1224
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(50)
1225
+
1226
+ expect(root_child0_child0_child1.getComputedLeft()).toBe(0)
1227
+ expect(root_child0_child0_child1.getComputedTop()).toBe(0)
1228
+ expect(root_child0_child0_child1.getComputedWidth()).toBe(50)
1229
+ expect(root_child0_child0_child1.getComputedHeight()).toBe(50)
1230
+ } finally {
1231
+ if (typeof root !== "undefined") {
1232
+ root.freeRecursive()
1233
+ }
1234
+
1235
+ config.free()
1236
+ }
1237
+ })
1238
+ test("percent_absolute_position", () => {
1239
+ const config = Yoga.Config.create()
1240
+ let root
1241
+
1242
+ try {
1243
+ root = Yoga.Node.create(config)
1244
+ root.setPositionType(PositionType.Absolute)
1245
+ root.setWidth(60)
1246
+ root.setHeight(50)
1247
+
1248
+ const root_child0 = Yoga.Node.create(config)
1249
+ root_child0.setFlexDirection(FlexDirection.Row)
1250
+ root_child0.setPositionType(PositionType.Absolute)
1251
+ root_child0.setPosition(Edge.Left, "50%")
1252
+ root_child0.setWidth("100%")
1253
+ root_child0.setHeight(50)
1254
+ root.insertChild(root_child0, 0)
1255
+
1256
+ const root_child0_child0 = Yoga.Node.create(config)
1257
+ root_child0_child0.setWidth("100%")
1258
+ root_child0.insertChild(root_child0_child0, 0)
1259
+
1260
+ const root_child0_child1 = Yoga.Node.create(config)
1261
+ root_child0_child1.setWidth("100%")
1262
+ root_child0.insertChild(root_child0_child1, 1)
1263
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1264
+
1265
+ expect(root.getComputedLeft()).toBe(0)
1266
+ expect(root.getComputedTop()).toBe(0)
1267
+ expect(root.getComputedWidth()).toBe(60)
1268
+ expect(root.getComputedHeight()).toBe(50)
1269
+
1270
+ expect(root_child0.getComputedLeft()).toBe(30)
1271
+ expect(root_child0.getComputedTop()).toBe(0)
1272
+ expect(root_child0.getComputedWidth()).toBe(60)
1273
+ expect(root_child0.getComputedHeight()).toBe(50)
1274
+
1275
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1276
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1277
+ expect(root_child0_child0.getComputedWidth()).toBe(60)
1278
+ expect(root_child0_child0.getComputedHeight()).toBe(50)
1279
+
1280
+ expect(root_child0_child1.getComputedLeft()).toBe(60)
1281
+ expect(root_child0_child1.getComputedTop()).toBe(0)
1282
+ expect(root_child0_child1.getComputedWidth()).toBe(60)
1283
+ expect(root_child0_child1.getComputedHeight()).toBe(50)
1284
+
1285
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1286
+
1287
+ expect(root.getComputedLeft()).toBe(0)
1288
+ expect(root.getComputedTop()).toBe(0)
1289
+ expect(root.getComputedWidth()).toBe(60)
1290
+ expect(root.getComputedHeight()).toBe(50)
1291
+
1292
+ expect(root_child0.getComputedLeft()).toBe(30)
1293
+ expect(root_child0.getComputedTop()).toBe(0)
1294
+ expect(root_child0.getComputedWidth()).toBe(60)
1295
+ expect(root_child0.getComputedHeight()).toBe(50)
1296
+
1297
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1298
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1299
+ expect(root_child0_child0.getComputedWidth()).toBe(60)
1300
+ expect(root_child0_child0.getComputedHeight()).toBe(50)
1301
+
1302
+ expect(root_child0_child1.getComputedLeft()).toBe(-60)
1303
+ expect(root_child0_child1.getComputedTop()).toBe(0)
1304
+ expect(root_child0_child1.getComputedWidth()).toBe(60)
1305
+ expect(root_child0_child1.getComputedHeight()).toBe(50)
1306
+ } finally {
1307
+ if (typeof root !== "undefined") {
1308
+ root.freeRecursive()
1309
+ }
1310
+
1311
+ config.free()
1312
+ }
1313
+ })
1314
+ test("percent_of_minmax_main", () => {
1315
+ const config = Yoga.Config.create()
1316
+ let root
1317
+
1318
+ try {
1319
+ root = Yoga.Node.create(config)
1320
+ root.setFlexDirection(FlexDirection.Row)
1321
+ root.setPositionType(PositionType.Absolute)
1322
+ root.setMinWidth(60)
1323
+ root.setMaxWidth(60)
1324
+ root.setHeight(50)
1325
+
1326
+ const root_child0 = Yoga.Node.create(config)
1327
+ root_child0.setWidth("50%")
1328
+ root_child0.setHeight(20)
1329
+ root.insertChild(root_child0, 0)
1330
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1331
+
1332
+ expect(root.getComputedLeft()).toBe(0)
1333
+ expect(root.getComputedTop()).toBe(0)
1334
+ expect(root.getComputedWidth()).toBe(60)
1335
+ expect(root.getComputedHeight()).toBe(50)
1336
+
1337
+ expect(root_child0.getComputedLeft()).toBe(0)
1338
+ expect(root_child0.getComputedTop()).toBe(0)
1339
+ expect(root_child0.getComputedWidth()).toBe(30)
1340
+ expect(root_child0.getComputedHeight()).toBe(20)
1341
+
1342
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1343
+
1344
+ expect(root.getComputedLeft()).toBe(0)
1345
+ expect(root.getComputedTop()).toBe(0)
1346
+ expect(root.getComputedWidth()).toBe(60)
1347
+ expect(root.getComputedHeight()).toBe(50)
1348
+
1349
+ expect(root_child0.getComputedLeft()).toBe(30)
1350
+ expect(root_child0.getComputedTop()).toBe(0)
1351
+ expect(root_child0.getComputedWidth()).toBe(30)
1352
+ expect(root_child0.getComputedHeight()).toBe(20)
1353
+ } finally {
1354
+ if (typeof root !== "undefined") {
1355
+ root.freeRecursive()
1356
+ }
1357
+
1358
+ config.free()
1359
+ }
1360
+ })
1361
+ test.skip("percent_of_min_main", () => {
1362
+ const config = Yoga.Config.create()
1363
+ let root
1364
+
1365
+ try {
1366
+ root = Yoga.Node.create(config)
1367
+ root.setFlexDirection(FlexDirection.Row)
1368
+ root.setPositionType(PositionType.Absolute)
1369
+ root.setMinWidth(60)
1370
+ root.setHeight(50)
1371
+
1372
+ const root_child0 = Yoga.Node.create(config)
1373
+ root_child0.setWidth("50%")
1374
+ root_child0.setHeight(20)
1375
+ root.insertChild(root_child0, 0)
1376
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1377
+
1378
+ expect(root.getComputedLeft()).toBe(0)
1379
+ expect(root.getComputedTop()).toBe(0)
1380
+ expect(root.getComputedWidth()).toBe(60)
1381
+ expect(root.getComputedHeight()).toBe(50)
1382
+
1383
+ expect(root_child0.getComputedLeft()).toBe(0)
1384
+ expect(root_child0.getComputedTop()).toBe(0)
1385
+ expect(root_child0.getComputedWidth()).toBe(30)
1386
+ expect(root_child0.getComputedHeight()).toBe(20)
1387
+
1388
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1389
+
1390
+ expect(root.getComputedLeft()).toBe(0)
1391
+ expect(root.getComputedTop()).toBe(0)
1392
+ expect(root.getComputedWidth()).toBe(60)
1393
+ expect(root.getComputedHeight()).toBe(50)
1394
+
1395
+ expect(root_child0.getComputedLeft()).toBe(30)
1396
+ expect(root_child0.getComputedTop()).toBe(0)
1397
+ expect(root_child0.getComputedWidth()).toBe(30)
1398
+ expect(root_child0.getComputedHeight()).toBe(20)
1399
+ } finally {
1400
+ if (typeof root !== "undefined") {
1401
+ root.freeRecursive()
1402
+ }
1403
+
1404
+ config.free()
1405
+ }
1406
+ })
1407
+ test.skip("percent_of_min_main_multiple", () => {
1408
+ const config = Yoga.Config.create()
1409
+ let root
1410
+
1411
+ try {
1412
+ root = Yoga.Node.create(config)
1413
+ root.setFlexDirection(FlexDirection.Row)
1414
+ root.setPositionType(PositionType.Absolute)
1415
+ root.setMinWidth(60)
1416
+ root.setHeight(50)
1417
+
1418
+ const root_child0 = Yoga.Node.create(config)
1419
+ root_child0.setWidth("50%")
1420
+ root_child0.setHeight(20)
1421
+ root.insertChild(root_child0, 0)
1422
+
1423
+ const root_child1 = Yoga.Node.create(config)
1424
+ root_child1.setWidth("50%")
1425
+ root_child1.setHeight(20)
1426
+ root.insertChild(root_child1, 1)
1427
+
1428
+ const root_child2 = Yoga.Node.create(config)
1429
+ root_child2.setWidth("50%")
1430
+ root_child2.setHeight(20)
1431
+ root.insertChild(root_child2, 2)
1432
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1433
+
1434
+ expect(root.getComputedLeft()).toBe(0)
1435
+ expect(root.getComputedTop()).toBe(0)
1436
+ expect(root.getComputedWidth()).toBe(60)
1437
+ expect(root.getComputedHeight()).toBe(50)
1438
+
1439
+ expect(root_child0.getComputedLeft()).toBe(0)
1440
+ expect(root_child0.getComputedTop()).toBe(0)
1441
+ expect(root_child0.getComputedWidth()).toBe(30)
1442
+ expect(root_child0.getComputedHeight()).toBe(20)
1443
+
1444
+ expect(root_child1.getComputedLeft()).toBe(30)
1445
+ expect(root_child1.getComputedTop()).toBe(0)
1446
+ expect(root_child1.getComputedWidth()).toBe(30)
1447
+ expect(root_child1.getComputedHeight()).toBe(20)
1448
+
1449
+ expect(root_child2.getComputedLeft()).toBe(60)
1450
+ expect(root_child2.getComputedTop()).toBe(0)
1451
+ expect(root_child2.getComputedWidth()).toBe(30)
1452
+ expect(root_child2.getComputedHeight()).toBe(20)
1453
+
1454
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1455
+
1456
+ expect(root.getComputedLeft()).toBe(0)
1457
+ expect(root.getComputedTop()).toBe(0)
1458
+ expect(root.getComputedWidth()).toBe(60)
1459
+ expect(root.getComputedHeight()).toBe(50)
1460
+
1461
+ expect(root_child0.getComputedLeft()).toBe(30)
1462
+ expect(root_child0.getComputedTop()).toBe(0)
1463
+ expect(root_child0.getComputedWidth()).toBe(30)
1464
+ expect(root_child0.getComputedHeight()).toBe(20)
1465
+
1466
+ expect(root_child1.getComputedLeft()).toBe(0)
1467
+ expect(root_child1.getComputedTop()).toBe(0)
1468
+ expect(root_child1.getComputedWidth()).toBe(30)
1469
+ expect(root_child1.getComputedHeight()).toBe(20)
1470
+
1471
+ expect(root_child2.getComputedLeft()).toBe(-30)
1472
+ expect(root_child2.getComputedTop()).toBe(0)
1473
+ expect(root_child2.getComputedWidth()).toBe(30)
1474
+ expect(root_child2.getComputedHeight()).toBe(20)
1475
+ } finally {
1476
+ if (typeof root !== "undefined") {
1477
+ root.freeRecursive()
1478
+ }
1479
+
1480
+ config.free()
1481
+ }
1482
+ })
1483
+ test.skip("percent_of_max_main", () => {
1484
+ const config = Yoga.Config.create()
1485
+ let root
1486
+
1487
+ try {
1488
+ root = Yoga.Node.create(config)
1489
+ root.setFlexDirection(FlexDirection.Row)
1490
+ root.setPositionType(PositionType.Absolute)
1491
+ root.setMaxWidth(60)
1492
+ root.setHeight(50)
1493
+
1494
+ const root_child0 = Yoga.Node.create(config)
1495
+ root_child0.setWidth("50%")
1496
+ root_child0.setHeight(20)
1497
+ root.insertChild(root_child0, 0)
1498
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1499
+
1500
+ expect(root.getComputedLeft()).toBe(0)
1501
+ expect(root.getComputedTop()).toBe(0)
1502
+ expect(root.getComputedWidth()).toBe(0)
1503
+ expect(root.getComputedHeight()).toBe(50)
1504
+
1505
+ expect(root_child0.getComputedLeft()).toBe(0)
1506
+ expect(root_child0.getComputedTop()).toBe(0)
1507
+ expect(root_child0.getComputedWidth()).toBe(0)
1508
+ expect(root_child0.getComputedHeight()).toBe(20)
1509
+
1510
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1511
+
1512
+ expect(root.getComputedLeft()).toBe(0)
1513
+ expect(root.getComputedTop()).toBe(0)
1514
+ expect(root.getComputedWidth()).toBe(0)
1515
+ expect(root.getComputedHeight()).toBe(50)
1516
+
1517
+ expect(root_child0.getComputedLeft()).toBe(0)
1518
+ expect(root_child0.getComputedTop()).toBe(0)
1519
+ expect(root_child0.getComputedWidth()).toBe(0)
1520
+ expect(root_child0.getComputedHeight()).toBe(20)
1521
+ } finally {
1522
+ if (typeof root !== "undefined") {
1523
+ root.freeRecursive()
1524
+ }
1525
+
1526
+ config.free()
1527
+ }
1528
+ })
1529
+ test("percent_of_minmax_cross_stretched", () => {
1530
+ const config = Yoga.Config.create()
1531
+ let root
1532
+
1533
+ try {
1534
+ root = Yoga.Node.create(config)
1535
+ root.setPositionType(PositionType.Absolute)
1536
+ root.setMinWidth(60)
1537
+ root.setMaxWidth(60)
1538
+ root.setHeight(50)
1539
+
1540
+ const root_child0 = Yoga.Node.create(config)
1541
+ root_child0.setWidth("50%")
1542
+ root_child0.setHeight(20)
1543
+ root.insertChild(root_child0, 0)
1544
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1545
+
1546
+ expect(root.getComputedLeft()).toBe(0)
1547
+ expect(root.getComputedTop()).toBe(0)
1548
+ expect(root.getComputedWidth()).toBe(60)
1549
+ expect(root.getComputedHeight()).toBe(50)
1550
+
1551
+ expect(root_child0.getComputedLeft()).toBe(0)
1552
+ expect(root_child0.getComputedTop()).toBe(0)
1553
+ expect(root_child0.getComputedWidth()).toBe(30)
1554
+ expect(root_child0.getComputedHeight()).toBe(20)
1555
+
1556
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1557
+
1558
+ expect(root.getComputedLeft()).toBe(0)
1559
+ expect(root.getComputedTop()).toBe(0)
1560
+ expect(root.getComputedWidth()).toBe(60)
1561
+ expect(root.getComputedHeight()).toBe(50)
1562
+
1563
+ expect(root_child0.getComputedLeft()).toBe(30)
1564
+ expect(root_child0.getComputedTop()).toBe(0)
1565
+ expect(root_child0.getComputedWidth()).toBe(30)
1566
+ expect(root_child0.getComputedHeight()).toBe(20)
1567
+ } finally {
1568
+ if (typeof root !== "undefined") {
1569
+ root.freeRecursive()
1570
+ }
1571
+
1572
+ config.free()
1573
+ }
1574
+ })
1575
+ test("percent_absolute_of_minmax_cross_stretched", () => {
1576
+ const config = Yoga.Config.create()
1577
+ let root
1578
+
1579
+ try {
1580
+ root = Yoga.Node.create(config)
1581
+ root.setPositionType(PositionType.Absolute)
1582
+ root.setMinWidth(60)
1583
+ root.setMaxWidth(60)
1584
+ root.setHeight(50)
1585
+
1586
+ const root_child0 = Yoga.Node.create(config)
1587
+ root_child0.setPositionType(PositionType.Absolute)
1588
+ root_child0.setWidth("50%")
1589
+ root_child0.setHeight(20)
1590
+ root.insertChild(root_child0, 0)
1591
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1592
+
1593
+ expect(root.getComputedLeft()).toBe(0)
1594
+ expect(root.getComputedTop()).toBe(0)
1595
+ expect(root.getComputedWidth()).toBe(60)
1596
+ expect(root.getComputedHeight()).toBe(50)
1597
+
1598
+ expect(root_child0.getComputedLeft()).toBe(0)
1599
+ expect(root_child0.getComputedTop()).toBe(0)
1600
+ expect(root_child0.getComputedWidth()).toBe(30)
1601
+ expect(root_child0.getComputedHeight()).toBe(20)
1602
+
1603
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1604
+
1605
+ expect(root.getComputedLeft()).toBe(0)
1606
+ expect(root.getComputedTop()).toBe(0)
1607
+ expect(root.getComputedWidth()).toBe(60)
1608
+ expect(root.getComputedHeight()).toBe(50)
1609
+
1610
+ expect(root_child0.getComputedLeft()).toBe(30)
1611
+ expect(root_child0.getComputedTop()).toBe(0)
1612
+ expect(root_child0.getComputedWidth()).toBe(30)
1613
+ expect(root_child0.getComputedHeight()).toBe(20)
1614
+ } finally {
1615
+ if (typeof root !== "undefined") {
1616
+ root.freeRecursive()
1617
+ }
1618
+
1619
+ config.free()
1620
+ }
1621
+ })
1622
+ test("percent_of_minmax_cross_unstretched", () => {
1623
+ const config = Yoga.Config.create()
1624
+ let root
1625
+
1626
+ try {
1627
+ root = Yoga.Node.create(config)
1628
+ root.setAlignItems(Align.FlexStart)
1629
+ root.setPositionType(PositionType.Absolute)
1630
+ root.setMinWidth(60)
1631
+ root.setMaxWidth(60)
1632
+ root.setHeight(50)
1633
+
1634
+ const root_child0 = Yoga.Node.create(config)
1635
+ root_child0.setWidth("50%")
1636
+ root_child0.setHeight(20)
1637
+ root.insertChild(root_child0, 0)
1638
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1639
+
1640
+ expect(root.getComputedLeft()).toBe(0)
1641
+ expect(root.getComputedTop()).toBe(0)
1642
+ expect(root.getComputedWidth()).toBe(60)
1643
+ expect(root.getComputedHeight()).toBe(50)
1644
+
1645
+ expect(root_child0.getComputedLeft()).toBe(0)
1646
+ expect(root_child0.getComputedTop()).toBe(0)
1647
+ expect(root_child0.getComputedWidth()).toBe(30)
1648
+ expect(root_child0.getComputedHeight()).toBe(20)
1649
+
1650
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1651
+
1652
+ expect(root.getComputedLeft()).toBe(0)
1653
+ expect(root.getComputedTop()).toBe(0)
1654
+ expect(root.getComputedWidth()).toBe(60)
1655
+ expect(root.getComputedHeight()).toBe(50)
1656
+
1657
+ expect(root_child0.getComputedLeft()).toBe(30)
1658
+ expect(root_child0.getComputedTop()).toBe(0)
1659
+ expect(root_child0.getComputedWidth()).toBe(30)
1660
+ expect(root_child0.getComputedHeight()).toBe(20)
1661
+ } finally {
1662
+ if (typeof root !== "undefined") {
1663
+ root.freeRecursive()
1664
+ }
1665
+
1666
+ config.free()
1667
+ }
1668
+ })
1669
+ test.skip("percent_of_min_cross_unstretched", () => {
1670
+ const config = Yoga.Config.create()
1671
+ let root
1672
+
1673
+ try {
1674
+ root = Yoga.Node.create(config)
1675
+ root.setAlignItems(Align.FlexStart)
1676
+ root.setPositionType(PositionType.Absolute)
1677
+ root.setMinWidth(60)
1678
+ root.setHeight(50)
1679
+
1680
+ const root_child0 = Yoga.Node.create(config)
1681
+ root_child0.setWidth("50%")
1682
+ root_child0.setHeight(20)
1683
+ root.insertChild(root_child0, 0)
1684
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1685
+
1686
+ expect(root.getComputedLeft()).toBe(0)
1687
+ expect(root.getComputedTop()).toBe(0)
1688
+ expect(root.getComputedWidth()).toBe(60)
1689
+ expect(root.getComputedHeight()).toBe(50)
1690
+
1691
+ expect(root_child0.getComputedLeft()).toBe(0)
1692
+ expect(root_child0.getComputedTop()).toBe(0)
1693
+ expect(root_child0.getComputedWidth()).toBe(30)
1694
+ expect(root_child0.getComputedHeight()).toBe(20)
1695
+
1696
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1697
+
1698
+ expect(root.getComputedLeft()).toBe(0)
1699
+ expect(root.getComputedTop()).toBe(0)
1700
+ expect(root.getComputedWidth()).toBe(60)
1701
+ expect(root.getComputedHeight()).toBe(50)
1702
+
1703
+ expect(root_child0.getComputedLeft()).toBe(30)
1704
+ expect(root_child0.getComputedTop()).toBe(0)
1705
+ expect(root_child0.getComputedWidth()).toBe(30)
1706
+ expect(root_child0.getComputedHeight()).toBe(20)
1707
+ } finally {
1708
+ if (typeof root !== "undefined") {
1709
+ root.freeRecursive()
1710
+ }
1711
+
1712
+ config.free()
1713
+ }
1714
+ })
1715
+ test("percent_of_max_cross_unstretched", () => {
1716
+ const config = Yoga.Config.create()
1717
+ let root
1718
+
1719
+ try {
1720
+ root = Yoga.Node.create(config)
1721
+ root.setAlignItems(Align.FlexStart)
1722
+ root.setPositionType(PositionType.Absolute)
1723
+ root.setMaxWidth(60)
1724
+ root.setHeight(50)
1725
+
1726
+ const root_child0 = Yoga.Node.create(config)
1727
+ root_child0.setWidth("50%")
1728
+ root_child0.setHeight(20)
1729
+ root.insertChild(root_child0, 0)
1730
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1731
+
1732
+ expect(root.getComputedLeft()).toBe(0)
1733
+ expect(root.getComputedTop()).toBe(0)
1734
+ expect(root.getComputedWidth()).toBe(0)
1735
+ expect(root.getComputedHeight()).toBe(50)
1736
+
1737
+ expect(root_child0.getComputedLeft()).toBe(0)
1738
+ expect(root_child0.getComputedTop()).toBe(0)
1739
+ expect(root_child0.getComputedWidth()).toBe(0)
1740
+ expect(root_child0.getComputedHeight()).toBe(20)
1741
+
1742
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1743
+
1744
+ expect(root.getComputedLeft()).toBe(0)
1745
+ expect(root.getComputedTop()).toBe(0)
1746
+ expect(root.getComputedWidth()).toBe(0)
1747
+ expect(root.getComputedHeight()).toBe(50)
1748
+
1749
+ expect(root_child0.getComputedLeft()).toBe(0)
1750
+ expect(root_child0.getComputedTop()).toBe(0)
1751
+ expect(root_child0.getComputedWidth()).toBe(0)
1752
+ expect(root_child0.getComputedHeight()).toBe(20)
1753
+ } finally {
1754
+ if (typeof root !== "undefined") {
1755
+ root.freeRecursive()
1756
+ }
1757
+
1758
+ config.free()
1759
+ }
1760
+ })