@astryxdesign/native 0.7.5-canary.c60f571 → 0.7.5-canary.d76a228

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 CHANGED
@@ -22,9 +22,9 @@ rests on evidence.
22
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
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
24
 
25
- Contracts cover Button, Card, Divider, Heading, HStack, ProgressBar, Selector,
26
- Switch, Text, TextInput, and VStack. React Native and Android bindings are not built yet; see
27
- [the experiment matrix](#experiment-matrix).
25
+ Contracts cover Badge, Button, Card, Divider, Heading, HStack, ProgressBar,
26
+ Selector, Switch, Text, TextInput, and VStack. React Native and Android
27
+ bindings are not built yet; see [the experiment matrix](#experiment-matrix).
28
28
 
29
29
  ```ts
30
30
  // tsconfig.json for an iOS app: "customConditions": ["ios"]
@@ -124,7 +124,9 @@ const bridge = connectBridge(core, {
124
124
  ## Working on it
125
125
 
126
126
  ```sh
127
+ pnpm -F @astryxdesign/native typecheck # source and tests
127
128
  pnpm -F @astryxdesign/native build # dist/, including platform types
129
+ pnpm -F @astryxdesign/native typecheck:types # every platform's types, after build
128
130
  pnpm -F @astryxdesign/native generate:apple # regenerate apple/Sources/.../Generated
129
131
  pnpm vitest run --project node packages/native
130
132
  ```
@@ -7,6 +7,7 @@ import Foundation
7
7
  /// or a known one with a value its enums lack or a required prop missing. An older
8
8
  /// app then keeps drawing the rest of a newer core's tree.
9
9
  public enum AstryxNode: Decodable, Equatable, Sendable {
10
+ case badge(BadgeNode)
10
11
  case button(ButtonNode)
11
12
  case card(CardNode)
12
13
  case divider(DividerNode)
@@ -22,6 +23,7 @@ public enum AstryxNode: Decodable, Equatable, Sendable {
22
23
 
23
24
  public var key: String {
24
25
  switch self {
26
+ case .badge(let node): return node.key
25
27
  case .button(let node): return node.key
26
28
  case .card(let node): return node.key
27
29
  case .divider(let node): return node.key
@@ -45,6 +47,7 @@ public enum AstryxNode: Decodable, Equatable, Sendable {
45
47
  let key = try container.decode(String.self, forKey: .key)
46
48
  do {
47
49
  switch component {
50
+ case "Badge": self = .badge(try BadgeNode(from: decoder))
48
51
  case "Button": self = .button(try ButtonNode(from: decoder))
49
52
  case "Card": self = .card(try CardNode(from: decoder))
50
53
  case "Divider": self = .divider(try DividerNode(from: decoder))
@@ -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
@@ -15,6 +15,8 @@ import Testing
15
15
  let heading = HeadingProps(level: .v2, children: "Orders")
16
16
  #expect(heading.level.rawValue == 2)
17
17
  #expect(heading.children == "Orders")
18
+ let badge = BadgeProps(variant: .success, label: "Paid")
19
+ #expect(badge.label == "Paid")
18
20
  let divider = DividerProps(label: "Or")
19
21
  #expect(divider.label == "Or")
20
22
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/Badge.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core Badge contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Badge documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const badge: NativeAdditions;
10
+ //# sourceMappingURL=Badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,KAAK,EAAE,eAKnB,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const badge = {
3
+ name: 'Badge',
4
+ baseTarget: 'root',
5
+ // `icon` stays web-only until the core has an icon slot.
6
+ slots: { label: 'text' },
7
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAarE,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAYvD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAcrE,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAavD,CAAC"}
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import { badge } from './Badge.js';
2
3
  import { button } from './Button.js';
3
4
  import { card } from './Card.js';
4
5
  import { divider } from './Divider.js';
@@ -11,6 +12,7 @@ import { text } from './Text.js';
11
12
  import { textInput } from './TextInput.js';
12
13
  import { vStack } from './VStack.js';
13
14
  export const NATIVE_COMPONENTS = [
15
+ badge,
14
16
  button,
15
17
  card,
16
18
  divider,
@@ -1,6 +1,9 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- import type {AstryxSharedBaseProps, SelectorOption, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
- export type {AstryxSharedBaseProps, AstryxContentNode, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
2
+ import type {AstryxSharedBaseProps, SelectorOption, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
+ export type {AstryxSharedBaseProps, AstryxContentNode, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
4
+ /** Badge props: core contract plus the android contract. */
5
+ export interface BadgeProps extends BadgeCoreProps {}
6
+ export declare function Badge(props: BadgeProps): unknown;
4
7
  /** Button props: core contract plus the android contract. */
5
8
  export interface ButtonProps extends ButtonCoreProps {}
6
9
  export declare function Button(props: ButtonProps): unknown;
@@ -36,6 +39,13 @@ export declare function TextInput(props: TextInputProps): unknown;
36
39
  /** VStack props: core contract plus the android contract. */
37
40
  export interface VStackProps extends VStackCoreProps {}
38
41
  export declare function VStack(props: VStackProps): unknown;
42
+ /** Badge as JSON from a TypeScript core. */
43
+ export interface BadgeNode {
44
+ component: 'Badge';
45
+ key: string;
46
+ base?: AstryxSharedBaseProps;
47
+ props: {variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'; label: string;};
48
+ }
39
49
  /** Button as JSON from a TypeScript core. */
40
50
  export interface ButtonNode {
41
51
  component: 'Button';
@@ -122,7 +132,7 @@ export interface VStackNode {
122
132
  props: {gap?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; padding?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInline?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlock?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; isScrollable?: boolean; hAlign?: 'start' | 'center' | 'end' | 'stretch'; vAlign?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; align?: 'start' | 'center' | 'end' | 'stretch'; wrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; children?: ReadonlyArray<AstryxNode>;};
123
133
  }
124
134
  /** Any Astryx component a TypeScript core can send. */
125
- export type AstryxNode = ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
135
+ export type AstryxNode = BadgeNode | ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
126
136
  /** A callback a native view called, sent back to the core. */
127
137
  export type AstryxAction =
128
138
  | {key: string; component: 'Button'; event: 'onClick'; args: []}
@@ -15,6 +15,11 @@ export interface SelectorOption {
15
15
  disabled?: boolean;
16
16
  }
17
17
  /** Core contract. Base props attach to the root. */
18
+ export interface BadgeCoreProps extends AstryxSharedBaseProps {
19
+ variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow';
20
+ label: string;
21
+ }
22
+ /** Core contract. Base props attach to the root. */
18
23
  export interface ButtonCoreProps extends AstryxSharedBaseProps {
19
24
  label: string;
20
25
  variant?: 'primary' | 'secondary' | 'ghost' | 'destructive';
@@ -1,6 +1,9 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- import type {AstryxSharedBaseProps, SelectorOption, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
- export type {AstryxSharedBaseProps, AstryxContentNode, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
2
+ import type {AstryxSharedBaseProps, SelectorOption, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
+ export type {AstryxSharedBaseProps, AstryxContentNode, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
4
+ /** Badge props: core contract plus the ios contract. */
5
+ export interface BadgeProps extends BadgeCoreProps {}
6
+ export declare function Badge(props: BadgeProps): unknown;
4
7
  /** Button props: core contract plus the ios contract. */
5
8
  export interface ButtonProps extends ButtonCoreProps {}
6
9
  export declare function Button(props: ButtonProps): unknown;
@@ -36,6 +39,13 @@ export declare function TextInput(props: TextInputProps): unknown;
36
39
  /** VStack props: core contract plus the ios contract. */
37
40
  export interface VStackProps extends VStackCoreProps {}
38
41
  export declare function VStack(props: VStackProps): unknown;
42
+ /** Badge as JSON from a TypeScript core. */
43
+ export interface BadgeNode {
44
+ component: 'Badge';
45
+ key: string;
46
+ base?: AstryxSharedBaseProps;
47
+ props: {variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'; label: string;};
48
+ }
39
49
  /** Button as JSON from a TypeScript core. */
40
50
  export interface ButtonNode {
41
51
  component: 'Button';
@@ -122,7 +132,7 @@ export interface VStackNode {
122
132
  props: {gap?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; padding?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInline?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlock?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; isScrollable?: boolean; hAlign?: 'start' | 'center' | 'end' | 'stretch'; vAlign?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; align?: 'start' | 'center' | 'end' | 'stretch'; wrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; children?: ReadonlyArray<AstryxNode>;};
123
133
  }
124
134
  /** Any Astryx component a TypeScript core can send. */
125
- export type AstryxNode = ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
135
+ export type AstryxNode = BadgeNode | ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
126
136
  /** A callback a native view called, sent back to the core. */
127
137
  export type AstryxAction =
128
138
  | {key: string; component: 'Button'; event: 'onClick'; args: []}
@@ -1,6 +1,9 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- import type {AstryxSharedBaseProps, SelectorOption, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
- export type {AstryxSharedBaseProps, AstryxContentNode, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
2
+ import type {AstryxSharedBaseProps, SelectorOption, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
+ export type {AstryxSharedBaseProps, AstryxContentNode, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
4
+ /** Badge props: core contract plus the macos contract. */
5
+ export interface BadgeProps extends BadgeCoreProps {}
6
+ export declare function Badge(props: BadgeProps): unknown;
4
7
  /** Button props: core contract plus the macos contract. */
5
8
  export interface ButtonProps extends ButtonCoreProps {}
6
9
  export declare function Button(props: ButtonProps): unknown;
@@ -36,6 +39,13 @@ export declare function TextInput(props: TextInputProps): unknown;
36
39
  /** VStack props: core contract plus the macos contract. */
37
40
  export interface VStackProps extends VStackCoreProps {}
38
41
  export declare function VStack(props: VStackProps): unknown;
42
+ /** Badge as JSON from a TypeScript core. */
43
+ export interface BadgeNode {
44
+ component: 'Badge';
45
+ key: string;
46
+ base?: AstryxSharedBaseProps;
47
+ props: {variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'; label: string;};
48
+ }
39
49
  /** Button as JSON from a TypeScript core. */
40
50
  export interface ButtonNode {
41
51
  component: 'Button';
@@ -122,7 +132,7 @@ export interface VStackNode {
122
132
  props: {gap?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; padding?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInline?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlock?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; isScrollable?: boolean; hAlign?: 'start' | 'center' | 'end' | 'stretch'; vAlign?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; align?: 'start' | 'center' | 'end' | 'stretch'; wrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; children?: ReadonlyArray<AstryxNode>;};
123
133
  }
124
134
  /** Any Astryx component a TypeScript core can send. */
125
- export type AstryxNode = ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
135
+ export type AstryxNode = BadgeNode | ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
126
136
  /** A callback a native view called, sent back to the core. */
127
137
  export type AstryxAction =
128
138
  | {key: string; component: 'Button'; event: 'onClick'; args: []}
@@ -1,6 +1,9 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- import type {AstryxSharedBaseProps, SelectorOption, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
- export type {AstryxSharedBaseProps, AstryxContentNode, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
2
+ import type {AstryxSharedBaseProps, SelectorOption, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
+ export type {AstryxSharedBaseProps, AstryxContentNode, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
4
+ /** Badge props: core contract only. */
5
+ export interface BadgeProps extends BadgeCoreProps {}
6
+ export declare function Badge(props: BadgeProps): unknown;
4
7
  /** Button props: core contract only. */
5
8
  export interface ButtonProps extends ButtonCoreProps {}
6
9
  export declare function Button(props: ButtonProps): unknown;
@@ -34,6 +37,13 @@ export declare function TextInput(props: TextInputProps): unknown;
34
37
  /** VStack props: core contract only. */
35
38
  export interface VStackProps extends VStackCoreProps {}
36
39
  export declare function VStack(props: VStackProps): unknown;
40
+ /** Badge as JSON from a TypeScript core. */
41
+ export interface BadgeNode {
42
+ component: 'Badge';
43
+ key: string;
44
+ base?: AstryxSharedBaseProps;
45
+ props: {variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'; label: string;};
46
+ }
37
47
  /** Button as JSON from a TypeScript core. */
38
48
  export interface ButtonNode {
39
49
  component: 'Button';
@@ -120,7 +130,7 @@ export interface VStackNode {
120
130
  props: {gap?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; padding?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInline?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlock?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; isScrollable?: boolean; hAlign?: 'start' | 'center' | 'end' | 'stretch'; vAlign?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; align?: 'start' | 'center' | 'end' | 'stretch'; wrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; children?: ReadonlyArray<AstryxNode>;};
121
131
  }
122
132
  /** Any Astryx component a TypeScript core can send. */
123
- export type AstryxNode = ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
133
+ export type AstryxNode = BadgeNode | ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
124
134
  /** A callback a native view called, sent back to the core. */
125
135
  export type AstryxAction =
126
136
  | {key: string; component: 'Button'; event: 'onClick'; args: []}
@@ -1,6 +1,9 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- import type {AstryxSharedBaseProps, SelectorOption, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
- export type {AstryxSharedBaseProps, AstryxContentNode, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
2
+ import type {AstryxSharedBaseProps, SelectorOption, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
3
+ export type {AstryxSharedBaseProps, AstryxContentNode, BadgeCoreProps, ButtonCoreProps, CardCoreProps, DividerCoreProps, HeadingCoreProps, HStackCoreProps, ProgressBarCoreProps, SelectorOption, SelectorCoreProps, SwitchCoreProps, TextCoreProps, TextInputCoreProps, VStackCoreProps} from './core.js';
4
+ /** Badge props: core contract plus the windows contract. */
5
+ export interface BadgeProps extends BadgeCoreProps {}
6
+ export declare function Badge(props: BadgeProps): unknown;
4
7
  /** Button props: core contract plus the windows contract. */
5
8
  export interface ButtonProps extends ButtonCoreProps {}
6
9
  export declare function Button(props: ButtonProps): unknown;
@@ -34,6 +37,13 @@ export declare function TextInput(props: TextInputProps): unknown;
34
37
  /** VStack props: core contract plus the windows contract. */
35
38
  export interface VStackProps extends VStackCoreProps {}
36
39
  export declare function VStack(props: VStackProps): unknown;
40
+ /** Badge as JSON from a TypeScript core. */
41
+ export interface BadgeNode {
42
+ component: 'Badge';
43
+ key: string;
44
+ base?: AstryxSharedBaseProps;
45
+ props: {variant?: 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'blue' | 'cyan' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'; label: string;};
46
+ }
37
47
  /** Button as JSON from a TypeScript core. */
38
48
  export interface ButtonNode {
39
49
  component: 'Button';
@@ -120,7 +130,7 @@ export interface VStackNode {
120
130
  props: {gap?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; padding?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInline?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingInlineEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlock?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockStart?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; paddingBlockEnd?: 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10; isScrollable?: boolean; hAlign?: 'start' | 'center' | 'end' | 'stretch'; vAlign?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'; align?: 'start' | 'center' | 'end' | 'stretch'; wrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; children?: ReadonlyArray<AstryxNode>;};
121
131
  }
122
132
  /** Any Astryx component a TypeScript core can send. */
123
- export type AstryxNode = ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
133
+ export type AstryxNode = BadgeNode | ButtonNode | CardNode | DividerNode | HeadingNode | HStackNode | ProgressBarNode | SelectorNode | SwitchNode | TextNode | TextInputNode | VStackNode;
124
134
  /** A callback a native view called, sent back to the core. */
125
135
  export type AstryxAction =
126
136
  | {key: string; component: 'Button'; event: 'onClick'; args: []}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/native",
3
- "version": "0.7.5-canary.c60f571",
3
+ "version": "0.7.5-canary.d76a228",
4
4
  "description": "Experimental native platforms for Astryx (iOS, Android, macOS, Windows) — published to npm only under the @canary dist-tag; never released as a stable (latest) version.",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -69,15 +69,16 @@
69
69
  }
70
70
  },
71
71
  "peerDependencies": {
72
- "@astryxdesign/core": "0.7.5-canary.c60f571"
72
+ "@astryxdesign/core": "0.7.5-canary.d76a228"
73
73
  },
74
74
  "devDependencies": {
75
- "@astryxdesign/core": "0.7.5-canary.c60f571"
75
+ "@astryxdesign/core": "0.7.5-canary.d76a228"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "node ../../scripts/clean-dist.mjs && tsc --project tsconfig.build.json && node scripts/generate.mjs --types",
79
79
  "generate:apple": "pnpm build && node scripts/generate.mjs --apple",
80
80
  "test": "vitest run --root ../.. packages/native",
81
- "typecheck": "tsc --project tsconfig.json --noEmit"
81
+ "typecheck": "tsc --project tsconfig.json --noEmit",
82
+ "typecheck:types": "tsc --project tsconfig.types.json"
82
83
  }
83
84
  }
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file components/Badge.ts
5
+ * @input None
6
+ * @output What @astryxdesign/native adds to the core Badge contract
7
+ * @position Native additions read by fromComponentDoc together with core's
8
+ * Badge documentation
9
+ */
10
+
11
+ import type {NativeAdditions} from '../contract/fromComponentDoc.js';
12
+
13
+ export const badge: NativeAdditions = {
14
+ name: 'Badge',
15
+ baseTarget: 'root',
16
+ // `icon` stays web-only until the core has an icon slot.
17
+ slots: {label: 'text'},
18
+ };
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {NativeAdditions} from '../contract/fromComponentDoc.js';
12
+ import {badge} from './Badge.js';
12
13
  import {button} from './Button.js';
13
14
  import {card} from './Card.js';
14
15
  import {divider} from './Divider.js';
@@ -22,6 +23,7 @@ import {textInput} from './TextInput.js';
22
23
  import {vStack} from './VStack.js';
23
24
 
24
25
  export const NATIVE_COMPONENTS: readonly NativeAdditions[] = [
26
+ badge,
25
27
  button,
26
28
  card,
27
29
  divider,
@@ -76,6 +76,13 @@ describe('native contracts', () => {
76
76
  values: [1, 2, 3, 4, 5, 6],
77
77
  });
78
78
  expect(byName.get('Text')!.core).not.toHaveProperty('id');
79
+ expect(byName.get('Badge')!.core.label).toMatchObject({
80
+ type: {kind: 'string'},
81
+ optional: false,
82
+ });
83
+ expect(byName.get('Badge')!.webOnly.map(prop => prop.name)).toContain(
84
+ 'icon',
85
+ );
79
86
  });
80
87
 
81
88
  it('reports naming and portability errors', () => {