@builder.io/mitosis 0.0.106 → 0.0.107-0

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 (84) hide show
  1. package/dist/src/constants/hooks.d.ts +7 -0
  2. package/dist/src/constants/hooks.js +7 -0
  3. package/dist/src/constants/html_tags.d.ts +1 -0
  4. package/dist/src/constants/html_tags.js +17 -1
  5. package/dist/src/generators/alpine/generate.js +6 -4
  6. package/dist/src/generators/angular.js +7 -7
  7. package/dist/src/generators/context/svelte.d.ts +6 -2
  8. package/dist/src/generators/context/svelte.js +31 -2
  9. package/dist/src/generators/helpers/context.d.ts +5 -1
  10. package/dist/src/generators/helpers/context.js +8 -1
  11. package/dist/src/generators/html.js +59 -58
  12. package/dist/src/generators/liquid.js +2 -2
  13. package/dist/src/generators/lit/generate.js +6 -4
  14. package/dist/src/generators/marko/generate.js +4 -3
  15. package/dist/src/generators/mitosis.js +4 -3
  16. package/dist/src/generators/qwik/component-generator.js +3 -1
  17. package/dist/src/generators/qwik/src-generator.js +2 -2
  18. package/dist/src/generators/react/blocks.js +2 -2
  19. package/dist/src/generators/react/generator.js +10 -1
  20. package/dist/src/generators/react/types.d.ts +1 -0
  21. package/dist/src/generators/rsc.js +1 -0
  22. package/dist/src/generators/solid/blocks.js +2 -2
  23. package/dist/src/generators/solid/index.js +2 -1
  24. package/dist/src/generators/stencil/generate.js +6 -4
  25. package/dist/src/generators/svelte/blocks.js +3 -3
  26. package/dist/src/generators/svelte/helpers.d.ts +3 -0
  27. package/dist/src/generators/svelte/helpers.js +30 -1
  28. package/dist/src/generators/svelte/svelte.js +40 -9
  29. package/dist/src/generators/template.js +2 -2
  30. package/dist/src/generators/vue/blocks.js +2 -2
  31. package/dist/src/generators/vue/vue.js +3 -1
  32. package/dist/src/helpers/get-state-object-string.d.ts +2 -1
  33. package/dist/src/helpers/get-state-object-string.js +1 -1
  34. package/dist/src/helpers/handle-missing-state.js +1 -1
  35. package/dist/src/helpers/merge-options.d.ts +8 -2
  36. package/dist/src/helpers/merge-options.js +14 -2
  37. package/dist/src/helpers/plugins/process-code/index.d.ts +8 -0
  38. package/dist/src/helpers/plugins/process-code/index.js +79 -0
  39. package/dist/src/helpers/plugins/process-code/types.d.ts +5 -0
  40. package/dist/src/helpers/plugins/process-code/types.js +2 -0
  41. package/dist/src/helpers/plugins/process-signals.d.ts +42 -0
  42. package/dist/src/helpers/plugins/process-signals.js +93 -0
  43. package/dist/src/helpers/plugins/process-target-blocks.d.ts +6 -0
  44. package/dist/src/helpers/plugins/process-target-blocks.js +47 -0
  45. package/dist/src/helpers/process-http-requests.js +1 -1
  46. package/dist/src/helpers/replace-identifiers.d.ts +17 -1
  47. package/dist/src/helpers/replace-identifiers.js +52 -7
  48. package/dist/src/index.d.ts +34 -23
  49. package/dist/src/index.js +0 -52
  50. package/dist/src/parsers/builder/helpers.js +1 -1
  51. package/dist/src/parsers/context.js +14 -1
  52. package/dist/src/parsers/jsx/element-parser.js +1 -3
  53. package/dist/src/parsers/jsx/function-parser.d.ts +0 -3
  54. package/dist/src/parsers/jsx/function-parser.js +41 -43
  55. package/dist/src/parsers/jsx/helpers.d.ts +0 -1
  56. package/dist/src/parsers/jsx/helpers.js +1 -17
  57. package/dist/src/parsers/jsx/hooks/helpers.d.ts +5 -0
  58. package/dist/src/parsers/jsx/hooks/helpers.js +56 -0
  59. package/dist/src/parsers/jsx/hooks/index.d.ts +15 -0
  60. package/dist/src/parsers/jsx/{hooks.js → hooks/index.js} +26 -28
  61. package/dist/src/parsers/jsx/hooks/use-target.d.ts +13 -0
  62. package/dist/src/parsers/jsx/hooks/use-target.js +92 -0
  63. package/dist/src/parsers/jsx/imports.d.ts +2 -0
  64. package/dist/src/parsers/jsx/imports.js +18 -13
  65. package/dist/src/parsers/jsx/index.d.ts +1 -2
  66. package/dist/src/parsers/jsx/index.js +4 -5
  67. package/dist/src/parsers/jsx/jsx.js +64 -13
  68. package/dist/src/parsers/jsx/state.js +33 -20
  69. package/dist/src/parsers/jsx/types-identification.d.ts +41 -0
  70. package/dist/src/parsers/jsx/types-identification.js +236 -0
  71. package/dist/src/parsers/jsx/types.d.ts +10 -0
  72. package/dist/src/parsers/svelte/helpers/post-process.d.ts +2 -1
  73. package/dist/src/parsers/svelte/html/actions.js +1 -0
  74. package/dist/src/targets.d.ts +1 -0
  75. package/dist/src/types/config.d.ts +8 -1
  76. package/dist/src/types/metadata.d.ts +3 -0
  77. package/dist/src/types/metadata.js +2 -0
  78. package/dist/src/types/mitosis-component.d.ts +26 -4
  79. package/dist/src/types/mitosis-context.d.ts +2 -2
  80. package/dist/tsconfig.build.tsbuildinfo +1 -1
  81. package/package.json +5 -2
  82. package/dist/src/helpers/plugins/process-code.d.ts +0 -10
  83. package/dist/src/helpers/plugins/process-code.js +0 -71
  84. package/dist/src/parsers/jsx/hooks.d.ts +0 -14
@@ -5,4 +5,11 @@ export declare const HOOKS: {
5
5
  readonly REF: "useRef";
6
6
  readonly DEFAULT_PROPS: "useDefaultProps";
7
7
  readonly STYLE: "useStyle";
8
+ readonly TARGET: "useTarget";
9
+ readonly METADATA: "useMetadata";
10
+ readonly MOUNT: "onMount";
11
+ readonly UNMOUNT: "onUnMount";
12
+ readonly UPDATE: "onUpdate";
13
+ readonly INIT: "onInit";
14
+ readonly SET_CONTEXT: "setContext";
8
15
  };
