@builder.io/mitosis 0.0.56-25 → 0.0.56-28

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 (35) hide show
  1. package/dist/src/__tests__/hash-code.test.d.ts +1 -0
  2. package/dist/src/__tests__/hash-code.test.js +8 -0
  3. package/dist/src/generators/qwik/component.d.ts +1 -0
  4. package/dist/src/generators/qwik/component.js +25 -7
  5. package/dist/src/generators/qwik/directives.js +8 -0
  6. package/dist/src/generators/qwik/jsx.d.ts +12 -0
  7. package/dist/src/generators/qwik/jsx.js +12 -0
  8. package/dist/src/generators/qwik/src-generator.js +6 -5
  9. package/dist/src/generators/react.js +4 -4
  10. package/dist/src/generators/solid.js +32 -17
  11. package/dist/src/helpers/styles/collect-css.js +2 -2
  12. package/dist/src/helpers/styles/helpers.d.ts +1 -0
  13. package/dist/src/parsers/builder.js +2 -1
  14. package/dist/src/symbols/symbol-processor.d.ts +2 -0
  15. package/dist/src/symbols/symbol-processor.js +47 -13
  16. package/dist/test/qwik/Accordion/low.jsx +18 -6
  17. package/dist/test/qwik/For/low.jsx +9 -3
  18. package/dist/test/qwik/Image/med.js +2 -2
  19. package/dist/test/qwik/Image.slow/med.js +2 -2
  20. package/dist/test/qwik/bindings/low.cjs +0 -1
  21. package/dist/test/qwik/button/low.js +0 -1
  22. package/dist/test/qwik/component/bindings/low.jsx +16 -6
  23. package/dist/test/qwik/component/component/inputs/med.cjsx +2 -2
  24. package/dist/test/qwik/for-loop.bindings/low.cjs +9 -3
  25. package/dist/test/qwik/hello_world/stylesheet/low.jsx +0 -1
  26. package/dist/test/qwik/page-with-symbol/low.js +0 -1
  27. package/dist/test/qwik/show-hide/med.jsx +4 -3
  28. package/dist/test/qwik/svg/low.js +4 -2
  29. package/dist/test/qwik/todo/Todo.cjs/med.cjs +0 -1
  30. package/dist/test/qwik/todo/Todo.js/med.js +0 -1
  31. package/dist/test/qwik/todo/Todo.tsx/med.tsx +0 -1
  32. package/dist/test/qwik/todos/Todo.tsx/low.tsx +0 -1
  33. package/dist/tsconfig.build.tsbuildinfo +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var __1 = require("..");
4
+ describe('hashCode', function () {
5
+ test('should compute object', function () {
6
+ expect((0, __1.hashCodeAsString)({ foo: 'bar' })).toEqual('1jo4fm');
7
+ });
8
+ });
@@ -16,6 +16,7 @@ export declare function createFileSet(options?: QwikOptions): FileSet;
16
16
  export declare function addComponent(fileSet: FileSet, component: MitosisComponent, opts?: {
17
17
  isRoot?: boolean;
18
18
  shareStyles?: boolean;
19
+ hostProps?: Record<string, string>;
19
20
  }): void;
20
21
  export declare function renderUseLexicalScope(file: File): (this: SrcBuilder) => SrcBuilder;
21
22
  export declare function addCommonStyles(fileSet: FileSet): void;
@@ -21,6 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.addCommonStyles = exports.renderUseLexicalScope = exports.addComponent = exports.createFileSet = void 0;
24
+ var create_mitosis_node_1 = require("../../helpers/create-mitosis-node");
24
25
  var compile_away_builder_components_1 = require("../../plugins/compile-away-builder-components");
25
26
  var handlers_1 = require("./handlers");
26
27
  var jsx_1 = require("./jsx");
@@ -54,8 +55,9 @@ function getCommonStyles(fileSet) {
54
55
  }
55
56
  function addComponent(fileSet, component, opts) {
56
57
  if (opts === void 0) { opts = {}; }
57
- var _opts = __assign({ isRoot: false, shareStyles: false }, opts);
58
+ var _opts = __assign({ isRoot: false, shareStyles: false, hostProps: null }, opts);
58
59
  (0, compile_away_builder_components_1.compileAwayBuilderComponentsFromTree)(component, __assign(__assign({}, compile_away_builder_components_1.components), { Image: undefined, CoreButton: undefined }));
60
+ addBuilderBlockClass(component.children);
59
61
  var componentName = component.name;
60
62
  var handlers = (0, handlers_1.renderHandlers)(fileSet.high, componentName, component.children);
61
63
  // If the component has no handlers, than it is probably static
@@ -82,8 +84,18 @@ function addComponent(fileSet, component, opts) {
82
84
  }
83
85
  }
