@builder.io/mitosis 0.0.56-98 → 0.0.57

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 (259) hide show
  1. package/dist/src/__tests__/data/blocks/content-slot-jsx.raw.jsx +4 -1
  2. package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
  3. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +5 -1
  4. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +3 -3
  5. package/dist/src/__tests__/data/jsx-json.spec.d.ts +2 -0
  6. package/dist/src/__tests__/data/jsx-json.spec.js +10226 -0
  7. package/dist/src/__tests__/shared.d.ts +7 -2
  8. package/dist/src/__tests__/shared.js +66 -9
  9. package/dist/src/constants/method-literal-prefix.d.ts +0 -1
  10. package/dist/src/constants/method-literal-prefix.js +0 -3
  11. package/dist/src/generators/angular.d.ts +2 -2
  12. package/dist/src/generators/angular.js +5 -3
  13. package/dist/src/generators/builder.d.ts +4 -11
  14. package/dist/src/generators/builder.js +3 -2
  15. package/dist/src/generators/context/svelte.d.ts +3 -0
  16. package/dist/src/generators/context/svelte.js +3 -0
  17. package/dist/src/generators/helpers/functions.d.ts +2 -0
  18. package/dist/src/generators/helpers/functions.js +28 -0
  19. package/dist/src/generators/html.d.ts +3 -3
  20. package/dist/src/generators/html.js +9 -7
  21. package/dist/src/generators/liquid.d.ts +2 -2
  22. package/dist/src/generators/liquid.js +4 -4
  23. package/dist/src/generators/lit/generate.d.ts +2 -2
  24. package/dist/src/generators/lit/generate.js +14 -6
  25. package/dist/src/generators/marko/generate.d.ts +2 -2
  26. package/dist/src/generators/marko/generate.js +10 -8
  27. package/dist/src/generators/mitosis.d.ts +3 -4
  28. package/dist/src/generators/mitosis.js +3 -2
  29. package/dist/src/generators/qwik/component-generator.d.ts +2 -2
  30. package/dist/src/generators/qwik/component-generator.js +49 -55
  31. package/dist/src/generators/qwik/component.d.ts +0 -1
  32. package/dist/src/generators/qwik/component.js +22 -19
  33. package/dist/src/generators/qwik/directives.d.ts +1 -0
  34. package/dist/src/generators/qwik/directives.js +11 -14
  35. package/dist/src/generators/qwik/jsx.d.ts +1 -1
  36. package/dist/src/generators/qwik/jsx.js +9 -5
  37. package/dist/src/generators/qwik/src-generator.js +9 -3
  38. package/dist/src/generators/qwik/stable-serialize.d.ts +6 -0
  39. package/dist/src/generators/qwik/stable-serialize.js +51 -0
  40. package/dist/src/generators/react/generator.d.ts +6 -0
  41. package/dist/src/generators/{react.js → react/generator.js} +58 -150
  42. package/dist/src/generators/react/helpers.d.ts +2 -0
  43. package/dist/src/generators/react/helpers.js +14 -0
  44. package/dist/src/generators/react/index.d.ts +2 -0
  45. package/dist/src/generators/react/index.js +18 -0
  46. package/dist/src/generators/react/state.d.ts +9 -0
  47. package/dist/src/generators/react/state.js +107 -0
  48. package/dist/src/generators/react/types.d.ts +10 -0
  49. package/dist/src/{types/string-map.js → generators/react/types.js} +0 -0
  50. package/dist/src/generators/react-native.d.ts +2 -2
  51. package/dist/src/generators/solid/index.d.ts +3 -0
  52. package/dist/src/generators/{solid.js → solid/index.js} +80 -40
  53. package/dist/src/generators/solid/state.d.ts +19 -0
  54. package/dist/src/generators/solid/state.js +144 -0
  55. package/dist/src/generators/solid/types.d.ts +6 -0
  56. package/dist/src/generators/solid/types.js +2 -0
  57. package/dist/src/generators/stencil/generate.d.ts +2 -2
  58. package/dist/src/generators/stencil/generate.js +5 -2
  59. package/dist/src/generators/svelte.d.ts +6 -7
  60. package/dist/src/generators/svelte.js +43 -40
  61. package/dist/src/generators/swift-ui.d.ts +3 -5
  62. package/dist/src/generators/swift-ui.js +3 -2
  63. package/dist/src/generators/template.d.ts +2 -2
  64. package/dist/src/generators/template.js +3 -2
  65. package/dist/src/generators/vue.d.ts +5 -3
  66. package/dist/src/generators/vue.js +256 -113
  67. package/dist/src/helpers/babel-transform.d.ts +3 -1
  68. package/dist/src/helpers/babel-transform.js +52 -56
  69. package/dist/src/helpers/get-bindings.js +3 -5
  70. package/dist/src/helpers/get-props.js +14 -1
  71. package/dist/src/helpers/get-state-object-string.js +24 -21
  72. package/dist/src/helpers/getters-to-functions.js +1 -11
  73. package/dist/src/helpers/map-refs.js +25 -25
  74. package/dist/src/helpers/nodes/for.d.ts +4 -0
  75. package/dist/src/helpers/nodes/for.js +13 -0
  76. package/dist/src/helpers/nullable.d.ts +2 -0
  77. package/dist/src/helpers/nullable.js +7 -0
  78. package/dist/src/helpers/patterns.d.ts +2 -0
  79. package/dist/src/helpers/patterns.js +5 -1
  80. package/dist/src/helpers/render-imports.js +3 -3
  81. package/dist/src/helpers/replace-identifiers.d.ts +5 -0
  82. package/dist/src/helpers/{replace-idenifiers.js → replace-identifiers.js} +2 -1
  83. package/dist/src/helpers/slots.d.ts +2 -0
  84. package/dist/src/helpers/slots.js +15 -1
  85. package/dist/src/helpers/state.d.ts +0 -2
  86. package/dist/src/helpers/state.js +1 -10
  87. package/dist/src/helpers/strip-state-and-props-refs.d.ts +1 -1
  88. package/dist/src/helpers/strip-state-and-props-refs.js +43 -31
  89. package/dist/src/helpers/styles/helpers.d.ts +1 -0
  90. package/dist/src/index.d.ts +0 -2
  91. package/dist/src/index.js +0 -2
  92. package/dist/src/parsers/angular.js +2 -2
  93. package/dist/src/parsers/builder.d.ts +2 -2
  94. package/dist/src/parsers/builder.js +61 -43
  95. package/dist/src/parsers/constants/outdated-prefixes.d.ts +10 -0
  96. package/dist/src/parsers/constants/outdated-prefixes.js +13 -0
  97. package/dist/src/parsers/context.js +2 -2
  98. package/dist/src/parsers/helpers/state.d.ts +3 -0
  99. package/dist/src/parsers/helpers/state.js +30 -0
  100. package/dist/src/parsers/jsx/component-types.d.ts +1 -1
  101. package/dist/src/parsers/jsx/component-types.js +15 -2
  102. package/dist/src/parsers/jsx/context.js +1 -1
  103. package/dist/src/parsers/jsx/element-parser.d.ts +6 -0
  104. package/dist/src/parsers/jsx/element-parser.js +243 -0
  105. package/dist/src/parsers/jsx/exports.d.ts +3 -0
  106. package/dist/src/parsers/jsx/exports.js +78 -0
  107. package/dist/src/parsers/jsx/function-parser.d.ts +7 -0
  108. package/dist/src/parsers/jsx/function-parser.js +291 -0
  109. package/dist/src/parsers/jsx/helpers.d.ts +2 -0
  110. package/dist/src/parsers/jsx/helpers.js +30 -1
  111. package/dist/src/parsers/jsx/imports.d.ts +7 -0
  112. package/dist/src/parsers/jsx/imports.js +65 -0
  113. package/dist/src/parsers/jsx/index.d.ts +1 -1
  114. package/dist/src/parsers/jsx/index.js +1 -2
  115. package/dist/src/parsers/jsx/jsx.js +29 -516
  116. package/dist/src/parsers/jsx/state.d.ts +2 -3
  117. package/dist/src/parsers/jsx/state.js +15 -22
  118. package/dist/src/plugins/compile-away-builder-components.js +6 -0
  119. package/dist/src/symbols/symbol-processor.js +3 -0
  120. package/dist/src/targets.d.ts +21 -28
  121. package/dist/src/targets.js +2 -2
  122. package/dist/src/types/config.d.ts +11 -1
  123. package/dist/src/types/mitosis-component.d.ts +12 -6
  124. package/dist/src/types/mitosis-component.js +11 -0
  125. package/dist/src/types/mitosis-context.d.ts +2 -2
  126. package/dist/src/types/mitosis-node.d.ts +14 -5
  127. package/dist/src/types/mitosis-node.js +3 -0
  128. package/dist/src/types/transpiler.d.ts +6 -1
  129. package/dist/tsconfig.build.tsbuildinfo +1 -1
  130. package/package.json +9 -9
  131. package/dist/src/__tests__/angular.test.d.ts +0 -1
  132. package/dist/src/__tests__/angular.test.js +0 -10
  133. package/dist/src/__tests__/builder.test.d.ts +0 -1
  134. package/dist/src/__tests__/builder.test.js +0 -235
  135. package/dist/src/__tests__/context.test.d.ts +0 -1
  136. package/dist/src/__tests__/context.test.js +0 -35
  137. package/dist/src/__tests__/data/blocks/builder-render-block.raw.d.ts +0 -6
  138. package/dist/src/__tests__/data/blocks/builder-render-block.raw.jsx +0 -90
  139. package/dist/src/__tests__/data/blocks/builder-render-content.raw.d.ts +0 -10
  140. package/dist/src/__tests__/data/blocks/builder-render-content.raw.jsx +0 -69
  141. package/dist/src/__tests__/hash-code.test.d.ts +0 -1
  142. package/dist/src/__tests__/hash-code.test.js +0 -11
  143. package/dist/src/__tests__/html.test.d.ts +0 -1
  144. package/dist/src/__tests__/html.test.js +0 -7
  145. package/dist/src/__tests__/liquid.test.d.ts +0 -1
  146. package/dist/src/__tests__/liquid.test.js +0 -7
  147. package/dist/src/__tests__/lit.test.d.ts +0 -1
  148. package/dist/src/__tests__/lit.test.js +0 -7
  149. package/dist/src/__tests__/marko.test.d.ts +0 -1
  150. package/dist/src/__tests__/marko.test.js +0 -14
  151. package/dist/src/__tests__/parse-jsx.test.d.ts +0 -1
  152. package/dist/src/__tests__/parse-jsx.test.js +0 -37
  153. package/dist/src/__tests__/qwik/convert-method-to-function.test.d.ts +0 -1
  154. package/dist/src/__tests__/qwik/convert-method-to-function.test.js +0 -37
  155. package/dist/src/__tests__/qwik/src-generator.test.d.ts +0 -1
  156. package/dist/src/__tests__/qwik/src-generator.test.js +0 -65
  157. package/dist/src/__tests__/qwik.directive.test.d.ts +0 -1
  158. package/dist/src/__tests__/qwik.directive.test.js +0 -108
  159. package/dist/src/__tests__/qwik.test.d.ts +0 -1
  160. package/dist/src/__tests__/qwik.test.js +0 -465
  161. package/dist/src/__tests__/react-native.test.d.ts +0 -1
  162. package/dist/src/__tests__/react-native.test.js +0 -7
  163. package/dist/src/__tests__/react.test.d.ts +0 -1
  164. package/dist/src/__tests__/react.test.js +0 -20
  165. package/dist/src/__tests__/solid.test.d.ts +0 -1
  166. package/dist/src/__tests__/solid.test.js +0 -10
  167. package/dist/src/__tests__/stencil.test.d.ts +0 -1
  168. package/dist/src/__tests__/stencil.test.js +0 -7
  169. package/dist/src/__tests__/styles.test.d.ts +0 -1
  170. package/dist/src/__tests__/styles.test.js +0 -23
  171. package/dist/src/__tests__/svelte.test.d.ts +0 -1
  172. package/dist/src/__tests__/svelte.test.js +0 -7
  173. package/dist/src/__tests__/vue.test.d.ts +0 -1
  174. package/dist/src/__tests__/vue.test.js +0 -7
  175. package/dist/src/__tests__/webcomponent.test.d.ts +0 -1
  176. package/dist/src/__tests__/webcomponent.test.js +0 -15
  177. package/dist/src/constants/function-literal-prefix.d.ts +0 -1
  178. package/dist/src/constants/function-literal-prefix.js +0 -4
  179. package/dist/src/generators/qwik/convertMethodToFunction.d.ts +0 -1
  180. package/dist/src/generators/qwik/convertMethodToFunction.js +0 -161
  181. package/dist/src/generators/react.d.ts +0 -14
  182. package/dist/src/generators/solid.d.ts +0 -5
  183. package/dist/src/helpers/babel-transform.test.d.ts +0 -1
  184. package/dist/src/helpers/babel-transform.test.js +0 -7
  185. package/dist/src/helpers/generic-format.test.d.ts +0 -1
  186. package/dist/src/helpers/generic-format.test.js +0 -8
  187. package/dist/src/helpers/map-to-attributes.d.ts +0 -2
  188. package/dist/src/helpers/map-to-attributes.js +0 -19
  189. package/dist/src/helpers/map-to-css.d.ts +0 -2
  190. package/dist/src/helpers/map-to-css.js +0 -16
  191. package/dist/src/helpers/parse-reactive-script.d.ts +0 -7
  192. package/dist/src/helpers/parse-reactive-script.js +0 -87
  193. package/dist/src/helpers/remove-surrounding-block.test.d.ts +0 -1
  194. package/dist/src/helpers/remove-surrounding-block.test.js +0 -9
  195. package/dist/src/helpers/render-imports.test.d.ts +0 -1
  196. package/dist/src/helpers/render-imports.test.js +0 -33
  197. package/dist/src/helpers/replace-idenifiers.d.ts +0 -1
  198. package/dist/src/helpers/styles/collect-css.test.d.ts +0 -1
  199. package/dist/src/helpers/styles/collect-css.test.js +0 -18
  200. package/dist/src/parsers/html.d.ts +0 -0
  201. package/dist/src/parsers/html.js +0 -2
  202. package/dist/src/parsers/liquid.d.ts +0 -70
  203. package/dist/src/parsers/liquid.js +0 -2538
  204. package/dist/src/types/string-map.d.ts +0 -3
  205. package/dist/test/qwik/Accordion/high.jsx +0 -0
  206. package/dist/test/qwik/Accordion/low.jsx +0 -240
  207. package/dist/test/qwik/Accordion/med.jsx +0 -4
  208. package/dist/test/qwik/For/high.jsx +0 -0
  209. package/dist/test/qwik/For/low.jsx +0 -52
  210. package/dist/test/qwik/For/med.jsx +0 -4
  211. package/dist/test/qwik/Image/high.js +0 -9
  212. package/dist/test/qwik/Image/low.js +0 -0
  213. package/dist/test/qwik/Image/med.js +0 -155
  214. package/dist/test/qwik/Image.slow/high.js +0 -9
  215. package/dist/test/qwik/Image.slow/low.js +0 -0
  216. package/dist/test/qwik/Image.slow/med.js +0 -155
  217. package/dist/test/qwik/bindings/high.cjs +0 -0
  218. package/dist/test/qwik/bindings/low.cjs +0 -45
  219. package/dist/test/qwik/bindings/med.cjs +0 -3
  220. package/dist/test/qwik/button/high.js +0 -3
  221. package/dist/test/qwik/button/low.js +0 -25
  222. package/dist/test/qwik/button/med.js +0 -31
  223. package/dist/test/qwik/component/bindings/high.jsx +0 -0
  224. package/dist/test/qwik/component/bindings/low.jsx +0 -104
  225. package/dist/test/qwik/component/bindings/med.jsx +0 -7
  226. package/dist/test/qwik/component/component/inputs/high.cjsx +0 -9
  227. package/dist/test/qwik/component/component/inputs/low.cjsx +0 -0
  228. package/dist/test/qwik/component/component/inputs/med.cjsx +0 -68
  229. package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
  230. package/dist/test/qwik/for-loop.bindings/low.cjs +0 -56
  231. package/dist/test/qwik/for-loop.bindings/med.cjs +0 -5
  232. package/dist/test/qwik/hello_world/stylesheet/high.jsx +0 -0
  233. package/dist/test/qwik/hello_world/stylesheet/low.jsx +0 -26
  234. package/dist/test/qwik/hello_world/stylesheet/med.jsx +0 -4
  235. package/dist/test/qwik/mount/high.cjs +0 -0
  236. package/dist/test/qwik/mount/low.cjs +0 -47
  237. package/dist/test/qwik/mount/med.cjs +0 -3
  238. package/dist/test/qwik/page-with-symbol/high.js +0 -0
  239. package/dist/test/qwik/page-with-symbol/low.js +0 -33
  240. package/dist/test/qwik/page-with-symbol/med.js +0 -4
  241. package/dist/test/qwik/show-hide/high.jsx +0 -9
  242. package/dist/test/qwik/show-hide/low.jsx +0 -0
  243. package/dist/test/qwik/show-hide/med.jsx +0 -181
  244. package/dist/test/qwik/svg/high.js +0 -0
  245. package/dist/test/qwik/svg/low.js +0 -30
  246. package/dist/test/qwik/svg/med.js +0 -4
  247. package/dist/test/qwik/todo/Todo.cjs/high.cjs +0 -19
  248. package/dist/test/qwik/todo/Todo.cjs/low.cjs +0 -0
  249. package/dist/test/qwik/todo/Todo.cjs/med.cjs +0 -51
  250. package/dist/test/qwik/todo/Todo.js/high.js +0 -19
  251. package/dist/test/qwik/todo/Todo.js/low.js +0 -0
  252. package/dist/test/qwik/todo/Todo.js/med.js +0 -47
  253. package/dist/test/qwik/todo/Todo.tsx/high.tsx +0 -19
  254. package/dist/test/qwik/todo/Todo.tsx/low.tsx +0 -0
  255. package/dist/test/qwik/todo/Todo.tsx/med.tsx +0 -43
  256. package/dist/test/qwik/todos/Todo.tsx/high.tsx +0 -7
  257. package/dist/test/qwik/todos/Todo.tsx/low.tsx +0 -32
  258. package/dist/test/qwik/todos/Todo.tsx/med.tsx +0 -4
  259. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,161 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertMethodToFunction = void 0;
