Module: Plushie
- Defined in:
- lib/plushie.rb,
lib/plushie/ui.rb,
lib/plushie/app.rb,
lib/plushie/data.rb,
lib/plushie/node.rb,
lib/plushie/test.rb,
lib/plushie/tree.rb,
lib/plushie/undo.rb,
lib/plushie/event.rb,
lib/plushie/model.rb,
lib/plushie/route.rb,
lib/plushie/state.rb,
lib/plushie/binary.rb,
lib/plushie/bridge.rb,
lib/plushie/effect.rb,
lib/plushie/encode.rb,
lib/plushie/widget.rb,
lib/plushie/command.rb,
lib/plushie/runtime.rb,
lib/plushie/version.rb,
lib/plushie/protocol.rb,
lib/plushie/animation.rb,
lib/plushie/selection.rb,
lib/plushie/test/case.rb,
lib/plushie/tree/diff.rb,
lib/plushie/type/a11y.rb,
lib/plushie/type/font.rb,
lib/plushie/connection.rb,
lib/plushie/dev_server.rb,
lib/plushie/test/rspec.rb,
lib/plushie/type/color.rb,
lib/plushie/type/theme.rb,
lib/plushie/widget/pin.rb,
lib/plushie/widget/row.rb,
lib/plushie/widget/svg.rb,
lib/plushie/widget_set.rb,
lib/plushie/event/specs.rb,
lib/plushie/test/script.rb,
lib/plushie/thread_pool.rb,
lib/plushie/tree/search.rb,
lib/plushie/type/anchor.rb,
lib/plushie/type/border.rb,
lib/plushie/type/length.rb,
lib/plushie/type/shadow.rb,
lib/plushie/widget/grid.rb,
lib/plushie/widget/rule.rb,
lib/plushie/widget/text.rb,
lib/plushie/canvas/shape.rb,
lib/plushie/command/text.rb,
lib/plushie/renderer_env.rb,
lib/plushie/subscription.rb,
lib/plushie/test/helpers.rb,
lib/plushie/test/session.rb,
lib/plushie/type/padding.rb,
lib/plushie/type/shaping.rb,
lib/plushie/widget/build.rb,
lib/plushie/widget/image.rb,
lib/plushie/widget/radio.rb,
lib/plushie/widget/space.rb,
lib/plushie/widget/stack.rb,
lib/plushie/widget/table.rb,
lib/plushie/bounded_queue.rb,
lib/plushie/canvas_widget.rb,
lib/plushie/cargo_plushie.rb,
lib/plushie/command/image.rb,
lib/plushie/dsl/buildable.rb,
lib/plushie/key_modifiers.rb,
lib/plushie/protocol/keys.rb,
lib/plushie/renderer_exit.rb,
lib/plushie/test/snapshot.rb,
lib/plushie/type/gradient.rb,
lib/plushie/type/position.rb,
lib/plushie/type/wrapping.rb,
lib/plushie/widget/button.rb,
lib/plushie/widget/canvas.rb,
lib/plushie/widget/column.rb,
lib/plushie/widget/sensor.rb,
lib/plushie/widget/slider.rb,
lib/plushie/widget/themer.rb,
lib/plushie/widget/window.rb,
lib/plushie/command/scroll.rb,
lib/plushie/command/window.rb,
lib/plushie/type/alignment.rb,
lib/plushie/type/direction.rb,
lib/plushie/type/style_map.rb,
lib/plushie/widget/overlay.rb,
lib/plushie/widget/qr_code.rb,
lib/plushie/widget/toggler.rb,
lib/plushie/widget/tooltip.rb,
lib/plushie/animation/tween.rb,
lib/plushie/protocol/decode.rb,
lib/plushie/protocol/encode.rb,
lib/plushie/runtime/windows.rb,
lib/plushie/timer_scheduler.rb,
lib/plushie/widget/checkbox.rb,
lib/plushie/widget/floating.rb,
lib/plushie/widget/markdown.rb,
lib/plushie/animation/spring.rb,
lib/plushie/event/diagnostic.rb,
lib/plushie/protocol/parsers.rb,
lib/plushie/runtime/commands.rb,
lib/plushie/type/content_fit.rb,
lib/plushie/type/line_height.rb,
lib/plushie/widget/combo_box.rb,
lib/plushie/widget/container.rb,
lib/plushie/widget/pane_grid.rb,
lib/plushie/widget/pick_list.rb,
lib/plushie/widget/rich_text.rb,
lib/plushie/canvas/shape/clip.rb,
lib/plushie/canvas/shape/dash.rb,
lib/plushie/canvas/shape/line.rb,
lib/plushie/canvas/shape/path.rb,
lib/plushie/canvas/shape/rect.rb,
lib/plushie/test/session_pool.rb,
lib/plushie/transport/framing.rb,
lib/plushie/widget/responsive.rb,
lib/plushie/widget/scrollable.rb,
lib/plushie/widget/text_input.rb,
lib/plushie/animation/sequence.rb,
lib/plushie/canvas/shape/group.rb,
lib/plushie/test/script/runner.rb,
lib/plushie/type/filter_method.rb,
lib/plushie/widget/text_editor.rb,
lib/plushie/canvas/shape/circle.rb,
lib/plushie/canvas/shape/stroke.rb,
lib/plushie/widget/keyed_column.rb,
lib/plushie/widget/native_build.rb,
lib/plushie/widget/pointer_area.rb,
lib/plushie/widget/progress_bar.rb,
lib/plushie/animation/transition.rb,
lib/plushie/command/window_query.rb,
lib/plushie/canvas/shape/hit_rect.rb,
lib/plushie/runtime/subscriptions.rb,
lib/plushie/transport/tcp_adapter.rb,
lib/plushie/canvas/shape/transform.rb,
lib/plushie/widget/vertical_slider.rb,
lib/plushie/canvas/shape/canvas_svg.rb,
lib/plushie/canvas/shape/canvas_text.rb,
lib/plushie/canvas/shape/drag_bounds.rb,
lib/plushie/canvas/shape/shape_style.rb,
lib/plushie/canvas/shape/canvas_image.rb,
lib/plushie/canvas/shape/linear_gradient.rb,
sig/plushie.rbs,
sig/plushie/ui.rbs,
sig/plushie/app.rbs,
sig/plushie/data.rbs,
sig/plushie/node.rbs,
sig/plushie/tree.rbs,
sig/plushie/undo.rbs,
sig/plushie/event.rbs,
sig/plushie/model.rbs,
sig/plushie/route.rbs,
sig/plushie/state.rbs,
sig/plushie/binary.rbs,
sig/plushie/bridge.rbs,
sig/plushie/effect.rbs,
sig/plushie/encode.rbs,
sig/plushie/command.rbs,
sig/plushie/runtime.rbs,
sig/plushie/protocol.rbs,
sig/plushie/animation.rbs,
sig/plushie/selection.rbs,
sig/plushie/tree/diff.rbs,
sig/plushie/type/a11y.rbs,
sig/plushie/type/font.rbs,
sig/plushie/connection.rbs,
sig/plushie/dev_server.rbs,
sig/plushie/widget_dsl.rbs,
sig/plushie/widget_set.rbs,
sig/plushie/thread_pool.rbs,
sig/plushie/tree/search.rbs,
sig/plushie/canvas/shape.rbs,
sig/plushie/command/text.rbs,
sig/plushie/renderer_env.rbs,
sig/plushie/subscription.rbs,
sig/plushie/widget/build.rbs,
sig/plushie/bounded_queue.rbs,
sig/plushie/canvas_widget.rbs,
sig/plushie/cargo_plushie.rbs,
sig/plushie/command/image.rbs,
sig/plushie/dsl/buildable.rbs,
sig/plushie/key_modifiers.rbs,
sig/plushie/type/gradient.rbs,
sig/plushie/command/scroll.rbs,
sig/plushie/command/window.rbs,
sig/plushie/runtime/windows.rbs,
sig/plushie/timer_scheduler.rbs,
sig/plushie/type/line_height.rbs,
sig/plushie/transport/framing.rbs,
sig/plushie/command/window_query.rbs
Overview
Native desktop GUI framework for Ruby, powered by iced.
Plushie implements the Elm architecture (init/update/view) for building desktop applications. The rendering is handled by a precompiled binary that communicates with Ruby over stdin/stdout using MessagePack.
Defined Under Namespace
Modules: Animation, App, Binary, BoundedQueue, Canvas, CanvasWidget, CargoPlushie, DSL, DataQuery, Effect, Encode, Event, Model, Protocol, RendererEnv, Test, Transport, Tree, Type, UI, Widget, WidgetSet Classes: Bridge, Command, Configuration, Connection, DevServer, Error, KeyModifiers, Node, ProtocolVersionMismatchError, RendererExit, Route, Runtime, Selection, State, Subscription, ThreadPool, TimerScheduler, Undo
Constant Summary collapse
- VERSION =
Current version of the plushie gem.
"0.6.0"- PLUSHIE_RUST_VERSION =
The plushie-rust release this SDK targets. Host SDKs pin to this exact version to download the matching renderer binary, install the matching cargo-plushie, and emit matching dep versions into generated Cargo.toml. See plushie-rust docs/versioning.md.
"0.7.1"- RENDERER_EXIT_TYPES =
Structured renderer exit reason passed to
handle_renderer_exit.The runtime converts raw internal exit reasons (connection errors, exit statuses, heartbeat timeouts) into a typed object before calling the app callback. This normalizes implementation details into a stable public API.
Pattern matching works automatically via Data.define:
i[crash connection_lost shutdown heartbeat_timeout].freeze
Instance Attribute Summary collapse
-
#children [Array<Node>] frozen array of child nodes (empty for leaf widgets)([Array<Node>](empty) ⇒ Object
readonly
A UI tree node.
-
#details [Hash, nil] safe structured context([Hash, nil]) ⇒ Object
readonly
Structured renderer exit reason passed to
handle_renderer_exit. -
#id [String] unique widget identifier (scoped within parent containers)([String](scoped within parent containers)) ⇒ Object
readonly
A UI tree node.
-
#message [String] human-readable description([String]) ⇒ Object
readonly
Structured renderer exit reason passed to
handle_renderer_exit. -
#meta [Hash] frozen runtime-only metadata, never sent to the renderer or included in diffs([Hash], neversenttotherenderer) ⇒ Object
readonly
A UI tree node.
-
#props [Hash] frozen hash of property values (symbol keys)([Hash](symbol keys)) ⇒ Object
readonly
A UI tree node.
-
#type [String] widget type name ("button", "column", "text_input", etc.)([String]("button", "column", "text_input", etc.)) ⇒ Object
readonly
A UI tree node.
-
#type [Symbol] exit category (:crash, :connection_lost, :shutdown, :heartbeat_timeout)([Symbol](: crash, :connection_lost, :shutdown, :heartbeat_timeout)) ⇒ Object
readonly
Structured renderer exit reason passed to
handle_renderer_exit.
Class Method Summary collapse
-
.configuration ⇒ Configuration
The global configuration.
-
.configure {|Configuration| ... }
Configure the SDK via a block.
-
.run(app_class, **opts)
Start a Plushie app and block until it exits.
-
.start(app_class, **opts) ⇒ Runtime
Start a Plushie app in the background.
Instance Attribute Details
#children [Array<Node>] frozen array of child nodes (empty for leaf widgets)([Array<Node>](empty) ⇒ Object (readonly)
A UI tree node. Produced by DSL methods and widget builders.
Nodes are immutable value objects representing a single widget in the view tree. The runtime diffs consecutive trees to produce patches sent to the renderer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plushie/node.rb', line 24 Node = Data.define(:id, :type, :props, :children, :meta) do # Create a new Node with string-coerced id and type, and frozen props/children/meta. # # @param id [#to_s] unique widget identifier # @param type [#to_s] widget type name # @param props [Hash] widget properties (will be frozen) # @param children [Array<Node>] child nodes (will be frozen) # @param meta [Hash] runtime-only metadata, never sent to the renderer (will be frozen) # @return [Node] def initialize(id:, type:, props: {}, children: [], meta: {}) raise ArgumentError, "Node id cannot be nil" if id.nil? raise ArgumentError, "Node type cannot be nil" if type.nil? super(id: id.to_s, type: type.to_s, props: props.freeze, children: children.freeze, meta: .freeze) end # Return a new Node with the given fields replaced. # Unspecified fields retain their current values. # # @param changes [Hash] fields to replace (:id, :type, :props, :children, :meta) # @return [Node] new Node with the changes applied def with(**changes) self.class.new(**to_h.merge(changes)) end end |
#details [Hash, nil] safe structured context([Hash, nil]) ⇒ Object (readonly)
Structured renderer exit reason passed to handle_renderer_exit.
The runtime converts raw internal exit reasons (connection errors, exit statuses, heartbeat timeouts) into a typed object before calling the app callback. This normalizes implementation details into a stable public API.
Pattern matching works automatically via Data.define:
28 |
# File 'lib/plushie/renderer_exit.rb', line 28 RENDERER_EXIT_TYPES = i[crash connection_lost shutdown heartbeat_timeout].freeze |
#id [String] unique widget identifier (scoped within parent containers)([String](scoped within parent containers)) ⇒ Object (readonly)
A UI tree node. Produced by DSL methods and widget builders.
Nodes are immutable value objects representing a single widget in the view tree. The runtime diffs consecutive trees to produce patches sent to the renderer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plushie/node.rb', line 24 Node = Data.define(:id, :type, :props, :children, :meta) do # Create a new Node with string-coerced id and type, and frozen props/children/meta. # # @param id [#to_s] unique widget identifier # @param type [#to_s] widget type name # @param props [Hash] widget properties (will be frozen) # @param children [Array<Node>] child nodes (will be frozen) # @param meta [Hash] runtime-only metadata, never sent to the renderer (will be frozen) # @return [Node] def initialize(id:, type:, props: {}, children: [], meta: {}) raise ArgumentError, "Node id cannot be nil" if id.nil? raise ArgumentError, "Node type cannot be nil" if type.nil? super(id: id.to_s, type: type.to_s, props: props.freeze, children: children.freeze, meta: .freeze) end # Return a new Node with the given fields replaced. # Unspecified fields retain their current values. # # @param changes [Hash] fields to replace (:id, :type, :props, :children, :meta) # @return [Node] new Node with the changes applied def with(**changes) self.class.new(**to_h.merge(changes)) end end |
#message [String] human-readable description([String]) ⇒ Object (readonly)
Structured renderer exit reason passed to handle_renderer_exit.
The runtime converts raw internal exit reasons (connection errors, exit statuses, heartbeat timeouts) into a typed object before calling the app callback. This normalizes implementation details into a stable public API.
Pattern matching works automatically via Data.define:
28 |
# File 'lib/plushie/renderer_exit.rb', line 28 RENDERER_EXIT_TYPES = i[crash connection_lost shutdown heartbeat_timeout].freeze |
#meta [Hash] frozen runtime-only metadata, never sent to the renderer or included in diffs([Hash], neversenttotherenderer) ⇒ Object (readonly)
A UI tree node. Produced by DSL methods and widget builders.
Nodes are immutable value objects representing a single widget in the view tree. The runtime diffs consecutive trees to produce patches sent to the renderer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plushie/node.rb', line 24 Node = Data.define(:id, :type, :props, :children, :meta) do # Create a new Node with string-coerced id and type, and frozen props/children/meta. # # @param id [#to_s] unique widget identifier # @param type [#to_s] widget type name # @param props [Hash] widget properties (will be frozen) # @param children [Array<Node>] child nodes (will be frozen) # @param meta [Hash] runtime-only metadata, never sent to the renderer (will be frozen) # @return [Node] def initialize(id:, type:, props: {}, children: [], meta: {}) raise ArgumentError, "Node id cannot be nil" if id.nil? raise ArgumentError, "Node type cannot be nil" if type.nil? super(id: id.to_s, type: type.to_s, props: props.freeze, children: children.freeze, meta: .freeze) end # Return a new Node with the given fields replaced. # Unspecified fields retain their current values. # # @param changes [Hash] fields to replace (:id, :type, :props, :children, :meta) # @return [Node] new Node with the changes applied def with(**changes) self.class.new(**to_h.merge(changes)) end end |
#props [Hash] frozen hash of property values (symbol keys)([Hash](symbol keys)) ⇒ Object (readonly)
A UI tree node. Produced by DSL methods and widget builders.
Nodes are immutable value objects representing a single widget in the view tree. The runtime diffs consecutive trees to produce patches sent to the renderer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plushie/node.rb', line 24 Node = Data.define(:id, :type, :props, :children, :meta) do # Create a new Node with string-coerced id and type, and frozen props/children/meta. # # @param id [#to_s] unique widget identifier # @param type [#to_s] widget type name # @param props [Hash] widget properties (will be frozen) # @param children [Array<Node>] child nodes (will be frozen) # @param meta [Hash] runtime-only metadata, never sent to the renderer (will be frozen) # @return [Node] def initialize(id:, type:, props: {}, children: [], meta: {}) raise ArgumentError, "Node id cannot be nil" if id.nil? raise ArgumentError, "Node type cannot be nil" if type.nil? super(id: id.to_s, type: type.to_s, props: props.freeze, children: children.freeze, meta: .freeze) end # Return a new Node with the given fields replaced. # Unspecified fields retain their current values. # # @param changes [Hash] fields to replace (:id, :type, :props, :children, :meta) # @return [Node] new Node with the changes applied def with(**changes) self.class.new(**to_h.merge(changes)) end end |
#type [String] widget type name ("button", "column", "text_input", etc.)([String]("button", "column", "text_input", etc.)) ⇒ Object (readonly)
A UI tree node. Produced by DSL methods and widget builders.
Nodes are immutable value objects representing a single widget in the view tree. The runtime diffs consecutive trees to produce patches sent to the renderer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plushie/node.rb', line 24 Node = Data.define(:id, :type, :props, :children, :meta) do # Create a new Node with string-coerced id and type, and frozen props/children/meta. # # @param id [#to_s] unique widget identifier # @param type [#to_s] widget type name # @param props [Hash] widget properties (will be frozen) # @param children [Array<Node>] child nodes (will be frozen) # @param meta [Hash] runtime-only metadata, never sent to the renderer (will be frozen) # @return [Node] def initialize(id:, type:, props: {}, children: [], meta: {}) raise ArgumentError, "Node id cannot be nil" if id.nil? raise ArgumentError, "Node type cannot be nil" if type.nil? super(id: id.to_s, type: type.to_s, props: props.freeze, children: children.freeze, meta: .freeze) end # Return a new Node with the given fields replaced. # Unspecified fields retain their current values. # # @param changes [Hash] fields to replace (:id, :type, :props, :children, :meta) # @return [Node] new Node with the changes applied def with(**changes) self.class.new(**to_h.merge(changes)) end end |
#type [Symbol] exit category (:crash, :connection_lost, :shutdown, :heartbeat_timeout)([Symbol](: crash, :connection_lost, :shutdown, :heartbeat_timeout)) ⇒ Object (readonly)
Structured renderer exit reason passed to handle_renderer_exit.
The runtime converts raw internal exit reasons (connection errors, exit statuses, heartbeat timeouts) into a typed object before calling the app callback. This normalizes implementation details into a stable public API.
Pattern matching works automatically via Data.define:
28 |
# File 'lib/plushie/renderer_exit.rb', line 28 RENDERER_EXIT_TYPES = i[crash connection_lost shutdown heartbeat_timeout].freeze |
Class Method Details
.configuration ⇒ Configuration
Returns the global configuration.
233 234 235 |
# File 'lib/plushie.rb', line 233 def self.configuration @configuration end |
.configure {|Configuration| ... }
This method returns an undefined value.
Configure the SDK via a block.
240 241 242 |
# File 'lib/plushie.rb', line 240 def self.configure yield @configuration end |
.run(app_class, **opts)
This method returns an undefined value.
Start a Plushie app and block until it exits.
249 250 251 252 253 |
# File 'lib/plushie.rb', line 249 def self.run(app_class, **opts) app = app_class.new runtime = Runtime.new(app:, **opts) runtime.run end |
.start(app_class, **opts) ⇒ Runtime
Start a Plushie app in the background. Returns a runtime handle.
261 262 263 264 265 266 |
# File 'lib/plushie.rb', line 261 def self.start(app_class, **opts) app = app_class.new runtime = Runtime.new(app:, **opts) runtime.start runtime end |