@astryxdesign/native 0.7.4-canary.720bb10 → 0.7.5-canary.04434e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -4
- package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +1 -1
- package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +69 -0
- package/apple/Sources/AstryxNative/Generated/AstryxWire.swift +67 -0
- package/apple/Sources/AstryxNative/Generated/Badge.swift +89 -0
- package/apple/Sources/AstryxNative/Generated/Button.swift +154 -0
- package/apple/Sources/AstryxNative/Generated/Card.swift +117 -0
- package/apple/Sources/AstryxNative/Generated/Divider.swift +97 -0
- package/apple/Sources/AstryxNative/Generated/HStack.swift +308 -0
- package/apple/Sources/AstryxNative/Generated/Heading.swift +169 -0
- package/apple/Sources/AstryxNative/Generated/ProgressBar.swift +144 -0
- package/apple/Sources/AstryxNative/Generated/Selector.swift +133 -9
- package/apple/Sources/AstryxNative/Generated/Switch.swift +202 -0
- package/apple/Sources/AstryxNative/Generated/Text.swift +172 -0
- package/apple/Sources/AstryxNative/Generated/TextInput.swift +243 -0
- package/apple/Sources/AstryxNative/Generated/VStack.swift +308 -0
- package/apple/Sources/AstryxNative/Logic/AstryxLogicHost.swift +102 -0
- package/apple/Tests/AstryxNativeTests/ControlPropsTests.swift +29 -0
- package/apple/Tests/AstryxNativeTests/LogicHostTests.swift +85 -0
- package/apple/Tests/AstryxNativeTests/WireTests.swift +53 -0
- package/dist/components/Badge.d.ts +10 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +7 -0
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +15 -0
- package/dist/components/Card.d.ts +10 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +7 -0
- package/dist/components/Divider.d.ts +10 -0
- package/dist/components/Divider.d.ts.map +1 -0
- package/dist/components/Divider.js +6 -0
- package/dist/components/HStack.d.ts +10 -0
- package/dist/components/HStack.d.ts.map +1 -0
- package/dist/components/HStack.js +9 -0
- package/dist/components/Heading.d.ts +10 -0
- package/dist/components/Heading.d.ts.map +1 -0
- package/dist/components/Heading.js +14 -0
- package/dist/components/ProgressBar.d.ts +10 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +5 -0
- package/dist/components/Switch.d.ts +10 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +6 -0
- package/dist/components/Text.d.ts +10 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +13 -0
- package/dist/components/TextInput.d.ts +10 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +9 -0
- package/dist/components/VStack.d.ts +10 -0
- package/dist/components/VStack.d.ts.map +1 -0
- package/dist/components/VStack.js +9 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +25 -1
- package/dist/components/stackShared.d.ts +9 -0
- package/dist/components/stackShared.d.ts.map +1 -0
- package/dist/components/stackShared.js +4 -0
- package/dist/contract/fromComponentDoc.d.ts +44 -5
- package/dist/contract/fromComponentDoc.d.ts.map +1 -1
- package/dist/contract/fromComponentDoc.js +47 -4
- package/dist/contract/generateSwift.d.ts.map +1 -1
- package/dist/contract/generateSwift.js +193 -10
- package/dist/contract/generateTypeScript.d.ts.map +1 -1
- package/dist/contract/generateTypeScript.js +69 -9
- package/dist/contract/index.d.ts +7 -3
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +2 -1
- package/dist/contract/parseDocType.d.ts +5 -2
- package/dist/contract/parseDocType.d.ts.map +1 -1
- package/dist/contract/parseDocType.js +34 -5
- package/dist/contract/rules.d.ts +5 -2
- package/dist/contract/rules.d.ts.map +1 -1
- package/dist/contract/rules.js +8 -4
- package/dist/contract/types.d.ts +11 -0
- package/dist/contract/types.d.ts.map +1 -1
- package/dist/logic/connectBridge.d.ts +29 -0
- package/dist/logic/connectBridge.d.ts.map +1 -0
- package/dist/logic/connectBridge.js +32 -0
- package/dist/logic/createLogicCore.d.ts +44 -0
- package/dist/logic/createLogicCore.d.ts.map +1 -0
- package/dist/logic/createLogicCore.js +40 -0
- package/dist/logic/index.d.ts +12 -0
- package/dist/logic/index.d.ts.map +1 -0
- package/dist/logic/index.js +10 -0
- package/dist/types/android.d.ts +136 -2
- package/dist/types/core.d.ts +150 -0
- package/dist/types/ios.d.ts +136 -2
- package/dist/types/macos.d.ts +136 -2
- package/dist/types/shared.d.ts +136 -2
- package/dist/types/windows.d.ts +136 -2
- package/package.json +10 -4
- package/src/components/Badge.ts +18 -0
- package/src/components/Button.ts +26 -0
- package/src/components/Card.ts +18 -0
- package/src/components/Divider.ts +17 -0
- package/src/components/HStack.ts +20 -0
- package/src/components/Heading.ts +25 -0
- package/src/components/ProgressBar.ts +16 -0
- package/src/components/Switch.ts +17 -0
- package/src/components/Text.ts +24 -0
- package/src/components/TextInput.ts +20 -0
- package/src/components/VStack.ts +20 -0
- package/src/components/index.ts +25 -1
- package/src/components/stackShared.ts +14 -0
- package/src/contract/contracts.test.ts +58 -0
- package/src/contract/fromComponentDoc.test.ts +97 -0
- package/src/contract/fromComponentDoc.ts +106 -9
- package/src/contract/generateSwift.ts +223 -10
- package/src/contract/generateTypeScript.ts +83 -10
- package/src/contract/index.ts +13 -4
- package/src/contract/parseDocType.test.ts +45 -0
- package/src/contract/parseDocType.ts +41 -6
- package/src/contract/rules.ts +11 -4
- package/src/contract/types.ts +6 -0
- package/src/logic/connectBridge.ts +72 -0
- package/src/logic/createLogicCore.ts +97 -0
- package/src/logic/index.ts +19 -0
- package/src/logic/logic.test.ts +160 -0
package/README.md
CHANGED
|
@@ -19,9 +19,13 @@ rests on evidence.
|
|
|
19
19
|
| Swift binding | `apple/` | A Swift package with props generated from the same contracts. iOS and macOS props sit behind `#if os(...)`. |
|
|
20
20
|
| 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. |
|
|
21
21
|
| Icons | `NATIVE_ICON_DEFAULTS` | Astryx's built-in icon names mapped to SF Symbols on Apple platforms and Material Symbols on Android. |
|
|
22
|
+
| 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:)`. |
|
|
23
|
+
| Logic core | `@astryxdesign/native/logic` | `createLogicCore` holds a screen's state, builds its node tree, and reduces actions; `connectBridge` carries it to a native host as JSON. ECMAScript built-ins only, so it runs in Hermes. Shaped after EJ Campbell's astryx-swift spike. |
|
|
24
|
+
| Logic host | `AstryxLogicHost` (Swift) | Runs a logic core bundle in JavaScriptCore, decodes each tree into `AstryxNode`, and sends views' actions back. A Hermes host speaks the same bridge. |
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
Contracts cover Badge, Button, Card, Divider, Heading, HStack, ProgressBar,
|
|
27
|
+
Selector, Switch, Text, TextInput, and VStack. React Native and Android
|
|
28
|
+
bindings are not built yet; see [the experiment matrix](#experiment-matrix).
|
|
25
29
|
|
|
26
30
|
```ts
|
|
27
31
|
// tsconfig.json for an iOS app: "customConditions": ["ios"]
|
|
@@ -34,10 +38,96 @@ const props: SelectorProps = {
|
|
|
34
38
|
};
|
|
35
39
|
```
|
|
36
40
|
|
|
41
|
+
How core documentation becomes a contract:
|
|
42
|
+
|
|
43
|
+
- A callback whose arguments are values followed by the DOM event that caused
|
|
44
|
+
them, such as `(checked: boolean, e: ChangeEvent) => void`, keeps the values
|
|
45
|
+
in the core; the event stays on the web.
|
|
46
|
+
- A callback that carries only an event stays on the web, unless the component
|
|
47
|
+
names it in `callbacks`, as Button does for `onClick`. Its core form takes no
|
|
48
|
+
arguments. A callback with an event before a value stays on the web either
|
|
49
|
+
way.
|
|
50
|
+
- Free-form content becomes a typed slot only where a component declares one
|
|
51
|
+
in `slots`; `text` is a string, as for a badge's label or a heading's words,
|
|
52
|
+
and `content` is child Astryx components, as for a stack's or a card's
|
|
53
|
+
children. A SwiftUI view takes content as a view builder, so `<Name>Props`
|
|
54
|
+
leaves it out; `<Name>Node` carries it as child nodes.
|
|
55
|
+
- A closed set of numbers, such as a heading level, is a Swift enum with raw
|
|
56
|
+
values.
|
|
57
|
+
- A core prop may share a platform toolkit's name only when the component
|
|
58
|
+
declares in `sameMeaning` that it means the same thing there.
|
|
59
|
+
|
|
60
|
+
### The wire (arm C)
|
|
61
|
+
|
|
62
|
+
A TypeScript core sends a tree of nodes and receives actions. A node lists the
|
|
63
|
+
callbacks the core listens to in `events`; a view gets only those callbacks.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// tsconfig: "customConditions": ["ios"]
|
|
67
|
+
import type {AstryxAction, AstryxNode} from '@astryxdesign/native/components';
|
|
68
|
+
|
|
69
|
+
const screen: AstryxNode = {
|
|
70
|
+
component: 'VStack',
|
|
71
|
+
key: 'root',
|
|
72
|
+
props: {
|
|
73
|
+
gap: 2,
|
|
74
|
+
children: [
|
|
75
|
+
{
|
|
76
|
+
component: 'Switch',
|
|
77
|
+
key: 'wifi',
|
|
78
|
+
props: {label: 'Wi-Fi', value: true},
|
|
79
|
+
events: ['onChange'],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
// What the host sends back when the switch is turned off:
|
|
85
|
+
const action: AstryxAction = {
|
|
86
|
+
key: 'wifi',
|
|
87
|
+
component: 'Switch',
|
|
88
|
+
event: 'onChange',
|
|
89
|
+
args: [false],
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```swift
|
|
94
|
+
let host = AstryxLogicHost(bundle: bundleSource) // calls the bundle's global astryxStart(host)
|
|
95
|
+
if case .switch(let wifi) = host.root {
|
|
96
|
+
let props = wifi.viewProps(send: host.send)
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// tsconfig: "customConditions": ["ios"]
|
|
102
|
+
import type {AstryxAction, AstryxNode} from '@astryxdesign/native/components';
|
|
103
|
+
import {connectBridge, createLogicCore} from '@astryxdesign/native/logic';
|
|
104
|
+
import type {Bridge, BridgeHost} from '@astryxdesign/native/logic';
|
|
105
|
+
|
|
106
|
+
const core = createLogicCore<{wifi: boolean}, AstryxNode, AstryxAction>({
|
|
107
|
+
initial: {wifi: true},
|
|
108
|
+
view: state => ({
|
|
109
|
+
component: 'Switch',
|
|
110
|
+
key: 'wifi',
|
|
111
|
+
props: {label: 'Wi-Fi', value: state.wifi},
|
|
112
|
+
events: ['onChange'],
|
|
113
|
+
}),
|
|
114
|
+
reduce: (state, action) =>
|
|
115
|
+
action.component === 'Switch' && action.event === 'onChange'
|
|
116
|
+
? {wifi: action.args[0]}
|
|
117
|
+
: state,
|
|
118
|
+
});
|
|
119
|
+
// The bundle's entry: the native host calls it with its two calls in and
|
|
120
|
+
// gets back the bridge it reads snapshots from and dispatches actions to.
|
|
121
|
+
(globalThis as {astryxStart?: (host: BridgeHost) => Bridge}).astryxStart =
|
|
122
|
+
host => connectBridge(core, host);
|
|
123
|
+
```
|
|
124
|
+
|
|
37
125
|
## Working on it
|
|
38
126
|
|
|
39
127
|
```sh
|
|
128
|
+
pnpm -F @astryxdesign/native typecheck # source and tests
|
|
40
129
|
pnpm -F @astryxdesign/native build # dist/, including platform types
|
|
130
|
+
pnpm -F @astryxdesign/native typecheck:types # every platform's types, after build
|
|
41
131
|
pnpm -F @astryxdesign/native generate:apple # regenerate apple/Sources/.../Generated
|
|
42
132
|
pnpm vitest run --project node packages/native
|
|
43
133
|
```
|
|
@@ -45,11 +135,33 @@ pnpm vitest run --project node packages/native
|
|
|
45
135
|
Generated Swift is committed so a Swift package can pin a commit. A test fails
|
|
46
136
|
when it drifts from the contracts.
|
|
47
137
|
|
|
138
|
+
**Cleanup needed.** Committing the generated Swift
|
|
139
|
+
(`apple/Sources/AstryxNative/Generated`) is temporary. It is there only because
|
|
140
|
+
Swift Package Manager installs a package from a git commit and cannot run the
|
|
141
|
+
Node generator. The intended replacement: CI generates the Swift files and
|
|
142
|
+
publishes them to a Swift-only branch or tag that apps pin, and the generated
|
|
143
|
+
files are ignored on `main`.
|
|
144
|
+
|
|
48
145
|
Boundaries, checked by `pnpm check:package-boundaries`:
|
|
49
146
|
|
|
50
147
|
- `@astryxdesign/core` never imports this package.
|
|
51
|
-
-
|
|
52
|
-
|
|
148
|
+
- No file in this package, in any folder, imports core, apart from the
|
|
149
|
+
build-time reads AST-082 FR16 lists until core's portable entry ships: the
|
|
150
|
+
theme generator in `scripts/` may import `@astryxdesign/core/theme` and
|
|
151
|
+
`@astryxdesign/core/theme/tokens`; `scripts/swift-ios-strings.mjs` may
|
|
152
|
+
read core's locale catalogs (`@astryxdesign/core/locales/*.json`); and
|
|
153
|
+
`scripts/core-docs.mjs` reads core's component documentation and built-in
|
|
154
|
+
icon names as data.
|
|
155
|
+
- The check reads source text in every folder except `node_modules`, `dist`,
|
|
156
|
+
`.build`, and `.swiftpm`. It flags any other module specifier that names
|
|
157
|
+
core (`import`, `require`, `require.resolve`, `import.meta.resolve`, or a
|
|
158
|
+
relative path into `packages/core`). It also flags a path to core's package,
|
|
159
|
+
written as adjacent string segments (`'@astryxdesign', 'core'`,
|
|
160
|
+
`'node_modules', '@astryxdesign/core'`, `'packages', 'core'`) or inside one
|
|
161
|
+
string (`node_modules/@astryxdesign/core`, `packages/core`). In
|
|
162
|
+
`scripts/core-docs.mjs` it allows exactly one such path, the `CORE_ROOT`
|
|
163
|
+
definition, and only the listed reads under `CORE_ROOT`. It does not follow
|
|
164
|
+
paths computed in other ways.
|
|
53
165
|
|
|
54
166
|
## Experiment matrix
|
|
55
167
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
public enum AstryxBaseTarget: String, Sendable { case root, trigger, control, container }
|
|
3
3
|
|
|
4
4
|
/// Base props shared by every platform (AST-082 FR7).
|
|
5
|
-
public struct AstryxBaseProps: Equatable, Sendable {
|
|
5
|
+
public struct AstryxBaseProps: Equatable, Codable, Sendable {
|
|
6
6
|
public var id: String?
|
|
7
7
|
public var isHidden: Bool?
|
|
8
8
|
public init(id: String? = nil, isHidden: Bool? = nil) {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
#if os(iOS) || os(macOS)
|
|
5
|
+
/// One Astryx component in a tree a TypeScript core sends, by its `component` name.
|
|
6
|
+
/// A node this binding cannot read decodes as `unsupported`: an unknown component,
|
|
7
|
+
/// or a known one with a value its enums lack or a required prop missing. An older
|
|
8
|
+
/// app then keeps drawing the rest of a newer core's tree.
|
|
9
|
+
public enum AstryxNode: Decodable, Equatable, Sendable {
|
|
10
|
+
case badge(BadgeNode)
|
|
11
|
+
case button(ButtonNode)
|
|
12
|
+
case card(CardNode)
|
|
13
|
+
case divider(DividerNode)
|
|
14
|
+
case heading(HeadingNode)
|
|
15
|
+
case hStack(HStackNode)
|
|
16
|
+
case progressBar(ProgressBarNode)
|
|
17
|
+
case selector(SelectorNode)
|
|
18
|
+
case `switch`(SwitchNode)
|
|
19
|
+
case text(TextNode)
|
|
20
|
+
case textInput(TextInputNode)
|
|
21
|
+
case vStack(VStackNode)
|
|
22
|
+
case unsupported(component: String, key: String)
|
|
23
|
+
|
|
24
|
+
public var key: String {
|
|
25
|
+
switch self {
|
|
26
|
+
case .badge(let node): return node.key
|
|
27
|
+
case .button(let node): return node.key
|
|
28
|
+
case .card(let node): return node.key
|
|
29
|
+
case .divider(let node): return node.key
|
|
30
|
+
case .heading(let node): return node.key
|
|
31
|
+
case .hStack(let node): return node.key
|
|
32
|
+
case .progressBar(let node): return node.key
|
|
33
|
+
case .selector(let node): return node.key
|
|
34
|
+
case .`switch`(let node): return node.key
|
|
35
|
+
case .text(let node): return node.key
|
|
36
|
+
case .textInput(let node): return node.key
|
|
37
|
+
case .vStack(let node): return node.key
|
|
38
|
+
case .unsupported(_, let key): return key
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private enum Keys: String, CodingKey { case component, key }
|
|
43
|
+
|
|
44
|
+
public init(from decoder: any Decoder) throws {
|
|
45
|
+
let container = try decoder.container(keyedBy: Keys.self)
|
|
46
|
+
let component = try container.decode(String.self, forKey: .component)
|
|
47
|
+
let key = try container.decode(String.self, forKey: .key)
|
|
48
|
+
do {
|
|
49
|
+
switch component {
|
|
50
|
+
case "Badge": self = .badge(try BadgeNode(from: decoder))
|
|
51
|
+
case "Button": self = .button(try ButtonNode(from: decoder))
|
|
52
|
+
case "Card": self = .card(try CardNode(from: decoder))
|
|
53
|
+
case "Divider": self = .divider(try DividerNode(from: decoder))
|
|
54
|
+
case "Heading": self = .heading(try HeadingNode(from: decoder))
|
|
55
|
+
case "HStack": self = .hStack(try HStackNode(from: decoder))
|
|
56
|
+
case "ProgressBar": self = .progressBar(try ProgressBarNode(from: decoder))
|
|
57
|
+
case "Selector": self = .selector(try SelectorNode(from: decoder))
|
|
58
|
+
case "Switch": self = .`switch`(try SwitchNode(from: decoder))
|
|
59
|
+
case "Text": self = .text(try TextNode(from: decoder))
|
|
60
|
+
case "TextInput": self = .textInput(try TextInputNode(from: decoder))
|
|
61
|
+
case "VStack": self = .vStack(try VStackNode(from: decoder))
|
|
62
|
+
default: self = .unsupported(component: component, key: key)
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
self = .unsupported(component: component, key: key)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
#endif
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
/// A JSON value: a portable callback argument on its way to the core.
|
|
5
|
+
public enum AstryxValue: Codable, Equatable, Sendable {
|
|
6
|
+
case null
|
|
7
|
+
case bool(Bool)
|
|
8
|
+
case number(Double)
|
|
9
|
+
case string(String)
|
|
10
|
+
case array([AstryxValue])
|
|
11
|
+
case object([String: AstryxValue])
|
|
12
|
+
|
|
13
|
+
/// Any portable value (a contract's strings, numbers, enums, and records) as JSON.
|
|
14
|
+
public init<T: Encodable>(_ value: T) {
|
|
15
|
+
guard let data = try? JSONEncoder().encode(value),
|
|
16
|
+
let decoded = try? JSONDecoder().decode(AstryxValue.self, from: data) else {
|
|
17
|
+
self = .null
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
self = decoded
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public init(from decoder: any Decoder) throws {
|
|
24
|
+
let container = try decoder.singleValueContainer()
|
|
25
|
+
if container.decodeNil() { self = .null }
|
|
26
|
+
else if let value = try? container.decode(Bool.self) { self = .bool(value) }
|
|
27
|
+
else if let value = try? container.decode(Double.self) { self = .number(value) }
|
|
28
|
+
else if let value = try? container.decode(String.self) { self = .string(value) }
|
|
29
|
+
else if let value = try? container.decode([AstryxValue].self) { self = .array(value) }
|
|
30
|
+
else { self = .object(try container.decode([String: AstryxValue].self)) }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public func encode(to encoder: any Encoder) throws {
|
|
34
|
+
var container = encoder.singleValueContainer()
|
|
35
|
+
switch self {
|
|
36
|
+
case .null: try container.encodeNil()
|
|
37
|
+
case .bool(let value): try container.encode(value)
|
|
38
|
+
case .number(let value): try container.encode(value)
|
|
39
|
+
case .string(let value): try container.encode(value)
|
|
40
|
+
case .array(let value): try container.encode(value)
|
|
41
|
+
case .object(let value): try container.encode(value)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// A callback a view called: which node, which prop, and its arguments.
|
|
47
|
+
public struct AstryxAction: Codable, Equatable, Sendable {
|
|
48
|
+
public let key: String
|
|
49
|
+
public let component: String
|
|
50
|
+
public let event: String
|
|
51
|
+
public let args: [AstryxValue]
|
|
52
|
+
|
|
53
|
+
public init(key: String, component: String, event: String, args: [AstryxValue]) {
|
|
54
|
+
self.key = key
|
|
55
|
+
self.component = component
|
|
56
|
+
self.event = event
|
|
57
|
+
self.args = args
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// The JSON the core receives.
|
|
61
|
+
public var json: String {
|
|
62
|
+
let encoder = JSONEncoder()
|
|
63
|
+
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
|
|
64
|
+
guard let data = try? encoder.encode(self) else { return "{}" }
|
|
65
|
+
return String(decoding: data, as: UTF8.self)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum BadgeVariant: String, CaseIterable, Codable, Sendable {
|
|
3
|
+
case neutral = "neutral"
|
|
4
|
+
case info = "info"
|
|
5
|
+
case success = "success"
|
|
6
|
+
case warning = "warning"
|
|
7
|
+
case error = "error"
|
|
8
|
+
case blue = "blue"
|
|
9
|
+
case cyan = "cyan"
|
|
10
|
+
case green = "green"
|
|
11
|
+
case orange = "orange"
|
|
12
|
+
case pink = "pink"
|
|
13
|
+
case purple = "purple"
|
|
14
|
+
case red = "red"
|
|
15
|
+
case teal = "teal"
|
|
16
|
+
case yellow = "yellow"
|
|
17
|
+
}
|
|
18
|
+
#if os(iOS)
|
|
19
|
+
public struct BadgeProps {
|
|
20
|
+
/// Base props attach to this part on every platform.
|
|
21
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
22
|
+
public var base: AstryxBaseProps
|
|
23
|
+
public var variant: BadgeVariant?
|
|
24
|
+
public var label: String
|
|
25
|
+
public init(variant: BadgeVariant? = nil, label: String, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
26
|
+
self.variant = variant
|
|
27
|
+
self.label = label
|
|
28
|
+
self.base = base
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
public struct BadgeNode: Decodable, Equatable, Sendable {
|
|
32
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
33
|
+
public var variant: BadgeVariant?
|
|
34
|
+
public var label: String
|
|
35
|
+
}
|
|
36
|
+
public let key: String
|
|
37
|
+
public let base: AstryxBaseProps?
|
|
38
|
+
public let props: Props
|
|
39
|
+
/// The callbacks the core listens to, by prop name.
|
|
40
|
+
public let events: [String]?
|
|
41
|
+
|
|
42
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
43
|
+
|
|
44
|
+
/// The contract a Badge view takes; its callbacks send actions to the core.
|
|
45
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> BadgeProps {
|
|
46
|
+
return BadgeProps(
|
|
47
|
+
variant: props.variant,
|
|
48
|
+
label: props.label,
|
|
49
|
+
base: base ?? AstryxBaseProps()
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
#endif
|
|
54
|
+
#if os(macOS)
|
|
55
|
+
public struct BadgeProps {
|
|
56
|
+
/// Base props attach to this part on every platform.
|
|
57
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
58
|
+
public var base: AstryxBaseProps
|
|
59
|
+
public var variant: BadgeVariant?
|
|
60
|
+
public var label: String
|
|
61
|
+
public init(variant: BadgeVariant? = nil, label: String, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
62
|
+
self.variant = variant
|
|
63
|
+
self.label = label
|
|
64
|
+
self.base = base
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
public struct BadgeNode: Decodable, Equatable, Sendable {
|
|
68
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
69
|
+
public var variant: BadgeVariant?
|
|
70
|
+
public var label: String
|
|
71
|
+
}
|
|
72
|
+
public let key: String
|
|
73
|
+
public let base: AstryxBaseProps?
|
|
74
|
+
public let props: Props
|
|
75
|
+
/// The callbacks the core listens to, by prop name.
|
|
76
|
+
public let events: [String]?
|
|
77
|
+
|
|
78
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
79
|
+
|
|
80
|
+
/// The contract a Badge view takes; its callbacks send actions to the core.
|
|
81
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> BadgeProps {
|
|
82
|
+
return BadgeProps(
|
|
83
|
+
variant: props.variant,
|
|
84
|
+
label: props.label,
|
|
85
|
+
base: base ?? AstryxBaseProps()
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum ButtonVariant: String, CaseIterable, Codable, Sendable {
|
|
3
|
+
case primary = "primary"
|
|
4
|
+
case secondary = "secondary"
|
|
5
|
+
case ghost = "ghost"
|
|
6
|
+
case destructive = "destructive"
|
|
7
|
+
}
|
|
8
|
+
public enum ButtonSize: String, CaseIterable, Codable, Sendable {
|
|
9
|
+
case sm = "sm"
|
|
10
|
+
case md = "md"
|
|
11
|
+
case lg = "lg"
|
|
12
|
+
}
|
|
13
|
+
public enum ButtonElevation: String, CaseIterable, Codable, Sendable {
|
|
14
|
+
case none = "none"
|
|
15
|
+
case low = "low"
|
|
16
|
+
case med = "med"
|
|
17
|
+
case high = "high"
|
|
18
|
+
}
|
|
19
|
+
#if os(iOS)
|
|
20
|
+
public struct ButtonProps {
|
|
21
|
+
/// Base props attach to this part on every platform.
|
|
22
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
23
|
+
public var base: AstryxBaseProps
|
|
24
|
+
public var label: String
|
|
25
|
+
public var variant: ButtonVariant?
|
|
26
|
+
public var size: ButtonSize?
|
|
27
|
+
public var elevation: ButtonElevation?
|
|
28
|
+
public var isLoading: Bool?
|
|
29
|
+
public var isInterruptible: Bool?
|
|
30
|
+
public var isDisabled: Bool?
|
|
31
|
+
public var tooltip: String?
|
|
32
|
+
public var onClick: (() -> Void)?
|
|
33
|
+
public var href: String?
|
|
34
|
+
public init(label: String, variant: ButtonVariant? = nil, size: ButtonSize? = nil, elevation: ButtonElevation? = nil, isLoading: Bool? = nil, isInterruptible: Bool? = nil, isDisabled: Bool? = nil, tooltip: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
35
|
+
self.label = label
|
|
36
|
+
self.variant = variant
|
|
37
|
+
self.size = size
|
|
38
|
+
self.elevation = elevation
|
|
39
|
+
self.isLoading = isLoading
|
|
40
|
+
self.isInterruptible = isInterruptible
|
|
41
|
+
self.isDisabled = isDisabled
|
|
42
|
+
self.tooltip = tooltip
|
|
43
|
+
self.onClick = onClick
|
|
44
|
+
self.href = href
|
|
45
|
+
self.base = base
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
public struct ButtonNode: Decodable, Equatable, Sendable {
|
|
49
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
50
|
+
public var label: String
|
|
51
|
+
public var variant: ButtonVariant?
|
|
52
|
+
public var size: ButtonSize?
|
|
53
|
+
public var elevation: ButtonElevation?
|
|
54
|
+
public var isLoading: Bool?
|
|
55
|
+
public var isInterruptible: Bool?
|
|
56
|
+
public var isDisabled: Bool?
|
|
57
|
+
public var tooltip: String?
|
|
58
|
+
public var href: String?
|
|
59
|
+
}
|
|
60
|
+
public let key: String
|
|
61
|
+
public let base: AstryxBaseProps?
|
|
62
|
+
public let props: Props
|
|
63
|
+
/// The callbacks the core listens to, by prop name.
|
|
64
|
+
public let events: [String]?
|
|
65
|
+
|
|
66
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
67
|
+
|
|
68
|
+
/// The contract a Button view takes; its callbacks send actions to the core.
|
|
69
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ButtonProps {
|
|
70
|
+
let key = self.key
|
|
71
|
+
return ButtonProps(
|
|
72
|
+
label: props.label,
|
|
73
|
+
variant: props.variant,
|
|
74
|
+
size: props.size,
|
|
75
|
+
elevation: props.elevation,
|
|
76
|
+
isLoading: props.isLoading,
|
|
77
|
+
isInterruptible: props.isInterruptible,
|
|
78
|
+
isDisabled: props.isDisabled,
|
|
79
|
+
tooltip: props.tooltip,
|
|
80
|
+
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Button", event: "onClick", args: [])) } : nil,
|
|
81
|
+
href: props.href,
|
|
82
|
+
base: base ?? AstryxBaseProps()
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
#endif
|
|
87
|
+
#if os(macOS)
|
|
88
|
+
public struct ButtonProps {
|
|
89
|
+
/// Base props attach to this part on every platform.
|
|
90
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
91
|
+
public var base: AstryxBaseProps
|
|
92
|
+
public var label: String
|
|
93
|
+
public var variant: ButtonVariant?
|
|
94
|
+
public var size: ButtonSize?
|
|
95
|
+
public var elevation: ButtonElevation?
|
|
96
|
+
public var isLoading: Bool?
|
|
97
|
+
public var isInterruptible: Bool?
|
|
98
|
+
public var isDisabled: Bool?
|
|
99
|
+
public var tooltip: String?
|
|
100
|
+
public var onClick: (() -> Void)?
|
|
101
|
+
public var href: String?
|
|
102
|
+
public init(label: String, variant: ButtonVariant? = nil, size: ButtonSize? = nil, elevation: ButtonElevation? = nil, isLoading: Bool? = nil, isInterruptible: Bool? = nil, isDisabled: Bool? = nil, tooltip: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
103
|
+
self.label = label
|
|
104
|
+
self.variant = variant
|
|
105
|
+
self.size = size
|
|
106
|
+
self.elevation = elevation
|
|
107
|
+
self.isLoading = isLoading
|
|
108
|
+
self.isInterruptible = isInterruptible
|
|
109
|
+
self.isDisabled = isDisabled
|
|
110
|
+
self.tooltip = tooltip
|
|
111
|
+
self.onClick = onClick
|
|
112
|
+
self.href = href
|
|
113
|
+
self.base = base
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
public struct ButtonNode: Decodable, Equatable, Sendable {
|
|
117
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
118
|
+
public var label: String
|
|
119
|
+
public var variant: ButtonVariant?
|
|
120
|
+
public var size: ButtonSize?
|
|
121
|
+
public var elevation: ButtonElevation?
|
|
122
|
+
public var isLoading: Bool?
|
|
123
|
+
public var isInterruptible: Bool?
|
|
124
|
+
public var isDisabled: Bool?
|
|
125
|
+
public var tooltip: String?
|
|
126
|
+
public var href: String?
|
|
127
|
+
}
|
|
128
|
+
public let key: String
|
|
129
|
+
public let base: AstryxBaseProps?
|
|
130
|
+
public let props: Props
|
|
131
|
+
/// The callbacks the core listens to, by prop name.
|
|
132
|
+
public let events: [String]?
|
|
133
|
+
|
|
134
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
135
|
+
|
|
136
|
+
/// The contract a Button view takes; its callbacks send actions to the core.
|
|
137
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ButtonProps {
|
|
138
|
+
let key = self.key
|
|
139
|
+
return ButtonProps(
|
|
140
|
+
label: props.label,
|
|
141
|
+
variant: props.variant,
|
|
142
|
+
size: props.size,
|
|
143
|
+
elevation: props.elevation,
|
|
144
|
+
isLoading: props.isLoading,
|
|
145
|
+
isInterruptible: props.isInterruptible,
|
|
146
|
+
isDisabled: props.isDisabled,
|
|
147
|
+
tooltip: props.tooltip,
|
|
148
|
+
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Button", event: "onClick", args: [])) } : nil,
|
|
149
|
+
href: props.href,
|
|
150
|
+
base: base ?? AstryxBaseProps()
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
#endif
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum CardPadding: Double, CaseIterable, Codable, Sendable {
|
|
3
|
+
case v0 = 0
|
|
4
|
+
case v0_5 = 0.5
|
|
5
|
+
case v1 = 1
|
|
6
|
+
case v1_5 = 1.5
|
|
7
|
+
case v2 = 2
|
|
8
|
+
case v3 = 3
|
|
9
|
+
case v4 = 4
|
|
10
|
+
case v5 = 5
|
|
11
|
+
case v6 = 6
|
|
12
|
+
case v8 = 8
|
|
13
|
+
case v10 = 10
|
|
14
|
+
}
|
|
15
|
+
public enum CardVariant: String, CaseIterable, Codable, Sendable {
|
|
16
|
+
case `default` = "default"
|
|
17
|
+
case transparent = "transparent"
|
|
18
|
+
case muted = "muted"
|
|
19
|
+
case blue = "blue"
|
|
20
|
+
case cyan = "cyan"
|
|
21
|
+
case gray = "gray"
|
|
22
|
+
case green = "green"
|
|
23
|
+
case orange = "orange"
|
|
24
|
+
case pink = "pink"
|
|
25
|
+
case purple = "purple"
|
|
26
|
+
case red = "red"
|
|
27
|
+
case teal = "teal"
|
|
28
|
+
case yellow = "yellow"
|
|
29
|
+
}
|
|
30
|
+
public enum CardElevation: String, CaseIterable, Codable, Sendable {
|
|
31
|
+
case none = "none"
|
|
32
|
+
case low = "low"
|
|
33
|
+
case med = "med"
|
|
34
|
+
case high = "high"
|
|
35
|
+
}
|
|
36
|
+
#if os(iOS)
|
|
37
|
+
public struct CardProps {
|
|
38
|
+
/// Base props attach to this part on every platform.
|
|
39
|
+
public static let baseTarget: AstryxBaseTarget = .container
|
|
40
|
+
public var base: AstryxBaseProps
|
|
41
|
+
public var padding: CardPadding?
|
|
42
|
+
public var variant: CardVariant?
|
|
43
|
+
public var elevation: CardElevation?
|
|
44
|
+
public init(padding: CardPadding? = nil, variant: CardVariant? = nil, elevation: CardElevation? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
45
|
+
self.padding = padding
|
|
46
|
+
self.variant = variant
|
|
47
|
+
self.elevation = elevation
|
|
48
|
+
self.base = base
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
public struct CardNode: Decodable, Equatable, Sendable {
|
|
52
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
53
|
+
public var children: [AstryxNode]?
|
|
54
|
+
public var padding: CardPadding?
|
|
55
|
+
public var variant: CardVariant?
|
|
56
|
+
public var elevation: CardElevation?
|
|
57
|
+
}
|
|
58
|
+
public let key: String
|
|
59
|
+
public let base: AstryxBaseProps?
|
|
60
|
+
public let props: Props
|
|
61
|
+
/// The callbacks the core listens to, by prop name.
|
|
62
|
+
public let events: [String]?
|
|
63
|
+
|
|
64
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
65
|
+
|
|
66
|
+
/// The contract a Card view takes; its callbacks send actions to the core.
|
|
67
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> CardProps {
|
|
68
|
+
return CardProps(
|
|
69
|
+
padding: props.padding,
|
|
70
|
+
variant: props.variant,
|
|
71
|
+
elevation: props.elevation,
|
|
72
|
+
base: base ?? AstryxBaseProps()
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
#endif
|
|
77
|
+
#if os(macOS)
|
|
78
|
+
public struct CardProps {
|
|
79
|
+
/// Base props attach to this part on every platform.
|
|
80
|
+
public static let baseTarget: AstryxBaseTarget = .container
|
|
81
|
+
public var base: AstryxBaseProps
|
|
82
|
+
public var padding: CardPadding?
|
|
83
|
+
public var variant: CardVariant?
|
|
84
|
+
public var elevation: CardElevation?
|
|
85
|
+
public init(padding: CardPadding? = nil, variant: CardVariant? = nil, elevation: CardElevation? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
86
|
+
self.padding = padding
|
|
87
|
+
self.variant = variant
|
|
88
|
+
self.elevation = elevation
|
|
89
|
+
self.base = base
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
public struct CardNode: Decodable, Equatable, Sendable {
|
|
93
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
94
|
+
public var children: [AstryxNode]?
|
|
95
|
+
public var padding: CardPadding?
|
|
96
|
+
public var variant: CardVariant?
|
|
97
|
+
public var elevation: CardElevation?
|
|
98
|
+
}
|
|
99
|
+
public let key: String
|
|
100
|
+
public let base: AstryxBaseProps?
|
|
101
|
+
public let props: Props
|
|
102
|
+
/// The callbacks the core listens to, by prop name.
|
|
103
|
+
public let events: [String]?
|
|
104
|
+
|
|
105
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
106
|
+
|
|
107
|
+
/// The contract a Card view takes; its callbacks send actions to the core.
|
|
108
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> CardProps {
|
|
109
|
+
return CardProps(
|
|
110
|
+
padding: props.padding,
|
|
111
|
+
variant: props.variant,
|
|
112
|
+
elevation: props.elevation,
|
|
113
|
+
base: base ?? AstryxBaseProps()
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
#endif
|