@builder.io/sdk-react-nextjs 0.5.9 → 0.6.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 (286) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-29f9ac5c.js +23 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-dfa97c43.mjs +664 -0
  3. package/lib/browser/USE_SERVER_BUNDLE-25e181fa.js +1 -0
  4. package/lib/browser/USE_SERVER_BUNDLE-fcd44ecb.mjs +11 -0
  5. package/lib/browser/bundle-5cab6113.js +76 -0
  6. package/lib/browser/bundle-babbd573.mjs +2419 -0
  7. package/lib/browser/index.cjs +1 -0
  8. package/lib/browser/index.mjs +34 -0
  9. package/lib/edge/USE_CLIENT_BUNDLE-3cbb02d5.mjs +664 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-d0b99f60.js +23 -0
  11. package/lib/edge/USE_SERVER_BUNDLE-4eeb4634.mjs +11 -0
  12. package/lib/edge/USE_SERVER_BUNDLE-bbd89085.js +1 -0
  13. package/lib/edge/bundle-9ed99f98.mjs +4863 -0
  14. package/lib/edge/bundle-e4764e2a.js +96 -0
  15. package/lib/edge/index.cjs +1 -0
  16. package/lib/edge/index.mjs +34 -0
  17. package/lib/node/USE_CLIENT_BUNDLE-29f9ac5c.js +23 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-dfa97c43.mjs +664 -0
  19. package/lib/node/USE_SERVER_BUNDLE-25e181fa.js +1 -0
  20. package/lib/node/USE_SERVER_BUNDLE-fcd44ecb.mjs +11 -0
  21. package/lib/node/bundle-5cab6113.js +76 -0
  22. package/lib/node/bundle-babbd573.mjs +2419 -0
  23. package/lib/node/index.cjs +1 -0
  24. package/lib/node/index.mjs +34 -0
  25. package/package.json +96 -13
  26. package/types/constants/sdk-version.d.ts +1 -0
  27. package/types/functions/deopt.d.ts +4 -0
  28. package/types/functions/evaluate/browser-runtime/index.d.ts +1 -0
  29. package/{dist → types}/functions/fetch-builder-props.d.ts +2 -1
  30. package/{dist → types}/functions/get-content/index.d.ts +4 -5
  31. package/{dist → types}/index-helpers/blocks-exports.d.ts +2 -2
  32. package/dist/blocks/button/button.js +0 -12
  33. package/dist/blocks/button/component-info.js +0 -34
  34. package/dist/blocks/columns/columns.js +0 -119
  35. package/dist/blocks/columns/component-info.js +0 -219
  36. package/dist/blocks/custom-code/component-info.js +0 -23
  37. package/dist/blocks/custom-code/custom-code.js +0 -51
  38. package/dist/blocks/embed/component-info.js +0 -39
  39. package/dist/blocks/embed/embed.js +0 -42
  40. package/dist/blocks/embed/helpers.js +0 -2
  41. package/dist/blocks/fragment/component-info.js +0 -7
  42. package/dist/blocks/fragment/fragment.js +0 -6
  43. package/dist/blocks/helpers.js +0 -40
  44. package/dist/blocks/image/component-info.js +0 -122
  45. package/dist/blocks/image/image.helpers.js +0 -47
  46. package/dist/blocks/image/image.js +0 -82
  47. package/dist/blocks/img/component-info.js +0 -15
  48. package/dist/blocks/img/img.js +0 -10
  49. package/dist/blocks/section/component-info.js +0 -40
  50. package/dist/blocks/section/section.js +0 -17
  51. package/dist/blocks/symbol/component-info.js +0 -34
  52. package/dist/blocks/symbol/symbol.helpers.js +0 -31
  53. package/dist/blocks/symbol/symbol.js +0 -29
  54. package/dist/blocks/text/component-info.js +0 -19
  55. package/dist/blocks/text/text.js +0 -7
  56. package/dist/blocks/video/component-info.js +0 -82
  57. package/dist/blocks/video/video.js +0 -50
  58. package/dist/components/block/block.helpers.js +0 -69
  59. package/dist/components/block/block.js +0 -92
  60. package/dist/components/block/components/block-styles.js +0 -65
  61. package/dist/components/block/components/block-wrapper.js +0 -36
  62. package/dist/components/block/components/component-ref/component-ref.helpers.js +0 -22
  63. package/dist/components/block/components/component-ref/component-ref.js +0 -21
  64. package/dist/components/block/components/interactive-element.js +0 -20
  65. package/dist/components/block/components/repeated-block.js +0 -7
  66. package/dist/components/block/types.js +0 -1
  67. package/dist/components/blocks/blocks-wrapper.js +0 -38
  68. package/dist/components/blocks/blocks.js +0 -10
  69. package/dist/components/content/components/enable-editor.js +0 -250
  70. package/dist/components/content/components/styles.helpers.js +0 -58
  71. package/dist/components/content/components/styles.js +0 -30
  72. package/dist/components/content/content.helpers.js +0 -30
  73. package/dist/components/content/content.js +0 -74
  74. package/dist/components/content/content.types.js +0 -1
  75. package/dist/components/content/wrap-component-ref.js +0 -6
  76. package/dist/components/content-variants/content-variants.js +0 -45
  77. package/dist/components/content-variants/content-variants.types.js +0 -1
  78. package/dist/components/content-variants/helpers.js +0 -189
  79. package/dist/components/inlined-script.js +0 -5
  80. package/dist/components/inlined-styles.js +0 -5
  81. package/dist/constants/builder-registered-components.js +0 -60
  82. package/dist/constants/device-sizes.js +0 -45
  83. package/dist/constants/sdk-version.d.ts +0 -1
  84. package/dist/constants/sdk-version.js +0 -1
  85. package/dist/constants/target.js +0 -2
  86. package/dist/context/builder.context.js +0 -12
  87. package/dist/context/components.context.js +0 -2
  88. package/dist/context/types.js +0 -1
  89. package/dist/functions/camel-to-kebab-case.js +0 -1
  90. package/dist/functions/evaluate/browser-runtime/browser.js +0 -31
  91. package/dist/functions/evaluate/evaluate.js +0 -47
  92. package/dist/functions/evaluate/helpers.js +0 -10
  93. package/dist/functions/evaluate/index.js +0 -1
  94. package/dist/functions/evaluate/non-node-runtime/acorn-interpreter.d.ts +0 -2
  95. package/dist/functions/evaluate/non-node-runtime/acorn-interpreter.js +0 -3111
  96. package/dist/functions/evaluate/non-node-runtime/index.d.ts +0 -1
  97. package/dist/functions/evaluate/non-node-runtime/index.js +0 -2
  98. package/dist/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +0 -2
  99. package/dist/functions/evaluate/non-node-runtime/non-node-runtime.js +0 -83
  100. package/dist/functions/event-handler-name.js +0 -4
  101. package/dist/functions/extract-text-styles.js +0 -22
  102. package/dist/functions/fast-clone.js +0 -4
  103. package/dist/functions/fetch-builder-props.js +0 -25
  104. package/dist/functions/get-block-actions-handler.js +0 -10
  105. package/dist/functions/get-block-actions.js +0 -28
  106. package/dist/functions/get-block-component-options.js +0 -10
  107. package/dist/functions/get-block-properties.js +0 -72
  108. package/dist/functions/get-builder-search-params/index.js +0 -38
  109. package/dist/functions/get-content/generate-content-url.js +0 -33
  110. package/dist/functions/get-content/index.js +0 -100
  111. package/dist/functions/get-content/types.js +0 -1
  112. package/dist/functions/get-fetch.js +0 -11
  113. package/dist/functions/get-global-this.js +0 -15
  114. package/dist/functions/get-processed-block.js +0 -46
  115. package/dist/functions/get-react-native-block-styles.js +0 -17
  116. package/dist/functions/is-browser.js +0 -3
  117. package/dist/functions/is-editing.js +0 -5
  118. package/dist/functions/is-iframe.js +0 -4
  119. package/dist/functions/is-non-node-server.d.ts +0 -4
  120. package/dist/functions/is-non-node-server.js +0 -8
  121. package/dist/functions/is-previewing.js +0 -11
  122. package/dist/functions/register-component.js +0 -38
  123. package/dist/functions/register.js +0 -27
  124. package/dist/functions/sanitize-react-native-block-styles.js +0 -61
  125. package/dist/functions/set-editor-settings.js +0 -12
  126. package/dist/functions/set.js +0 -14
  127. package/dist/functions/track/helpers.js +0 -51
  128. package/dist/functions/track/index.js +0 -71
  129. package/dist/functions/track/interaction.js +0 -53
  130. package/dist/functions/transform-block-properties.js +0 -5
  131. package/dist/functions/transform-block.js +0 -4
  132. package/dist/helpers/ab-tests.js +0 -122
  133. package/dist/helpers/canTrack.js +0 -2
  134. package/dist/helpers/cookie.js +0 -55
  135. package/dist/helpers/css.js +0 -27
  136. package/dist/helpers/flatten.js +0 -19
  137. package/dist/helpers/localStorage.js +0 -24
  138. package/dist/helpers/logger.js +0 -7
  139. package/dist/helpers/nullable.js +0 -1
  140. package/dist/helpers/preview-lru-cache/get.js +0 -9
  141. package/dist/helpers/preview-lru-cache/helpers.js +0 -9
  142. package/dist/helpers/preview-lru-cache/init.js +0 -15
  143. package/dist/helpers/preview-lru-cache/set.js +0 -7
  144. package/dist/helpers/preview-lru-cache/types.js +0 -6
  145. package/dist/helpers/sessionId.js +0 -30
  146. package/dist/helpers/url.js +0 -15
  147. package/dist/helpers/uuid.js +0 -15
  148. package/dist/helpers/visitorId.js +0 -30
  149. package/dist/index-helpers/blocks-exports.js +0 -19
  150. package/dist/index-helpers/top-of-file.js +0 -4
  151. package/dist/index.js +0 -7
  152. package/dist/scripts/init-editing.js +0 -110
  153. package/dist/server-index.js +0 -10
  154. package/dist/types/api-version.js +0 -1
  155. package/dist/types/builder-block.js +0 -1
  156. package/dist/types/builder-content.js +0 -1
  157. package/dist/types/builder-props.js +0 -1
  158. package/dist/types/can-track.js +0 -1
  159. package/dist/types/components.js +0 -1
  160. package/dist/types/deep-partial.js +0 -1
  161. package/dist/types/element.js +0 -1
  162. package/dist/types/enforced-partials.js +0 -1
  163. package/dist/types/input.js +0 -1
  164. package/dist/types/targets.js +0 -1
  165. package/dist/types/typescript.js +0 -1
  166. /package/{dist → types}/blocks/button/button.d.ts +0 -0
  167. /package/{dist → types}/blocks/button/component-info.d.ts +0 -0
  168. /package/{dist → types}/blocks/columns/columns.d.ts +0 -0
  169. /package/{dist → types}/blocks/columns/component-info.d.ts +0 -0
  170. /package/{dist → types}/blocks/custom-code/component-info.d.ts +0 -0
  171. /package/{dist → types}/blocks/custom-code/custom-code.d.ts +0 -0
  172. /package/{dist → types}/blocks/embed/component-info.d.ts +0 -0
  173. /package/{dist → types}/blocks/embed/embed.d.ts +0 -0
  174. /package/{dist → types}/blocks/embed/helpers.d.ts +0 -0
  175. /package/{dist → types}/blocks/fragment/component-info.d.ts +0 -0
  176. /package/{dist → types}/blocks/fragment/fragment.d.ts +0 -0
  177. /package/{dist → types}/blocks/helpers.d.ts +0 -0
  178. /package/{dist → types}/blocks/image/component-info.d.ts +0 -0
  179. /package/{dist → types}/blocks/image/image.d.ts +0 -0
  180. /package/{dist → types}/blocks/image/image.helpers.d.ts +0 -0
  181. /package/{dist → types}/blocks/img/component-info.d.ts +0 -0
  182. /package/{dist → types}/blocks/img/img.d.ts +0 -0
  183. /package/{dist → types}/blocks/section/component-info.d.ts +0 -0
  184. /package/{dist → types}/blocks/section/section.d.ts +0 -0
  185. /package/{dist → types}/blocks/symbol/component-info.d.ts +0 -0
  186. /package/{dist → types}/blocks/symbol/symbol.d.ts +0 -0
  187. /package/{dist → types}/blocks/symbol/symbol.helpers.d.ts +0 -0
  188. /package/{dist → types}/blocks/text/component-info.d.ts +0 -0
  189. /package/{dist → types}/blocks/text/text.d.ts +0 -0
  190. /package/{dist → types}/blocks/video/component-info.d.ts +0 -0
  191. /package/{dist → types}/blocks/video/video.d.ts +0 -0
  192. /package/{dist → types}/components/block/block.d.ts +0 -0
  193. /package/{dist → types}/components/block/block.helpers.d.ts +0 -0
  194. /package/{dist → types}/components/block/components/block-styles.d.ts +0 -0
  195. /package/{dist → types}/components/block/components/block-wrapper.d.ts +0 -0
  196. /package/{dist → types}/components/block/components/component-ref/component-ref.d.ts +0 -0
  197. /package/{dist → types}/components/block/components/component-ref/component-ref.helpers.d.ts +0 -0
  198. /package/{dist → types}/components/block/components/interactive-element.d.ts +0 -0
  199. /package/{dist → types}/components/block/components/repeated-block.d.ts +0 -0
  200. /package/{dist → types}/components/block/types.d.ts +0 -0
  201. /package/{dist → types}/components/blocks/blocks-wrapper.d.ts +0 -0
  202. /package/{dist → types}/components/blocks/blocks.d.ts +0 -0
  203. /package/{dist → types}/components/content/components/enable-editor.d.ts +0 -0
  204. /package/{dist → types}/components/content/components/styles.d.ts +0 -0
  205. /package/{dist → types}/components/content/components/styles.helpers.d.ts +0 -0
  206. /package/{dist → types}/components/content/content.d.ts +0 -0
  207. /package/{dist → types}/components/content/content.helpers.d.ts +0 -0
  208. /package/{dist → types}/components/content/content.types.d.ts +0 -0
  209. /package/{dist → types}/components/content/wrap-component-ref.d.ts +0 -0
  210. /package/{dist → types}/components/content-variants/content-variants.d.ts +0 -0
  211. /package/{dist → types}/components/content-variants/content-variants.types.d.ts +0 -0
  212. /package/{dist → types}/components/content-variants/helpers.d.ts +0 -0
  213. /package/{dist → types}/components/inlined-script.d.ts +0 -0
  214. /package/{dist → types}/components/inlined-styles.d.ts +0 -0
  215. /package/{dist → types}/constants/builder-registered-components.d.ts +0 -0
  216. /package/{dist → types}/constants/device-sizes.d.ts +0 -0
  217. /package/{dist → types}/constants/target.d.ts +0 -0
  218. /package/{dist → types}/context/builder.context.d.ts +0 -0
  219. /package/{dist → types}/context/components.context.d.ts +0 -0
  220. /package/{dist → types}/context/types.d.ts +0 -0
  221. /package/{dist → types}/functions/camel-to-kebab-case.d.ts +0 -0
  222. /package/{dist → types}/functions/evaluate/browser-runtime/browser.d.ts +0 -0
  223. /package/{dist → types}/functions/evaluate/evaluate.d.ts +0 -0
  224. /package/{dist → types}/functions/evaluate/helpers.d.ts +0 -0
  225. /package/{dist → types}/functions/evaluate/index.d.ts +0 -0
  226. /package/{dist → types}/functions/event-handler-name.d.ts +0 -0
  227. /package/{dist → types}/functions/extract-text-styles.d.ts +0 -0
  228. /package/{dist → types}/functions/fast-clone.d.ts +0 -0
  229. /package/{dist → types}/functions/get-block-actions-handler.d.ts +0 -0
  230. /package/{dist → types}/functions/get-block-actions.d.ts +0 -0
  231. /package/{dist → types}/functions/get-block-component-options.d.ts +0 -0
  232. /package/{dist → types}/functions/get-block-properties.d.ts +0 -0
  233. /package/{dist → types}/functions/get-builder-search-params/index.d.ts +0 -0
  234. /package/{dist → types}/functions/get-content/generate-content-url.d.ts +0 -0
  235. /package/{dist → types}/functions/get-content/types.d.ts +0 -0
  236. /package/{dist → types}/functions/get-fetch.d.ts +0 -0
  237. /package/{dist → types}/functions/get-global-this.d.ts +0 -0
  238. /package/{dist → types}/functions/get-processed-block.d.ts +0 -0
  239. /package/{dist → types}/functions/get-react-native-block-styles.d.ts +0 -0
  240. /package/{dist → types}/functions/is-browser.d.ts +0 -0
  241. /package/{dist → types}/functions/is-editing.d.ts +0 -0
  242. /package/{dist → types}/functions/is-iframe.d.ts +0 -0
  243. /package/{dist → types}/functions/is-previewing.d.ts +0 -0
  244. /package/{dist → types}/functions/register-component.d.ts +0 -0
  245. /package/{dist → types}/functions/register.d.ts +0 -0
  246. /package/{dist → types}/functions/sanitize-react-native-block-styles.d.ts +0 -0
  247. /package/{dist → types}/functions/set-editor-settings.d.ts +0 -0
  248. /package/{dist → types}/functions/set.d.ts +0 -0
  249. /package/{dist → types}/functions/track/helpers.d.ts +0 -0
  250. /package/{dist → types}/functions/track/index.d.ts +0 -0
  251. /package/{dist → types}/functions/track/interaction.d.ts +0 -0
  252. /package/{dist → types}/functions/transform-block-properties.d.ts +0 -0
  253. /package/{dist → types}/functions/transform-block.d.ts +0 -0
  254. /package/{dist → types}/helpers/ab-tests.d.ts +0 -0
  255. /package/{dist → types}/helpers/canTrack.d.ts +0 -0
  256. /package/{dist → types}/helpers/cookie.d.ts +0 -0
  257. /package/{dist → types}/helpers/css.d.ts +0 -0
  258. /package/{dist → types}/helpers/flatten.d.ts +0 -0
  259. /package/{dist → types}/helpers/localStorage.d.ts +0 -0
  260. /package/{dist → types}/helpers/logger.d.ts +0 -0
  261. /package/{dist → types}/helpers/nullable.d.ts +0 -0
  262. /package/{dist → types}/helpers/preview-lru-cache/get.d.ts +0 -0
  263. /package/{dist → types}/helpers/preview-lru-cache/helpers.d.ts +0 -0
  264. /package/{dist → types}/helpers/preview-lru-cache/init.d.ts +0 -0
  265. /package/{dist → types}/helpers/preview-lru-cache/set.d.ts +0 -0
  266. /package/{dist → types}/helpers/preview-lru-cache/types.d.ts +0 -0
  267. /package/{dist → types}/helpers/sessionId.d.ts +0 -0
  268. /package/{dist → types}/helpers/url.d.ts +0 -0
  269. /package/{dist → types}/helpers/uuid.d.ts +0 -0
  270. /package/{dist → types}/helpers/visitorId.d.ts +0 -0
  271. /package/{dist → types}/index-helpers/top-of-file.d.ts +0 -0
  272. /package/{dist → types}/index.d.ts +0 -0
  273. /package/{dist → types}/scripts/init-editing.d.ts +0 -0
  274. /package/{dist → types}/server-index.d.ts +0 -0
  275. /package/{dist → types}/types/api-version.d.ts +0 -0
  276. /package/{dist → types}/types/builder-block.d.ts +0 -0
  277. /package/{dist → types}/types/builder-content.d.ts +0 -0
  278. /package/{dist → types}/types/builder-props.d.ts +0 -0
  279. /package/{dist → types}/types/can-track.d.ts +0 -0
  280. /package/{dist → types}/types/components.d.ts +0 -0
  281. /package/{dist → types}/types/deep-partial.d.ts +0 -0
  282. /package/{dist → types}/types/element.d.ts +0 -0
  283. /package/{dist → types}/types/enforced-partials.d.ts +0 -0
  284. /package/{dist → types}/types/input.d.ts +0 -0
  285. /package/{dist → types}/types/targets.d.ts +0 -0
  286. /package/{dist → types}/types/typescript.d.ts +0 -0
