unframer 3.0.2 → 3.0.4

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 (112) hide show
  1. package/dist/cli.js +1 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.test.js +14 -6
  4. package/dist/cli.test.js.map +1 -1
  5. package/dist/example-code.test.js +1 -1
  6. package/dist/exporter.d.ts +0 -14
  7. package/dist/exporter.d.ts.map +1 -1
  8. package/dist/exporter.js +13 -186
  9. package/dist/exporter.js.map +1 -1
  10. package/dist/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.d.ts +115 -0
  11. package/dist/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.d.ts.map +1 -0
  12. package/dist/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.js +8 -0
  13. package/dist/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.js.map +1 -0
  14. package/dist/framer-chunks/fontshare-622CVMZZ-HFPH543A.d.ts +781 -0
  15. package/dist/framer-chunks/fontshare-622CVMZZ-HFPH543A.d.ts.map +1 -0
  16. package/dist/framer-chunks/fontshare-622CVMZZ-HFPH543A.js +8 -0
  17. package/dist/framer-chunks/fontshare-622CVMZZ-HFPH543A.js.map +1 -0
  18. package/dist/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.d.ts +634 -0
  19. package/dist/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.d.ts.map +1 -0
  20. package/dist/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.js +8 -0
  21. package/dist/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.js.map +1 -0
  22. package/dist/framer-chunks/google-3ASCFEEO-3R47BR2A.d.ts +1561 -0
  23. package/dist/framer-chunks/google-3ASCFEEO-3R47BR2A.d.ts.map +1 -0
  24. package/dist/framer-chunks/google-3ASCFEEO-3R47BR2A.js +8 -0
  25. package/dist/framer-chunks/google-3ASCFEEO-3R47BR2A.js.map +1 -0
  26. package/dist/framer-chunks/google-C62SNV32-LCI4F7VO.d.ts +3546 -0
  27. package/dist/framer-chunks/google-C62SNV32-LCI4F7VO.d.ts.map +1 -0
  28. package/dist/framer-chunks/google-C62SNV32-LCI4F7VO.js +8 -0
  29. package/dist/framer-chunks/google-C62SNV32-LCI4F7VO.js.map +1 -0
  30. package/dist/framer-chunks/google-FDB6LUFQ-PFSUZGKF.d.ts +10258 -0
  31. package/dist/framer-chunks/google-FDB6LUFQ-PFSUZGKF.d.ts.map +1 -0
  32. package/dist/framer-chunks/google-FDB6LUFQ-PFSUZGKF.js +8 -0
  33. package/dist/framer-chunks/google-FDB6LUFQ-PFSUZGKF.js.map +1 -0
  34. package/dist/framer.js +1230 -223
  35. package/dist/generated/api-client.js.map +1 -1
  36. package/dist/typescript.d.ts +20 -0
  37. package/dist/typescript.d.ts.map +1 -0
  38. package/dist/typescript.js +169 -0
  39. package/dist/typescript.js.map +1 -0
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +1 -1
  42. package/esm/cli.js +1 -0
  43. package/esm/cli.js.map +1 -1
  44. package/esm/cli.test.js +9 -1
  45. package/esm/cli.test.js.map +1 -1
  46. package/esm/example-code.test.js +1 -1
  47. package/esm/exporter.d.ts +0 -14
  48. package/esm/exporter.d.ts.map +1 -1
  49. package/esm/exporter.js +10 -181
  50. package/esm/exporter.js.map +1 -1
  51. package/esm/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.d.ts +115 -0
  52. package/esm/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.d.ts.map +1 -0
  53. package/esm/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.js +5 -0
  54. package/esm/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.js.map +1 -0
  55. package/esm/framer-chunks/fontshare-622CVMZZ-HFPH543A.d.ts +781 -0
  56. package/esm/framer-chunks/fontshare-622CVMZZ-HFPH543A.d.ts.map +1 -0
  57. package/esm/framer-chunks/fontshare-622CVMZZ-HFPH543A.js +5 -0
  58. package/esm/framer-chunks/fontshare-622CVMZZ-HFPH543A.js.map +1 -0
  59. package/esm/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.d.ts +634 -0
  60. package/esm/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.d.ts.map +1 -0
  61. package/esm/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.js +5 -0
  62. package/esm/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.js.map +1 -0
  63. package/esm/framer-chunks/google-3ASCFEEO-3R47BR2A.d.ts +1561 -0
  64. package/esm/framer-chunks/google-3ASCFEEO-3R47BR2A.d.ts.map +1 -0
  65. package/esm/framer-chunks/google-3ASCFEEO-3R47BR2A.js +5 -0
  66. package/esm/framer-chunks/google-3ASCFEEO-3R47BR2A.js.map +1 -0
  67. package/esm/framer-chunks/google-C62SNV32-LCI4F7VO.d.ts +3546 -0
  68. package/esm/framer-chunks/google-C62SNV32-LCI4F7VO.d.ts.map +1 -0
  69. package/esm/framer-chunks/google-C62SNV32-LCI4F7VO.js +5 -0
  70. package/esm/framer-chunks/google-C62SNV32-LCI4F7VO.js.map +1 -0
  71. package/esm/framer-chunks/google-FDB6LUFQ-PFSUZGKF.d.ts +10258 -0
  72. package/esm/framer-chunks/google-FDB6LUFQ-PFSUZGKF.d.ts.map +1 -0
  73. package/esm/framer-chunks/google-FDB6LUFQ-PFSUZGKF.js +5 -0
  74. package/esm/framer-chunks/google-FDB6LUFQ-PFSUZGKF.js.map +1 -0
  75. package/esm/framer.js +1230 -224
  76. package/esm/generated/api-client.js.map +1 -1
  77. package/esm/typescript.d.ts +20 -0
  78. package/esm/typescript.d.ts.map +1 -0
  79. package/esm/typescript.js +165 -0
  80. package/esm/typescript.js.map +1 -0
  81. package/esm/version.d.ts +1 -1
  82. package/esm/version.js +1 -1
  83. package/package.json +6 -3
  84. package/src/cli.test.ts +8 -1
  85. package/src/cli.ts +1 -1
  86. package/src/example-code.test.ts +1 -1
  87. package/src/exporter.ts +12 -202
  88. package/src/framer-chunks/fontshare-4J2ZFRBB-H5VQLZTM.js +7 -0
  89. package/src/framer-chunks/fontshare-622CVMZZ-HFPH543A.js +7 -0
  90. package/src/framer-chunks/fontshare-JGEKH7YN-QOX3MC3K.js +7 -0
  91. package/src/framer-chunks/google-3ASCFEEO-3R47BR2A.js +7 -0
  92. package/src/framer-chunks/google-C62SNV32-LCI4F7VO.js +7 -0
  93. package/src/framer-chunks/google-FDB6LUFQ-PFSUZGKF.js +7 -0
  94. package/src/framer.js +1170 -215
  95. package/src/generated/api-client.d.ts +790 -1042
  96. package/src/generated/api-client.js +5 -5
  97. package/src/styles/framer.css +1963 -0
  98. package/src/styles/reset.css +33 -0
  99. package/src/typescript.ts +196 -0
  100. package/src/version.ts +1 -1
  101. package/dist/generated/api-client.test.d.ts +0 -2
  102. package/dist/generated/api-client.test.d.ts.map +0 -1
  103. package/dist/generated/api-client.test.js +0 -3
  104. package/dist/generated/api-client.test.js.map +0 -1
  105. package/esm/generated/api-client.test.d.ts +0 -1
  106. package/esm/generated/api-client.test.d.ts.map +0 -1
  107. package/esm/generated/api-client.test.js +0 -2
  108. package/esm/generated/api-client.test.js.map +0 -1
  109. package/src/generated/api-client.d.ts.map +0 -1
  110. package/src/generated/api-client.js.map +0 -1
  111. package/src/generated/api-client.test.d.ts +0 -1
  112. package/src/generated/api-client.test.js +0 -1
