@astryxdesign/native 0.0.0-stage → 0.7.5-canary.0026f37
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/LICENSE +21 -0
- package/README.md +232 -2
- package/apple/Package.swift +18 -0
- package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +12 -0
- 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 +283 -0
- 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/SelectorPropsTests.swift +17 -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/Selector.d.ts +10 -0
- package/dist/components/Selector.d.ts.map +1 -0
- package/dist/components/Selector.js +38 -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 +10 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +27 -0
- 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 +71 -0
- package/dist/contract/fromComponentDoc.d.ts.map +1 -0
- package/dist/contract/fromComponentDoc.js +124 -0
- package/dist/contract/generateSwift.d.ts +4 -0
- package/dist/contract/generateSwift.d.ts.map +1 -0
- package/dist/contract/generateSwift.js +316 -0
- package/dist/contract/generateTypeScript.d.ts +4 -0
- package/dist/contract/generateTypeScript.d.ts.map +1 -0
- package/dist/contract/generateTypeScript.js +147 -0
- package/dist/contract/index.d.ts +24 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +34 -0
- package/dist/contract/names.d.ts +20 -0
- package/dist/contract/names.d.ts.map +1 -0
- package/dist/contract/names.js +90 -0
- package/dist/contract/parseDocType.d.ts +25 -0
- package/dist/contract/parseDocType.d.ts.map +1 -0
- package/dist/contract/parseDocType.js +212 -0
- package/dist/contract/rules.d.ts +13 -0
- package/dist/contract/rules.d.ts.map +1 -0
- package/dist/contract/rules.js +91 -0
- package/dist/contract/types.d.ts +68 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/icons/defaults.d.ts +25 -0
- package/dist/icons/defaults.d.ts.map +1 -0
- package/dist/icons/defaults.js +111 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- 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/platforms.d.ts +13 -0
- package/dist/platforms.d.ts.map +1 -0
- package/dist/platforms.js +14 -0
- package/dist/theme/defineNativeTheme.d.ts +75 -0
- package/dist/theme/defineNativeTheme.d.ts.map +1 -0
- package/dist/theme/defineNativeTheme.js +126 -0
- package/dist/types/android.d.ts +142 -0
- package/dist/types/core.d.ts +185 -0
- package/dist/types/ios.d.ts +142 -0
- package/dist/types/macos.d.ts +142 -0
- package/dist/types/shared.d.ts +140 -0
- package/dist/types/windows.d.ts +140 -0
- package/package.json +81 -3
- 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/Selector.ts +50 -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 +38 -0
- package/src/components/stackShared.ts +14 -0
- package/src/contract/contracts.test.ts +208 -0
- package/src/contract/fromComponentDoc.test.ts +97 -0
- package/src/contract/fromComponentDoc.ts +228 -0
- package/src/contract/generateSwift.ts +383 -0
- package/src/contract/generateTypeScript.ts +188 -0
- package/src/contract/index.ts +62 -0
- package/src/contract/names.ts +103 -0
- package/src/contract/parseDocType.test.ts +97 -0
- package/src/contract/parseDocType.ts +246 -0
- package/src/contract/rules.ts +139 -0
- package/src/contract/types.ts +58 -0
- package/src/icons/defaults.test.ts +47 -0
- package/src/icons/defaults.ts +136 -0
- package/src/index.ts +35 -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/src/platforms.ts +20 -0
- package/src/theme/defineNativeTheme.test.ts +88 -0
- package/src/theme/defineNativeTheme.ts +224 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Meta Platforms, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,233 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @astryxdesign/native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Experimental. Canary only.** This package is published only under the
|
|
4
|
+
> `@canary` dist-tag and is never released as a stable version. Its APIs change
|
|
5
|
+
> without notice. Nothing here is supported for production apps.
|
|
6
|
+
|
|
7
|
+
`@astryxdesign/native` is where Astryx experiments with native platforms
|
|
8
|
+
(iOS, Android, macOS, Windows) under AST-082 (Native-first surfaces). The
|
|
9
|
+
experiment compares ways of building Astryx components on each platform and
|
|
10
|
+
measures them against the same scorecard, so the decision for each platform
|
|
11
|
+
rests on evidence.
|
|
12
|
+
|
|
13
|
+
## What is here today
|
|
14
|
+
|
|
15
|
+
| Part | Path | What it does |
|
|
16
|
+
| -------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| Contracts | `src/contract/` | Reads a core component's documentation and splits its props into a portable **core contract** and a **web-only** part, with a reason for each web-only prop. Checks prop names against Swift and Kotlin keywords and platform toolkit names. |
|
|
18
|
+
| Platform types | `@astryxdesign/native/components` | TypeScript props per platform, chosen by type-resolution condition: `ios`, `android`, `macos`, `windows`, or `shared` for the core contract only. |
|
|
19
|
+
| Swift binding | `apple/` | A Swift package with props generated from the same contracts. iOS and macOS props sit behind `#if os(...)`. |
|
|
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
|
+
| 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. |
|
|
25
|
+
|
|
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).
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// tsconfig.json for an iOS app: "customConditions": ["ios"]
|
|
32
|
+
import type {SelectorProps} from '@astryxdesign/native/components';
|
|
33
|
+
|
|
34
|
+
const props: SelectorProps = {
|
|
35
|
+
label: 'Shipping',
|
|
36
|
+
options: [{value: 'standard', label: 'Standard'}],
|
|
37
|
+
menuStyle: 'pullDown', // iOS-only prop; an Android build rejects it
|
|
38
|
+
};
|
|
39
|
+
```
|
|
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
|
+
|
|
125
|
+
## Working on it
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
pnpm -F @astryxdesign/native typecheck # source and tests
|
|
129
|
+
pnpm -F @astryxdesign/native build # dist/, including platform types
|
|
130
|
+
pnpm -F @astryxdesign/native typecheck:types # every platform's types, after build
|
|
131
|
+
pnpm -F @astryxdesign/native generate:apple # regenerate apple/Sources/.../Generated
|
|
132
|
+
pnpm vitest run --project node packages/native
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Generated Swift is committed so a Swift package can pin a commit. A test fails
|
|
136
|
+
when it drifts from the contracts.
|
|
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
|
+
|
|
145
|
+
Boundaries, checked by `pnpm check:package-boundaries`:
|
|
146
|
+
|
|
147
|
+
- `@astryxdesign/core` never imports this package.
|
|
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.
|
|
165
|
+
|
|
166
|
+
## Experiment matrix
|
|
167
|
+
|
|
168
|
+
Every arm runs the same subjects on the same devices and is scored against a
|
|
169
|
+
**reference**: the same screens hand-built with the platform toolkit (SwiftUI,
|
|
170
|
+
Jetpack Compose, WinUI).
|
|
171
|
+
|
|
172
|
+
| Arm | How components are built | iOS | Android | macOS | Windows |
|
|
173
|
+
| ------------------------- | ---------------------------------------------------------------------------------------- | --- | ------- | ----- | ------- |
|
|
174
|
+
| A. Pure native | Platform views (SwiftUI, Compose, WinUI) on generated contracts | ✓ | ✓ | ✓ | ✓ |
|
|
175
|
+
| B. React Native | React Native components; desktop through `react-native-macos` and `react-native-windows` | ✓ | ✓ | ✓ | ✓ |
|
|
176
|
+
| C. Shared logic core | Component logic in TypeScript running in Hermes, driving platform views | ✓ | ✓ | ✓ | — |
|
|
177
|
+
| D. Web on native | Web React components through a native renderer, such as Expo's experimental fork | ✓ | ✓ | — | — |
|
|
178
|
+
| E. Web in a desktop shell | Astryx's web components unchanged inside Electron | — | — | ✓ | ✓ |
|
|
179
|
+
|
|
180
|
+
Arms D and E are measured but cannot become required runtimes as written:
|
|
181
|
+
arm D depends on a third-party fork and arm E on Electron, a third-party
|
|
182
|
+
runtime (AST-082 FR13). Arm E is the baseline for how far plain web gets on
|
|
183
|
+
desktop.
|
|
184
|
+
|
|
185
|
+
### Test subjects
|
|
186
|
+
|
|
187
|
+
Templates come first because their web version is a known reference for
|
|
188
|
+
content and states.
|
|
189
|
+
|
|
190
|
+
1. **Wave 1:** `checkout-wizard` (forms, stepper, pickers, validation, keyboard),
|
|
191
|
+
`table-inbox` (long list, row actions, search, compose sheet), `dashboard`
|
|
192
|
+
(charts, tables, scrolling).
|
|
193
|
+
2. **Wave 2:** `settings`, `kanban-board`, `ai-chat`, `product-detail`.
|
|
194
|
+
3. **Component flows:** Selector, text entry, dialog and sheet, list with row
|
|
195
|
+
actions.
|
|
196
|
+
|
|
197
|
+
Each subject has one scripted interaction that every arm replays.
|
|
198
|
+
|
|
199
|
+
Visual scores come from real screens. Every scripted step is captured as a
|
|
200
|
+
screenshot on the device, every behavior (sheet open and dismiss, navigation
|
|
201
|
+
transitions, gestures, scrolling, press feedback, keyboard) as a short video or
|
|
202
|
+
GIF, and every scenario as a recording, for each arm, the
|
|
203
|
+
reference, and the web version, in light and dark and at the largest text size.
|
|
204
|
+
Reviewers compare captures side by side with arm names hidden, and pixel checks
|
|
205
|
+
read colors and sizes from the captures, never from source.
|
|
206
|
+
|
|
207
|
+
### Metrics
|
|
208
|
+
|
|
209
|
+
| Area | Measure | How | Unit |
|
|
210
|
+
| --------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
|
|
211
|
+
| Gate | Required runtimes | Dependency manifest against FR13 | pass/fail |
|
|
212
|
+
| Gate | Screen-reader parity | VoiceOver, TalkBack, Narrator task script | pass/fail |
|
|
213
|
+
| Gate | Completeness | Every subject renders every state | pass/fail |
|
|
214
|
+
| Experience | Platform feel | Blind reviewer rating of captured screens and recordings against the reference, plus a platform-conventions checklist | score, % of checklist |
|
|
215
|
+
| Experience | Behavior and motion | Blind reviewer rating of behavior videos against the reference: timing, easing, gesture response, interruptibility | score per behavior |
|
|
216
|
+
| Experience | Time to adopt a new OS feature | Days from OS release to shipping it in the arm (for example, Liquid Glass) | days |
|
|
217
|
+
| Performance | Startup to first content | Release build, cold start, median of runs | ms |
|
|
218
|
+
| Performance | Smoothness | Dropped frames during the scripted interaction | % frames |
|
|
219
|
+
| Performance | Input latency | Touch or key to visible response | ms |
|
|
220
|
+
| Performance | Memory and size | Peak memory during the script; app download size | MB |
|
|
221
|
+
| Maintenance | Change cost | Time to ship one real Astryx change on the arm (a new prop, a new token) | hours |
|
|
222
|
+
| Developer speed | Iteration | Edit to visible on device | seconds |
|
|
223
|
+
| Developer speed | Sharing | Share of app code reused across platforms | % lines |
|
|
224
|
+
| Design | Brand preservation | Blind designer review of whether the brand is recognizable from the web version while the screen still feels native, plus pixel checks on the captures for the theme's color, type, shape, spacing, and icons | score, % token checks |
|
|
225
|
+
| Fidelity | Match to web | Content and states matching the web template | % checks |
|
|
226
|
+
|
|
227
|
+
### Judging
|
|
228
|
+
|
|
229
|
+
1. An arm that fails a gate is out for that platform.
|
|
230
|
+
2. The remaining arms are compared per platform, each measure relative to the
|
|
231
|
+
reference on the same device.
|
|
232
|
+
3. Whether the measures are weighted into one score or ranked side by side is
|
|
233
|
+
not decided yet.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
|
|
4
|
+
// Experimental Astryx for Apple platforms (AST-082). The contract types under
|
|
5
|
+
// Sources/AstryxNative/Generated are generated by `pnpm generate:apple`; do not
|
|
6
|
+
// edit them by hand.
|
|
7
|
+
|
|
8
|
+
import PackageDescription
|
|
9
|
+
|
|
10
|
+
let package = Package(
|
|
11
|
+
name: "AstryxNative",
|
|
12
|
+
platforms: [.iOS(.v17), .macOS(.v14)],
|
|
13
|
+
products: [.library(name: "AstryxNative", targets: ["AstryxNative"])],
|
|
14
|
+
targets: [
|
|
15
|
+
.target(name: "AstryxNative", path: "Sources/AstryxNative"),
|
|
16
|
+
.testTarget(name: "AstryxNativeTests", dependencies: ["AstryxNative"], path: "Tests/AstryxNativeTests"),
|
|
17
|
+
]
|
|
18
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum AstryxBaseTarget: String, Sendable { case root, trigger, control, container }
|
|
3
|
+
|
|
4
|
+
/// Base props shared by every platform (AST-082 FR7).
|
|
5
|
+
public struct AstryxBaseProps: Equatable, Codable, Sendable {
|
|
6
|
+
public var id: String?
|
|
7
|
+
public var isHidden: Bool?
|
|
8
|
+
public init(id: String? = nil, isHidden: Bool? = nil) {
|
|
9
|
+
self.id = id
|
|
10
|
+
self.isHidden = isHidden
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -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
|