@builder.io/sdk-qwik 0.0.19 → 0.0.21

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.
@@ -272,7 +272,7 @@ const css = function css2(props, state) {
272
272
  };
273
273
  const BlockStyles = (props) => {
274
274
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
275
- children: TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ jsxRuntime.jsx(RenderInlinedStyles$1, {
275
+ children: TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" || TARGET === "qwik" ? /* @__PURE__ */ jsxRuntime.jsx(RenderInlinedStyles$1, {
276
276
  styles: css(props)
277
277
  }) : null
278
278
  });
@@ -281,7 +281,21 @@ const BlockStyles$1 = BlockStyles;
281
281
  function capitalizeFirstLetter(string) {
282
282
  return string.charAt(0).toUpperCase() + string.slice(1);
283
283
  }
284
- const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
284
+ const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}$`;
285
+ function crateEventHandler(value, options) {
286
+ return qwik.inlinedQrl((event) => {
287
+ const [options2, value2] = qwik.useLexicalScope();
288
+ return evaluate({
289
+ code: value2,
290
+ context: options2.context,
291
+ state: options2.state,
292
+ event
293
+ });
294
+ }, "crateEventHandler_wgxT8Hlq4s8", [
295
+ options,
296
+ value
297
+ ]);
298
+ }
285
299
  function getBlockActions(options) {
286
300
  const obj = {};
287
301
  const optionActions = options.block.actions ?? {};
@@ -289,12 +303,7 @@ function getBlockActions(options) {
289
303
  if (!optionActions.hasOwnProperty(key))
290
304
  continue;
291
305
  const value = optionActions[key];
292
- obj[getEventHandlerName(key)] = (event) => evaluate({
293
- code: value,
294
- context: options.context,
295
- state: options.state,
296
- event
297
- });
306
+ obj[getEventHandlerName(key)] = crateEventHandler(value, options);
298
307
  }
299
308
  return obj;
300
309
  }
@@ -317,22 +326,8 @@ function getBlockProperties(block) {
317
326
  ].filter(Boolean).join(" ")
318
327
  };
319
328
  }
320
- const convertStyleObject = (obj) => {
321
- return obj;
322
- };
323
- const sanitizeBlockStyles = (_styles) => {
324
- };
325
329
  function getBlockStyles(block) {
326
- const styles = {
327
- ...convertStyleObject(block.responsiveStyles?.large),
328
- ...block.styles
329
- };
330
- if (block.responsiveStyles?.medium)
331
- styles[getMaxWidthQueryForSize("medium")] = convertStyleObject(block.responsiveStyles?.medium);
332
- if (block.responsiveStyles?.small)
333
- styles[getMaxWidthQueryForSize("small")] = convertStyleObject(block.responsiveStyles?.small);
334
- sanitizeBlockStyles();
335
- return styles;
330
+ return null;
336
331
  }
337
332
  function getBlockTag(block) {
338
333
  return block.tagName || "div";
@@ -430,7 +425,7 @@ const component = function component2(props, state) {
430
425
  } else
431
426
  return ref;
432
427
  };
433
- const componentInfo$a = function componentInfo(props, state) {
428
+ const componentInfo$b = function componentInfo(props, state) {
434
429
  if (component(props)) {
435
430
  const { component: _, ...info } = component(props);
436
431
  return info;
@@ -463,7 +458,7 @@ const attributes = function attributes2(props, state) {
463
458
  };
464
459
  };
465
460
  const shouldWrap = function shouldWrap2(props, state) {
466
- return !componentInfo$a(props)?.noWrap;
461
+ return !componentInfo$b(props)?.noWrap;
467
462
  };
468
463
  const componentOptions = function componentOptions2(props, state) {
469
464
  return {
@@ -522,8 +517,7 @@ const RenderBlock = (props) => {
522
517
  };
523
518
  state.tagName = tagName2(props);
524
519
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
525
- children: shouldWrap(props) ? !isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxRuntime.jsxs(state.tagName, {
526
- ...attributes(props),
520
+ children: shouldWrap(props) ? !isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
527
521
  children: [
528
522
  repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
529
523
  return /* @__PURE__ */ jsxRuntime.jsx(RenderRepeatedBlock$1, {
@@ -531,21 +525,26 @@ const RenderBlock = (props) => {
531
525
  block: data.block
532
526
  }, index);
533
527
  }) : null,
534
- !repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
535
- ...renderComponentProps(props)
536
- }) : null,
537
- (childrenWithoutParentComponent(props) || []).map(function(child) {
538
- return /* @__PURE__ */ jsxRuntime.jsx(RenderBlock, {
539
- block: child,
540
- context: props.context
541
- }, "render-block-" + child.id);
542
- }),
543
- (childrenWithoutParentComponent(props) || []).map(function(child) {
544
- return /* @__PURE__ */ jsxRuntime.jsx(BlockStyles$1, {
545
- block: child,
546
- context: props.context
547
- }, "block-style-" + child.id);
548
- })
528
+ !repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsxs(state.tagName, {
529
+ ...attributes(props),
530
+ children: [
531
+ /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
532
+ ...renderComponentProps(props)
533
+ }),
534
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
535
+ return /* @__PURE__ */ jsxRuntime.jsx(RenderBlock, {
536
+ block: child,
537
+ context: props.context
538
+ }, "render-block-" + child.id);
539
+ }),
540
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
541
+ return /* @__PURE__ */ jsxRuntime.jsx(BlockStyles$1, {
542
+ block: child,
543
+ context: props.context
544
+ }, "block-style-" + child.id);
545
+ })
546
+ ]
547
+ }) : null
549
548
  ]
550
549
  }) : /* @__PURE__ */ jsxRuntime.jsx(state.tagName, {
551
550
  ...attributes(props)
@@ -882,7 +881,7 @@ const Video = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
882
881
  const Video$1 = Video;
883
882
  const Button = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
884
883
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
885
- return /* @__PURE__ */ jsxRuntime.jsx(qwik.Fragment, {
884
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
886
885
  children: props.link ? /* @__PURE__ */ jsxRuntime.jsx("a", {
887
886
  role: "button",
888
887
  ...props.attributes,
@@ -899,7 +898,7 @@ const Button = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
899
898
  const Button$1 = Button;
900
899
  const STYLES = `.button-Button {
901
900
  all: unset; }`;
902
- const componentInfo$9 = {
901
+ const componentInfo$a = {
903
902
  name: "Core:Button",
904
903
  builtIn: true,
905
904
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
@@ -941,7 +940,7 @@ function markSerializable(fn) {
941
940
  fn.__qwik_serializable__ = true;
942
941
  return fn;
943
942
  }
944
- const componentInfo$8 = {
943
+ const componentInfo$9 = {
945
944
  name: "Columns",
946
945
  builtIn: true,
947
946
  inputs: [
@@ -1182,7 +1181,7 @@ const componentInfo$8 = {
1182
1181
  }
1183
1182
  ]
1184
1183
  };
1185
- const componentInfo$7 = {
1184
+ const componentInfo$8 = {
1186
1185
  name: "Fragment",
1187
1186
  static: true,
1188
1187
  hidden: true,
@@ -1196,7 +1195,7 @@ const FragmentComponent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((pro
1196
1195
  });
1197
1196
  }, "FragmentComponent_component_T0AypnadAK0"));
1198
1197
  const Fragment = FragmentComponent;
1199
- const componentInfo$6 = {
1198
+ const componentInfo$7 = {
1200
1199
  name: "Image",
1201
1200
  static: true,
1202
1201
  builtIn: true,
@@ -1345,7 +1344,7 @@ const componentInfo$6 = {
1345
1344
  }
1346
1345
  ]
1347
1346
  };
1348
- const componentInfo$5 = {
1347
+ const componentInfo$6 = {
1349
1348
  name: "Core:Section",
1350
1349
  static: true,
1351
1350
  builtIn: true,
@@ -1401,7 +1400,7 @@ const SectionComponent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((prop
1401
1400
  });
1402
1401
  }, "SectionComponent_component_ZWF9iD5WeLg"));
1403
1402
  const Section = SectionComponent;
1404
- const componentInfo$4 = {
1403
+ const componentInfo$5 = {
1405
1404
  name: "Symbol",
1406
1405
  noWrap: true,
1407
1406
  static: true,
@@ -1441,7 +1440,7 @@ const componentInfo$4 = {
1441
1440
  }
1442
1441
  ]
1443
1442
  };
1444
- const componentInfo$3 = {
1443
+ const componentInfo$4 = {
1445
1444
  name: "Text",
1446
1445
  static: true,
1447
1446
  builtIn: true,
@@ -1462,7 +1461,7 @@ const componentInfo$3 = {
1462
1461
  textAlign: "center"
1463
1462
  }
1464
1463
  };
1465
- const componentInfo$2 = {
1464
+ const componentInfo$3 = {
1466
1465
  name: "Video",
1467
1466
  canHaveChildren: true,
1468
1467
  builtIn: true,
@@ -1575,7 +1574,7 @@ const componentInfo$2 = {
1575
1574
  }
1576
1575
  ]
1577
1576
  };
1578
- const componentInfo$1 = {
1577
+ const componentInfo$2 = {
1579
1578
  name: "Embed",
1580
1579
  static: true,
1581
1580
  builtIn: true,
@@ -1619,7 +1618,9 @@ const SCRIPT_MIME_TYPES = [
1619
1618
  "application/ecmascript"
1620
1619
  ];
1621
1620
  const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
1622
- const findAndRunScripts = function findAndRunScripts2(props, state, elem) {
1621
+ const findAndRunScripts$1 = function findAndRunScripts(props, state, elem) {
1622
+ if (!elem || !elem.getElementsByTagName)
1623
+ return;
1623
1624
  const scripts = elem.getElementsByTagName("script");
1624
1625
  for (let i = 0; i < scripts.length; i++) {
1625
1626
  const script = scripts[i];
@@ -1650,7 +1651,7 @@ const Embed = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
1650
1651
  state2 && track2(state2, "ranInitFn");
1651
1652
  if (elem2 && !state2.ranInitFn) {
1652
1653
  state2.ranInitFn = true;
1653
- findAndRunScripts(props2, state2, elem2);
1654
+ findAndRunScripts$1(props2, state2, elem2);
1654
1655
  }
1655
1656
  }, "Embed_component_useWatch_AxgWjrHdlAI", [
1656
1657
  elem,
@@ -1676,7 +1677,7 @@ const ImgComponent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) =
1676
1677
  }, isEditing() && props.imgSrc || "default-key");
1677
1678
  }, "ImgComponent_component_FXvIDBSffO8"));
1678
1679
  const Img = ImgComponent;
1679
- const componentInfo2 = {
1680
+ const componentInfo$1 = {
1680
1681
  name: "Raw:Img",
1681
1682
  hideFromInsertMenu: true,
1682
1683
  builtIn: true,
@@ -1698,46 +1699,131 @@ const componentInfo2 = {
1698
1699
  noWrap: true,
1699
1700
  static: true
1700
1701
  };
1702
+ const findAndRunScripts2 = function findAndRunScripts3(props, state, elem) {
1703
+ if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
1704
+ const scripts = elem.getElementsByTagName("script");
1705
+ for (let i = 0; i < scripts.length; i++) {
1706
+ const script = scripts[i];
1707
+ if (script.src) {
1708
+ if (state.scriptsInserted.includes(script.src))
1709
+ continue;
1710
+ state.scriptsInserted.push(script.src);
1711
+ const newScript = document.createElement("script");
1712
+ newScript.async = true;
1713
+ newScript.src = script.src;
1714
+ document.head.appendChild(newScript);
1715
+ } else if (!script.type || [
1716
+ "text/javascript",
1717
+ "application/javascript",
1718
+ "application/ecmascript"
1719
+ ].includes(script.type)) {
1720
+ if (state.scriptsRun.includes(script.innerText))
1721
+ continue;
1722
+ try {
1723
+ state.scriptsRun.push(script.innerText);
1724
+ new Function(script.innerText)();
1725
+ } catch (error) {
1726
+ console.warn("`CustomCode`: Error running script:", error);
1727
+ }
1728
+ }
1729
+ }
1730
+ }
1731
+ };
1732
+ const CustomCode = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
1733
+ const elem = qwik.useRef();
1734
+ const state = qwik.useStore({
1735
+ scriptsInserted: [],
1736
+ scriptsRun: []
1737
+ });
1738
+ qwik.useClientEffectQrl(qwik.inlinedQrl(() => {
1739
+ const [elem2, props2, state2] = qwik.useLexicalScope();
1740
+ findAndRunScripts2(props2, state2, elem2);
1741
+ }, "CustomCode_component_useClientEffect_4w4c951ufB4", [
1742
+ elem,
1743
+ props,
1744
+ state
1745
+ ]));
1746
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
1747
+ ref: elem,
1748
+ class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
1749
+ dangerouslySetInnerHTML: props.code
1750
+ });
1751
+ }, "CustomCode_component_uYOSy7w7Zqw"));
1752
+ const customCode = CustomCode;
1753
+ const componentInfo2 = {
1754
+ name: "Custom Code",
1755
+ static: true,
1756
+ builtIn: true,
1757
+ requiredPermissions: [
1758
+ "editCode"
1759
+ ],
1760
+ inputs: [
1761
+ {
1762
+ name: "code",
1763
+ type: "html",
1764
+ required: true,
1765
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1766
+ code: true
1767
+ },
1768
+ {
1769
+ name: "replaceNodes",
1770
+ type: "boolean",
1771
+ helperText: "Preserve server rendered dom nodes",
1772
+ advanced: true
1773
+ },
1774
+ {
1775
+ name: "scriptsClientOnly",
1776
+ type: "boolean",
1777
+ defaultValue: false,
1778
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1779
+ advanced: true
1780
+ }
1781
+ ]
1782
+ };
1701
1783
  const getDefaultRegisteredComponents = () => [
1702
1784
  {
1703
1785
  component: Columns$1,
1704
- ...componentInfo$8
1786
+ ...componentInfo$9
1705
1787
  },
1706
1788
  {
1707
1789
  component: Image$1,
1708
- ...componentInfo$6
1790
+ ...componentInfo$7
1709
1791
  },
1710
1792
  {
1711
1793
  component: Img,
1712
- ...componentInfo2
1794
+ ...componentInfo$1
1713
1795
  },
1714
1796
  {
1715
1797
  component: Text$1,
1716
- ...componentInfo$3
1798
+ ...componentInfo$4
1717
1799
  },
1718
1800
  {
1719
1801
  component: Video$1,
1720
- ...componentInfo$2
1802
+ ...componentInfo$3
1721
1803
  },
1722
1804
  {
1723
1805
  component: Symbol$2,
1724
- ...componentInfo$4
1806
+ ...componentInfo$5
1725
1807
  },
1726
1808
  {
1727
1809
  component: Button$1,
1728
- ...componentInfo$9
1810
+ ...componentInfo$a
1729
1811
  },
1730
1812
  {
1731
1813
  component: Section,
1732
- ...componentInfo$5
1814
+ ...componentInfo$6
1733
1815
  },
1734
1816
  {
1735
1817
  component: Fragment,
1736
- ...componentInfo$7
1818
+ ...componentInfo$8
1737
1819
  },
1738
1820
  {
1739
1821
  component: embed,
1740
- ...componentInfo$1
1822
+ ...componentInfo$2
1823
+ },
1824
+ {
1825
+ component: customCode,
1826
+ ...componentInfo2
1741
1827
  }
1742
1828
  ];
1743
1829
  function flatten(object, path = null, separator = ".") {
@@ -1797,17 +1883,13 @@ function getGlobalThis() {
1797
1883
  return self;
1798
1884
  return null;
1799
1885
  }
1800
- const NODE_FETCH_URL = () => "node-fetch";
1801
- let fetch$1 = void 0;
1802
1886
  async function getFetch() {
1803
- if (fetch$1)
1804
- return fetch$1;
1805
1887
  const globalFetch = getGlobalThis().fetch;
1806
1888
  if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
1807
- const nodeFetch = Promise.resolve().then(() => /* @__PURE__ */ _interopNamespace(require(NODE_FETCH_URL()))).then((d) => d.default);
1808
- return fetch$1 = nodeFetch.default || nodeFetch;
1889
+ const nodeFetch = Promise.resolve().then(() => /* @__PURE__ */ _interopNamespace(require("node-fetch"))).then((d) => d.default);
1890
+ return nodeFetch.default || nodeFetch;
1809
1891
  }
1810
- return fetch$1 = globalFetch.default || globalFetch;
1892
+ return globalFetch.default || globalFetch;
1811
1893
  }
1812
1894
  const handleABTesting = (item, testGroups) => {
1813
1895
  if (item.variations && Object.keys(item.variations).length) {
@@ -1,4 +1,4 @@
1
- import { createContext, mutable, componentQrl, inlinedQrl, useContextProvider, useStore, useStylesScopedQrl, useContext, useLexicalScope, Slot, Fragment as Fragment$2, useRef, useWatchQrl, useClientEffectQrl, _useMutableProps, useCleanupQrl } from "@builder.io/qwik";
1
+ import { createContext, inlinedQrl, useLexicalScope, mutable, componentQrl, useContextProvider, useStore, useStylesScopedQrl, useContext, Slot, useRef, useWatchQrl, useClientEffectQrl, _useMutableProps, useCleanupQrl } from "@builder.io/qwik";
2
2
  import { jsx, Fragment as Fragment$1, jsxs } from "@builder.io/qwik/jsx-runtime";
3
3
  const TARGET = "qwik";
4
4
  function isBrowser() {
@@ -252,7 +252,7 @@ const css = function css2(props, state) {
252
252
  };
253
253
  const BlockStyles = (props) => {
254
254
  return /* @__PURE__ */ jsx(Fragment$1, {
255
- children: TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ jsx(RenderInlinedStyles$1, {
255
+ children: TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" || TARGET === "qwik" ? /* @__PURE__ */ jsx(RenderInlinedStyles$1, {
256
256
  styles: css(props)
257
257
  }) : null
258
258
  });
@@ -261,7 +261,21 @@ const BlockStyles$1 = BlockStyles;
261
261
  function capitalizeFirstLetter(string) {
262
262
  return string.charAt(0).toUpperCase() + string.slice(1);
263
263
  }
264
- const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
264
+ const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}$`;
265
+ function crateEventHandler(value, options) {
266
+ return inlinedQrl((event) => {
267
+ const [options2, value2] = useLexicalScope();
268
+ return evaluate({
269
+ code: value2,
270
+ context: options2.context,
271
+ state: options2.state,
272
+ event
273
+ });
274
+ }, "crateEventHandler_wgxT8Hlq4s8", [
275
+ options,
276
+ value
277
+ ]);
278
+ }
265
279
  function getBlockActions(options) {
266
280
  const obj = {};
267
281
  const optionActions = options.block.actions ?? {};
@@ -269,12 +283,7 @@ function getBlockActions(options) {
269
283
  if (!optionActions.hasOwnProperty(key))
270
284
  continue;
271
285
  const value = optionActions[key];
272
- obj[getEventHandlerName(key)] = (event) => evaluate({
273
- code: value,
274
- context: options.context,
275
- state: options.state,
276
- event
277
- });
286
+ obj[getEventHandlerName(key)] = crateEventHandler(value, options);
278
287
  }
279
288
  return obj;
280
289
  }
