An open source design system that's fully customizable and agent ready
TypeScript
feat(native): a wire for a TypeScript core driving native views (#7987)
Cindy Zhang8656e3c4dd91
diff --git a/packages/native/README.md b/packages/native/README.mdindex 0e6f4545e2..e5e4243c6e 100644--- a/packages/native/README.md+++ b/packages/native/README.md@@ -19,9 +19,10 @@ rests on evidence.| Swift binding | `apple/` | A Swift package with props generated from the same contracts. iOS and macOS props sit behind `#if os(...)`. || Native theme | `defineNativeTheme` | Durable theme intent (`material: 'opaque' \| 'translucent'`) plus platform entries scoped by OS version, such as Liquid Glass from iOS 26. Never sets tokens. || Icons | `NATIVE_ICON_DEFAULTS` | Astryx's built-in icon names mapped to SF Symbols on Apple platforms and Material Symbols on Android. |+| Wire | `AstryxNode`, `AstryxAction` | Each component as JSON a TypeScript core sends a native host (arm C), and the action a host sends back when a view calls a callback. Swift decodes `<Name>Node` and turns it into `<Name>Props` with `viewProps(send:)`. |-Contracts cover Button, Divider, Heading, ProgressBar, Selector, Switch, Text,-and TextInput. React Native and Android bindings are not built yet; see+Contracts cover Button, Card, Divider, Heading, HStack, ProgressBar, Selector,+Switch, Text, TextInput, and VStack. React Native and Android bindings are not built yet; see[the experiment matrix](#experiment-matrix).```ts@@ -45,12 +46,55 @@ How core documentation becomes a contract:arguments. A callback with an event before a value stays on the web eitherway.- Free-form content becomes a typed slot only where a component declares one- in `slots`; `text` is a string, as for a badge's label or a heading's words.+ in `slots`; `text` is a string, as for a badge's label or a heading's words,+ and `content` is child Astryx components, as for a stack's or a card's+ children. A SwiftUI view takes content as a view builder, so `<Name>Props`+ leaves it out; `<Name>Node` carries it as child nodes.- A closed set of numbers, such as a heading level, is a Swift enum with rawvalues.- A core prop may share a platform toolkit's name only when the componentdeclares in `sameMeaning` that it means the same thing there.+### The wire (arm C)++A TypeScript core sends a tree of nodes and receives actions. A node lists the+callbacks the core listens to in `events`; a view gets only those callbacks.++```ts+// tsconfig: "customConditions": ["ios"]+import type {AstryxAction, AstryxNode} from '@astryxdesign/native/components';++const screen: AstryxNode = {+ component: 'VStack',+ key: 'root',+ props: {+ gap: 2,+ children: [+ {+ component: 'Switch',+ key: 'wifi',+ props: {label: 'Wi-Fi', value: true},+ events: ['onChange'],+ },+ ],+ },+};+// What the host sends back when the switch is turned off:+const action: AstryxAction = {+ key: 'wifi',+ component: 'Switch',+ event: 'onChange',+ args: [false],+};+```++```swift+let node = try JSONDecoder().decode(AstryxNode.self, from: snapshot)+if case .switch(let wifi) = node {+ let props = wifi.viewProps { action in core.dispatch(action.json) }+}+```+## Working on it```shdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/AstryxBase.swift b/packages/native/apple/Sources/AstryxNative/Generated/AstryxBase.swiftindex 732a8225a4..e35d21f0a2 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/AstryxBase.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/AstryxBase.swift@@ -2,7 +2,7 @@public enum AstryxBaseTarget: String, Sendable { case root, trigger, control, container }/// Base props shared by every platform (AST-082 FR7).-public struct AstryxBaseProps: Equatable, Sendable {+public struct AstryxBaseProps: Equatable, Codable, Sendable {public var id: String?public var isHidden: Bool?public init(id: String? = nil, isHidden: Bool? = nil) {diff --git a/packages/native/apple/Sources/AstryxNative/Generated/AstryxNode.swift b/packages/native/apple/Sources/AstryxNative/Generated/AstryxNode.swiftnew file mode 100644index 0000000000..7ccf725f3a--- /dev/null+++ b/packages/native/apple/Sources/AstryxNative/Generated/AstryxNode.swift@@ -0,0 +1,66 @@+// Generated by @astryxdesign/native. Do not edit.+import Foundation++#if os(iOS) || os(macOS)+/// One Astryx component in a tree a TypeScript core sends, by its `component` name.+/// A node this binding cannot read decodes as `unsupported`: an unknown component,+/// or a known one with a value its enums lack or a required prop missing. An older+/// app then keeps drawing the rest of a newer core's tree.+public enum AstryxNode: Decodable, Equatable, Sendable {+ case button(ButtonNode)+ case card(CardNode)+ case divider(DividerNode)+ case heading(HeadingNode)+ case hStack(HStackNode)+ case progressBar(ProgressBarNode)+ case selector(SelectorNode)+ case `switch`(SwitchNode)+ case text(TextNode)+ case textInput(TextInputNode)+ case vStack(VStackNode)+ case unsupported(component: String, key: String)++ public var key: String {+ switch self {+ case .button(let node): return node.key+ case .card(let node): return node.key+ case .divider(let node): return node.key+ case .heading(let node): return node.key+ case .hStack(let node): return node.key+ case .progressBar(let node): return node.key+ case .selector(let node): return node.key+ case .`switch`(let node): return node.key+ case .text(let node): return node.key+ case .textInput(let node): return node.key+ case .vStack(let node): return node.key+ case .unsupported(_, let key): return key+ }+ }++ private enum Keys: String, CodingKey { case component, key }++ public init(from decoder: any Decoder) throws {+ let container = try decoder.container(keyedBy: Keys.self)+ let component = try container.decode(String.self, forKey: .component)+ let key = try container.decode(String.self, forKey: .key)+ do {+ switch component {+ case "Button": self = .button(try ButtonNode(from: decoder))+ case "Card": self = .card(try CardNode(from: decoder))+ case "Divider": self = .divider(try DividerNode(from: decoder))+ case "Heading": self = .heading(try HeadingNode(from: decoder))+ case "HStack": self = .hStack(try HStackNode(from: decoder))+ case "ProgressBar": self = .progressBar(try ProgressBarNode(from: decoder))+ case "Selector": self = .selector(try SelectorNode(from: decoder))+ case "Switch": self = .`switch`(try SwitchNode(from: decoder))+ case "Text": self = .text(try TextNode(from: decoder))+ case "TextInput": self = .textInput(try TextInputNode(from: decoder))+ case "VStack": self = .vStack(try VStackNode(from: decoder))+ default: self = .unsupported(component: component, key: key)+ }+ } catch {+ self = .unsupported(component: component, key: key)+ }+ }+}+#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/AstryxWire.swift b/packages/native/apple/Sources/AstryxNative/Generated/AstryxWire.swiftnew file mode 100644index 0000000000..1401391691--- /dev/null+++ b/packages/native/apple/Sources/AstryxNative/Generated/AstryxWire.swift@@ -0,0 +1,67 @@+// Generated by @astryxdesign/native. Do not edit.+import Foundation++/// A JSON value: a portable callback argument on its way to the core.+public enum AstryxValue: Codable, Equatable, Sendable {+ case null+ case bool(Bool)+ case number(Double)+ case string(String)+ case array([AstryxValue])+ case object([String: AstryxValue])++ /// Any portable value (a contract's strings, numbers, enums, and records) as JSON.+ public init<T: Encodable>(_ value: T) {+ guard let data = try? JSONEncoder().encode(value),+ let decoded = try? JSONDecoder().decode(AstryxValue.self, from: data) else {+ self = .null+ return+ }+ self = decoded+ }++ public init(from decoder: any Decoder) throws {+ let container = try decoder.singleValueContainer()+ if container.decodeNil() { self = .null }+ else if let value = try? container.decode(Bool.self) { self = .bool(value) }+ else if let value = try? container.decode(Double.self) { self = .number(value) }+ else if let value = try? container.decode(String.self) { self = .string(value) }+ else if let value = try? container.decode([AstryxValue].self) { self = .array(value) }+ else { self = .object(try container.decode([String: AstryxValue].self)) }+ }++ public func encode(to encoder: any Encoder) throws {+ var container = encoder.singleValueContainer()+ switch self {+ case .null: try container.encodeNil()+ case .bool(let value): try container.encode(value)+ case .number(let value): try container.encode(value)+ case .string(let value): try container.encode(value)+ case .array(let value): try container.encode(value)+ case .object(let value): try container.encode(value)+ }+ }+}++/// A callback a view called: which node, which prop, and its arguments.+public struct AstryxAction: Codable, Equatable, Sendable {+ public let key: String+ public let component: String+ public let event: String+ public let args: [AstryxValue]++ public init(key: String, component: String, event: String, args: [AstryxValue]) {+ self.key = key+ self.component = component+ self.event = event+ self.args = args+ }++ /// The JSON the core receives.+ public var json: String {+ let encoder = JSONEncoder()+ encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]+ guard let data = try? encoder.encode(self) else { return "{}" }+ return String(decoding: data, as: UTF8.self)+ }+}diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Button.swift b/packages/native/apple/Sources/AstryxNative/Generated/Button.swiftindex 28c1784ec4..d89ec022a6 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Button.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Button.swift@@ -1,16 +1,16 @@// Generated by @astryxdesign/native. Do not edit.-public enum ButtonVariant: String, CaseIterable, Sendable {+public enum ButtonVariant: String, CaseIterable, Codable, Sendable {case primary = "primary"case secondary = "secondary"case ghost = "ghost"case destructive = "destructive"}-public enum ButtonSize: String, CaseIterable, Sendable {+public enum ButtonSize: String, CaseIterable, Codable, Sendable {case sm = "sm"case md = "md"case lg = "lg"}-public enum ButtonElevation: String, CaseIterable, Sendable {+public enum ButtonElevation: String, CaseIterable, Codable, Sendable {case none = "none"case low = "low"case med = "med"@@ -45,6 +45,44 @@ public struct ButtonProps {self.base = base}}+public struct ButtonNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var variant: ButtonVariant?+ public var size: ButtonSize?+ public var elevation: ButtonElevation?+ public var isLoading: Bool?+ public var isInterruptible: Bool?+ public var isDisabled: Bool?+ public var tooltip: String?+ public var href: String?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Button view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ButtonProps {+ let key = self.key+ return ButtonProps(+ label: props.label,+ variant: props.variant,+ size: props.size,+ elevation: props.elevation,+ isLoading: props.isLoading,+ isInterruptible: props.isInterruptible,+ isDisabled: props.isDisabled,+ tooltip: props.tooltip,+ onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Button", event: "onClick", args: [])) } : nil,+ href: props.href,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct ButtonProps {@@ -75,4 +113,42 @@ public struct ButtonProps {self.base = base}}+public struct ButtonNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var variant: ButtonVariant?+ public var size: ButtonSize?+ public var elevation: ButtonElevation?+ public var isLoading: Bool?+ public var isInterruptible: Bool?+ public var isDisabled: Bool?+ public var tooltip: String?+ public var href: String?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Button view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ButtonProps {+ let key = self.key+ return ButtonProps(+ label: props.label,+ variant: props.variant,+ size: props.size,+ elevation: props.elevation,+ isLoading: props.isLoading,+ isInterruptible: props.isInterruptible,+ isDisabled: props.isDisabled,+ tooltip: props.tooltip,+ onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Button", event: "onClick", args: [])) } : nil,+ href: props.href,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Card.swift b/packages/native/apple/Sources/AstryxNative/Generated/Card.swiftnew file mode 100644index 0000000000..ae8589a3cd--- /dev/null+++ b/packages/native/apple/Sources/AstryxNative/Generated/Card.swift@@ -0,0 +1,117 @@+// Generated by @astryxdesign/native. Do not edit.+public enum CardPadding: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum CardVariant: String, CaseIterable, Codable, Sendable {+ case `default` = "default"+ case transparent = "transparent"+ case muted = "muted"+ case blue = "blue"+ case cyan = "cyan"+ case gray = "gray"+ case green = "green"+ case orange = "orange"+ case pink = "pink"+ case purple = "purple"+ case red = "red"+ case teal = "teal"+ case yellow = "yellow"+}+public enum CardElevation: String, CaseIterable, Codable, Sendable {+ case none = "none"+ case low = "low"+ case med = "med"+ case high = "high"+}+#if os(iOS)+public struct CardProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var padding: CardPadding?+ public var variant: CardVariant?+ public var elevation: CardElevation?+ public init(padding: CardPadding? = nil, variant: CardVariant? = nil, elevation: CardElevation? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.padding = padding+ self.variant = variant+ self.elevation = elevation+ self.base = base+ }+}+public struct CardNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var children: [AstryxNode]?+ public var padding: CardPadding?+ public var variant: CardVariant?+ public var elevation: CardElevation?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Card view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> CardProps {+ return CardProps(+ padding: props.padding,+ variant: props.variant,+ elevation: props.elevation,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endif+#if os(macOS)+public struct CardProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var padding: CardPadding?+ public var variant: CardVariant?+ public var elevation: CardElevation?+ public init(padding: CardPadding? = nil, variant: CardVariant? = nil, elevation: CardElevation? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.padding = padding+ self.variant = variant+ self.elevation = elevation+ self.base = base+ }+}+public struct CardNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var children: [AstryxNode]?+ public var padding: CardPadding?+ public var variant: CardVariant?+ public var elevation: CardElevation?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Card view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> CardProps {+ return CardProps(+ padding: props.padding,+ variant: props.variant,+ elevation: props.elevation,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift b/packages/native/apple/Sources/AstryxNative/Generated/Divider.swiftindex efa9e8c8f1..e715df6ff5 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift@@ -1,9 +1,9 @@// Generated by @astryxdesign/native. Do not edit.-public enum DividerOrientation: String, CaseIterable, Sendable {+public enum DividerOrientation: String, CaseIterable, Codable, Sendable {case horizontal = "horizontal"case vertical = "vertical"}-public enum DividerVariant: String, CaseIterable, Sendable {+public enum DividerVariant: String, CaseIterable, Codable, Sendable {case subtle = "subtle"case strong = "strong"}@@ -24,6 +24,32 @@ public struct DividerProps {self.base = base}}+public struct DividerNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var orientation: DividerOrientation?+ public var label: String?+ public var variant: DividerVariant?+ public var isFullBleed: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Divider view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> DividerProps {+ return DividerProps(+ orientation: props.orientation,+ label: props.label,+ variant: props.variant,+ isFullBleed: props.isFullBleed,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct DividerProps {@@ -42,4 +68,30 @@ public struct DividerProps {self.base = base}}+public struct DividerNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var orientation: DividerOrientation?+ public var label: String?+ public var variant: DividerVariant?+ public var isFullBleed: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Divider view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> DividerProps {+ return DividerProps(+ orientation: props.orientation,+ label: props.label,+ variant: props.variant,+ isFullBleed: props.isFullBleed,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/HStack.swift b/packages/native/apple/Sources/AstryxNative/Generated/HStack.swiftnew file mode 100644index 0000000000..a6a15e98d7--- /dev/null+++ b/packages/native/apple/Sources/AstryxNative/Generated/HStack.swift@@ -0,0 +1,308 @@+// Generated by @astryxdesign/native. Do not edit.+public enum HStackGap: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPadding: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingInline: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingInlineStart: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingInlineEnd: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingBlock: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingBlockStart: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackPaddingBlockEnd: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum HStackHAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case between = "between"+ case around = "around"+ case evenly = "evenly"+}+public enum HStackVAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case stretch = "stretch"+}+public enum HStackJustify: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case between = "between"+ case around = "around"+ case evenly = "evenly"+}+public enum HStackAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case stretch = "stretch"+}+public enum HStackWrap: String, CaseIterable, Codable, Sendable {+ case nowrap = "nowrap"+ case wrap = "wrap"+ case wrapReverse = "wrap-reverse"+}+#if os(iOS)+public struct HStackProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var gap: HStackGap?+ public var padding: HStackPadding?+ public var paddingInline: HStackPaddingInline?+ public var paddingInlineStart: HStackPaddingInlineStart?+ public var paddingInlineEnd: HStackPaddingInlineEnd?+ public var paddingBlock: HStackPaddingBlock?+ public var paddingBlockStart: HStackPaddingBlockStart?+ public var paddingBlockEnd: HStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: HStackHAlign?+ public var vAlign: HStackVAlign?+ public var justify: HStackJustify?+ public var align: HStackAlign?+ public var wrap: HStackWrap?+ public init(gap: HStackGap? = nil, padding: HStackPadding? = nil, paddingInline: HStackPaddingInline? = nil, paddingInlineStart: HStackPaddingInlineStart? = nil, paddingInlineEnd: HStackPaddingInlineEnd? = nil, paddingBlock: HStackPaddingBlock? = nil, paddingBlockStart: HStackPaddingBlockStart? = nil, paddingBlockEnd: HStackPaddingBlockEnd? = nil, isScrollable: Bool? = nil, hAlign: HStackHAlign? = nil, vAlign: HStackVAlign? = nil, justify: HStackJustify? = nil, align: HStackAlign? = nil, wrap: HStackWrap? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.gap = gap+ self.padding = padding+ self.paddingInline = paddingInline+ self.paddingInlineStart = paddingInlineStart+ self.paddingInlineEnd = paddingInlineEnd+ self.paddingBlock = paddingBlock+ self.paddingBlockStart = paddingBlockStart+ self.paddingBlockEnd = paddingBlockEnd+ self.isScrollable = isScrollable+ self.hAlign = hAlign+ self.vAlign = vAlign+ self.justify = justify+ self.align = align+ self.wrap = wrap+ self.base = base+ }+}+public struct HStackNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var gap: HStackGap?+ public var padding: HStackPadding?+ public var paddingInline: HStackPaddingInline?+ public var paddingInlineStart: HStackPaddingInlineStart?+ public var paddingInlineEnd: HStackPaddingInlineEnd?+ public var paddingBlock: HStackPaddingBlock?+ public var paddingBlockStart: HStackPaddingBlockStart?+ public var paddingBlockEnd: HStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: HStackHAlign?+ public var vAlign: HStackVAlign?+ public var justify: HStackJustify?+ public var align: HStackAlign?+ public var wrap: HStackWrap?+ public var children: [AstryxNode]?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a HStack view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> HStackProps {+ return HStackProps(+ gap: props.gap,+ padding: props.padding,+ paddingInline: props.paddingInline,+ paddingInlineStart: props.paddingInlineStart,+ paddingInlineEnd: props.paddingInlineEnd,+ paddingBlock: props.paddingBlock,+ paddingBlockStart: props.paddingBlockStart,+ paddingBlockEnd: props.paddingBlockEnd,+ isScrollable: props.isScrollable,+ hAlign: props.hAlign,+ vAlign: props.vAlign,+ justify: props.justify,+ align: props.align,+ wrap: props.wrap,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endif+#if os(macOS)+public struct HStackProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var gap: HStackGap?+ public var padding: HStackPadding?+ public var paddingInline: HStackPaddingInline?+ public var paddingInlineStart: HStackPaddingInlineStart?+ public var paddingInlineEnd: HStackPaddingInlineEnd?+ public var paddingBlock: HStackPaddingBlock?+ public var paddingBlockStart: HStackPaddingBlockStart?+ public var paddingBlockEnd: HStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: HStackHAlign?+ public var vAlign: HStackVAlign?+ public var justify: HStackJustify?+ public var align: HStackAlign?+ public var wrap: HStackWrap?+ public init(gap: HStackGap? = nil, padding: HStackPadding? = nil, paddingInline: HStackPaddingInline? = nil, paddingInlineStart: HStackPaddingInlineStart? = nil, paddingInlineEnd: HStackPaddingInlineEnd? = nil, paddingBlock: HStackPaddingBlock? = nil, paddingBlockStart: HStackPaddingBlockStart? = nil, paddingBlockEnd: HStackPaddingBlockEnd? = nil, isScrollable: Bool? = nil, hAlign: HStackHAlign? = nil, vAlign: HStackVAlign? = nil, justify: HStackJustify? = nil, align: HStackAlign? = nil, wrap: HStackWrap? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.gap = gap+ self.padding = padding+ self.paddingInline = paddingInline+ self.paddingInlineStart = paddingInlineStart+ self.paddingInlineEnd = paddingInlineEnd+ self.paddingBlock = paddingBlock+ self.paddingBlockStart = paddingBlockStart+ self.paddingBlockEnd = paddingBlockEnd+ self.isScrollable = isScrollable+ self.hAlign = hAlign+ self.vAlign = vAlign+ self.justify = justify+ self.align = align+ self.wrap = wrap+ self.base = base+ }+}+public struct HStackNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var gap: HStackGap?+ public var padding: HStackPadding?+ public var paddingInline: HStackPaddingInline?+ public var paddingInlineStart: HStackPaddingInlineStart?+ public var paddingInlineEnd: HStackPaddingInlineEnd?+ public var paddingBlock: HStackPaddingBlock?+ public var paddingBlockStart: HStackPaddingBlockStart?+ public var paddingBlockEnd: HStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: HStackHAlign?+ public var vAlign: HStackVAlign?+ public var justify: HStackJustify?+ public var align: HStackAlign?+ public var wrap: HStackWrap?+ public var children: [AstryxNode]?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a HStack view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> HStackProps {+ return HStackProps(+ gap: props.gap,+ padding: props.padding,+ paddingInline: props.paddingInline,+ paddingInlineStart: props.paddingInlineStart,+ paddingInlineEnd: props.paddingInlineEnd,+ paddingBlock: props.paddingBlock,+ paddingBlockStart: props.paddingBlockStart,+ paddingBlockEnd: props.paddingBlockEnd,+ isScrollable: props.isScrollable,+ hAlign: props.hAlign,+ vAlign: props.vAlign,+ justify: props.justify,+ align: props.align,+ wrap: props.wrap,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift b/packages/native/apple/Sources/AstryxNative/Generated/Heading.swiftindex 2e6c59093b..91dcd15ba9 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift@@ -1,5 +1,5 @@// Generated by @astryxdesign/native. Do not edit.-public enum HeadingLevel: Int, CaseIterable, Sendable {+public enum HeadingLevel: Int, CaseIterable, Codable, Sendable {case v1 = 1case v2 = 2case v3 = 3@@ -7,18 +7,18 @@ public enum HeadingLevel: Int, CaseIterable, Sendable {case v5 = 5case v6 = 6}-public enum HeadingType: String, CaseIterable, Sendable {+public enum HeadingType: String, CaseIterable, Codable, Sendable {case display1 = "display-1"case display2 = "display-2"case display3 = "display-3"}-public enum HeadingWeight: String, CaseIterable, Sendable {+public enum HeadingWeight: String, CaseIterable, Codable, Sendable {case normal = "normal"case medium = "medium"case semibold = "semibold"case bold = "bold"}-public enum HeadingAccessibilityLevel: Int, CaseIterable, Sendable {+public enum HeadingAccessibilityLevel: Int, CaseIterable, Codable, Sendable {case v1 = 1case v2 = 2case v3 = 3@@ -26,7 +26,7 @@ public enum HeadingAccessibilityLevel: Int, CaseIterable, Sendable {case v5 = 5case v6 = 6}-public enum HeadingColor: String, CaseIterable, Sendable {+public enum HeadingColor: String, CaseIterable, Codable, Sendable {case primary = "primary"case secondary = "secondary"case disabled = "disabled"@@ -34,7 +34,7 @@ public enum HeadingColor: String, CaseIterable, Sendable {case accent = "accent"case inherit = "inherit"}-public enum HeadingJustify: String, CaseIterable, Sendable {+public enum HeadingJustify: String, CaseIterable, Codable, Sendable {case start = "start"case center = "center"case end = "end"@@ -66,6 +66,42 @@ public struct HeadingProps {self.base = base}}+public struct HeadingNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var level: HeadingLevel+ public var type: HeadingType?+ public var weight: HeadingWeight?+ public var children: String+ public var accessibilityLevel: HeadingAccessibilityLevel?+ public var color: HeadingColor?+ public var maxLines: Double?+ public var justify: HeadingJustify?+ public var hasStrikethrough: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Heading view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> HeadingProps {+ return HeadingProps(+ level: props.level,+ type: props.type,+ weight: props.weight,+ children: props.children,+ accessibilityLevel: props.accessibilityLevel,+ color: props.color,+ maxLines: props.maxLines,+ justify: props.justify,+ hasStrikethrough: props.hasStrikethrough,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct HeadingProps {@@ -94,4 +130,40 @@ public struct HeadingProps {self.base = base}}+public struct HeadingNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var level: HeadingLevel+ public var type: HeadingType?+ public var weight: HeadingWeight?+ public var children: String+ public var accessibilityLevel: HeadingAccessibilityLevel?+ public var color: HeadingColor?+ public var maxLines: Double?+ public var justify: HeadingJustify?+ public var hasStrikethrough: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Heading view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> HeadingProps {+ return HeadingProps(+ level: props.level,+ type: props.type,+ weight: props.weight,+ children: props.children,+ accessibilityLevel: props.accessibilityLevel,+ color: props.color,+ maxLines: props.maxLines,+ justify: props.justify,+ hasStrikethrough: props.hasStrikethrough,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift b/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swiftindex 830597ded7..dc02d860d4 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift@@ -1,12 +1,12 @@// Generated by @astryxdesign/native. Do not edit.-public enum ProgressBarVariant: String, CaseIterable, Sendable {+public enum ProgressBarVariant: String, CaseIterable, Codable, Sendable {case accent = "accent"case success = "success"case warning = "warning"case error = "error"case neutral = "neutral"}-public struct ProgressBarMarks: Equatable, Sendable {+public struct ProgressBarMarks: Equatable, Codable, Sendable {public var value: Doublepublic var label: Stringpublic init(value: Double, label: String) {@@ -41,6 +41,42 @@ public struct ProgressBarProps {self.base = base}}+public struct ProgressBarNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var value: Double?+ public var max: Double?+ public var isLabelHidden: Bool?+ public var hasValueLabel: Bool?+ public var variant: ProgressBarVariant?+ public var isIndeterminate: Bool?+ public var marks: [ProgressBarMarks]?+ public var isDisabled: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a ProgressBar view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ProgressBarProps {+ return ProgressBarProps(+ label: props.label,+ value: props.value,+ max: props.max,+ isLabelHidden: props.isLabelHidden,+ hasValueLabel: props.hasValueLabel,+ variant: props.variant,+ isIndeterminate: props.isIndeterminate,+ marks: props.marks,+ isDisabled: props.isDisabled,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct ProgressBarProps {@@ -69,4 +105,40 @@ public struct ProgressBarProps {self.base = base}}+public struct ProgressBarNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var value: Double?+ public var max: Double?+ public var isLabelHidden: Bool?+ public var hasValueLabel: Bool?+ public var variant: ProgressBarVariant?+ public var isIndeterminate: Bool?+ public var marks: [ProgressBarMarks]?+ public var isDisabled: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a ProgressBar view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ProgressBarProps {+ return ProgressBarProps(+ label: props.label,+ value: props.value,+ max: props.max,+ isLabelHidden: props.isLabelHidden,+ hasValueLabel: props.hasValueLabel,+ variant: props.variant,+ isIndeterminate: props.isIndeterminate,+ marks: props.marks,+ isDisabled: props.isDisabled,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Selector.swift b/packages/native/apple/Sources/AstryxNative/Generated/Selector.swiftindex af4655836d..23642d07c7 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Selector.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Selector.swift@@ -1,5 +1,5 @@// Generated by @astryxdesign/native. Do not edit.-public struct SelectorOption: Equatable, Sendable {+public struct SelectorOption: Equatable, Codable, Sendable {public var value: Stringpublic var label: String?public var disabled: Bool?@@ -9,22 +9,22 @@ public struct SelectorOption: Equatable, Sendable {self.disabled = disabled}}-public enum SelectorSize: String, CaseIterable, Sendable {+public enum SelectorSize: String, CaseIterable, Codable, Sendable {case sm = "sm"case md = "md"case lg = "lg"}-public enum SelectorVariant: String, CaseIterable, Sendable {+public enum SelectorVariant: String, CaseIterable, Codable, Sendable {case input = "input"case secondary = "secondary"case ghost = "ghost"}-public enum SelectorStatusType: String, CaseIterable, Sendable {+public enum SelectorStatusType: String, CaseIterable, Codable, Sendable {case error = "error"case warning = "warning"case success = "success"}-public struct SelectorStatus: Equatable, Sendable {+public struct SelectorStatus: Equatable, Codable, Sendable {public var type: SelectorStatusTypepublic var message: String?public init(type: SelectorStatusType, message: String? = nil) {@@ -32,17 +32,17 @@ public struct SelectorStatus: Equatable, Sendable {self.message = message}}-public enum SelectorStatusVariant: String, CaseIterable, Sendable {+public enum SelectorStatusVariant: String, CaseIterable, Codable, Sendable {case attached = "attached"case detached = "detached"case tooltip = "tooltip"}-public enum SelectorIndicatorPosition: String, CaseIterable, Sendable {+public enum SelectorIndicatorPosition: String, CaseIterable, Codable, Sendable {case start = "start"case end = "end"}#if os(iOS)-public enum SelectorMenuStyle: String, CaseIterable, Sendable {+public enum SelectorMenuStyle: String, CaseIterable, Codable, Sendable {case popUp = "popUp"case pullDown = "pullDown"}@@ -98,9 +98,71 @@ public struct SelectorProps {self.base = base}}+public struct SelectorNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var options: [SelectorOption]+ public var value: String?+ public var hasClear: Bool?+ public var hasSearch: Bool?+ public var searchPlaceholder: String?+ public var placeholder: String?+ public var size: SelectorSize?+ public var variant: SelectorVariant?+ public var isDisabled: Bool?+ public var isReadOnly: Bool?+ public var disabledMessage: String?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var status: SelectorStatus?+ public var statusVariant: SelectorStatusVariant?+ public var indicatorPosition: SelectorIndicatorPosition?+ public var isLoading: Bool?+ public var menuStyle: SelectorMenuStyle?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Selector view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SelectorProps {+ let key = self.key+ return SelectorProps(+ label: props.label,+ options: props.options,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Selector", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ hasClear: props.hasClear,+ hasSearch: props.hasSearch,+ searchPlaceholder: props.searchPlaceholder,+ placeholder: props.placeholder,+ size: props.size,+ variant: props.variant,+ isDisabled: props.isDisabled,+ isReadOnly: props.isReadOnly,+ disabledMessage: props.disabledMessage,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ status: props.status,+ statusVariant: props.statusVariant,+ indicatorPosition: props.indicatorPosition,+ isLoading: props.isLoading,+ menuStyle: props.menuStyle,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)-public enum SelectorMenuStyle: String, CaseIterable, Sendable {+public enum SelectorMenuStyle: String, CaseIterable, Codable, Sendable {case popUp = "popUp"case pullDown = "pullDown"}@@ -156,4 +218,66 @@ public struct SelectorProps {self.base = base}}+public struct SelectorNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var options: [SelectorOption]+ public var value: String?+ public var hasClear: Bool?+ public var hasSearch: Bool?+ public var searchPlaceholder: String?+ public var placeholder: String?+ public var size: SelectorSize?+ public var variant: SelectorVariant?+ public var isDisabled: Bool?+ public var isReadOnly: Bool?+ public var disabledMessage: String?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var status: SelectorStatus?+ public var statusVariant: SelectorStatusVariant?+ public var indicatorPosition: SelectorIndicatorPosition?+ public var isLoading: Bool?+ public var menuStyle: SelectorMenuStyle?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Selector view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SelectorProps {+ let key = self.key+ return SelectorProps(+ label: props.label,+ options: props.options,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Selector", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ hasClear: props.hasClear,+ hasSearch: props.hasSearch,+ searchPlaceholder: props.searchPlaceholder,+ placeholder: props.placeholder,+ size: props.size,+ variant: props.variant,+ isDisabled: props.isDisabled,+ isReadOnly: props.isReadOnly,+ disabledMessage: props.disabledMessage,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ status: props.status,+ statusVariant: props.statusVariant,+ indicatorPosition: props.indicatorPosition,+ isLoading: props.isLoading,+ menuStyle: props.menuStyle,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift b/packages/native/apple/Sources/AstryxNative/Generated/Switch.swiftindex daad0dfba6..6f1c2c97ad 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift@@ -1,14 +1,14 @@// Generated by @astryxdesign/native. Do not edit.-public enum SwitchSize: String, CaseIterable, Sendable {+public enum SwitchSize: String, CaseIterable, Codable, Sendable {case sm = "sm"case md = "md"}-public enum SwitchStatusType: String, CaseIterable, Sendable {+public enum SwitchStatusType: String, CaseIterable, Codable, Sendable {case warning = "warning"case error = "error"case success = "success"}-public struct SwitchStatus: Equatable, Sendable {+public struct SwitchStatus: Equatable, Codable, Sendable {public var type: SwitchStatusTypepublic var message: String?public init(type: SwitchStatusType, message: String? = nil) {@@ -16,11 +16,11 @@ public struct SwitchStatus: Equatable, Sendable {self.message = message}}-public enum SwitchLabelPosition: String, CaseIterable, Sendable {+public enum SwitchLabelPosition: String, CaseIterable, Codable, Sendable {case start = "start"case end = "end"}-public enum SwitchLabelSpacing: String, CaseIterable, Sendable {+public enum SwitchLabelSpacing: String, CaseIterable, Codable, Sendable {case hug = "hug"case spread = "spread"}@@ -63,6 +63,54 @@ public struct SwitchProps {self.base = base}}+public struct SwitchNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var value: Bool+ public var isLoading: Bool?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isDisabled: Bool?+ public var size: SwitchSize?+ public var disabledMessage: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var status: SwitchStatus?+ public var labelTooltip: String?+ public var labelPosition: SwitchLabelPosition?+ public var labelSpacing: SwitchLabelSpacing?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Switch view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {+ let key = self.key+ return SwitchProps(+ label: props.label,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ isLoading: props.isLoading,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isDisabled: props.isDisabled,+ size: props.size,+ disabledMessage: props.disabledMessage,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ status: props.status,+ labelTooltip: props.labelTooltip,+ labelPosition: props.labelPosition,+ labelSpacing: props.labelSpacing,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct SwitchProps {@@ -103,4 +151,52 @@ public struct SwitchProps {self.base = base}}+public struct SwitchNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var label: String+ public var value: Bool+ public var isLoading: Bool?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isDisabled: Bool?+ public var size: SwitchSize?+ public var disabledMessage: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var status: SwitchStatus?+ public var labelTooltip: String?+ public var labelPosition: SwitchLabelPosition?+ public var labelSpacing: SwitchLabelSpacing?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Switch view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {+ let key = self.key+ return SwitchProps(+ label: props.label,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ isLoading: props.isLoading,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isDisabled: props.isDisabled,+ size: props.size,+ disabledMessage: props.disabledMessage,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ status: props.status,+ labelTooltip: props.labelTooltip,+ labelPosition: props.labelPosition,+ labelSpacing: props.labelSpacing,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/Text.swift b/packages/native/apple/Sources/AstryxNative/Generated/Text.swiftindex 31718aa044..b43c8324b1 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/Text.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/Text.swift@@ -1,5 +1,5 @@// Generated by @astryxdesign/native. Do not edit.-public enum TextType: String, CaseIterable, Sendable {+public enum TextType: String, CaseIterable, Codable, Sendable {case body = "body"case large = "large"case label = "label"@@ -10,7 +10,7 @@ public enum TextType: String, CaseIterable, Sendable {case display3 = "display-3"case inherit = "inherit"}-public enum TextSize: String, CaseIterable, Sendable {+public enum TextSize: String, CaseIterable, Codable, Sendable {case v4xs = "4xs"case v3xs = "3xs"case v2xs = "2xs"@@ -23,7 +23,7 @@ public enum TextSize: String, CaseIterable, Sendable {case v3xl = "3xl"case v4xl = "4xl"}-public enum TextColor: String, CaseIterable, Sendable {+public enum TextColor: String, CaseIterable, Codable, Sendable {case primary = "primary"case secondary = "secondary"case disabled = "disabled"@@ -31,13 +31,13 @@ public enum TextColor: String, CaseIterable, Sendable {case accent = "accent"case inherit = "inherit"}-public enum TextWeight: String, CaseIterable, Sendable {+public enum TextWeight: String, CaseIterable, Codable, Sendable {case normal = "normal"case medium = "medium"case semibold = "semibold"case bold = "bold"}-public enum TextJustify: String, CaseIterable, Sendable {+public enum TextJustify: String, CaseIterable, Codable, Sendable {case start = "start"case center = "center"case end = "end"@@ -69,6 +69,42 @@ public struct TextProps {self.base = base}}+public struct TextNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var type: TextType?+ public var children: String+ public var size: TextSize?+ public var color: TextColor?+ public var weight: TextWeight?+ public var maxLines: Double?+ public var justify: TextJustify?+ public var hasStrikethrough: Bool?+ public var hasTabularNumbers: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Text view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextProps {+ return TextProps(+ type: props.type,+ children: props.children,+ size: props.size,+ color: props.color,+ weight: props.weight,+ maxLines: props.maxLines,+ justify: props.justify,+ hasStrikethrough: props.hasStrikethrough,+ hasTabularNumbers: props.hasTabularNumbers,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct TextProps {@@ -97,4 +133,40 @@ public struct TextProps {self.base = base}}+public struct TextNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var type: TextType?+ public var children: String+ public var size: TextSize?+ public var color: TextColor?+ public var weight: TextWeight?+ public var maxLines: Double?+ public var justify: TextJustify?+ public var hasStrikethrough: Bool?+ public var hasTabularNumbers: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a Text view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextProps {+ return TextProps(+ type: props.type,+ children: props.children,+ size: props.size,+ color: props.color,+ weight: props.weight,+ maxLines: props.maxLines,+ justify: props.justify,+ hasStrikethrough: props.hasStrikethrough,+ hasTabularNumbers: props.hasTabularNumbers,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift b/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swiftindex 46ea5dd044..6bd76e6127 100644--- a/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift+++ b/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift@@ -1,20 +1,20 @@// Generated by @astryxdesign/native. Do not edit.-public enum TextInputType: String, CaseIterable, Sendable {+public enum TextInputType: String, CaseIterable, Codable, Sendable {case text = "text"case password = "password"case email = "email"}-public enum TextInputSize: String, CaseIterable, Sendable {+public enum TextInputSize: String, CaseIterable, Codable, Sendable {case sm = "sm"case md = "md"case lg = "lg"}-public enum TextInputStatusType: String, CaseIterable, Sendable {+public enum TextInputStatusType: String, CaseIterable, Codable, Sendable {case error = "error"case warning = "warning"case success = "success"}-public struct TextInputStatus: Equatable, Sendable {+public struct TextInputStatus: Equatable, Codable, Sendable {public var type: TextInputStatusTypepublic var message: String?public init(type: TextInputStatusType, message: String? = nil) {@@ -22,7 +22,7 @@ public struct TextInputStatus: Equatable, Sendable {self.message = message}}-public enum TextInputStatusVariant: String, CaseIterable, Sendable {+public enum TextInputStatusVariant: String, CaseIterable, Codable, Sendable {case attached = "attached"case detached = "detached"case tooltip = "tooltip"@@ -76,6 +76,63 @@ public struct TextInputProps {self.base = base}}+public struct TextInputNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var type: TextInputType?+ public var label: String+ public var value: String+ public var size: TextInputSize?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var isDisabled: Bool?+ public var isReadOnly: Bool?+ public var disabledMessage: String?+ public var isLoading: Bool?+ public var placeholder: String?+ public var labelTooltip: String?+ public var status: TextInputStatus?+ public var statusVariant: TextInputStatusVariant?+ public var hasClear: Bool?+ public var hasAutoFocus: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a TextInput view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {+ let key = self.key+ return TextInputProps(+ type: props.type,+ label: props.label,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ size: props.size,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,+ isDisabled: props.isDisabled,+ isReadOnly: props.isReadOnly,+ disabledMessage: props.disabledMessage,+ isLoading: props.isLoading,+ placeholder: props.placeholder,+ labelTooltip: props.labelTooltip,+ status: props.status,+ statusVariant: props.statusVariant,+ hasClear: props.hasClear,+ hasAutoFocus: props.hasAutoFocus,+ base: base ?? AstryxBaseProps()+ )+ }+}#endif#if os(macOS)public struct TextInputProps {@@ -126,4 +183,61 @@ public struct TextInputProps {self.base = base}}+public struct TextInputNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var type: TextInputType?+ public var label: String+ public var value: String+ public var size: TextInputSize?+ public var isLabelHidden: Bool?+ public var description: String?+ public var isOptional: Bool?+ public var isRequired: Bool?+ public var isDisabled: Bool?+ public var isReadOnly: Bool?+ public var disabledMessage: String?+ public var isLoading: Bool?+ public var placeholder: String?+ public var labelTooltip: String?+ public var status: TextInputStatus?+ public var statusVariant: TextInputStatusVariant?+ public var hasClear: Bool?+ public var hasAutoFocus: Bool?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a TextInput view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {+ let key = self.key+ return TextInputProps(+ type: props.type,+ label: props.label,+ value: props.value,+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,+ size: props.size,+ isLabelHidden: props.isLabelHidden,+ description: props.description,+ isOptional: props.isOptional,+ isRequired: props.isRequired,+ onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,+ isDisabled: props.isDisabled,+ isReadOnly: props.isReadOnly,+ disabledMessage: props.disabledMessage,+ isLoading: props.isLoading,+ placeholder: props.placeholder,+ labelTooltip: props.labelTooltip,+ status: props.status,+ statusVariant: props.statusVariant,+ hasClear: props.hasClear,+ hasAutoFocus: props.hasAutoFocus,+ base: base ?? AstryxBaseProps()+ )+ }+}#endifdiff --git a/packages/native/apple/Sources/AstryxNative/Generated/VStack.swift b/packages/native/apple/Sources/AstryxNative/Generated/VStack.swiftnew file mode 100644index 0000000000..7e111ddc63--- /dev/null+++ b/packages/native/apple/Sources/AstryxNative/Generated/VStack.swift@@ -0,0 +1,308 @@+// Generated by @astryxdesign/native. Do not edit.+public enum VStackGap: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPadding: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingInline: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingInlineStart: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingInlineEnd: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingBlock: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingBlockStart: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackPaddingBlockEnd: Double, CaseIterable, Codable, Sendable {+ case v0 = 0+ case v0_5 = 0.5+ case v1 = 1+ case v1_5 = 1.5+ case v2 = 2+ case v3 = 3+ case v4 = 4+ case v5 = 5+ case v6 = 6+ case v8 = 8+ case v10 = 10+}+public enum VStackHAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case stretch = "stretch"+}+public enum VStackVAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case between = "between"+ case around = "around"+ case evenly = "evenly"+}+public enum VStackJustify: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case between = "between"+ case around = "around"+ case evenly = "evenly"+}+public enum VStackAlign: String, CaseIterable, Codable, Sendable {+ case start = "start"+ case center = "center"+ case end = "end"+ case stretch = "stretch"+}+public enum VStackWrap: String, CaseIterable, Codable, Sendable {+ case nowrap = "nowrap"+ case wrap = "wrap"+ case wrapReverse = "wrap-reverse"+}+#if os(iOS)+public struct VStackProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var gap: VStackGap?+ public var padding: VStackPadding?+ public var paddingInline: VStackPaddingInline?+ public var paddingInlineStart: VStackPaddingInlineStart?+ public var paddingInlineEnd: VStackPaddingInlineEnd?+ public var paddingBlock: VStackPaddingBlock?+ public var paddingBlockStart: VStackPaddingBlockStart?+ public var paddingBlockEnd: VStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: VStackHAlign?+ public var vAlign: VStackVAlign?+ public var justify: VStackJustify?+ public var align: VStackAlign?+ public var wrap: VStackWrap?+ public init(gap: VStackGap? = nil, padding: VStackPadding? = nil, paddingInline: VStackPaddingInline? = nil, paddingInlineStart: VStackPaddingInlineStart? = nil, paddingInlineEnd: VStackPaddingInlineEnd? = nil, paddingBlock: VStackPaddingBlock? = nil, paddingBlockStart: VStackPaddingBlockStart? = nil, paddingBlockEnd: VStackPaddingBlockEnd? = nil, isScrollable: Bool? = nil, hAlign: VStackHAlign? = nil, vAlign: VStackVAlign? = nil, justify: VStackJustify? = nil, align: VStackAlign? = nil, wrap: VStackWrap? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.gap = gap+ self.padding = padding+ self.paddingInline = paddingInline+ self.paddingInlineStart = paddingInlineStart+ self.paddingInlineEnd = paddingInlineEnd+ self.paddingBlock = paddingBlock+ self.paddingBlockStart = paddingBlockStart+ self.paddingBlockEnd = paddingBlockEnd+ self.isScrollable = isScrollable+ self.hAlign = hAlign+ self.vAlign = vAlign+ self.justify = justify+ self.align = align+ self.wrap = wrap+ self.base = base+ }+}+public struct VStackNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var gap: VStackGap?+ public var padding: VStackPadding?+ public var paddingInline: VStackPaddingInline?+ public var paddingInlineStart: VStackPaddingInlineStart?+ public var paddingInlineEnd: VStackPaddingInlineEnd?+ public var paddingBlock: VStackPaddingBlock?+ public var paddingBlockStart: VStackPaddingBlockStart?+ public var paddingBlockEnd: VStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: VStackHAlign?+ public var vAlign: VStackVAlign?+ public var justify: VStackJustify?+ public var align: VStackAlign?+ public var wrap: VStackWrap?+ public var children: [AstryxNode]?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a VStack view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> VStackProps {+ return VStackProps(+ gap: props.gap,+ padding: props.padding,+ paddingInline: props.paddingInline,+ paddingInlineStart: props.paddingInlineStart,+ paddingInlineEnd: props.paddingInlineEnd,+ paddingBlock: props.paddingBlock,+ paddingBlockStart: props.paddingBlockStart,+ paddingBlockEnd: props.paddingBlockEnd,+ isScrollable: props.isScrollable,+ hAlign: props.hAlign,+ vAlign: props.vAlign,+ justify: props.justify,+ align: props.align,+ wrap: props.wrap,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endif+#if os(macOS)+public struct VStackProps {+ /// Base props attach to this part on every platform.+ public static let baseTarget: AstryxBaseTarget = .container+ public var base: AstryxBaseProps+ public var gap: VStackGap?+ public var padding: VStackPadding?+ public var paddingInline: VStackPaddingInline?+ public var paddingInlineStart: VStackPaddingInlineStart?+ public var paddingInlineEnd: VStackPaddingInlineEnd?+ public var paddingBlock: VStackPaddingBlock?+ public var paddingBlockStart: VStackPaddingBlockStart?+ public var paddingBlockEnd: VStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: VStackHAlign?+ public var vAlign: VStackVAlign?+ public var justify: VStackJustify?+ public var align: VStackAlign?+ public var wrap: VStackWrap?+ public init(gap: VStackGap? = nil, padding: VStackPadding? = nil, paddingInline: VStackPaddingInline? = nil, paddingInlineStart: VStackPaddingInlineStart? = nil, paddingInlineEnd: VStackPaddingInlineEnd? = nil, paddingBlock: VStackPaddingBlock? = nil, paddingBlockStart: VStackPaddingBlockStart? = nil, paddingBlockEnd: VStackPaddingBlockEnd? = nil, isScrollable: Bool? = nil, hAlign: VStackHAlign? = nil, vAlign: VStackVAlign? = nil, justify: VStackJustify? = nil, align: VStackAlign? = nil, wrap: VStackWrap? = nil, base: AstryxBaseProps = AstryxBaseProps()) {+ self.gap = gap+ self.padding = padding+ self.paddingInline = paddingInline+ self.paddingInlineStart = paddingInlineStart+ self.paddingInlineEnd = paddingInlineEnd+ self.paddingBlock = paddingBlock+ self.paddingBlockStart = paddingBlockStart+ self.paddingBlockEnd = paddingBlockEnd+ self.isScrollable = isScrollable+ self.hAlign = hAlign+ self.vAlign = vAlign+ self.justify = justify+ self.align = align+ self.wrap = wrap+ self.base = base+ }+}+public struct VStackNode: Decodable, Equatable, Sendable {+ public struct Props: Decodable, Equatable, Sendable {+ public var gap: VStackGap?+ public var padding: VStackPadding?+ public var paddingInline: VStackPaddingInline?+ public var paddingInlineStart: VStackPaddingInlineStart?+ public var paddingInlineEnd: VStackPaddingInlineEnd?+ public var paddingBlock: VStackPaddingBlock?+ public var paddingBlockStart: VStackPaddingBlockStart?+ public var paddingBlockEnd: VStackPaddingBlockEnd?+ public var isScrollable: Bool?+ public var hAlign: VStackHAlign?+ public var vAlign: VStackVAlign?+ public var justify: VStackJustify?+ public var align: VStackAlign?+ public var wrap: VStackWrap?+ public var children: [AstryxNode]?+ }+ public let key: String+ public let base: AstryxBaseProps?+ public let props: Props+ /// The callbacks the core listens to, by prop name.+ public let events: [String]?++ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }++ /// The contract a VStack view takes; its callbacks send actions to the core.+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> VStackProps {+ return VStackProps(+ gap: props.gap,+ padding: props.padding,+ paddingInline: props.paddingInline,+ paddingInlineStart: props.paddingInlineStart,+ paddingInlineEnd: props.paddingInlineEnd,+ paddingBlock: props.paddingBlock,+ paddingBlockStart: props.paddingBlockStart,+ paddingBlockEnd: props.paddingBlockEnd,+ isScrollable: props.isScrollable,+ hAlign: props.hAlign,+ vAlign: props.vAlign,+ justify: props.justify,+ align: props.align,+ wrap: props.wrap,+ base: base ?? AstryxBaseProps()+ )+ }+}+#endifdiff --git a/packages/native/apple/Tests/AstryxNativeTests/WireTests.swift b/packages/native/apple/Tests/AstryxNativeTests/WireTests.swiftnew file mode 100644index 0000000000..c8c50d9c42--- /dev/null+++ b/packages/native/apple/Tests/AstryxNativeTests/WireTests.swift@@ -0,0 +1,53 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import Foundation+import Testing+@testable import AstryxNative++private let tree = """+{"component": "VStack", "key": "root", "props": {"gap": 2, "children": [+ {"component": "Heading", "key": "title", "props": {"level": 2, "children": "Settings"}},+ {"component": "Switch", "key": "wifi", "props": {"label": "Wi-Fi", "value": true}, "events": ["onChange"]},+ {"component": "Button", "key": "save", "base": {"id": "save"}, "props": {"label": "Save", "variant": "primary"}},+ {"component": "Chart", "key": "later", "props": {}},+ {"component": "Button", "key": "newer", "props": {"label": "Go", "variant": "glass"}}+]}}+"""++private final class Sent: @unchecked Sendable {+ var actions: [AstryxAction] = []+}++@Test func decodesATreeByComponentName() throws {+ let node = try JSONDecoder().decode(AstryxNode.self, from: Data(tree.utf8))+ guard case .vStack(let stack) = node else { Issue.record("not a VStack"); return }+ #expect(stack.props.gap == .v2)+ let children = stack.props.children ?? []+ #expect(children.map(\.key) == ["title", "wifi", "save", "later", "newer"])+ guard case .heading(let heading) = children[0] else { Issue.record("not a Heading"); return }+ #expect(heading.props.level == .v2)+ #expect(heading.props.children == "Settings")+ #expect(children[3] == .unsupported(component: "Chart", key: "later"))+ // A value this binding's enum lacks makes only that node unsupported.+ #expect(children[4] == .unsupported(component: "Button", key: "newer"))+}++@Test func callbacksTheCoreListensToSendActions() throws {+ let node = try JSONDecoder().decode(AstryxNode.self, from: Data(tree.utf8))+ guard case .vStack(let stack) = node,+ case .switch(let wifi) = stack.props.children?[1],+ case .button(let save) = stack.props.children?[2] else {+ Issue.record("unexpected tree")+ return+ }+ let sent = Sent()+ let switchProps = wifi.viewProps { sent.actions.append($0) }+ switchProps.onChange?(false)+ #expect(sent.actions == [AstryxAction(key: "wifi", component: "Switch", event: "onChange", args: [.bool(false)])])+ #expect(sent.actions[0].json == #"{"args":[false],"component":"Switch","event":"onChange","key":"wifi"}"#)++ // The core did not listen to the button's press, so the view gets no callback.+ let buttonProps = save.viewProps { sent.actions.append($0) }+ #expect(buttonProps.onClick == nil)+ #expect(buttonProps.base.id == "save")+}diff --git a/packages/native/src/components/Card.ts b/packages/native/src/components/Card.tsnew file mode 100644index 0000000000..84ab1d2680--- /dev/null+++ b/packages/native/src/components/Card.ts@@ -0,0 +1,18 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file components/Card.ts+ * @input None+ * @output What @astryxdesign/native adds to the core Card contract+ * @position Native additions read by fromComponentDoc together with core's+ * Card documentation+ */++import type {NativeAdditions} from '../contract/fromComponentDoc.js';++export const card: NativeAdditions = {+ name: 'Card',+ baseTarget: 'container',+ slots: {children: 'content'},+ sameMeaning: {children: "the component's content, as on the web"},+};diff --git a/packages/native/src/components/HStack.ts b/packages/native/src/components/HStack.tsnew file mode 100644index 0000000000..bd4bdfdba9--- /dev/null+++ b/packages/native/src/components/HStack.ts@@ -0,0 +1,20 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file components/HStack.ts+ * @input None+ * @output What @astryxdesign/native adds to the core HStack contract+ * @position Native additions read by fromComponentDoc together with core's+ * Stack documentation, which documents HStack+ */++import type {NativeAdditions} from '../contract/fromComponentDoc.js';+import {STACK_SLOTS} from './stackShared.js';++export const hStack: NativeAdditions = {+ name: 'HStack',+ baseTarget: 'container',+ doc: {file: 'Stack', component: 'HStack'},+ slots: STACK_SLOTS,+ sameMeaning: {children: "the component's content, as on the web"},+};diff --git a/packages/native/src/components/VStack.ts b/packages/native/src/components/VStack.tsnew file mode 100644index 0000000000..0ad035781c--- /dev/null+++ b/packages/native/src/components/VStack.ts@@ -0,0 +1,20 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file components/VStack.ts+ * @input None+ * @output What @astryxdesign/native adds to the core VStack contract+ * @position Native additions read by fromComponentDoc together with core's+ * Stack documentation, which documents VStack+ */++import type {NativeAdditions} from '../contract/fromComponentDoc.js';+import {STACK_SLOTS} from './stackShared.js';++export const vStack: NativeAdditions = {+ name: 'VStack',+ baseTarget: 'container',+ doc: {file: 'Stack', component: 'VStack'},+ slots: STACK_SLOTS,+ sameMeaning: {children: "the component's content, as on the web"},+};diff --git a/packages/native/src/components/index.ts b/packages/native/src/components/index.tsindex afa8dc4e9f..c693941bd1 100644--- a/packages/native/src/components/index.ts+++ b/packages/native/src/components/index.ts@@ -10,21 +10,27 @@import type {NativeAdditions} from '../contract/fromComponentDoc.js';import {button} from './Button.js';+import {card} from './Card.js';import {divider} from './Divider.js';import {heading} from './Heading.js';+import {hStack} from './HStack.js';import {progressBar} from './ProgressBar.js';import {selector} from './Selector.js';import {switchControl} from './Switch.js';import {text} from './Text.js';import {textInput} from './TextInput.js';+import {vStack} from './VStack.js';export const NATIVE_COMPONENTS: readonly NativeAdditions[] = [button,+ card,divider,heading,+ hStack,progressBar,selector,switchControl,text,textInput,+ vStack,];diff --git a/packages/native/src/components/stackShared.ts b/packages/native/src/components/stackShared.tsnew file mode 100644index 0000000000..05735a32e1--- /dev/null+++ b/packages/native/src/components/stackShared.ts@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file components/stackShared.ts+ * @input None+ * @output The slot declarations HStack and VStack share+ * @position Read by components/HStack.ts and components/VStack.ts+ */++import type {SlotKind} from '../contract/fromComponentDoc.js';++export const STACK_SLOTS: Readonly<Record<string, SlotKind>> = {+ children: 'content',+};diff --git a/packages/native/src/contract/contracts.test.ts b/packages/native/src/contract/contracts.test.tsindex ead3d24c2a..3701994072 100644--- a/packages/native/src/contract/contracts.test.ts+++ b/packages/native/src/contract/contracts.test.ts@@ -173,5 +173,29 @@ describe('native contracts', () => {expect(errorsFor(null, usage('pullDown')).join('\n')).toContain('menuStyle',);++ const wire = (node: string, action: string) =>+ "import type {AstryxAction, AstryxNode} from '@astryxdesign/native/components';\n" ++ `export const node: AstryxNode = ${node};\n` ++ `export const action: AstryxAction = ${action};\n`;+ const tree =+ "{component: 'VStack', key: 'root', props: {gap: 2, children: [" ++ "{component: 'Switch', key: 'wifi', props: {label: 'Wi-Fi', value: true}, events: ['onChange']}," ++ "{component: 'Selector', key: 'ship', props: {label: 'Shipping', options: [], menuStyle: 'pullDown'}}]}}";+ const toggled =+ "{key: 'wifi', component: 'Switch', event: 'onChange', args: [false]}";+ expect(errorsFor('ios', wire(tree, toggled))).toEqual([]);+ expect(errorsFor('android', wire(tree, toggled)).join('\n')).toContain(+ 'pullDown',+ );+ expect(+ errorsFor(+ 'ios',+ wire(+ tree,+ "{key: 'wifi', component: 'Switch', event: 'onChange', args: ['off']}",+ ),+ ).length,+ ).toBeGreaterThan(0);});});diff --git a/packages/native/src/contract/fromComponentDoc.test.ts b/packages/native/src/contract/fromComponentDoc.test.tsindex 0b7c3c74eb..c4f02e7f35 100644--- a/packages/native/src/contract/fromComponentDoc.test.ts+++ b/packages/native/src/contract/fromComponentDoc.test.ts@@ -67,7 +67,7 @@ describe('fromComponentDoc', () => {it('writes a closed set of numbers as a Swift enum with raw values', () => {const swift = generateSwift([contract])['Toggle.swift'];expect(swift).toContain(- 'public enum ToggleLevel: Int, CaseIterable, Sendable {',+ 'public enum ToggleLevel: Int, CaseIterable, Codable, Sendable {',);expect(swift).toContain(' case v1 = 1');});diff --git a/packages/native/src/contract/fromComponentDoc.ts b/packages/native/src/contract/fromComponentDoc.tsindex 98f7e6904b..9f5c776170 100644--- a/packages/native/src/contract/fromComponentDoc.ts+++ b/packages/native/src/contract/fromComponentDoc.ts@@ -45,9 +45,10 @@ export interface ComponentDocLike {/*** Typed slots (AST-082 FR4) for documented free-form content. `text` is a- * string in the core contract, as a badge's label or a heading's words.+ * string in the core contract, as a badge's label or a heading's words;+ * `content` is child Astryx components, as a stack's or a card's children.*/-export type SlotKind = 'text';+export type SlotKind = 'text' | 'content';/** What the native package adds to one core component. */export interface NativeAdditions {@@ -108,6 +109,7 @@ function documentedProps(const SLOT_TYPES: Readonly<Record<SlotKind, PropType>> = {text: {kind: 'string'},+ content: {kind: 'content'},};export function fromComponentDoc(diff --git a/packages/native/src/contract/generateSwift.ts b/packages/native/src/contract/generateSwift.tsindex 90a385f80a..f94df6eb0d 100644--- a/packages/native/src/contract/generateSwift.ts+++ b/packages/native/src/contract/generateSwift.ts@@ -3,9 +3,13 @@/*** @file contract/generateSwift.ts* @input Component contracts- * @output Swift sources for the Apple platforms: shared base props and one file- * per component, with the iOS and macOS contracts behind `#if os(...)`- * @position Produces the Swift binding (AST-082 FR5). Generated files are+ * @output Swift sources for the Apple platforms: shared base props, the wire+ * (AstryxNode, AstryxAction), and one file per component with the iOS and+ * macOS contracts behind `#if os(...)`+ * @position Produces the Swift binding (AST-082 FR5). Each component gets+ * `<Name>Props`, the contract a SwiftUI view takes, and `<Name>Node`, the+ * same contract as JSON a TypeScript core sends (arm C), which turns into+ * props whose callbacks send `AstryxAction`s back. Generated files are* committed under apple/ so a Swift package can pin a commit*/@@ -18,6 +22,8 @@ const APPLE_PLATFORMS = [{platform: 'macos', condition: 'os(macOS)'},] as const;+const RECORD_CONFORMANCES = 'Equatable, Codable, Sendable';+const camel = (text: string) =>text.replace(/[-_ ]+([a-zA-Z0-9])/g, (_, ch: string) => ch.toUpperCase());const pascal = (text: string) =>@@ -53,7 +59,7 @@ class SwiftWriter {value => ` case ${caseName(value)} = "${value}"`,);this.decls.push(- `public enum ${name}: String, CaseIterable, Sendable {\n${cases.join('\n')}\n}`,+ `public enum ${name}: String, CaseIterable, Codable, Sendable {\n${cases.join('\n')}\n}`,);return name;}@@ -64,7 +70,7 @@ class SwiftWriter {value => ` case ${numberCaseName(value)} = ${value}`,);this.decls.push(- `public enum ${name}: ${raw}, CaseIterable, Sendable {\n${cases.join('\n')}\n}`,+ `public enum ${name}: ${raw}, CaseIterable, Codable, Sendable {\n${cases.join('\n')}\n}`,);return name;}@@ -72,11 +78,13 @@ class SwiftWriter {return `[${this.type(owner, prop, type.of)}]`;case 'record': {const name = `${owner}${pascal(prop)}`;- this.decls.push(this.struct(name, type.fields, 'Equatable, Sendable'));+ this.decls.push(this.struct(name, type.fields, RECORD_CONFORMANCES));return name;}case 'fn':return `(${type.args.map((arg, i) => this.type(owner, `${prop}Arg${i}`, arg)).join(', ')}) -> Void`;+ case 'content':+ return '[AstryxNode]';case 'named':return type.name;}@@ -121,10 +129,71 @@ class SwiftWriter {}}+/** Props without content slots: a SwiftUI view takes content as a builder. */+function withoutContent(props: PropMap): PropMap {+ return Object.fromEntries(+ Object.entries(props).filter(([, spec]) => spec.type.kind !== 'content'),+ );+}++function withoutCallbacks(props: PropMap): PropMap {+ return Object.fromEntries(+ Object.entries(props).filter(([, spec]) => spec.type.kind !== 'fn'),+ );+}++/** `<Name>Node`: the component as JSON from a TypeScript core (arm C). */+function nodeStruct(+ writer: SwiftWriter,+ contract: ComponentContract,+ props: PropMap,+): string {+ const name = contract.name;+ const data = writer.fields(name, withoutCallbacks(props));+ const callbacks = Object.entries(props).filter(+ ([, spec]) => spec.type.kind === 'fn',+ );+ // Each callback the core listens to (`events`) sends an action with the+ // callback's arguments; one it does not listen to stays nil.+ const binding = Object.entries(withoutContent(props)).map(([prop, spec]) => {+ if (spec.type.kind !== 'fn') {+ return ` ${prop}: props.${ident(prop)}`;+ }+ const params = spec.type.args.map((_, i) => `arg${i}`);+ const values = params.map(param => `AstryxValue(${param})`).join(', ');+ const closure = `{ ${params.length > 0 ? `${params.join(', ')} in ` : ''}send(AstryxAction(key: key, component: "${name}", event: "${prop}", args: [${values}])) }`;+ return spec.optional+ ? ` ${prop}: listens("${prop}") ? ${closure} : nil`+ : ` ${prop}: ${closure}`;+ });+ return [+ `public struct ${name}Node: Decodable, Equatable, Sendable {`,+ ` public struct Props: Decodable, Equatable, Sendable {`,+ ...data.map(field => ` ${field.decl}`),+ ' }',+ ' public let key: String',+ ' public let base: AstryxBaseProps?',+ ' public let props: Props',+ ` /// The callbacks the core listens to, by prop name.`,+ ' public let events: [String]?',+ '',+ ` public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }`,+ '',+ ` /// The contract a ${name} view takes; its callbacks send actions to the core.`,+ ` public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ${name}Props {`,+ ...(callbacks.length > 0 ? [' let key = self.key'] : []),+ ` return ${name}Props(`,+ [...binding, ' base: base ?? AstryxBaseProps()'].join(',\n'),+ ' )',+ ' }',+ '}',+ ].join('\n');+}+function componentFile(contract: ComponentContract): string {const shared = new SwiftWriter();const typeDecls = Object.entries(contract.types).map(([name, fields]) =>- shared.struct(name, fields, 'Equatable, Sendable'),+ shared.struct(name, fields, RECORD_CONFORMANCES),);// Core enums and records are declared once, outside the platform blocks.shared.fields(`${contract.name}`, contract.core);@@ -132,7 +201,9 @@ function componentFile(contract: ComponentContract): string {const variants = APPLE_PLATFORMS.map(({platform, condition}) => {const writer = new SwiftWriter();const extra = contract.platforms[platform] ?? {};- const fields = writer.fields(contract.name, {...contract.core, ...extra});+ const all = {...contract.core, ...extra};+ const fields = writer.fields(contract.name, withoutContent(all));+ const node = nodeStruct(writer, contract, all);// Core-prop declarations already live outside the platform blocks; keep// only the declarations this platform's own props need.writer.decls.length = 0;@@ -149,7 +220,7 @@ function componentFile(contract: ComponentContract): string {' }','}',].join('\n');- return `#if ${condition}\n${[...writer.decls, struct].join('\n')}\n#endif`;+ return `#if ${condition}\n${[...writer.decls, struct, node].join('\n')}\n#endif`;});return (@@ -157,13 +228,135 @@ function componentFile(contract: ComponentContract): string {);}+/** `AstryxNode`: one case per component, decoded by its `component` name. */+function nodeFile(contracts: readonly ComponentContract[]): string {+ const caseOf = (name: string) =>+ camel(name.replace(/^./, ch => ch.toLowerCase()));+ return (+ HEADER ++ [+ 'import Foundation',+ '',+ '#if os(iOS) || os(macOS)',+ '/// One Astryx component in a tree a TypeScript core sends, by its `component` name.',+ '/// A node this binding cannot read decodes as `unsupported`: an unknown component,',+ '/// or a known one with a value its enums lack or a required prop missing. An older',+ "/// app then keeps drawing the rest of a newer core's tree.",+ 'public enum AstryxNode: Decodable, Equatable, Sendable {',+ ...contracts.map(c => ` case ${ident(caseOf(c.name))}(${c.name}Node)`),+ ' case unsupported(component: String, key: String)',+ '',+ ' public var key: String {',+ ' switch self {',+ ...contracts.map(+ c => ` case .${ident(caseOf(c.name))}(let node): return node.key`,+ ),+ ' case .unsupported(_, let key): return key',+ ' }',+ ' }',+ '',+ ' private enum Keys: String, CodingKey { case component, key }',+ '',+ ' public init(from decoder: any Decoder) throws {',+ ' let container = try decoder.container(keyedBy: Keys.self)',+ ' let component = try container.decode(String.self, forKey: .component)',+ ' let key = try container.decode(String.self, forKey: .key)',+ ' do {',+ ' switch component {',+ ...contracts.map(+ c =>+ ` case "${c.name}": self = .${ident(caseOf(c.name))}(try ${c.name}Node(from: decoder))`,+ ),+ ' default: self = .unsupported(component: component, key: key)',+ ' }',+ ' } catch {',+ ' self = .unsupported(component: component, key: key)',+ ' }',+ ' }',+ '}',+ '#endif',+ ].join('\n') ++ '\n'+ );+}++const WIRE_FILE =+ HEADER ++ `import Foundation++/// A JSON value: a portable callback argument on its way to the core.+public enum AstryxValue: Codable, Equatable, Sendable {+ case null+ case bool(Bool)+ case number(Double)+ case string(String)+ case array([AstryxValue])+ case object([String: AstryxValue])++ /// Any portable value (a contract's strings, numbers, enums, and records) as JSON.+ public init<T: Encodable>(_ value: T) {+ guard let data = try? JSONEncoder().encode(value),+ let decoded = try? JSONDecoder().decode(AstryxValue.self, from: data) else {+ self = .null+ return+ }+ self = decoded+ }++ public init(from decoder: any Decoder) throws {+ let container = try decoder.singleValueContainer()+ if container.decodeNil() { self = .null }+ else if let value = try? container.decode(Bool.self) { self = .bool(value) }+ else if let value = try? container.decode(Double.self) { self = .number(value) }+ else if let value = try? container.decode(String.self) { self = .string(value) }+ else if let value = try? container.decode([AstryxValue].self) { self = .array(value) }+ else { self = .object(try container.decode([String: AstryxValue].self)) }+ }++ public func encode(to encoder: any Encoder) throws {+ var container = encoder.singleValueContainer()+ switch self {+ case .null: try container.encodeNil()+ case .bool(let value): try container.encode(value)+ case .number(let value): try container.encode(value)+ case .string(let value): try container.encode(value)+ case .array(let value): try container.encode(value)+ case .object(let value): try container.encode(value)+ }+ }+}++/// A callback a view called: which node, which prop, and its arguments.+public struct AstryxAction: Codable, Equatable, Sendable {+ public let key: String+ public let component: String+ public let event: String+ public let args: [AstryxValue]++ public init(key: String, component: String, event: String, args: [AstryxValue]) {+ self.key = key+ self.component = component+ self.event = event+ self.args = args+ }++ /// The JSON the core receives.+ public var json: String {+ let encoder = JSONEncoder()+ encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]+ guard let data = try? encoder.encode(self) else { return "{}" }+ return String(decoding: data, as: UTF8.self)+ }+}+`;+const BASE_FILE =HEADER +['public enum AstryxBaseTarget: String, Sendable { case root, trigger, control, container }','','/// Base props shared by every platform (AST-082 FR7).',- 'public struct AstryxBaseProps: Equatable, Sendable {',+ 'public struct AstryxBaseProps: Equatable, Codable, Sendable {',' public var id: String?',' public var isHidden: Bool?',' public init(id: String? = nil, isHidden: Bool? = nil) {',@@ -178,7 +371,11 @@ const BASE_FILE =export function generateSwift(contracts: readonly ComponentContract[],): Record<string, string> {- const files: Record<string, string> = {'AstryxBase.swift': BASE_FILE};+ const files: Record<string, string> = {+ 'AstryxBase.swift': BASE_FILE,+ 'AstryxNode.swift': nodeFile(contracts),+ 'AstryxWire.swift': WIRE_FILE,+ };for (const contract of contracts) {files[`${contract.name}.swift`] = componentFile(contract);}diff --git a/packages/native/src/contract/generateTypeScript.ts b/packages/native/src/contract/generateTypeScript.tsindex 8cacae379f..3cce8e47f3 100644--- a/packages/native/src/contract/generateTypeScript.ts+++ b/packages/native/src/contract/generateTypeScript.ts@@ -9,11 +9,15 @@*/import {NATIVE_PLATFORMS, type NativePlatform} from '../platforms.js';-import type {ComponentContract, PropMap, PropType} from './types.js';+import type {ComponentContract, PropMap, PropSpec, PropType} from './types.js';const HEADER = '// Generated by @astryxdesign/native. Do not edit.\n';-function tsType(type: PropType): string {+/**+ * `content` names the type of one child component: the open+ * `AstryxContentNode` in core contracts, a platform's `AstryxNode` in its wire.+ */+function tsType(type: PropType, content = 'AstryxContentNode'): string {switch (type.kind) {case 'string':case 'number':@@ -24,13 +28,15 @@ function tsType(type: PropType): string {case 'numberEnum':return type.values.join(' | ');case 'array': {- const inner = tsType(type.of);+ const inner = tsType(type.of, content);return `ReadonlyArray<${inner}>`;}case 'record':- return `{${members(type.fields, ' ')}}`;+ return `{${members(type.fields, ' ', content)}}`;case 'fn':- return `(${type.args.map((arg, i) => `arg${i}: ${tsType(arg)}`).join(', ')}) => void`;+ return `(${type.args.map((arg, i) => `arg${i}: ${tsType(arg, content)}`).join(', ')}) => void`;+ case 'content':+ return `ReadonlyArray<${content}>`;case 'named':return type.name;}@@ -40,11 +46,15 @@ function key(name: string): string {return /^[A-Za-z_$][\w$]*$/.test(name) ? name : `'${name}'`;}-function members(props: PropMap, separator = '\n '): string {+function members(+ props: PropMap,+ separator = '\n ',+ content = 'AstryxContentNode',+): string {return Object.entries(props).map(([name, spec]) =>- `${key(name)}${spec.optional ? '?' : ''}: ${tsType(spec.type)};`,+ `${key(name)}${spec.optional ? '?' : ''}: ${tsType(spec.type, content)};`,).join(separator);}@@ -68,13 +78,15 @@ function coreFile(contracts: readonly ComponentContract[]): string {HEADER +'/** Base props shared by every platform (AST-082 FR7). */\n' +'export interface AstryxSharedBaseProps {\n id?: string;\n isHidden?: boolean;\n}\n' ++ '/** One child Astryx component in a content slot (AST-082 FR4). */\n' ++ 'export interface AstryxContentNode {\n readonly component: string;\n readonly key: string;\n}\n' +[...typeDecls, ...props].join('\n') +'\n');}function reExports(contracts: readonly ComponentContract[]): string {- const names = new Set<string>(['AstryxSharedBaseProps']);+ const names = new Set<string>(['AstryxSharedBaseProps', 'AstryxContentNode']);for (const contract of contracts) {Object.keys(contract.types).forEach(name => names.add(name));names.add(`${contract.name}CoreProps`);@@ -82,11 +94,62 @@ function reExports(contracts: readonly ComponentContract[]): string {return `export type {${[...names].join(', ')}} from './core.js';\n`;}+/**+ * The wire a TypeScript core sends a native host (arm C): each component as+ * JSON with its data props, the callbacks it listens to, and the actions a+ * host sends back when a view calls one.+ */+function wire(+ contracts: readonly ComponentContract[],+ platform: NativePlatform | null,+): string {+ const nodes: string[] = [];+ const actions: string[] = [];+ for (const contract of contracts) {+ const props = {+ ...contract.core,+ ...(platform ? (contract.platforms[platform] ?? {}) : {}),+ };+ const data: Record<string, PropSpec> = {};+ const events: string[] = [];+ for (const [name, spec] of Object.entries(props)) {+ if (spec.type.kind === 'fn') {+ events.push(name);+ actions.push(+ ` | {key: string; component: '${contract.name}'; event: '${name}'; args: [${spec.type.args.map(arg => tsType(arg, 'AstryxNode')).join(', ')}]}`,+ );+ } else {+ data[name] = spec;+ }+ }+ nodes.push(+ `/** ${contract.name} as JSON from a TypeScript core. */\n` ++ `export interface ${contract.name}Node {\n` ++ ` component: '${contract.name}';\n` ++ ' key: string;\n' ++ ' base?: AstryxSharedBaseProps;\n' ++ ` props: {${members(data, ' ', 'AstryxNode')}};\n` ++ (events.length > 0+ ? ` /** The callbacks the core listens to. */\n events?: ReadonlyArray<${events.map(e => `'${e}'`).join(' | ')}>;\n`+ : '') ++ '}',+ );+ }+ return [+ ...nodes,+ '/** Any Astryx component a TypeScript core can send. */',+ `export type AstryxNode = ${contracts.map(c => `${c.name}Node`).join(' | ')};`,+ '/** A callback a native view called, sent back to the core. */',+ `export type AstryxAction =\n${actions.join('\n') || ' never'};`,+ ].join('\n');+}+function platformFile(contracts: readonly ComponentContract[],platform: NativePlatform | null,): string {- const imports = `import type {${contracts.map(c => `${c.name}CoreProps`).join(', ')}} from './core.js';\n`;+ const named = contracts.flatMap(c => Object.keys(c.types));+ const imports = `import type {${['AstryxSharedBaseProps', ...new Set(named), ...contracts.map(c => `${c.name}CoreProps`)].join(', ')}} from './core.js';\n`;const components = contracts.map(contract => {const extra = platform ? (contract.platforms[platform] ?? {}) : {};const body = Object.keys(extra).length > 0 ? `\n ${members(extra)}\n` : '';@@ -99,7 +162,15 @@ function platformFile(`export declare function ${contract.name}(props: ${contract.name}Props): unknown;`);});- return HEADER + imports + reExports(contracts) + components.join('\n') + '\n';+ return (+ HEADER ++ imports ++ reExports(contracts) ++ components.join('\n') ++ '\n' ++ wire(contracts, platform) ++ '\n'+ );}/** Returns file name to contents, relative to the types output folder. */diff --git a/packages/native/src/contract/types.ts b/packages/native/src/contract/types.tsindex dec3d3eee8..f9d72d5544 100644--- a/packages/native/src/contract/types.ts+++ b/packages/native/src/contract/types.ts@@ -21,6 +21,8 @@ export type PropType =| {kind: 'array'; of: PropType}| {kind: 'record'; fields: Readonly<Record<string, PropSpec>>}| {kind: 'fn'; args: readonly PropType[]}+ /** Child Astryx components: the typed content slot (AST-082 FR4). */+ | {kind: 'content'}| {kind: 'named'; name: string};export interface PropSpec {