@@ -8,4 +8,11 @@ exports.HOOKS = {
8
8
  REF: 'useRef',
9
9
  DEFAULT_PROPS: 'useDefaultProps',
10
10
  STYLE: 'useStyle',
11
+ TARGET: 'useTarget',
12
+ METADATA: 'useMetadata',
13
+ MOUNT: 'onMount',
14
+ UNMOUNT: 'onUnMount',
15
+ UPDATE: 'onUpdate',
16
+ INIT: 'onInit',
17
+ SET_CONTEXT: 'setContext',
11
18
  };
@@ -1 +1,2 @@
1
1
  export declare const VALID_HTML_TAGS: string[];
2
+ export declare const SELF_CLOSING_HTML_TAGS: Set<string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VALID_HTML_TAGS = void 0;
3
+ exports.SELF_CLOSING_HTML_TAGS = exports.VALID_HTML_TAGS = void 0;
4
4
  exports.VALID_HTML_TAGS = [
5
5
  'html',
6
6
  'base',
@@ -180,3 +180,19 @@ exports.VALID_HTML_TAGS = [
180
180
  'use',
181
181
  'view',
182
182
  ];
183
+ exports.SELF_CLOSING_HTML_TAGS = new Set([
184
+ 'area',
185
+ 'base',
186
+ 'br',
187
+ 'col',
188
+ 'embed',
189
+ 'hr',
190
+ 'img',
191
+ 'input',
192
+ 'link',
193
+ 'meta',
194
+ 'param',
195
+ 'source',
196
+ 'track',
197
+ 'wbr',
198
+ ]);
@@ -14,18 +14,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.componentToAlpine = exports.isValidAlpineBinding = exports.checkIsComponentNode = void 0;
15
15
  var lodash_1 = require("lodash");
16
16
  var standalone_1 = require("prettier/standalone");
17
+ var html_tags_1 = require("../../constants/html_tags");
17
18
  var babel_transform_1 = require("../../helpers/babel-transform");
18
19
  var dash_case_1 = require("../../helpers/dash-case");
19
20
  var fast_clone_1 = require("../../helpers/fast-clone");
20
21
  var get_refs_1 = require("../../helpers/get-refs");
21
22
  var get_state_object_string_1 = require("../../helpers/get-state-object-string");
23
+ var merge_options_1 = require("../../helpers/merge-options");
22
24
  var remove_surrounding_block_1 = require("../../helpers/remove-surrounding-block");
23
25
  var replace_identifiers_1 = require("../../helpers/replace-identifiers");
24
26
  var strip_meta_properties_1 = require("../../helpers/strip-meta-properties");
25
27
  var strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-props-refs");
26
28
  var collect_css_1 = require("../../helpers/styles/collect-css");
27
29
  var plugins_1 = require("../../modules/plugins");
28
- var jsx_1 = require("../../parsers/jsx");
29
30
  var mitosis_node_1 = require("../../types/mitosis-node");
30
31
  var render_mount_hook_1 = require("./render-mount-hook");
31
32
  var render_update_hooks_1 = require("./render-update-hooks");
@@ -154,14 +155,15 @@ var blockToAlpine = function (json, options) {
154
155
  str += " ".concat(bind).concat(bindingType === 'spread' ? '' : key, "=\"").concat(useValue, "\" ").replace(':=', '=');
155
156
  }
156
157
  }
157
- return jsx_1.selfClosingTags.has(json.name)
158
+ return html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)
158
159
  ? "".concat(str, " />")
159
160
  : "".concat(str, ">").concat(((_b = json.children) !== null && _b !== void 0 ? _b : []).map(function (item) { return blockToAlpine(item, options); }).join('\n'), "</").concat(json.name, ">");
160
161
  };
161
- var componentToAlpine = function (options) {
162
- if (options === void 0) { options = {}; }
162
+ var componentToAlpine = function (_options) {
163
+ if (_options === void 0) { _options = {}; }
163
164
  return function (_a) {
164
165
  var component = _a.component;
166
+ var options = (0, merge_options_1.initializeOptions)('alpine', _options);
165
167
  var json = (0, fast_clone_1.fastClone)(component);
166
168
  if (options.plugins) {
167
169
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
@@ -53,7 +53,6 @@ var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
53
53
  var strip_state_and_props_refs_1 = require("../helpers/strip-state-and-props-refs");
54
54
  var collect_css_1 = require("../helpers/styles/collect-css");
55
55
  var plugins_1 = require("../modules/plugins");
56
- var jsx_1 = require("../parsers/jsx");
57
56
  var mitosis_node_1 = require("../types/mitosis-node");
58
57
  var merge_options_1 = require("../helpers/merge-options");
59
58
  var process_code_1 = require("../helpers/plugins/process-code");
@@ -189,7 +188,7 @@ var blockToAngular = function (json, options, blockOptions) {
189
188
  str += "[".concat(key, "]=\"").concat(code, "\" ");
190
189
  }
191
190
  }
192
- if (jsx_1.selfClosingTags.has(json.name)) {
191
+ if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)) {
193
192
  return str + ' />';
194
193
  }
195
194
  str += '>';
@@ -215,22 +214,22 @@ var processAngularCode = function (_a) {
215
214
  }), function (newCode) { return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(newCode, { replaceWith: replaceWith }); });
216
215
  };
217
216
  };
217
+ var DEFAULT_OPTIONS = {
218
+ preserveImports: false,
219
+ preserveFileExtensions: false,
220
+ };
218
221
  var componentToAngular = function (userOptions) {
219
222
  if (userOptions === void 0) { userOptions = {}; }
220
223
  return function (_a) {
221
224
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
222
225
  var _component = _a.component;
223
- var DEFAULT_OPTIONS = {
224
- preserveImports: false,
225
- preserveFileExtensions: false,
226
- };
227
226
  // Make a copy we can safely mutate, similar to babel's toolchain
228
227
  var json = (0, fast_clone_1.fastClone)(_component);
229
228
  var contextVars = Object.keys(((_b = json === null || json === void 0 ? void 0 : json.context) === null || _b === void 0 ? void 0 : _b.get) || {});
230
229
  var metaOutputVars = ((_d = (_c = json.meta) === null || _c === void 0 ? void 0 : _c.useMetadata) === null || _d === void 0 ? void 0 : _d.outputs) || [];
231
230
  var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(json), true));
232
231
  var stateVars = Object.keys((json === null || json === void 0 ? void 0 : json.state) || {});