@@ -297,22 +306,8 @@ function getBlockProperties(block) {
297
306
  ].filter(Boolean).join(" ")
298
307
  };
299
308
  }
300
- const convertStyleObject = (obj) => {
301
- return obj;
302
- };
303
- const sanitizeBlockStyles = (_styles) => {
304
- };
305
309
  function getBlockStyles(block) {
306
- const styles = {
307
- ...convertStyleObject(block.responsiveStyles?.large),
308
- ...block.styles
309
- };
310
- if (block.responsiveStyles?.medium)
311
- styles[getMaxWidthQueryForSize("medium")] = convertStyleObject(block.responsiveStyles?.medium);
312
- if (block.responsiveStyles?.small)
313
- styles[getMaxWidthQueryForSize("small")] = convertStyleObject(block.responsiveStyles?.small);
314
- sanitizeBlockStyles();
315
- return styles;
310
+ return null;
316
311
  }
317
312
  function getBlockTag(block) {
318
313
  return block.tagName || "div";
@@ -410,7 +405,7 @@ const component = function component2(props, state) {
410
405
  } else
411
406
  return ref;
412
407
  };
413
- const componentInfo$a = function componentInfo(props, state) {
408
+ const componentInfo$b = function componentInfo(props, state) {
414
409
  if (component(props)) {
415
410
  const { component: _, ...info } = component(props);
416
411
  return info;
@@ -443,7 +438,7 @@ const attributes = function attributes2(props, state) {
443
438
  };
444
439
  };
445
440
  const shouldWrap = function shouldWrap2(props, state) {
446
- return !componentInfo$a(props)?.noWrap;
441
+ return !componentInfo$b(props)?.noWrap;
447
442
  };
448
443
  const componentOptions = function componentOptions2(props, state) {
449
444
  return {
@@ -502,8 +497,7 @@ const RenderBlock = (props) => {
502
497
  };
503
498
  state.tagName = tagName2(props);
504
499
  return /* @__PURE__ */ jsx(Fragment$1, {
505
- children: shouldWrap(props) ? !isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxs(state.tagName, {
506
- ...attributes(props),
500
+ children: shouldWrap(props) ? !isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxs(Fragment$1, {
507
501
  children: [
508
502
  repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
509
503
  return /* @__PURE__ */ jsx(RenderRepeatedBlock$1, {
@@ -511,21 +505,26 @@ const RenderBlock = (props) => {
511
505
  block: data.block
512
506
  }, index);
513
507
  }) : null,
514
- !repeatItemData(props) ? /* @__PURE__ */ jsx(RenderComponent$1, {
515
- ...renderComponentProps(props)
516
- }) : null,
517
- (childrenWithoutParentComponent(props) || []).map(function(child) {
518
- return /* @__PURE__ */ jsx(RenderBlock, {
519
- block: child,
520
- context: props.context
521
- }, "render-block-" + child.id);
522
- }),
523
- (childrenWithoutParentComponent(props) || []).map(function(child) {
524
- return /* @__PURE__ */ jsx(BlockStyles$1, {
525
- block: child,
526
- context: props.context
527
- }, "block-style-" + child.id);
528
- })
508
+ !repeatItemData(props) ? /* @__PURE__ */ jsxs(state.tagName, {
509
+ ...attributes(props),
510
+ children: [
511
+ /* @__PURE__ */ jsx(RenderComponent$1, {
512
+ ...renderComponentProps(props)
513
+ }),
514
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
515
+ return /* @__PURE__ */ jsx(RenderBlock, {
516
+ block: child,
517
+ context: props.context
518
+ }, "render-block-" + child.id);
519
+ }),
520
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
521
+ return /* @__PURE__ */ jsx(BlockStyles$1, {
522
+ block: child,
523
+ context: props.context
524
+ }, "block-style-" + child.id);
525
+ })
526
+ ]
527
+ }) : null
529
528
  ]
530
529
  }) : /* @__PURE__ */ jsx(state.tagName, {
531
530
  ...attributes(props)
@@ -862,7 +861,7 @@ const Video = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
862
861
  const Video$1 = Video;
863
862
  const Button = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
864
863
  useStylesScopedQrl(inlinedQrl(STYLES, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
865
- return /* @__PURE__ */ jsx(Fragment$2, {
864
+ return /* @__PURE__ */ jsx(Fragment$1, {
866
865
  children: props.link ? /* @__PURE__ */ jsx("a", {
867
866
  role: "button",
868
867
  ...props.attributes,
@@ -879,7 +878,7 @@ const Button = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
879
878
  const Button$1 = Button;
880
879
  const STYLES = `.button-Button {
881
880
  all: unset; }`;
882
- const componentInfo$9 = {
881
+ const componentInfo$a = {
883
882
  name: "Core:Button",
884
883
  builtIn: true,
885
884
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
@@ -921,7 +920,7 @@ function markSerializable(fn) {
921
920
  fn.__qwik_serializable__ = true;
922
921
  return fn;
923
922
  }
924
- const componentInfo$8 = {
923
+ const componentInfo$9 = {
925
924
  name: "Columns",
926
925
  builtIn: true,
927
926
  inputs: [
@@ -1162,7 +1161,7 @@ const componentInfo$8 = {
1162
1161
  }
1163
1162
  ]
1164
1163
  };
1165
- const componentInfo$7 = {
1164
+ const componentInfo$8 = {
1166
1165
  name: "Fragment",
1167
1166
  static: true,
1168
1167
  hidden: true,
@@ -1176,7 +1175,7 @@ const FragmentComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
1176
1175
  });
1177
1176
  }, "FragmentComponent_component_T0AypnadAK0"));
1178
1177
  const Fragment = FragmentComponent;
1179
- const componentInfo$6 = {
1178
+ const componentInfo$7 = {
1180
1179
  name: "Image",
1181
1180
  static: true,
1182
1181
  builtIn: true,
@@ -1325,7 +1324,7 @@ const componentInfo$6 = {
1325
1324
  }
1326
1325
  ]
1327
1326
  };
1328
- const componentInfo$5 = {
1327
+ const componentInfo$6 = {
1329
1328
  name: "Core:Section",
1330
1329
  static: true,
1331
1330
  builtIn: true,
@@ -1381,7 +1380,7 @@ const SectionComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
1381
1380
  });
1382
1381
  }, "SectionComponent_component_ZWF9iD5WeLg"));
1383
1382
  const Section = SectionComponent;
1384
- const componentInfo$4 = {
1383
+ const componentInfo$5 = {
1385
1384
  name: "Symbol",
1386
1385
  noWrap: true,
1387
1386
  static: true,
@@ -1421,7 +1420,7 @@ const componentInfo$4 = {
1421
1420
  }
1422
1421
  ]
1423
1422
  };
1424
- const componentInfo$3 = {
1423
+ const componentInfo$4 = {
1425
1424
  name: "Text",
1426
1425
  static: true,
1427
1426
  builtIn: true,
@@ -1442,7 +1441,7 @@ const componentInfo$3 = {
1442
1441
  textAlign: "center"
1443
1442
  }
1444
1443
  };
1445
- const componentInfo$2 = {
1444
+ const componentInfo$3 = {
1446
1445
  name: "Video",
1447
1446
  canHaveChildren: true,
1448
1447
  builtIn: true,
@@ -1555,7 +1554,7 @@ const componentInfo$2 = {
1555
1554
  }
1556
1555
  ]
1557
1556
  };
1558
- const componentInfo$1 = {
1557
+ const componentInfo$2 = {
1559
1558
  name: "Embed",
1560
1559
  static: true,
1561
1560
  builtIn: true,
@@ -1599,7 +1598,9 @@ const SCRIPT_MIME_TYPES = [
1599
1598
  "application/ecmascript"
1600
1599
  ];
1601
1600
  const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
1602
- const findAndRunScripts = function findAndRunScripts2(props, state, elem) {
1601
+ const findAndRunScripts$1 = function findAndRunScripts(props, state, elem) {
1602
+ if (!elem || !elem.getElementsByTagName)
1603
+ return;
1603
1604
  const scripts = elem.getElementsByTagName("script");
1604
1605
  for (let i = 0; i < scripts.length; i++) {
1605
1606
  const script = scripts[i];
@@ -1630,7 +1631,7 @@ const Embed = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
1630
1631
  state2 && track2(state2, "ranInitFn");
1631
1632
  if (elem2 && !state2.ranInitFn) {
1632
1633
  state2.ranInitFn = true;
1633
- findAndRunScripts(props2, state2, elem2);
1634
+ findAndRunScripts$1(props2, state2, elem2);
1634
1635
  }
1635
1636
  }, "Embed_component_useWatch_AxgWjrHdlAI", [
1636
1637
  elem,
@@ -1656,7 +1657,7 @@ const ImgComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
1656
1657
  }, isEditing() && props.imgSrc || "default-key");
1657
1658
  }, "ImgComponent_component_FXvIDBSffO8"));
1658
1659
  const Img = ImgComponent;
1659
- const componentInfo2 = {
1660
+ const componentInfo$1 = {
1660
1661
  name: "Raw:Img",
1661
1662
  hideFromInsertMenu: true,
1662
1663
  builtIn: true,
@@ -1678,46 +1679,131 @@ const componentInfo2 = {
1678
1679
  noWrap: true,
1679
1680
  static: true
1680
1681
  };
1682
+ const findAndRunScripts2 = function findAndRunScripts3(props, state, elem) {
1683
+ if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
1684
+ const scripts = elem.getElementsByTagName("script");
1685
+ for (let i = 0; i < scripts.length; i++) {
1686
+ const script = scripts[i];
1687
+ if (script.src) {
1688
+ if (state.scriptsInserted.includes(script.src))
1689
+ continue;
1690
+ state.scriptsInserted.push(script.src);
1691
+ const newScript = document.createElement("script");
1692
+ newScript.async = true;
1693
+ newScript.src = script.src;
1694
+ document.head.appendChild(newScript);
1695
+ } else if (!script.type || [
1696
+ "text/javascript",
1697
+ "application/javascript",
1698
+ "application/ecmascript"
1699
+ ].includes(script.type)) {
1700
+ if (state.scriptsRun.includes(script.innerText))
1701
+ continue;
1702
+ try {
1703
+ state.scriptsRun.push(script.innerText);
1704
+ new Function(script.innerText)();
1705
+ } catch (error) {
1706
+ console.warn("`CustomCode`: Error running script:", error);
1707
+ }
1708
+ }
1709
+ }
1710
+ }
1711
+ };
1712
+ const CustomCode = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
1713
+ const elem = useRef();
1714
+ const state = useStore({
1715
+ scriptsInserted: [],
1716
+ scriptsRun: []
1717
+ });
1718
+ useClientEffectQrl(inlinedQrl(() => {
1719
+ const [elem2, props2, state2] = useLexicalScope();
1720
+ findAndRunScripts2(props2, state2, elem2);
1721
+ }, "CustomCode_component_useClientEffect_4w4c951ufB4", [
1722
+ elem,
1723
+ props,
1724
+ state
1725
+ ]));
1726
+ return /* @__PURE__ */ jsx("div", {
1727
+ ref: elem,
1728
+ class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
1729
+ dangerouslySetInnerHTML: props.code
1730
+ });
1731
+ }, "CustomCode_component_uYOSy7w7Zqw"));
1732
+ const customCode = CustomCode;
1733
+ const componentInfo2 = {
1734
+ name: "Custom Code",
1735
+ static: true,
1736
+ builtIn: true,
1737
+ requiredPermissions: [
1738
+ "editCode"
1739
+ ],
1740
+ inputs: [
1741
+ {
1742
+ name: "code",
1743
+ type: "html",
1744
+ required: true,
1745
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1746
+ code: true
1747
+ },
1748
+ {
1749
+ name: "replaceNodes",
1750
+ type: "boolean",
1751
+ helperText: "Preserve server rendered dom nodes",
1752
+ advanced: true
1753
+ },
1754
+ {
1755
+ name: "scriptsClientOnly",
1756
+ type: "boolean",
1757
+ defaultValue: false,
1758
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1759
+ advanced: true
1760
+ }
1761
+ ]
1762
+ };
1681
1763
  const getDefaultRegisteredComponents = () => [
1682
1764
  {
1683
1765
  component: Columns$1,
1684
- ...componentInfo$8
1766
+ ...componentInfo$9
1685
1767
  },
1686
1768
  {
1687
1769
  component: Image$1,
1688
- ...componentInfo$6
1770
+ ...componentInfo$7
1689
1771
  },
1690
1772
  {
1691
1773
  component: Img,
1692
- ...componentInfo2
1774
+ ...componentInfo$1
1693
1775
  },
1694
1776
  {
1695
1777
  component: Text$1,
1696
- ...componentInfo$3
1778
+ ...componentInfo$4
1697
1779
  },
1698
1780
  {
1699
1781
  component: Video$1,
1700
- ...componentInfo$2
1782
+ ...componentInfo$3
1701
1783
  },
1702
1784
  {
1703
1785
  component: Symbol$2,
1704
- ...componentInfo$4
1786
+ ...componentInfo$5
1705
1787
  },
1706
1788
  {
1707
1789
  component: Button$1,
1708
- ...componentInfo$9
1790
+ ...componentInfo$a
1709
1791
  },
1710
1792
  {
1711
1793
  component: Section,
1712
- ...componentInfo$5
1794
+ ...componentInfo$6
1713
1795
  },
1714
1796
  {
1715
1797
  component: Fragment,
1716
- ...componentInfo$7
1798
+ ...componentInfo$8
1717
1799
  },
1718
1800
  {
1719
1801
  component: embed,
1720
- ...componentInfo$1
1802
+ ...componentInfo$2
1803
+ },
1804
+ {
1805
+ component: customCode,
1806
+ ...componentInfo2
1721
1807
  }
1722
1808
  ];
1723
1809
  function flatten(object, path = null, separator = ".") {
@@ -1777,17 +1863,13 @@ function getGlobalThis() {
1777
1863
  return self;
1778
1864
  return null;
1779
1865
  }
1780
- const NODE_FETCH_URL = () => "node-fetch";
1781
- let fetch$1 = void 0;
1782
1866
  async function getFetch() {
1783
- if (fetch$1)
1784
- return fetch$1;
1785
1867
  const globalFetch = getGlobalThis().fetch;
1786
1868
  if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
1787
- const nodeFetch = import(NODE_FETCH_URL()).then((d) => d.default);
1788
- return fetch$1 = nodeFetch.default || nodeFetch;
1869
+ const nodeFetch = import("node-fetch").then((d) => d.default);
1870
+ return nodeFetch.default || nodeFetch;
1789
1871
  }
1790
- return fetch$1 = globalFetch.default || globalFetch;
1872
+ return globalFetch.default || globalFetch;
1791
1873
  }
1792
1874
  const handleABTesting = (item, testGroups) => {
1793
1875
  if (item.variations && Object.keys(item.variations).length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Builder.io Qwik SDK",
5
5
  "type": "module",
6
6
  "main": "./lib/index.qwik.cjs",
@@ -15,16 +15,17 @@
15
15
  },
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
- "build.lib": "tsc && vite build --mode lib",
19
- "release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag latest --access public"
18
+ "build": "tsc && vite build --mode lib",
19
+ "release:patch": "yarn run build && npm version patch --no-git-tag-version && npm publish --access public",
20
+ "release:dev": "yarn run build && npm version prerelease --no-git-tag-version && npm publish --tag latest --access public"
20
21
  },
21
22
  "devDependencies": {
22
- "@builder.io/qwik": "BuilderIO/qwik-build#commit=08a6883d163f8eea8dc1710357b63b7ac01b2bef",
23
+ "@builder.io/qwik": "0.0.108-dev20220913220811",
23
24
  "@types/node": "latest",
24
- "typescript": "4.7.4",
25
- "vite": "3.0.2"
25
+ "typescript": "^4",
26
+ "vite": "^3.0.4"
26
27
  },
27
28
  "peerDependencies": {
28
- "@builder.io/qwik": "0.0.108"
29
+ "@builder.io/qwik": "0.0.108-dev20220913220811"
29
30
  }
30
31
  }
@@ -8,7 +8,7 @@ export declare type RenderBlockProps = {
8
8
  export declare const component: (props: any, state: any) => any;
9
9
  export declare const componentInfo: (props: any, state: any) => any;
10
10
  export declare const componentRef: (props: any, state: any) => any;
11
- export declare const tagName: (props: any, state: any) => import("../../functions/get-block-tag.js").TagName;
11
+ export declare const tagName: (props: any, state: any) => string;
12
12
  export declare const useBlock: (props: any, state: any) => any;
13
13
  export declare const attributes: (props: any, state: any) => {
14
14
  style: any;
@@ -1,6 +1,6 @@
1
1
  import { BuilderRenderContext, RegisteredComponent } from "../../context/types.js";
2
2
  import { BuilderContent } from "../../types/builder-content.js";
3
- import { Nullable } from "../../types/typescript.js";
3
+ import type { Nullable } from "../../types/typescript.js";
4
4
  export declare type RenderContentProps = {
5
5
  content?: Nullable<BuilderContent>;
6
6
  model?: string;
@@ -0,0 +1,5 @@
1
+ import type { BuilderContextInterface } from '../context/types.js';
2
+ import { BuilderBlock } from '../types/builder-block.js';
3
+ export declare function crateEventHandler(value: string, options: {
4
+ block: BuilderBlock;
5
+ } & Pick<BuilderContextInterface, 'state' | 'context'>): (event: Event) => any;
@@ -1,10 +1,3 @@
1
- import { JSX } from '@builder.io/mitosis/jsx-runtime';
2
1
  import { BuilderBlock } from '../types/builder-block.js';
3
- declare type JSXElementConstructor<P> = (props: P) => JSX.Element | null;
4
- export declare type TagName = string | JSXElementConstructor<any>;
5
- /**
6
- * The `JSXElementConstructor` type is here to account for a react-native override, where we have a
7
- * `View` tag wrapping every component.
8
- */
2
+ export declare type TagName = string;
9
3
  export declare function getBlockTag(block: BuilderBlock): TagName;
10
- export {};
@@ -8,7 +8,7 @@ export declare const components: RegisteredComponent[];
8
8
  * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
9
9
  */
10
10
  export declare function registerComponent(component: any, info: ComponentInfo): void;
11
- export declare const createRegisterComponentMessage: ({ component: _, ...info }: RegisteredComponent) => {
11
+ export declare const createRegisterComponentMessage: ({ component, ...info }: RegisteredComponent) => {
12
12
  type: string;
13
13
  data: ComponentInfo;
14
14
  };