@@ -1,51 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- import { useState, useRef, useEffect } from "react";
4
- function CustomCode(props) {
5
- const elem = useRef(null);
6
- const [scriptsInserted, setScriptsInserted] = useState(() => []);
7
- const [scriptsRun, setScriptsRun] = useState(() => []);
8
- function findAndRunScripts() {
9
- // TODO: Move this function to standalone one in '@builder.io/utils'
10
- if (elem.current &&
11
- elem.current.getElementsByTagName &&
12
- typeof window !== "undefined") {
13
- const scripts = elem.current.getElementsByTagName("script");
14
- for (let i = 0; i < scripts.length; i++) {
15
- const script = scripts[i];
16
- if (script.src) {
17
- if (scriptsInserted.includes(script.src)) {
18
- continue;
19
- }
20
- scriptsInserted.push(script.src);
21
- const newScript = document.createElement("script");
22
- newScript.async = true;
23
- newScript.src = script.src;
24
- document.head.appendChild(newScript);
25
- }
26
- else if (!script.type ||
27
- [
28
- "text/javascript",
29
- "application/javascript",
30
- "application/ecmascript",
31
- ].includes(script.type)) {
32
- if (scriptsRun.includes(script.innerText)) {
33
- continue;
34
- }
35
- try {
36
- scriptsRun.push(script.innerText);
37
- new Function(script.innerText)();
38
- }
39
- catch (error) {
40
- console.warn("`CustomCode`: Error running script:", error);
41
- }
42
- }
43
- }
44
- }
45
- }
46
- useEffect(() => {
47
- findAndRunScripts();
48
- }, []);
49
- return (React.createElement("div", { ref: elem, className: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), dangerouslySetInnerHTML: { __html: props.code } }));
50
- }
51
- export default CustomCode;
@@ -1,39 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Embed',
3
- static: true,
4
- inputs: [{
5
- name: 'url',
6
- type: 'url',
7
- required: true,
8
- defaultValue: '',
9
- helperText: 'e.g. enter a youtube url, google map, etc',
10
- onChange: (options) => {
11
- const url = options.get('url');
12
- if (url) {
13
- options.set('content', 'Loading...');
14
- // TODO: get this out of here!
15
- const apiKey = 'ae0e60e78201a3f2b0de4b';
16
- return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then(res => res.json()).then(data => {
17
- if (options.get('url') === url) {
18
- if (data.html) {
19
- options.set('content', data.html);
20
- }
21
- else {
22
- options.set('content', 'Invalid url, please try another');
23
- }
24
- }
25
- }).catch(_err => {
26
- options.set('content', 'There was an error embedding this URL, please try again or another URL');
27
- });
28
- }
29
- else {
30
- options.delete('content');
31
- }
32
- }
33
- }, {
34
- name: 'content',
35
- type: 'html',
36
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
37
- hideFromUI: true
38
- }]
39
- };
@@ -1,42 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- import { useState, useRef, useEffect } from "react";
4
- import { isJsScript } from "./helpers.js";
5
- function Embed(props) {
6
- const elem = useRef(null);
7
- const [scriptsInserted, setScriptsInserted] = useState(() => []);
8
- const [scriptsRun, setScriptsRun] = useState(() => []);
9
- const [ranInitFn, setRanInitFn] = useState(() => false);
10
- function findAndRunScripts() {
11
- if (!elem.current || !elem.current.getElementsByTagName)
12
- return;
13
- const scripts = elem.current.getElementsByTagName("script");
14
- for (let i = 0; i < scripts.length; i++) {
15
- const script = scripts[i];
16
- if (script.src && !scriptsInserted.includes(script.src)) {
17
- scriptsInserted.push(script.src);
18
- const newScript = document.createElement("script");
19
- newScript.async = true;
20
- newScript.src = script.src;
21
- document.head.appendChild(newScript);
22
- }
23
- else if (isJsScript(script) && !scriptsRun.includes(script.innerText)) {
24
- try {
25
- scriptsRun.push(script.innerText);
26
- new Function(script.innerText)();
27
- }
28
- catch (error) {
29
- console.warn("`Embed`: Error running script:", error);
30
- }
31
- }
32
- }
33
- }
34
- useEffect(() => {
35
- if (elem.current && !ranInitFn) {
36
- setRanInitFn(true);
37
- findAndRunScripts();
38
- }
39
- }, [elem.current, ranInitFn]);
40
- return (React.createElement("div", { className: "builder-embed", ref: elem, dangerouslySetInnerHTML: { __html: props.content } }));
41
- }
42
- export default Embed;
@@ -1,2 +0,0 @@
1
- const SCRIPT_MIME_TYPES = ['text/javascript', 'application/javascript', 'application/ecmascript'];
2
- export const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
@@ -1,7 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Fragment',
3
- static: true,
4
- hidden: true,
5
- canHaveChildren: true,
6
- noWrap: true
7
- };
@@ -1,6 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- function FragmentComponent(props) {
4
- return React.createElement("span", null, props.children);
5
- }
6
- export default FragmentComponent;
@@ -1,40 +0,0 @@
1
- export function filterAttrs(attrs = {}, prefix, isEvent) {
2
- const result = {};
3
- for (const attr in attrs) {
4
- if (!attrs[attr])
5
- continue;
6
- if (isEvent && !attr.startsWith(prefix))
7
- continue;
8
- const eventName = isEvent ? attr.replace(prefix, '') : attr;
9
- result[eventName] = attrs[attr];
10
- }
11
- return result;
12
- }
13
- /**
14
- * Svelte SDK: workaround to dynamically provide event handlers to components/elements.
15
- * https://svelte.dev/repl/1246699e266f41218a8eeb45b9b58b54?version=3.24.1
16
- */
17
- export function setAttrs(node, attrs = {}) {
18
- const attrKeys = Object.keys(attrs);
19
- /**
20
- *
21
- * @param {string} attr
22
- */
23
- const setup = (attr) => node.addEventListener(attr, attrs[attr]);
24
- /**
25
- *
26
- * @param {string} attr
27
- */
28
- const teardown = (attr) => node.removeEventListener(attr, attrs[attr]);
29
- attrKeys.forEach(setup);
30
- return {
31
- update(attrs = {}) {
32
- const attrKeys = Object.keys(attrs);
33
- attrKeys.forEach(teardown);
34
- attrKeys.forEach(setup);
35
- },
36
- destroy() {
37
- attrKeys.forEach(teardown);
38
- }
39
- };
40
- }
@@ -1,122 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Image',
3
- static: true,
4
- image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
5
- defaultStyles: {
6
- position: 'relative',
7
- minHeight: '20px',
8
- minWidth: '20px',
9
- overflow: 'hidden'
10
- },
11
- canHaveChildren: true,
12
- inputs: [{
13
- name: 'image',
14
- type: 'file',
15
- bubble: true,
16
- allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
17
- required: true,
18
- defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
19
- onChange: (options) => {
20
- const DEFAULT_ASPECT_RATIO = 0.7041;
21
- options.delete('srcset');
22
- options.delete('noWebp');
23
- function loadImage(url, timeout = 60000) {
24
- return new Promise((resolve, reject) => {
25
- const img = document.createElement('img');
26
- let loaded = false;
27
- img.onload = () => {
28
- loaded = true;
29
- resolve(img);
30
- };
31
- img.addEventListener('error', event => {
32
- console.warn('Image load failed', event.error);
33
- reject(event.error);
34
- });
35
- img.src = url;
36
- setTimeout(() => {
37
- if (!loaded) {
38
- reject(new Error('Image load timed out'));
39
- }
40
- }, timeout);
41
- });
42
- }
43
- function round(num) {
44
- return Math.round(num * 1000) / 1000;
45
- }
46
- const value = options.get('image');
47
- const aspectRatio = options.get('aspectRatio');
48
- // For SVG images - don't render as webp, keep them as SVG
49
- fetch(value).then(res => res.blob()).then(blob => {
50
- if (blob.type.includes('svg')) {
51
- options.set('noWebp', true);
52
- }
53
- });
54
- if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
55
- return loadImage(value).then(img => {
56
- const possiblyUpdatedAspectRatio = options.get('aspectRatio');
57
- if (options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
58
- if (img.width && img.height) {
59
- options.set('aspectRatio', round(img.height / img.width));
60
- options.set('height', img.height);
61
- options.set('width', img.width);
62
- }
63
- }
64
- });
65
- }
66
- }
67
- }, {
68
- name: 'backgroundSize',
69
- type: 'text',
70
- defaultValue: 'cover',
71
- enum: [{
72
- label: 'contain',
73
- value: 'contain',
74
- helperText: 'The image should never get cropped'
75
- }, {
76
- label: 'cover',
77
- value: 'cover',
78
- helperText: "The image should fill it's box, cropping when needed"
79
- }]
80
- }, {
81
- name: 'backgroundPosition',
82
- type: 'text',
83
- defaultValue: 'center',
84
- enum: ['center', 'top', 'left', 'right', 'bottom', 'top left', 'top right', 'bottom left', 'bottom right']
85
- }, {
86
- name: 'altText',
87
- type: 'string',
88
- helperText: 'Text to display when the user has images off'
89
- }, {
90
- name: 'height',
91
- type: 'number',
92
- hideFromUI: true
93
- }, {
94
- name: 'width',
95
- type: 'number',
96
- hideFromUI: true
97
- }, {
98
- name: 'sizes',
99
- type: 'string',
100
- hideFromUI: true
101
- }, {
102
- name: 'srcset',
103
- type: 'string',
104
- hideFromUI: true
105
- }, {
106
- name: 'lazy',
107
- type: 'boolean',
108
- defaultValue: true,
109
- hideFromUI: true
110
- }, {
111
- name: 'fitContent',
112
- type: 'boolean',
113
- helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
114
- defaultValue: true
115
- }, {
116
- name: 'aspectRatio',
117
- type: 'number',
118
- helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
119
- advanced: true,
120
- defaultValue: 0.7041
121
- }]
122
- };
@@ -1,47 +0,0 @@
1
- // Taken from (and modified) the shopify theme script repo
2
- // https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
3
- function removeProtocol(path) {
4
- return path.replace(/http(s)?:/, '');
5
- }
6
- function updateQueryParam(uri = '', key, value) {
7
- const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
8
- const separator = uri.indexOf('?') !== -1 ? '&' : '?';
9
- if (uri.match(re)) {
10
- return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
11
- }
12
- return uri + separator + key + '=' + encodeURIComponent(value);
13
- }
14
- function getShopifyImageUrl(src, size) {
15
- if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
16
- return src;
17
- }
18
- if (size === 'master') {
19
- return removeProtocol(src);
20
- }
21
- const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
22
- if (match) {
23
- const prefix = src.split(match[0]);
24
- const suffix = match[3];
25
- const useSize = size.match('x') ? size : `${size}x`;
26
- return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
27
- }
28
- return null;
29
- }
30
- export function getSrcSet(url) {
31
- if (!url) {
32
- return url;
33
- }
34
- const sizes = [100, 200, 400, 800, 1200, 1600, 2000];
35
- if (url.match(/builder\.io/)) {
36
- let srcUrl = url;
37
- const widthInSrc = Number(url.split('?width=')[1]);
38
- if (!isNaN(widthInSrc)) {
39
- srcUrl = `${srcUrl} ${widthInSrc}w`;
40
- }
41
- return sizes.filter(size => size !== widthInSrc).map(size => `${updateQueryParam(url, 'width', size)} ${size}w`).concat([srcUrl]).join(', ');
42
- }
43
- if (url.match(/cdn\.shopify\.com/)) {
44
- return sizes.map(size => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(', ');
45
- }
46
- return url;
47
- }
@@ -1,82 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- import { getSrcSet } from "./image.helpers.js";
4
- function Image(props) {
5
- function srcSetToUse() {
6
- const imageToUse = props.image || props.src;
7
- const url = imageToUse;
8
- if (!url ||
9
- // We can auto add srcset for cdn.builder.io and shopify
10
- // images, otherwise you can supply this prop manually
11
- !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) {
12
- return props.srcset;
13
- }
14
- if (props.srcset && props.image?.includes("builder.io/api/v1/image")) {
15
- if (!props.srcset.includes(props.image.split("?")[0])) {
16
- console.debug("Removed given srcset");
17
- return getSrcSet(url);
18
- }
19
- }
20
- else if (props.image && !props.srcset) {
21
- return getSrcSet(url);
22
- }
23
- return getSrcSet(url);
24
- }
25
- function webpSrcSet() {
26
- if (srcSetToUse?.()?.match(/builder\.io/) && !props.noWebp) {
27
- return srcSetToUse().replace(/\?/g, "?format=webp&");
28
- }
29
- else {
30
- return "";
31
- }
32
- }
33
- function aspectRatioCss() {
34
- const aspectRatioStyles = {
35
- position: "absolute",
36
- height: "100%",
37
- width: "100%",
38
- left: "0px",
39
- top: "0px",
40
- };
41
- const out = props.aspectRatio ? aspectRatioStyles : undefined;
42
- return out;
43
- }
44
- return (React.createElement(React.Fragment, null,
45
- React.createElement(React.Fragment, null,
46
- React.createElement("picture", null,
47
- webpSrcSet() ? (React.createElement(React.Fragment, null,
48
- React.createElement("source", { type: "image/webp", srcSet: webpSrcSet() }))) : null,
49
- React.createElement("img", { loading: "lazy", alt: props.altText, role: props.altText ? "presentation" : undefined, style: {
50
- objectPosition: props.backgroundPosition || "center",
51
- objectFit: props.backgroundSize || "cover",
52
- ...aspectRatioCss(),
53
- }, className: "builder-image" +
54
- (props.className ? " " + props.className : "") +
55
- " img-ef11a6be", src: props.image, srcSet: srcSetToUse(), sizes: props.sizes })),
56
- props.aspectRatio &&
57
- !(props.builderBlock?.children?.length && props.fitContent) ? (React.createElement(React.Fragment, null,
58
- React.createElement("div", { className: "builder-image-sizer div-ef11a6be", style: {
59
- paddingTop: props.aspectRatio * 100 + "%",
60
- } }))) : null,
61
- props.builderBlock?.children?.length && props.fitContent ? (React.createElement(React.Fragment, null, props.children)) : null,
62
- !props.fitContent && props.children ? (React.createElement(React.Fragment, null,
63
- React.createElement("div", { className: "div-ef11a6be-2" }, props.children))) : null),
64
- React.createElement("style", null, `.img-ef11a6be {
65
- opacity: 1;
66
- transition: opacity 0.2s ease-in-out;
67
- }.div-ef11a6be {
68
- width: 100%;
69
- pointer-events: none;
70
- font-size: 0;
71
- }.div-ef11a6be-2 {
72
- display: flex;
73
- flex-direction: column;
74
- align-items: stretch;
75
- position: absolute;
76
- top: 0;
77
- left: 0;
78
- width: 100%;
79
- height: 100%;
80
- }`)));
81
- }
82
- export default Image;
@@ -1,15 +0,0 @@
1
- export const componentInfo = {
2
- // friendlyName?
3
- name: 'Raw:Img',
4
- hideFromInsertMenu: true,
5
- image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
6
- inputs: [{
7
- name: 'image',
8
- bubble: true,
9
- type: 'file',
10
- allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'gif', 'webp'],
11
- required: true
12
- }],
13
- noWrap: true,
14
- static: true
15
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- import { isEditing } from "../../functions/is-editing.js";
4
- function ImgComponent(props) {
5
- return (React.createElement("img", { style: {
6
- objectFit: props.backgroundSize || "cover",
7
- objectPosition: props.backgroundPosition || "center",
8
- }, key: (isEditing() && props.imgSrc) || "default-key", alt: props.altText, src: props.imgSrc || props.image, ...props.attributes }));
9
- }
10
- export default ImgComponent;
@@ -1,40 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Core:Section',
3
- static: true,
4
- image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
5
- inputs: [{
6
- name: 'maxWidth',
7
- type: 'number',
8
- defaultValue: 1200
9
- }, {
10
- name: 'lazyLoad',
11
- type: 'boolean',
12
- defaultValue: false,
13
- advanced: true,
14
- description: 'Only render this section when in view'
15
- }],
16
- defaultStyles: {
17
- paddingLeft: '20px',
18
- paddingRight: '20px',
19
- paddingTop: '50px',
20
- paddingBottom: '50px',
21
- marginTop: '0px',
22
- width: '100vw',
23
- marginLeft: 'calc(50% - 50vw)'
24
- },
25
- canHaveChildren: true,
26
- defaultChildren: [{
27
- '@type': '@builder.io/sdk:Element',
28
- responsiveStyles: {
29
- large: {
30
- textAlign: 'center'
31
- }
32
- },
33
- component: {
34
- name: 'Text',
35
- options: {
36
- text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
37
- }
38
- }
39
- }]
40
- };
@@ -1,17 +0,0 @@
1
- "use client";
2
- import * as React from "react";
3
- function SectionComponent(props) {
4
- return (React.createElement("section", { ...props.attributes, style: {
5
- width: "100%",
6
- alignSelf: "stretch",
7
- flexGrow: 1,
8
- boxSizing: "border-box",
9
- maxWidth: props.maxWidth || 1200,
10
- display: "flex",
11
- flexDirection: "column",
12
- alignItems: "stretch",
13
- marginLeft: "auto",
14
- marginRight: "auto",
15
- } }, props.children));
16
- }
17
- export default SectionComponent;
@@ -1,34 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Symbol',
3
- noWrap: true,
4
- static: true,
5
- isRSC: true,
6
- inputs: [{
7
- name: 'symbol',
8
- type: 'uiSymbol'
9
- }, {
10
- name: 'dataOnly',
11
- helperText: "Make this a data symbol that doesn't display any UI",
12
- type: 'boolean',
13
- defaultValue: false,
14
- advanced: true,
15
- hideFromUI: true
16
- }, {
17
- name: 'inheritState',
18
- helperText: 'Inherit the parent component state and data',
19
- type: 'boolean',
20
- defaultValue: false,
21
- advanced: true
22
- }, {
23
- name: 'renderToLiquid',
24
- helperText: 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
25
- type: 'boolean',
26
- defaultValue: false,
27
- advanced: true,
28
- hideFromUI: true
29
- }, {
30
- name: 'useChildren',
31
- hideFromUI: true,
32
- type: 'boolean'
33
- }]
34
- };
@@ -1,31 +0,0 @@
1
- import { logger } from '../../helpers/logger.js';
2
- import { fetchOneEntry } from '../../index.js';
3
- export const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
4
- /**
5
- * If:
6
- * - we have a symbol prop
7
- * - yet it does not have any content
8
- * - and we have not already stored content from before
9
- * - and it has a model name
10
- *
11
- * then we want to re-fetch the symbol content.
12
- */
13
- if (symbol?.model &&
14
- // This is a hack, we should not need to check for this, but it is needed for Svelte.
15
- builderContextValue?.apiKey) {
16
- return fetchOneEntry({
17
- model: symbol.model,
18
- apiKey: builderContextValue.apiKey,
19
- apiVersion: builderContextValue.apiVersion,
20
- ...(symbol?.entry && {
21
- query: {
22
- id: symbol.entry
23
- }
24
- })
25
- }).catch(err => {
26
- logger.error('Could not fetch symbol content: ', err);
27
- return undefined;
28
- });
29
- }
30
- return undefined;
31
- };
@@ -1,29 +0,0 @@
1
- import * as React from "react";
2
- import ContentVariants from "../../components/content-variants/content-variants";
3
- import { fetchSymbolContent } from "./symbol.helpers.js";
4
- async function Symbol(props) {
5
- const className = function className() {
6
- return [
7
- ...[props.attributes.className],
8
- "builder-symbol",
9
- props.symbol?.inline ? "builder-inline-symbol" : undefined,
10
- props.symbol?.dynamic || props.dynamic
11
- ? "builder-dynamic-symbol"
12
- : undefined,
13
- ]
14
- .filter(Boolean)
15
- .join(" ");
16
- };
17
- const contentToUse = (props.symbol?.content ||
18
- (await fetchSymbolContent({
19
- symbol: props.symbol,
20
- builderContextValue: props.builderContext,
21
- })));
22
- return (React.createElement("div", { ...props.attributes, className: className() },
23
- React.createElement(ContentVariants, { __isNestedRender: true, apiVersion: props.builderContext.apiVersion, apiKey: props.builderContext.apiKey, context: props.builderContext.context, customComponents: Object.values(props.builderComponents), data: {
24
- ...props.symbol?.data,
25
- ...props.builderContext.localState,
26
- ...contentToUse?.data?.state,
27
- }, model: props.symbol?.model, content: contentToUse })));
28
- }
29
- export default Symbol;
@@ -1,19 +0,0 @@
1
- export const componentInfo = {
2
- name: 'Text',
3
- static: true,
4
- isRSC: true,
5
- image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929',
6
- inputs: [{
7
- name: 'text',
8
- type: 'html',
9
- required: true,
10
- autoFocus: true,
11
- bubble: true,
12
- defaultValue: 'Enter some text...'
13
- }],
14
- defaultStyles: {
15
- lineHeight: 'normal',
16
- height: 'auto',
17
- textAlign: 'center'
18
- }
19
- };
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- function Text(props) {
3
- return (React.createElement("span", { className: "builder-text", dangerouslySetInnerHTML: { __html: props.text?.toString() || "" }, style: {
4
- outline: "none",
5
- } }));
6
- }
7
- export default Text;