react-native-gtkx 0.2.0-alpha.1 → 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 +14 -2
- package/dist/adw/widgets.generated.d.ts +4 -4
- package/dist/adw/widgets.generated.js +51 -51
- package/dist/adw/widgets.generated.js.map +1 -1
- 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/create-animated.d.ts +2 -0
- package/dist/animated/create-animated.js +2 -0
- package/dist/animated/create-animated.js.map +1 -1
- package/dist/animated/index.d.ts +4 -0
- package/dist/animated/index.js +6 -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/animated/value-xy.d.ts +41 -0
- package/dist/animated/value-xy.js +90 -0
- package/dist/animated/value-xy.js.map +1 -0
- package/dist/animated/value.d.ts +9 -0
- package/dist/animated/value.js +30 -2
- package/dist/animated/value.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/icon.d.ts +23 -0
- package/dist/common/icon.js +14 -0
- package/dist/common/icon.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +25 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/widget.d.ts +1 -22
- package/dist/common/widget.js +75 -8
- package/dist/common/widget.js.map +1 -1
- package/dist/components/animated.d.ts +73 -7
- package/dist/components/animated.js +560 -45
- package/dist/components/animated.js.map +1 -1
- package/dist/components/app-registry.d.ts +26 -0
- package/dist/components/app-registry.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/host-node.d.ts +7 -0
- package/dist/components/host-node.js +26 -1
- package/dist/components/host-node.js.map +1 -1
- 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 +11 -5
- package/dist/components/index.js +7 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/measure.d.ts +63 -0
- package/dist/components/measure.js +150 -0
- package/dist/components/measure.js.map +1 -0
- package/dist/components/modal.d.ts +1 -1
- package/dist/components/press-event.d.ts +28 -0
- package/dist/components/press-event.js +46 -0
- package/dist/components/press-event.js.map +1 -0
- package/dist/components/pressable.d.ts +63 -7
- package/dist/components/pressable.js +165 -12
- 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 +43 -3
- package/dist/components/scroll-view.js +386 -45
- 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 +68 -9
- 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 +205 -19
- package/dist/components/use-layout-child.js.map +1 -1
- package/dist/components/view.d.ts +12 -4
- package/dist/components/view.js +25 -14
- 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 +23 -3
- 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 +3 -1
- package/dist/gtk/index.js +14 -1
- package/dist/gtk/index.js.map +1 -1
- package/dist/gtk/widgets.generated.d.ts +14 -14
- package/dist/gtk/widgets.generated.js +101 -102
- package/dist/gtk/widgets.generated.js.map +1 -1
- package/dist/gtk/window-actions.d.ts +77 -0
- package/dist/gtk/window-actions.js +193 -0
- package/dist/gtk/window-actions.js.map +1 -0
- package/dist/gtkx/bridge/geometry.d.ts +15 -0
- package/dist/gtkx/bridge/geometry.js +40 -0
- package/dist/gtkx/bridge/geometry.js.map +1 -0
- package/dist/gtkx/bridge/index.d.ts +7 -3
- package/dist/gtkx/bridge/index.js +12 -4
- package/dist/gtkx/bridge/index.js.map +1 -1
- package/dist/gtkx/bridge/slot-portal.d.ts +12 -0
- package/dist/gtkx/bridge/slot-portal.js +17 -0
- package/dist/gtkx/bridge/slot-portal.js.map +1 -0
- package/dist/gtkx/bridge/svg-node.js +10 -54
- package/dist/gtkx/bridge/svg-node.js.map +1 -1
- package/dist/gtkx/bridge/use-signal.js +2 -2
- 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 +310 -91
- package/dist/mcp/data/generated.js +365 -90
- package/dist/mcp/data/generated.js.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/server.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 +47 -1
- package/dist/navigation/sidebar.js +77 -3
- 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 +100 -0
- package/dist/responder/system.js +304 -0
- package/dist/responder/system.js.map +1 -0
- package/dist/responder/touch-history.d.ts +10 -0
- package/dist/responder/touch-history.js +78 -0
- package/dist/responder/touch-history.js.map +1 -0
- package/dist/responder/types.d.ts +63 -0
- package/dist/responder/types.js +29 -0
- package/dist/responder/types.js.map +1 -0
- package/dist/responder/use-responder.d.ts +23 -0
- package/dist/responder/use-responder.js +317 -0
- package/dist/responder/use-responder.js.map +1 -0
- package/dist/runner/host-dev.js +4 -2
- package/dist/runner/host-dev.js.map +1 -1
- package/dist/runner/host.js +6 -2
- 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 +2 -2
- 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/box-shadow.d.ts +7 -0
- package/dist/style/box-shadow.js +197 -0
- package/dist/style/box-shadow.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 +4 -1
- package/dist/style/index.js +4 -1
- package/dist/style/index.js.map +1 -1
- package/dist/style/split-style.d.ts +5 -2
- package/dist/style/split-style.js +36 -3
- package/dist/style/split-style.js.map +1 -1
- package/dist/style/text-decoration.d.ts +15 -0
- package/dist/style/text-decoration.js +26 -0
- package/dist/style/text-decoration.js.map +1 -0
- package/dist/style/visual-css.js +37 -1
- package/dist/style/visual-css.js.map +1 -1
- package/dist/svg/gradient-geometry.js +2 -5
- package/dist/svg/gradient-geometry.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/vendor/react-native/pan-responder.d.ts +102 -0
- package/dist/vendor/react-native/pan-responder.js +196 -0
- package/dist/vendor/react-native/pan-responder.js.map +1 -0
- package/dist/vendor/react-native/touch-history-math.d.ts +18 -0
- package/dist/vendor/react-native/touch-history-math.js +102 -0
- package/dist/vendor/react-native/touch-history-math.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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FlatStyle, SplitStyle } from "../contracts";
|
|
2
2
|
/**
|
|
3
|
-
* Splits a flattened style into { layout, visual }.
|
|
4
|
-
*
|
|
3
|
+
* Splits a flattened style into { layout, visual }. Behavioral props
|
|
4
|
+
* (pointerEvents) belong to neither bucket and are consumed silently — the
|
|
5
|
+
* component that owns the behavior reads them from the flattened style.
|
|
6
|
+
* Unknown properties are ignored with a one-time dev warning per key;
|
|
7
|
+
* undefined values are dropped.
|
|
5
8
|
*/
|
|
6
9
|
export declare const splitStyle: (flat: FlatStyle) => SplitStyle;
|
|
@@ -47,11 +47,14 @@ const LAYOUT_KEYS = {
|
|
|
47
47
|
top: true,
|
|
48
48
|
width: true,
|
|
49
49
|
};
|
|
50
|
+
// Note: `textDecorationLine` and `textAlign` are visual by contract but never
|
|
51
|
+
// reach CSS — Pango carries both, and the Text component applies them.
|
|
50
52
|
// Note: `transform` is visual by contract — it is applied as the
|
|
51
53
|
// GskTransform of the child's allocation, not through CSS, and is passed
|
|
52
54
|
// through here untouched.
|
|
53
55
|
const VISUAL_KEYS = {
|
|
54
56
|
backgroundColor: true,
|
|
57
|
+
boxShadow: true,
|
|
55
58
|
borderBottomColor: true,
|
|
56
59
|
borderBottomLeftRadius: true,
|
|
57
60
|
borderBottomRightRadius: true,
|
|
@@ -76,12 +79,42 @@ const VISUAL_KEYS = {
|
|
|
76
79
|
letterSpacing: true,
|
|
77
80
|
lineHeight: true,
|
|
78
81
|
opacity: true,
|
|
82
|
+
outlineColor: true,
|
|
83
|
+
outlineOffset: true,
|
|
84
|
+
outlineStyle: true,
|
|
85
|
+
outlineWidth: true,
|
|
79
86
|
textAlign: true,
|
|
87
|
+
textDecorationLine: true,
|
|
80
88
|
transform: true,
|
|
81
89
|
};
|
|
90
|
+
// Behavioral props: supported, but by neither half of this pipeline. Since
|
|
91
|
+
// RN 0.71 `pointerEvents` may be written in a style and not only as a prop,
|
|
92
|
+
// and View reads it straight off the flattened style (components/view.tsx)
|
|
93
|
+
// to drive GTK picking — it never reaches Yoga and it has no CSS
|
|
94
|
+
// equivalent. So the splitter must CONSUME it silently: warning here told a
|
|
95
|
+
// user that working code was being ignored, on the very line where
|
|
96
|
+
// tests/gtk/components/pointer-events.gtk.test.tsx proves it is not.
|
|
97
|
+
//
|
|
98
|
+
// Exhaustive the same way the two buckets above are, but over what FlatStyle
|
|
99
|
+
// adds ON TOP of LayoutStyle and VisualStyle — that Omit makes the three
|
|
100
|
+
// records a partition of the contract, so a future fourth kind of style prop
|
|
101
|
+
// cannot be added to FlatStyle without failing compilation right here. That
|
|
102
|
+
// is exactly the drift this list suffered: `pointerEvents` was added to the
|
|
103
|
+
// contract and to View, and nothing forced anyone to classify it.
|
|
104
|
+
const BEHAVIORAL_KEYS = {
|
|
105
|
+
pointerEvents: true,
|
|
106
|
+
// `zIndex` joined it for the same reason: it is neither a Yoga input nor a
|
|
107
|
+
// CSS declaration, it is the container widget's paint and pick order
|
|
108
|
+
// (gtkx/bridge/view-box.ts), and useLayoutChild pushes it there from the
|
|
109
|
+
// flattened style.
|
|
110
|
+
zIndex: true,
|
|
111
|
+
};
|
|
82
112
|
/**
|
|
83
|
-
* Splits a flattened style into { layout, visual }.
|
|
84
|
-
*
|
|
113
|
+
* Splits a flattened style into { layout, visual }. Behavioral props
|
|
114
|
+
* (pointerEvents) belong to neither bucket and are consumed silently — the
|
|
115
|
+
* component that owns the behavior reads them from the flattened style.
|
|
116
|
+
* Unknown properties are ignored with a one-time dev warning per key;
|
|
117
|
+
* undefined values are dropped.
|
|
85
118
|
*/
|
|
86
119
|
export const splitStyle = (flat) => {
|
|
87
120
|
const layout = {};
|
|
@@ -98,7 +131,7 @@ export const splitStyle = (flat) => {
|
|
|
98
131
|
;
|
|
99
132
|
visual[key] = value;
|
|
100
133
|
}
|
|
101
|
-
else {
|
|
134
|
+
else if (!Object.hasOwn(BEHAVIORAL_KEYS, key)) {
|
|
102
135
|
warnOnce(`unknown-style-prop:${key}`, `[react-native-gtkx] Unknown style property "${key}" is not supported and will be ignored`);
|
|
103
136
|
}
|
|
104
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-style.js","sourceRoot":"","sources":["../../src/style/split-style.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,iEAAiE;AAQjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,sEAAsE;AACtE,mEAAmE;AACnE,MAAM,WAAW,GAAoC;IACnD,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,G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,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;CAChB,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"split-style.js","sourceRoot":"","sources":["../../src/style/split-style.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,iEAAiE;AAQjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,sEAAsE;AACtE,mEAAmE;AACnE,MAAM,WAAW,GAAoC;IACnD,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,IAAI;IACpB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,IAAI;IACpB,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,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AA6E;AAC7E,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,eAAe,GAGjB;IACF,aAAa,EAAE,IAAI;IACnB,2EAA2E;IAC3E,qEAAqE;IACrE,yEAAyE;IACzE,mBAAmB;IACnB,MAAM,EAAE,IAAI;CACb,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAe,EAAc,EAAE;IACxD,MAAM,MAAM,GAAgB,EAAE,CAAA;IAC9B,MAAM,MAAM,GAAgB,EAAE,CAAA;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAQ;QACV,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;YACpC,CAAC;YAAC,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACnD,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;YAC3C,CAAC;YAAC,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACnD,CAAC;aAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC;YAChD,QAAQ,CACN,sBAAsB,GAAG,EAAE,EAC3B,+CAA+C,GAAG,wCAAwC,CAC3F,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["// Classifies a flattened style into layout props (consumed by the Yoga\n// engine) and visual props (compiled into GTK CSS). Pure module.\n\nimport type {\n FlatStyle,\n LayoutStyle,\n SplitStyle,\n VisualStyle,\n} from \"../contracts\"\nimport { warnOnce } from \"./dev-warning\"\n\n// Exhaustive over the frozen contract: adding a key to LayoutStyle in\n// contracts.ts fails compilation here until the key is classified.\nconst LAYOUT_KEYS: Record<keyof LayoutStyle, true> = {\n alignContent: true,\n alignItems: true,\n alignSelf: true,\n aspectRatio: true,\n bottom: true,\n columnGap: true,\n direction: true,\n display: true,\n flex: true,\n flexBasis: true,\n flexDirection: true,\n flexGrow: true,\n flexShrink: true,\n flexWrap: true,\n gap: true,\n height: true,\n justifyContent: true,\n left: true,\n margin: true,\n marginBottom: true,\n marginHorizontal: true,\n marginLeft: true,\n marginRight: true,\n marginTop: true,\n marginVertical: true,\n maxHeight: true,\n maxWidth: true,\n minHeight: true,\n minWidth: true,\n overflow: true,\n padding: true,\n paddingBottom: true,\n paddingHorizontal: true,\n paddingLeft: true,\n paddingRight: true,\n paddingTop: true,\n paddingVertical: true,\n position: true,\n right: true,\n rowGap: true,\n top: true,\n width: true,\n}\n\n// Note: `textDecorationLine` and `textAlign` are visual by contract but never\n// reach CSS — Pango carries both, and the Text component applies them.\n// Note: `transform` is visual by contract — it is applied as the\n// GskTransform of the child's allocation, not through CSS, and is passed\n// through here untouched.\nconst VISUAL_KEYS: Record<keyof VisualStyle, true> = {\n backgroundColor: true,\n boxShadow: true,\n borderBottomColor: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderBottomWidth: true,\n borderColor: true,\n borderLeftColor: true,\n borderLeftWidth: true,\n borderRadius: true,\n borderRightColor: true,\n borderRightWidth: true,\n borderStyle: true,\n borderTopColor: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderTopWidth: true,\n borderWidth: true,\n color: true,\n fontFamily: true,\n fontSize: true,\n fontStyle: true,\n fontWeight: true,\n letterSpacing: true,\n lineHeight: true,\n opacity: true,\n outlineColor: true,\n outlineOffset: true,\n outlineStyle: true,\n outlineWidth: true,\n textAlign: true,\n textDecorationLine: true,\n transform: true,\n}\n\n// Behavioral props: supported, but by neither half of this pipeline. Since\n// RN 0.71 `pointerEvents` may be written in a style and not only as a prop,\n// and View reads it straight off the flattened style (components/view.tsx)\n// to drive GTK picking — it never reaches Yoga and it has no CSS\n// equivalent. So the splitter must CONSUME it silently: warning here told a\n// user that working code was being ignored, on the very line where\n// tests/gtk/components/pointer-events.gtk.test.tsx proves it is not.\n//\n// Exhaustive the same way the two buckets above are, but over what FlatStyle\n// adds ON TOP of LayoutStyle and VisualStyle — that Omit makes the three\n// records a partition of the contract, so a future fourth kind of style prop\n// cannot be added to FlatStyle without failing compilation right here. That\n// is exactly the drift this list suffered: `pointerEvents` was added to the\n// contract and to View, and nothing forced anyone to classify it.\nconst BEHAVIORAL_KEYS: Record<\n keyof Omit<FlatStyle, keyof LayoutStyle | keyof VisualStyle>,\n true\n> = {\n pointerEvents: true,\n // `zIndex` joined it for the same reason: it is neither a Yoga input nor a\n // CSS declaration, it is the container widget's paint and pick order\n // (gtkx/bridge/view-box.ts), and useLayoutChild pushes it there from the\n // flattened style.\n zIndex: true,\n}\n\n/**\n * Splits a flattened style into { layout, visual }. Behavioral props\n * (pointerEvents) belong to neither bucket and are consumed silently — the\n * component that owns the behavior reads them from the flattened style.\n * Unknown properties are ignored with a one-time dev warning per key;\n * undefined values are dropped.\n */\nexport const splitStyle = (flat: FlatStyle): SplitStyle => {\n const layout: LayoutStyle = {}\n const visual: VisualStyle = {}\n for (const [key, value] of Object.entries(flat)) {\n if (value === undefined) {\n continue\n }\n if (Object.hasOwn(LAYOUT_KEYS, key)) {\n ;(layout as Record<string, unknown>)[key] = value\n } else if (Object.hasOwn(VISUAL_KEYS, key)) {\n ;(visual as Record<string, unknown>)[key] = value\n } else if (!Object.hasOwn(BEHAVIORAL_KEYS, key)) {\n warnOnce(\n `unknown-style-prop:${key}`,\n `[react-native-gtkx] Unknown style property \"${key}\" is not supported and will be ignored`,\n )\n }\n }\n return { layout, visual }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TextDecorationLine } from "../contracts";
|
|
2
|
+
export type TextDecorations = {
|
|
3
|
+
underline: boolean;
|
|
4
|
+
strikethrough: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Splits RN's `textDecorationLine` into the two Pango attributes that carry
|
|
8
|
+
* it. `"none"` and `undefined` produce neither, which is what lets the caller
|
|
9
|
+
* skip building an attribute list at all.
|
|
10
|
+
*
|
|
11
|
+
* RN's `"underline line-through"` is the combined value; the words are
|
|
12
|
+
* matched individually so the reversed spelling behaves the same, as it does
|
|
13
|
+
* in CSS.
|
|
14
|
+
*/
|
|
15
|
+
export declare const textDecorationToAttrs: (value: TextDecorationLine | undefined) => TextDecorations;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// textDecorationLine, classified. Pure module — no bridge imports.
|
|
2
|
+
//
|
|
3
|
+
// GTK4 CSS has no `text-decoration` for widgets, the same way it has no
|
|
4
|
+
// `text-align`: both are Pango's business, not the style sheet's. So this
|
|
5
|
+
// follows text-align.ts's shape exactly — the style system decides WHAT is
|
|
6
|
+
// wanted, and the Text component applies it through the label's Pango
|
|
7
|
+
// attribute list.
|
|
8
|
+
/**
|
|
9
|
+
* Splits RN's `textDecorationLine` into the two Pango attributes that carry
|
|
10
|
+
* it. `"none"` and `undefined` produce neither, which is what lets the caller
|
|
11
|
+
* skip building an attribute list at all.
|
|
12
|
+
*
|
|
13
|
+
* RN's `"underline line-through"` is the combined value; the words are
|
|
14
|
+
* matched individually so the reversed spelling behaves the same, as it does
|
|
15
|
+
* in CSS.
|
|
16
|
+
*/
|
|
17
|
+
export const textDecorationToAttrs = (value) => {
|
|
18
|
+
if (value === undefined || value === "none") {
|
|
19
|
+
return { underline: false, strikethrough: false };
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
underline: value.includes("underline"),
|
|
23
|
+
strikethrough: value.includes("line-through"),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=text-decoration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-decoration.js","sourceRoot":"","sources":["../../src/style/text-decoration.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,sEAAsE;AACtE,kBAAkB;AASlB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAqC,EACpB,EAAE;IACnB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;IACnD,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;QACtC,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;KAC9C,CAAA;AACH,CAAC,CAAA","sourcesContent":["// textDecorationLine, classified. Pure module — no bridge imports.\n//\n// GTK4 CSS has no `text-decoration` for widgets, the same way it has no\n// `text-align`: both are Pango's business, not the style sheet's. So this\n// follows text-align.ts's shape exactly — the style system decides WHAT is\n// wanted, and the Text component applies it through the label's Pango\n// attribute list.\n\nimport type { TextDecorationLine } from \"../contracts\"\n\nexport type TextDecorations = {\n underline: boolean\n strikethrough: boolean\n}\n\n/**\n * Splits RN's `textDecorationLine` into the two Pango attributes that carry\n * it. `\"none\"` and `undefined` produce neither, which is what lets the caller\n * skip building an attribute list at all.\n *\n * RN's `\"underline line-through\"` is the combined value; the words are\n * matched individually so the reversed spelling behaves the same, as it does\n * in CSS.\n */\nexport const textDecorationToAttrs = (\n value: TextDecorationLine | undefined,\n): TextDecorations => {\n if (value === undefined || value === \"none\") {\n return { underline: false, strikethrough: false }\n }\n return {\n underline: value.includes(\"underline\"),\n strikethrough: value.includes(\"line-through\"),\n }\n}\n"]}
|
package/dist/style/visual-css.js
CHANGED
|
@@ -5,12 +5,19 @@
|
|
|
5
5
|
// GTK4 CSS is not web CSS. What this generator relies on:
|
|
6
6
|
// - background-color, border-*, border-radius (incl. per-corner), opacity,
|
|
7
7
|
// color, font-*, letter-spacing: supported by GTK4;
|
|
8
|
+
// - box-shadow and outline-*: supported by GTK4, and used by Adwaita itself
|
|
9
|
+
// for the `.card`/`.boxed-list` frame and for every focus ring in the
|
|
10
|
+
// theme — which is why an app cannot reproduce the platform's own look
|
|
11
|
+
// without them. box-shadow is compiled by ./box-shadow.ts;
|
|
8
12
|
// - line-height: supported since GTK 4.6 (we target 4.20+);
|
|
9
13
|
// - text-align does NOT exist in GTK CSS — textAlign is applied by the Text
|
|
10
14
|
// component via widget properties (justify/xalign), so it is skipped here;
|
|
15
|
+
// - text-decoration does not exist for GTK widgets either: Pango carries it,
|
|
16
|
+
// and the Text component applies textDecorationLine as label attributes;
|
|
11
17
|
// - transform does NOT exist as a widget property in GTK4 CSS either: it is
|
|
12
18
|
// composed into a matrix by ./transform.ts and applied as the GskTransform
|
|
13
19
|
// of the child's allocation, so it is skipped here as well.
|
|
20
|
+
import { boxShadowToCss } from "./box-shadow";
|
|
14
21
|
import { parseColor } from "./colors";
|
|
15
22
|
import { warnOnce } from "./dev-warning";
|
|
16
23
|
const px = (value) => `${value}px`;
|
|
@@ -44,6 +51,12 @@ export const visualStyleToCss = (visual) => {
|
|
|
44
51
|
if (visual.opacity !== undefined) {
|
|
45
52
|
decls.push(`opacity: ${clamp01(visual.opacity)};`);
|
|
46
53
|
}
|
|
54
|
+
if (visual.boxShadow !== undefined) {
|
|
55
|
+
const shadow = boxShadowToCss(visual.boxShadow);
|
|
56
|
+
if (shadow !== null) {
|
|
57
|
+
decls.push(`box-shadow: ${shadow};`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
47
60
|
// GTK defaults border-style to none — width alone renders nothing. An
|
|
48
61
|
// explicit borderStyle wins (GTK4 CSS supports solid/dotted/dashed);
|
|
49
62
|
// otherwise any positive border width turns the border on with "solid".
|
|
@@ -107,6 +120,28 @@ export const visualStyleToCss = (visual) => {
|
|
|
107
120
|
if (visual.borderBottomLeftRadius !== undefined) {
|
|
108
121
|
decls.push(`border-bottom-left-radius: ${px(visual.borderBottomLeftRadius)};`);
|
|
109
122
|
}
|
|
123
|
+
// outline is a ring around the border box that takes no layout space, so
|
|
124
|
+
// unlike `border` it needs no Yoga involvement at all — GTK4 draws it from
|
|
125
|
+
// CSS exactly as the web does, which is how Adwaita itself paints every
|
|
126
|
+
// focus ring in the theme. GTK, like the web, defaults outline-style to
|
|
127
|
+
// `none`, so a width on its own would draw nothing; the same auto-solid
|
|
128
|
+
// rule the borders above use applies.
|
|
129
|
+
const hasVisibleOutlineWidth = visual.outlineWidth !== undefined && visual.outlineWidth > 0;
|
|
130
|
+
if (visual.outlineStyle !== undefined) {
|
|
131
|
+
decls.push(`outline-style: ${visual.outlineStyle};`);
|
|
132
|
+
}
|
|
133
|
+
else if (hasVisibleOutlineWidth) {
|
|
134
|
+
decls.push("outline-style: solid;");
|
|
135
|
+
}
|
|
136
|
+
if (visual.outlineWidth !== undefined) {
|
|
137
|
+
decls.push(`outline-width: ${px(visual.outlineWidth)};`);
|
|
138
|
+
}
|
|
139
|
+
if (visual.outlineColor !== undefined) {
|
|
140
|
+
pushColor(decls, "outline-color", visual.outlineColor, "outlineColor");
|
|
141
|
+
}
|
|
142
|
+
if (visual.outlineOffset !== undefined) {
|
|
143
|
+
decls.push(`outline-offset: ${px(visual.outlineOffset)};`);
|
|
144
|
+
}
|
|
110
145
|
if (visual.color !== undefined) {
|
|
111
146
|
pushColor(decls, "color", visual.color, "color");
|
|
112
147
|
}
|
|
@@ -128,7 +163,8 @@ export const visualStyleToCss = (visual) => {
|
|
|
128
163
|
if (visual.lineHeight !== undefined) {
|
|
129
164
|
decls.push(`line-height: ${px(visual.lineHeight)};`);
|
|
130
165
|
}
|
|
131
|
-
// visual.textAlign, visual.transform:
|
|
166
|
+
// visual.textAlign, visual.textDecorationLine, visual.transform:
|
|
167
|
+
// intentionally not CSS (see header).
|
|
132
168
|
return decls.join("\n");
|
|
133
169
|
};
|
|
134
170
|
//# sourceMappingURL=visual-css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-css.js","sourceRoot":"","sources":["../../src/style/visual-css.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,0DAA0D;AAC1D,2EAA2E;AAC3E,sDAAsD;AACtD,4DAA4D;AAC5D,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,8DAA8D;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,GAAG,KAAK,IAAI,CAAA;AAElD,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;AAE1E,MAAM,SAAS,GAAG,CAChB,YAAsB,EACtB,WAAmB,EACnB,KAAa,EACb,aAAqB,EACf,EAAE;IACR,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,QAAQ,CACN,iBAAiB,aAAa,IAAI,KAAK,EAAE,EACzC,qCAAqC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,aAAa,yBAAyB,CACzG,CAAA;QACD,OAAM;IACR,CAAC;IACD,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,KAAK,MAAM,GAAG,CAAC,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC7B,IAA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KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAClD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,gBAAgB,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACpE,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAClD,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,SAAS,GAAG,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,UAAU,GAAG,CAAC,CAAA;IAClD,CAAC;IACD,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACtD,CAAC;IAED,0EAA0E;IAE1E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["// Compiles a VisualStyle into a GTK4 CSS declaration block (no selector).\n// Pure module — the resulting string is registered as a class through an\n// injected `css` function (see registry.ts / registry.gtkx.ts).\n//\n// GTK4 CSS is not web CSS. What this generator relies on:\n// - background-color, border-*, border-radius (incl. per-corner), opacity,\n// color, font-*, letter-spacing: supported by GTK4;\n// - line-height: supported since GTK 4.6 (we target 4.20+);\n// - text-align does NOT exist in GTK CSS — textAlign is applied by the Text\n// component via widget properties (justify/xalign), so it is skipped here;\n// - transform does NOT exist as a widget property in GTK4 CSS either: it is\n// composed into a matrix by ./transform.ts and applied as the GskTransform\n// of the child's allocation, so it is skipped here as well.\n\nimport type { VisualStyle } from \"../contracts\"\nimport { parseColor } from \"./colors\"\nimport { warnOnce } from \"./dev-warning\"\n\nconst px = (value: number): string => `${value}px`\n\nconst clamp01 = (value: number): number => Math.min(1, Math.max(0, value))\n\nconst pushColor = (\n declarations: string[],\n cssProperty: string,\n value: string,\n styleProperty: string,\n): void => {\n const parsed = parseColor(value)\n if (parsed === null) {\n warnOnce(\n `invalid-color:${styleProperty}:${value}`,\n `[react-native-gtkx] Invalid color ${JSON.stringify(value)} in \"${styleProperty}\" — declaration dropped`,\n )\n return\n }\n declarations.push(`${cssProperty}: ${parsed};`)\n}\n\nconst formatFontFamily = (family: string): string => {\n const trimmed = family.trim()\n if (/^(\".*\"|'.*')$/.test(trimmed)) {\n return trimmed\n }\n return /^[A-Za-z][\\w-]*$/.test(trimmed)\n ? trimmed\n : `\"${trimmed.replace(/\"/g, '\\\\\"')}\"`\n}\n\n/**\n * Renders a VisualStyle as GTK CSS declarations (one per line, stable\n * order). Returns \"\" when the style produces no CSS (e.g. transform-only).\n */\nexport const visualStyleToCss = (visual: VisualStyle): string => {\n const decls: string[] = []\n\n if (visual.backgroundColor !== undefined) {\n pushColor(\n decls,\n \"background-color\",\n visual.backgroundColor,\n \"backgroundColor\",\n )\n }\n if (visual.opacity !== undefined) {\n decls.push(`opacity: ${clamp01(visual.opacity)};`)\n }\n\n // GTK defaults border-style to none — width alone renders nothing. An\n // explicit borderStyle wins (GTK4 CSS supports solid/dotted/dashed);\n // otherwise any positive border width turns the border on with \"solid\".\n const hasVisibleBorderWidth = [\n visual.borderWidth,\n visual.borderTopWidth,\n visual.borderRightWidth,\n visual.borderBottomWidth,\n visual.borderLeftWidth,\n ].some((width) => width !== undefined && width > 0)\n if (visual.borderStyle !== undefined) {\n decls.push(`border-style: ${visual.borderStyle};`)\n } else if (hasVisibleBorderWidth) {\n decls.push(\"border-style: solid;\")\n }\n // Shorthands first, then per-side overrides so the sides win.\n if (visual.borderWidth !== undefined) {\n decls.push(`border-width: ${px(visual.borderWidth)};`)\n }\n if (visual.borderTopWidth !== undefined) {\n decls.push(`border-top-width: ${px(visual.borderTopWidth)};`)\n }\n if (visual.borderRightWidth !== undefined) {\n decls.push(`border-right-width: ${px(visual.borderRightWidth)};`)\n }\n if (visual.borderBottomWidth !== undefined) {\n decls.push(`border-bottom-width: ${px(visual.borderBottomWidth)};`)\n }\n if (visual.borderLeftWidth !== undefined) {\n decls.push(`border-left-width: ${px(visual.borderLeftWidth)};`)\n }\n if (visual.borderColor !== undefined) {\n pushColor(decls, \"border-color\", visual.borderColor, \"borderColor\")\n }\n if (visual.borderTopColor !== undefined) {\n pushColor(\n decls,\n \"border-top-color\",\n visual.borderTopColor,\n \"borderTopColor\",\n )\n }\n if (visual.borderRightColor !== undefined) {\n pushColor(\n decls,\n \"border-right-color\",\n visual.borderRightColor,\n \"borderRightColor\",\n )\n }\n if (visual.borderBottomColor !== undefined) {\n pushColor(\n decls,\n \"border-bottom-color\",\n visual.borderBottomColor,\n \"borderBottomColor\",\n )\n }\n if (visual.borderLeftColor !== undefined) {\n pushColor(\n decls,\n \"border-left-color\",\n visual.borderLeftColor,\n \"borderLeftColor\",\n )\n }\n if (visual.borderRadius !== undefined) {\n decls.push(`border-radius: ${px(visual.borderRadius)};`)\n }\n // Per-corner radii come after the shorthand so they override it.\n if (visual.borderTopLeftRadius !== undefined) {\n decls.push(`border-top-left-radius: ${px(visual.borderTopLeftRadius)};`)\n }\n if (visual.borderTopRightRadius !== undefined) {\n decls.push(`border-top-right-radius: ${px(visual.borderTopRightRadius)};`)\n }\n if (visual.borderBottomRightRadius !== undefined) {\n decls.push(\n `border-bottom-right-radius: ${px(visual.borderBottomRightRadius)};`,\n )\n }\n if (visual.borderBottomLeftRadius !== undefined) {\n decls.push(\n `border-bottom-left-radius: ${px(visual.borderBottomLeftRadius)};`,\n )\n }\n\n if (visual.color !== undefined) {\n pushColor(decls, \"color\", visual.color, \"color\")\n }\n if (visual.fontFamily !== undefined) {\n decls.push(`font-family: ${formatFontFamily(visual.fontFamily)};`)\n }\n if (visual.fontSize !== undefined) {\n decls.push(`font-size: ${px(visual.fontSize)};`)\n }\n if (visual.fontStyle !== undefined) {\n decls.push(`font-style: ${visual.fontStyle};`)\n }\n if (visual.fontWeight !== undefined) {\n decls.push(`font-weight: ${visual.fontWeight};`)\n }\n if (visual.letterSpacing !== undefined) {\n decls.push(`letter-spacing: ${px(visual.letterSpacing)};`)\n }\n if (visual.lineHeight !== undefined) {\n decls.push(`line-height: ${px(visual.lineHeight)};`)\n }\n\n // visual.textAlign, visual.transform: intentionally not CSS (see header).\n\n return decls.join(\"\\n\")\n}\n"]}
|
|
1
|
+
{"version":3,"file":"visual-css.js","sourceRoot":"","sources":["../../src/style/visual-css.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,0DAA0D;AAC1D,2EAA2E;AAC3E,sDAAsD;AACtD,4EAA4E;AAC5E,wEAAwE;AACxE,yEAAyE;AACzE,6DAA6D;AAC7D,4DAA4D;AAC5D,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,8DAA8D;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,GAAG,KAAK,IAAI,CAA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C,UAAU,GAAG,CAAC,CAAA;IAClD,CAAC;IACD,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACtD,CAAC;IAED,iEAAiE;IACjE,sCAAsC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["// Compiles a VisualStyle into a GTK4 CSS declaration block (no selector).\n// Pure module — the resulting string is registered as a class through an\n// injected `css` function (see registry.ts / registry.gtkx.ts).\n//\n// GTK4 CSS is not web CSS. What this generator relies on:\n// - background-color, border-*, border-radius (incl. per-corner), opacity,\n// color, font-*, letter-spacing: supported by GTK4;\n// - box-shadow and outline-*: supported by GTK4, and used by Adwaita itself\n// for the `.card`/`.boxed-list` frame and for every focus ring in the\n// theme — which is why an app cannot reproduce the platform's own look\n// without them. box-shadow is compiled by ./box-shadow.ts;\n// - line-height: supported since GTK 4.6 (we target 4.20+);\n// - text-align does NOT exist in GTK CSS — textAlign is applied by the Text\n// component via widget properties (justify/xalign), so it is skipped here;\n// - text-decoration does not exist for GTK widgets either: Pango carries it,\n// and the Text component applies textDecorationLine as label attributes;\n// - transform does NOT exist as a widget property in GTK4 CSS either: it is\n// composed into a matrix by ./transform.ts and applied as the GskTransform\n// of the child's allocation, so it is skipped here as well.\n\nimport type { VisualStyle } from \"../contracts\"\nimport { boxShadowToCss } from \"./box-shadow\"\nimport { parseColor } from \"./colors\"\nimport { warnOnce } from \"./dev-warning\"\n\nconst px = (value: number): string => `${value}px`\n\nconst clamp01 = (value: number): number => Math.min(1, Math.max(0, value))\n\nconst pushColor = (\n declarations: string[],\n cssProperty: string,\n value: string,\n styleProperty: string,\n): void => {\n const parsed = parseColor(value)\n if (parsed === null) {\n warnOnce(\n `invalid-color:${styleProperty}:${value}`,\n `[react-native-gtkx] Invalid color ${JSON.stringify(value)} in \"${styleProperty}\" — declaration dropped`,\n )\n return\n }\n declarations.push(`${cssProperty}: ${parsed};`)\n}\n\nconst formatFontFamily = (family: string): string => {\n const trimmed = family.trim()\n if (/^(\".*\"|'.*')$/.test(trimmed)) {\n return trimmed\n }\n return /^[A-Za-z][\\w-]*$/.test(trimmed)\n ? trimmed\n : `\"${trimmed.replace(/\"/g, '\\\\\"')}\"`\n}\n\n/**\n * Renders a VisualStyle as GTK CSS declarations (one per line, stable\n * order). Returns \"\" when the style produces no CSS (e.g. transform-only).\n */\nexport const visualStyleToCss = (visual: VisualStyle): string => {\n const decls: string[] = []\n\n if (visual.backgroundColor !== undefined) {\n pushColor(\n decls,\n \"background-color\",\n visual.backgroundColor,\n \"backgroundColor\",\n )\n }\n if (visual.opacity !== undefined) {\n decls.push(`opacity: ${clamp01(visual.opacity)};`)\n }\n if (visual.boxShadow !== undefined) {\n const shadow = boxShadowToCss(visual.boxShadow)\n if (shadow !== null) {\n decls.push(`box-shadow: ${shadow};`)\n }\n }\n\n // GTK defaults border-style to none — width alone renders nothing. An\n // explicit borderStyle wins (GTK4 CSS supports solid/dotted/dashed);\n // otherwise any positive border width turns the border on with \"solid\".\n const hasVisibleBorderWidth = [\n visual.borderWidth,\n visual.borderTopWidth,\n visual.borderRightWidth,\n visual.borderBottomWidth,\n visual.borderLeftWidth,\n ].some((width) => width !== undefined && width > 0)\n if (visual.borderStyle !== undefined) {\n decls.push(`border-style: ${visual.borderStyle};`)\n } else if (hasVisibleBorderWidth) {\n decls.push(\"border-style: solid;\")\n }\n // Shorthands first, then per-side overrides so the sides win.\n if (visual.borderWidth !== undefined) {\n decls.push(`border-width: ${px(visual.borderWidth)};`)\n }\n if (visual.borderTopWidth !== undefined) {\n decls.push(`border-top-width: ${px(visual.borderTopWidth)};`)\n }\n if (visual.borderRightWidth !== undefined) {\n decls.push(`border-right-width: ${px(visual.borderRightWidth)};`)\n }\n if (visual.borderBottomWidth !== undefined) {\n decls.push(`border-bottom-width: ${px(visual.borderBottomWidth)};`)\n }\n if (visual.borderLeftWidth !== undefined) {\n decls.push(`border-left-width: ${px(visual.borderLeftWidth)};`)\n }\n if (visual.borderColor !== undefined) {\n pushColor(decls, \"border-color\", visual.borderColor, \"borderColor\")\n }\n if (visual.borderTopColor !== undefined) {\n pushColor(\n decls,\n \"border-top-color\",\n visual.borderTopColor,\n \"borderTopColor\",\n )\n }\n if (visual.borderRightColor !== undefined) {\n pushColor(\n decls,\n \"border-right-color\",\n visual.borderRightColor,\n \"borderRightColor\",\n )\n }\n if (visual.borderBottomColor !== undefined) {\n pushColor(\n decls,\n \"border-bottom-color\",\n visual.borderBottomColor,\n \"borderBottomColor\",\n )\n }\n if (visual.borderLeftColor !== undefined) {\n pushColor(\n decls,\n \"border-left-color\",\n visual.borderLeftColor,\n \"borderLeftColor\",\n )\n }\n if (visual.borderRadius !== undefined) {\n decls.push(`border-radius: ${px(visual.borderRadius)};`)\n }\n // Per-corner radii come after the shorthand so they override it.\n if (visual.borderTopLeftRadius !== undefined) {\n decls.push(`border-top-left-radius: ${px(visual.borderTopLeftRadius)};`)\n }\n if (visual.borderTopRightRadius !== undefined) {\n decls.push(`border-top-right-radius: ${px(visual.borderTopRightRadius)};`)\n }\n if (visual.borderBottomRightRadius !== undefined) {\n decls.push(\n `border-bottom-right-radius: ${px(visual.borderBottomRightRadius)};`,\n )\n }\n if (visual.borderBottomLeftRadius !== undefined) {\n decls.push(\n `border-bottom-left-radius: ${px(visual.borderBottomLeftRadius)};`,\n )\n }\n\n // outline is a ring around the border box that takes no layout space, so\n // unlike `border` it needs no Yoga involvement at all — GTK4 draws it from\n // CSS exactly as the web does, which is how Adwaita itself paints every\n // focus ring in the theme. GTK, like the web, defaults outline-style to\n // `none`, so a width on its own would draw nothing; the same auto-solid\n // rule the borders above use applies.\n const hasVisibleOutlineWidth =\n visual.outlineWidth !== undefined && visual.outlineWidth > 0\n if (visual.outlineStyle !== undefined) {\n decls.push(`outline-style: ${visual.outlineStyle};`)\n } else if (hasVisibleOutlineWidth) {\n decls.push(\"outline-style: solid;\")\n }\n if (visual.outlineWidth !== undefined) {\n decls.push(`outline-width: ${px(visual.outlineWidth)};`)\n }\n if (visual.outlineColor !== undefined) {\n pushColor(decls, \"outline-color\", visual.outlineColor, \"outlineColor\")\n }\n if (visual.outlineOffset !== undefined) {\n decls.push(`outline-offset: ${px(visual.outlineOffset)};`)\n }\n\n if (visual.color !== undefined) {\n pushColor(decls, \"color\", visual.color, \"color\")\n }\n if (visual.fontFamily !== undefined) {\n decls.push(`font-family: ${formatFontFamily(visual.fontFamily)};`)\n }\n if (visual.fontSize !== undefined) {\n decls.push(`font-size: ${px(visual.fontSize)};`)\n }\n if (visual.fontStyle !== undefined) {\n decls.push(`font-style: ${visual.fontStyle};`)\n }\n if (visual.fontWeight !== undefined) {\n decls.push(`font-weight: ${visual.fontWeight};`)\n }\n if (visual.letterSpacing !== undefined) {\n decls.push(`letter-spacing: ${px(visual.letterSpacing)};`)\n }\n if (visual.lineHeight !== undefined) {\n decls.push(`line-height: ${px(visual.lineHeight)};`)\n }\n\n // visual.textAlign, visual.textDecorationLine, visual.transform:\n // intentionally not CSS (see header).\n\n return decls.join(\"\\n\")\n}\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Pure objectBoundingBox / userSpaceOnUse coordinate math for gradients — no
|
|
2
|
-
// gtkx imports, so it
|
|
3
|
-
//
|
|
4
|
-
// (see the WORKAROUND note by makeColorStop in gtkx/bridge/svg-node.ts).
|
|
5
|
-
// This is the part of gradient support that already works end to end today
|
|
6
|
-
// and will need no changes once that bug is fixed upstream.
|
|
2
|
+
// gtkx imports, so it is unit-testable off Linux; the bridge
|
|
3
|
+
// (gtkx/bridge/svg-node.ts) feeds the results to Gsk's gradient nodes.
|
|
7
4
|
export const resolveGradientPoint = (bounds, fractionX, fractionY, units) => units === "userSpaceOnUse"
|
|
8
5
|
? { x: fractionX, y: fractionY }
|
|
9
6
|
: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gradient-geometry.js","sourceRoot":"","sources":["../../src/svg/gradient-geometry.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"gradient-geometry.js","sourceRoot":"","sources":["../../src/svg/gradient-geometry.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6DAA6D;AAC7D,uEAAuE;AAUvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAmB,EACnB,SAAiB,EACjB,SAAiB,EACjB,KAAoB,EACM,EAAE,CAC5B,KAAK,KAAK,gBAAgB;IACxB,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE;IAChC,CAAC,CAAC;QACE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,KAAK;QACtC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM;KACxC,CAAA;AAEP,yEAAyE;AACzE,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAAmB,EACnB,CAAS,EACT,KAAoB,EACkB,EAAE,CACxC,KAAK,KAAK,gBAAgB;IACxB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;IAC5B,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA","sourcesContent":["// Pure objectBoundingBox / userSpaceOnUse coordinate math for gradients — no\n// gtkx imports, so it is unit-testable off Linux; the bridge\n// (gtkx/bridge/svg-node.ts) feeds the results to Gsk's gradient nodes.\n\nexport type BoundingBox = {\n x: number\n y: number\n width: number\n height: number\n}\nexport type GradientUnits = \"objectBoundingBox\" | \"userSpaceOnUse\"\n\nexport const resolveGradientPoint = (\n bounds: BoundingBox,\n fractionX: number,\n fractionY: number,\n units: GradientUnits,\n): { x: number; y: number } =>\n units === \"userSpaceOnUse\"\n ? { x: fractionX, y: fractionY }\n : {\n x: bounds.x + fractionX * bounds.width,\n y: bounds.y + fractionY * bounds.height,\n }\n\n// SVG only has one radial radius; objectBoundingBox stretches it into an\n// ellipse matching the shape's own aspect ratio (what browsers do too).\nexport const resolveGradientRadius = (\n bounds: BoundingBox,\n r: number,\n units: GradientUnits,\n): { hradius: number; vradius: number } =>\n units === \"userSpaceOnUse\"\n ? { hradius: r, vradius: r }\n : { hradius: r * bounds.width, vradius: r * bounds.height }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAOlD,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,iDAAiD;AACjD,cAAc,eAAe,CAAA;AA2B7B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAmC,EACnC,OAAkC;IAIlC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;IAChD,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,QAAoC,EACpC,OAAmC,CACpC,CAAA;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC","sourcesContent":["import { render, renderHook } from \"@gtkx/testing\"\nimport type {\n RenderHookOptions,\n RenderHookResult,\n RenderResult,\n} from \"@gtkx/testing\"\n\n// react-native-gtkx/testing — @gtkx/testing's queries, render, renderHook,\n// fireEvent and userEvent already operate on the real GTK widget tree our\n// RN components render into, so `getByText` on a `Text` or `userEvent.click`\n// on a `Pressable` already work with no RN-flavoured wrapper: this subpath\n// re-exports that surface as-is, one import source for a consumer, plus the\n// one genuinely repeated workaround (see below).\nexport * from \"@gtkx/testing\"\n\n//
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAOlD,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,iDAAiD;AACjD,cAAc,eAAe,CAAA;AA2B7B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAmC,EACnC,OAAkC;IAIlC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;IAChD,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,QAAoC,EACpC,OAAmC,CACpC,CAAA;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC","sourcesContent":["import { render, renderHook } from \"@gtkx/testing\"\nimport type {\n RenderHookOptions,\n RenderHookResult,\n RenderResult,\n} from \"@gtkx/testing\"\n\n// react-native-gtkx/testing — @gtkx/testing's queries, render, renderHook,\n// fireEvent and userEvent already operate on the real GTK widget tree our\n// RN components render into, so `getByText` on a `Text` or `userEvent.click`\n// on a `Pressable` already work with no RN-flavoured wrapper: this subpath\n// re-exports that surface as-is, one import source for a consumer, plus the\n// one genuinely repeated workaround (see below).\nexport * from \"@gtkx/testing\"\n\n// RC4-WORKAROUND(renderhook-no-window): see docs/gtkx-rc4-notes.md\n// @gtkx/testing's renderHook() always mounts its test component into a bare\n// Gtk.Box, so a hook that reads the active toplevel (useWindowDimensions,\n// anything through Gtk.Window.getToplevels()) has nothing to read. render()\n// always creates and presents a harness window when no container is given,\n// regardless of what it renders — rendering null is enough to get one.\n\n/**\n * Like `renderHook`, but first creates and presents a harness window (via\n * `render(null)`), so window-dependent hooks have a toplevel to read.\n * Cleanup is automatic — @gtkx/testing tears down every active render\n * (including the harness window) after each test.\n */\nexport function renderHookWithWindow<Result>(\n callback: () => Result,\n options?: RenderHookOptions<undefined>,\n): Promise<\n RenderHookResult<Result, undefined> & { window: RenderResult[\"container\"] }\n>\nexport function renderHookWithWindow<Result, Props>(\n callback: (props: Props) => Result,\n options: RenderHookOptions<Props>,\n): Promise<\n RenderHookResult<Result, Props> & { window: RenderResult[\"container\"] }\n>\nexport async function renderHookWithWindow<Result, Props>(\n callback: (props?: Props) => Result,\n options?: RenderHookOptions<Props>,\n): Promise<\n RenderHookResult<Result, Props> & { window: RenderResult[\"container\"] }\n> {\n const { container: window } = await render(null)\n const hook = await renderHook(\n callback as (props: Props) => Result,\n options as RenderHookOptions<Props>,\n )\n return { ...hook, window }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an `unsupported(name)` for one mirrored package.
|
|
3
|
+
*
|
|
4
|
+
* `explanation` is appended to every message and is where the surface says
|
|
5
|
+
* what IS implemented and what to reach for instead — a refusal that does not
|
|
6
|
+
* point somewhere is half an answer.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createUnsupportedFactory: (packageName: string, explanation: string) => ((name: string) => any);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The stand-in for an export a compat surface deliberately does not
|
|
2
|
+
// implement.
|
|
3
|
+
//
|
|
4
|
+
// WHY it throws rather than no-ops. docs/research/gestures.md records the
|
|
5
|
+
// failure mode this repo most wants to avoid: `Animated.View` silently
|
|
6
|
+
// accepting the responder props and ignoring them compiled, ran, and did
|
|
7
|
+
// nothing — "the worst possible failure mode". A `PanGestureHandler` that
|
|
8
|
+
// renders its children without gestures, or a `FadeIn` that mounts without
|
|
9
|
+
// fading, is the same trap. An unsupported import must fail where it is
|
|
10
|
+
// used, naming itself and naming the replacement.
|
|
11
|
+
//
|
|
12
|
+
// Shared by every mirrored package (react-native-gesture-handler,
|
|
13
|
+
// react-native-reanimated) because the trap is the same one each time and the
|
|
14
|
+
// introspection allowlist below is the part that is easy to get subtly wrong.
|
|
15
|
+
/**
|
|
16
|
+
* Builds an `unsupported(name)` for one mirrored package.
|
|
17
|
+
*
|
|
18
|
+
* `explanation` is appended to every message and is where the surface says
|
|
19
|
+
* what IS implemented and what to reach for instead — a refusal that does not
|
|
20
|
+
* point somewhere is half an answer.
|
|
21
|
+
*/
|
|
22
|
+
export const createUnsupportedFactory = (packageName, explanation) => {
|
|
23
|
+
// React, bundlers and `console.log` all introspect a value before using it.
|
|
24
|
+
// Throwing on `$$typeof` or `toString` would replace a precise message with
|
|
25
|
+
// a confusing one from inside React, so those reads answer normally; every
|
|
26
|
+
// read that could only come from real use throws.
|
|
27
|
+
const introspection = new Set([
|
|
28
|
+
"$$typeof",
|
|
29
|
+
"prototype",
|
|
30
|
+
"name",
|
|
31
|
+
"length",
|
|
32
|
+
"displayName",
|
|
33
|
+
"defaultProps",
|
|
34
|
+
"propTypes",
|
|
35
|
+
"contextTypes",
|
|
36
|
+
"childContextTypes",
|
|
37
|
+
"toString",
|
|
38
|
+
"toJSON",
|
|
39
|
+
"then",
|
|
40
|
+
"_owner",
|
|
41
|
+
"_store",
|
|
42
|
+
"render",
|
|
43
|
+
"constructor",
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* A FUNCTION wrapped in a Proxy, so the symbol throws however it is
|
|
47
|
+
* reached: called as a hook or factory (`usePanGesture()`), rendered as a
|
|
48
|
+
* component (React calls it), or read as a namespace (`Gesture.Pan()`,
|
|
49
|
+
* `State.ACTIVE`).
|
|
50
|
+
*/
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
return (name) => {
|
|
53
|
+
const fail = () => {
|
|
54
|
+
throw new Error(`${packageName}: \`${name}\` is not supported on Linux ` +
|
|
55
|
+
`(react-native-gtkx). ${explanation}`);
|
|
56
|
+
};
|
|
57
|
+
return new Proxy(fail, {
|
|
58
|
+
get: (target, key, receiver) => typeof key === "symbol" || introspection.has(key)
|
|
59
|
+
? Reflect.get(target, key, receiver)
|
|
60
|
+
: fail(),
|
|
61
|
+
apply: fail,
|
|
62
|
+
construct: fail,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=unsupported-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-export.js","sourceRoot":"","sources":["../src/unsupported-export.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,aAAa;AACb,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,kDAAkD;AAClD,EAAE;AACF,kEAAkE;AAClE,8EAA8E;AAC9E,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,WAAmB,EACnB,WAAmB,EAEM,EAAE;IAC3B,4EAA4E;IAC5E,4EAA4E;IAC5E,2EAA2E;IAC3E,kDAAkD;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;QAC5B,UAAU;QACV,WAAW;QACX,MAAM;QACN,QAAQ;QACR,aAAa;QACb,cAAc;QACd,WAAW;QACX,cAAc;QACd,mBAAmB;QACnB,UAAU;QACV,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,aAAa;KACd,CAAC,CAAA;IAEF;;;;;OAKG;IACH,8DAA8D;IAC9D,OAAO,CAAC,IAAY,EAAO,EAAE;QAC3B,MAAM,IAAI,GAAG,GAAU,EAAE;YACvB,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,OAAO,IAAI,+BAA+B;gBACtD,wBAAwB,WAAW,EAAE,CACxC,CAAA;QACH,CAAC,CAAA;QAED,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACrB,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAC7B,OAAO,GAAG,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;gBAC/C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC;gBACpC,CAAC,CAAC,IAAI,EAAE;YACZ,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SAChB,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["// The stand-in for an export a compat surface deliberately does not\n// implement.\n//\n// WHY it throws rather than no-ops. docs/research/gestures.md records the\n// failure mode this repo most wants to avoid: `Animated.View` silently\n// accepting the responder props and ignoring them compiled, ran, and did\n// nothing — \"the worst possible failure mode\". A `PanGestureHandler` that\n// renders its children without gestures, or a `FadeIn` that mounts without\n// fading, is the same trap. An unsupported import must fail where it is\n// used, naming itself and naming the replacement.\n//\n// Shared by every mirrored package (react-native-gesture-handler,\n// react-native-reanimated) because the trap is the same one each time and the\n// introspection allowlist below is the part that is easy to get subtly wrong.\n\n/**\n * Builds an `unsupported(name)` for one mirrored package.\n *\n * `explanation` is appended to every message and is where the surface says\n * what IS implemented and what to reach for instead — a refusal that does not\n * point somewhere is half an answer.\n */\nexport const createUnsupportedFactory = (\n packageName: string,\n explanation: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ((name: string) => any) => {\n // React, bundlers and `console.log` all introspect a value before using it.\n // Throwing on `$$typeof` or `toString` would replace a precise message with\n // a confusing one from inside React, so those reads answer normally; every\n // read that could only come from real use throws.\n const introspection = new Set([\n \"$$typeof\",\n \"prototype\",\n \"name\",\n \"length\",\n \"displayName\",\n \"defaultProps\",\n \"propTypes\",\n \"contextTypes\",\n \"childContextTypes\",\n \"toString\",\n \"toJSON\",\n \"then\",\n \"_owner\",\n \"_store\",\n \"render\",\n \"constructor\",\n ])\n\n /**\n * A FUNCTION wrapped in a Proxy, so the symbol throws however it is\n * reached: called as a hook or factory (`usePanGesture()`), rendered as a\n * component (React calls it), or read as a namespace (`Gesture.Pan()`,\n * `State.ACTIVE`).\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (name: string): any => {\n const fail = (): never => {\n throw new Error(\n `${packageName}: \\`${name}\\` is not supported on Linux ` +\n `(react-native-gtkx). ${explanation}`,\n )\n }\n\n return new Proxy(fail, {\n get: (target, key, receiver) =>\n typeof key === \"symbol\" || introspection.has(key)\n ? Reflect.get(target, key, receiver)\n : fail(),\n apply: fail,\n construct: fail,\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
import type { GestureResponderEvent } from "../../responder/types";
|
|
8
|
+
export type PanResponderGestureState = {
|
|
9
|
+
/** ID of the gestureState - persisted as long as there's a touch on screen */
|
|
10
|
+
stateID: number;
|
|
11
|
+
/** the latest screen coordinates of the recently-moved touch */
|
|
12
|
+
moveX: number;
|
|
13
|
+
/** the latest screen coordinates of the recently-moved touch */
|
|
14
|
+
moveY: number;
|
|
15
|
+
/** the screen coordinates of the responder grant */
|
|
16
|
+
x0: number;
|
|
17
|
+
/** the screen coordinates of the responder grant */
|
|
18
|
+
y0: number;
|
|
19
|
+
/** accumulated distance of the gesture since the touch started */
|
|
20
|
+
dx: number;
|
|
21
|
+
/** accumulated distance of the gesture since the touch started */
|
|
22
|
+
dy: number;
|
|
23
|
+
/** current velocity of the gesture */
|
|
24
|
+
vx: number;
|
|
25
|
+
/** current velocity of the gesture */
|
|
26
|
+
vy: number;
|
|
27
|
+
/** Number of touches currently on screen */
|
|
28
|
+
numberActiveTouches: number;
|
|
29
|
+
/** All `gestureState` accounts for timeStamps up until this value */
|
|
30
|
+
_accountsForMovesUpTo: number;
|
|
31
|
+
};
|
|
32
|
+
type ActiveCallback = (event: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean;
|
|
33
|
+
type PassiveCallback = (event: GestureResponderEvent, gestureState: PanResponderGestureState) => unknown;
|
|
34
|
+
export type GestureResponderHandlerMethods = {
|
|
35
|
+
onMoveShouldSetResponder: (event: GestureResponderEvent) => boolean;
|
|
36
|
+
onMoveShouldSetResponderCapture: (event: GestureResponderEvent) => boolean;
|
|
37
|
+
onResponderEnd: (event: GestureResponderEvent) => void;
|
|
38
|
+
onResponderGrant: (event: GestureResponderEvent) => boolean;
|
|
39
|
+
onResponderMove: (event: GestureResponderEvent) => void;
|
|
40
|
+
onResponderReject: (event: GestureResponderEvent) => void;
|
|
41
|
+
onResponderRelease: (event: GestureResponderEvent) => void;
|
|
42
|
+
onResponderStart: (event: GestureResponderEvent) => void;
|
|
43
|
+
onResponderTerminate: (event: GestureResponderEvent) => void;
|
|
44
|
+
onResponderTerminationRequest: (event: GestureResponderEvent) => boolean;
|
|
45
|
+
onStartShouldSetResponder: (event: GestureResponderEvent) => boolean;
|
|
46
|
+
onStartShouldSetResponderCapture: (event: GestureResponderEvent) => boolean;
|
|
47
|
+
};
|
|
48
|
+
export type PanResponderCallbacks = Readonly<{
|
|
49
|
+
onMoveShouldSetPanResponder?: ActiveCallback;
|
|
50
|
+
onMoveShouldSetPanResponderCapture?: ActiveCallback;
|
|
51
|
+
onStartShouldSetPanResponder?: ActiveCallback;
|
|
52
|
+
onStartShouldSetPanResponderCapture?: ActiveCallback;
|
|
53
|
+
onPanResponderGrant?: PassiveCallback;
|
|
54
|
+
onPanResponderMove?: PassiveCallback;
|
|
55
|
+
onPanResponderRelease?: PassiveCallback;
|
|
56
|
+
onPanResponderTerminate?: PassiveCallback;
|
|
57
|
+
onPanResponderReject?: PassiveCallback;
|
|
58
|
+
onPanResponderStart?: PassiveCallback;
|
|
59
|
+
onPanResponderEnd?: PassiveCallback;
|
|
60
|
+
onPanResponderTerminationRequest?: ActiveCallback;
|
|
61
|
+
onShouldBlockNativeResponder?: ActiveCallback;
|
|
62
|
+
}>;
|
|
63
|
+
declare const PanResponder: {
|
|
64
|
+
_initializeGestureState(gestureState: PanResponderGestureState): void;
|
|
65
|
+
/**
|
|
66
|
+
* This is nuanced and is necessary. It is incorrect to continuously take all
|
|
67
|
+
* active *and* recently moved touches, find the centroid, and track how that
|
|
68
|
+
* result changes over time. Instead, we must take all recently moved
|
|
69
|
+
* touches, and calculate how the centroid has changed just for those
|
|
70
|
+
* recently moved touches, and append that change to an accumulator. This is
|
|
71
|
+
* to (at least) handle the case where the user is moving three fingers, and
|
|
72
|
+
* then one of the fingers stops but the other two continue.
|
|
73
|
+
*
|
|
74
|
+
* This is very different than taking all of the recently moved touches and
|
|
75
|
+
* storing their centroid as `dx/dy`. For correctness, we must *accumulate
|
|
76
|
+
* changes* in the centroid of recently moved touches.
|
|
77
|
+
*
|
|
78
|
+
* There is also some nuance with how we handle multiple moved touches in a
|
|
79
|
+
* single event. With the way `ReactNativeEventEmitter` dispatches touches as
|
|
80
|
+
* individual events, multiple touches generate two 'move' events, each of
|
|
81
|
+
* them triggering `onResponderMove`. But with the way `PanResponder` works,
|
|
82
|
+
* all of the gesture inference is performed on the first dispatch, since it
|
|
83
|
+
* looks at all of the touches (even the ones for which there hasn't been a
|
|
84
|
+
* native dispatch yet). Therefore, `PanResponder` does not call
|
|
85
|
+
* `onResponderMove` passed the first dispatch. This diverges from the
|
|
86
|
+
* typical responder callback pattern (without using `PanResponder`), but
|
|
87
|
+
* avoids more dispatches than necessary.
|
|
88
|
+
*/
|
|
89
|
+
_updateGestureStateOnMove(gestureState: PanResponderGestureState, touchHistory: GestureResponderEvent["touchHistory"]): void;
|
|
90
|
+
/**
|
|
91
|
+
* @param config Enhanced versions of all of the responder callbacks that
|
|
92
|
+
* provide not only the typical `ResponderSyntheticEvent`, but also the
|
|
93
|
+
* `PanResponder` gesture state. Simply replace the word `Responder` with
|
|
94
|
+
* `PanResponder` in each of the typical `onResponder*` callbacks.
|
|
95
|
+
*/
|
|
96
|
+
create(config: PanResponderCallbacks): {
|
|
97
|
+
getInteractionHandle: () => number | null;
|
|
98
|
+
panHandlers: GestureResponderHandlerMethods;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export type PanResponderInstance = ReturnType<(typeof PanResponder)["create"]>;
|
|
102
|
+
export default PanResponder;
|