@seed-design/figma 0.0.21 → 0.0.23

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 (81) hide show
  1. package/lib/codegen/index.cjs +8012 -0
  2. package/lib/codegen/index.d.ts +1828 -0
  3. package/lib/codegen/index.js +7983 -0
  4. package/lib/codegen/targets/react/index.cjs +12198 -0
  5. package/lib/codegen/targets/react/index.d.ts +267 -0
  6. package/lib/codegen/targets/react/index.js +12180 -0
  7. package/lib/index.cjs +79 -2741
  8. package/lib/index.d.ts +17 -1937
  9. package/lib/index.js +61 -2715
  10. package/package.json +12 -2
  11. package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
  12. package/src/codegen/core/codegen.ts +17 -6
  13. package/src/codegen/core/{component.ts → component-handler.ts} +3 -3
  14. package/src/codegen/core/component-type-helper.ts +35 -0
  15. package/src/codegen/core/index.ts +14 -14
  16. package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
  17. package/src/codegen/core/{value.ts → value-resolver.ts} +87 -50
  18. package/src/codegen/default-services.ts +44 -0
  19. package/src/codegen/index.ts +1 -44
  20. package/src/codegen/targets/figma/frame.ts +8 -8
  21. package/src/codegen/targets/figma/index.ts +1 -1
  22. package/src/codegen/targets/figma/pipeline.ts +94 -0
  23. package/src/codegen/targets/figma/props.ts +59 -70
  24. package/src/codegen/targets/figma/shape.ts +18 -18
  25. package/src/codegen/targets/figma/text.ts +6 -6
  26. package/src/codegen/targets/figma/value-resolver.ts +19 -0
  27. package/src/codegen/targets/react/component/deps.interface.ts +5 -4
  28. package/src/codegen/targets/react/component/{transformers → handlers}/action-button.ts +8 -14
  29. package/src/codegen/targets/react/component/{transformers → handlers}/action-chip.ts +10 -20
  30. package/src/codegen/targets/react/component/{transformers → handlers}/action-sheet.ts +13 -10
  31. package/src/codegen/targets/react/component/{transformers → handlers}/app-bar.ts +28 -36
  32. package/src/codegen/targets/react/component/handlers/avatar-stack.ts +29 -0
  33. package/src/codegen/targets/react/component/{transformers → handlers}/avatar.ts +12 -9
  34. package/src/codegen/targets/react/component/handlers/badge.ts +18 -0
  35. package/src/codegen/targets/react/component/{transformers → handlers}/callout.ts +6 -8
  36. package/src/codegen/targets/react/component/{transformers → handlers}/checkbox.ts +5 -5
  37. package/src/codegen/targets/react/component/{transformers → handlers}/chip-tabs.ts +10 -10
  38. package/src/codegen/targets/react/component/{transformers → handlers}/control-chip.ts +10 -20
  39. package/src/codegen/targets/react/component/{transformers → handlers}/error-state.ts +9 -9
  40. package/src/codegen/targets/react/component/{transformers → handlers}/extended-action-sheet.ts +16 -18
  41. package/src/codegen/targets/react/component/{transformers → handlers}/extended-fab.ts +6 -6
  42. package/src/codegen/targets/react/component/handlers/fab.ts +18 -0
  43. package/src/codegen/targets/react/component/{transformers → handlers}/help-bubble.ts +5 -5
  44. package/src/codegen/targets/react/component/{transformers → handlers}/identity-placeholder.ts +5 -5
  45. package/src/codegen/targets/react/component/{transformers → handlers}/inline-banner.ts +7 -10
  46. package/src/codegen/targets/react/component/{transformers → handlers}/manner-temp-badge.ts +5 -5
  47. package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts +5 -5
  48. package/src/codegen/targets/react/component/{transformers → handlers}/progress-circle.ts +5 -5
  49. package/src/codegen/targets/react/component/{transformers → handlers}/reaction-button.ts +6 -6
  50. package/src/codegen/targets/react/component/{transformers → handlers}/segmented-control.ts +10 -10
  51. package/src/codegen/targets/react/component/{transformers → handlers}/select-box.ts +10 -10
  52. package/src/codegen/targets/react/component/handlers/skeleton.ts +25 -0
  53. package/src/codegen/targets/react/component/{transformers → handlers}/snackbar.ts +5 -5
  54. package/src/codegen/targets/react/component/{transformers → handlers}/switch.ts +5 -5
  55. package/src/codegen/targets/react/component/{transformers → handlers}/tabs.ts +15 -15
  56. package/src/codegen/targets/react/component/{transformers → handlers}/text-button.ts +7 -13
  57. package/src/codegen/targets/react/component/{transformers → handlers}/text-field.ts +9 -9
  58. package/src/codegen/targets/react/component/{transformers → handlers}/toggle-button.ts +7 -11
  59. package/src/codegen/targets/react/component/index.ts +79 -75
  60. package/src/codegen/targets/react/frame.ts +8 -8
  61. package/src/codegen/targets/react/icon.ts +50 -0
  62. package/src/codegen/targets/react/index.ts +1 -1
  63. package/src/codegen/targets/react/instance.ts +19 -50
  64. package/src/codegen/targets/react/pipeline.ts +124 -0
  65. package/src/codegen/targets/react/props.ts +95 -73
  66. package/src/codegen/targets/react/shape.ts +5 -5
  67. package/src/codegen/targets/react/text.ts +6 -6
  68. package/src/codegen/targets/react/value-resolver.ts +32 -0
  69. package/src/entities/icon.repository.ts +2 -2
  70. package/src/entities/icon.service.ts +9 -20
  71. package/src/entities/style.service.ts +5 -17
  72. package/src/entities/variable.service.ts +36 -68
  73. package/src/utils/figma-variable.ts +39 -3
  74. package/src/codegen/core/component.types.ts +0 -29
  75. package/src/codegen/targets/figma/context.ts +0 -139
  76. package/src/codegen/targets/react/component/transformers/avatar-stack.ts +0 -29
  77. package/src/codegen/targets/react/component/transformers/badge.ts +0 -21
  78. package/src/codegen/targets/react/component/transformers/fab.ts +0 -18
  79. package/src/codegen/targets/react/component/transformers/skeleton.ts +0 -51
  80. package/src/codegen/targets/react/context.ts +0 -176
  81. /package/src/codegen/core/{element.ts → element-transformer.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/figma",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -14,6 +14,16 @@
14
14
  "types": "./lib/index.d.ts",
15
15
  "import": "./lib/index.js",
16
16
  "require": "./lib/index.cjs"
17
+ },
18
+ "./codegen": {
19
+ "types": "./lib/codegen/index.d.ts",
20
+ "import": "./lib/codegen/index.js",
21
+ "require": "./lib/codegen/index.cjs"
22
+ },
23
+ "./codegen/targets/react": {
24
+ "types": "./lib/codegen/targets/react/index.d.ts",
25
+ "import": "./lib/codegen/targets/react/index.js",
26
+ "require": "./lib/codegen/targets/react/index.cjs"
17
27
  }
