@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,1446 @@
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<<1bd782301afbab34ed3c9a296c3ecaa6>>
8
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.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("max_width", () => {
32
+ const config = Yoga.Config.create()
33
+ let root
34
+
35
+ try {
36
+ root = Yoga.Node.create(config)
37
+ root.setPositionType(PositionType.Absolute)
38
+ root.setWidth(100)
39
+ root.setHeight(100)
40
+
41
+ const root_child0 = Yoga.Node.create(config)
42
+ root_child0.setMaxWidth(50)
43
+ root_child0.setHeight(10)
44
+ root.insertChild(root_child0, 0)
45
+ root.calculateLayout(undefined, undefined, Direction.LTR)
46
+
47
+ expect(root.getComputedLeft()).toBe(0)
48
+ expect(root.getComputedTop()).toBe(0)
49
+ expect(root.getComputedWidth()).toBe(100)
50
+ expect(root.getComputedHeight()).toBe(100)
51
+
52
+ expect(root_child0.getComputedLeft()).toBe(0)
53
+ expect(root_child0.getComputedTop()).toBe(0)
54
+ expect(root_child0.getComputedWidth()).toBe(50)
55
+ expect(root_child0.getComputedHeight()).toBe(10)
56
+
57
+ root.calculateLayout(undefined, undefined, Direction.RTL)
58
+
59
+ expect(root.getComputedLeft()).toBe(0)
60
+ expect(root.getComputedTop()).toBe(0)
61
+ expect(root.getComputedWidth()).toBe(100)
62
+ expect(root.getComputedHeight()).toBe(100)
63
+
64
+ expect(root_child0.getComputedLeft()).toBe(50)
65
+ expect(root_child0.getComputedTop()).toBe(0)
66
+ expect(root_child0.getComputedWidth()).toBe(50)
67
+ expect(root_child0.getComputedHeight()).toBe(10)
68
+ } finally {
69
+ if (typeof root !== "undefined") {
70
+ root.freeRecursive()
71
+ }
72
+
73
+ config.free()
74
+ }
75
+ })
76
+ test("max_height", () => {
77
+ const config = Yoga.Config.create()
78
+ let root
79
+
80
+ try {
81
+ root = Yoga.Node.create(config)
82
+ root.setFlexDirection(FlexDirection.Row)
83
+ root.setPositionType(PositionType.Absolute)
84
+ root.setWidth(100)
85
+ root.setHeight(100)
86
+
87
+ const root_child0 = Yoga.Node.create(config)
88
+ root_child0.setWidth(10)
89
+ root_child0.setMaxHeight(50)
90
+ root.insertChild(root_child0, 0)
91
+ root.calculateLayout(undefined, undefined, Direction.LTR)
92
+
93
+ expect(root.getComputedLeft()).toBe(0)
94
+ expect(root.getComputedTop()).toBe(0)
95
+ expect(root.getComputedWidth()).toBe(100)
96
+ expect(root.getComputedHeight()).toBe(100)
97
+
98
+ expect(root_child0.getComputedLeft()).toBe(0)
99
+ expect(root_child0.getComputedTop()).toBe(0)
100
+ expect(root_child0.getComputedWidth()).toBe(10)
101
+ expect(root_child0.getComputedHeight()).toBe(50)
102
+
103
+ root.calculateLayout(undefined, undefined, Direction.RTL)
104
+
105
+ expect(root.getComputedLeft()).toBe(0)
106
+ expect(root.getComputedTop()).toBe(0)
107
+ expect(root.getComputedWidth()).toBe(100)
108
+ expect(root.getComputedHeight()).toBe(100)
109
+
110
+ expect(root_child0.getComputedLeft()).toBe(90)
111
+ expect(root_child0.getComputedTop()).toBe(0)
112
+ expect(root_child0.getComputedWidth()).toBe(10)
113
+ expect(root_child0.getComputedHeight()).toBe(50)
114
+ } finally {
115
+ if (typeof root !== "undefined") {
116
+ root.freeRecursive()
117
+ }
118
+
119
+ config.free()
120
+ }
121
+ })
122
+ test.skip("min_height", () => {
123
+ const config = Yoga.Config.create()
124
+ let root
125
+
126
+ try {
127
+ root = Yoga.Node.create(config)
128
+ root.setPositionType(PositionType.Absolute)
129
+ root.setWidth(100)
130
+ root.setHeight(100)
131
+
132
+ const root_child0 = Yoga.Node.create(config)
133
+ root_child0.setFlexGrow(1)
134
+ root_child0.setMinHeight(60)
135
+ root.insertChild(root_child0, 0)
136
+
137
+ const root_child1 = Yoga.Node.create(config)
138
+ root_child1.setFlexGrow(1)
139
+ root.insertChild(root_child1, 1)
140
+ root.calculateLayout(undefined, undefined, Direction.LTR)
141
+
142
+ expect(root.getComputedLeft()).toBe(0)
143
+ expect(root.getComputedTop()).toBe(0)
144
+ expect(root.getComputedWidth()).toBe(100)
145
+ expect(root.getComputedHeight()).toBe(100)
146
+
147
+ expect(root_child0.getComputedLeft()).toBe(0)
148
+ expect(root_child0.getComputedTop()).toBe(0)
149
+ expect(root_child0.getComputedWidth()).toBe(100)
150
+ expect(root_child0.getComputedHeight()).toBe(60)
151
+
152
+ expect(root_child1.getComputedLeft()).toBe(0)
153
+ expect(root_child1.getComputedTop()).toBe(60)
154
+ expect(root_child1.getComputedWidth()).toBe(100)
155
+ expect(root_child1.getComputedHeight()).toBe(40)
156
+
157
+ root.calculateLayout(undefined, undefined, Direction.RTL)
158
+
159
+ expect(root.getComputedLeft()).toBe(0)
160
+ expect(root.getComputedTop()).toBe(0)
161
+ expect(root.getComputedWidth()).toBe(100)
162
+ expect(root.getComputedHeight()).toBe(100)
163
+
164
+ expect(root_child0.getComputedLeft()).toBe(0)
165
+ expect(root_child0.getComputedTop()).toBe(0)
166
+ expect(root_child0.getComputedWidth()).toBe(100)
167
+ expect(root_child0.getComputedHeight()).toBe(60)
168
+
169
+ expect(root_child1.getComputedLeft()).toBe(0)
170
+ expect(root_child1.getComputedTop()).toBe(60)
171
+ expect(root_child1.getComputedWidth()).toBe(100)
172
+ expect(root_child1.getComputedHeight()).toBe(40)
173
+ } finally {
174
+ if (typeof root !== "undefined") {
175
+ root.freeRecursive()
176
+ }
177
+
178
+ config.free()
179
+ }
180
+ })
181
+ test.skip("min_width", () => {
182
+ const config = Yoga.Config.create()
183
+ let root
184
+
185
+ try {
186
+ root = Yoga.Node.create(config)
187
+ root.setFlexDirection(FlexDirection.Row)
188
+ root.setPositionType(PositionType.Absolute)
189
+ root.setWidth(100)
190
+ root.setHeight(100)
191
+
192
+ const root_child0 = Yoga.Node.create(config)
193
+ root_child0.setFlexGrow(1)
194
+ root_child0.setMinWidth(60)
195
+ root.insertChild(root_child0, 0)
196
+
197
+ const root_child1 = Yoga.Node.create(config)
198
+ root_child1.setFlexGrow(1)
199
+ root.insertChild(root_child1, 1)
200
+ root.calculateLayout(undefined, undefined, Direction.LTR)
201
+
202
+ expect(root.getComputedLeft()).toBe(0)
203
+ expect(root.getComputedTop()).toBe(0)
204
+ expect(root.getComputedWidth()).toBe(100)
205
+ expect(root.getComputedHeight()).toBe(100)
206
+
207
+ expect(root_child0.getComputedLeft()).toBe(0)
208
+ expect(root_child0.getComputedTop()).toBe(0)
209
+ expect(root_child0.getComputedWidth()).toBe(60)
210
+ expect(root_child0.getComputedHeight()).toBe(100)
211
+
212
+ expect(root_child1.getComputedLeft()).toBe(60)
213
+ expect(root_child1.getComputedTop()).toBe(0)
214
+ expect(root_child1.getComputedWidth()).toBe(40)
215
+ expect(root_child1.getComputedHeight()).toBe(100)
216
+
217
+ root.calculateLayout(undefined, undefined, Direction.RTL)
218
+
219
+ expect(root.getComputedLeft()).toBe(0)
220
+ expect(root.getComputedTop()).toBe(0)
221
+ expect(root.getComputedWidth()).toBe(100)
222
+ expect(root.getComputedHeight()).toBe(100)
223
+
224
+ expect(root_child0.getComputedLeft()).toBe(40)
225
+ expect(root_child0.getComputedTop()).toBe(0)
226
+ expect(root_child0.getComputedWidth()).toBe(60)
227
+ expect(root_child0.getComputedHeight()).toBe(100)
228
+
229
+ expect(root_child1.getComputedLeft()).toBe(0)
230
+ expect(root_child1.getComputedTop()).toBe(0)
231
+ expect(root_child1.getComputedWidth()).toBe(40)
232
+ expect(root_child1.getComputedHeight()).toBe(100)
233
+ } finally {
234
+ if (typeof root !== "undefined") {
235
+ root.freeRecursive()
236
+ }
237
+
238
+ config.free()
239
+ }
240
+ })
241
+ test("justify_content_min_max", () => {
242
+ const config = Yoga.Config.create()
243
+ let root
244
+
245
+ try {
246
+ root = Yoga.Node.create(config)
247
+ root.setJustifyContent(Justify.Center)
248
+ root.setPositionType(PositionType.Absolute)
249
+ root.setWidth(100)
250
+ root.setMinHeight(100)
251
+ root.setMaxHeight(200)
252
+
253
+ const root_child0 = Yoga.Node.create(config)
254
+ root_child0.setWidth(60)
255
+ root_child0.setHeight(60)
256
+ root.insertChild(root_child0, 0)
257
+ root.calculateLayout(undefined, undefined, Direction.LTR)
258
+
259
+ expect(root.getComputedLeft()).toBe(0)
260
+ expect(root.getComputedTop()).toBe(0)
261
+ expect(root.getComputedWidth()).toBe(100)
262
+ expect(root.getComputedHeight()).toBe(100)
263
+
264
+ expect(root_child0.getComputedLeft()).toBe(0)
265
+ expect(root_child0.getComputedTop()).toBe(20)
266
+ expect(root_child0.getComputedWidth()).toBe(60)
267
+ expect(root_child0.getComputedHeight()).toBe(60)
268
+
269
+ root.calculateLayout(undefined, undefined, Direction.RTL)
270
+
271
+ expect(root.getComputedLeft()).toBe(0)
272
+ expect(root.getComputedTop()).toBe(0)
273
+ expect(root.getComputedWidth()).toBe(100)
274
+ expect(root.getComputedHeight()).toBe(100)
275
+
276
+ expect(root_child0.getComputedLeft()).toBe(40)
277
+ expect(root_child0.getComputedTop()).toBe(20)
278
+ expect(root_child0.getComputedWidth()).toBe(60)
279
+ expect(root_child0.getComputedHeight()).toBe(60)
280
+ } finally {
281
+ if (typeof root !== "undefined") {
282
+ root.freeRecursive()
283
+ }
284
+
285
+ config.free()
286
+ }
287
+ })
288
+ test("align_items_min_max", () => {
289
+ const config = Yoga.Config.create()
290
+ let root
291
+
292
+ try {
293
+ root = Yoga.Node.create(config)
294
+ root.setAlignItems(Align.Center)
295
+ root.setPositionType(PositionType.Absolute)
296
+ root.setMinWidth(100)
297
+ root.setMaxWidth(200)
298
+ root.setHeight(100)
299
+
300
+ const root_child0 = Yoga.Node.create(config)
301
+ root_child0.setWidth(60)
302
+ root_child0.setHeight(60)
303
+ root.insertChild(root_child0, 0)
304
+ root.calculateLayout(undefined, undefined, Direction.LTR)
305
+
306
+ expect(root.getComputedLeft()).toBe(0)
307
+ expect(root.getComputedTop()).toBe(0)
308
+ expect(root.getComputedWidth()).toBe(100)
309
+ expect(root.getComputedHeight()).toBe(100)
310
+
311
+ expect(root_child0.getComputedLeft()).toBe(20)
312
+ expect(root_child0.getComputedTop()).toBe(0)
313
+ expect(root_child0.getComputedWidth()).toBe(60)
314
+ expect(root_child0.getComputedHeight()).toBe(60)
315
+
316
+ root.calculateLayout(undefined, undefined, Direction.RTL)
317
+
318
+ expect(root.getComputedLeft()).toBe(0)
319
+ expect(root.getComputedTop()).toBe(0)
320
+ expect(root.getComputedWidth()).toBe(100)
321
+ expect(root.getComputedHeight()).toBe(100)
322
+
323
+ expect(root_child0.getComputedLeft()).toBe(20)
324
+ expect(root_child0.getComputedTop()).toBe(0)
325
+ expect(root_child0.getComputedWidth()).toBe(60)
326
+ expect(root_child0.getComputedHeight()).toBe(60)
327
+ } finally {
328
+ if (typeof root !== "undefined") {
329
+ root.freeRecursive()
330
+ }
331
+
332
+ config.free()
333
+ }
334
+ })
335
+ test("justify_content_overflow_min_max", () => {
336
+ const config = Yoga.Config.create()
337
+ let root
338
+
339
+ try {
340
+ root = Yoga.Node.create(config)
341
+ root.setJustifyContent(Justify.Center)
342
+ root.setPositionType(PositionType.Absolute)
343
+ root.setMinHeight(100)
344
+ root.setMaxHeight(110)
345
+
346
+ const root_child0 = Yoga.Node.create(config)
347
+ root_child0.setWidth(50)
348
+ root_child0.setHeight(50)
349
+ root.insertChild(root_child0, 0)
350
+
351
+ const root_child1 = Yoga.Node.create(config)
352
+ root_child1.setWidth(50)
353
+ root_child1.setHeight(50)
354
+ root.insertChild(root_child1, 1)
355
+
356
+ const root_child2 = Yoga.Node.create(config)
357
+ root_child2.setWidth(50)
358
+ root_child2.setHeight(50)
359
+ root.insertChild(root_child2, 2)
360
+ root.calculateLayout(undefined, undefined, Direction.LTR)
361
+
362
+ expect(root.getComputedLeft()).toBe(0)
363
+ expect(root.getComputedTop()).toBe(0)
364
+ expect(root.getComputedWidth()).toBe(50)
365
+ expect(root.getComputedHeight()).toBe(110)
366
+
367
+ expect(root_child0.getComputedLeft()).toBe(0)
368
+ expect(root_child0.getComputedTop()).toBe(-20)
369
+ expect(root_child0.getComputedWidth()).toBe(50)
370
+ expect(root_child0.getComputedHeight()).toBe(50)
371
+
372
+ expect(root_child1.getComputedLeft()).toBe(0)
373
+ expect(root_child1.getComputedTop()).toBe(30)
374
+ expect(root_child1.getComputedWidth()).toBe(50)
375
+ expect(root_child1.getComputedHeight()).toBe(50)
376
+
377
+ expect(root_child2.getComputedLeft()).toBe(0)
378
+ expect(root_child2.getComputedTop()).toBe(80)
379
+ expect(root_child2.getComputedWidth()).toBe(50)
380
+ expect(root_child2.getComputedHeight()).toBe(50)
381
+
382
+ root.calculateLayout(undefined, undefined, Direction.RTL)
383
+
384
+ expect(root.getComputedLeft()).toBe(0)
385
+ expect(root.getComputedTop()).toBe(0)
386
+ expect(root.getComputedWidth()).toBe(50)
387
+ expect(root.getComputedHeight()).toBe(110)
388
+
389
+ expect(root_child0.getComputedLeft()).toBe(0)
390
+ expect(root_child0.getComputedTop()).toBe(-20)
391
+ expect(root_child0.getComputedWidth()).toBe(50)
392
+ expect(root_child0.getComputedHeight()).toBe(50)
393
+
394
+ expect(root_child1.getComputedLeft()).toBe(0)
395
+ expect(root_child1.getComputedTop()).toBe(30)
396
+ expect(root_child1.getComputedWidth()).toBe(50)
397
+ expect(root_child1.getComputedHeight()).toBe(50)
398
+
399
+ expect(root_child2.getComputedLeft()).toBe(0)
400
+ expect(root_child2.getComputedTop()).toBe(80)
401
+ expect(root_child2.getComputedWidth()).toBe(50)
402
+ expect(root_child2.getComputedHeight()).toBe(50)
403
+ } finally {
404
+ if (typeof root !== "undefined") {
405
+ root.freeRecursive()
406
+ }
407
+
408
+ config.free()
409
+ }
410
+ })
411
+ test("flex_grow_to_min", () => {
412
+ const config = Yoga.Config.create()
413
+ let root
414
+
415
+ try {
416
+ root = Yoga.Node.create(config)
417
+ root.setPositionType(PositionType.Absolute)
418
+ root.setWidth(100)
419
+ root.setMinHeight(100)
420
+ root.setMaxHeight(500)
421
+
422
+ const root_child0 = Yoga.Node.create(config)
423
+ root_child0.setFlexGrow(1)
424
+ root_child0.setFlexShrink(1)
425
+ root.insertChild(root_child0, 0)
426
+
427
+ const root_child1 = Yoga.Node.create(config)
428
+ root_child1.setHeight(50)
429
+ root.insertChild(root_child1, 1)
430
+ root.calculateLayout(undefined, undefined, Direction.LTR)
431
+
432
+ expect(root.getComputedLeft()).toBe(0)
433
+ expect(root.getComputedTop()).toBe(0)
434
+ expect(root.getComputedWidth()).toBe(100)
435
+ expect(root.getComputedHeight()).toBe(100)
436
+
437
+ expect(root_child0.getComputedLeft()).toBe(0)
438
+ expect(root_child0.getComputedTop()).toBe(0)
439
+ expect(root_child0.getComputedWidth()).toBe(100)
440
+ expect(root_child0.getComputedHeight()).toBe(50)
441
+
442
+ expect(root_child1.getComputedLeft()).toBe(0)
443
+ expect(root_child1.getComputedTop()).toBe(50)
444
+ expect(root_child1.getComputedWidth()).toBe(100)
445
+ expect(root_child1.getComputedHeight()).toBe(50)
446
+
447
+ root.calculateLayout(undefined, undefined, Direction.RTL)
448
+
449
+ expect(root.getComputedLeft()).toBe(0)
450
+ expect(root.getComputedTop()).toBe(0)
451
+ expect(root.getComputedWidth()).toBe(100)
452
+ expect(root.getComputedHeight()).toBe(100)
453
+
454
+ expect(root_child0.getComputedLeft()).toBe(0)
455
+ expect(root_child0.getComputedTop()).toBe(0)
456
+ expect(root_child0.getComputedWidth()).toBe(100)
457
+ expect(root_child0.getComputedHeight()).toBe(50)
458
+
459
+ expect(root_child1.getComputedLeft()).toBe(0)
460
+ expect(root_child1.getComputedTop()).toBe(50)
461
+ expect(root_child1.getComputedWidth()).toBe(100)
462
+ expect(root_child1.getComputedHeight()).toBe(50)
463
+ } finally {
464
+ if (typeof root !== "undefined") {
465
+ root.freeRecursive()
466
+ }
467
+
468
+ config.free()
469
+ }
470
+ })
471
+ test("flex_grow_in_at_most_container", () => {
472
+ const config = Yoga.Config.create()
473
+ let root
474
+
475
+ try {
476
+ root = Yoga.Node.create(config)
477
+ root.setFlexDirection(FlexDirection.Row)
478
+ root.setAlignItems(Align.FlexStart)
479
+ root.setPositionType(PositionType.Absolute)
480
+ root.setWidth(100)
481
+ root.setHeight(100)
482
+
483
+ const root_child0 = Yoga.Node.create(config)
484
+ root_child0.setFlexDirection(FlexDirection.Row)
485
+ root.insertChild(root_child0, 0)
486
+
487
+ const root_child0_child0 = Yoga.Node.create(config)
488
+ root_child0_child0.setFlexGrow(1)
489
+ root_child0_child0.setFlexBasis(0)
490
+ root_child0.insertChild(root_child0_child0, 0)
491
+ root.calculateLayout(undefined, undefined, Direction.LTR)
492
+
493
+ expect(root.getComputedLeft()).toBe(0)
494
+ expect(root.getComputedTop()).toBe(0)
495
+ expect(root.getComputedWidth()).toBe(100)
496
+ expect(root.getComputedHeight()).toBe(100)
497
+
498
+ expect(root_child0.getComputedLeft()).toBe(0)
499
+ expect(root_child0.getComputedTop()).toBe(0)
500
+ expect(root_child0.getComputedWidth()).toBe(0)
501
+ expect(root_child0.getComputedHeight()).toBe(0)
502
+
503
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
504
+ expect(root_child0_child0.getComputedTop()).toBe(0)
505
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
506
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
507
+
508
+ root.calculateLayout(undefined, undefined, Direction.RTL)
509
+
510
+ expect(root.getComputedLeft()).toBe(0)
511
+ expect(root.getComputedTop()).toBe(0)
512
+ expect(root.getComputedWidth()).toBe(100)
513
+ expect(root.getComputedHeight()).toBe(100)
514
+
515
+ expect(root_child0.getComputedLeft()).toBe(100)
516
+ expect(root_child0.getComputedTop()).toBe(0)
517
+ expect(root_child0.getComputedWidth()).toBe(0)
518
+ expect(root_child0.getComputedHeight()).toBe(0)
519
+
520
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
521
+ expect(root_child0_child0.getComputedTop()).toBe(0)
522
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
523
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
524
+ } finally {
525
+ if (typeof root !== "undefined") {
526
+ root.freeRecursive()
527
+ }
528
+
529
+ config.free()
530
+ }
531
+ })
532
+ test("flex_grow_child", () => {
533
+ const config = Yoga.Config.create()
534
+ let root
535
+
536
+ try {
537
+ root = Yoga.Node.create(config)
538
+ root.setFlexDirection(FlexDirection.Row)
539
+ root.setPositionType(PositionType.Absolute)
540
+
541
+ const root_child0 = Yoga.Node.create(config)
542
+ root_child0.setFlexGrow(1)
543
+ root_child0.setFlexBasis(0)
544
+ root_child0.setHeight(100)
545
+ root.insertChild(root_child0, 0)
546
+ root.calculateLayout(undefined, undefined, Direction.LTR)
547
+
548
+ expect(root.getComputedLeft()).toBe(0)
549
+ expect(root.getComputedTop()).toBe(0)
550
+ expect(root.getComputedWidth()).toBe(0)
551
+ expect(root.getComputedHeight()).toBe(100)
552
+
553
+ expect(root_child0.getComputedLeft()).toBe(0)
554
+ expect(root_child0.getComputedTop()).toBe(0)
555
+ expect(root_child0.getComputedWidth()).toBe(0)
556
+ expect(root_child0.getComputedHeight()).toBe(100)
557
+
558
+ root.calculateLayout(undefined, undefined, Direction.RTL)
559
+
560
+ expect(root.getComputedLeft()).toBe(0)
561
+ expect(root.getComputedTop()).toBe(0)
562
+ expect(root.getComputedWidth()).toBe(0)
563
+ expect(root.getComputedHeight()).toBe(100)
564
+
565
+ expect(root_child0.getComputedLeft()).toBe(0)
566
+ expect(root_child0.getComputedTop()).toBe(0)
567
+ expect(root_child0.getComputedWidth()).toBe(0)
568
+ expect(root_child0.getComputedHeight()).toBe(100)
569
+ } finally {
570
+ if (typeof root !== "undefined") {
571
+ root.freeRecursive()
572
+ }
573
+
574
+ config.free()
575
+ }
576
+ })
577
+ test("flex_grow_within_constrained_min_max_column", () => {
578
+ const config = Yoga.Config.create()
579
+ let root
580
+
581
+ try {
582
+ root = Yoga.Node.create(config)
583
+ root.setPositionType(PositionType.Absolute)
584
+ root.setMinHeight(100)
585
+ root.setMaxHeight(200)
586
+
587
+ const root_child0 = Yoga.Node.create(config)
588
+ root_child0.setFlexGrow(1)
589
+ root.insertChild(root_child0, 0)
590
+
591
+ const root_child1 = Yoga.Node.create(config)
592
+ root_child1.setHeight(50)
593
+ root.insertChild(root_child1, 1)
594
+ root.calculateLayout(undefined, undefined, Direction.LTR)
595
+
596
+ expect(root.getComputedLeft()).toBe(0)
597
+ expect(root.getComputedTop()).toBe(0)
598
+ expect(root.getComputedWidth()).toBe(0)
599
+ expect(root.getComputedHeight()).toBe(100)
600
+
601
+ expect(root_child0.getComputedLeft()).toBe(0)
602
+ expect(root_child0.getComputedTop()).toBe(0)
603
+ expect(root_child0.getComputedWidth()).toBe(0)
604
+ expect(root_child0.getComputedHeight()).toBe(50)
605
+
606
+ expect(root_child1.getComputedLeft()).toBe(0)
607
+ expect(root_child1.getComputedTop()).toBe(50)
608
+ expect(root_child1.getComputedWidth()).toBe(0)
609
+ expect(root_child1.getComputedHeight()).toBe(50)
610
+
611
+ root.calculateLayout(undefined, undefined, Direction.RTL)
612
+
613
+ expect(root.getComputedLeft()).toBe(0)
614
+ expect(root.getComputedTop()).toBe(0)
615
+ expect(root.getComputedWidth()).toBe(0)
616
+ expect(root.getComputedHeight()).toBe(100)
617
+
618
+ expect(root_child0.getComputedLeft()).toBe(0)
619
+ expect(root_child0.getComputedTop()).toBe(0)
620
+ expect(root_child0.getComputedWidth()).toBe(0)
621
+ expect(root_child0.getComputedHeight()).toBe(50)
622
+
623
+ expect(root_child1.getComputedLeft()).toBe(0)
624
+ expect(root_child1.getComputedTop()).toBe(50)
625
+ expect(root_child1.getComputedWidth()).toBe(0)
626
+ expect(root_child1.getComputedHeight()).toBe(50)
627
+ } finally {
628
+ if (typeof root !== "undefined") {
629
+ root.freeRecursive()
630
+ }
631
+
632
+ config.free()
633
+ }
634
+ })
635
+ test("flex_grow_within_max_width", () => {
636
+ const config = Yoga.Config.create()
637
+ let root
638
+
639
+ try {
640
+ root = Yoga.Node.create(config)
641
+ root.setPositionType(PositionType.Absolute)
642
+ root.setWidth(200)
643
+ root.setHeight(100)
644
+
645
+ const root_child0 = Yoga.Node.create(config)
646
+ root_child0.setFlexDirection(FlexDirection.Row)
647
+ root_child0.setMaxWidth(100)
648
+ root.insertChild(root_child0, 0)
649
+
650
+ const root_child0_child0 = Yoga.Node.create(config)
651
+ root_child0_child0.setFlexGrow(1)
652
+ root_child0_child0.setHeight(20)
653
+ root_child0.insertChild(root_child0_child0, 0)
654
+ root.calculateLayout(undefined, undefined, Direction.LTR)
655
+
656
+ expect(root.getComputedLeft()).toBe(0)
657
+ expect(root.getComputedTop()).toBe(0)
658
+ expect(root.getComputedWidth()).toBe(200)
659
+ expect(root.getComputedHeight()).toBe(100)
660
+
661
+ expect(root_child0.getComputedLeft()).toBe(0)
662
+ expect(root_child0.getComputedTop()).toBe(0)
663
+ expect(root_child0.getComputedWidth()).toBe(100)
664
+ expect(root_child0.getComputedHeight()).toBe(20)
665
+
666
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
667
+ expect(root_child0_child0.getComputedTop()).toBe(0)
668
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
669
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
670
+
671
+ root.calculateLayout(undefined, undefined, Direction.RTL)
672
+
673
+ expect(root.getComputedLeft()).toBe(0)
674
+ expect(root.getComputedTop()).toBe(0)
675
+ expect(root.getComputedWidth()).toBe(200)
676
+ expect(root.getComputedHeight()).toBe(100)
677
+
678
+ expect(root_child0.getComputedLeft()).toBe(100)
679
+ expect(root_child0.getComputedTop()).toBe(0)
680
+ expect(root_child0.getComputedWidth()).toBe(100)
681
+ expect(root_child0.getComputedHeight()).toBe(20)
682
+
683
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
684
+ expect(root_child0_child0.getComputedTop()).toBe(0)
685
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
686
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
687
+ } finally {
688
+ if (typeof root !== "undefined") {
689
+ root.freeRecursive()
690
+ }
691
+
692
+ config.free()
693
+ }
694
+ })
695
+ test("flex_grow_within_constrained_max_width", () => {
696
+ const config = Yoga.Config.create()
697
+ let root
698
+
699
+ try {
700
+ root = Yoga.Node.create(config)
701
+ root.setPositionType(PositionType.Absolute)
702
+ root.setWidth(200)
703
+ root.setHeight(100)
704
+
705
+ const root_child0 = Yoga.Node.create(config)
706
+ root_child0.setFlexDirection(FlexDirection.Row)
707
+ root_child0.setMaxWidth(300)
708
+ root.insertChild(root_child0, 0)
709
+
710
+ const root_child0_child0 = Yoga.Node.create(config)
711
+ root_child0_child0.setFlexGrow(1)
712
+ root_child0_child0.setHeight(20)
713
+ root_child0.insertChild(root_child0_child0, 0)
714
+ root.calculateLayout(undefined, undefined, Direction.LTR)
715
+
716
+ expect(root.getComputedLeft()).toBe(0)
717
+ expect(root.getComputedTop()).toBe(0)
718
+ expect(root.getComputedWidth()).toBe(200)
719
+ expect(root.getComputedHeight()).toBe(100)
720
+
721
+ expect(root_child0.getComputedLeft()).toBe(0)
722
+ expect(root_child0.getComputedTop()).toBe(0)
723
+ expect(root_child0.getComputedWidth()).toBe(200)
724
+ expect(root_child0.getComputedHeight()).toBe(20)
725
+
726
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
727
+ expect(root_child0_child0.getComputedTop()).toBe(0)
728
+ expect(root_child0_child0.getComputedWidth()).toBe(200)
729
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
730
+
731
+ root.calculateLayout(undefined, undefined, Direction.RTL)
732
+
733
+ expect(root.getComputedLeft()).toBe(0)
734
+ expect(root.getComputedTop()).toBe(0)
735
+ expect(root.getComputedWidth()).toBe(200)
736
+ expect(root.getComputedHeight()).toBe(100)
737
+
738
+ expect(root_child0.getComputedLeft()).toBe(0)
739
+ expect(root_child0.getComputedTop()).toBe(0)
740
+ expect(root_child0.getComputedWidth()).toBe(200)
741
+ expect(root_child0.getComputedHeight()).toBe(20)
742
+
743
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
744
+ expect(root_child0_child0.getComputedTop()).toBe(0)
745
+ expect(root_child0_child0.getComputedWidth()).toBe(200)
746
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
747
+ } finally {
748
+ if (typeof root !== "undefined") {
749
+ root.freeRecursive()
750
+ }
751
+
752
+ config.free()
753
+ }
754
+ })
755
+ test("flex_root_ignored", () => {
756
+ const config = Yoga.Config.create()
757
+ let root
758
+
759
+ try {
760
+ root = Yoga.Node.create(config)
761
+ root.setPositionType(PositionType.Absolute)
762
+ root.setFlexGrow(1)
763
+ root.setWidth(100)
764
+ root.setMinHeight(100)
765
+ root.setMaxHeight(500)
766
+
767
+ const root_child0 = Yoga.Node.create(config)
768
+ root_child0.setFlexGrow(1)
769
+ root_child0.setFlexBasis(200)
770
+ root.insertChild(root_child0, 0)
771
+
772
+ const root_child1 = Yoga.Node.create(config)
773
+ root_child1.setHeight(100)
774
+ root.insertChild(root_child1, 1)
775
+ root.calculateLayout(undefined, undefined, Direction.LTR)
776
+
777
+ expect(root.getComputedLeft()).toBe(0)
778
+ expect(root.getComputedTop()).toBe(0)
779
+ expect(root.getComputedWidth()).toBe(100)
780
+ expect(root.getComputedHeight()).toBe(300)
781
+
782
+ expect(root_child0.getComputedLeft()).toBe(0)
783
+ expect(root_child0.getComputedTop()).toBe(0)
784
+ expect(root_child0.getComputedWidth()).toBe(100)
785
+ expect(root_child0.getComputedHeight()).toBe(200)
786
+
787
+ expect(root_child1.getComputedLeft()).toBe(0)
788
+ expect(root_child1.getComputedTop()).toBe(200)
789
+ expect(root_child1.getComputedWidth()).toBe(100)
790
+ expect(root_child1.getComputedHeight()).toBe(100)
791
+
792
+ root.calculateLayout(undefined, undefined, Direction.RTL)
793
+
794
+ expect(root.getComputedLeft()).toBe(0)
795
+ expect(root.getComputedTop()).toBe(0)
796
+ expect(root.getComputedWidth()).toBe(100)
797
+ expect(root.getComputedHeight()).toBe(300)
798
+
799
+ expect(root_child0.getComputedLeft()).toBe(0)
800
+ expect(root_child0.getComputedTop()).toBe(0)
801
+ expect(root_child0.getComputedWidth()).toBe(100)
802
+ expect(root_child0.getComputedHeight()).toBe(200)
803
+
804
+ expect(root_child1.getComputedLeft()).toBe(0)
805
+ expect(root_child1.getComputedTop()).toBe(200)
806
+ expect(root_child1.getComputedWidth()).toBe(100)
807
+ expect(root_child1.getComputedHeight()).toBe(100)
808
+ } finally {
809
+ if (typeof root !== "undefined") {
810
+ root.freeRecursive()
811
+ }
812
+
813
+ config.free()
814
+ }
815
+ })
816
+ test("flex_grow_root_minimized", () => {
817
+ const config = Yoga.Config.create()
818
+ let root
819
+
820
+ try {
821
+ root = Yoga.Node.create(config)
822
+ root.setPositionType(PositionType.Absolute)
823
+ root.setWidth(100)
824
+ root.setMinHeight(100)
825
+ root.setMaxHeight(500)
826
+
827
+ const root_child0 = Yoga.Node.create(config)
828
+ root_child0.setFlexGrow(1)
829
+ root_child0.setMinHeight(100)
830
+ root_child0.setMaxHeight(500)
831
+ root.insertChild(root_child0, 0)
832
+
833
+ const root_child0_child0 = Yoga.Node.create(config)
834
+ root_child0_child0.setFlexGrow(1)
835
+ root_child0_child0.setFlexBasis(200)
836
+ root_child0.insertChild(root_child0_child0, 0)
837
+
838
+ const root_child0_child1 = Yoga.Node.create(config)
839
+ root_child0_child1.setHeight(100)
840
+ root_child0.insertChild(root_child0_child1, 1)
841
+ root.calculateLayout(undefined, undefined, Direction.LTR)
842
+
843
+ expect(root.getComputedLeft()).toBe(0)
844
+ expect(root.getComputedTop()).toBe(0)
845
+ expect(root.getComputedWidth()).toBe(100)
846
+ expect(root.getComputedHeight()).toBe(300)
847
+
848
+ expect(root_child0.getComputedLeft()).toBe(0)
849
+ expect(root_child0.getComputedTop()).toBe(0)
850
+ expect(root_child0.getComputedWidth()).toBe(100)
851
+ expect(root_child0.getComputedHeight()).toBe(300)
852
+
853
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
854
+ expect(root_child0_child0.getComputedTop()).toBe(0)
855
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
856
+ expect(root_child0_child0.getComputedHeight()).toBe(200)
857
+
858
+ expect(root_child0_child1.getComputedLeft()).toBe(0)
859
+ expect(root_child0_child1.getComputedTop()).toBe(200)
860
+ expect(root_child0_child1.getComputedWidth()).toBe(100)
861
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
862
+
863
+ root.calculateLayout(undefined, undefined, Direction.RTL)
864
+
865
+ expect(root.getComputedLeft()).toBe(0)
866
+ expect(root.getComputedTop()).toBe(0)
867
+ expect(root.getComputedWidth()).toBe(100)
868
+ expect(root.getComputedHeight()).toBe(300)
869
+
870
+ expect(root_child0.getComputedLeft()).toBe(0)
871
+ expect(root_child0.getComputedTop()).toBe(0)
872
+ expect(root_child0.getComputedWidth()).toBe(100)
873
+ expect(root_child0.getComputedHeight()).toBe(300)
874
+
875
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
876
+ expect(root_child0_child0.getComputedTop()).toBe(0)
877
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
878
+ expect(root_child0_child0.getComputedHeight()).toBe(200)
879
+
880
+ expect(root_child0_child1.getComputedLeft()).toBe(0)
881
+ expect(root_child0_child1.getComputedTop()).toBe(200)
882
+ expect(root_child0_child1.getComputedWidth()).toBe(100)
883
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
884
+ } finally {
885
+ if (typeof root !== "undefined") {
886
+ root.freeRecursive()
887
+ }
888
+
889
+ config.free()
890
+ }
891
+ })
892
+ test("flex_grow_height_maximized", () => {
893
+ const config = Yoga.Config.create()
894
+ let root
895
+
896
+ try {
897
+ root = Yoga.Node.create(config)
898
+ root.setPositionType(PositionType.Absolute)
899
+ root.setWidth(100)
900
+ root.setHeight(500)
901
+
902
+ const root_child0 = Yoga.Node.create(config)
903
+ root_child0.setFlexGrow(1)
904
+ root_child0.setMinHeight(100)
905
+ root_child0.setMaxHeight(500)
906
+ root.insertChild(root_child0, 0)
907
+
908
+ const root_child0_child0 = Yoga.Node.create(config)
909
+ root_child0_child0.setFlexGrow(1)
910
+ root_child0_child0.setFlexBasis(200)
911
+ root_child0.insertChild(root_child0_child0, 0)
912
+
913
+ const root_child0_child1 = Yoga.Node.create(config)
914
+ root_child0_child1.setHeight(100)
915
+ root_child0.insertChild(root_child0_child1, 1)
916
+ root.calculateLayout(undefined, undefined, Direction.LTR)
917
+
918
+ expect(root.getComputedLeft()).toBe(0)
919
+ expect(root.getComputedTop()).toBe(0)
920
+ expect(root.getComputedWidth()).toBe(100)
921
+ expect(root.getComputedHeight()).toBe(500)
922
+
923
+ expect(root_child0.getComputedLeft()).toBe(0)
924
+ expect(root_child0.getComputedTop()).toBe(0)
925
+ expect(root_child0.getComputedWidth()).toBe(100)
926
+ expect(root_child0.getComputedHeight()).toBe(500)
927
+
928
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
929
+ expect(root_child0_child0.getComputedTop()).toBe(0)
930
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
931
+ expect(root_child0_child0.getComputedHeight()).toBe(400)
932
+
933
+ expect(root_child0_child1.getComputedLeft()).toBe(0)
934
+ expect(root_child0_child1.getComputedTop()).toBe(400)
935
+ expect(root_child0_child1.getComputedWidth()).toBe(100)
936
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
937
+
938
+ root.calculateLayout(undefined, undefined, Direction.RTL)
939
+
940
+ expect(root.getComputedLeft()).toBe(0)
941
+ expect(root.getComputedTop()).toBe(0)
942
+ expect(root.getComputedWidth()).toBe(100)
943
+ expect(root.getComputedHeight()).toBe(500)
944
+
945
+ expect(root_child0.getComputedLeft()).toBe(0)
946
+ expect(root_child0.getComputedTop()).toBe(0)
947
+ expect(root_child0.getComputedWidth()).toBe(100)
948
+ expect(root_child0.getComputedHeight()).toBe(500)
949
+
950
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
951
+ expect(root_child0_child0.getComputedTop()).toBe(0)
952
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
953
+ expect(root_child0_child0.getComputedHeight()).toBe(400)
954
+
955
+ expect(root_child0_child1.getComputedLeft()).toBe(0)
956
+ expect(root_child0_child1.getComputedTop()).toBe(400)
957
+ expect(root_child0_child1.getComputedWidth()).toBe(100)
958
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
959
+ } finally {
960
+ if (typeof root !== "undefined") {
961
+ root.freeRecursive()
962
+ }
963
+
964
+ config.free()
965
+ }
966
+ })
967
+ test("flex_grow_within_constrained_min_row", () => {
968
+ const config = Yoga.Config.create()
969
+ let root
970
+
971
+ try {
972
+ root = Yoga.Node.create(config)
973
+ root.setFlexDirection(FlexDirection.Row)
974
+ root.setPositionType(PositionType.Absolute)
975
+ root.setMinWidth(100)
976
+ root.setHeight(100)
977
+
978
+ const root_child0 = Yoga.Node.create(config)
979
+ root_child0.setFlexGrow(1)
980
+ root.insertChild(root_child0, 0)
981
+
982
+ const root_child1 = Yoga.Node.create(config)
983
+ root_child1.setWidth(50)
984
+ root.insertChild(root_child1, 1)
985
+ root.calculateLayout(undefined, undefined, Direction.LTR)
986
+
987
+ expect(root.getComputedLeft()).toBe(0)
988
+ expect(root.getComputedTop()).toBe(0)
989
+ expect(root.getComputedWidth()).toBe(100)
990
+ expect(root.getComputedHeight()).toBe(100)
991
+
992
+ expect(root_child0.getComputedLeft()).toBe(0)
993
+ expect(root_child0.getComputedTop()).toBe(0)
994
+ expect(root_child0.getComputedWidth()).toBe(50)
995
+ expect(root_child0.getComputedHeight()).toBe(100)
996
+
997
+ expect(root_child1.getComputedLeft()).toBe(50)
998
+ expect(root_child1.getComputedTop()).toBe(0)
999
+ expect(root_child1.getComputedWidth()).toBe(50)
1000
+ expect(root_child1.getComputedHeight()).toBe(100)
1001
+
1002
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1003
+
1004
+ expect(root.getComputedLeft()).toBe(0)
1005
+ expect(root.getComputedTop()).toBe(0)
1006
+ expect(root.getComputedWidth()).toBe(100)
1007
+ expect(root.getComputedHeight()).toBe(100)
1008
+
1009
+ expect(root_child0.getComputedLeft()).toBe(50)
1010
+ expect(root_child0.getComputedTop()).toBe(0)
1011
+ expect(root_child0.getComputedWidth()).toBe(50)
1012
+ expect(root_child0.getComputedHeight()).toBe(100)
1013
+
1014
+ expect(root_child1.getComputedLeft()).toBe(0)
1015
+ expect(root_child1.getComputedTop()).toBe(0)
1016
+ expect(root_child1.getComputedWidth()).toBe(50)
1017
+ expect(root_child1.getComputedHeight()).toBe(100)
1018
+ } finally {
1019
+ if (typeof root !== "undefined") {
1020
+ root.freeRecursive()
1021
+ }
1022
+
1023
+ config.free()
1024
+ }
1025
+ })
1026
+ test("flex_grow_within_constrained_min_column", () => {
1027
+ const config = Yoga.Config.create()
1028
+ let root
1029
+
1030
+ try {
1031
+ root = Yoga.Node.create(config)
1032
+ root.setPositionType(PositionType.Absolute)
1033
+ root.setMinHeight(100)
1034
+
1035
+ const root_child0 = Yoga.Node.create(config)
1036
+ root_child0.setFlexGrow(1)
1037
+ root.insertChild(root_child0, 0)
1038
+
1039
+ const root_child1 = Yoga.Node.create(config)
1040
+ root_child1.setHeight(50)
1041
+ root.insertChild(root_child1, 1)
1042
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1043
+
1044
+ expect(root.getComputedLeft()).toBe(0)
1045
+ expect(root.getComputedTop()).toBe(0)
1046
+ expect(root.getComputedWidth()).toBe(0)
1047
+ expect(root.getComputedHeight()).toBe(100)
1048
+
1049
+ expect(root_child0.getComputedLeft()).toBe(0)
1050
+ expect(root_child0.getComputedTop()).toBe(0)
1051
+ expect(root_child0.getComputedWidth()).toBe(0)
1052
+ expect(root_child0.getComputedHeight()).toBe(50)
1053
+
1054
+ expect(root_child1.getComputedLeft()).toBe(0)
1055
+ expect(root_child1.getComputedTop()).toBe(50)
1056
+ expect(root_child1.getComputedWidth()).toBe(0)
1057
+ expect(root_child1.getComputedHeight()).toBe(50)
1058
+
1059
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1060
+
1061
+ expect(root.getComputedLeft()).toBe(0)
1062
+ expect(root.getComputedTop()).toBe(0)
1063
+ expect(root.getComputedWidth()).toBe(0)
1064
+ expect(root.getComputedHeight()).toBe(100)
1065
+
1066
+ expect(root_child0.getComputedLeft()).toBe(0)
1067
+ expect(root_child0.getComputedTop()).toBe(0)
1068
+ expect(root_child0.getComputedWidth()).toBe(0)
1069
+ expect(root_child0.getComputedHeight()).toBe(50)
1070
+
1071
+ expect(root_child1.getComputedLeft()).toBe(0)
1072
+ expect(root_child1.getComputedTop()).toBe(50)
1073
+ expect(root_child1.getComputedWidth()).toBe(0)
1074
+ expect(root_child1.getComputedHeight()).toBe(50)
1075
+ } finally {
1076
+ if (typeof root !== "undefined") {
1077
+ root.freeRecursive()
1078
+ }
1079
+
1080
+ config.free()
1081
+ }
1082
+ })
1083
+ test("flex_grow_within_constrained_max_row", () => {
1084
+ const config = Yoga.Config.create()
1085
+ let root
1086
+
1087
+ try {
1088
+ root = Yoga.Node.create(config)
1089
+ root.setPositionType(PositionType.Absolute)
1090
+ root.setWidth(200)
1091
+
1092
+ const root_child0 = Yoga.Node.create(config)
1093
+ root_child0.setFlexDirection(FlexDirection.Row)
1094
+ root_child0.setMaxWidth(100)
1095
+ root_child0.setHeight(100)
1096
+ root.insertChild(root_child0, 0)
1097
+
1098
+ const root_child0_child0 = Yoga.Node.create(config)
1099
+ root_child0_child0.setFlexShrink(1)
1100
+ root_child0_child0.setFlexBasis(100)
1101
+ root_child0.insertChild(root_child0_child0, 0)
1102
+
1103
+ const root_child0_child1 = Yoga.Node.create(config)
1104
+ root_child0_child1.setWidth(50)
1105
+ root_child0.insertChild(root_child0_child1, 1)
1106
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1107
+
1108
+ expect(root.getComputedLeft()).toBe(0)
1109
+ expect(root.getComputedTop()).toBe(0)
1110
+ expect(root.getComputedWidth()).toBe(200)
1111
+ expect(root.getComputedHeight()).toBe(100)
1112
+
1113
+ expect(root_child0.getComputedLeft()).toBe(0)
1114
+ expect(root_child0.getComputedTop()).toBe(0)
1115
+ expect(root_child0.getComputedWidth()).toBe(100)
1116
+ expect(root_child0.getComputedHeight()).toBe(100)
1117
+
1118
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1119
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1120
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
1121
+ expect(root_child0_child0.getComputedHeight()).toBe(100)
1122
+
1123
+ expect(root_child0_child1.getComputedLeft()).toBe(50)
1124
+ expect(root_child0_child1.getComputedTop()).toBe(0)
1125
+ expect(root_child0_child1.getComputedWidth()).toBe(50)
1126
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
1127
+
1128
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1129
+
1130
+ expect(root.getComputedLeft()).toBe(0)
1131
+ expect(root.getComputedTop()).toBe(0)
1132
+ expect(root.getComputedWidth()).toBe(200)
1133
+ expect(root.getComputedHeight()).toBe(100)
1134
+
1135
+ expect(root_child0.getComputedLeft()).toBe(100)
1136
+ expect(root_child0.getComputedTop()).toBe(0)
1137
+ expect(root_child0.getComputedWidth()).toBe(100)
1138
+ expect(root_child0.getComputedHeight()).toBe(100)
1139
+
1140
+ expect(root_child0_child0.getComputedLeft()).toBe(50)
1141
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1142
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
1143
+ expect(root_child0_child0.getComputedHeight()).toBe(100)
1144
+
1145
+ expect(root_child0_child1.getComputedLeft()).toBe(0)
1146
+ expect(root_child0_child1.getComputedTop()).toBe(0)
1147
+ expect(root_child0_child1.getComputedWidth()).toBe(50)
1148
+ expect(root_child0_child1.getComputedHeight()).toBe(100)
1149
+ } finally {
1150
+ if (typeof root !== "undefined") {
1151
+ root.freeRecursive()
1152
+ }
1153
+
1154
+ config.free()
1155
+ }
1156
+ })
1157
+ test("flex_grow_within_constrained_max_column", () => {
1158
+ const config = Yoga.Config.create()
1159
+ let root
1160
+
1161
+ try {
1162
+ root = Yoga.Node.create(config)
1163
+ root.setPositionType(PositionType.Absolute)
1164
+ root.setWidth(100)
1165
+ root.setMaxHeight(100)
1166
+
1167
+ const root_child0 = Yoga.Node.create(config)
1168
+ root_child0.setFlexShrink(1)
1169
+ root_child0.setFlexBasis(100)
1170
+ root.insertChild(root_child0, 0)
1171
+
1172
+ const root_child1 = Yoga.Node.create(config)
1173
+ root_child1.setHeight(50)
1174
+ root.insertChild(root_child1, 1)
1175
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1176
+
1177
+ expect(root.getComputedLeft()).toBe(0)
1178
+ expect(root.getComputedTop()).toBe(0)
1179
+ expect(root.getComputedWidth()).toBe(100)
1180
+ expect(root.getComputedHeight()).toBe(100)
1181
+
1182
+ expect(root_child0.getComputedLeft()).toBe(0)
1183
+ expect(root_child0.getComputedTop()).toBe(0)
1184
+ expect(root_child0.getComputedWidth()).toBe(100)
1185
+ expect(root_child0.getComputedHeight()).toBe(50)
1186
+
1187
+ expect(root_child1.getComputedLeft()).toBe(0)
1188
+ expect(root_child1.getComputedTop()).toBe(50)
1189
+ expect(root_child1.getComputedWidth()).toBe(100)
1190
+ expect(root_child1.getComputedHeight()).toBe(50)
1191
+
1192
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1193
+
1194
+ expect(root.getComputedLeft()).toBe(0)
1195
+ expect(root.getComputedTop()).toBe(0)
1196
+ expect(root.getComputedWidth()).toBe(100)
1197
+ expect(root.getComputedHeight()).toBe(100)
1198
+
1199
+ expect(root_child0.getComputedLeft()).toBe(0)
1200
+ expect(root_child0.getComputedTop()).toBe(0)
1201
+ expect(root_child0.getComputedWidth()).toBe(100)
1202
+ expect(root_child0.getComputedHeight()).toBe(50)
1203
+
1204
+ expect(root_child1.getComputedLeft()).toBe(0)
1205
+ expect(root_child1.getComputedTop()).toBe(50)
1206
+ expect(root_child1.getComputedWidth()).toBe(100)
1207
+ expect(root_child1.getComputedHeight()).toBe(50)
1208
+ } finally {
1209
+ if (typeof root !== "undefined") {
1210
+ root.freeRecursive()
1211
+ }
1212
+
1213
+ config.free()
1214
+ }
1215
+ })
1216
+ test("child_min_max_width_flexing", () => {
1217
+ const config = Yoga.Config.create()
1218
+ let root
1219
+
1220
+ try {
1221
+ root = Yoga.Node.create(config)
1222
+ root.setFlexDirection(FlexDirection.Row)
1223
+ root.setPositionType(PositionType.Absolute)
1224
+ root.setWidth(120)
1225
+ root.setHeight(50)
1226
+
1227
+ const root_child0 = Yoga.Node.create(config)
1228
+ root_child0.setFlexGrow(1)
1229
+ root_child0.setFlexBasis(0)
1230
+ root_child0.setMinWidth(60)
1231
+ root.insertChild(root_child0, 0)
1232
+
1233
+ const root_child1 = Yoga.Node.create(config)
1234
+ root_child1.setFlexGrow(1)
1235
+ root_child1.setFlexBasis("50%")
1236
+ root_child1.setMaxWidth(20)
1237
+ root.insertChild(root_child1, 1)
1238
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1239
+
1240
+ expect(root.getComputedLeft()).toBe(0)
1241
+ expect(root.getComputedTop()).toBe(0)
1242
+ expect(root.getComputedWidth()).toBe(120)
1243
+ expect(root.getComputedHeight()).toBe(50)
1244
+
1245
+ expect(root_child0.getComputedLeft()).toBe(0)
1246
+ expect(root_child0.getComputedTop()).toBe(0)
1247
+ expect(root_child0.getComputedWidth()).toBe(100)
1248
+ expect(root_child0.getComputedHeight()).toBe(50)
1249
+
1250
+ expect(root_child1.getComputedLeft()).toBe(100)
1251
+ expect(root_child1.getComputedTop()).toBe(0)
1252
+ expect(root_child1.getComputedWidth()).toBe(20)
1253
+ expect(root_child1.getComputedHeight()).toBe(50)
1254
+
1255
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1256
+
1257
+ expect(root.getComputedLeft()).toBe(0)
1258
+ expect(root.getComputedTop()).toBe(0)
1259
+ expect(root.getComputedWidth()).toBe(120)
1260
+ expect(root.getComputedHeight()).toBe(50)
1261
+
1262
+ expect(root_child0.getComputedLeft()).toBe(20)
1263
+ expect(root_child0.getComputedTop()).toBe(0)
1264
+ expect(root_child0.getComputedWidth()).toBe(100)
1265
+ expect(root_child0.getComputedHeight()).toBe(50)
1266
+
1267
+ expect(root_child1.getComputedLeft()).toBe(0)
1268
+ expect(root_child1.getComputedTop()).toBe(0)
1269
+ expect(root_child1.getComputedWidth()).toBe(20)
1270
+ expect(root_child1.getComputedHeight()).toBe(50)
1271
+ } finally {
1272
+ if (typeof root !== "undefined") {
1273
+ root.freeRecursive()
1274
+ }
1275
+
1276
+ config.free()
1277
+ }
1278
+ })
1279
+ test("min_width_overrides_width", () => {
1280
+ const config = Yoga.Config.create()
1281
+ let root
1282
+
1283
+ try {
1284
+ root = Yoga.Node.create(config)
1285
+ root.setPositionType(PositionType.Absolute)
1286
+ root.setWidth(50)
1287
+ root.setMinWidth(100)
1288
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1289
+
1290
+ expect(root.getComputedLeft()).toBe(0)
1291
+ expect(root.getComputedTop()).toBe(0)
1292
+ expect(root.getComputedWidth()).toBe(100)
1293
+ expect(root.getComputedHeight()).toBe(0)
1294
+
1295
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1296
+
1297
+ expect(root.getComputedLeft()).toBe(0)
1298
+ expect(root.getComputedTop()).toBe(0)
1299
+ expect(root.getComputedWidth()).toBe(100)
1300
+ expect(root.getComputedHeight()).toBe(0)
1301
+ } finally {
1302
+ if (typeof root !== "undefined") {
1303
+ root.freeRecursive()
1304
+ }
1305
+
1306
+ config.free()
1307
+ }
1308
+ })
1309
+ test("max_width_overrides_width", () => {
1310
+ const config = Yoga.Config.create()
1311
+ let root
1312
+
1313
+ try {
1314
+ root = Yoga.Node.create(config)
1315
+ root.setPositionType(PositionType.Absolute)
1316
+ root.setWidth(200)
1317
+ root.setMaxWidth(100)
1318
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1319
+
1320
+ expect(root.getComputedLeft()).toBe(0)
1321
+ expect(root.getComputedTop()).toBe(0)
1322
+ expect(root.getComputedWidth()).toBe(100)
1323
+ expect(root.getComputedHeight()).toBe(0)
1324
+
1325
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1326
+
1327
+ expect(root.getComputedLeft()).toBe(0)
1328
+ expect(root.getComputedTop()).toBe(0)
1329
+ expect(root.getComputedWidth()).toBe(100)
1330
+ expect(root.getComputedHeight()).toBe(0)
1331
+ } finally {
1332
+ if (typeof root !== "undefined") {
1333
+ root.freeRecursive()
1334
+ }
1335
+
1336
+ config.free()
1337
+ }
1338
+ })
1339
+ test("min_height_overrides_height", () => {
1340
+ const config = Yoga.Config.create()
1341
+ let root
1342
+
1343
+ try {
1344
+ root = Yoga.Node.create(config)
1345
+ root.setPositionType(PositionType.Absolute)
1346
+ root.setHeight(50)
1347
+ root.setMinHeight(100)
1348
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1349
+
1350
+ expect(root.getComputedLeft()).toBe(0)
1351
+ expect(root.getComputedTop()).toBe(0)
1352
+ expect(root.getComputedWidth()).toBe(0)
1353
+ expect(root.getComputedHeight()).toBe(100)
1354
+
1355
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1356
+
1357
+ expect(root.getComputedLeft()).toBe(0)
1358
+ expect(root.getComputedTop()).toBe(0)
1359
+ expect(root.getComputedWidth()).toBe(0)
1360
+ expect(root.getComputedHeight()).toBe(100)
1361
+ } finally {
1362
+ if (typeof root !== "undefined") {
1363
+ root.freeRecursive()
1364
+ }
1365
+
1366
+ config.free()
1367
+ }
1368
+ })
1369
+ test("max_height_overrides_height", () => {
1370
+ const config = Yoga.Config.create()
1371
+ let root
1372
+
1373
+ try {
1374
+ root = Yoga.Node.create(config)
1375
+ root.setPositionType(PositionType.Absolute)
1376
+ root.setHeight(200)
1377
+ root.setMaxHeight(100)
1378
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1379
+
1380
+ expect(root.getComputedLeft()).toBe(0)
1381
+ expect(root.getComputedTop()).toBe(0)
1382
+ expect(root.getComputedWidth()).toBe(0)
1383
+ expect(root.getComputedHeight()).toBe(100)
1384
+
1385
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1386
+
1387
+ expect(root.getComputedLeft()).toBe(0)
1388
+ expect(root.getComputedTop()).toBe(0)
1389
+ expect(root.getComputedWidth()).toBe(0)
1390
+ expect(root.getComputedHeight()).toBe(100)
1391
+ } finally {
1392
+ if (typeof root !== "undefined") {
1393
+ root.freeRecursive()
1394
+ }
1395
+
1396
+ config.free()
1397
+ }
1398
+ })
1399
+ test("min_max_percent_no_width_height", () => {
1400
+ const config = Yoga.Config.create()
1401
+ let root
1402
+
1403
+ try {
1404
+ root = Yoga.Node.create(config)
1405
+ root.setAlignItems(Align.FlexStart)
1406
+ root.setPositionType(PositionType.Absolute)
1407
+ root.setWidth(100)
1408
+ root.setHeight(100)
1409
+
1410
+ const root_child0 = Yoga.Node.create(config)
1411
+ root_child0.setMinWidth("10%")
1412
+ root_child0.setMaxWidth("10%")
1413
+ root_child0.setMinHeight("10%")
1414
+ root_child0.setMaxHeight("10%")
1415
+ root.insertChild(root_child0, 0)
1416
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1417
+
1418
+ expect(root.getComputedLeft()).toBe(0)
1419
+ expect(root.getComputedTop()).toBe(0)
1420
+ expect(root.getComputedWidth()).toBe(100)
1421
+ expect(root.getComputedHeight()).toBe(100)
1422
+
1423
+ expect(root_child0.getComputedLeft()).toBe(0)
1424
+ expect(root_child0.getComputedTop()).toBe(0)
1425
+ expect(root_child0.getComputedWidth()).toBe(10)
1426
+ expect(root_child0.getComputedHeight()).toBe(10)
1427
+
1428
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1429
+
1430
+ expect(root.getComputedLeft()).toBe(0)
1431
+ expect(root.getComputedTop()).toBe(0)
1432
+ expect(root.getComputedWidth()).toBe(100)
1433
+ expect(root.getComputedHeight()).toBe(100)
1434
+
1435
+ expect(root_child0.getComputedLeft()).toBe(90)
1436
+ expect(root_child0.getComputedTop()).toBe(0)
1437
+ expect(root_child0.getComputedWidth()).toBe(10)
1438
+ expect(root_child0.getComputedHeight()).toBe(10)
1439
+ } finally {
1440
+ if (typeof root !== "undefined") {
1441
+ root.freeRecursive()
1442
+ }
1443
+
1444
+ config.free()
1445
+ }
1446
+ })