@@ -0,0 +1,33 @@
1
+ :root {
2
+ -webkit-font-smoothing: antialiased;
3
+ -moz-osx-font-smoothing: grayscale;
4
+ }
5
+
6
+ * {
7
+ box-sizing: border-box;
8
+ -webkit-font-smoothing: inherit;
9
+ }
10
+
11
+ .unframer h1,
12
+ .unframer h2,
13
+ .unframer h3,
14
+ .unframer h4,
15
+ .unframer h5,
16
+ .unframer h6,
17
+ .unframer p,
18
+ .unframer figure {
19
+ margin: 0;
20
+ }
21
+
22
+ .unframer {
23
+ line-height: normal;
24
+ }
25
+
26
+ .unframer,
27
+ .unframer input,
28
+ .unframer textarea,
29
+ .unframer select,
30
+ .unframer button {
31
+ font-size: 12px;
32
+ font-family: sans-serif;
33
+ }
@@ -0,0 +1,196 @@
1
+ import { propCamelCaseJustLikeFramer } from './compat.js'
2
+ import { ControlDescription, ControlType, PropertyControls } from './framer.js'
3
+
4
+ export function componentCamelCase(str: string) {
5
+ str = str?.replace(/\.jsx?$/, '')
6
+ if (!str) {
7
+ return 'FramerComponent'
8
+ }
9
+ // Take last part after slashes
10
+ str = str.split('/').filter(Boolean).pop() || ''
11
+
12
+ // Replace all non-alphanumeric characters with space
13
+ // This handles spaces, special chars, underscores, hyphens, etc.
14
+ str = str.replace(/[^a-zA-Z0-9]+/g, ' ')
15
+
16
+ // Convert to camelCase: split by spaces, capitalize each word except first
17
+ const words = str.trim().split(/\s+/).filter(Boolean)
18
+ if (words.length === 0) {
19
+ return 'FramerComponent'
20
+ }
21
+
22
+ str = words
23
+ .map((word, index) => {
24
+ // First word: capitalize only if it starts with lowercase
25
+ if (index === 0) {
26
+ return word[0].toUpperCase() + word.slice(1)
27
+ }
28
+ // Other words: always capitalize first letter
29
+ return word[0].toUpperCase() + word.slice(1)
30
+ })
31
+ .join('')
32
+
33
+ // If component name starts with a number, add prefix 'Framer'
34
+ if (/^[0-9]/.test(str)) {
35
+ str = 'Framer' + str
36
+ }
37
+
38
+ str = str + 'FramerComponent'
39
+ return str
40
+ }
41
+
42
+ /**
43
+ * Generates TypeDoc comments that will be injected into JSX files
44
+ * instead of generating separate .d.ts files
45
+ */
46
+ export function propControlsToTypedocComments({
47
+ locales,
48
+ componentImportedName,
49
+ propertyControls,
50
+ logger,
51
+ includeLocaleTypes = false,
52
+ }: {
53
+ propertyControls: PropertyControls
54
+ componentImportedName: string
55
+ locales?: Array<{ slug: string }>
56
+ logger: any
57
+ includeLocaleTypes?: boolean
58
+ }) {
59
+ try {
60
+ const types = Object.entries(
61
+ propertyControls || ({} as PropertyControls),
62
+ )
63
+ .map(([key, value]) => {
64
+ if (!value) {
65
+ return
66
+ }
67
+
68
+ const typescriptType = (value: ControlDescription<any>) => {
69
+ value.type
70
+ switch (value.type) {
71
+ case ControlType.Color:
72
+ return 'string'
73
+ case ControlType.Boolean:
74
+ return 'boolean'
75
+ case ControlType.Number:
76
+ return 'number'
77
+ case ControlType.String:
78
+ return 'string'
79
+ case ControlType.Enum: {
80
+ // @ts-expect-error
81
+ const options = value.optionTitles || value.options
82
+ return options.map((x) => `'${x}'`).join(' | ')
83
+ }
84
+ case ControlType.File:
85
+ return 'string'
86
+ case ControlType.Image:
87
+ return 'string'
88
+ case ControlType.ComponentInstance:
89
+ return 'React.ReactNode'
90
+ case ControlType.Array:
91
+ // @ts-expect-error
92
+ return `${typescriptType(value.control)}[]`
93
+ case ControlType.Object:
94
+ // @ts-expect-error
95
+ return `{${Object.entries(value.controls)
96
+ .map(([k, v]) => {
97
+ // @ts-expect-error
98
+ return `${k}: ${typescriptType(v)}`
99
+ })
100
+ .join(', ')}`
101
+ case ControlType.Date:
102
+ return 'string | Date'
103
+ case ControlType.Link:
104
+ return 'string'
105
+ case ControlType.ResponsiveImage:
106
+ return `{src: string, srcSet?: string, alt?: string}`
107
+ case ControlType.FusedNumber:
108
+ return 'number'
109
+ case ControlType.Transition:
110
+ return 'any'
111
+ case ControlType.EventHandler:
112
+ return 'Function'
113
+ }
114
+ }
115
+ let name = propCamelCaseJustLikeFramer(value.title || key || '')
116
+ if (!name) {
117
+ return ''
118
+ }
119
+ return ` * ${name}?: ${typescriptType(value)} // ${value.title || name}`
120
+ })
121
+ .filter(Boolean)
122
+ .join('\n')
123
+
124
+ const componentName = componentImportedName
125
+
126
+ const defaultPropsJsDoc = [
127
+ ' * children?: React.ReactNode',
128
+ includeLocaleTypes ? ' * locale?: Locale' : null,
129
+ ' * style?: React.CSSProperties',
130
+ ' * className?: string',
131
+ ' * id?: string',
132
+ ' * ref?: any',
133
+ ' * width?: any',
134
+ ' * height?: any',
135
+ ' * layoutId?: string',
136
+ ].filter(Boolean).join('\n')
137
+
138
+ // Generate header comment with type definitions
139
+ let headerComment = ''
140
+
141
+ if (includeLocaleTypes) {
142
+ headerComment += '/**\n'
143
+ headerComment += ' * @typedef Locale\n'
144
+
145
+ // Generate union type from locales if available
146
+ const localeType = (() => {
147
+ if (locales && Array.isArray(locales) && locales.length > 0) {
148
+ return locales.map((locale) => `'${locale.slug}'`).join(' | ')
149
+ }
150
+ return 'string'
151
+ })()
152
+
153
+ headerComment += ` * ${localeType}\n`
154
+ headerComment += ' */\n\n'
155
+ }
156
+
157
+ headerComment += '/**\n'
158
+ headerComment += ' * @typedef {{\n'
159
+ headerComment += defaultPropsJsDoc
160
+
161
+ if (types) {
162
+ headerComment += '\n' + types
163
+ }
164
+ headerComment += `\n}} Props\n`
165
+ headerComment += '\n */'
166
+
167
+ // Generate responsive comment
168
+ let responsiveComment = '/**\n'
169
+ responsiveComment += ' * @type {import("unframer").UnframerBreakpoint}\n'
170
+ responsiveComment += ' * Represents a responsive breakpoint for unframer.\n'
171
+ responsiveComment += ' */\n\n'
172
+ responsiveComment += '/**\n'
173
+ responsiveComment += ' * @typedef VariantsMap\n'
174
+ responsiveComment += " * Partial record of UnframerBreakpoint to Props.variant, with a mandatory 'base' key.\n"
175
+ responsiveComment += " * { [key in UnframerBreakpoint]?: Props['variant'] } & { base: Props['variant'] }\n"
176
+ responsiveComment += ' */\n\n'
177
+ responsiveComment += `/**\n * Renders ${componentName} for all breakpoints with a variants map. Variant prop is inferred per breakpoint.\n * @function\n * @param {Omit<Props, 'variant'> & {variants?: VariantsMap}} props\n * @returns {any}\n */`
178
+
179
+ // Generate default export comment - use inline function type instead of referencing undefined type
180
+ const defaultExportComment = `/** @type {function(Props): any} */`
181
+
182
+ return {
183
+ headerComment,
184
+ responsiveComment,
185
+ defaultExportComment,
186
+ }
187
+ } catch (e: any) {
188
+ logger.error(e.message)
189
+ logger.error('cannot generate typedoc comments', e.stack)
190
+ return {
191
+ headerComment: '',
192
+ responsiveComment: '',
193
+ defaultExportComment: '',
194
+ }
195
+ }
196
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '3.0.2'
1
+ export const version = '3.0.4'
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=api-client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.d.ts","sourceRoot":"","sources":["../../src/generated/api-client.test.js"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=api-client.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../../src/generated/api-client.test.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=api-client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.d.ts","sourceRoot":"","sources":["../../src/generated/api-client.test.js"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=api-client.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../../src/generated/api-client.test.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-