4
- function convertMethodToFunction(code, methods, lexicalArgs) {
5
- var out = [];
6
- var idx = 0;
7
- var lastIdx = idx;
8
- var end = code.length;
9
- var templateDepth = 0;
10
- var mode = "code" /* Mode.code */;
11
- var braceDepth = 0;
12
- var stringEndBraceDepth = -1;
13
- var stringEndBraceDepthQueue = [];
14
- var lastCh = null;
15
- while (idx < end) {
16
- var ch = code.charCodeAt(idx++);
17
- // console.log(mode, code[idx - 1]);
18
- switch (mode) {
19
- case "code" /* Mode.code */:
20
- if (ch === QUOTE_DOUBLE) {
21
- mode = "stringDouble" /* Mode.stringDouble */;
22
- }
23
- else if (ch === QUOTE_SINGLE) {
24
- mode = "stringSingle" /* Mode.stringSingle */;
25
- }
26
- else if (ch === QUOTE_BACK_TICK) {
27
- mode = "stringTemplate" /* Mode.stringTemplate */;
28
- templateDepth++;
29
- }
30
- else if (ch === OPEN_BRACE) {
31
- braceDepth++;
32
- }
33
- else if (lastCh == FORWARD_SLASH && ch == FORWARD_SLASH) {
34
- mode = "commentSingleline" /* Mode.commentSingleline */;
35
- }
36
- else if (lastCh == FORWARD_SLASH && ch == STAR) {
37
- mode = "commentMultiline" /* Mode.commentMultiline */;
38
- }
39
- else if (ch === CLOSE_BRACE) {
40
- braceDepth--;
41
- if (braceDepth === stringEndBraceDepth) {
42
- stringEndBraceDepth = stringEndBraceDepthQueue.pop();
43
- templateDepth--;
44
- mode = "stringTemplate" /* Mode.stringTemplate */;
45
- }
46
- }
47
- else if (isWord(ch, code, idx, 'this') || isWord(ch, code, idx, 'state')) {
48
- idx--;
49
- flush();
50
- consumeIdent();
51
- if (code.charCodeAt(idx) == DOT) {
52
- idx++;
53
- var propEndIdx = findIdentEnd();
54
- var identifier = code.substring(idx, propEndIdx);
55
- if (identifier in methods) {
56
- var isGetter = code.charCodeAt(propEndIdx) !== OPEN_PAREN;
57
- lastIdx = idx = propEndIdx + (isGetter ? 0 : 1);
58
- if (isGetter) {
59
- out.push(identifier, "(".concat(lexicalArgs.join(','), ")"));
60
- }
61
- else {
62
- out.push(identifier, "(".concat(lexicalArgs.join(','), ","));
63
- }
64
- }
65
- else {
66
- flush();
67
- }
68
- }
69
- }
70
- break;
71
- case "commentSingleline" /* Mode.commentSingleline */:
72
- if (ch == EOL)
73
- mode = "code" /* Mode.code */;
74
- break;
75
- case "commentMultiline" /* Mode.commentMultiline */:
76
- if (lastCh == STAR && ch == FORWARD_SLASH)
77
- mode = "code" /* Mode.code */;
78
- break;
79
- case "stringSingle" /* Mode.stringSingle */:
80
- if (lastCh !== BACKSLASH && ch == QUOTE_SINGLE)
81
- mode = "code" /* Mode.code */;
82
- break;
83
- case "stringDouble" /* Mode.stringDouble */:
84
- if (lastCh !== BACKSLASH && ch == QUOTE_DOUBLE)
85
- mode = "code" /* Mode.code */;
86
- break;
87
- case "stringTemplate" /* Mode.stringTemplate */:
88
- if (lastCh !== BACKSLASH && ch == QUOTE_BACK_TICK) {
89
- mode = "code" /* Mode.code */;
90
- templateDepth--;
91
- }
92
- else if (lastCh === DOLLAR && ch == OPEN_BRACE) {
93
- templateDepth++;
94
- mode = "code" /* Mode.code */;
95
- stringEndBraceDepthQueue.push(stringEndBraceDepth);
96
- stringEndBraceDepth = braceDepth;
97
- braceDepth++;
98
- }
99
- break;
100
- }
101
- lastCh = ch;
102
- }
103
- flush();
104
- return out.join('');
105
- function flush() {
106
- out.push(code.substring(lastIdx, idx));
107
- lastIdx = idx;
108
- }
109
- function findIdentEnd() {
110
- var scanIdx = idx;
111
- while (isIdentCh(code.charCodeAt(scanIdx)) && scanIdx < end) {
112
- scanIdx++;
113
- }
114
- return scanIdx;
115
- }
116
- function consumeIdent() {
117
- while (isIdentCh(code.charCodeAt(idx))) {
118
- idx++;
119
- }
120
- }
121
- }
122
- exports.convertMethodToFunction = convertMethodToFunction;
123
- function isIdentCh(ch) {
124
- return ((CHAR_0 <= ch && ch <= CHAR_9) ||
125
- (CHAR_a <= ch && ch <= CHAR_z) ||
126
- (CHAR_A <= ch && ch <= CHAR_Z) ||
127
- ch === UNDERSCORE ||
128
- ch === DOLLAR);
129
- }
130
- function isWord(ch, code, idx, word) {
131
- if (ch !== word.charCodeAt(0))
132
- return false;
133
- for (var i = 1; i < word.length; i++) {
134
- if (code.charCodeAt(idx + i - 1) !== word.charCodeAt(i)) {
135
- return false;
136
- }
137
- }
138
- if (isIdentCh(code.charCodeAt(idx + word.length - 1))) {
139
- return false;
140
- }
141
- return true;
142
- }
143
- var QUOTE_DOUBLE = '"'.charCodeAt(0);
144
- var QUOTE_SINGLE = "'".charCodeAt(0);
145
- var QUOTE_BACK_TICK = '`'.charCodeAt(0);
146
- var BACKSLASH = "\\".charCodeAt(0);
147
- var FORWARD_SLASH = "/".charCodeAt(0);
148
- var EOL = "\n".charCodeAt(0);
149
- var STAR = "*".charCodeAt(0);
150
- var CHAR_0 = "0".charCodeAt(0);
151
- var CHAR_9 = "9".charCodeAt(0);
152
- var CHAR_a = "a".charCodeAt(0);
153
- var CHAR_z = "z".charCodeAt(0);
154
- var CHAR_A = "A".charCodeAt(0);
155
- var CHAR_Z = "Z".charCodeAt(0);
156
- var UNDERSCORE = "_".charCodeAt(0);
157
- var DOLLAR = "$".charCodeAt(0);
158
- var DOT = ".".charCodeAt(0);
159
- var OPEN_PAREN = '('.charCodeAt(0);
160
- var OPEN_BRACE = '{'.charCodeAt(0);
161
- var CLOSE_BRACE = '}'.charCodeAt(0);
@@ -1,14 +0,0 @@
1
- import { BaseTranspilerOptions, Transpiler } from '../types/transpiler';
2
- import { MitosisNode } from '../types/mitosis-node';
3
- export interface ToReactOptions extends BaseTranspilerOptions {
4
- stylesType?: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native' | 'style-tag';
5
- stateType?: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder';
6
- format?: 'lite' | 'safe';
7
- type?: 'dom' | 'native';
8
- preact?: boolean;
9
- forwardRef?: string;
10
- experimental?: any;
11
- }
12
- export declare const blockToReact: (json: MitosisNode, options: ToReactOptions, parentSlots?: any[]) => string;
13
- export declare const componentToPreact: (reactOptions?: ToReactOptions) => Transpiler;
14
- export declare const componentToReact: (reactOptions?: ToReactOptions) => Transpiler;
@@ -1,5 +0,0 @@
1
- import { BaseTranspilerOptions, Transpiler } from '../types/transpiler';
2
- export interface ToSolidOptions extends BaseTranspilerOptions {
3
- stylesType?: 'styled-components' | 'style-tag';
4
- }
5
- export declare const componentToSolid: (_options?: ToSolidOptions) => Transpiler;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var babel_transform_1 = require("./babel-transform");
4
- test('babelTransform', function () {
5
- var code = "\nconst symbol = symbol;\n\nif (symbol) {\n getContent({\n apiKey: builderContext.apiKey!,\n }).then(response => {\n content = response;\n });\n}\n";
6
- expect((0, babel_transform_1.babelTransformCode)(code)).toMatchSnapshot();
7
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var globals_1 = require("@jest/globals");
4
- var generic_format_1 = require("./generic-format");
5
- (0, globals_1.test)('Can generic format sloppy Swift code', function () {
6
- var code = "\n import SwiftUI\n import JavaScriptCore\n \n struct MyComponent: View {\n \n @State private var updateIndex = 0\n private var context = JSContext()\n \n func eval(expression: String) -> JSValue! {\n return context?.evaluateScript(expression)\n }\n \n init() {\n let jsSource = \"\"\"\n const state = { name: \"Steve\" };\n \n \"\"\"\n context?.evaluateScript(jsSource)\n }\n \n \n var body: some View {\n VStack {\n Text(String(updateIndex)).hidden()\n VStack(){\n Foo(\n bar: baz\n )\n TextField(){}\n Text(\"Hello\")\n Text(eval(expression: \"\"\"state.name\"\"\"))\n Text(\"! I can run in React, Vue, Solid, or Liquid!\")}\n }\n }\n }\n ";
7
- (0, globals_1.expect)((0, generic_format_1.format)(code)).toMatchSnapshot();
8
- });
@@ -1,2 +0,0 @@
1
- import { StringMap } from '../types/string-map';
2
- export declare function mapToAttributes(map: StringMap): string;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapToAttributes = void 0;
4
- var lodash_1 = require("lodash");
5
- // This list is not exhaustive of all HTML boolean attributes, but we can add more in the future if needed.
6
- var booleanHTMLAttributes = new Set(['checked', 'disabled', 'selected']);
7
- function mapToAttributes(map) {
8
- if (!(0, lodash_1.size)(map)) {
9
- return '';
10
- }
11
- return (0, lodash_1.reduce)(map, function (memo, value, key) {
12
- var attributeValue = " ".concat(key, "=\"").concat(value, "\"");
13
- if (booleanHTMLAttributes.has(key) && value) {
14
- attributeValue = " ".concat(value);
15
- }
16
- return memo + attributeValue;
17
- }, '');
18
- }
19
- exports.mapToAttributes = mapToAttributes;
@@ -1,2 +0,0 @@
1
- import { StringMap } from '../types/string-map';
2
- export declare function mapToCss(map: StringMap, spaces?: number, important?: boolean, uewNewLine?: boolean): string;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapToCss = void 0;
4
- var lodash_1 = require("lodash");
5
- function mapToCss(map, spaces, important, uewNewLine) {
6
- if (spaces === void 0) { spaces = 2; }
7
- if (important === void 0) { important = false; }
8
- if (uewNewLine === void 0) { uewNewLine = spaces > 1; }
9
- return (0, lodash_1.reduce)(map, function (memo, value, key) {
10
- return (memo +
11
- (value && value.trim()
12
- ? "".concat(uewNewLine ? '\n' : '').concat(' '.repeat(spaces)).concat((0, lodash_1.kebabCase)(key), ": ").concat(value + (important ? ' !important' : ''), ";")
13
- : ''));
14
- }, '');
15
- }
16
- exports.mapToCss = mapToCss;
@@ -1,7 +0,0 @@
1
- export declare type ParseReactiveScriptOptions = {
2
- format: 'html' | 'js';
3
- };
4
- export declare const reactiveScriptRe: RegExp;
5
- export declare function parseReactiveScript(code: string, options: ParseReactiveScriptOptions): {
6
- state: any;
7
- };
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.parseReactiveScript = exports.reactiveScriptRe = void 0;
18
- var core_1 = require("@babel/core");
19
- var generator_1 = __importDefault(require("@babel/generator"));
20
- var json5_1 = __importDefault(require("json5"));
21
- var method_literal_prefix_1 = require("../constants/method-literal-prefix");
22
- var jsx_1 = require("../parsers/jsx");
23
- exports.reactiveScriptRe = /<script\s[^>]*reactive[^>]*>([\s\S]*)<\/\s*script>/i;
24
- function parseReactiveScript(code, options) {
25
- var _a;
26
- var state = {};
27
- var format = options.format || 'html';
28
- var useCode = format === 'html' ? ((_a = code.match(exports.reactiveScriptRe)) === null || _a === void 0 ? void 0 : _a[1]) || '' : code;
29
- var output = (0, core_1.transform)(useCode, {
30
- plugins: [
31
- function () { return ({
32
- visitor: {
33
- ExportDefaultDeclaration: function (path) {
34
- if (core_1.types.isObjectExpression(path.node.declaration)) {
35
- var stateProperty = path.node.declaration.properties.find(function (item) {
36
- return core_1.types.isObjectProperty(item) &&
37
- core_1.types.isIdentifier(item.key) &&
38
- item.key.name === 'state';
39
- });
40
- if (stateProperty) {
41
- var value = stateProperty.value;
42
- if (core_1.types.isObjectExpression(value)) {
43
- var properties = value.properties;
44
- var useProperties = properties.map(function (item) {
45
- if (core_1.types.isObjectProperty(item)) {
46
- if (core_1.types.isFunctionExpression(item.value) ||
47
- core_1.types.isArrowFunctionExpression(item.value)) {
48
- return (0, jsx_1.createFunctionStringLiteralObjectProperty)(item.key, item.value);
49
- }
50
- }
51
- if (core_1.types.isObjectMethod(item)) {
52
- return core_1.types.objectProperty(item.key, core_1.types.stringLiteral("".concat(method_literal_prefix_1.methodLiteralPrefix).concat((0, generator_1.default)(__assign(__assign({}, item), { returnType: null })).code)));
53
- }
54
- // Remove typescript types, e.g. from
55
- // { foo: ('string' as SomeType) }
56
- if (core_1.types.isObjectProperty(item)) {
57
- var value_1 = item.value;
58
- if (core_1.types.isTSAsExpression(value_1)) {
59
- value_1 = value_1.expression;
60
- }
61
- return core_1.types.objectProperty(item.key, value_1);
62
- }
63
- return item;
64
- });
65
- var newObject = core_1.types.objectExpression(useProperties);
66
- var code_1;
67
- var obj = void 0;
68
- try {
69
- code_1 = (0, generator_1.default)(newObject).code;
70
- obj = json5_1.default.parse(code_1);
71
- }
72
- catch (err) {
73
- console.error('Could not JSON5 parse object:\n', code_1);
74
- throw err;
75
- }
76
- state = obj;
77
- }
78
- }
79
- }
80
- },
81
- },
82
- }); },
83
- ],
84
- });
85
- return { state: state };
86
- }
87
- exports.parseReactiveScript = parseReactiveScript;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var remove_surrounding_block_1 = require("./remove-surrounding-block");
4
- describe('removeSurroundingBlock', function () {
5
- test('It removes the surrounding wrapper block', function () {
6
- var output = (0, remove_surrounding_block_1.removeSurroundingBlock)('{ const foo = "bar" }');
7
- expect(output).toBe(' const foo = "bar" ');
8
- });
9
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var render_imports_1 = require("./render-imports");
4
- describe('renderImport', function () {
5
- test('Adds correct extension to component import', function () {
6
- var data = [
7
- {
8
- imports: { RenderBlocks: 'default' },
9
- path: '../render-blocks.lite',
10
- },
11
- ];
12
- var output = (0, render_imports_1.renderImport)({
13
- theImport: data[0],
14
- target: 'vue',
15
- asyncComponentImports: false,
16
- });
17
- expect(output).toMatchSnapshot();
18
- });
19
- test('Adds correctly a side-effect import', function () {
20
- var data = [
21
- {
22
- imports: {},
23
- path: '../render-blocks.scss',
24
- },
25
- ];
26
- var output = (0, render_imports_1.renderImport)({
27
- theImport: data[0],
28
- target: 'react',
29
- asyncComponentImports: false,
30
- });
31
- expect(output).toEqual("import '../render-blocks.scss';");
32
- });
33
- });
@@ -1 +0,0 @@
1
- export declare const replaceIdentifiers: (code: string, from: string | string[], to: string | ((identifier: string) => string)) => string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var collect_css_1 = require("./collect-css");
4
- var jsx_1 = require("../../parsers/jsx");
5
- var classRaw = require('../../__tests__/data/styles/class.raw');
6
- var classState = require('../../__tests__/data/styles/classState.raw');
7
- describe('Styles', function () {
8
- test('class property and CSS are merged', function () {
9
- var component = (0, jsx_1.parseJsx)(classRaw);
10
- var output = (0, collect_css_1.collectCss)(component);
11
- expect({ component: component, output: output }).toMatchSnapshot();
12
- });
13
- test('class binding and CSS are merged', function () {
14
- var component = (0, jsx_1.parseJsx)(classState);
15
- var output = (0, collect_css_1.collectCss)(component);
16
- expect({ component: component, output: output }).toMatchSnapshot();
17
- });
18
- });
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- // TODO: import via HTML and/or Vue-esque compiler
@@ -1,70 +0,0 @@
1
- import { BuilderElement } from '@builder.io/sdk';
2
- import { ITemplate } from 'liquidjs';
3
- import * as compiler from 'vue-template-compiler';
4
- /**
5
- * Extract a liquid expression from our JS structure - i.e. transform
6
- * "context.shopify.liquid.condition('some | liquid')" to "some | liquid"
7
- */
8
- export declare const getLiquidConditionExpresion: (expression: string) => string;
9
- interface Options {
10
- emailMode?: boolean;
11
- extractCss?: boolean;
12
- minify?: boolean;
13
- includeJson?: boolean;
14
- skipPrettier?: boolean;
15
- wrap?: boolean;
16
- useBuilderSignature?: boolean;
17
- componentOnly?: boolean;
18
- openingTagOnly?: boolean;
19
- static?: boolean;
20
- looseBindings?: boolean;
21
- }
22
- export declare function blockToLiquid(json: BuilderElement, options?: Options): string;
23
- export declare function humanCase(str: string): string;
24
- export declare const parsedLiquidToHtml: (templates: ITemplate[], options: LiquidToBuilderOptions) => Promise<string>;
25
- export declare const htmlNodeToBuilder: (node: compiler.ASTNode, index: number, parentArray: compiler.ASTNode[], options: LiquidToBuilderOptions) => Promise<BuilderElement | BuilderElement[] | null>;
26
- export declare const liquidToAst: (str: string, options?: LiquidToBuilderOptions) => ITemplate[];
27
- export declare const htmlToAst: (html: string) => {
28
- htmlNodes: compiler.ASTNode[];
29
- preprocessed: compiler.ASTNode[];
30
- };
31
- export declare const separateTagsAndText: (text: string) => compiler.ASTText[];
32
- export declare const postProcessHtmlAstNodes: (nodes: compiler.ASTNode[]) => compiler.ASTNode[];
33
- export declare const postProcessBuilderTree: (nodes: BuilderElement[], options: LiquidToBuilderOptions) => Promise<BuilderElement[]>;
34
- export declare const htmlAstToBuilder: (nodes: compiler.ASTNode[], options: LiquidToBuilderOptions) => Promise<BuilderElement[]>;
35
- export declare const processedAstToBuilder: (nodes: compiler.ASTNode[], options: LiquidToBuilderOptions) => Promise<{
36
- blocks: BuilderElement[];
37
- preprocessed: BuilderElement[];
38
- }>;
39
- export interface LiquidToBuilderOptions {
40
- log?: boolean;
41
- themeId?: string;
42
- importSections?: boolean;
43
- importSnippets?: boolean;
44
- translations?: {
45
- [key: string]: string;
46
- };
47
- cachebust?: boolean;
48
- auth?: {
49
- token?: string;
50
- publicKey?: string;
51
- };
52
- }
53
- export declare const htmlDebugString: (els: BuilderElement[]) => string;
54
- export declare const tryFormat: (str: string) => string;
55
- /**
56
- * This function is the first step, before we turn the liquid into an AST.
57
- * It is used to make certain changes to the liquid string that are much
58
- * easier to do before we process it. Examples of this include rewriting
59
- * certain tags to a format we already know how to parse, or fixing common
60
- * liquid template errors that cause problems during import.
61
- *
62
- * Note: there are a lot of regexes in here, and they can be confusing!
63
- * If you are trying to debug something that includes a regex, try using
64
- * a tool like https://regex101.com/ to break down what is going on.
65
- */
66
- export declare const preprocessLiquid: (liquid: string, options?: LiquidToBuilderOptions) => Promise<string>;
67
- export declare const liquidToBuilder: (liquid: string, options?: LiquidToBuilderOptions) => Promise<BuilderElement[]>;
68
- export declare const htmlToBuilder: (html: string) => Promise<BuilderElement[]>;
69
- export declare const bindingsFromAttrs: (node: compiler.ASTElement, bindings: Record<string, any>, properties: Record<string, any>, options: LiquidToBuilderOptions) => Promise<void>;
70
- export {};