233
- var options = (0, merge_options_1.mergeOptions)(__assign(__assign({}, DEFAULT_OPTIONS), userOptions));
232
+ var options = (0, merge_options_1.initializeOptions)('angular', DEFAULT_OPTIONS, userOptions);
234
233
  options.plugins = __spreadArray(__spreadArray([], (options.plugins || []), true), [
235
234
  (0, process_code_1.CODE_PROCESSOR_PLUGIN)(function (codeType) {
236
235
  switch (codeType) {
@@ -270,6 +269,7 @@ var componentToAngular = function (userOptions) {
270
269
  case 'state':
271
270
  case 'properties':
272
271
  case 'dynamic-jsx-elements':
272
+ case 'types':
273
273
  return function (x) { return x; };
274
274
  }
275
275
  }),
@@ -1,7 +1,11 @@
1
+ import { MitosisContext } from '../../types/mitosis-context';
1
2
  import { BaseTranspilerOptions } from '../../types/transpiler';
3
+ interface ContextToSvelteOptions extends Pick<BaseTranspilerOptions, 'prettier'> {
4
+ }
2
5
  /**
3
6
  * TO-DO: support types
4
7
  */
5
- export declare const contextToSvelte: (options: Pick<BaseTranspilerOptions, "prettier">) => ({ context }: {
6
- context: import("../../types/mitosis-context").MitosisContext;
8
+ export declare const contextToSvelte: (options: ContextToSvelteOptions) => ({ context }: {
9
+ context: MitosisContext;
7
10
  }) => string;
11
+ export {};
@@ -1,8 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.contextToSvelte = void 0;
4
- var context_with_symbol_key_1 = require("./helpers/context-with-symbol-key");
4
+ var standalone_1 = require("prettier/standalone");
5
+ var get_state_object_string_1 = require("../../helpers/get-state-object-string");
5
6
  /**
6
7
  * TO-DO: support types
7
8
  */
8
- exports.contextToSvelte = context_with_symbol_key_1.getContextWithSymbolKey;
9
+ var contextToSvelte = function (options) {
10
+ return function (_a) {
11
+ var context = _a.context;
12
+ var isReactive = context.type === 'reactive';
13
+ var str = "\nconst key = Symbol(); \n".concat(isReactive ? 'import {writable} from "svelte/store";' : '', "\n\nexport default {\n ").concat(context.name, ": ").concat([
14
+ isReactive && 'writable(',
15
+ (0, get_state_object_string_1.stringifyContextValue)(context.value),
16
+ isReactive && ')',
17
+ ]
18
+ .filter(Boolean)
19
+ .join(''), ", \n key \n}\n");
20
+ if (options.prettier !== false) {
21
+ try {
22
+ str = (0, standalone_1.format)(str, {
23
+ parser: 'typescript',
24
+ plugins: [
25
+ require('prettier/parser-typescript'), // To support running in browsers
26
+ ],
27
+ });
28
+ }
29
+ catch (err) {
30
+ console.error('Format error for file:', str);
31
+ throw err;
32
+ }
33
+ }
34
+ return str;
35
+ };
36
+ };
37
+ exports.contextToSvelte = contextToSvelte;
@@ -1,4 +1,8 @@
1
- import { MitosisComponent } from '../../types/mitosis-component';
1
+ import { ContextGetInfo, ContextSetInfo, MitosisComponent, ReactivityType } from '../../types/mitosis-component';
2
2
  export declare const hasContext: (component: MitosisComponent) => boolean;
3
3
  export declare const hasSetContext: (component: MitosisComponent) => boolean;
4
4
  export declare const hasGetContext: (component: MitosisComponent) => boolean;
5
+ export declare const getContextType: ({ component, context, }: {
6
+ component: MitosisComponent;
7
+ context: ContextGetInfo | ContextSetInfo;
8
+ }) => ReactivityType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasGetContext = exports.hasSetContext = exports.hasContext = void 0;
3
+ exports.getContextType = exports.hasGetContext = exports.hasSetContext = exports.hasContext = void 0;
4
4
  var hasContext = function (component) {
5
5
  return (0, exports.hasSetContext)(component) || (0, exports.hasGetContext)(component);
6
6
  };
@@ -13,3 +13,10 @@ var hasGetContext = function (component) {
13
13
  return Object.keys(component.context.get).length > 0;
14
14
  };
15
15
  exports.hasGetContext = hasGetContext;
16
+ var getContextType = function (_a) {
17
+ var _b, _c;
18
+ var component = _a.component, context = _a.context;
19
+ // TO-DO: remove useMetadata check if no longer needed.
20
+ return ((_c = (_b = component.meta.useMetadata) === null || _b === void 0 ? void 0 : _b.contextTypes) === null || _c === void 0 ? void 0 : _c[context.name]) || context.type || 'normal';
21
+ };
22
+ exports.getContextType = getContextType;
@@ -25,9 +25,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.componentToCustomElement = exports.componentToHtml = void 0;
27
27
  var core_1 = require("@babel/core");
28
+ var function_1 = require("fp-ts/lib/function");
28
29
  var lodash_1 = require("lodash");
29
30
  var standalone_1 = require("prettier/standalone");
30
31
  var traverse_1 = __importDefault(require("traverse"));
32
+ var html_tags_1 = require("../constants/html_tags");
31
33
  var babel_transform_1 = require("../helpers/babel-transform");
32
34
  var dash_case_1 = require("../helpers/dash-case");
33
35
  var fast_clone_1 = require("../helpers/fast-clone");
@@ -45,16 +47,15 @@ var is_component_1 = require("../helpers/is-component");
45
47
  var is_html_attribute_1 = require("../helpers/is-html-attribute");
46
48
  var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
47
49
  var map_refs_1 = require("../helpers/map-refs");
50
+ var merge_options_1 = require("../helpers/merge-options");
51
+ var for_1 = require("../helpers/nodes/for");
48
52
  var remove_surrounding_block_1 = require("../helpers/remove-surrounding-block");
49
53
  var render_imports_1 = require("../helpers/render-imports");
50
54
  var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
51
55
  var strip_state_and_props_refs_1 = require("../helpers/strip-state-and-props-refs");
52
56
  var collect_css_1 = require("../helpers/styles/collect-css");
53
57
  var plugins_1 = require("../modules/plugins");
54
- var jsx_1 = require("../parsers/jsx");
55
58
  var mitosis_node_1 = require("../types/mitosis-node");
56
- var function_1 = require("fp-ts/lib/function");
57
- var for_1 = require("../helpers/nodes/for");
58
59
  var isAttribute = function (key) {
59
60
  return /-/.test(key);
60
61
  };
@@ -352,7 +353,7 @@ var blockToHtml = function (json, options, blockOptions) {
352
353
  return "const ".concat(scopeVar, " = ").concat(options.format === 'class' ? 'this.' : '', "getScope(el, \"").concat(scopeVar, "\");");
353
354
  }), "\n "));
354
355
  }
355
- if (jsx_1.selfClosingTags.has(json.name)) {
356
+ if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)) {
356
357
  return str + ' />';
357
358
  }
358
359
  str += '>';
@@ -413,17 +414,17 @@ function addUpdateAfterSetInCode(code, options, useString) {
413
414
  }
414
415
  var htmlDecode = function (html) { return html.replace(/&quot;/gi, '"'); };
415
416
  // TODO: props support via custom elements
