react-native-gtkx 0.2.0-alpha.2 → 0.3.0-alpha.1
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.
- package/README.md +5 -2
- package/dist/aliases/index.d.ts +84 -0
- package/dist/aliases/index.js +208 -0
- package/dist/aliases/index.js.map +1 -0
- package/dist/animated/index.d.ts +2 -0
- package/dist/animated/index.js +5 -0
- package/dist/animated/index.js.map +1 -1
- package/dist/animated/types.d.ts +1 -0
- package/dist/animated/types.js.map +1 -1
- package/dist/animated/value-animation.js +17 -4
- package/dist/animated/value-animation.js.map +1 -1
- package/dist/apis/host.gtkx.js +9 -12
- package/dist/apis/host.gtkx.js.map +1 -1
- package/dist/apis/index.d.ts +4 -2
- package/dist/apis/index.js +2 -0
- package/dist/apis/index.js.map +1 -1
- package/dist/apis/keyboard.d.ts +60 -0
- package/dist/apis/keyboard.js +63 -0
- package/dist/apis/keyboard.js.map +1 -0
- package/dist/apis/log-box.d.ts +15 -0
- package/dist/apis/log-box.js +46 -0
- package/dist/apis/log-box.js.map +1 -0
- package/dist/apis/platform.d.ts +18 -1
- package/dist/apis/platform.js.map +1 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +24 -1
- package/dist/common/index.js.map +1 -1
- package/dist/components/animated.d.ts +70 -6
- package/dist/components/animated.js +559 -46
- package/dist/components/animated.js.map +1 -1
- package/dist/components/driven-size.d.ts +27 -0
- package/dist/components/driven-size.js +85 -0
- package/dist/components/driven-size.js.map +1 -0
- package/dist/components/find-node-handle.d.ts +11 -0
- package/dist/components/find-node-handle.js +53 -0
- package/dist/components/find-node-handle.js.map +1 -0
- package/dist/components/flat-list.d.ts +3 -2
- package/dist/components/flat-list.js.map +1 -1
- package/dist/components/frame-scheduler.d.ts +16 -0
- package/dist/components/frame-scheduler.js +37 -0
- package/dist/components/frame-scheduler.js.map +1 -0
- package/dist/components/image.d.ts +6 -1
- package/dist/components/image.js +15 -4
- package/dist/components/image.js.map +1 -1
- package/dist/components/index.d.ts +7 -5
- package/dist/components/index.js +5 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/measure.d.ts +51 -1
- package/dist/components/measure.js +101 -2
- package/dist/components/measure.js.map +1 -1
- package/dist/components/pressable.d.ts +61 -1
- package/dist/components/pressable.js +151 -4
- package/dist/components/pressable.js.map +1 -1
- package/dist/components/rect-store.d.ts +58 -0
- package/dist/components/rect-store.js +124 -3
- package/dist/components/rect-store.js.map +1 -1
- package/dist/components/root.js +6 -1
- package/dist/components/root.js.map +1 -1
- package/dist/components/scroll-phase.d.ts +35 -0
- package/dist/components/scroll-phase.js +26 -0
- package/dist/components/scroll-phase.js.map +1 -0
- package/dist/components/scroll-view.d.ts +39 -3
- package/dist/components/scroll-view.js +378 -43
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/text-input.js +9 -25
- package/dist/components/text-input.js.map +1 -1
- package/dist/components/text.d.ts +6 -2
- package/dist/components/text.js +43 -8
- package/dist/components/text.js.map +1 -1
- package/dist/components/use-focus.d.ts +27 -0
- package/dist/components/use-focus.js +116 -0
- package/dist/components/use-focus.js.map +1 -0
- package/dist/components/use-layout-child.d.ts +13 -1
- package/dist/components/use-layout-child.js +188 -5
- package/dist/components/use-layout-child.js.map +1 -1
- package/dist/components/view.d.ts +5 -2
- package/dist/components/view.js +18 -13
- package/dist/components/view.js.map +1 -1
- package/dist/components/virtualized-list.d.ts +45 -5
- package/dist/components/virtualized-list.js +90 -24
- package/dist/components/virtualized-list.js.map +1 -1
- package/dist/components/wheel-scroll-session.d.ts +7 -0
- package/dist/components/wheel-scroll-session.js +53 -0
- package/dist/components/wheel-scroll-session.js.map +1 -0
- package/dist/components/widget-retention.d.ts +35 -0
- package/dist/components/widget-retention.js +169 -0
- package/dist/components/widget-retention.js.map +1 -0
- package/dist/contracts.d.ts +4 -0
- package/dist/contracts.js.map +1 -1
- package/dist/dnd/context.d.ts +69 -0
- package/dist/dnd/context.js +149 -0
- package/dist/dnd/context.js.map +1 -0
- package/dist/dnd/draggable.d.ts +59 -0
- package/dist/dnd/draggable.js +149 -0
- package/dist/dnd/draggable.js.map +1 -0
- package/dist/dnd/droppable.d.ts +24 -0
- package/dist/dnd/droppable.js +74 -0
- package/dist/dnd/droppable.js.map +1 -0
- package/dist/dnd/gtk-controllers.d.ts +39 -0
- package/dist/dnd/gtk-controllers.js +110 -0
- package/dist/dnd/gtk-controllers.js.map +1 -0
- package/dist/dnd/index.d.ts +6 -0
- package/dist/dnd/index.js +31 -0
- package/dist/dnd/index.js.map +1 -0
- package/dist/dnd/order.d.ts +7 -0
- package/dist/dnd/order.js +20 -0
- package/dist/dnd/order.js.map +1 -0
- package/dist/dnd/payload.d.ts +14 -0
- package/dist/dnd/payload.js +41 -0
- package/dist/dnd/payload.js.map +1 -0
- package/dist/dnd/sortable.d.ts +49 -0
- package/dist/dnd/sortable.js +307 -0
- package/dist/dnd/sortable.js.map +1 -0
- package/dist/dnd/types.d.ts +290 -0
- package/dist/dnd/types.js +25 -0
- package/dist/dnd/types.js.map +1 -0
- package/dist/gesture-handler-compat/builder.d.ts +251 -0
- package/dist/gesture-handler-compat/builder.js +513 -0
- package/dist/gesture-handler-compat/builder.js.map +1 -0
- package/dist/gesture-handler-compat/composition.d.ts +23 -0
- package/dist/gesture-handler-compat/composition.js +111 -0
- package/dist/gesture-handler-compat/composition.js.map +1 -0
- package/dist/gesture-handler-compat/deciders.d.ts +3 -0
- package/dist/gesture-handler-compat/deciders.js +47 -0
- package/dist/gesture-handler-compat/deciders.js.map +1 -0
- package/dist/gesture-handler-compat/detector-runtime.d.ts +44 -0
- package/dist/gesture-handler-compat/detector-runtime.js +374 -0
- package/dist/gesture-handler-compat/detector-runtime.js.map +1 -0
- package/dist/gesture-handler-compat/detector.d.ts +22 -0
- package/dist/gesture-handler-compat/detector.js +104 -0
- package/dist/gesture-handler-compat/detector.js.map +1 -0
- package/dist/gesture-handler-compat/fling.d.ts +24 -0
- package/dist/gesture-handler-compat/fling.js +123 -0
- package/dist/gesture-handler-compat/fling.js.map +1 -0
- package/dist/gesture-handler-compat/force-touch.d.ts +13 -0
- package/dist/gesture-handler-compat/force-touch.js +40 -0
- package/dist/gesture-handler-compat/force-touch.js.map +1 -0
- package/dist/gesture-handler-compat/hooks.d.ts +157 -0
- package/dist/gesture-handler-compat/hooks.js +268 -0
- package/dist/gesture-handler-compat/hooks.js.map +1 -0
- package/dist/gesture-handler-compat/hover.d.ts +2 -0
- package/dist/gesture-handler-compat/hover.js +22 -0
- package/dist/gesture-handler-compat/hover.js.map +1 -0
- package/dist/gesture-handler-compat/index.d.ts +98 -0
- package/dist/gesture-handler-compat/index.js +255 -0
- package/dist/gesture-handler-compat/index.js.map +1 -0
- package/dist/gesture-handler-compat/long-press.d.ts +6 -0
- package/dist/gesture-handler-compat/long-press.js +21 -0
- package/dist/gesture-handler-compat/long-press.js.map +1 -0
- package/dist/gesture-handler-compat/manual.d.ts +2 -0
- package/dist/gesture-handler-compat/manual.js +18 -0
- package/dist/gesture-handler-compat/manual.js.map +1 -0
- package/dist/gesture-handler-compat/native.d.ts +7 -0
- package/dist/gesture-handler-compat/native.js +34 -0
- package/dist/gesture-handler-compat/native.js.map +1 -0
- package/dist/gesture-handler-compat/orchestrator.d.ts +77 -0
- package/dist/gesture-handler-compat/orchestrator.js +284 -0
- package/dist/gesture-handler-compat/orchestrator.js.map +1 -0
- package/dist/gesture-handler-compat/pan.d.ts +23 -0
- package/dist/gesture-handler-compat/pan.js +116 -0
- package/dist/gesture-handler-compat/pan.js.map +1 -0
- package/dist/gesture-handler-compat/recognizer.d.ts +268 -0
- package/dist/gesture-handler-compat/recognizer.js +1056 -0
- package/dist/gesture-handler-compat/recognizer.js.map +1 -0
- package/dist/gesture-handler-compat/relations.d.ts +43 -0
- package/dist/gesture-handler-compat/relations.js +128 -0
- package/dist/gesture-handler-compat/relations.js.map +1 -0
- package/dist/gesture-handler-compat/tap.d.ts +6 -0
- package/dist/gesture-handler-compat/tap.js +29 -0
- package/dist/gesture-handler-compat/tap.js.map +1 -0
- package/dist/gesture-handler-compat/touchpad.d.ts +41 -0
- package/dist/gesture-handler-compat/touchpad.js +64 -0
- package/dist/gesture-handler-compat/touchpad.js.map +1 -0
- package/dist/gesture-handler-compat/types.d.ts +441 -0
- package/dist/gesture-handler-compat/types.js +167 -0
- package/dist/gesture-handler-compat/types.js.map +1 -0
- package/dist/gtk/controllers.d.ts +39 -0
- package/dist/gtk/controllers.js +92 -0
- package/dist/gtk/controllers.js.map +1 -0
- package/dist/gtk/index.d.ts +2 -1
- package/dist/gtk/index.js +7 -1
- package/dist/gtk/index.js.map +1 -1
- package/dist/gtkx/bridge/geometry.js +6 -4
- package/dist/gtkx/bridge/geometry.js.map +1 -1
- package/dist/gtkx/bridge/index.d.ts +5 -3
- package/dist/gtkx/bridge/index.js +6 -3
- package/dist/gtkx/bridge/index.js.map +1 -1
- package/dist/gtkx/bridge/slot-portal.js.map +1 -1
- package/dist/gtkx/bridge/use-signal.js +1 -1
- package/dist/gtkx/bridge/use-signal.js.map +1 -1
- package/dist/gtkx/bridge/view-box.d.ts +56 -0
- package/dist/gtkx/bridge/view-box.js +394 -9
- package/dist/gtkx/bridge/view-box.js.map +1 -1
- package/dist/gtkx/bridge/widget-css.d.ts +17 -0
- package/dist/gtkx/bridge/widget-css.js +72 -0
- package/dist/gtkx/bridge/widget-css.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/driven-size.d.ts +12 -0
- package/dist/layout/driven-size.js +70 -0
- package/dist/layout/driven-size.js.map +1 -0
- package/dist/layout/engine.d.ts +17 -1
- package/dist/layout/engine.js +3 -20
- package/dist/layout/engine.js.map +1 -1
- package/dist/layout/node.d.ts +13 -0
- package/dist/layout/node.js +14 -0
- package/dist/layout/node.js.map +1 -1
- package/dist/layout/yoga.d.ts +3 -2
- package/dist/layout/yoga.js +5 -2
- package/dist/layout/yoga.js.map +1 -1
- package/dist/mcp/data/generated.d.ts +257 -60
- package/dist/mcp/data/generated.js +306 -62
- package/dist/mcp/data/generated.js.map +1 -1
- package/dist/metro/index.d.ts +10 -0
- package/dist/metro/index.js +21 -12
- package/dist/metro/index.js.map +1 -1
- package/dist/navigation/sidebar.d.ts +16 -0
- package/dist/navigation/sidebar.js +65 -1
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/reanimated-compat/animated-ref.d.ts +32 -0
- package/dist/reanimated-compat/animated-ref.js +57 -0
- package/dist/reanimated-compat/animated-ref.js.map +1 -0
- package/dist/reanimated-compat/animation.d.ts +177 -0
- package/dist/reanimated-compat/animation.js +540 -0
- package/dist/reanimated-compat/animation.js.map +1 -0
- package/dist/reanimated-compat/color.d.ts +28 -0
- package/dist/reanimated-compat/color.js +249 -0
- package/dist/reanimated-compat/color.js.map +1 -0
- package/dist/reanimated-compat/decay.d.ts +39 -0
- package/dist/reanimated-compat/decay.js +96 -0
- package/dist/reanimated-compat/decay.js.map +1 -0
- package/dist/reanimated-compat/easing.d.ts +30 -0
- package/dist/reanimated-compat/easing.js +76 -0
- package/dist/reanimated-compat/easing.js.map +1 -0
- package/dist/reanimated-compat/hooks.d.ts +14 -0
- package/dist/reanimated-compat/hooks.js +217 -0
- package/dist/reanimated-compat/hooks.js.map +1 -0
- package/dist/reanimated-compat/index.d.ts +258 -0
- package/dist/reanimated-compat/index.js +464 -0
- package/dist/reanimated-compat/index.js.map +1 -0
- package/dist/reanimated-compat/interpolation.d.ts +18 -0
- package/dist/reanimated-compat/interpolation.js +122 -0
- package/dist/reanimated-compat/interpolation.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-config.d.ts +43 -0
- package/dist/reanimated-compat/layout-animation-config.js +78 -0
- package/dist/reanimated-compat/layout-animation-config.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-presets.d.ts +117 -0
- package/dist/reanimated-compat/layout-animation-presets.js +498 -0
- package/dist/reanimated-compat/layout-animation-presets.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-runtime.d.ts +21 -0
- package/dist/reanimated-compat/layout-animation-runtime.js +311 -0
- package/dist/reanimated-compat/layout-animation-runtime.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-view.d.ts +27 -0
- package/dist/reanimated-compat/layout-animation-view.js +266 -0
- package/dist/reanimated-compat/layout-animation-view.js.map +1 -0
- package/dist/reanimated-compat/layout-animation.d.ts +171 -0
- package/dist/reanimated-compat/layout-animation.js +469 -0
- package/dist/reanimated-compat/layout-animation.js.map +1 -0
- package/dist/reanimated-compat/layout-transitions.d.ts +83 -0
- package/dist/reanimated-compat/layout-transitions.js +350 -0
- package/dist/reanimated-compat/layout-transitions.js.map +1 -0
- package/dist/reanimated-compat/mutable.d.ts +29 -0
- package/dist/reanimated-compat/mutable.js +139 -0
- package/dist/reanimated-compat/mutable.js.map +1 -0
- package/dist/reanimated-compat/props.d.ts +18 -0
- package/dist/reanimated-compat/props.js +111 -0
- package/dist/reanimated-compat/props.js.map +1 -0
- package/dist/reanimated-compat/scroll-handler.d.ts +119 -0
- package/dist/reanimated-compat/scroll-handler.js +274 -0
- package/dist/reanimated-compat/scroll-handler.js.map +1 -0
- package/dist/reanimated-compat/scroll-offset.d.ts +12 -0
- package/dist/reanimated-compat/scroll-offset.js +104 -0
- package/dist/reanimated-compat/scroll-offset.js.map +1 -0
- package/dist/reanimated-compat/style.d.ts +90 -0
- package/dist/reanimated-compat/style.js +452 -0
- package/dist/reanimated-compat/style.js.map +1 -0
- package/dist/reanimated-compat/test-timers.d.ts +28 -0
- package/dist/reanimated-compat/test-timers.js +136 -0
- package/dist/reanimated-compat/test-timers.js.map +1 -0
- package/dist/reanimated-compat/threads.d.ts +13 -0
- package/dist/reanimated-compat/threads.js +41 -0
- package/dist/reanimated-compat/threads.js.map +1 -0
- package/dist/reanimated-compat/tracking.d.ts +41 -0
- package/dist/reanimated-compat/tracking.js +106 -0
- package/dist/reanimated-compat/tracking.js.map +1 -0
- package/dist/reanimated-compat/updater-animations.d.ts +36 -0
- package/dist/reanimated-compat/updater-animations.js +273 -0
- package/dist/reanimated-compat/updater-animations.js.map +1 -0
- package/dist/responder/system.d.ts +80 -7
- package/dist/responder/system.js +143 -23
- package/dist/responder/system.js.map +1 -1
- package/dist/responder/use-responder.d.ts +11 -0
- package/dist/responder/use-responder.js +225 -6
- package/dist/responder/use-responder.js.map +1 -1
- package/dist/runner/host-dev.js +1 -1
- package/dist/runner/host-dev.js.map +1 -1
- package/dist/runner/host.js +1 -1
- package/dist/runner/host.js.map +1 -1
- package/dist/runner/index.js +3 -3
- package/dist/runner/index.js.map +1 -1
- package/dist/sea/gtkx-config-module.js +1 -1
- package/dist/sea/gtkx-config-module.js.map +1 -1
- package/dist/style/absolute-insets.d.ts +26 -0
- package/dist/style/absolute-insets.js +113 -0
- package/dist/style/absolute-insets.js.map +1 -0
- package/dist/style/animated-size.d.ts +25 -0
- package/dist/style/animated-size.js +225 -0
- package/dist/style/animated-size.js.map +1 -0
- package/dist/style/colors.d.ts +17 -0
- package/dist/style/colors.js +25 -6
- package/dist/style/colors.js.map +1 -1
- package/dist/style/imperative-css.d.ts +21 -0
- package/dist/style/imperative-css.js +63 -0
- package/dist/style/imperative-css.js.map +1 -0
- package/dist/style/index.d.ts +2 -1
- package/dist/style/index.js +2 -1
- package/dist/style/index.js.map +1 -1
- package/dist/style/split-style.js +5 -0
- package/dist/style/split-style.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unsupported-export.d.ts +8 -0
- package/dist/unsupported-export.js +66 -0
- package/dist/unsupported-export.js.map +1 -0
- package/dist/vite/index.d.ts +21 -8
- package/dist/vite/index.js +127 -82
- package/dist/vite/index.js.map +1 -1
- package/dist/vitest/index.d.ts +2 -2
- package/dist/vitest/index.js.map +1 -1
- package/dist/worklets-compat/index.d.ts +4 -0
- package/dist/worklets-compat/index.js +28 -0
- package/dist/worklets-compat/index.js.map +1 -0
- package/dist/worklets-compat/surface.d.ts +110 -0
- package/dist/worklets-compat/surface.js +153 -0
- package/dist/worklets-compat/surface.js.map +1 -0
- package/package.json +25 -9
- package/types.d.ts +9 -0
- package/dist/common/list.d.ts +0 -82
- package/dist/common/list.js +0 -166
- package/dist/common/list.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAE1E,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,MAAM,EACN,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAE1E,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,MAAM,EACN,cAAc,EACd,QAAQ,EACR,KAAK,EACL,KAAK,EACL,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,MAAM,EACN,IAAI,EACJ,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,IAAI,EACJ,eAAe,GA6ChB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,mBAAmB,GAiBpB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAiBzD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Public surface of react-native-gtkx, mirroring the `react-native` module.\n// Components · APIs · StyleSheet, with the Yoga layout engine underneath.\n\nexport {\n ActivityIndicator,\n Animated,\n AppRegistry,\n Easing,\n findNodeHandle,\n FlatList,\n Image,\n Modal,\n IntrinsicRoot,\n PanResponder,\n NestedRoot,\n Pressable,\n Root,\n SafeAreaView,\n ScrollView,\n SectionList,\n StatusBar,\n Switch,\n Text,\n TextInput,\n TouchableHighlight,\n TouchableOpacity,\n TouchableWithoutFeedback,\n View,\n VirtualizedList,\n type ActivityIndicatorProps,\n type FlatListProps,\n type GestureResponderEvent,\n type ImageHandle,\n type ImageProps,\n type ImageSource,\n type LayoutEvent,\n type ListRenderItemInfo,\n type MeasureHandle,\n type MeasureInWindowOnSuccessCallback,\n type MeasureLayoutOnSuccessCallback,\n type MeasureOnSuccessCallback,\n type ItemLayout,\n type ModalProps,\n type NativeTouch,\n type NodeHandle,\n type PanResponderCallbacks,\n type PanResponderGestureState,\n type PanResponderInstance,\n type PressableProps,\n type PressableStateCallbackType,\n type IntrinsicRootProps,\n type NestedRootProps,\n type PressEvent,\n type ResponderProps,\n type RootProps,\n type RunApplicationParams,\n type ScrollEvent,\n type ScrollViewHandle,\n type ScrollViewProps,\n type SectionListProps,\n type SwitchProps,\n type TextHandle,\n type TextInputProps,\n type TextProps,\n type TouchHistory,\n type TouchRecord,\n type TouchableHighlightProps,\n type TouchableOpacityProps,\n type TouchableWithoutFeedbackProps,\n type ViewabilityConfig,\n type ViewHandle,\n type ViewProps,\n type ViewToken,\n} from \"./components/index\"\n\n// List scroll handle (scrollTo/scrollToEnd/scrollToIndex/scrollToItem/\n// scrollToOffset) — exported straight from the component module.\nexport type { FlatListHandle } from \"./components/flat-list\"\n\nexport {\n Alert,\n Appearance,\n AppState,\n BackHandler,\n DevSettings,\n Dimensions,\n I18nManager,\n InteractionManager,\n Keyboard,\n Linking,\n LogBox,\n Platform,\n useColorScheme,\n useWindowDimensions,\n type AlertButton,\n type AlertButtonStyle,\n type AlertOptions,\n type AppearancePreferences,\n type AppStateEvent,\n type AppStateStatus,\n type ColorSchemeName,\n type DimensionKey,\n type DimensionsPayload,\n type InteractionPromise,\n type KeyboardEvent,\n type KeyboardEventName,\n type LogBoxIgnorePattern,\n type PlatformOSType,\n type PlatformSelectSpec,\n type ScaledSize,\n} from \"./apis/index\"\n\nexport { PlatformColor, StyleSheet } from \"./style/index\"\n\nexport type {\n BoxShadowValue,\n DimensionValue,\n FlatStyle,\n ImageStyle,\n LayoutStyle,\n PointerEventsValue,\n StyleProp,\n TextDecorationLine,\n TextStyle,\n TransformPart,\n ViewStyle,\n VisualStyle,\n} from \"./contracts\"\n\nexport const version = \"0.1.0\"\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LayoutNode } from "./node";
|
|
2
|
+
export type DrivenSize = {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Lays `node`'s own subtree out at `size`, leaving the computed values on the
|
|
8
|
+
* Yoga nodes for a caller to read. The node's STYLE is restored before this
|
|
9
|
+
* returns — computed values survive it, so the driven layout is readable while
|
|
10
|
+
* the shadow tree is untouched.
|
|
11
|
+
*/
|
|
12
|
+
export declare const layoutSubtreeAtSize: (node: LayoutNode, size: DrivenSize) => void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Direction, Edge, Unit } from "./yoga";
|
|
2
|
+
/** The content box of the node's owner: what percentages inside it resolve against. */
|
|
3
|
+
const ownerContentBox = (node) => {
|
|
4
|
+
const parent = node.parent;
|
|
5
|
+
if (!parent) {
|
|
6
|
+
return {
|
|
7
|
+
width: node.yoga.getComputedWidth(),
|
|
8
|
+
height: node.yoga.getComputedHeight(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const owner = parent.yoga;
|
|
12
|
+
return {
|
|
13
|
+
width: owner.getComputedWidth() -
|
|
14
|
+
owner.getComputedPadding(Edge.Left) -
|
|
15
|
+
owner.getComputedPadding(Edge.Right),
|
|
16
|
+
height: owner.getComputedHeight() -
|
|
17
|
+
owner.getComputedPadding(Edge.Top) -
|
|
18
|
+
owner.getComputedPadding(Edge.Bottom),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const restore = (saved, set) => {
|
|
22
|
+
if (saved.unit === Unit.Point) {
|
|
23
|
+
set.point(saved.value);
|
|
24
|
+
}
|
|
25
|
+
else if (saved.unit === Unit.Percent) {
|
|
26
|
+
set.percent(saved.value);
|
|
27
|
+
}
|
|
28
|
+
else if (saved.unit === Unit.Auto) {
|
|
29
|
+
set.auto();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
set.reset();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Lays `node`'s own subtree out at `size`, leaving the computed values on the
|
|
37
|
+
* Yoga nodes for a caller to read. The node's STYLE is restored before this
|
|
38
|
+
* returns — computed values survive it, so the driven layout is readable while
|
|
39
|
+
* the shadow tree is untouched.
|
|
40
|
+
*/
|
|
41
|
+
export const layoutSubtreeAtSize = (node, size) => {
|
|
42
|
+
const yoga = node.yoga;
|
|
43
|
+
const owner = ownerContentBox(node);
|
|
44
|
+
const savedWidth = yoga.getWidth();
|
|
45
|
+
const savedHeight = yoga.getHeight();
|
|
46
|
+
if (size.width !== undefined) {
|
|
47
|
+
yoga.setWidth(size.width);
|
|
48
|
+
}
|
|
49
|
+
if (size.height !== undefined) {
|
|
50
|
+
yoga.setHeight(size.height);
|
|
51
|
+
}
|
|
52
|
+
yoga.calculateLayout(owner.width, owner.height, Direction.LTR);
|
|
53
|
+
if (size.width !== undefined) {
|
|
54
|
+
restore(savedWidth, {
|
|
55
|
+
point: (value) => yoga.setWidth(value),
|
|
56
|
+
percent: (value) => yoga.setWidthPercent(value),
|
|
57
|
+
auto: () => yoga.setWidthAuto(),
|
|
58
|
+
reset: () => yoga.setWidthAuto(),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (size.height !== undefined) {
|
|
62
|
+
restore(savedHeight, {
|
|
63
|
+
point: (value) => yoga.setHeight(value),
|
|
64
|
+
percent: (value) => yoga.setHeightPercent(value),
|
|
65
|
+
auto: () => yoga.setHeightAuto(),
|
|
66
|
+
reset: () => yoga.setHeightAuto(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=driven-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driven-size.js","sourceRoot":"","sources":["../../src/layout/driven-size.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAiC,MAAM,QAAQ,CAAA;AAO7E,uFAAuF;AACvF,MAAM,eAAe,GAAG,CACtB,IAAgB,EACmB,EAAE;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACnC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;SACtC,CAAA;IACH,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;IACzB,OAAO;QACL,KAAK,EACH,KAAK,CAAC,gBAAgB,EAAE;YACxB,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;YACnC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QACtC,MAAM,EACJ,KAAK,CAAC,iBAAiB,EAAE;YACzB,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;YAClC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;KACxC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CACd,KAAgB,EA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,EAAE;YAClB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;YAC/C,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE;YAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE;SACjC,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,WAAW,EAAE;YACnB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YACvC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAChD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;YAChC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;SAClC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAA","sourcesContent":["// The pinned subtree pass: Yoga rooted at the ANIMATED NODE rather than at the\n// tree's root.\n//\n// A layout write normally costs what the CONTAINER costs, and the shape of\n// that cost is why animated layout is refused here at all: 52 / 133 / 496 µs\n// at 5 / 60 / 300 children, of which the biggest single line is not Yoga\n// (137 µs) but the engine's incremental COMMIT WALK (320 µs), which visits\n// every child the container re-solved even when 299 of 300 rects came back\n// identical (docs/research/animated-size.md §3).\n//\n// This pass pays neither. It pins the node's own size to the driven value,\n// asks Yoga to lay out THAT node — its container, its siblings and its\n// ancestors are never visited — and puts the style back, so the shadow tree is\n// exactly as React left it and no engine flush is dirtied. Measured at 6.6 µs\n// for a leaf and 23 µs for a node with wrapped text, FLAT at 5, 60 and 300\n// siblings.\n//\n// It is only correct where the change is genuinely confined to the node, and\n// that question is answered by ../style/animated-size.ts, not here.\n//\n// Two details had to be got right or the pass silently diverges from a full\n// one, and both were found by measuring rather than by reading:\n//\n// - the available space is the OWNER's content box, not the node's own size.\n// Percentages inside the node — its own padding included — resolve against\n// the owner, so passing the node's size resolves `padding: \"5%\"` against\n// 400 where a real pass resolves it against 800.\n// - pinning is what makes the pass resolve at all for a node whose size is\n// `auto` or a `flex`: without it Yoga re-derives the size from the content\n// and the driven value never lands.\nimport type { LayoutNode } from \"./node\"\nimport { Direction, Edge, Unit, type YogaNode, type YogaValue } from \"./yoga\"\n\nexport type DrivenSize = {\n width?: number\n height?: number\n}\n\n/** The content box of the node's owner: what percentages inside it resolve against. */\nconst ownerContentBox = (\n node: LayoutNode,\n): { width: number; height: number } => {\n const parent = node.parent\n if (!parent) {\n return {\n width: node.yoga.getComputedWidth(),\n height: node.yoga.getComputedHeight(),\n }\n }\n const owner = parent.yoga\n return {\n width:\n owner.getComputedWidth() -\n owner.getComputedPadding(Edge.Left) -\n owner.getComputedPadding(Edge.Right),\n height:\n owner.getComputedHeight() -\n owner.getComputedPadding(Edge.Top) -\n owner.getComputedPadding(Edge.Bottom),\n }\n}\n\nconst restore = (\n saved: YogaValue,\n set: {\n point: (value: number) => void\n percent: (value: number) => void\n auto: () => void\n reset: () => void\n },\n): void => {\n if (saved.unit === Unit.Point) {\n set.point(saved.value)\n } else if (saved.unit === Unit.Percent) {\n set.percent(saved.value)\n } else if (saved.unit === Unit.Auto) {\n set.auto()\n } else {\n set.reset()\n }\n}\n\n/**\n * Lays `node`'s own subtree out at `size`, leaving the computed values on the\n * Yoga nodes for a caller to read. The node's STYLE is restored before this\n * returns — computed values survive it, so the driven layout is readable while\n * the shadow tree is untouched.\n */\nexport const layoutSubtreeAtSize = (\n node: LayoutNode,\n size: DrivenSize,\n): void => {\n const yoga: YogaNode = node.yoga\n const owner = ownerContentBox(node)\n const savedWidth = yoga.getWidth()\n const savedHeight = yoga.getHeight()\n if (size.width !== undefined) {\n yoga.setWidth(size.width)\n }\n if (size.height !== undefined) {\n yoga.setHeight(size.height)\n }\n yoga.calculateLayout(owner.width, owner.height, Direction.LTR)\n if (size.width !== undefined) {\n restore(savedWidth, {\n point: (value) => yoga.setWidth(value),\n percent: (value) => yoga.setWidthPercent(value),\n auto: () => yoga.setWidthAuto(),\n reset: () => yoga.setWidthAuto(),\n })\n }\n if (size.height !== undefined) {\n restore(savedHeight, {\n point: (value) => yoga.setHeight(value),\n percent: (value) => yoga.setHeightPercent(value),\n auto: () => yoga.setHeightAuto(),\n reset: () => yoga.setHeightAuto(),\n })\n }\n}\n"]}
|
package/dist/layout/engine.d.ts
CHANGED
|
@@ -3,15 +3,31 @@ export type ViewportSize = {
|
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
};
|
|
6
|
+
export type LayoutEngineOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Whether this root REPORTS its Yoga content size to GTK rather than
|
|
9
|
+
* adopting a rectangle it is given — `IntrinsicRoot`, i.e. React Native
|
|
10
|
+
* content mounted directly in a GTK chrome slot.
|
|
11
|
+
*
|
|
12
|
+
* The one thing that reads it is the animated-size rule
|
|
13
|
+
* (../style/animated-size.ts): under a content-sized root every ancestor's
|
|
14
|
+
* size is derived from its children all the way up to the toplevel's own
|
|
15
|
+
* size request, which is the single configuration where a size write really
|
|
16
|
+
* does resize the window (docs/research/animated-size.md §4). Under an
|
|
17
|
+
* ordinary `Root` the climb ends at a viewport instead, and it cannot.
|
|
18
|
+
*/
|
|
19
|
+
contentSized?: boolean;
|
|
20
|
+
};
|
|
6
21
|
export declare class LayoutEngine {
|
|
7
22
|
readonly root: LayoutNode;
|
|
23
|
+
readonly contentSized: boolean;
|
|
8
24
|
private viewport;
|
|
9
25
|
private dirty;
|
|
10
26
|
private scheduled;
|
|
11
27
|
private disposed;
|
|
12
28
|
private dirtyNodes;
|
|
13
29
|
private walkAll;
|
|
14
|
-
constructor(viewport: ViewportSize);
|
|
30
|
+
constructor(viewport: ViewportSize, options?: LayoutEngineOptions);
|
|
15
31
|
createNode(): LayoutNode;
|
|
16
32
|
setViewport(viewport: ViewportSize): void;
|
|
17
33
|
getViewport(): ViewportSize;
|
package/dist/layout/engine.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { perfAddTime, perfBurst, perfCount, perfEnabled, perfGauge, perfNow, } from "../perf";
|
|
2
2
|
import { getLiveNodeCount, LayoutNode } from "./node";
|
|
3
3
|
import { Direction } from "./yoga";
|
|
4
|
-
// One engine per window root. Batches every mutation (style, tree, measure
|
|
5
|
-
// invalidation) into a single Yoga pass per microtask, then walks the shadow
|
|
6
|
-
// tree, diffs rects and fires commit (widget move) + onLayout callbacks only
|
|
7
|
-
// for nodes whose rect actually changed.
|
|
8
|
-
//
|
|
9
|
-
// The commit walk is INCREMENTAL: it descends only where this pass can have
|
|
10
|
-
// changed something, so a small mutation inside a large stable shell costs
|
|
11
|
-
// O(changed) instead of O(all nodes). Two signals drive the descent, and both
|
|
12
|
-
// are needed:
|
|
13
|
-
// - Yoga's per-node `hasNewLayout` flag, which Yoga sets on every node it
|
|
14
|
-
// actually laid out. It covers the nodes a dirty set cannot know about:
|
|
15
|
-
// mutating one child re-lays out its FOLLOWING SIBLINGS (they shift) and
|
|
16
|
-
// any ancestor whose size followed, while untouched subtrees keep their
|
|
17
|
-
// cached layout — and their rects are parent-relative, so an unvisited
|
|
18
|
-
// subtree of a moved container is genuinely unchanged.
|
|
19
|
-
// - the engine's own dirty set (which node each mutation came from), which
|
|
20
|
-
// covers commits Yoga's flag does not imply: a re-measured leaf whose rect
|
|
21
|
-
// is identical still has to recommit, because measuring reset its widget
|
|
22
|
-
// size request.
|
|
23
4
|
export class LayoutEngine {
|
|
24
5
|
root;
|
|
6
|
+
contentSized;
|
|
25
7
|
viewport;
|
|
26
8
|
dirty = false;
|
|
27
9
|
scheduled = false;
|
|
@@ -33,8 +15,9 @@ export class LayoutEngine {
|
|
|
33
15
|
// a viewport change or a speculative measureContent pass, both of which can
|
|
34
16
|
// move anything — and for the first flush, where nothing has a rect yet.
|
|
35
17
|
walkAll = true;
|
|
36
|
-
constructor(viewport) {
|
|
18
|
+
constructor(viewport, options) {
|
|
37
19
|
this.viewport = viewport;
|
|
20
|
+
this.contentSized = options?.contentSized ?? false;
|
|
38
21
|
this.root = new LayoutNode(this.requestFlush);
|
|
39
22
|
}
|
|
40
23
|
createNode() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/layout/engine.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,OAAO,GACR,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIlC,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,yCAAyC;AACzC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,8EAA8E;AAC9E,cAAc;AACd,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,2DAA2D;AAC3D,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,oBAAoB;AACpB,MAAM,OAAO,YAAY;IACd,IAAI,CAAY;IAEjB,QAAQ,CAAc;IACtB,KAAK,GAAG,KAAK,CAAA;IACb,SAAS,GAAG,KAAK,CAAA;IACjB,QAAQ,GAAG,KAAK,CAAA;IACxB,wEAAwE;IACxE,mDAAmD;IAC3C,UAAU,GAAG,IAAI,GAAG,EAAc,CAAA;IAC1C,0EAA0E;IAC1E,4EAA4E;IAC5E,yEAAyE;IACjE,OAAO,GAAG,IAAI,CAAA;IAEtB,YAAY,QAAsB;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACx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I,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAClC,CAAC;gBACD,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;YAC3D,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAEO,QAAQ,CAAC,IAAgB;QAC/B,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;CACF","sourcesContent":["import type { Rect } from \"../contracts\"\nimport {\n perfAddTime,\n perfBurst,\n perfCount,\n perfEnabled,\n perfGauge,\n perfNow,\n} from \"../perf\"\nimport { getLiveNodeCount, LayoutNode } from \"./node\"\nimport { Direction } from \"./yoga\"\n\nexport type ViewportSize = { width: number; height: number }\n\n// One engine per window root. Batches every mutation (style, tree, measure\n// invalidation) into a single Yoga pass per microtask, then walks the shadow\n// tree, diffs rects and fires commit (widget move) + onLayout callbacks only\n// for nodes whose rect actually changed.\n//\n// The commit walk is INCREMENTAL: it descends only where this pass can have\n// changed something, so a small mutation inside a large stable shell costs\n// O(changed) instead of O(all nodes). Two signals drive the descent, and both\n// are needed:\n// - Yoga's per-node `hasNewLayout` flag, which Yoga sets on every node it\n// actually laid out. It covers the nodes a dirty set cannot know about:\n// mutating one child re-lays out its FOLLOWING SIBLINGS (they shift) and\n// any ancestor whose size followed, while untouched subtrees keep their\n// cached layout — and their rects are parent-relative, so an unvisited\n// subtree of a moved container is genuinely unchanged.\n// - the engine's own dirty set (which node each mutation came from), which\n// covers commits Yoga's flag does not imply: a re-measured leaf whose rect\n// is identical still has to recommit, because measuring reset its widget\n// size request.\nexport class LayoutEngine {\n readonly root: LayoutNode\n\n private viewport: ViewportSize\n private dirty = false\n private scheduled = false\n private disposed = false\n // Nodes mutated since the last flush (setStyle/insertChild/removeChild/\n // markDirty/setMeasureFn). Cleared by every flush.\n private dirtyNodes = new Set<LayoutNode>()\n // Set when the engine is dirtied by something that is not a single node —\n // a viewport change or a speculative measureContent pass, both of which can\n // move anything — and for the first flush, where nothing has a rect yet.\n private walkAll = true\n\n constructor(viewport: ViewportSize) {\n this.viewport = viewport\n this.root = new LayoutNode(this.requestFlush)\n }\n\n createNode(): LayoutNode {\n return new LayoutNode(this.requestFlush)\n }\n\n setViewport(viewport: ViewportSize): void {\n if (\n viewport.width === this.viewport.width &&\n viewport.height === this.viewport.height\n ) {\n return\n }\n this.viewport = viewport\n this.walkAll = true\n this.requestFlush()\n }\n\n getViewport(): ViewportSize {\n return this.viewport\n }\n\n // Synchronous pass — used by tests and by resize handling when the caller\n // needs rects immediately after a mutation.\n flushSync(): void {\n if (!this.dirty || this.disposed) {\n return\n }\n this.dirty = false\n const start = perfEnabled ? perfNow() : 0\n this.root.yoga.calculateLayout(\n this.viewport.width,\n this.viewport.height,\n Direction.LTR,\n )\n if (perfEnabled) {\n perfAddTime(\"engine.yoga\", perfNow() - start)\n }\n this.commitTree(this.root)\n if (perfEnabled) {\n const elapsed = perfNow() - start\n perfAddTime(\"engine.flush\", elapsed)\n perfBurst(\"engine.flushMsPerFrame\", elapsed)\n }\n }\n\n // Intrinsic content size for measure vfuncs: lays the tree out WITHOUT\n // committing widget rects (GTK forbids allocation during measure) and\n // leaves the engine dirty so the next allocate-time flush recomputes\n // against the real viewport instead of these speculative constraints.\n measureContent(\n orientation: \"horizontal\" | \"vertical\",\n forSize: number,\n ): number {\n if (this.disposed) {\n return 0\n }\n const width =\n orientation === \"vertical\" && forSize > 0 ? forSize : undefined\n this.root.yoga.calculateLayout(width, undefined, Direction.LTR)\n const size =\n orientation === \"horizontal\"\n ? this.root.yoga.getComputedWidth()\n : this.root.yoga.getComputedHeight()\n this.dirty = true\n // Speculative constraints may have re-measured leaves anywhere in the\n // tree; the next real flush has to re-commit all of them.\n this.walkAll = true\n return Math.ceil(size)\n }\n\n dispose(): void {\n if (this.disposed) {\n return\n }\n this.disposed = true\n this.freeTree(this.root)\n this.dirtyNodes.clear()\n }\n\n private requestFlush = (node?: LayoutNode): void => {\n this.dirty = true\n if (node === undefined) {\n this.walkAll = true\n } else {\n this.dirtyNodes.add(node)\n }\n if (this.scheduled || this.disposed) {\n return\n }\n this.scheduled = true\n queueMicrotask(() => {\n this.scheduled = false\n this.flushSync()\n })\n }\n\n // Pre-order walk: parents commit before children so a child is always\n // positioned inside an already-sized container.\n private commitTree(node: LayoutNode): void {\n const entries: Array<{ node: LayoutNode; rect: Rect; changed: boolean }> =\n []\n const walkAll = this.walkAll\n const visited = this.collectChanges(\n node,\n entries,\n walkAll,\n walkAll ? null : this.dirtyPath(),\n )\n // Mutations made by the callbacks below belong to the NEXT flush.\n this.walkAll = false\n this.dirtyNodes.clear()\n if (perfEnabled) {\n perfCount(\"engine.flushes\")\n perfCount(\"engine.commits\", entries.length)\n perfCount(\"engine.visited\", visited)\n perfGauge(\"engine.nodes\", getLiveNodeCount())\n }\n for (const entry of entries) {\n entry.node.notifyCommit(entry.rect)\n }\n // onLayout fires after the whole pass is committed, like React Native.\n for (const entry of entries) {\n if (entry.changed) {\n entry.node.notifyLayout(entry.rect)\n }\n }\n }\n\n // Every dirty node plus its ancestors: the paths the walk must follow even\n // where Yoga reports no new layout. Nodes already detached from the root\n // (freed mid-tick) simply lead nowhere — the walk never reaches them.\n private dirtyPath(): Set<LayoutNode> {\n const path = new Set<LayoutNode>()\n for (const node of this.dirtyNodes) {\n let current: LayoutNode | null = node\n while (current !== null && !path.has(current)) {\n path.add(current)\n current = current.parent\n }\n }\n return path\n }\n\n // Returns the number of visited nodes (perf: the walk size per flush).\n private collectChanges(\n node: LayoutNode,\n out: Array<{ node: LayoutNode; rect: Rect; changed: boolean }>,\n walkAll: boolean,\n path: Set<LayoutNode> | null,\n ): number {\n const change = node.collectChange()\n if (change !== null) {\n out.push({ node, rect: change.rect, changed: change.changed })\n }\n // Consume the flag: only nodes Yoga lays out again will raise it anew.\n node.yoga.markLayoutSeen()\n let visited = 1\n for (const child of node.children) {\n if (\n walkAll ||\n child.yoga.hasNewLayout() ||\n (path !== null && path.has(child))\n ) {\n visited += this.collectChanges(child, out, walkAll, path)\n }\n }\n return visited\n }\n\n private freeTree(node: LayoutNode): void {\n for (const child of [...node.children]) {\n this.freeTree(child)\n }\n node.free()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/layout/engine.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,OAAO,GACR,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAuClC,MAAM,OAAO,YAAY;IACd,IAAI,CAAY;IAEhB,YAAY,CAAS;IAEtB,QAAQ,CAAc;IACtB,KAAK,GAAG,KAAK,CAAA;IACb,SAAS,GAAG,KAAK,CAAA;IACjB,QAAQ,GAAG,KAAK,CAAA;IACxB,wEAAwE;IACxE,mDAAmD;IAC3C,UAAU,GAAG,IAAI,GAAG,EAAc,CAAA;IAC1C,0EAA0E;IAC1E,4EAA4E;IAC5E,yEAAyE;IACjE,OAAO,GAAG,IAAI,CAAA;IAEtB,YAAY,QAAsB,EAAE,OAA6B;QAC/D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,KAAK,CAAA;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC/C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC1C,CAAC;IAED,WAAW,CA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AO,OAAO,CAAA;IAChB,CAAC;IAEO,QAAQ,CAAC,IAAgB;QAC/B,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;CACF","sourcesContent":["import type { Rect } from \"../contracts\"\nimport {\n perfAddTime,\n perfBurst,\n perfCount,\n perfEnabled,\n perfGauge,\n perfNow,\n} from \"../perf\"\nimport { getLiveNodeCount, LayoutNode } from \"./node\"\nimport { Direction } from \"./yoga\"\n\nexport type ViewportSize = { width: number; height: number }\n\n// One engine per window root. Batches every mutation (style, tree, measure\n// invalidation) into a single Yoga pass per microtask, then walks the shadow\n// tree, diffs rects and fires commit (widget move) + onLayout callbacks only\n// for nodes whose rect actually changed.\n//\n// The commit walk is INCREMENTAL: it descends only where this pass can have\n// changed something, so a small mutation inside a large stable shell costs\n// O(changed) instead of O(all nodes). Two signals drive the descent, and both\n// are needed:\n// - Yoga's per-node `hasNewLayout` flag, which Yoga sets on every node it\n// actually laid out. It covers the nodes a dirty set cannot know about:\n// mutating one child re-lays out its FOLLOWING SIBLINGS (they shift) and\n// any ancestor whose size followed, while untouched subtrees keep their\n// cached layout — and their rects are parent-relative, so an unvisited\n// subtree of a moved container is genuinely unchanged.\n// - the engine's own dirty set (which node each mutation came from), which\n// covers commits Yoga's flag does not imply: a re-measured leaf whose rect\n// is identical still has to recommit, because measuring reset its widget\n// size request.\nexport type LayoutEngineOptions = {\n /**\n * Whether this root REPORTS its Yoga content size to GTK rather than\n * adopting a rectangle it is given — `IntrinsicRoot`, i.e. React Native\n * content mounted directly in a GTK chrome slot.\n *\n * The one thing that reads it is the animated-size rule\n * (../style/animated-size.ts): under a content-sized root every ancestor's\n * size is derived from its children all the way up to the toplevel's own\n * size request, which is the single configuration where a size write really\n * does resize the window (docs/research/animated-size.md §4). Under an\n * ordinary `Root` the climb ends at a viewport instead, and it cannot.\n */\n contentSized?: boolean\n}\n\nexport class LayoutEngine {\n readonly root: LayoutNode\n\n readonly contentSized: boolean\n\n private viewport: ViewportSize\n private dirty = false\n private scheduled = false\n private disposed = false\n // Nodes mutated since the last flush (setStyle/insertChild/removeChild/\n // markDirty/setMeasureFn). Cleared by every flush.\n private dirtyNodes = new Set<LayoutNode>()\n // Set when the engine is dirtied by something that is not a single node —\n // a viewport change or a speculative measureContent pass, both of which can\n // move anything — and for the first flush, where nothing has a rect yet.\n private walkAll = true\n\n constructor(viewport: ViewportSize, options?: LayoutEngineOptions) {\n this.viewport = viewport\n this.contentSized = options?.contentSized ?? false\n this.root = new LayoutNode(this.requestFlush)\n }\n\n createNode(): LayoutNode {\n return new LayoutNode(this.requestFlush)\n }\n\n setViewport(viewport: ViewportSize): void {\n if (\n viewport.width === this.viewport.width &&\n viewport.height === this.viewport.height\n ) {\n return\n }\n this.viewport = viewport\n this.walkAll = true\n this.requestFlush()\n }\n\n getViewport(): ViewportSize {\n return this.viewport\n }\n\n // Synchronous pass — used by tests and by resize handling when the caller\n // needs rects immediately after a mutation.\n flushSync(): void {\n if (!this.dirty || this.disposed) {\n return\n }\n this.dirty = false\n const start = perfEnabled ? perfNow() : 0\n this.root.yoga.calculateLayout(\n this.viewport.width,\n this.viewport.height,\n Direction.LTR,\n )\n if (perfEnabled) {\n perfAddTime(\"engine.yoga\", perfNow() - start)\n }\n this.commitTree(this.root)\n if (perfEnabled) {\n const elapsed = perfNow() - start\n perfAddTime(\"engine.flush\", elapsed)\n perfBurst(\"engine.flushMsPerFrame\", elapsed)\n }\n }\n\n // Intrinsic content size for measure vfuncs: lays the tree out WITHOUT\n // committing widget rects (GTK forbids allocation during measure) and\n // leaves the engine dirty so the next allocate-time flush recomputes\n // against the real viewport instead of these speculative constraints.\n measureContent(\n orientation: \"horizontal\" | \"vertical\",\n forSize: number,\n ): number {\n if (this.disposed) {\n return 0\n }\n const width =\n orientation === \"vertical\" && forSize > 0 ? forSize : undefined\n this.root.yoga.calculateLayout(width, undefined, Direction.LTR)\n const size =\n orientation === \"horizontal\"\n ? this.root.yoga.getComputedWidth()\n : this.root.yoga.getComputedHeight()\n this.dirty = true\n // Speculative constraints may have re-measured leaves anywhere in the\n // tree; the next real flush has to re-commit all of them.\n this.walkAll = true\n return Math.ceil(size)\n }\n\n dispose(): void {\n if (this.disposed) {\n return\n }\n this.disposed = true\n this.freeTree(this.root)\n this.dirtyNodes.clear()\n }\n\n private requestFlush = (node?: LayoutNode): void => {\n this.dirty = true\n if (node === undefined) {\n this.walkAll = true\n } else {\n this.dirtyNodes.add(node)\n }\n if (this.scheduled || this.disposed) {\n return\n }\n this.scheduled = true\n queueMicrotask(() => {\n this.scheduled = false\n this.flushSync()\n })\n }\n\n // Pre-order walk: parents commit before children so a child is always\n // positioned inside an already-sized container.\n private commitTree(node: LayoutNode): void {\n const entries: Array<{ node: LayoutNode; rect: Rect; changed: boolean }> =\n []\n const walkAll = this.walkAll\n const visited = this.collectChanges(\n node,\n entries,\n walkAll,\n walkAll ? null : this.dirtyPath(),\n )\n // Mutations made by the callbacks below belong to the NEXT flush.\n this.walkAll = false\n this.dirtyNodes.clear()\n if (perfEnabled) {\n perfCount(\"engine.flushes\")\n perfCount(\"engine.commits\", entries.length)\n perfCount(\"engine.visited\", visited)\n perfGauge(\"engine.nodes\", getLiveNodeCount())\n }\n for (const entry of entries) {\n entry.node.notifyCommit(entry.rect)\n }\n // onLayout fires after the whole pass is committed, like React Native.\n for (const entry of entries) {\n if (entry.changed) {\n entry.node.notifyLayout(entry.rect)\n }\n }\n }\n\n // Every dirty node plus its ancestors: the paths the walk must follow even\n // where Yoga reports no new layout. Nodes already detached from the root\n // (freed mid-tick) simply lead nowhere — the walk never reaches them.\n private dirtyPath(): Set<LayoutNode> {\n const path = new Set<LayoutNode>()\n for (const node of this.dirtyNodes) {\n let current: LayoutNode | null = node\n while (current !== null && !path.has(current)) {\n path.add(current)\n current = current.parent\n }\n }\n return path\n }\n\n // Returns the number of visited nodes (perf: the walk size per flush).\n private collectChanges(\n node: LayoutNode,\n out: Array<{ node: LayoutNode; rect: Rect; changed: boolean }>,\n walkAll: boolean,\n path: Set<LayoutNode> | null,\n ): number {\n const change = node.collectChange()\n if (change !== null) {\n out.push({ node, rect: change.rect, changed: change.changed })\n }\n // Consume the flag: only nodes Yoga lays out again will raise it anew.\n node.yoga.markLayoutSeen()\n let visited = 1\n for (const child of node.children) {\n if (\n walkAll ||\n child.yoga.hasNewLayout() ||\n (path !== null && path.has(child))\n ) {\n visited += this.collectChanges(child, out, walkAll, path)\n }\n }\n return visited\n }\n\n private freeTree(node: LayoutNode): void {\n for (const child of [...node.children]) {\n this.freeTree(child)\n }\n node.free()\n }\n}\n"]}
|
package/dist/layout/node.d.ts
CHANGED
|
@@ -6,6 +6,19 @@ export declare class LayoutNode implements LayoutNodeApi {
|
|
|
6
6
|
readonly yoga: YogaNode;
|
|
7
7
|
parent: LayoutNode | null;
|
|
8
8
|
readonly children: LayoutNode[];
|
|
9
|
+
/**
|
|
10
|
+
* The layout style last applied to this node — null on the engine root,
|
|
11
|
+
* which is laid out against the viewport rather than a style.
|
|
12
|
+
*
|
|
13
|
+
* Kept because Yoga's JS binding is not fully readable: there is no
|
|
14
|
+
* `getFlex()`, and `setFlex(1)` leaves `getFlexGrow()` at its default, so
|
|
15
|
+
* "does this node's size come from its container" cannot be answered from
|
|
16
|
+
* the Yoga node alone. The animated-size rule
|
|
17
|
+
* (../style/animated-size.ts) has to answer it about a node's CONTAINER,
|
|
18
|
+
* whose style is nowhere near the animated component. One reference to an
|
|
19
|
+
* object that already exists.
|
|
20
|
+
*/
|
|
21
|
+
style: Readonly<LayoutStyle> | null;
|
|
9
22
|
private onDirty;
|
|
10
23
|
private onLayoutCallback;
|
|
11
24
|
private commitCallback;
|
package/dist/layout/node.js
CHANGED
|
@@ -11,6 +11,19 @@ export class LayoutNode {
|
|
|
11
11
|
yoga;
|
|
12
12
|
parent = null;
|
|
13
13
|
children = [];
|
|
14
|
+
/**
|
|
15
|
+
* The layout style last applied to this node — null on the engine root,
|
|
16
|
+
* which is laid out against the viewport rather than a style.
|
|
17
|
+
*
|
|
18
|
+
* Kept because Yoga's JS binding is not fully readable: there is no
|
|
19
|
+
* `getFlex()`, and `setFlex(1)` leaves `getFlexGrow()` at its default, so
|
|
20
|
+
* "does this node's size come from its container" cannot be answered from
|
|
21
|
+
* the Yoga node alone. The animated-size rule
|
|
22
|
+
* (../style/animated-size.ts) has to answer it about a node's CONTAINER,
|
|
23
|
+
* whose style is nowhere near the animated component. One reference to an
|
|
24
|
+
* object that already exists.
|
|
25
|
+
*/
|
|
26
|
+
style = null;
|
|
14
27
|
onDirty;
|
|
15
28
|
onLayoutCallback = null;
|
|
16
29
|
commitCallback = null;
|
|
@@ -30,6 +43,7 @@ export class LayoutNode {
|
|
|
30
43
|
return;
|
|
31
44
|
}
|
|
32
45
|
applyLayoutStyle(this.yoga, style);
|
|
46
|
+
this.style = style;
|
|
33
47
|
this.onDirty(this);
|
|
34
48
|
}
|
|
35
49
|
setMeasureFn(measure) {
|
package/dist/layout/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/layout/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAiB,MAAM,QAAQ,CAAA;AAMpE,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB,gEAAgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAW,EAAE,CAAC,aAAa,CAAA;AAE3D,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,MAAM,OAAO,UAAU;IACZ,IAAI,CAAU;IACvB,MAAM,GAAsB,IAAI,CAAA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,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;QACxB,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,YAAY,CAAC,IAAU;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAED,YAAY,CAAC,IAAU;QACrB,IAAI,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAM;QACR,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;QAC9B,sEAAsE;QACtE,sEAAsE;QACtE,gEAAgE;QAChE,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAA;YAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAChB,aAAa,IAAI,CAAC,CAAA;QAClB,SAAS,CAAC,WAAW,CAAC,CAAA;IACxB,CAAC;CACF","sourcesContent":["import type { LayoutNodeApi, LayoutStyle, MeasureFn, Rect } from \"../contracts\"\nimport { perfCount } from \"../perf\"\nimport { applyLayoutStyle, applyNodeDefaults } from \"./apply-style\"\nimport { createYogaNode, MEASURE_MODE, type YogaNode } from \"./yoga\"\n\n// The engine records WHICH node was mutated so a flush can walk only the\n// dirty subtrees instead of the whole live tree.\ntype DirtyListener = (node: LayoutNode) => void\n\nlet liveNodeCount = 0\n\n// Number of not-yet-freed nodes; used by tests to detect leaks.\nexport const getLiveNodeCount = (): number => liveNodeCount\n\n// Shadow-tree node: owns one Yoga node, mirrors the React component tree.\n// Components talk to it through the LayoutNodeApi contract; the engine walks\n// it after every layout pass to diff rects and notify commit/onLayout hooks.\nexport class LayoutNode implements LayoutNodeApi {\n readonly yoga: YogaNode\n parent: LayoutNode | null = null\n readonly children: LayoutNode[] = []\n\n private onDirty: DirtyListener\n private onLayoutCallback: ((rect: Rect) => void) | null = null\n private commitCallback: ((rect: Rect) => void) | null = null\n private lastRect: Rect | null = null\n private freed = false\n private hasMeasure = false\n private forceCommit = false\n\n constructor(onDirty: DirtyListener) {\n this.yoga = createYogaNode()\n applyNodeDefaults(this.yoga)\n this.onDirty = onDirty\n liveNodeCount += 1\n perfCount(\"node.create\")\n }\n\n setStyle(style: LayoutStyle): void {\n if (this.freed) {\n return\n }\n applyLayoutStyle(this.yoga, style)\n this.onDirty(this)\n }\n\n setMeasureFn(measure: MeasureFn | null): void {\n if (this.freed) {\n return\n }\n if (measure === null) {\n // Unsetting an absent measure func destroys a null wasm binding and\n // crashes yoga-wasm — track presence explicitly.\n if (this.hasMeasure) {\n this.yoga.unsetMeasureFunc()\n this.hasMeasure = false\n }\n } else {\n this.yoga.setMeasureFunc((width, widthMode, height, heightMode) =>\n measure(\n width,\n MEASURE_MODE[widthMode],\n height,\n MEASURE_MODE[heightMode],\n ),\n )\n this.hasMeasure = true\n }\n this.onDirty(this)\n }\n\n markDirty(): void {\n // Only measure-backed leaves may be marked dirty in Yoga.\n if (this.freed || !this.hasMeasure) {\n return\n }\n this.yoga.markDirty()\n // Re-measuring resets the widget size request; even an unchanged rect\n // must recommit so the request is re-applied.\n this.forceCommit = true\n this.onDirty(this)\n }\n\n getRect(): Rect | null {\n return this.lastRect\n }\n\n setOnLayout(callback: ((rect: Rect) => void) | null): void {\n this.onLayoutCallback = callback\n }\n\n // The commit hook is the write path to GTK: the component layer moves its\n // widget's stored rect when the engine reports a new one.\n setCommit(callback: ((rect: Rect) => void) | null): void {\n this.commitCallback = callback\n // A late-registered commit hook must still receive the current rect.\n if (callback !== null && this.lastRect !== null) {\n callback(this.lastRect)\n }\n }\n\n insertChild(child: LayoutNode, index: number): void {\n if (this.freed || child.freed) {\n return\n }\n child.parent = this\n this.children.splice(index, 0, child)\n this.yoga.insertChild(child.yoga, index)\n this.onDirty(this)\n }\n\n removeChild(child: LayoutNode): void {\n const index = this.children.indexOf(child)\n if (index === -1) {\n return\n }\n this.children.splice(index, 1)\n child.parent = null\n // Touching the wasm node of a freed parent corrupts the emscripten heap.\n if (!this.freed && !child.freed) {\n this.yoga.removeChild(child.yoga)\n this.onDirty(this)\n }\n }\n\n // Reads the computed rect (parent-relative). Measured leaves always\n // recommit: any Yoga-invoked re-measure resets their widget size request,\n // and Yoga may re-measure without markDirty (constraint changes), so the\n // request must be re-applied after every pass. onLayout still fires only\n // on real changes.\n collectChange(): { rect: Rect; changed: boolean } | null {\n const rect: Rect = {\n x: this.yoga.getComputedLeft(),\n y: this.yoga.getComputedTop(),\n width: this.yoga.getComputedWidth(),\n height: this.yoga.getComputedHeight(),\n }\n const previous = this.lastRect\n const unchanged =\n previous !== null &&\n previous.x === rect.x &&\n previous.y === rect.y &&\n previous.width === rect.width &&\n previous.height === rect.height\n const changed = this.forceCommit || !unchanged\n this.forceCommit = false\n if (!changed && !this.hasMeasure) {\n return null\n }\n this.lastRect = rect\n return { rect, changed }\n }\n\n notifyCommit(rect: Rect): void {\n this.commitCallback?.(rect)\n }\n\n notifyLayout(rect: Rect): void {\n this.onLayoutCallback?.(rect)\n }\n\n free(): void {\n if (this.freed) {\n return\n }\n this.parent?.removeChild(this)\n // React unmounts parents before children (effect cleanup order), so a\n // container can be freed while its children are still linked — detach\n // them first or their own free() would touch freed wasm memory.\n for (const child of [...this.children]) {\n this.removeChild(child)\n }\n if (this.hasMeasure) {\n this.yoga.unsetMeasureFunc()\n this.hasMeasure = false\n }\n this.freed = true\n this.yoga.free()\n liveNodeCount -= 1\n perfCount(\"node.free\")\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/layout/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAiB,MAAM,QAAQ,CAAA;AAMpE,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB,gEAAgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAW,EAAE,CAAC,aAAa,CAAA;AAE3D,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,MAAM,OAAO,UAAU;IACZ,IAAI,CAAU;IACvB,MAAM,GAAsB,IAAI,CAAA;IACvB,QAAQ,GAAiB,EAAE,CAAA;IAEpC;;;;;;;;;;;OAWG;IACH,KAAK,GAAiC,IAAI,CAAA;IAElC,OAAO,CAAe;IACtB,gBAAgB,GAAkC,IAAI,CAAA;IACtD,cAAc,GAAkC,IAAI,CAAA;IACpD,QAAQ,GAAgB,IAAI,CAAA;IAC5B,KAAK,GAAG,KAAK,CAAA;IACb,UAAU,GAAG,KAAK,CAAA;IAClB,WAAW,GAAG,KAAK,CAAA;IAE3B,YAAY,OAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,cAAc,EAAE,CAAA;QAC5B,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,aAAa,IAAI,CAAC,CAAA;QAClB,SAAS,CAAC,aAAa,CAAC,CAAA;IAC1B,CAAC;IAED,QAAQ,CAAC,KAAkB;QACzB,IAAI,IAAI,CAAC,KAAK,EA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ACD,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;QAC9B,sEAAsE;QACtE,sEAAsE;QACtE,gEAAgE;QAChE,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAA;YAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAChB,aAAa,IAAI,CAAC,CAAA;QAClB,SAAS,CAAC,WAAW,CAAC,CAAA;IACxB,CAAC;CACF","sourcesContent":["import type { LayoutNodeApi, LayoutStyle, MeasureFn, Rect } from \"../contracts\"\nimport { perfCount } from \"../perf\"\nimport { applyLayoutStyle, applyNodeDefaults } from \"./apply-style\"\nimport { createYogaNode, MEASURE_MODE, type YogaNode } from \"./yoga\"\n\n// The engine records WHICH node was mutated so a flush can walk only the\n// dirty subtrees instead of the whole live tree.\ntype DirtyListener = (node: LayoutNode) => void\n\nlet liveNodeCount = 0\n\n// Number of not-yet-freed nodes; used by tests to detect leaks.\nexport const getLiveNodeCount = (): number => liveNodeCount\n\n// Shadow-tree node: owns one Yoga node, mirrors the React component tree.\n// Components talk to it through the LayoutNodeApi contract; the engine walks\n// it after every layout pass to diff rects and notify commit/onLayout hooks.\nexport class LayoutNode implements LayoutNodeApi {\n readonly yoga: YogaNode\n parent: LayoutNode | null = null\n readonly children: LayoutNode[] = []\n\n /**\n * The layout style last applied to this node — null on the engine root,\n * which is laid out against the viewport rather than a style.\n *\n * Kept because Yoga's JS binding is not fully readable: there is no\n * `getFlex()`, and `setFlex(1)` leaves `getFlexGrow()` at its default, so\n * \"does this node's size come from its container\" cannot be answered from\n * the Yoga node alone. The animated-size rule\n * (../style/animated-size.ts) has to answer it about a node's CONTAINER,\n * whose style is nowhere near the animated component. One reference to an\n * object that already exists.\n */\n style: Readonly<LayoutStyle> | null = null\n\n private onDirty: DirtyListener\n private onLayoutCallback: ((rect: Rect) => void) | null = null\n private commitCallback: ((rect: Rect) => void) | null = null\n private lastRect: Rect | null = null\n private freed = false\n private hasMeasure = false\n private forceCommit = false\n\n constructor(onDirty: DirtyListener) {\n this.yoga = createYogaNode()\n applyNodeDefaults(this.yoga)\n this.onDirty = onDirty\n liveNodeCount += 1\n perfCount(\"node.create\")\n }\n\n setStyle(style: LayoutStyle): void {\n if (this.freed) {\n return\n }\n applyLayoutStyle(this.yoga, style)\n this.style = style\n this.onDirty(this)\n }\n\n setMeasureFn(measure: MeasureFn | null): void {\n if (this.freed) {\n return\n }\n if (measure === null) {\n // Unsetting an absent measure func destroys a null wasm binding and\n // crashes yoga-wasm — track presence explicitly.\n if (this.hasMeasure) {\n this.yoga.unsetMeasureFunc()\n this.hasMeasure = false\n }\n } else {\n this.yoga.setMeasureFunc((width, widthMode, height, heightMode) =>\n measure(\n width,\n MEASURE_MODE[widthMode],\n height,\n MEASURE_MODE[heightMode],\n ),\n )\n this.hasMeasure = true\n }\n this.onDirty(this)\n }\n\n markDirty(): void {\n // Only measure-backed leaves may be marked dirty in Yoga.\n if (this.freed || !this.hasMeasure) {\n return\n }\n this.yoga.markDirty()\n // Re-measuring resets the widget size request; even an unchanged rect\n // must recommit so the request is re-applied.\n this.forceCommit = true\n this.onDirty(this)\n }\n\n getRect(): Rect | null {\n return this.lastRect\n }\n\n setOnLayout(callback: ((rect: Rect) => void) | null): void {\n this.onLayoutCallback = callback\n }\n\n // The commit hook is the write path to GTK: the component layer moves its\n // widget's stored rect when the engine reports a new one.\n setCommit(callback: ((rect: Rect) => void) | null): void {\n this.commitCallback = callback\n // A late-registered commit hook must still receive the current rect.\n if (callback !== null && this.lastRect !== null) {\n callback(this.lastRect)\n }\n }\n\n insertChild(child: LayoutNode, index: number): void {\n if (this.freed || child.freed) {\n return\n }\n child.parent = this\n this.children.splice(index, 0, child)\n this.yoga.insertChild(child.yoga, index)\n this.onDirty(this)\n }\n\n removeChild(child: LayoutNode): void {\n const index = this.children.indexOf(child)\n if (index === -1) {\n return\n }\n this.children.splice(index, 1)\n child.parent = null\n // Touching the wasm node of a freed parent corrupts the emscripten heap.\n if (!this.freed && !child.freed) {\n this.yoga.removeChild(child.yoga)\n this.onDirty(this)\n }\n }\n\n // Reads the computed rect (parent-relative). Measured leaves always\n // recommit: any Yoga-invoked re-measure resets their widget size request,\n // and Yoga may re-measure without markDirty (constraint changes), so the\n // request must be re-applied after every pass. onLayout still fires only\n // on real changes.\n collectChange(): { rect: Rect; changed: boolean } | null {\n const rect: Rect = {\n x: this.yoga.getComputedLeft(),\n y: this.yoga.getComputedTop(),\n width: this.yoga.getComputedWidth(),\n height: this.yoga.getComputedHeight(),\n }\n const previous = this.lastRect\n const unchanged =\n previous !== null &&\n previous.x === rect.x &&\n previous.y === rect.y &&\n previous.width === rect.width &&\n previous.height === rect.height\n const changed = this.forceCommit || !unchanged\n this.forceCommit = false\n if (!changed && !this.hasMeasure) {\n return null\n }\n this.lastRect = rect\n return { rect, changed }\n }\n\n notifyCommit(rect: Rect): void {\n this.commitCallback?.(rect)\n }\n\n notifyLayout(rect: Rect): void {\n this.onLayoutCallback?.(rect)\n }\n\n free(): void {\n if (this.freed) {\n return\n }\n this.parent?.removeChild(this)\n // React unmounts parents before children (effect cleanup order), so a\n // container can be freed while its children are still linked — detach\n // them first or their own free() would touch freed wasm memory.\n for (const child of [...this.children]) {\n this.removeChild(child)\n }\n if (this.hasMeasure) {\n this.yoga.unsetMeasureFunc()\n this.hasMeasure = false\n }\n this.freed = true\n this.yoga.free()\n liveNodeCount -= 1\n perfCount(\"node.free\")\n }\n}\n"]}
|
package/dist/layout/yoga.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Yoga, { Align, Direction, Display, Edge, FlexDirection, Gutter, Justify, MeasureMode, Overflow, PositionType, Wrap, type Node as YogaNode } from "yoga-layout";
|
|
1
|
+
import Yoga, { Align, Direction, Display, Edge, FlexDirection, Gutter, Justify, MeasureMode, Overflow, PositionType, Unit, Wrap, type Node as YogaNode } from "yoga-layout";
|
|
2
2
|
import type { FlexAlignType, LayoutStyle, MeasureConstraintMode } from "../contracts";
|
|
3
|
-
export { Direction, Edge, Gutter, MeasureMode, Yoga };
|
|
3
|
+
export { Align, Direction, Edge, FlexDirection, Gutter, MeasureMode, PositionType, Unit, Wrap, Yoga, };
|
|
4
|
+
export type YogaValue = ReturnType<YogaNode["getWidth"]>;
|
|
4
5
|
export type { YogaNode };
|
|
5
6
|
export declare const FLEX_DIRECTION: Record<NonNullable<LayoutStyle["flexDirection"]>, FlexDirection>;
|
|
6
7
|
export declare const JUSTIFY: Record<NonNullable<LayoutStyle["justifyContent"]>, Justify>;
|
package/dist/layout/yoga.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import Yoga, { Align, Direction, Display, Edge, FlexDirection, Gutter, Justify, MeasureMode, Overflow, PositionType, Wrap, } from "yoga-layout";
|
|
2
|
-
|
|
1
|
+
import Yoga, { Align, Direction, Display, Edge, FlexDirection, Gutter, Justify, MeasureMode, Overflow, PositionType, Unit, Wrap, } from "yoga-layout";
|
|
2
|
+
// The enums are re-exported rather than imported from `yoga-layout` directly
|
|
3
|
+
// elsewhere: this module is the one door onto the layout library, the same way
|
|
4
|
+
// `gtkx/bridge` is the one door onto @gtkx.
|
|
5
|
+
export { Align, Direction, Edge, FlexDirection, Gutter, MeasureMode, PositionType, Unit, Wrap, Yoga, };
|
|
3
6
|
export const FLEX_DIRECTION = {
|
|
4
7
|
row: FlexDirection.Row,
|
|
5
8
|
"row-reverse": FlexDirection.RowReverse,
|
package/dist/layout/yoga.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yoga.js","sourceRoot":"","sources":["../../src/layout/yoga.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EACX,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,aAAa,EACb,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,IAAI,GAEL,MAAM,aAAa,CAAA;AAOpB,OAAO,
|
|
1
|
+
{"version":3,"file":"yoga.js","sourceRoot":"","sources":["../../src/layout/yoga.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EACX,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,aAAa,EACb,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,IAAI,GAEL,MAAM,aAAa,CAAA;AAOpB,6EAA6E;AAC7E,+EAA+E;AAC/E,4CAA4C;AAC5C,OAAO,EACL,KAAK,EACL,SAAS,EACT,IAAI,EACJ,aAAa,EACb,MAAM,EACN,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,CAAA;AAOD,MAAM,CAAC,MAAM,cAAc,GAGvB;IACF,GAAG,EAAE,aAAa,CAAC,GAAG;IACtB,aAAa,EAAE,aAAa,CAAC,UAAU;IACvC,MAAM,EAAE,aAAa,CAAC,MAAM;IAC5B,gBAAgB,EAAE,aAAa,CAAC,aAAa;CAC9C,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAGhB;IACF,YAAY,EAAE,OAAO,CAAC,SAAS;IAC/B,UAAU,EAAE,OAAO,CAAC,OAAO;IAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,eAAe,EAAE,OAAO,CAAC,YAAY;IACrC,cAAc,EAAE,OAAO,CAAC,WAAW;IACnC,cAAc,EAAE,OAAO,CAAC,WAAW;CACpC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAGd;IACF,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,Y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\n Overflow,\n PositionType,\n Unit,\n Wrap,\n type Node as YogaNode,\n} from \"yoga-layout\"\nimport type {\n FlexAlignType,\n LayoutStyle,\n MeasureConstraintMode,\n} from \"../contracts\"\n\n// The enums are re-exported rather than imported from `yoga-layout` directly\n// elsewhere: this module is the one door onto the layout library, the same way\n// `gtkx/bridge` is the one door onto @gtkx.\nexport {\n Align,\n Direction,\n Edge,\n FlexDirection,\n Gutter,\n MeasureMode,\n PositionType,\n Unit,\n Wrap,\n Yoga,\n}\n// `yoga-layout` does not export the record its dimension getters return, so\n// it is named here rather than re-derived at every call site.\nexport type YogaValue = ReturnType<YogaNode[\"getWidth\"]>\n\nexport type { YogaNode }\n\nexport const FLEX_DIRECTION: Record<\n NonNullable<LayoutStyle[\"flexDirection\"]>,\n FlexDirection\n> = {\n row: FlexDirection.Row,\n \"row-reverse\": FlexDirection.RowReverse,\n column: FlexDirection.Column,\n \"column-reverse\": FlexDirection.ColumnReverse,\n}\n\nexport const JUSTIFY: Record<\n NonNullable<LayoutStyle[\"justifyContent\"]>,\n Justify\n> = {\n \"flex-start\": Justify.FlexStart,\n \"flex-end\": Justify.FlexEnd,\n center: Justify.Center,\n \"space-between\": Justify.SpaceBetween,\n \"space-around\": Justify.SpaceAround,\n \"space-evenly\": Justify.SpaceEvenly,\n}\n\nexport const ALIGN: Record<\n \"auto\" | FlexAlignType | \"space-between\" | \"space-around\",\n Align\n> = {\n auto: Align.Auto,\n \"flex-start\": Align.FlexStart,\n \"flex-end\": Align.FlexEnd,\n center: Align.Center,\n stretch: Align.Stretch,\n baseline: Align.Baseline,\n \"space-between\": Align.SpaceBetween,\n \"space-around\": Align.SpaceAround,\n}\n\nexport const WRAP: Record<NonNullable<LayoutStyle[\"flexWrap\"]>, Wrap> = {\n nowrap: Wrap.NoWrap,\n wrap: Wrap.Wrap,\n \"wrap-reverse\": Wrap.WrapReverse,\n}\n\nexport const POSITION: Record<\n NonNullable<LayoutStyle[\"position\"]>,\n PositionType\n> = {\n absolute: PositionType.Absolute,\n relative: PositionType.Relative,\n static: PositionType.Static,\n}\n\nexport const OVERFLOW: Record<\n NonNullable<LayoutStyle[\"overflow\"]>,\n Overflow\n> = {\n visible: Overflow.Visible,\n hidden: Overflow.Hidden,\n scroll: Overflow.Scroll,\n}\n\nexport const DISPLAY: Record<NonNullable<LayoutStyle[\"display\"]>, Display> = {\n none: Display.None,\n flex: Display.Flex,\n}\n\nexport const MEASURE_MODE: Record<MeasureMode, MeasureConstraintMode> = {\n [MeasureMode.Undefined]: \"undefined\",\n [MeasureMode.Exactly]: \"exactly\",\n [MeasureMode.AtMost]: \"at-most\",\n}\n\nexport const createYogaNode = (): YogaNode => Yoga.Node.create()\n"]}
|