@builder.io/mitosis 0.4.0 → 0.4.2

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 (196) hide show
  1. package/dist/src/constants/media-sizes.js +4 -5
  2. package/dist/src/generators/alpine/generate.js +114 -132
  3. package/dist/src/generators/alpine/render-mount-hook.js +8 -5
  4. package/dist/src/generators/alpine/render-update-hooks.js +13 -13
  5. package/dist/src/generators/angular/helpers.js +19 -9
  6. package/dist/src/generators/angular/index.js +599 -584
  7. package/dist/src/generators/builder.js +200 -165
  8. package/dist/src/generators/context/angular.js +32 -26
  9. package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
  10. package/dist/src/generators/context/qwik.js +21 -21
  11. package/dist/src/generators/context/react.js +22 -22
  12. package/dist/src/generators/context/rsc.js +20 -22
  13. package/dist/src/generators/context/solid.js +22 -22
  14. package/dist/src/generators/context/svelte.js +33 -28
  15. package/dist/src/generators/context/vue.js +1 -1
  16. package/dist/src/generators/helpers/context.js +6 -13
  17. package/dist/src/generators/helpers/functions.js +8 -8
  18. package/dist/src/generators/helpers/on-mount.js +9 -5
  19. package/dist/src/generators/helpers/rsc.js +7 -9
  20. package/dist/src/generators/html.js +995 -534
  21. package/dist/src/generators/liquid.js +81 -79
  22. package/dist/src/generators/lit/collect-class-string.js +10 -12
  23. package/dist/src/generators/lit/generate.js +204 -159
  24. package/dist/src/generators/marko/generate.js +193 -183
  25. package/dist/src/generators/minify.js +5 -9
  26. package/dist/src/generators/mitosis.js +135 -134
  27. package/dist/src/generators/qwik/component-generator.js +159 -154
  28. package/dist/src/generators/qwik/component.js +51 -81
  29. package/dist/src/generators/qwik/directives.js +68 -84
  30. package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
  31. package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
  32. package/dist/src/generators/qwik/helpers/handlers.js +16 -25
  33. package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
  34. package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
  35. package/dist/src/generators/qwik/helpers/state.js +36 -43
  36. package/dist/src/generators/qwik/helpers/styles.js +19 -40
  37. package/dist/src/generators/qwik/jsx.js +63 -75
  38. package/dist/src/generators/qwik/src-generator.js +134 -167
  39. package/dist/src/generators/react/blocks.js +122 -127
  40. package/dist/src/generators/react/generator.js +314 -259
  41. package/dist/src/generators/react/helpers.js +23 -28
  42. package/dist/src/generators/react/state.js +34 -51
  43. package/dist/src/generators/react-native/index.js +72 -84
  44. package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
  45. package/dist/src/generators/rsc.js +30 -36
  46. package/dist/src/generators/solid/blocks.js +46 -43
  47. package/dist/src/generators/solid/helpers/styles.js +11 -11
  48. package/dist/src/generators/solid/index.js +199 -190
  49. package/dist/src/generators/solid/state/helpers.js +76 -90
  50. package/dist/src/generators/solid/state/signals.js +30 -37
  51. package/dist/src/generators/solid/state/state.js +35 -48
  52. package/dist/src/generators/solid/state/store.js +40 -46
  53. package/dist/src/generators/stencil/collect-class-string.js +10 -12
  54. package/dist/src/generators/stencil/generate.js +158 -145
  55. package/dist/src/generators/svelte/blocks.js +146 -144
  56. package/dist/src/generators/svelte/helpers.js +10 -17
  57. package/dist/src/generators/svelte/svelte.js +321 -287
  58. package/dist/src/generators/swift-ui.js +162 -101
  59. package/dist/src/generators/taro.js +32 -36
  60. package/dist/src/generators/template.js +71 -74
  61. package/dist/src/generators/vue/blocks.js +116 -107
  62. package/dist/src/generators/vue/compositionApi.js +67 -50
  63. package/dist/src/generators/vue/helpers.js +71 -96
  64. package/dist/src/generators/vue/optionsApi.js +134 -105
  65. package/dist/src/generators/vue/vue.js +210 -207
  66. package/dist/src/helpers/babel-transform.js +40 -63
  67. package/dist/src/helpers/bindings.js +4 -12
  68. package/dist/src/helpers/camel-case.js +4 -5
  69. package/dist/src/helpers/capitalize.js +1 -1
  70. package/dist/src/helpers/component-file-extensions.js +23 -35
  71. package/dist/src/helpers/create-mitosis-component.js +22 -26
  72. package/dist/src/helpers/create-mitosis-context.js +5 -12
  73. package/dist/src/helpers/create-mitosis-node.js +10 -12
  74. package/dist/src/helpers/dash-case.js +2 -2
  75. package/dist/src/helpers/dedent.js +18 -22
  76. package/dist/src/helpers/event-handlers.js +1 -1
  77. package/dist/src/helpers/fast-clone.js +1 -1
  78. package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
  79. package/dist/src/helpers/generic-format.js +7 -8
  80. package/dist/src/helpers/get-bindings.js +4 -4
  81. package/dist/src/helpers/get-components-used.js +3 -3
  82. package/dist/src/helpers/get-components.js +4 -4
  83. package/dist/src/helpers/get-custom-imports.js +10 -12
  84. package/dist/src/helpers/get-prop-functions.js +7 -8
  85. package/dist/src/helpers/get-props-ref.js +8 -8
  86. package/dist/src/helpers/get-props.js +12 -13
  87. package/dist/src/helpers/get-refs.js +4 -4
  88. package/dist/src/helpers/get-state-object-string.js +42 -61
  89. package/dist/src/helpers/get-state-used.js +7 -8
  90. package/dist/src/helpers/get-styles.js +6 -6
  91. package/dist/src/helpers/getters-to-functions.js +8 -12
  92. package/dist/src/helpers/handle-missing-state.js +3 -3
  93. package/dist/src/helpers/has-bindings-text.js +6 -6
  94. package/dist/src/helpers/has-component.js +4 -4
  95. package/dist/src/helpers/has-props.js +3 -3
  96. package/dist/src/helpers/has-stateful-dom.js +4 -4
  97. package/dist/src/helpers/has.js +3 -3
  98. package/dist/src/helpers/indent.js +2 -3
  99. package/dist/src/helpers/is-children.js +4 -5
  100. package/dist/src/helpers/is-component.js +1 -1
  101. package/dist/src/helpers/is-html-attribute.js +2 -11
  102. package/dist/src/helpers/is-mitosis-node.js +1 -1
  103. package/dist/src/helpers/is-root-text-node.js +1 -1
  104. package/dist/src/helpers/is-upper-case.js +1 -1
  105. package/dist/src/helpers/is-valid-attribute-name.js +1 -1
  106. package/dist/src/helpers/json.js +2 -2
  107. package/dist/src/helpers/map-refs.js +29 -40
  108. package/dist/src/helpers/merge-options.js +20 -31
  109. package/dist/src/helpers/mitosis-imports.js +5 -6
  110. package/dist/src/helpers/nodes/for.js +2 -3
  111. package/dist/src/helpers/nullable.js +1 -3
  112. package/dist/src/helpers/on-event.js +32 -36
  113. package/dist/src/helpers/output.js +4 -5
  114. package/dist/src/helpers/parse-node.js +13 -5
  115. package/dist/src/helpers/parsers.js +10 -14
  116. package/dist/src/helpers/patterns.js +6 -8
  117. package/dist/src/helpers/plugins/process-code/index.js +114 -120
  118. package/dist/src/helpers/plugins/process-signals.js +114 -125
  119. package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
  120. package/dist/src/helpers/process-http-requests.js +8 -4
  121. package/dist/src/helpers/remove-surrounding-block.js +2 -2
  122. package/dist/src/helpers/render-imports.js +99 -111
  123. package/dist/src/helpers/replace-identifiers.js +40 -49
  124. package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
  125. package/dist/src/helpers/signals/signals.js +27 -35
  126. package/dist/src/helpers/slots.js +11 -20
  127. package/dist/src/helpers/state.js +1 -3
  128. package/dist/src/helpers/strip-meta-properties.js +6 -6
  129. package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
  130. package/dist/src/helpers/styles/collect-css.js +39 -44
  131. package/dist/src/helpers/styles/collect-styled-components.js +30 -28
  132. package/dist/src/helpers/styles/helpers.js +23 -29
  133. package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
  134. package/dist/src/helpers/transform-state-setters.js +16 -19
  135. package/dist/src/helpers/traverse-nodes.js +2 -2
  136. package/dist/src/helpers/try-prettier-format.js +3 -3
  137. package/dist/src/helpers/typescript-project.js +25 -25
  138. package/dist/src/helpers/typescript.js +1 -3
  139. package/dist/src/modules/plugins.js +20 -28
  140. package/dist/src/parsers/angular.js +49 -57
  141. package/dist/src/parsers/builder/builder.js +448 -343
  142. package/dist/src/parsers/builder/helpers.js +10 -10
  143. package/dist/src/parsers/context.js +15 -17
  144. package/dist/src/parsers/jsx/ast.js +11 -11
  145. package/dist/src/parsers/jsx/component-types.js +22 -32
  146. package/dist/src/parsers/jsx/context.js +12 -12
  147. package/dist/src/parsers/jsx/element-parser.js +43 -54
  148. package/dist/src/parsers/jsx/exports.js +12 -14
  149. package/dist/src/parsers/jsx/function-parser.js +108 -119
  150. package/dist/src/parsers/jsx/helpers.js +11 -13
  151. package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
  152. package/dist/src/parsers/jsx/hooks/index.js +34 -44
  153. package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
  154. package/dist/src/parsers/jsx/imports.js +7 -17
  155. package/dist/src/parsers/jsx/jsx.js +92 -91
  156. package/dist/src/parsers/jsx/props-types.js +8 -10
  157. package/dist/src/parsers/jsx/props.js +15 -23
  158. package/dist/src/parsers/jsx/signals.js +28 -29
  159. package/dist/src/parsers/jsx/state.d.ts +2 -4
  160. package/dist/src/parsers/jsx/state.js +59 -93
  161. package/dist/src/parsers/svelte/css/index.js +1 -1
  162. package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
  163. package/dist/src/parsers/svelte/helpers/children.js +5 -6
  164. package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
  165. package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
  166. package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
  167. package/dist/src/parsers/svelte/helpers/string.js +5 -5
  168. package/dist/src/parsers/svelte/html/actions.js +17 -10
  169. package/dist/src/parsers/svelte/html/each.js +11 -16
  170. package/dist/src/parsers/svelte/html/element.js +68 -78
  171. package/dist/src/parsers/svelte/html/fragment.js +3 -3
  172. package/dist/src/parsers/svelte/html/if-else.js +11 -18
  173. package/dist/src/parsers/svelte/html/index.js +14 -14
  174. package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
  175. package/dist/src/parsers/svelte/html/slot.js +5 -5
  176. package/dist/src/parsers/svelte/html/text.js +7 -14
  177. package/dist/src/parsers/svelte/index.js +23 -72
  178. package/dist/src/parsers/svelte/instance/context.js +17 -17
  179. package/dist/src/parsers/svelte/instance/expressions.js +2 -2
  180. package/dist/src/parsers/svelte/instance/functions.js +35 -30
  181. package/dist/src/parsers/svelte/instance/hooks.js +4 -5
  182. package/dist/src/parsers/svelte/instance/imports.js +11 -21
  183. package/dist/src/parsers/svelte/instance/index.js +22 -22
  184. package/dist/src/parsers/svelte/instance/properties.js +11 -23
  185. package/dist/src/parsers/svelte/instance/reactive.js +11 -11
  186. package/dist/src/parsers/svelte/instance/references.js +13 -13
  187. package/dist/src/parsers/svelte/instance/statements.js +3 -3
  188. package/dist/src/parsers/svelte/module/index.js +14 -26
  189. package/dist/src/parsers/svelte/typescript/index.js +27 -36
  190. package/dist/src/plugins/compile-away-builder-components.js +223 -156
  191. package/dist/src/plugins/compile-away-components.js +13 -21
  192. package/dist/src/plugins/map-styles.js +7 -7
  193. package/dist/src/symbols/symbol-processor.js +44 -62
  194. package/dist/src/targets.js +19 -19
  195. package/dist/src/types/mitosis-node.js +1 -1
  196. package/package.json +1 -1