416
- var componentToHtml = function (options) {
417
- if (options === void 0) { options = {}; }
417
+ var componentToHtml = function (_options) {
418
+ if (_options === void 0) { _options = {}; }
418
419
  return function (_a) {
419
420
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
420
421
  var component = _a.component;
421
- var useOptions = __assign(__assign({}, options), { onChangeJsById: {}, js: '', namesMap: {}, format: 'script' });
422
+ var options = (0, merge_options_1.initializeOptions)('html', __assign(__assign({}, _options), { onChangeJsById: {}, js: '', namesMap: {}, format: 'script' }));
422
423
  var json = (0, fast_clone_1.fastClone)(component);
423
424
  if (options.plugins) {
424
425
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
425
426
  }
426
- addUpdateAfterSet(json, useOptions);
427
+ addUpdateAfterSet(json, options);
427
428
  var componentHasProps = (0, has_props_1.hasProps)(json);
428
429
  var hasLoop = (0, has_component_1.hasComponent)('For', json);
429
430
  var hasShow = (0, has_component_1.hasComponent)('Show', json);
@@ -434,23 +435,23 @@ var componentToHtml = function (options) {
434
435
  var css = (0, collect_css_1.collectCss)(json, {
435
436
  prefix: options.prefix,
436
437
  });
437
- var str = json.children.map(function (item) { return blockToHtml(item, useOptions); }).join('\n');
438
+ var str = json.children.map(function (item) { return blockToHtml(item, options); }).join('\n');
438
439
  if (css.trim().length) {
439
440
  str += "<style>".concat(css, "</style>");
440
441
  }
441
- var hasChangeListeners = Boolean(Object.keys(useOptions.onChangeJsById).length);
442
- var hasGeneratedJs = Boolean(useOptions.js.trim().length);
442
+ var hasChangeListeners = Boolean(Object.keys(options.onChangeJsById).length);
443
+ var hasGeneratedJs = Boolean(options.js.trim().length);
443
444
  if (hasChangeListeners || hasGeneratedJs || ((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) || hasLoop) {
444
445
  // TODO: collectJs helper for here and liquid
445
446
  str += "\n <script>\n (() => {\n const state = ".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
446
447
  valueMapper: function (value) {
447
- return addUpdateAfterSetInCode(updateReferencesInCode(value, useOptions), useOptions);
448
+ return addUpdateAfterSetInCode(updateReferencesInCode(value, options), options);
448
449
  },
449
450
  }), ";\n ").concat(componentHasProps ? "let props = {};" : '', "\n let context = null;\n let nodesToDestroy = [];\n let pendingUpdate = false;\n ").concat(!((_d = (_c = json.hooks) === null || _c === void 0 ? void 0 : _c.onInit) === null || _d === void 0 ? void 0 : _d.code) ? '' : 'let onInitOnce = false;', "\n\n function destroyAnyNodes() {\n // destroy current view template refs before rendering again\n nodesToDestroy.forEach(el => el.remove());\n nodesToDestroy = [];\n }\n ").concat(!hasChangeListeners
450
451
  ? ''
451
- : "\n \n // Function to update data bindings and loops\n // call update() when you mutate state and need the updates to reflect\n // in the dom\n function update() {\n if (pendingUpdate === true) {\n return;\n }\n pendingUpdate = true;\n ".concat(Object.keys(useOptions.onChangeJsById)
452
+ : "\n \n // Function to update data bindings and loops\n // call update() when you mutate state and need the updates to reflect\n // in the dom\n function update() {\n if (pendingUpdate === true) {\n return;\n }\n pendingUpdate = true;\n ".concat(Object.keys(options.onChangeJsById)
452
453
  .map(function (key) {
453
- var value = useOptions.onChangeJsById[key];
454
+ var value = options.onChangeJsById[key];
454
455
  if (!value) {
455
456
  return '';
456
457
  }
@@ -459,14 +460,14 @@ var componentToHtml = function (options) {
459
460
  .join('\n\n'), "\n\n destroyAnyNodes();\n\n ").concat(!((_e = json.hooks.onUpdate) === null || _e === void 0 ? void 0 : _e.length)
460
461
  ? ''
461
462
  : "\n ".concat(json.hooks.onUpdate.reduce(function (code, hook) {
462
- code += addUpdateAfterSetInCode(updateReferencesInCode(hook.code, useOptions), useOptions);
463
+ code += addUpdateAfterSetInCode(updateReferencesInCode(hook.code, options), options);
463
464
  return code + '\n';
464
- }, ''), " \n "), "\n\n pendingUpdate = false;\n }\n\n ").concat(useOptions.js, "\n\n // Update with initial state on first load\n update();\n "), "\n\n ").concat(!((_g = (_f = json.hooks) === null || _f === void 0 ? void 0 : _f.onInit) === null || _g === void 0 ? void 0 : _g.code)
465
+ }, ''), " \n "), "\n\n pendingUpdate = false;\n }\n\n ").concat(options.js, "\n\n // Update with initial state on first load\n update();\n "), "\n\n ").concat(!((_g = (_f = json.hooks) === null || _f === void 0 ? void 0 : _f.onInit) === null || _g === void 0 ? void 0 : _g.code)
465
466
  ? ''
466
- : "\n if (!onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((_j = (_h = json.hooks) === null || _h === void 0 ? void 0 : _h.onInit) === null || _j === void 0 ? void 0 : _j.code, useOptions), useOptions), "\n onInitOnce = true;\n }\n "), "\n\n ").concat(!((_k = json.hooks.onMount) === null || _k === void 0 ? void 0 : _k.code)
467
+ : "\n if (!onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((_j = (_h = json.hooks) === null || _h === void 0 ? void 0 : _h.onInit) === null || _j === void 0 ? void 0 : _j.code, options), options), "\n onInitOnce = true;\n }\n "), "\n\n ").concat(!((_k = json.hooks.onMount) === null || _k === void 0 ? void 0 : _k.code)
467
468
  ? ''
468
469
  : // TODO: make prettier by grabbing only the function body
469
- "\n // onMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onMount.code, useOptions), useOptions), " \n "), "\n\n ").concat(!hasShow
470
+ "\n // onMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onMount.code, options), options), " \n "), "\n\n ").concat(!hasShow
470
471
  ? ''
471
472
  : "\n function showContent(el) {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content\n // grabs the content of a node that is between <template> tags\n // iterates through child nodes to register all content including text elements\n // attaches the content after the template\n \n \n const elementFragment = el.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n children.forEach(child => {\n if (el?.scope) {\n child.scope = el.scope;\n }\n if (el?.context) {\n child.context = el.context;\n }\n nodesToDestroy.push(child);\n });\n el.after(elementFragment);\n }\n \n ", "\n ").concat(!hasTextBinding
472
473
  ? ''
@@ -502,21 +503,21 @@ var componentToHtml = function (options) {
502
503
  };
503
504
  exports.componentToHtml = componentToHtml;
504
505
  // TODO: props support via custom elements
505
- var componentToCustomElement = function (options) {
506
- if (options === void 0) { options = {}; }
506
+ var componentToCustomElement = function (_options) {
507
+ if (_options === void 0) { _options = {}; }
507
508
  return function (_a) {
508
509
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
509
510
  var component = _a.component;
510
511
  var ComponentName = component.name;
511
512
  var kebabName = (0, lodash_1.kebabCase)(ComponentName);
512
- var useOptions = __assign(__assign({ prefix: kebabName }, options), { onChangeJsById: {}, js: '', namesMap: {}, format: 'class' });
513
+ var options = (0, merge_options_1.initializeOptions)('customElement', __assign(__assign({ prefix: kebabName }, _options), { onChangeJsById: {}, js: '', namesMap: {}, format: 'class' }));
513
514
  var json = (0, fast_clone_1.fastClone)(component);
514
515
  if (options.plugins) {
515
516
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
516
517
  }
517
518
  var _15 = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _15[0], hasPropRef = _15[1];
518
519
  var contextVars = Object.keys(((_b = json === null || json === void 0 ? void 0 : json.context) === null || _b === void 0 ? void 0 : _b.get) || {});
519
- var childComponents = getChildComponents(json, useOptions);
520
+ var childComponents = getChildComponents(json, options);
520
521
  var componentHasProps = (0, has_props_1.hasProps)(json);
521
522
  var componentHasStatefulDom = (0, has_stateful_dom_1.hasStatefulDom)(json);
522
523
  var props = (0, get_props_1.getProps)(json);
@@ -541,7 +542,7 @@ var componentToCustomElement = function (options) {
541
542
  var _16 = json.context.set[key], name_1 = _16.name, value = _16.value, ref = _16.ref;
542
543
  setContext.push({ name: name_1, value: value, ref: ref });
543
544
  }
544
- addUpdateAfterSet(json, useOptions);
545
+ addUpdateAfterSet(json, options);
545
546
  var hasContext = context.length;
546
547
  var hasLoop = (0, has_component_1.hasComponent)('For', json);
547
548
  var hasScope = hasLoop;
@@ -550,8 +551,8 @@ var componentToCustomElement = function (options) {
550
551
  json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
551
552
  }
552
553
  var css = '';
553
- if ((_c = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _c === void 0 ? void 0 : _c.css) {
554
- css = (_d = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _d === void 0 ? void 0 : _d.css(json, useOptions, {
554
+ if ((_c = options === null || options === void 0 ? void 0 : options.experimental) === null || _c === void 0 ? void 0 : _c.css) {
555
+ css = (_d = options === null || options === void 0 ? void 0 : options.experimental) === null || _d === void 0 ? void 0 : _d.css(json, options, {
555
556
  collectCss: collect_css_1.collectCss,
556
557
  prefix: options.prefix,
557
558
  });
@@ -564,7 +565,7 @@ var componentToCustomElement = function (options) {
564
565
  (0, strip_meta_properties_1.stripMetaProperties)(json);
565
566
  var html = json.children
566
567
  .map(function (item) {
567
- return blockToHtml(item, useOptions, {
568
+ return blockToHtml(item, options, {
568
569
  childComponents: childComponents,
569
570
  props: props,
570
571
  outputs: outputs,
@@ -573,11 +574,11 @@ var componentToCustomElement = function (options) {
573
574
  });
574
575
  })
575
576
  .join('\n');
576
- if ((_e = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _e === void 0 ? void 0 : _e.childrenHtml) {
577
- html = (_f = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _f === void 0 ? void 0 : _f.childrenHtml(html, kebabName, json, useOptions);
577
+ if ((_e = options === null || options === void 0 ? void 0 : options.experimental) === null || _e === void 0 ? void 0 : _e.childrenHtml) {
578
+ html = (_f = options === null || options === void 0 ? void 0 : options.experimental) === null || _f === void 0 ? void 0 : _f.childrenHtml(html, kebabName, json, options);
578
579
  }
579
- if ((_g = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _g === void 0 ? void 0 : _g.cssHtml) {
580
- html += (_h = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _h === void 0 ? void 0 : _h.cssHtml(css);
580
+ if ((_g = options === null || options === void 0 ? void 0 : options.experimental) === null || _g === void 0 ? void 0 : _g.cssHtml) {
581
+ html += (_h = options === null || options === void 0 ? void 0 : options.experimental) === null || _h === void 0 ? void 0 : _h.cssHtml(css);
581
582
  }
582
583
  else if (css.length) {
583
584
  html += "<style>".concat(css, "</style>");
@@ -601,8 +602,8 @@ var componentToCustomElement = function (options) {
601
602
  console.warn('Could not prettify', { string: html }, err);
602
603
  }
603
604
  }
604
- var str = "\n ".concat(json.types ? json.types.join('\n') : '', "\n ").concat((0, render_imports_1.renderPreComponent)({ component: json, target: 'customElement' }), "\n /**\n * Usage:\n * \n * <").concat(kebabName, "></").concat(kebabName, ">\n * \n */\n class ").concat(ComponentName, " extends ").concat(((_j = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _j === void 0 ? void 0 : _j.classExtends)
605
- ? (_k = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _k === void 0 ? void 0 : _k.classExtends(json, useOptions)
605
+ var str = "\n ".concat(json.types ? json.types.join('\n') : '', "\n ").concat((0, render_imports_1.renderPreComponent)({ component: json, target: 'customElement' }), "\n /**\n * Usage:\n * \n * <").concat(kebabName, "></").concat(kebabName, ">\n * \n */\n class ").concat(ComponentName, " extends ").concat(((_j = options === null || options === void 0 ? void 0 : options.experimental) === null || _j === void 0 ? void 0 : _j.classExtends)
606
+ ? (_k = options === null || options === void 0 ? void 0 : options.experimental) === null || _k === void 0 ? void 0 : _k.classExtends(json, options)
606
607
  : 'HTMLElement', " {\n ").concat(Array.from(domRefs)
607
608
  .map(function (ref) {
608
609
  return "\n get _".concat(ref, "() {\n return this._root.querySelector(\"[data-ref='").concat(ComponentName, "-").concat(ref, "']\")\n }\n ");
@@ -613,7 +614,7 @@ var componentToCustomElement = function (options) {
613
614
  ? "this.context = ".concat(setContext[0].ref)
614
615
  : '', "\n\n ").concat(!((_o = (_m = json.hooks) === null || _m === void 0 ? void 0 : _m.onInit) === null || _o === void 0 ? void 0 : _o.code) ? '' : 'this.onInitOnce = false;', "\n\n this.state = ").concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
615
616
  valueMapper: function (value) {
616
- return (0, function_1.pipe)((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(addUpdateAfterSetInCode(value, useOptions, 'self.update'), {
617
+ return (0, function_1.pipe)((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(addUpdateAfterSetInCode(value, options, 'self.update'), {
617
618
  includeProps: false,
618
619
  includeState: true,
619
620
  // TODO: if it's an arrow function it's this.state.
@@ -640,9 +641,9 @@ var componentToCustomElement = function (options) {
640
641
  .map(function (prop) { return "\"".concat(prop, "\""); })
641
642
  .join(','), "];\n "), "\n\n ").concat(!((_p = json.hooks.onUpdate) === null || _p === void 0 ? void 0 : _p.length)
642
643
  ? ''
643
- : "\n this.updateDeps = [".concat((_q = json.hooks.onUpdate) === null || _q === void 0 ? void 0 : _q.map(function (hook) { return updateReferencesInCode((hook === null || hook === void 0 ? void 0 : hook.deps) || '[]', useOptions); }).join(','), "];\n "), "\n\n // used to keep track of all nodes created by show/for\n this.nodesToDestroy = [];\n // batch updates\n this.pendingUpdate = false;\n ").concat(((_r = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _r === void 0 ? void 0 : _r.componentConstructor)
644
- ? (_s = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _s === void 0 ? void 0 : _s.componentConstructor(json, useOptions)
645
- : '', "\n\n ").concat(useOptions.js, "\n\n ").concat(jsRefs
644
+ : "\n this.updateDeps = [".concat((_q = json.hooks.onUpdate) === null || _q === void 0 ? void 0 : _q.map(function (hook) { return updateReferencesInCode((hook === null || hook === void 0 ? void 0 : hook.deps) || '[]', options); }).join(','), "];\n "), "\n\n // used to keep track of all nodes created by show/for\n this.nodesToDestroy = [];\n // batch updates\n this.pendingUpdate = false;\n ").concat(((_r = options === null || options === void 0 ? void 0 : options.experimental) === null || _r === void 0 ? void 0 : _r.componentConstructor)
645
+ ? (_s = options === null || options === void 0 ? void 0 : options.experimental) === null || _s === void 0 ? void 0 : _s.componentConstructor(json, options)
646
+ : '', "\n\n ").concat(options.js, "\n\n ").concat(jsRefs
646
647
  .map(function (ref) {
647
648
  var _a;
648
649
  // const typeParameter = json['refs'][ref]?.typeParameter || '';
@@ -651,44 +652,44 @@ var componentToCustomElement = function (options) {
651
652
  })
652
653
  .join('\n'), "\n\n if (").concat((_t = json.meta.useMetadata) === null || _t === void 0 ? void 0 : _t.isAttachedToShadowDom, ") {\n this.attachShadow({ mode: 'open' })\n }\n }\n\n\n ").concat(!((_u = json.hooks.onUnMount) === null || _u === void 0 ? void 0 : _u.code)
653
654
  ? ''
654
- : "\n disconnectedCallback() {\n ".concat(((_v = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _v === void 0 ? void 0 : _v.disconnectedCallback)
655
- ? (_w = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _w === void 0 ? void 0 : _w.disconnectedCallback(json, useOptions)
656
- : "\n // onUnMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onUnMount.code, useOptions), useOptions, {
655
+ : "\n disconnectedCallback() {\n ".concat(((_v = options === null || options === void 0 ? void 0 : options.experimental) === null || _v === void 0 ? void 0 : _v.disconnectedCallback)
656
+ ? (_w = options === null || options === void 0 ? void 0 : options.experimental) === null || _w === void 0 ? void 0 : _w.disconnectedCallback(json, options)
657
+ : "\n // onUnMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onUnMount.code, options), options, {
657
658
  contextVars: contextVars,
658
659
  }), "\n this.destroyAnyNodes(); // clean up nodes when component is destroyed\n ").concat(!((_y = (_x = json.hooks) === null || _x === void 0 ? void 0 : _x.onInit) === null || _y === void 0 ? void 0 : _y.code) ? '' : 'this.onInitOnce = false;', "\n "), "\n }\n "), "\n\n destroyAnyNodes() {\n // destroy current view template refs before rendering again\n this.nodesToDestroy.forEach(el => el.remove());\n this.nodesToDestroy = [];\n }\n\n connectedCallback() {\n ").concat(context.join('\n'), "\n ").concat(!componentHasProps
659
660
  ? ''
660
- : "\n this.getAttributeNames().forEach((attr) => {\n const jsVar = attr.replace(/-/g, '');\n const regexp = new RegExp(jsVar, 'i');\n this.componentProps.forEach(prop => {\n if (regexp.test(prop)) {\n const attrValue = this.getAttribute(attr);\n if (this.props[prop] !== attrValue) {\n this.props[prop] = attrValue;\n }\n }\n });\n });\n ", "\n ").concat(((_z = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _z === void 0 ? void 0 : _z.connectedCallbackUpdate)
661
- ? (_0 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _0 === void 0 ? void 0 : _0.connectedCallbackUpdate(json, html, useOptions)
661
+ : "\n this.getAttributeNames().forEach((attr) => {\n const jsVar = attr.replace(/-/g, '');\n const regexp = new RegExp(jsVar, 'i');\n this.componentProps.forEach(prop => {\n if (regexp.test(prop)) {\n const attrValue = this.getAttribute(attr);\n if (this.props[prop] !== attrValue) {\n this.props[prop] = attrValue;\n }\n }\n });\n });\n ", "\n ").concat(((_z = options === null || options === void 0 ? void 0 : options.experimental) === null || _z === void 0 ? void 0 : _z.connectedCallbackUpdate)
662
+ ? (_0 = options === null || options === void 0 ? void 0 : options.experimental) === null || _0 === void 0 ? void 0 : _0.connectedCallbackUpdate(json, html, options)
662
663
  : "\n this._root.innerHTML = `\n ".concat(html, "`;\n this.pendingUpdate = true;\n ").concat(!((_2 = (_1 = json.hooks) === null || _1 === void 0 ? void 0 : _1.onInit) === null || _2 === void 0 ? void 0 : _2.code) ? '' : 'this.onInit();', "\n this.render();\n this.onMount();\n this.pendingUpdate = false;\n this.update();\n "), "\n }\n ").concat(!((_4 = (_3 = json.hooks) === null || _3 === void 0 ? void 0 : _3.onInit) === null || _4 === void 0 ? void 0 : _4.code)
663
664
  ? ''
664
665
  : "\n onInit() {\n ".concat(!((_6 = (_5 = json.hooks) === null || _5 === void 0 ? void 0 : _5.onInit) === null || _6 === void 0 ? void 0 : _6.code)
665
666
  ? ''
666
- : "\n if (!this.onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((_8 = (_7 = json.hooks) === null || _7 === void 0 ? void 0 : _7.onInit) === null || _8 === void 0 ? void 0 : _8.code, useOptions), useOptions, {
667
+ : "\n if (!this.onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((_8 = (_7 = json.hooks) === null || _7 === void 0 ? void 0 : _7.onInit) === null || _8 === void 0 ? void 0 : _8.code, options), options, {
667
668
  contextVars: contextVars,
668
669
  }), "\n this.onInitOnce = true;\n }"), "\n }\n "), "\n\n ").concat(!hasShow
669
670
  ? ''
670
- : "\n showContent(el) {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content\n // grabs the content of a node that is between <template> tags\n // iterates through child nodes to register all content including text elements\n // attaches the content after the template\n \n \n const elementFragment = el.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n children.forEach(child => {\n if (el?.scope) {\n child.scope = el.scope;\n }\n if (el?.context) {\n child.context = el.context;\n }\n this.nodesToDestroy.push(child);\n });\n el.after(elementFragment);\n }", "\n ").concat(!((_9 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _9 === void 0 ? void 0 : _9.attributeChangedCallback)
671
+ : "\n showContent(el) {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content\n // grabs the content of a node that is between <template> tags\n // iterates through child nodes to register all content including text elements\n // attaches the content after the template\n \n \n const elementFragment = el.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n children.forEach(child => {\n if (el?.scope) {\n child.scope = el.scope;\n }\n if (el?.context) {\n child.context = el.context;\n }\n this.nodesToDestroy.push(child);\n });\n el.after(elementFragment);\n }", "\n ").concat(!((_9 = options === null || options === void 0 ? void 0 : options.experimental) === null || _9 === void 0 ? void 0 : _9.attributeChangedCallback)
671
672
  ? ''
672
- : "\n attributeChangedCallback(name, oldValue, newValue) {\n ".concat((_10 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _10 === void 0 ? void 0 : _10.attributeChangedCallback(['name', 'oldValue', 'newValue'], json, useOptions), "\n }\n "), "\n\n onMount() {\n ").concat(!((_11 = json.hooks.onMount) === null || _11 === void 0 ? void 0 : _11.code)
673
+ : "\n attributeChangedCallback(name, oldValue, newValue) {\n ".concat((_10 = options === null || options === void 0 ? void 0 : options.experimental) === null || _10 === void 0 ? void 0 : _10.attributeChangedCallback(['name', 'oldValue', 'newValue'], json, options), "\n }\n "), "\n\n onMount() {\n ").concat(!((_11 = json.hooks.onMount) === null || _11 === void 0 ? void 0 : _11.code)
673
674
  ? ''
674
675
  : // TODO: make prettier by grabbing only the function body
675
- "\n // onMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onMount.code, useOptions), useOptions, {
676
+ "\n // onMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onMount.code, options), options, {
676
677
  contextVars: contextVars,
677
678
  }), "\n "), "\n }\n\n onUpdate() {\n ").concat(!((_12 = json.hooks.onUpdate) === null || _12 === void 0 ? void 0 : _12.length)
678
679
  ? ''
679
680
  : "\n const self = this;\n ".concat(json.hooks.onUpdate.reduce(function (code, hook, index) {
680
681
  // create check update
681
682
  if (hook === null || hook === void 0 ? void 0 : hook.deps) {
682
- code += "\n ;(function (__prev, __next) {\n const __hasChange = __prev.find((val, index) => val !== __next[index]);\n if (__hasChange !== undefined) {\n ".concat(updateReferencesInCode(hook.code, useOptions, {
683
+ code += "\n ;(function (__prev, __next) {\n const __hasChange = __prev.find((val, index) => val !== __next[index]);\n if (__hasChange !== undefined) {\n ".concat(updateReferencesInCode(hook.code, options, {
683
684
  contextVars: contextVars,
684
685
  context: 'self.',
685
- }), "\n self.updateDeps[").concat(index, "] = __next;\n }\n }(self.updateDeps[").concat(index, "], ").concat(updateReferencesInCode((hook === null || hook === void 0 ? void 0 : hook.deps) || '[]', useOptions, {
686
+ }), "\n self.updateDeps[").concat(index, "] = __next;\n }\n }(self.updateDeps[").concat(index, "], ").concat(updateReferencesInCode((hook === null || hook === void 0 ? void 0 : hook.deps) || '[]', options, {
686
687
  contextVars: contextVars,
687
688
  context: 'self.',
688
689
  }), "));\n ");
689
690
  }
690
691
  else {
691
- code += "\n ".concat(updateReferencesInCode(hook.code, useOptions, {
692
+ code += "\n ".concat(updateReferencesInCode(hook.code, options, {
692
693
  contextVars: contextVars,
693
694
  context: 'self.',
694
695
  }), "\n ");
@@ -700,25 +701,25 @@ var componentToCustomElement = function (options) {
700
701
  ? ''
701
702
  : "\n // hydrate input state\n if (preValues.length) {\n const nextStateful = this.getStateful(this._root);\n this.hydrateDom(preValues, nextStateful);\n }\n ", "\n }\n ").concat(!componentHasStatefulDom
702
703
  ? ''
703
- : "\n getStateful(el) {\n const stateful = el.querySelectorAll('[data-dom-state]');\n return stateful ? Array.from(stateful) : [];\n }\n prepareHydrate(stateful) {\n return stateful.map(el => {\n return {\n id: el.dataset.domState,\n value: el.value,\n active: document.activeElement === el,\n selectionStart: el.selectionStart\n };\n });\n }\n hydrateDom(preValues, stateful) {\n return stateful.map((el, index) => {\n const prev = preValues.find((prev) => el.dataset.domState === prev.id);\n if (prev) {\n el.value = prev.value;\n if (prev.active) {\n el.focus();\n el.selectionStart = prev.selectionStart;\n }\n }\n });\n }\n ", "\n\n updateBindings() {\n ").concat(Object.keys(useOptions.onChangeJsById)
704
+ : "\n getStateful(el) {\n const stateful = el.querySelectorAll('[data-dom-state]');\n return stateful ? Array.from(stateful) : [];\n }\n prepareHydrate(stateful) {\n return stateful.map(el => {\n return {\n id: el.dataset.domState,\n value: el.value,\n active: document.activeElement === el,\n selectionStart: el.selectionStart\n };\n });\n }\n hydrateDom(preValues, stateful) {\n return stateful.map((el, index) => {\n const prev = preValues.find((prev) => el.dataset.domState === prev.id);\n if (prev) {\n el.value = prev.value;\n if (prev.active) {\n el.focus();\n el.selectionStart = prev.selectionStart;\n }\n }\n });\n }\n ", "\n\n updateBindings() {\n ").concat(Object.keys(options.onChangeJsById)
704
705
  .map(function (key) {
705
706
  var _a, _b, _c, _d, _e, _f, _g;
706
- var value = useOptions.onChangeJsById[key];
707
+ var value = options.onChangeJsById[key];
707
708
  if (!value) {
708
709
  return '';
709
710
  }
710
711
  var code = '';
711
- if ((_a = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _a === void 0 ? void 0 : _a.updateBindings) {
712
- key = (_c = (_b = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _b === void 0 ? void 0 : _b.updateBindings) === null || _c === void 0 ? void 0 : _c.key(key, value, useOptions);
713
- code = (_e = (_d = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _d === void 0 ? void 0 : _d.updateBindings) === null || _e === void 0 ? void 0 : _e.code(key, value, useOptions);
712
+ if ((_a = options === null || options === void 0 ? void 0 : options.experimental) === null || _a === void 0 ? void 0 : _a.updateBindings) {
713
+ key = (_c = (_b = options === null || options === void 0 ? void 0 : options.experimental) === null || _b === void 0 ? void 0 : _b.updateBindings) === null || _c === void 0 ? void 0 : _c.key(key, value, options);
714
+ code = (_e = (_d = options === null || options === void 0 ? void 0 : options.experimental) === null || _d === void 0 ? void 0 : _d.updateBindings) === null || _e === void 0 ? void 0 : _e.code(key, value, options);
714
715
  }
715
716
  else {
716
- code = updateReferencesInCode(value, useOptions, {
717
+ code = updateReferencesInCode(value, options, {
717
718
  contextVars: contextVars,
718
719
  });
719
720
  }
720
- return "\n ".concat(((_f = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _f === void 0 ? void 0 : _f.generateQuerySelectorAll)
721
- ? "\n ".concat((_g = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _g === void 0 ? void 0 : _g.generateQuerySelectorAll(key, code), "\n ")
721
+ return "\n ".concat(((_f = options === null || options === void 0 ? void 0 : options.experimental) === null || _f === void 0 ? void 0 : _f.generateQuerySelectorAll)
722
+ ? "\n ".concat((_g = options === null || options === void 0 ? void 0 : options.experimental) === null || _g === void 0 ? void 0 : _g.generateQuerySelectorAll(key, code), "\n ")
722
723
  : " \n this._root.querySelectorAll(\"[data-el='".concat(key, "']\").forEach((el) => {\n ").concat(code, "\n })\n "), "\n ");
723
724
  })
724
725
  .join('\n\n'), "\n }\n\n // Helper to render content\n renderTextNode(el, text) {\n const textNode = document.createTextNode(text);\n if (el?.scope) {\n textNode.scope = el.scope;\n }\n if (el?.context) {\n textNode.context = el.context;\n }\n el.after(textNode);\n this.nodesToDestroy.push(el.nextSibling);\n }\n ").concat(!hasContext
@@ -727,8 +728,8 @@ var componentToCustomElement = function (options) {
727
728
  ? ''
728
729
  : "\n // scope helper\n getScope(el, name) {\n do {\n let value = el?.scope?.[name]\n if (value !== undefined) {\n return value\n }\n } while ((el = el.parentNode));\n }\n ", "\n\n ").concat(!hasLoop
729
730
  ? ''
730
- : "\n\n // Helper to render loops\n renderLoop(template, array, itemName, itemIndex, collectionName) {\n const collection = [];\n for (let [index, value] of array.entries()) {\n const elementFragment = template.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n const localScope = {};\n let scope = localScope;\n if (template?.scope) {\n const getParent = {\n get(target, prop, receiver) {\n if (prop in target) {\n return target[prop];\n }\n if (prop in template.scope) {\n return template.scope[prop];\n }\n return target[prop];\n }\n };\n scope = new Proxy(localScope, getParent);\n }\n children.forEach((child) => {\n if (itemName !== undefined) {\n scope[itemName] = value;\n }\n if (itemIndex !== undefined) {\n scope[itemIndex] = index;\n }\n if (collectionName !== undefined) {\n scope[collectionName] = array;\n }\n child.scope = scope;\n if (template.context) {\n child.context = context;\n }\n this.nodesToDestroy.push(child);\n collection.unshift(child)\n });\n }\n collection.forEach(child => template.after(child));\n }\n ", "\n }\n\n ").concat(((_13 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _13 === void 0 ? void 0 : _13.customElementsDefine)
731
- ? (_14 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _14 === void 0 ? void 0 : _14.customElementsDefine(kebabName, component, useOptions)
731
+ : "\n\n // Helper to render loops\n renderLoop(template, array, itemName, itemIndex, collectionName) {\n const collection = [];\n for (let [index, value] of array.entries()) {\n const elementFragment = template.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n const localScope = {};\n let scope = localScope;\n if (template?.scope) {\n const getParent = {\n get(target, prop, receiver) {\n if (prop in target) {\n return target[prop];\n }\n if (prop in template.scope) {\n return template.scope[prop];\n }\n return target[prop];\n }\n };\n scope = new Proxy(localScope, getParent);\n }\n children.forEach((child) => {\n if (itemName !== undefined) {\n scope[itemName] = value;\n }\n if (itemIndex !== undefined) {\n scope[itemIndex] = index;\n }\n if (collectionName !== undefined) {\n scope[collectionName] = array;\n }\n child.scope = scope;\n if (template.context) {\n child.context = context;\n }\n this.nodesToDestroy.push(child);\n collection.unshift(child)\n });\n }\n collection.forEach(child => template.after(child));\n }\n ", "\n }\n\n ").concat(((_13 = options === null || options === void 0 ? void 0 : options.experimental) === null || _13 === void 0 ? void 0 : _13.customElementsDefine)
732
+ ? (_14 = options === null || options === void 0 ? void 0 : options.experimental) === null || _14 === void 0 ? void 0 : _14.customElementsDefine(kebabName, component, options)
732
733
  : "customElements.define('".concat(kebabName, "', ").concat(ComponentName, ");"), "\n ");
733
734
  if (options.plugins) {
734
735
  str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.componentToLiquid = exports.isValidLiquidBinding = void 0;
4
4
  var standalone_1 = require("prettier/standalone");
5
+ var html_tags_1 = require("../constants/html_tags");
5
6
  var fast_clone_1 = require("../helpers/fast-clone");
6
7
  var get_state_object_string_1 = require("../helpers/get-state-object-string");
7
8
  var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
8
9
  var strip_state_and_props_refs_1 = require("../helpers/strip-state-and-props-refs");
9
10
  var collect_css_1 = require("../helpers/styles/collect-css");
10
11
  var plugins_1 = require("../modules/plugins");
11
- var jsx_1 = require("../parsers/jsx");
12
12
  var mitosis_node_1 = require("../types/mitosis-node");
13
13
  /**
14
14
  * Test if the binding expression would be likely to generate
@@ -94,7 +94,7 @@ var blockToLiquid = function (json, options) {
94
94
  str += " ".concat(key, "=\"{{").concat(useValue, "}}\" ");
95
95
  }
96
96
  }
97
- if (jsx_1.selfClosingTags.has(json.name)) {
97
+ if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)) {
98
98
  return str + ' />';
99
99
  }
100
100
  str += '>';