@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.
Files changed (119) hide show
  1. package/README.md +116 -4
  2. package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +1 -1
  3. package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +69 -0
  4. package/apple/Sources/AstryxNative/Generated/AstryxWire.swift +67 -0
  5. package/apple/Sources/AstryxNative/Generated/Badge.swift +89 -0
  6. package/apple/Sources/AstryxNative/Generated/Button.swift +154 -0
  7. package/apple/Sources/AstryxNative/Generated/Card.swift +117 -0
  8. package/apple/Sources/AstryxNative/Generated/Divider.swift +97 -0
  9. package/apple/Sources/AstryxNative/Generated/HStack.swift +308 -0
  10. package/apple/Sources/AstryxNative/Generated/Heading.swift +169 -0
  11. package/apple/Sources/AstryxNative/Generated/ProgressBar.swift +144 -0
  12. package/apple/Sources/AstryxNative/Generated/Selector.swift +133 -9
  13. package/apple/Sources/AstryxNative/Generated/Switch.swift +202 -0
  14. package/apple/Sources/AstryxNative/Generated/Text.swift +172 -0
  15. package/apple/Sources/AstryxNative/Generated/TextInput.swift +243 -0
  16. package/apple/Sources/AstryxNative/Generated/VStack.swift +308 -0
  17. package/apple/Sources/AstryxNative/Logic/AstryxLogicHost.swift +102 -0
  18. package/apple/Tests/AstryxNativeTests/ControlPropsTests.swift +29 -0
  19. package/apple/Tests/AstryxNativeTests/LogicHostTests.swift +85 -0
  20. package/apple/Tests/AstryxNativeTests/WireTests.swift +53 -0
  21. package/dist/components/Badge.d.ts +10 -0
  22. package/dist/components/Badge.d.ts.map +1 -0
  23. package/dist/components/Badge.js +7 -0
  24. package/dist/components/Button.d.ts +10 -0
  25. package/dist/components/Button.d.ts.map +1 -0
  26. package/dist/components/Button.js +15 -0
  27. package/dist/components/Card.d.ts +10 -0
  28. package/dist/components/Card.d.ts.map +1 -0
  29. package/dist/components/Card.js +7 -0
  30. package/dist/components/Divider.d.ts +10 -0
  31. package/dist/components/Divider.d.ts.map +1 -0
  32. package/dist/components/Divider.js +6 -0
  33. package/dist/components/HStack.d.ts +10 -0
  34. package/dist/components/HStack.d.ts.map +1 -0
  35. package/dist/components/HStack.js +9 -0
  36. package/dist/components/Heading.d.ts +10 -0
  37. package/dist/components/Heading.d.ts.map +1 -0
  38. package/dist/components/Heading.js +14 -0
  39. package/dist/components/ProgressBar.d.ts +10 -0
  40. package/dist/components/ProgressBar.d.ts.map +1 -0
  41. package/dist/components/ProgressBar.js +5 -0
  42. package/dist/components/Switch.d.ts +10 -0
  43. package/dist/components/Switch.d.ts.map +1 -0
  44. package/dist/components/Switch.js +6 -0
  45. package/dist/components/Text.d.ts +10 -0
  46. package/dist/components/Text.d.ts.map +1 -0
  47. package/dist/components/Text.js +13 -0
  48. package/dist/components/TextInput.d.ts +10 -0
  49. package/dist/components/TextInput.d.ts.map +1 -0
  50. package/dist/components/TextInput.js +9 -0
  51. package/dist/components/VStack.d.ts +10 -0
  52. package/dist/components/VStack.d.ts.map +1 -0
  53. package/dist/components/VStack.js +9 -0
  54. package/dist/components/index.d.ts.map +1 -1
  55. package/dist/components/index.js +25 -1
  56. package/dist/components/stackShared.d.ts +9 -0
  57. package/dist/components/stackShared.d.ts.map +1 -0
  58. package/dist/components/stackShared.js +4 -0
  59. package/dist/contract/fromComponentDoc.d.ts +44 -5
  60. package/dist/contract/fromComponentDoc.d.ts.map +1 -1
  61. package/dist/contract/fromComponentDoc.js +47 -4
  62. package/dist/contract/generateSwift.d.ts.map +1 -1
  63. package/dist/contract/generateSwift.js +193 -10
  64. package/dist/contract/generateTypeScript.d.ts.map +1 -1
  65. package/dist/contract/generateTypeScript.js +69 -9
  66. package/dist/contract/index.d.ts +7 -3
  67. package/dist/contract/index.d.ts.map +1 -1
  68. package/dist/contract/index.js +2 -1
  69. package/dist/contract/parseDocType.d.ts +5 -2
  70. package/dist/contract/parseDocType.d.ts.map +1 -1
  71. package/dist/contract/parseDocType.js +34 -5
  72. package/dist/contract/rules.d.ts +5 -2
  73. package/dist/contract/rules.d.ts.map +1 -1
  74. package/dist/contract/rules.js +8 -4
  75. package/dist/contract/types.d.ts +11 -0
  76. package/dist/contract/types.d.ts.map +1 -1
  77. package/dist/logic/connectBridge.d.ts +29 -0
  78. package/dist/logic/connectBridge.d.ts.map +1 -0
  79. package/dist/logic/connectBridge.js +32 -0
  80. package/dist/logic/createLogicCore.d.ts +44 -0
  81. package/dist/logic/createLogicCore.d.ts.map +1 -0
  82. package/dist/logic/createLogicCore.js +40 -0
  83. package/dist/logic/index.d.ts +12 -0
  84. package/dist/logic/index.d.ts.map +1 -0
  85. package/dist/logic/index.js +10 -0
  86. package/dist/types/android.d.ts +136 -2
  87. package/dist/types/core.d.ts +150 -0
  88. package/dist/types/ios.d.ts +136 -2
  89. package/dist/types/macos.d.ts +136 -2
  90. package/dist/types/shared.d.ts +136 -2
  91. package/dist/types/windows.d.ts +136 -2
  92. package/package.json +10 -4
  93. package/src/components/Badge.ts +18 -0
  94. package/src/components/Button.ts +26 -0
  95. package/src/components/Card.ts +18 -0
  96. package/src/components/Divider.ts +17 -0
  97. package/src/components/HStack.ts +20 -0
  98. package/src/components/Heading.ts +25 -0
  99. package/src/components/ProgressBar.ts +16 -0
  100. package/src/components/Switch.ts +17 -0
  101. package/src/components/Text.ts +24 -0
  102. package/src/components/TextInput.ts +20 -0
  103. package/src/components/VStack.ts +20 -0
  104. package/src/components/index.ts +25 -1
  105. package/src/components/stackShared.ts +14 -0
  106. package/src/contract/contracts.test.ts +58 -0
  107. package/src/contract/fromComponentDoc.test.ts +97 -0
  108. package/src/contract/fromComponentDoc.ts +106 -9
  109. package/src/contract/generateSwift.ts +223 -10
  110. package/src/contract/generateTypeScript.ts +83 -10
  111. package/src/contract/index.ts +13 -4
  112. package/src/contract/parseDocType.test.ts +45 -0
  113. package/src/contract/parseDocType.ts +41 -6
  114. package/src/contract/rules.ts +11 -4
  115. package/src/contract/types.ts +6 -0
  116. package/src/logic/connectBridge.ts +72 -0
  117. package/src/logic/createLogicCore.ts +97 -0
  118. package/src/logic/index.ts +19 -0
  119. package/src/logic/logic.test.ts +160 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/HStack.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core HStack contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Stack documentation, which documents HStack
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const hStack: NativeAdditions;
10
+ //# sourceMappingURL=HStack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HStack.d.ts","sourceRoot":"","sources":["../../src/components/HStack.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,MAAM,EAAE,eAMpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import { STACK_SLOTS } from './stackShared.js';
3
+ export const hStack = {
4
+ name: 'HStack',
5
+ baseTarget: 'container',
6
+ doc: { file: 'Stack', component: 'HStack' },
7
+ slots: STACK_SLOTS,
8
+ sameMeaning: { children: "the component's content, as on the web" },
9
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/Heading.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core Heading contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Heading documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const heading: NativeAdditions;
10
+ //# sourceMappingURL=Heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Heading.d.ts","sourceRoot":"","sources":["../../src/components/Heading.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,OAAO,EAAE,eAYrB,CAAC"}
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const heading = {
3
+ name: 'Heading',
4
+ baseTarget: 'root',
5
+ doc: { file: 'Text/Heading' },
6
+ slots: { children: 'text' },
7
+ sameMeaning: { children: "the component's content, as on the web" },
8
+ webOnly: {
9
+ display: 'CSS display; native layout places text by its container',
10
+ wordBreak: 'CSS line breaking; native text breaks by platform rules',
11
+ textWrap: 'CSS text wrapping; native text wraps by platform rules',
12
+ hasCapsize: 'web text-box trimming of CSS line height',
13
+ },
14
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/ProgressBar.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core ProgressBar contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * ProgressBar documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const progressBar: NativeAdditions;
10
+ //# sourceMappingURL=ProgressBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["../../src/components/ProgressBar.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,WAAW,EAAE,eAGzB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const progressBar = {
3
+ name: 'ProgressBar',
4
+ baseTarget: 'root',
5
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/Switch.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core Switch contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Switch documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const switchControl: NativeAdditions;
10
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,aAAa,EAAE,eAI3B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const switchControl = {
3
+ name: 'Switch',
4
+ // The web Switch forwards base props to its root wrapper.
5
+ baseTarget: 'root',
6
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/Text.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core Text contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Text documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const text: NativeAdditions;
10
+ //# sourceMappingURL=Text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/components/Text.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,IAAI,EAAE,eAWlB,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const text = {
3
+ name: 'Text',
4
+ baseTarget: 'root',
5
+ slots: { children: 'text' },
6
+ sameMeaning: { children: "the component's content, as on the web" },
7
+ webOnly: {
8
+ display: 'CSS display; native layout places text by its container',
9
+ wordBreak: 'CSS line breaking; native text breaks by platform rules',
10
+ textWrap: 'CSS text wrapping; native text wraps by platform rules',
11
+ hasCapsize: 'web text-box trimming of CSS line height',
12
+ },
13
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/TextInput.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core TextInput contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * TextInput documentation
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const textInput: NativeAdditions;
10
+ //# sourceMappingURL=TextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/components/TextInput.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,SAAS,EAAE,eAOvB,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const textInput = {
3
+ name: 'TextInput',
4
+ // family:input-fields routes base props to the primary semantic control.
5
+ baseTarget: 'control',
6
+ webOnly: {
7
+ autoComplete: 'HTML autocomplete attribute',
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file components/VStack.ts
3
+ * @input None
4
+ * @output What @astryxdesign/native adds to the core VStack contract
5
+ * @position Native additions read by fromComponentDoc together with core's
6
+ * Stack documentation, which documents VStack
7
+ */
8
+ import type { NativeAdditions } from '../contract/fromComponentDoc.js';
9
+ export declare const vStack: NativeAdditions;
10
+ //# sourceMappingURL=VStack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VStack.d.ts","sourceRoot":"","sources":["../../src/components/VStack.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,MAAM,EAAE,eAMpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import { STACK_SLOTS } from './stackShared.js';
3
+ export const vStack = {
4
+ name: 'VStack',
5
+ baseTarget: 'container',
6
+ doc: { file: 'Stack', component: 'VStack' },
7
+ slots: STACK_SLOTS,
8
+ sameMeaning: { children: "the component's content, as on the web" },
9
+ };
@@ -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;AAGrE,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAAe,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,3 +1,27 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import { badge } from './Badge.js';
3
+ import { button } from './Button.js';
4
+ import { card } from './Card.js';
5
+ import { divider } from './Divider.js';
6
+ import { heading } from './Heading.js';
7
+ import { hStack } from './HStack.js';
8
+ import { progressBar } from './ProgressBar.js';
2
9
  import { selector } from './Selector.js';
3
- export const NATIVE_COMPONENTS = [selector];
10
+ import { switchControl } from './Switch.js';
11
+ import { text } from './Text.js';
12
+ import { textInput } from './TextInput.js';
13
+ import { vStack } from './VStack.js';
14
+ export const NATIVE_COMPONENTS = [
15
+ badge,
16
+ button,
17
+ card,
18
+ divider,
19
+ heading,
20
+ hStack,
21
+ progressBar,
22
+ selector,
23
+ switchControl,
24
+ text,
25
+ textInput,
26
+ vStack,
27
+ ];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file components/stackShared.ts
3
+ * @input None
4
+ * @output The slot declarations HStack and VStack share
5
+ * @position Read by components/HStack.ts and components/VStack.ts
6
+ */
7
+ import type { SlotKind } from '../contract/fromComponentDoc.js';
8
+ export declare const STACK_SLOTS: Readonly<Record<string, SlotKind>>;
9
+ //# sourceMappingURL=stackShared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stackShared.d.ts","sourceRoot":"","sources":["../../src/components/stackShared.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,iCAAiC,CAAC;AAE9D,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAE1D,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ export const STACK_SLOTS = {
3
+ children: 'content',
4
+ };
@@ -1,19 +1,57 @@
1
1
  import type { BaseTarget, ComponentContract, PropMap } from './types.js';
2
2
  import type { NativePlatform } from '../platforms.js';
3
- /** The subset of a ComponentDoc this reader needs. */
3
+ interface DocProp {
4
+ readonly name: string;
5
+ readonly type?: unknown;
6
+ readonly required?: boolean;
7
+ readonly description?: unknown;
8
+ }
9
+ /**
10
+ * The subset of a ComponentDoc this reader needs. A file that documents
11
+ * several components, such as Stack with HStack and VStack, lists them in
12
+ * `components`.
13
+ */
4
14
  export interface ComponentDocLike {
5
15
  readonly name: string;
6
- readonly props?: ReadonlyArray<{
16
+ readonly props?: ReadonlyArray<DocProp>;
17
+ readonly components?: ReadonlyArray<{
7
18
  readonly name: string;
8
- readonly type?: unknown;
9
- readonly required?: boolean;
10
- readonly description?: unknown;
19
+ readonly props?: ReadonlyArray<DocProp>;
11
20
  }>;
12
21
  }
22
+ /**
23
+ * Typed slots (AST-082 FR4) for documented free-form content. `text` is a
24
+ * string in the core contract, as a badge's label or a heading's words;
25
+ * `content` is child Astryx components, as a stack's or a card's children.
26
+ */
27
+ export type SlotKind = 'text' | 'content';
13
28
  /** What the native package adds to one core component. */
14
29
  export interface NativeAdditions {
15
30
  readonly name: string;
16
31
  readonly baseTarget: BaseTarget;
32
+ /**
33
+ * Where core documents the component when it is not `<Name>/<Name>.doc.mjs`:
34
+ * `file` relative to core's `src` without `.doc.mjs`, and `component` when
35
+ * the file documents several components.
36
+ */
37
+ readonly doc?: {
38
+ readonly file: string;
39
+ readonly component?: string;
40
+ };
41
+ /** Documented free-form content props, given a typed slot in the core. */
42
+ readonly slots?: Readonly<Record<string, SlotKind>>;
43
+ /**
44
+ * Callbacks whose only documented argument is a DOM event but which name a
45
+ * moment every platform has, such as a button's press. Their core form
46
+ * takes no arguments.
47
+ */
48
+ readonly callbacks?: readonly string[];
49
+ /**
50
+ * Core props whose name a platform toolkit also uses, with the same meaning
51
+ * (AST-082 FR8 forbids only a different meaning), and why: a button's
52
+ * `onClick` is a press in Compose too.
53
+ */
54
+ readonly sameMeaning?: Readonly<Record<string, string>>;
17
55
  /**
18
56
  * Portable definitions for named types the documentation references. Fields
19
57
  * the web type has that are not portable are left out on purpose.
@@ -29,4 +67,5 @@ export interface NativeAdditions {
29
67
  readonly webOnly?: Readonly<Record<string, string>>;
30
68
  }
31
69
  export declare function fromComponentDoc(doc: ComponentDocLike, additions: NativeAdditions): ComponentContract;
70
+ export {};
32
71
  //# sourceMappingURL=fromComponentDoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fromComponentDoc.d.ts","sourceRoot":"","sources":["../../src/contract/fromComponentDoc.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,OAAO,EAGR,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC,CAAC;CACJ;AAED,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MA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AM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAyBD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,gBAAgB,EACrB,SAAS,EAAE,eAAe,GACzB,iBAAiB,CA8GnB"}
@@ -10,11 +10,33 @@
10
10
  */
11
11
  import { parseDocType } from './parseDocType.js';
12
12
  import { coreNameProblem } from './rules.js';
13
+ /** The documented props of the component the additions name. */
14
+ function documentedProps(doc, additions) {
15
+ const wanted = additions.doc?.component;
16
+ if (wanted == null) {
17
+ return doc.props ?? [];
18
+ }
19
+ const entry = doc.components?.find(component => component.name === wanted);
20
+ if (!entry) {
21
+ throw new Error(`${additions.name}: core documentation "${doc.name}" does not document "${wanted}"`);
22
+ }
23
+ return entry.props ?? [];
24
+ }
25
+ const SLOT_TYPES = {
26
+ text: { kind: 'string' },
27
+ content: { kind: 'content' },
28
+ };
13
29
  export function fromComponentDoc(doc, additions) {
14
30
  const core = {};
15
31
  const webOnly = [];
16
32
  const types = additions.types ?? {};
17
- for (const prop of doc.props ?? []) {
33
+ const describe = (prop) => typeof prop.description === 'string' ? { doc: prop.description } : {};
34
+ for (const prop of documentedProps(doc, additions)) {
35
+ // `id` and `isHidden` are shared base props on every platform (FR7), so a
36
+ // documented prop of either name is the base prop, not a core prop.
37
+ if (prop.name === 'id' || prop.name === 'isHidden') {
38
+ continue;
39
+ }
18
40
  const declaredWebOnly = additions.webOnly?.[prop.name];
19
41
  if (declaredWebOnly) {
20
42
  webOnly.push({ name: prop.name, reason: declaredWebOnly });
@@ -29,13 +51,33 @@ export function fromComponentDoc(doc, additions) {
29
51
  webOnly.push({ name: prop.name, reason: 'HTML attribute' });
30
52
  continue;
31
53
  }
32
- const parsed = parseDocType(String(prop.type ?? ''));
54
+ const slot = additions.slots?.[prop.name];
55
+ const slotNameProblem = slot &&
56
+ coreNameProblem(prop.name, prop.name in (additions.sameMeaning ?? {}));
57
+ if (slotNameProblem) {
58
+ webOnly.push({ name: prop.name, reason: slotNameProblem });
59
+ continue;
60
+ }
61
+ if (slot) {
62
+ core[prop.name] = {
63
+ type: SLOT_TYPES[slot],
64
+ optional: prop.required !== true,
65
+ ...describe(prop),
66
+ };
67
+ continue;
68
+ }
69
+ let parsed = parseDocType(String(prop.type ?? ''));
70
+ if (!parsed.ok &&
71
+ parsed.eventOnly === true &&
72
+ additions.callbacks?.includes(prop.name)) {
73
+ parsed = { ok: true, type: { kind: 'fn', args: [] } };
74
+ }
33
75
  if (!parsed.ok) {
34
76
  webOnly.push({ name: prop.name, reason: parsed.reason });
35
77
  continue;
36
78
  }
37
79
  // A portable type can still carry a name another platform owns.
38
- const nameProblem = coreNameProblem(prop.name);
80
+ const nameProblem = coreNameProblem(prop.name, prop.name in (additions.sameMeaning ?? {}));
39
81
  if (nameProblem) {
40
82
  webOnly.push({ name: prop.name, reason: nameProblem });
41
83
  continue;
@@ -67,7 +109,7 @@ export function fromComponentDoc(doc, additions) {
67
109
  core[prop.name] = {
68
110
  type,
69
111
  optional: prop.required !== true,
70
- ...(typeof prop.description === 'string' ? { doc: prop.description } : {}),
112
+ ...describe(prop),
71
113
  };
72
114
  }
73
115
  return {
@@ -77,5 +119,6 @@ export function fromComponentDoc(doc, additions) {
77
119
  core,
78
120
  platforms: additions.platforms ?? {},
79
121
  webOnly,
122
+ sameMeaning: Object.keys(additions.sameMeaning ?? {}).filter(name => name in core),
80
123
  };
81
124
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateSwift.d.ts","sourceRoot":"","sources":["../../src/contract/generateSwift.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAoJrE,6EAA6E;AAC7E,wBAAgB,aAAa,CAC3B,SAAS,EAAE,SAAS,iBAAiB,EAAE,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB"}
1
+ {"version":3,"file":"generateSwift.d.ts","sourceRoot":"","sources":["../../src/contract/generateSwift.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAiWrE,6EAA6E;AAC7E,wBAAgB,aAAa,CAC3B,SAAS,EAAE,SAAS,iBAAiB,EAAE,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUxB"}