84
86
  var directives = new Map();
87
+ var rootChildren = component.children;
88
+ if (_opts.hostProps) {
89
+ rootChildren = [
90
+ (0, create_mitosis_node_1.createMitosisNode)({
91
+ name: 'Host',
92
+ properties: _opts.hostProps,
93
+ children: component.children,
94
+ }),
95
+ ];
96
+ }
85
97
  addComponentOnMount(onRenderFile, function () {
86
- return this.emit('return ', (0, jsx_1.renderJSXNodes)(onRenderFile, directives, handlers, component.children, styles, {}), ';');
98
+ return this.emit('return ', (0, jsx_1.renderJSXNodes)(onRenderFile, directives, handlers, rootChildren, styles, {}), ';');
87
99
  }, componentName, component, useStyles);
88
100
  componentFile.exportConst(componentName, (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'componentQrl'), [generateQrl(componentFile, onRenderFile, componentName + '_onMount')], ['any', 'any']));
89
101
  directives.forEach(function (code, name) {
@@ -97,6 +109,14 @@ function generateStyles(fromFile, dstFile, symbol, scoped) {
97
109
  this.emit((0, src_generator_1.invoke)(fromFile.import(fromFile.qwikModule, scoped ? 'withScopedStylesQrl' : 'useStylesQrl'), [generateQrl(fromFile, dstFile, symbol)]), ';');
98
110
  };
99
111
  }
112
+ function addBuilderBlockClass(children) {
113
+ children.forEach(function (child) {
114
+ var props = child.properties;
115
+ if (props['builder-id']) {
116
+ props.class = (props.class ? props.class + ' ' : '') + 'builder-block';
117
+ }
118
+ });
119
+ }
100
120
  function renderUseLexicalScope(file) {
101
121
  return function () {
102
122
  return this.emit('const state=', file.import(file.qwikModule, 'useLexicalScope').localName, '()[0]');
@@ -122,12 +142,10 @@ function addComponentOnMount(componentFile, onRenderEmit, componentName, compone
122
142
  componentFile.exportConst(componentName + '_onMount', function () {
123
143
  var _this = this;
124
144
  this.emit((0, src_generator_1.arrowFnValue)(['state'], function () {
125
- var _a;
126
- return _this.emit.apply(_this, __spreadArray(__spreadArray(['{',
145
+ var _a, _b;
146
+ return _this.emit.apply(_this, __spreadArray(__spreadArray(__spreadArray(__spreadArray(['{',
127
147
  'if(!state.__INIT__){',
128
- 'state.__INIT__=true;'], inputInitializer, false), ['typeof __STATE__==="object"&&Object.assign(state,__STATE__[state.serverStateId]);',
129
- (0, src_generator_1.iif)((_a = component.hooks.onMount) === null || _a === void 0 ? void 0 : _a.code),
130
- '}',
148
+ 'state.__INIT__=true;'], inputInitializer, false), ['typeof __STATE__==="object"&&Object.assign(state,__STATE__[state.serverStateId]);'], false), (((_a = component.hooks.onMount) === null || _a === void 0 ? void 0 : _a.code) ? [(0, src_generator_1.iif)((_b = component.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code)] : []), false), ['}',
131
149
  useStyles,
132
150
  onRenderEmit,
133
151
  ';}'], false));
@@ -38,6 +38,14 @@ exports.DIRECTIVES = {
38
38
  });
39
39
  };
40
40
  },
41
+ Host: function (node, blockFn) {
42
+ return function () {
43
+ var host = this.file.import(this.file.qwikModule, 'Host').localName;
44
+ this.jsxBegin(host, node.properties, {});
45
+ blockFn();
46
+ this.jsxEnd(host);
47
+ };
48
+ },
41
49
  Image: (0, minify_1.minify)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), Image),
42
50
  CoreButton: (0, minify_1.minify)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), CoreButton),
43
51
  __passThroughProps__: (0, minify_1.minify)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["", ""], ["", ""])), __passThroughProps__),
@@ -1,4 +1,16 @@
1
1
  import { MitosisNode } from '../../types/mitosis-node';
2
2
  import { File } from './src-generator';
3
3
  import { CssStyles } from './styles';
4
+ /**
5
+ * Convert a Mitosis nodes to a JSX nodes.
6
+ *
7
+ * @param file File into which the output will be written to.
8
+ * @param directives Store for directives which we came across so that they can be imported.
9
+ * @param handlers A set of handlers which we came across so that they can be rendered
10
+ * @param children A list of children to convert to JSX
11
+ * @param styles Store for styles which we came across so that they can be rendered.
12
+ * @param parentSymbolBindings A set of bindings from parent to be written into the child.
13
+ * @param root True if this is the root JSX, and may need a Fragment wrapper.
14
+ * @returns
15
+ */
4
16
  export declare function renderJSXNodes(file: File, directives: Map<string, string>, handlers: Map<string, string>, children: MitosisNode[], styles: Map<string, CssStyles>, parentSymbolBindings: Record<string, string>, root?: boolean): any;
@@ -24,6 +24,18 @@ exports.renderJSXNodes = void 0;
24
24
  var is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
25
25
  var directives_1 = require("./directives");
26
26
  var src_generator_1 = require("./src-generator");
27
+ /**
28
+ * Convert a Mitosis nodes to a JSX nodes.
29
+ *
30
+ * @param file File into which the output will be written to.
31
+ * @param directives Store for directives which we came across so that they can be imported.
32
+ * @param handlers A set of handlers which we came across so that they can be rendered
33
+ * @param children A list of children to convert to JSX
34
+ * @param styles Store for styles which we came across so that they can be rendered.
35
+ * @param parentSymbolBindings A set of bindings from parent to be written into the child.
36
+ * @param root True if this is the root JSX, and may need a Fragment wrapper.
37
+ * @returns
38
+ */
27
39
  function renderJSXNodes(file, directives, handlers, children, styles, parentSymbolBindings, root) {
28
40
  if (root === void 0) { root = true; }
29
41
  return function () {
@@ -85,10 +85,11 @@ var File = /** @class */ (function () {
85
85
  });
86
86
  }
87
87
  catch (e) {
88
- debugger;
89
- source += "\n===============================\n";
90
- source += String(e);
91
- console.error(source);
88
+ throw new Error(e +
89
+ '\n' +
90
+ '========================================================================\n' +
91
+ source +
92
+ '\n\n========================================================================');
92
93
  }
93
94
  }
94
95
  return source;
@@ -207,6 +208,7 @@ var SrcBuilder = /** @class */ (function () {
207
208
  value.startsWith(':') ||
208
209
  value.startsWith(']') ||
209
210
  value.startsWith('}') ||
211
+ value.startsWith(',') ||
210
212
  value.startsWith('?')) {
211
213
  // clear last ',' or ';';
212
214
  var index = this.buf.length - 1;
@@ -449,7 +451,6 @@ function ignoreKey(key) {
449
451
  key.startsWith('_') ||
450
452
  key == 'code' ||
451
453
  key == '' ||
452
- key == 'builder-id' ||
453
454
  key.indexOf('.') !== -1);
454
455
  }
455
456
  var Block = /** @class */ (function () {
@@ -55,12 +55,12 @@ var collect_styled_components_1 = require("../helpers/styles/collect-styled-comp
55
55
  var helpers_1 = require("../helpers/styles/helpers");
56
56
  var slots_1 = require("../helpers/slots");
57
57
  /**
58
- * If the root Mitosis component only has 1 child, and it is a `Show` node, then we need to wrap it in a fragment.
58
+ * If the root Mitosis component only has 1 child, and it is a `Show`/`For` node, then we need to wrap it in a fragment.
59
59
  * Otherwise, we end up with invalid React render code.
60
60
  *
61
61
  */
62
- var isRootShowNode = function (json) {
63
- return json.children.length === 1 && ['Show'].includes(json.children[0].name);
62
+ var isRootSpecialNode = function (json) {
63
+ return json.children.length === 1 && ['Show', 'For'].includes(json.children[0].name);
64
64
  };
65
65
  var wrapInFragment = function (json) { return json.children.length !== 1; };
66
66
  var NODE_MAPPERS = {
@@ -475,7 +475,7 @@ var _componentToReact = function (json, options, isSubComponent) {
475
475
  }
476
476
  var wrap = wrapInFragment(json) ||
477
477
  (componentHasStyles && stylesType === 'styled-jsx') ||
478
- isRootShowNode(json);
478
+ isRootSpecialNode(json);
479
479
  var _o = getRefsString(json, allRefs, options), hasStateArgument = _o[0], refsString = _o[1];
480
480
  var nativeStyles = stylesType === 'react-native' && componentHasStyles && (0, react_native_1.collectReactNativeStyles)(json);
481
481
  var propsArgs = 'props';
@@ -14,6 +14,15 @@ var __assign = (this && this.__assign) || function () {
14
14
  };
15
15
  return __assign.apply(this, arguments);
16
16
  };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
17
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
28
  };
@@ -195,14 +204,10 @@ var blockToSolid = function (json, options) {
195
204
  }
196
205
  return str;
197
206
  };
198
- var getRefsString = function (json, refs) {
199
- if (refs === void 0) { refs = (0, get_refs_1.getRefs)(json); }
200
- var str = '';
201
- for (var _i = 0, _a = Array.from(refs); _i < _a.length; _i++) {
202
- var ref = _a[_i];
203
- str += "\nconst ".concat(ref, " = useRef();");
204
- }
205
- return str;
207
+ var getRefsString = function (json) {
208
+ return Array.from((0, get_refs_1.getRefs)(json))
209
+ .map(function (ref) { return "let ".concat(ref, ";"); })
210
+ .join('\n');
206
211
  };
207
212
  function addProviderComponents(json, options) {
208
213
  for (var key in json.context.set) {
@@ -219,7 +224,7 @@ function addProviderComponents(json, options) {
219
224
  var componentToSolid = function (options) {
220
225
  if (options === void 0) { options = {}; }
221
226
  return function (_a) {
222
- var _b, _c;
227
+ var _b, _c, _d;
223
228
  var component = _a.component;
224
229
  var json = (0, fast_clone_1.fastClone)(component);
225
230
  if (options.plugins) {
@@ -237,20 +242,30 @@ var componentToSolid = function (options) {
237
242
  var hasState = Object.keys(component.state).length > 0;
238
243
  var componentsUsed = (0, get_components_used_1.getComponentsUsed)(json);
239
244
  var componentHasContext = (0, context_1.hasContext)(json);
240
- var refs = getRefsString(json);
241
245
  var hasShowComponent = componentsUsed.has('Show');
242
246
  var hasForComponent = componentsUsed.has('For');
243
- var hasRefs = refs.length > 0;
244
- var solidJSImports = [
247
+ var solidJSImports = __spreadArray([
245
248
  componentHasContext ? 'useContext' : undefined,
246
249
  hasShowComponent ? 'Show' : undefined,
247
250
  hasForComponent ? 'For' : undefined,
248
- ((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? 'onMount' : undefined,
249
- hasRefs ? 'useRef' : undefined,
250
- ].filter(Boolean);
251
- var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(props) {\n ", "\n \n ", "\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n export default ", ";\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(props) {\n ", "\n \n ", "\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n export default ", ";\n "])), solidJSImports.length > 0
251
+ ((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? 'onMount' : undefined
252
+ ], (((_c = json.hooks.onUpdate) === null || _c === void 0 ? void 0 : _c.length) ? ['on', 'createEffect'] : []), true).filter(Boolean);
253
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(props) {\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n export default ", ";\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(props) {\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n export default ", ";\n "])), solidJSImports.length > 0
252
254
  ? "import { \n ".concat(solidJSImports.map(function (item) { return item; }).join(', '), "\n } from 'solid-js';")
253
- : '', !foundDynamicComponents ? '' : "import { Dynamic } from 'solid-js/web';", !hasState ? '' : "import { createMutable } from 'solid-js/store';", !componentHasStyles ? '' : "import { css } from \"solid-styled-components\";", (0, render_imports_1.renderPreComponent)({ component: json, target: 'solid' }), json.name, !hasState ? '' : "const state = createMutable(".concat(stateString, ");"), refs, getContextString(json, options), !((_c = json.hooks.onMount) === null || _c === void 0 ? void 0 : _c.code) ? '' : "onMount(() => { ".concat(json.hooks.onMount.code, " })"), addWrapper ? '<>' : '', json.children
255
+ : '', !foundDynamicComponents ? '' : "import { Dynamic } from 'solid-js/web';", !hasState ? '' : "import { createMutable } from 'solid-js/store';", !componentHasStyles ? '' : "import { css } from \"solid-styled-components\";", (0, render_imports_1.renderPreComponent)({ component: json, target: 'solid' }), json.name, !hasState ? '' : "const state = createMutable(".concat(stateString, ");"), getRefsString(json), getContextString(json, options), !((_d = json.hooks.onMount) === null || _d === void 0 ? void 0 : _d.code) ? '' : "onMount(() => { ".concat(json.hooks.onMount.code, " })"), json.hooks.onUpdate
256
+ ? json.hooks.onUpdate
257
+ .map(function (hook, index) {
258
+ if (hook.deps) {
259
+ var hookName = "onUpdateFn_".concat(index);
260
+ return "\n function ".concat(hookName, "() { ").concat(hook.code, " };\n createEffect(on(() => ").concat(hook.deps, ", ").concat(hookName, "));\n ");
261
+ }
262
+ else {
263
+ // TO-DO: support `onUpdate` without `deps`
264
+ return '';
265
+ }
266
+ })
267
+ .join('\n')
268
+ : '', addWrapper ? '<>' : '', json.children
254
269
  .filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
255
270
  .map(function (item) { return blockToSolid(item, options); })
256
271
  .join('\n'), addWrapper ? '</>' : '', json.name);
@@ -13,8 +13,8 @@ var trimClassStr = function (classStr) { return classStr.trim().replace(/\s{2,}/
13
13
  var updateClassForNode = function (item, className) {
14
14
  if (item.bindings.class) {
15
15
  // combine className with existing binding. We use single quotes because in Vue, bindings are wrapped in double quotes
16
- // e.g. <div :class="_classStringToObject(this.className + 'div-21azgz5avex')" />
17
- item.bindings.class.code = trimClassStr("".concat(item.bindings.class.code, " + '").concat(className, "'"));
16
+ // e.g. <div :class="_classStringToObject(this.className + ' div-21azgz5avex')" />
17
+ item.bindings.class.code = trimClassStr("".concat(item.bindings.class.code, " + ' ").concat(className, "'"));
18
18
  }
19
19
  else {
20
20
  item.properties.class = trimClassStr("".concat(item.properties.class || '', " ").concat(className));
@@ -1,3 +1,4 @@
1
+ /// <reference types="lodash" />
1
2
  import * as CSS from 'csstype';
2
3
  import { MitosisNode } from '../../types/mitosis-node';
3
4
  import { MitosisComponent } from '../../types/mitosis-component';
@@ -50,6 +50,7 @@ var create_mitosis_component_1 = require("../helpers/create-mitosis-component");
50
50
  var create_mitosis_node_1 = require("../helpers/create-mitosis-node");
51
51
  var jsx_1 = require("./jsx");
52
52
  var parsers_1 = require("../helpers/parsers");
53
+ var __1 = require("..");
53
54
  // Omit some superflous styles that can come from Builder's web importer
54
55
  var styleOmitList = [
55
56
  'backgroundRepeatX',
@@ -638,7 +639,7 @@ function extractSymbols(json) {
638
639
  subComponents: subComponents,
639
640
  };
640
641
  }
641
- var createBuilderElement = function (options) { return (__assign({ '@type': '@builder.io/sdk:Element', id: 'builder-' + Math.random().toString(36).split('.')[1] }, options)); };
642
+ var createBuilderElement = function (options) { return (__assign({ '@type': '@builder.io/sdk:Element', id: 'builder-' + (0, __1.hashCodeAsString)(options) }, options)); };
642
643
  exports.createBuilderElement = createBuilderElement;
643
644
  var isBuilderElement = function (el) {
644
645
  return (el === null || el === void 0 ? void 0 : el['@type']) === '@builder.io/sdk:Element';
@@ -16,3 +16,5 @@ export declare function convertBuilderContentToSymbolHierarchy(content: BuilderC
16
16
  }): SymbolHierarchy;
17
17
  export declare function convertBuilderElementToMitosisComponent(element: BuilderElement): MitosisComponent | null;
18
18
  export declare function getJsxSymbolComponentName(id: string): string;
19
+ export declare function hashCodeAsString(obj: any): string;
20
+ export declare function hashCode(obj: any, hash?: number): number;
@@ -15,7 +15,7 @@ var __assign = (this && this.__assign) || function () {
15
15
  return __assign.apply(this, arguments);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getJsxSymbolComponentName = exports.convertBuilderElementToMitosisComponent = exports.convertBuilderContentToSymbolHierarchy = exports.ensureAllSymbolsHaveIds = void 0;
18
+ exports.hashCode = exports.hashCodeAsString = exports.getJsxSymbolComponentName = exports.convertBuilderElementToMitosisComponent = exports.convertBuilderContentToSymbolHierarchy = exports.ensureAllSymbolsHaveIds = void 0;
19
19
  var traverse_1 = require("traverse");
20
20
  var builder_1 = require("../parsers/builder");
21
21
  var minify_1 = require("../generators/minify");
@@ -90,7 +90,7 @@ function convertBuilderContentToSymbolHierarchy(content, _a) {
90
90
  var props = symbol.data;
91
91
  var state = (_c = (_b = symbol.content) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state;
92
92
  if (state) {
93
- var id = toHash(state);
93
+ var id = hashCodeAsString(state);
94
94
  props['serverStateId'] = id;
95
95
  collectComponentState[id] = state;
96
96
  }
@@ -157,19 +157,53 @@ function addIfMissing(array, value) {
157
157
  function isString(value) {
158
158
  return typeof value == 'string';
159
159
  }
160
- function toHash(obj) {
161
- return hashCode(JSON.stringify(obj));
160
+ function hashCodeAsString(obj) {
161
+ return Number(Math.abs(hashCode(obj))).toString(36);
162
162
  }
163
- function hashCode(text) {
164
- var hash = 0, i, chr;
165
- if (text.length === 0)
166
- return String(hash);
167
- for (i = 0; i < text.length; i++) {
168
- chr = text.charCodeAt(i);
169
- hash = (hash << 5) - hash + chr;
170
- hash |= 0; // Convert to 32bit integer
163
+ exports.hashCodeAsString = hashCodeAsString;
164
+ function hashCode(obj, hash) {
165
+ if (hash === void 0) { hash = 0; }
166
+ var value = 0;
167
+ switch (typeof obj) {
168
+ case 'number':
169
+ value = obj;
170
+ break;
171
+ case 'undefined':
172
+ value = Number.MIN_SAFE_INTEGER;
173
+ break;
174
+ case 'string':
175
+ for (var i = 0; i < obj.length; i++) {
176
+ hash = hashCodeApply(hash, obj.charCodeAt(i));
177
+ }
178
+ value = obj.length;
179
+ case 'boolean':
180
+ value = obj ? 1 : 0;
181
+ break;
182
+ case 'object':
183
+ if (obj === null) {
184
+ value = Number.MAX_SAFE_INTEGER;
185
+ }
186
+ else if (Array.isArray(obj)) {
187
+ for (var i = 0; i < obj.length; i++) {
188
+ hash = hashCode(obj[i], hash);
189
+ }
190
+ }
191
+ else {
192
+ for (var key in obj) {
193
+ if (obj.hasOwnProperty(key)) {
194
+ hash = hashCode(obj[key], hash);
195
+ }
196
+ }
197
+ }
198
+ break;
171
199
  }
172
- return Number(Math.abs(hash)).toString(36);
200
+ return hashCodeApply(hash, value);
201
+ }
202
+ exports.hashCode = hashCode;
203
+ function hashCodeApply(hash, value) {
204
+ hash = (hash << 5) - hash + value;
205
+ hash |= 0; // Convert to 32bit integer
206
+ return hash;
173
207
  }
174
208
  function pad(value) {
175
209
  var padding = '000000';
@@ -5,13 +5,13 @@ export const MyComponent_onMount = (state) => {
5
5
  state.__INIT__ = true;
6
6
  typeof __STATE__ === "object" &&
7
7
  Object.assign(state, __STATE__[state.serverStateId]);
8
- undefined;
9
8
  }
10
9
  withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
11
10
  return (
12
11
  <div
12
+ builder-id="builder-bb2f62792e464d73b7cb89258027f356"
13
13
  gridRowWidth="25%"
14
- class="csw5022"
14
+ class="csw5022 builder-block"
15
15
  items={[
16
16
  {
17
17
  title: [
@@ -171,14 +171,20 @@ export const MyComponent_onMount = (state) => {
171
171
  <div>
172
172
  <div builder="accordion">
173
173
  <div builder="accordion-title">
174
- <div class="csanagh">
174
+ <div
175
+ builder-id="builder-5fed2723c1cc4fb39e9d22b9c54ef179"
176
+ class="csanagh"
177
+ >
175
178
  <div class="crwdrpw">
176
179
  <div innerHTML="<p>Item 1</p>" class="builder-text"></div>
177
180
  </div>
178
181
  </div>
179
182
  </div>
180
183
  <div builder="accordion-detail">
181
- <div class="c4qyc1p">
184
+ <div
185
+ builder-id="builder-18279a99b32240f19aa21d3f4b015cc9"
186
+ class="c4qyc1p"
187
+ >
182
188
  <div class="ctcw2m4">
183
189
  <div
184
190
  innerHTML="<p>Item 1 content</p>"
@@ -190,14 +196,20 @@ export const MyComponent_onMount = (state) => {
190
196
  </div>
191
197
  <div builder="accordion">
192
198
  <div builder="accordion-title">
193
- <div class="csanagh">
199
+ <div
200
+ builder-id="builder-2a93def22a354cf7aa193c20d1ad6def"
201
+ class="csanagh"
202
+ >
194
203
  <div class="crwdrpw">
195
204
  <div innerHTML="<p>Item 2</p>" class="builder-text"></div>
196
205
  </div>
197
206
  </div>
198
207
  </div>
199
208
  <div builder="accordion-detail">
200
- <div class="c4qyc1p">
209
+ <div
210
+ builder-id="builder-fd6ef41da6d040328fbd8b0801611fe5"
211
+ class="c4qyc1p"
212
+ >
201
213
  <div class="ctcw2m4">
202
214
  <div
203
215
  innerHTML="<p>Item 2 content</p>"
@@ -5,12 +5,18 @@ export const MyComponent_onMount = (state) => {
5
5
  state.__INIT__ = true;
6
6
  typeof __STATE__ === "object" &&
7
7
  Object.assign(state, __STATE__[state.serverStateId]);
8
- undefined;
9
8
  }
10
9
  withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
11
10
  return (
12
- <div class="cvdfnp5" maxWidth={1200}>
13
- <section class="cz5wnof">
11
+ <div
12
+ builder-id="builder-a58a66676d9b4ecc826c1b8bc5ad91f1"
13
+ class="cvdfnp5 builder-block"
14
+ maxWidth={1200}
15
+ >
16
+ <section
17
+ builder-id="builder-a58a66676d9b4ecc826c1b8bc5ad91f1"
18
+ class="cz5wnof"
19
+ >
14
20
  {(state.simpleList.results || []).map((item) => {
15
21
  var state = Object.assign({}, this, {
16
22
  resultsItem: item == null ? {} : item,
@@ -12,13 +12,13 @@ export const MyComponent_onMount = (state) => {
12
12
  if (!state.hasOwnProperty("myState")) state.myState = "initialValue";
13
13
  typeof __STATE__ === "object" &&
14
14
  Object.assign(state, __STATE__[state.serverStateId]);
15
- undefined;
16
15
  }
17
16
  withScopedStylesQrl(qrl("./med.js", "MyComponent_styles", []));
18
17
  return h(
19
18
  Fragment,
20
19
  null,
21
20
  h(Image, {
21
+ "builder-id": "builder-fa4480d2f48a44a7a2e98cf07c54927b",
22
22
  image:
23
23
  "https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1160",
24
24
  backgroundSize: "cover",
@@ -26,7 +26,7 @@ export const MyComponent_onMount = (state) => {
26
26
  srcset:
27
27
  "https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=100 100w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=200 200w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=400 400w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=800 800w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1200 1200w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1600 1600w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=2000 2000w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1160 1160w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=598 598w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=958 958w",
28
28
  sizes: "(max-width: 638px) 94vw, (max-width: 998px) 96vw, 83vw",
29
- class: "cvk52jt",
29
+ class: "cvk52jt builder-block",
30
30
  onClickQrl: qrl("./high.js", "MyComponent_onClick_0", [state]),
31
31
  lazy: false,
32
32
  fitContent: true,
@@ -12,13 +12,13 @@ export const MyComponent_onMount = (state) => {
12
12
  if (!state.hasOwnProperty("myState")) state.myState = "initialValue";
13
13
  typeof __STATE__ === "object" &&
14
14
  Object.assign(state, __STATE__[state.serverStateId]);
15
- undefined;
16
15
  }
17
16
  withScopedStylesQrl(qrl("./med.js", "MyComponent_styles", []));
18
17
  return h(
19
18
  Fragment,
20
19
  null,
21
20
  h(Image, {
21
+ "builder-id": "builder-fa4480d2f48a44a7a2e98cf07c54927b",
22
22
  image:
23
23
  "https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1160",
24
24
  backgroundSize: "cover",
@@ -26,7 +26,7 @@ export const MyComponent_onMount = (state) => {
26
26
  srcset:
27
27
  "https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=100 100w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=200 200w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=400 400w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=800 800w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1200 1200w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1600 1600w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=2000 2000w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=1160 1160w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=598 598w, https://cdn.builder.io/api/v1/image/assets%2F23dfd7cef1104af59f281d58ec525923%2F4ecf7b7554464b0183ab8250f67e797b?width=958 958w",
28
28
  sizes: "(max-width: 638px) 94vw, (max-width: 998px) 96vw, 83vw",
29
- class: "cvk52jt",
29
+ class: "cvk52jt builder-block",
30
30
  onClickQrl: qrl("./high.js", "MyComponent_onClick_0", [state]),
31
31
  lazy: false,
32
32
  fitContent: true,
@@ -10,7 +10,6 @@ exports.MyComponent_onMount = (state) => {
10
10
  if (!state.hasOwnProperty("hiliteTitle")) state.hiliteTitle = true;
11
11
  typeof __STATE__ === "object" &&
12
12
  Object.assign(state, __STATE__[state.serverStateId]);
13
- undefined;
14
13
  }
15
14
  withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
16
15
  return h(
@@ -6,7 +6,6 @@ export const MyComponent_onMount = (state) => {
6
6
  state.__INIT__ = true;
7
7
  typeof __STATE__ === "object" &&
8
8
  Object.assign(state, __STATE__[state.serverStateId]);
9
- undefined;
10
9
  }
11
10
  withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
12
11
  return h(CoreButton, {
@@ -7,13 +7,15 @@ export const ComponentD187055AF171488FAD843ACF045D6BF7_onMount = (state) => {
7
7
  if (!state.hasOwnProperty("title")) state.title = "default-title";
8
8
  typeof __STATE__ === "object" &&
9
9
  Object.assign(state, __STATE__[state.serverStateId]);
10
- undefined;
11
10
  }
12
11
  withScopedStylesQrl(
13
12
  qrl("./low.js", "ComponentD187055AF171488FAD843ACF045D6BF7_styles", [])
14
13
  );
15
14
  return (
16
- <div class="cj49hqu">
15
+ <div
16
+ builder-id="builder-139a8479536b4c4f9c2738e724ed0952"
17
+ class="cj49hqu builder-block"
18
+ >
17
19
  <div class="cjrqfb1">
18
20
  <div
19
21
  class="builder-text"
@@ -69,16 +71,24 @@ export const MyComponent_onMount = (state) => {
69
71
  withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
70
72
  return (
71
73
  <>
72
- <div class="c713ty2">
74
+ <div
75
+ builder-id="builder-50b2438beaa4498b985eb9d8a7659afa"
76
+ class="c713ty2 builder-block"
77
+ >
73
78
  <ComponentD187055AF171488FAD843ACF045D6BF7
79
+ builder-id="builder-h3uut6"
74
80
  title="First title from parent"
75
- serverStateId="woo8b6"
81
+ serverStateId="w8x6w6"
76
82
  ></ComponentD187055AF171488FAD843ACF045D6BF7>
77
83
  </div>
78
- <div class="c713ty2">
84
+ <div
85
+ builder-id="builder-33f427415bef4725b0c9fcd4fed325f2"
86
+ class="c713ty2 builder-block"
87
+ >
79
88
  <ComponentD187055AF171488FAD843ACF045D6BF7
89
+ builder-id="builder-bfxc0y"
80
90
  title="Second title from parent"
81
- serverStateId="woo8b6"
91
+ serverStateId="w8x6w6"
82
92
  ></ComponentD187055AF171488FAD843ACF045D6BF7>
83
93
  </div>
84
94
  </>
@@ -10,7 +10,6 @@ exports.MyComponent_onMount = (state) => {
10
10
  if (!state.hasOwnProperty("data")) state.data = 0;
11
11
  typeof __STATE__ === "object" &&
12
12
  Object.assign(state, __STATE__[state.serverStateId]);
13
- undefined;
14
13
  }
15
14
  withScopedStylesQrl(qrl("./med.js", "MyComponent_styles", []));
16
15
  return (
@@ -29,8 +28,9 @@ exports.MyComponent_onMount = (state) => {
29
28
  ></div>
30
29
  </div>
31
30
  <CoreButton
31
+ builder-id="builder-6f8fe6a1d2284f2890ae97657eed084a"
32
32
  text="Something else"
33
- class="c9nzze9"
33
+ class="c9nzze9 builder-block"
34
34
  onClickQrl={qrl("./high.js", "MyComponent_onClick_0", [state])}
35
35
  ></CoreButton>
36
36
  </>