18
28
  },
19
29
  "main": "./lib/index.cjs",
@@ -28,7 +38,7 @@
28
38
  "lint:publish": "bun publint"
29
39
  },
30
40
  "dependencies": {
31
- "@seed-design/css": "0.0.21",
41
+ "@seed-design/css": "0.0.23",
32
42
  "change-case": "^5.4.4",
33
43
  "ts-pattern": "^5.7.0"
34
44
  },
@@ -1,19 +1,19 @@
1
- import type { InferFromDefinition } from "@/codegen/core";
1
+ import type { InferComponentDefinition } from "@/codegen/core";
2
2
  import type * as metadata from "@/entities/data/__generated__/component-sets";
3
3
 
4
- export type ActionButtonProperties = InferFromDefinition<
4
+ export type ActionButtonProperties = InferComponentDefinition<
5
5
  typeof metadata.actionButton.componentPropertyDefinitions
6
6
  >;
7
7
 
8
- export type ActionChipProperties = InferFromDefinition<
8
+ export type ActionChipProperties = InferComponentDefinition<
9
9
  typeof metadata.actionChip.componentPropertyDefinitions
10
10
  >;
11
11
 
12
- export type ActionSheetProperties = InferFromDefinition<
12
+ export type ActionSheetProperties = InferComponentDefinition<
13
13
  typeof metadata.actionSheet.componentPropertyDefinitions