@@ -4,13 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.iteratorProperty = exports.lastProperty = exports.isStatement = exports.iif = exports.arrowFnValue = exports.arrowFnBlock = exports.invoke = exports.quote = exports.Imports = exports.Symbol = exports.SrcBuilder = exports.File = void 0;
7
- var parser_typescript_1 = __importDefault(require("prettier/parser-typescript"));
8
- var standalone_1 = require("prettier/standalone");
9
- var html_tags_1 = require("../../constants/html_tags");
10
- var builder_1 = require("../../parsers/builder");
11
- var stable_serialize_1 = require("./helpers/stable-serialize");
12
- var File = /** @class */ (function () {
13
- function File(filename, options, qwikModule, qrlPrefix) {
7
+ const parser_typescript_1 = __importDefault(require("prettier/parser-typescript"));
8
+ const standalone_1 = require("prettier/standalone");
9
+ const html_tags_1 = require("../../constants/html_tags");
10
+ const builder_1 = require("../../parsers/builder");
11
+ const stable_serialize_1 = require("./helpers/stable-serialize");
12
+ class File {
13
+ get module() {
14
+ return this.filename.substr(0, this.filename.lastIndexOf('.'));
15
+ }
16
+ get path() {
17
+ return this.filename;
18
+ }
19
+ get contents() {
20
+ return this.toString();
21
+ }
22
+ constructor(filename, options, qwikModule, qrlPrefix) {
14
23
  this.imports = new Imports();
15
24
  this.exports = new Map();
16
25
  this.filename = filename;
@@ -19,41 +28,19 @@ var File = /** @class */ (function () {
19
28
  this.qwikModule = qwikModule;
20
29
  this.qrlPrefix = qrlPrefix;
21
30
  }
22
- Object.defineProperty(File.prototype, "module", {
23
- get: function () {
24
- return this.filename.substr(0, this.filename.lastIndexOf('.'));
25
- },
26
- enumerable: false,
27
- configurable: true
28
- });
29
- Object.defineProperty(File.prototype, "path", {
30
- get: function () {
31
- return this.filename;
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
- Object.defineProperty(File.prototype, "contents", {
37
- get: function () {
38
- return this.toString();
39
- },
40
- enumerable: false,
41
- configurable: true
42
- });
43
- File.prototype.import = function (module, symbol, as) {
31
+ import(module, symbol, as) {
44
32
  return this.imports.get(module, symbol, as);
45
- };
46
- File.prototype.toQrlChunk = function () {
33
+ }
34
+ toQrlChunk() {
47
35
  return quote(this.qrlPrefix + this.module + '.js');
48
- };
49
- File.prototype.exportConst = function (name, value, locallyVisible) {
50
- if (locallyVisible === void 0) { locallyVisible = false; }
36
+ }
37
+ exportConst(name, value, locallyVisible = false) {
51
38
  if (this.exports.has(name))
52
39
  return;
53
40
  this.exports.set(name, this.src.isModule ? name : 'exports.' + name);
54
41
  this.src.const(name, value, true, locallyVisible);
55
- };
56
- File.prototype.exportDefault = function (symbolName) {
42
+ }
43
+ exportDefault(symbolName) {
57
44
  if (this.options.isPretty) {
58
45
  this.src.emit('\n\n');
59
46
  }
@@ -63,23 +50,22 @@ var File = /** @class */ (function () {
63
50
  else {
64
51
  this.src.emit('module.exports=', symbolName, ';');
65
52
  }
66
- };
67
- File.prototype.toString = function () {
68
- var _this = this;
69
- var srcImports = new SrcBuilder(this, this.options);
70
- var imports = this.imports.imports;
71
- var modules = Array.from(imports.keys()).sort();
72
- modules.forEach(function (module) {
53
+ }
54
+ toString() {
55
+ const srcImports = new SrcBuilder(this, this.options);
56
+ const imports = this.imports.imports;
57
+ const modules = Array.from(imports.keys()).sort();
58
+ modules.forEach((module) => {
73
59
  if (module == '<SELF>')
74
60
  return;
75
- var symbolMap = imports.get(module);
76
- var symbols = Array.from(symbolMap.values());
61
+ const symbolMap = imports.get(module);
62
+ const symbols = Array.from(symbolMap.values());
77
63
  symbols.sort(symbolSort);
78
- if (removeExt(module) !== removeExt(_this.qrlPrefix + _this.filename)) {
64
+ if (removeExt(module) !== removeExt(this.qrlPrefix + this.filename)) {
79
65
  srcImports.import(module, symbols);
80
66
  }
81
67
  });
82
- var source = srcImports.toString() + this.src.toString();
68
+ let source = srcImports.toString() + this.src.toString();
83
69
  if (this.options.isPretty) {
84
70
  try {
85
71
  source = (0, standalone_1.format)(source, {
@@ -101,19 +87,18 @@ var File = /** @class */ (function () {
101
87
  }
102
88
  }
103
89
  return source;
104
- };
105
- return File;
106
- }());
90
+ }
91
+ }
107
92
  exports.File = File;
108
93
  function symbolSort(a, b) {
109
94
  return a.importName < b.importName ? -1 : a.importName === b.importName ? 0 : 1;
110
95
  }
111
96
  function removeExt(filename) {
112
- var indx = filename.lastIndexOf('.');
97
+ const indx = filename.lastIndexOf('.');
113
98
  return indx == -1 ? filename : filename.substr(0, indx);
114
99
  }
115
- var SrcBuilder = /** @class */ (function () {
116
- function SrcBuilder(file, options) {
100
+ class SrcBuilder {
101
+ constructor(file, options) {
117
102
  this.buf = [];
118
103
  this.jsxDepth = 0;
119
104
  /**
@@ -128,8 +113,7 @@ var SrcBuilder = /** @class */ (function () {
128
113
  this.isJSX = options.isJSX;
129
114
  this.isBuilder = options.isBuilder;
130
115
  }
131
- SrcBuilder.prototype.import = function (module, symbols) {
132
- var _this = this;
116
+ import(module, symbols) {
133
117
  if (this.isModule) {
134
118
  this.emit('import');
135
119
  if (symbols.length === 1 && symbols[0].importName === 'default') {
@@ -137,22 +121,22 @@ var SrcBuilder = /** @class */ (function () {
137
121
  }
138
122
  else {
139
123
  this.emit('{');
140
- symbols.forEach(function (symbol) {
124
+ symbols.forEach((symbol) => {
141
125
  if (symbol.importName === symbol.localName) {
142
- _this.emit(symbol.importName);
126
+ this.emit(symbol.importName);
143
127
  }
144
128
  else {
145
- _this.emit(symbol.importName, ' as ', symbol.localName);
129
+ this.emit(symbol.importName, ' as ', symbol.localName);
146
130
  }
147
- _this.emit(',');
131
+ this.emit(',');
148
132
  });
149
133
  this.emit('}');
150
134
  }
151
135
  this.emit('from', quote(module), ';');
152
136
  }
153
137
  else {
154
- symbols.forEach(function (symbol) {
155
- _this.const(symbol.localName, function () {
138
+ symbols.forEach((symbol) => {
139
+ this.const(symbol.localName, function () {
156
140
  this.emit(invoke('require', [quote(module)]));
157
141
  if (symbol.importName !== 'default') {
158
142
  this.emit('.', symbol.importName);
@@ -164,14 +148,10 @@ var SrcBuilder = /** @class */ (function () {
164
148
  this.emit('\n\n');
165
149
  }
166
150
  return this;
167
- };
168
- SrcBuilder.prototype.emit = function () {
169
- var values = [];
170
- for (var _i = 0; _i < arguments.length; _i++) {
171
- values[_i] = arguments[_i];
172
- }
173
- for (var i = 0; i < values.length; i++) {
174
- var value = values[i];
151
+ }
152
+ emit(...values) {
153
+ for (let i = 0; i < values.length; i++) {
154
+ const value = values[i];
175
155
  if (typeof value == 'function') {
176
156
  value.call(this);
177
157
  }
@@ -195,8 +175,8 @@ var SrcBuilder = /** @class */ (function () {
195
175
  }
196
176
  else if (typeof value == 'object') {
197
177
  this.emit('{');
198
- var separator = false;
199
- for (var key in value) {
178
+ let separator = false;
179
+ for (const key in value) {
200
180
  if (Object.prototype.hasOwnProperty.call(value, key)) {
201
181
  if (separator) {
202
182
  this.emit(',');
@@ -212,8 +192,8 @@ var SrcBuilder = /** @class */ (function () {
212
192
  }
213
193
  }
214
194
  return this;
215
- };
216
- SrcBuilder.prototype.push = function (value) {
195
+ }
196
+ push(value) {
217
197
  if (value.startsWith(')') ||
218
198
  value.startsWith(':') ||
219
199
  value.startsWith(']') ||
@@ -221,20 +201,18 @@ var SrcBuilder = /** @class */ (function () {
221
201
  value.startsWith(',') ||
222
202
  value.startsWith('?')) {
223
203
  // clear last ',' or ';';
224
- var index = this.buf.length - 1;
225
- var ch = this.buf[index];
204
+ let index = this.buf.length - 1;
205
+ let ch = this.buf[index];
226
206
  if (ch.endsWith(',') || ch.endsWith(';')) {
227
207
  ch = ch.substring(0, ch.length - 1);
228
208
  this.buf[index] = ch;
229
209
  }
230
210
  }
231
211
  this.buf.push(value);
232
- };
233
- SrcBuilder.prototype.emitList = function (values, sep) {
234
- if (sep === void 0) { sep = ','; }
235
- var separator = false;
236
- for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
237
- var value = values_1[_i];
212
+ }
213
+ emitList(values, sep = ',') {
214
+ let separator = false;
215
+ for (const value of values) {
238
216
  if (separator) {
239
217
  this.emit(sep);
240
218
  }
@@ -242,10 +220,8 @@ var SrcBuilder = /** @class */ (function () {
242
220
  separator = true;
243
221
  }
244
222
  return this;
245
- };
246
- SrcBuilder.prototype.const = function (name, value, export_, locallyVisible) {
247
- if (export_ === void 0) { export_ = false; }
248
- if (locallyVisible === void 0) { locallyVisible = false; }
223
+ }
224
+ const(name, value, export_ = false, locallyVisible = false) {
249
225
  if (export_) {
250
226
  this.emit(this.isModule
251
227
  ? 'export const '
@@ -260,20 +236,20 @@ var SrcBuilder = /** @class */ (function () {
260
236
  }
261
237
  this.emit(';');
262
238
  return this;
263
- };
264
- SrcBuilder.prototype.type = function (def) {
239
+ }
240
+ type(def) {
265
241
  if (this.isTypeScript) {
266
242
  this.emit(':', def);
267
243
  }
268
244
  return this;
269
- };
270
- SrcBuilder.prototype.typeParameters = function (typeParameters) {
245
+ }
246
+ typeParameters(typeParameters) {
271
247
  if (this.isTypeScript && typeParameters && typeParameters.length) {
272
248
  this.emit('<', typeParameters, '>');
273
249
  }
274
- };
275
- SrcBuilder.prototype.jsxExpression = function (expression) {
276
- var previousJsxDepth = this.jsxDepth;
250
+ }
251
+ jsxExpression(expression) {
252
+ const previousJsxDepth = this.jsxDepth;
277
253
  try {
278
254
  if (previousJsxDepth) {
279
255
  this.jsxDepth = 0;
@@ -287,10 +263,10 @@ var SrcBuilder = /** @class */ (function () {
287
263
  }
288
264
  this.jsxDepth = previousJsxDepth;
289
265
  }
290
- };
291
- SrcBuilder.prototype.jsxBegin = function (symbol, props, bindings) {
266
+ }
267
+ jsxBegin(symbol, props, bindings) {
292
268
  this.jsxDepth++;
293
- var self = this;
269
+ const self = this;
294
270
  if (symbol == 'div' && ('href' in props || 'href' in bindings)) {
295
271
  // HACK: if we contain href then we are `a` not `div`
296
272
  symbol = 'a';
@@ -301,60 +277,56 @@ var SrcBuilder = /** @class */ (function () {
301
277
  else {
302
278
  this.emit('h(', literalTagName(symbol), ',{');
303
279
  }
304
- for (var key in props) {
280
+ for (const key in props) {
305
281
  if (Object.prototype.hasOwnProperty.call(props, key) &&
306
282
  !ignoreKey(key) &&
307
283
  !Object.prototype.hasOwnProperty.call(bindings, key)) {
308
284
  emitJsxProp(key, quote(props[key]));
309
285
  }
310
286
  }
311
- var _loop_1 = function (rawKey) {
287
+ for (const rawKey in bindings) {
312
288
  if (bindings[rawKey].type === 'spread') {
313
- if (this_1.isJSX) {
314
- this_1.emit('{...', bindings[rawKey].code, '}');
289
+ if (this.isJSX) {
290
+ this.emit('{...', bindings[rawKey].code, '}');
315
291
  }
316
292
  else {
317
- this_1.emit('...', bindings[rawKey].code);
293
+ this.emit('...', bindings[rawKey].code);
318
294
  }
319
295
  }
320
296
  else if (Object.prototype.hasOwnProperty.call(bindings, rawKey) && !ignoreKey(rawKey)) {
321
- var binding_1 = bindings[rawKey];
322
- binding_1 =
323
- binding_1 && typeof binding_1 == 'object' && 'code' in binding_1 ? binding_1.code : binding_1;
297
+ let binding = bindings[rawKey];
298
+ binding =
299
+ binding && typeof binding == 'object' && 'code' in binding ? binding.code : binding;
324
300
  if (rawKey === 'class' && props.class) {
325
301
  // special case for classes as they can have both static and dynamic binding
326
- binding_1 = quote(props.class + ' ') + '+' + binding_1;
302
+ binding = quote(props.class + ' ') + '+' + binding;
327
303
  }
328
- var key = lastProperty(rawKey);
304
+ let key = lastProperty(rawKey);
329
305
  if (isEvent(key)) {
330
306
  key = key + '$';
331
- binding_1 = "".concat(this_1.file.import(this_1.file.qwikModule, '$').localName, "((event)=>").concat(binding_1, ")");
307
+ binding = `${this.file.import(this.file.qwikModule, '$').localName}((event)=>${binding})`;
332
308
  }
333
- else if (!binding_1 && rawKey in props) {
334
- binding_1 = quote(props[rawKey]);
309
+ else if (!binding && rawKey in props) {
310
+ binding = quote(props[rawKey]);
335
311
  }
336
- else if (binding_1 != null && binding_1 === props[key]) {
312
+ else if (binding != null && binding === props[key]) {
337
313
  // HACK: workaround for the fact that sometimes the `bindings` have string literals
338
314
  // We assume that when the binding content equals prop content.
339
- binding_1 = quote(binding_1);
315
+ binding = quote(binding);
340
316
  }
341
- else if (typeof binding_1 == 'string' && isStatement(binding_1)) {
342
- binding_1 = iif(binding_1);
317
+ else if (typeof binding == 'string' && isStatement(binding)) {
318
+ binding = iif(binding);
343
319
  }
344
320
  if (key === 'hide' || key === 'show') {
345
- var _a = key == 'hide' ? ['"none"', '"inherit"'] : ['"inherit"', '"none"'], truthy_1 = _a[0], falsy_1 = _a[1];
321
+ let [truthy, falsy] = key == 'hide' ? ['"none"', '"inherit"'] : ['"inherit"', '"none"'];
346
322
  emitJsxProp('style', function () {
347
- this.emit('{display:', binding_1, '?', truthy_1, ':', falsy_1, '}');
323
+ this.emit('{display:', binding, '?', truthy, ':', falsy, '}');
348
324
  });
349
325
  }
350
326
  else {
351
- emitJsxProp(key, binding_1);
327
+ emitJsxProp(key, binding);
352
328
  }
353
329
  }
354
- };
355
- var this_1 = this;
356
- for (var rawKey in bindings) {
357
- _loop_1(rawKey);
358
330
  }
359
331
  if (this.isJSX) {
360
332
  if (!this.isSelfClosingTag(symbol)) {
@@ -388,11 +360,11 @@ var SrcBuilder = /** @class */ (function () {
388
360
  }
389
361
  }
390
362
  }
391
- };
392
- SrcBuilder.prototype.isSelfClosingTag = function (symbol) {
363
+ }
364
+ isSelfClosingTag(symbol) {
393
365
  return html_tags_1.SELF_CLOSING_HTML_TAGS.has(String(symbol));
394
- };
395
- SrcBuilder.prototype.jsxEnd = function (symbol) {
366
+ }
367
+ jsxEnd(symbol) {
396
368
  if (this.isJSX) {
397
369
  if (this.isSelfClosingTag(symbol)) {
398
370
  this.emit(' />');
@@ -405,8 +377,8 @@ var SrcBuilder = /** @class */ (function () {
405
377
  this.emit('),');
406
378
  }
407
379
  this.jsxDepth--;
408
- };
409
- SrcBuilder.prototype.jsxBeginFragment = function (symbol) {
380
+ }
381
+ jsxBeginFragment(symbol) {
410
382
  this.jsxDepth++;
411
383
  if (this.isJSX) {
412
384
  this.emit('<>');
@@ -414,8 +386,8 @@ var SrcBuilder = /** @class */ (function () {
414
386
  else {
415
387
  this.emit('h(', symbol.localName, ',null,');
416
388
  }
417
- };
418
- SrcBuilder.prototype.jsxEndFragment = function () {
389
+ }
390
+ jsxEndFragment() {
419
391
  this.jsxDepth--;
420
392
  if (this.isJSX) {
421
393
  this.emit('</>');
@@ -423,20 +395,19 @@ var SrcBuilder = /** @class */ (function () {
423
395
  else {
424
396
  this.emit(')');
425
397
  }
426
- };
427
- SrcBuilder.prototype.jsxTextBinding = function (exp) {
398
+ }
399
+ jsxTextBinding(exp) {
428
400
  if (this.isJSX) {
429
401
  this.emit('{', exp, '}');
430
402
  }
431
403
  else {
432
404
  this.emit(exp);
433
405
  }
434
- };
435
- SrcBuilder.prototype.toString = function () {
406
+ }
407
+ toString() {
436
408
  return this.buf.join('');
437
- };
438
- return SrcBuilder;
439
- }());
409
+ }
410
+ }
440
411
  exports.SrcBuilder = SrcBuilder;
441
412
  function isEvent(name) {
442
413
  return name.startsWith('on') && isUppercase(name.charAt(2)) && !name.endsWith('$');
@@ -444,45 +415,41 @@ function isEvent(name) {
444
415
  function isUppercase(ch) {
445
416
  return ch == ch.toUpperCase();
446
417
  }
447
- var Symbol = /** @class */ (function () {
448
- function Symbol(importName, localName) {
418
+ class Symbol {
419
+ constructor(importName, localName) {
449
420
  this.importName = importName;
450
421
  this.localName = localName;
451
422
  }
452
- return Symbol;
453
- }());
423
+ }
454
424
  exports.Symbol = Symbol;
455
- var Imports = /** @class */ (function () {
456
- function Imports() {
425
+ class Imports {
426
+ constructor() {
457
427
  this.imports = new Map();
458
428
  }
459
- Imports.prototype.get = function (moduleName, symbolName, asVar) {
460
- var importSymbols = this.imports.get(moduleName);
429
+ get(moduleName, symbolName, asVar) {
430
+ let importSymbols = this.imports.get(moduleName);
461
431
  if (!importSymbols) {
462
432
  importSymbols = new Map();
463
433
  this.imports.set(moduleName, importSymbols);
464
434
  }
465
- var symbol = importSymbols.get(symbolName);
435
+ let symbol = importSymbols.get(symbolName);
466
436
  if (!symbol) {
467
437
  symbol = new Symbol(symbolName, asVar || symbolName);
468
438
  importSymbols.set(symbolName, symbol);
469
439
  }
470
440
  return symbol;
471
- };
472
- Imports.prototype.hasImport = function (localName) {
473
- for (var _i = 0, _a = Array.from(this.imports.values()); _i < _a.length; _i++) {
474
- var symbolMap = _a[_i];
475
- for (var _b = 0, _c = Array.from(symbolMap.values()); _b < _c.length; _b++) {
476
- var symbol = _c[_b];
441
+ }
442
+ hasImport(localName) {
443
+ for (const symbolMap of Array.from(this.imports.values())) {
444
+ for (const symbol of Array.from(symbolMap.values())) {
477
445
  if (symbol.localName === localName) {
478
446
  return true;
479
447
  }
480
448
  }
481
449
  }
482
450
  return false;
483
- };
484
- return Imports;
485
- }());
451
+ }
452
+ }
486
453
  exports.Imports = Imports;
487
454
  function ignoreKey(key) {
488
455
  return (key.startsWith('$') ||
@@ -495,12 +462,12 @@ function possiblyQuotePropertyName(key) {
495
462
  return /^\w[\w\d]*$/.test(key) ? key : quote(key);
496
463
  }
497
464
  function quote(text) {
498
- var string = (0, stable_serialize_1.stableJSONserialize)(text);
465
+ const string = (0, stable_serialize_1.stableJSONserialize)(text);
499
466
  // So \u2028 is a line separator character and prettier treats it as such
500
467
  // https://www.fileformat.info/info/unicode/char/2028/index.htm
501
468
  // That means it can't be inside of a string, so we replace it with `\\u2028`.
502
469
  // (see double `\\` vs `\`)
503
- var parts = string.split('\u2028');
470
+ const parts = string.split('\u2028');
504
471
  return parts.join('\\u2028');
505
472
  }
506
473
  exports.quote = quote;
@@ -515,9 +482,9 @@ exports.invoke = invoke;
515
482
  function arrowFnBlock(args, statements, argTypes) {
516
483
  return function () {
517
484
  this.emit('(');
518
- for (var i = 0; i < args.length; i++) {
519
- var arg = args[i];
520
- var type = argTypes && argTypes[i];
485
+ for (let i = 0; i < args.length; i++) {
486
+ const arg = args[i];
487
+ const type = argTypes && argTypes[i];
521
488
  this.emit(arg);
522
489
  if (type && this.file.options.isTypeScript) {
523
490
  this.emit(':', type);
@@ -534,8 +501,8 @@ function arrowFnValue(args, expression) {
534
501
  };
535
502
  }
536
503
  exports.arrowFnValue = arrowFnValue;
537
- var _virtual_index = '_virtual_index;';
538
- var return_virtual_index = 'return _virtual_index;';
504
+ const _virtual_index = '_virtual_index;';
505
+ const return_virtual_index = 'return _virtual_index;';
539
506
  function iif(code) {
540
507
  if (!code)
541
508
  return;
@@ -551,7 +518,7 @@ function iif(code) {
551
518
  };
552
519
  }
553
520
  exports.iif = iif;
554
- var LOWER_CASE = 'a'.charCodeAt(0) - 1;
521
+ const LOWER_CASE = 'a'.charCodeAt(0) - 1;
555
522
  function literalTagName(symbol) {
556
523
  if (typeof symbol == 'string' &&
557
524
  symbol.charCodeAt(0) > LOWER_CASE &&
@@ -581,9 +548,9 @@ function isStatement(code) {
581
548
  // Code starting with `(` is most likely an IFF and hence is an expression.
582
549
  return false;
583
550
  }
584
- var codeNoStrings = code.replace(STRING_LITERAL, 'STRING_LITERAL');
585
- var identifiers = codeNoStrings.split(EXPRESSION_SEPARATORS);
586
- var filteredIdentifiers = identifiers.filter(function (i) {
551
+ const codeNoStrings = code.replace(STRING_LITERAL, 'STRING_LITERAL');
552
+ const identifiers = codeNoStrings.split(EXPRESSION_SEPARATORS);
553
+ const filteredIdentifiers = identifiers.filter((i) => {
587
554
  i = i.trim();
588
555
  return i && !i.match(EXPRESSION_IDENTIFIER);
589
556
  });
@@ -591,13 +558,13 @@ function isStatement(code) {
591
558
  }
592
559
  exports.isStatement = isStatement;
593
560
  // https://regexr.com/6cppf
594
- var STRING_LITERAL = /(["'`])((\\{2})*|((\n|.)*?[^\\](\\{2})*))\1/g;
561
+ const STRING_LITERAL = /(["'`])((\\{2})*|((\n|.)*?[^\\](\\{2})*))\1/g;
595
562
  // https://regexr.com/6cpk4
596
- var EXPRESSION_SEPARATORS = /[()\[\]{}.\?:\-+/*,|&]+/;
563
+ const EXPRESSION_SEPARATORS = /[()\[\]{}.\?:\-+/*,|&]+/;
597
564
  // https://regexr.com/6cpka
598
- var EXPRESSION_IDENTIFIER = /^\s*[a-zA-Z0-9_$]+\s*$/;
565
+ const EXPRESSION_IDENTIFIER = /^\s*[a-zA-Z0-9_$]+\s*$/;
599
566
  function lastProperty(expr) {
600
- var parts = expr.split('.');
567
+ const parts = expr.split('.');
601
568
  return parts[parts.length - 1];
602
569
  }
603
570
  exports.lastProperty = lastProperty;