14
14
  >;
15
15
 
16
- export type ActionSheetItemProperties = InferFromDefinition<{
16
+ export type ActionSheetItemProperties = InferComponentDefinition<{
17
17
  "Label#15420:4": {
18
18
  type: "TEXT";
19
19
  defaultValue: "액션 버튼";
@@ -30,31 +30,31 @@ export type ActionSheetItemProperties = InferFromDefinition<{
30
30
  };
31
31
  }>;
32
32
 
33
- export type AvatarProperties = InferFromDefinition<
33
+ export type AvatarProperties = InferComponentDefinition<
34
34
  typeof metadata.avatar.componentPropertyDefinitions
35
35
  >;
36
36
 
37
- export type AvatarStackProperties = InferFromDefinition<
37
+ export type AvatarStackProperties = InferComponentDefinition<
38
38
  typeof metadata.avatarStack.componentPropertyDefinitions
39
39
  >;
40
40
 
41
- export type BadgeProperties = InferFromDefinition<
41
+ export type BadgeProperties = InferComponentDefinition<
42
42
  typeof metadata.badge.componentPropertyDefinitions
43
43
  >;
44
44
 
45
- export type CalloutProperties = InferFromDefinition<
45
+ export type CalloutProperties = InferComponentDefinition<
46
46
  typeof metadata.callout.componentPropertyDefinitions
47
47
  >;
48
48
 
49
- export type CheckboxProperties = InferFromDefinition<
49
+ export type CheckboxProperties = InferComponentDefinition<
50
50
  typeof metadata.checkbox.componentPropertyDefinitions
51
51
  >;
52
52
 
53
- export type ChipTabsProperties = InferFromDefinition<
53
+ export type ChipTabsProperties = InferComponentDefinition<
54
54
  typeof metadata.chipTablist.componentPropertyDefinitions
55
55
  >;
56
56
 
57
- export type ChipTabsItemProperties = InferFromDefinition<{
57
+ export type ChipTabsItemProperties = InferComponentDefinition<{
58
58
  "Label#8876:0": {
59
59
  type: "TEXT";
60
60
  defaultValue: "라벨";
@@ -78,19 +78,19 @@ export type ChipTabsItemProperties = InferFromDefinition<{
78
78
  };
79
79
  }>;
80
80
 
81
- export type ControlChipProperties = InferFromDefinition<
81
+ export type ControlChipProperties = InferComponentDefinition<
82
82
  typeof metadata.controlChip.componentPropertyDefinitions
83
83
  >;
84
84
 
85
- export type ErrorStateProperties = InferFromDefinition<
85
+ export type ErrorStateProperties = InferComponentDefinition<
86
86
  typeof metadata.errorState.componentPropertyDefinitions
87
87
  >;
88
88
 
89
- export type ExtendedActionSheetProperties = InferFromDefinition<
89
+ export type ExtendedActionSheetProperties = InferComponentDefinition<
90
90
  typeof metadata.extendedActionSheet.componentPropertyDefinitions
91
91
  >;
92
92
 
93
- export type ExtendedActionSheetGroupProperties = InferFromDefinition<{
93
+ export type ExtendedActionSheetGroupProperties = InferComponentDefinition<{
94
94
  "Action Count": {
95
95
  type: "VARIANT";
96
96
  defaultValue: "8";
@@ -98,7 +98,7 @@ export type ExtendedActionSheetGroupProperties = InferFromDefinition<{
98
98
  };
99
99
  }>;
100
100
 
101
- export type ExtendedActionSheetItemProperties = InferFromDefinition<{
101
+ export type ExtendedActionSheetItemProperties = InferComponentDefinition<{
102
102
  "Show Prefix Icon#17043:5": {
103
103
  type: "BOOLEAN";
104
104
  defaultValue: true;
@@ -124,47 +124,47 @@ export type ExtendedActionSheetItemProperties = InferFromDefinition<{
124
124
  };
125
125
  }>;
126
126
 
127
- export type ExtendedFabProperties = InferFromDefinition<
127
+ export type ExtendedFabProperties = InferComponentDefinition<
128
128
  typeof metadata.extendedFloatingActionButton.componentPropertyDefinitions
129
129
  >;
130
130
 
131
- export type FabProperties = InferFromDefinition<
131
+ export type FabProperties = InferComponentDefinition<
132
132
  typeof metadata.floatingActionButton.componentPropertyDefinitions
133
133
  >;
134
134
 
135
- export type HelpBubbleProperties = InferFromDefinition<
135
+ export type HelpBubbleProperties = InferComponentDefinition<
136
136
  typeof metadata.helpBubble.componentPropertyDefinitions
137
137
  >;
138
138
 
139
- export type IdentityPlaceholderProperties = InferFromDefinition<
139
+ export type IdentityPlaceholderProperties = InferComponentDefinition<
140
140
  typeof metadata.identityPlaceholder.componentPropertyDefinitions
141
141
  >;
142
142
 
143
- export type InlineBannerProperties = InferFromDefinition<
143
+ export type InlineBannerProperties = InferComponentDefinition<
144
144
  typeof metadata.inlineBanner.componentPropertyDefinitions
145
145
  >;
146
146
 
147
- export type MannerTempBadgeProperties = InferFromDefinition<
147
+ export type MannerTempBadgeProperties = InferComponentDefinition<
148
148
  typeof metadata.mannerTempBadge.componentPropertyDefinitions
149
149
  >;
150
150
 
151
- export type MultilineTextFieldProperties = InferFromDefinition<
151
+ export type MultilineTextFieldProperties = InferComponentDefinition<
152
152
  typeof metadata.multilineTextField.componentPropertyDefinitions
153
153
  >;
154
154
 
155
- export type ProgressCircleProperties = InferFromDefinition<
155
+ export type ProgressCircleProperties = InferComponentDefinition<
156
156
  typeof metadata.progressCircle.componentPropertyDefinitions
157
157
  >;
158
158
 
159
- export type ReactionButtonProperties = InferFromDefinition<
159
+ export type ReactionButtonProperties = InferComponentDefinition<
160
160
  typeof metadata.reactionButton.componentPropertyDefinitions
161
161
  >;
162
162
 
163
- export type SegmentedControlProperties = InferFromDefinition<
163
+ export type SegmentedControlProperties = InferComponentDefinition<
164
164
  typeof metadata.segmentedControl.componentPropertyDefinitions
165
165
  >;
166
166
 
167
- export type SegmentedControlItemProperties = InferFromDefinition<{
167
+ export type SegmentedControlItemProperties = InferComponentDefinition<{
168
168
  "Label#11366:15": {
169
169
  type: "TEXT";
170
170
  defaultValue: "라벨";
@@ -183,31 +183,31 @@ export type SegmentedControlItemProperties = InferFromDefinition<{
183
183
  };
184
184
  }>;
185
185
 
186
- export type SelectBoxGroupProperties = InferFromDefinition<
186
+ export type SelectBoxGroupProperties = InferComponentDefinition<
187
187
  typeof metadata.templateSelectBoxGroup.componentPropertyDefinitions
188
188
  >;
189
189
 
190
- export type SelectBoxProperties = InferFromDefinition<
190
+ export type SelectBoxProperties = InferComponentDefinition<
191
191
  typeof metadata.selectBox.componentPropertyDefinitions
192
192
  >;
193
193
 
194
- export type SkeletonProperties = InferFromDefinition<
194
+ export type SkeletonProperties = InferComponentDefinition<
195
195
  typeof metadata.skeleton.componentPropertyDefinitions
196
196
  >;
197
197
 
198
- export type SnackbarProperties = InferFromDefinition<
198
+ export type SnackbarProperties = InferComponentDefinition<
199
199
  typeof metadata.snackbar.componentPropertyDefinitions
200
200
  >;
201
201
 
202
- export type SwitchProperties = InferFromDefinition<
202
+ export type SwitchProperties = InferComponentDefinition<
203
203
  typeof metadata.switch.componentPropertyDefinitions
204
204
  >;
205
205
 
206
- export type TabsProperties = InferFromDefinition<
206
+ export type TabsProperties = InferComponentDefinition<
207
207
  typeof metadata.tablist.componentPropertyDefinitions
208
208
  >;
209
209
 
210
- export type TabsHugItemProperties = InferFromDefinition<{
210
+ export type TabsHugItemProperties = InferComponentDefinition<{
211
211
  "Label#4478:2": {
212
212
  type: "TEXT";
213
213
  defaultValue: "라벨";
@@ -229,7 +229,7 @@ export type TabsHugItemProperties = InferFromDefinition<{
229
229
  };
230
230
  }>;
231
231
 
232
- export type TabsFillItemProperties = InferFromDefinition<{
232
+ export type TabsFillItemProperties = InferComponentDefinition<{
233
233
  "Label#4478:2": {
234
234
  type: "TEXT";
235
235
  defaultValue: "라벨";
@@ -251,23 +251,23 @@ export type TabsFillItemProperties = InferFromDefinition<{
251
251
  };
252
252
  }>;
253
253
 
254
- export type TextButtonProperties = InferFromDefinition<
254
+ export type TextButtonProperties = InferComponentDefinition<
255
255
  typeof metadata.textButton.componentPropertyDefinitions
256
256
  >;
257
257
 
258
- export type TextFieldProperties = InferFromDefinition<
258
+ export type TextFieldProperties = InferComponentDefinition<
259
259
  typeof metadata.textField.componentPropertyDefinitions
260
260
  >;
261
261
 
262
- export type ToggleButtonProperties = InferFromDefinition<
262
+ export type ToggleButtonProperties = InferComponentDefinition<
263
263
  typeof metadata.toggleButton.componentPropertyDefinitions
264
264
  >;
265
265
 
266
- export type AppBarProperties = InferFromDefinition<
266
+ export type AppBarProperties = InferComponentDefinition<
267
267
  typeof metadata.standardNavigation.componentPropertyDefinitions
268
268
  >;
269
269
 
270
- export type AppBarMainProperties = InferFromDefinition<{
270
+ export type AppBarMainProperties = InferComponentDefinition<{
271
271
  "Show Right#16958:13": {
272
272
  type: "BOOLEAN";
273
273
  defaultValue: false;
@@ -301,7 +301,7 @@ export type AppBarMainProperties = InferFromDefinition<{
301
301
  };
302
302
  }>;
303
303
 
304
- export type AppBarLeftProperties = InferFromDefinition<{
304
+ export type AppBarLeftProperties = InferComponentDefinition<{
305
305
  Action: {
306
306
  type: "VARIANT";
307
307
  defaultValue: "Back";
@@ -309,7 +309,7 @@ export type AppBarLeftProperties = InferFromDefinition<{
309
309
  };
310
310
  }>;
311
311
 
312
- export type AppBarRightProperties = InferFromDefinition<{
312
+ export type AppBarRightProperties = InferComponentDefinition<{
313
313
  Type: {
314
314
  type: "VARIANT";
315
315
  defaultValue: "1 Icon";
@@ -9,11 +9,11 @@ import type {
9
9
  NormalizedVectorNode,
10
10
  } from "@/normalizer";
11
11
  import { match } from "ts-pattern";
12
- import { appendSource, createElement, type ElementNode } from "../core/jsx";
13
- import type { ElementTransformer } from "./element";
12
+ import { appendSource, createElement, stringifyElement, type ElementNode } from "../core/jsx";
13
+ import type { ElementTransformer } from "./element-transformer";
14
14
  import { applyInferredLayout, inferLayout } from "./infer-layout";
15
15
 
16
- export interface CodegenTransformerDeps {
16
+ export interface CodeGeneratorDeps {
17
17
  frameTransformer: ElementTransformer<
18
18
  NormalizedFrameNode | NormalizedComponentNode | NormalizedInstanceNode
19
19
  >;
@@ -25,7 +25,7 @@ export interface CodegenTransformerDeps {
25
25
  shouldInferAutoLayout: boolean;
26
26
  }
27
27
 
28
- export function createCodegenTransformer({
28
+ export function createCodeGenerator({
29
29
  frameTransformer,
30
30
  textTransformer,
31
31
  rectangleTransformer,
@@ -33,7 +33,7 @@ export function createCodegenTransformer({
33
33
  vectorTransformer,
34
34
  booleanOperationTransformer,
35
35
  shouldInferAutoLayout,
36
- }: CodegenTransformerDeps): (node: NormalizedSceneNode) => ElementNode | undefined {
36
+ }: CodeGeneratorDeps) {
37
37
  function traverse(node: NormalizedSceneNode): ElementNode | undefined {
38
38
  if ("visible" in node && !node.visible) {
39
39
  return;
@@ -61,5 +61,16 @@ export function createCodegenTransformer({
61
61
  return;
62
62
  }
63
63
 
64
- return (node) => traverse(node);
64
+ function generateJsxTree(node: NormalizedSceneNode) {
65
+ return traverse(node);
66
+ }
67
+
68
+ function generateCode(node: NormalizedSceneNode, options: { shouldPrintSource: boolean }) {
69
+ const jsxTree = generateJsxTree(node);
70
+ return jsxTree
71
+ ? stringifyElement(jsxTree, { printSource: options.shouldPrintSource })
72
+ : undefined;
73
+ }
74
+
75
+ return { generateJsxTree, generateCode };
65
76
  }
@@ -1,7 +1,7 @@
1
1
  import type { NormalizedInstanceNode } from "@/normalizer";
2
2
  import type { ElementNode } from "./jsx";
3
3
 
4
- export interface ComponentTransformer<
4
+ export interface ComponentHandler<
5
5
  T extends
6
6
  NormalizedInstanceNode["componentProperties"] = NormalizedInstanceNode["componentProperties"],
7
7
  > {
@@ -9,9 +9,9 @@ export interface ComponentTransformer<
9
9
  transform: (node: NormalizedInstanceNode & { componentProperties: T }) => ElementNode;
10
10
  }
11
11
 
12
- export function defineComponentTransformer<T extends NormalizedInstanceNode["componentProperties"]>(
12
+ export function defineComponentHandler<T extends NormalizedInstanceNode["componentProperties"]>(
13
13
  key: string,
14
14
  transform: (node: NormalizedInstanceNode & { componentProperties: T }) => ElementNode,
15
- ): ComponentTransformer<T> {
15
+ ): ComponentHandler<T> {
16
16
  return { key, transform };
17
17
  }
@@ -0,0 +1,35 @@
1
+ import type { ComponentPropertyType, InstanceSwapPreferredValue } from "@figma/rest-api-spec";
2
+
3
+ export interface ComponentPropertyDefinition {
4
+ type: ComponentPropertyType;
5
+ preferredValues?: InstanceSwapPreferredValue[];
6
+ variantOptions?: string[];
7
+ }
8
+
9
+ export type InferComponentPropertyType<T extends ComponentPropertyDefinition> =
10
+ T["type"] extends "TEXT"
11
+ ? string
12
+ : T["type"] extends "BOOLEAN"
13
+ ? boolean
14
+ : T["type"] extends "INSTANCE_SWAP"
15
+ ? string
16
+ : T["type"] extends "VARIANT"
17
+ ? T["variantOptions"] extends string[]
18
+ ? T["variantOptions"][number]
19
+ : never
20
+ : never;
21
+
22
+ export type InferComponentDefinition<T extends Record<string, ComponentPropertyDefinition>> = {
23
+ [K in keyof T]: {
24
+ type: T[K]["type"];
25
+ value: InferComponentPropertyType<T[K]>;
26
+ readonly boundVariables?: {
27
+ [field in VariableBindableComponentPropertyField]?: VariableAlias;
28
+ };
29
+ } & (T[K]["type"] extends "INSTANCE_SWAP"
30
+ ? {
31
+ componentKey: string;
32
+ preferredValues: InstanceSwapPreferredValue[];
33
+ }
34
+ : {});
35
+ };
@@ -1,19 +1,19 @@
1
- export type { CodegenTransformerDeps } from "./codegen";
2
- export type { ComponentTransformer } from "./component";
1
+ export type { CodeGeneratorDeps } from "./codegen";
2
+ export type { ComponentHandler } from "./component-handler";
3
3
  export type {
4
4
  ComponentPropertyDefinition,
5
- InferFromDefinition,
6
- InferPropertyType,
7
- } from "./component.types";
8
- export type { ElementTransformer } from "./element";
5
+ InferComponentDefinition,
6
+ InferComponentPropertyType,
7
+ } from "./component-type-helper";
8
+ export type { ElementTransformer } from "./element-transformer";
9
9
  export type { ElementNode } from "./jsx";
10
- export type { PropsTransformer } from "./props";
11
- export type { ValueTransformer } from "./value";
10
+ export type { PropsConverter } from "./props-converter";
11
+ export type { ValueResolver } from "./value-resolver";
12
12
 
13
- export { createCodegenTransformer } from "./codegen";
14
- export { defineComponentTransformer } from "./component";
15
- export { defineElementTransformer } from "./element";
13
+ export { createCodeGenerator } from "./codegen";
14
+ export { defineComponentHandler } from "./component-handler";
15
+ export { defineElementTransformer } from "./element-transformer";
16
16
  export { inferLayout } from "./infer-layout";
17
- export { createElement, cloneElement } from "./jsx";
18
- export { createPropsTransformer, definePropsTransformer } from "./props";
19
- export { createValueTransformer } from "./value";
17
+ export { cloneElement, createElement } from "./jsx";
18
+ export { createPropsConverter, definePropsConverter } from "./props-converter";
19
+ export { createValueResolver } from "./value-resolver";
@@ -1,18 +1,15 @@
1
1
  import type { VariableValueResolved } from "@/entities";
2
- import type { NormalizedSceneNode } from "@/normalizer";
3
2
  import { objectEntries } from "@/utils/common";
4
- import type { ElementNode } from "./jsx";
5
3
 
6
- export type PropsTransformer<
4
+ export type PropsConverter<
7
5
  T extends Record<string, any> = Record<string, any>,
8
6
  R extends Record<string, any> = Record<string, any>,
9
- > = (node: T, traverse: (node: NormalizedSceneNode) => ElementNode | undefined) => R;
7
+ > = (node: T) => R;
10
8
 
11
- export function definePropsTransformer<
12
- T extends Record<string, any>,
13
- R extends Record<string, any>,
14
- >(transformer: PropsTransformer<T, R>) {
15
- return transformer;
9
+ export function definePropsConverter<T extends Record<string, any>, R extends Record<string, any>>(
10
+ converter: PropsConverter<T, R>,
11
+ ) {
12
+ return converter;
16
13
  }
17
14
 
18
15
  type Handlers<
@@ -28,7 +25,7 @@ type Shorthands<TProps extends Record<string, any>, HandlerKeys extends keyof TP
28
25
  HandlerKeys[]
29
26
  >;
30
27
 
31
- export interface PropsTransformerConfig<
28
+ export interface CreatePropsConverterConfig<
32
29
  TTrait extends Record<string, any>,
33
30
  TProps extends Record<string, any>,
34
31
  HandlerKeys extends keyof TProps,
@@ -42,7 +39,7 @@ export interface PropsTransformerConfig<
42
39
  defaults?: Partial<TProps>;
43
40
  }
44
41
 
45
- export function createPropsTransformer<
42
+ export function createPropsConverter<
46
43
  TTrait extends Record<string, any>,
47
44
  TProps extends Record<string, any>,
48
45
  HandlerKeys extends keyof TProps,
@@ -50,8 +47,8 @@ export function createPropsTransformer<
50
47
  handlers,
51
48
  shorthands,
52
49
  defaults,
53
- }: PropsTransformerConfig<TTrait, TProps, HandlerKeys>): PropsTransformer<TTrait, TProps> {
54
- return definePropsTransformer((node: TTrait) => {
50
+ }: CreatePropsConverterConfig<TTrait, TProps, HandlerKeys>): PropsConverter<TTrait, TProps> {
51
+ return definePropsConverter((node: TTrait) => {
55
52
  const result = {} as TProps;
56
53
 
57
54
  for (const [prop, handler] of objectEntries(handlers)) {