@builder.io/sdk-react-native 1.0.32 → 1.0.34

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 (277) hide show
  1. package/lib/browser/commonjs/blocks/text/text.js +1 -1
  2. package/lib/browser/commonjs/constants/sdk-version.js +1 -1
  3. package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  4. package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  5. package/lib/browser/commonjs/functions/is-from-trusted-host.js +3 -0
  6. package/lib/browser/commonjs/functions/is-from-trusted-host.js.map +1 -1
  7. package/lib/browser/commonjs/helpers/cookie.js +12 -2
  8. package/lib/browser/commonjs/helpers/cookie.js.map +1 -1
  9. package/lib/browser/module/blocks/text/text.js +1 -1
  10. package/lib/browser/module/blocks/text/text.js.map +1 -1
  11. package/lib/browser/module/constants/sdk-version.js +1 -1
  12. package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  13. package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  14. package/lib/browser/module/functions/is-from-trusted-host.js +3 -0
  15. package/lib/browser/module/functions/is-from-trusted-host.js.map +1 -1
  16. package/lib/browser/module/helpers/cookie.js +11 -2
  17. package/lib/browser/module/helpers/cookie.js.map +1 -1
  18. package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
  19. package/lib/browser/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  20. package/lib/browser/typescript/helpers/cookie.d.ts +1 -0
  21. package/lib/browser/typescript/helpers/cookie.d.ts.map +1 -1
  22. package/lib/edge/commonjs/blocks/text/text.js +1 -1
  23. package/lib/edge/commonjs/constants/sdk-version.js +1 -1
  24. package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  25. package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  26. package/lib/edge/commonjs/functions/is-from-trusted-host.js +3 -0
  27. package/lib/edge/commonjs/functions/is-from-trusted-host.js.map +1 -1
  28. package/lib/edge/commonjs/helpers/cookie.js +12 -2
  29. package/lib/edge/commonjs/helpers/cookie.js.map +1 -1
  30. package/lib/edge/module/blocks/text/text.js +1 -1
  31. package/lib/edge/module/blocks/text/text.js.map +1 -1
  32. package/lib/edge/module/constants/sdk-version.js +1 -1
  33. package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  34. package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  35. package/lib/edge/module/functions/is-from-trusted-host.js +3 -0
  36. package/lib/edge/module/functions/is-from-trusted-host.js.map +1 -1
  37. package/lib/edge/module/helpers/cookie.js +11 -2
  38. package/lib/edge/module/helpers/cookie.js.map +1 -1
  39. package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
  40. package/lib/edge/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  41. package/lib/edge/typescript/helpers/cookie.d.ts +1 -0
  42. package/lib/edge/typescript/helpers/cookie.d.ts.map +1 -1
  43. package/lib/node/commonjs/blocks/text/text.js +1 -1
  44. package/lib/node/commonjs/constants/sdk-version.js +1 -1
  45. package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  46. package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  47. package/lib/node/commonjs/functions/is-from-trusted-host.js +3 -0
  48. package/lib/node/commonjs/functions/is-from-trusted-host.js.map +1 -1
  49. package/lib/node/commonjs/helpers/cookie.js +12 -2
  50. package/lib/node/commonjs/helpers/cookie.js.map +1 -1
  51. package/lib/node/module/blocks/text/text.js +1 -1
  52. package/lib/node/module/blocks/text/text.js.map +1 -1
  53. package/lib/node/module/constants/sdk-version.js +1 -1
  54. package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  55. package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  56. package/lib/node/module/functions/is-from-trusted-host.js +3 -0
  57. package/lib/node/module/functions/is-from-trusted-host.js.map +1 -1
  58. package/lib/node/module/helpers/cookie.js +11 -2
  59. package/lib/node/module/helpers/cookie.js.map +1 -1
  60. package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
  61. package/lib/node/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  62. package/lib/node/typescript/helpers/cookie.d.ts +1 -0
  63. package/lib/node/typescript/helpers/cookie.d.ts.map +1 -1
  64. package/package.json +10 -7
  65. package/src/blocks/BaseText.tsx +17 -0
  66. package/src/blocks/accordion/accordion.tsx +181 -0
  67. package/src/blocks/accordion/accordion.types.ts +12 -0
  68. package/src/blocks/accordion/component-info.ts +124 -0
  69. package/src/blocks/accordion/helpers.ts +3 -0
  70. package/src/blocks/accordion/index.ts +1 -0
  71. package/src/blocks/button/button.tsx +56 -0
  72. package/src/blocks/button/button.types.ts +7 -0
  73. package/src/blocks/button/component-info.ts +35 -0
  74. package/src/blocks/button/index.ts +1 -0
  75. package/src/blocks/columns/columns.tsx +199 -0
  76. package/src/blocks/columns/columns.types.ts +14 -0
  77. package/src/blocks/columns/component-info.ts +219 -0
  78. package/src/blocks/columns/helpers.ts +3 -0
  79. package/src/blocks/columns/index.ts +1 -0
  80. package/src/blocks/custom-code/component-info.ts +24 -0
  81. package/src/blocks/custom-code/custom-code.tsx +71 -0
  82. package/src/blocks/custom-code/index.ts +1 -0
  83. package/src/blocks/embed/component-info.ts +38 -0
  84. package/src/blocks/embed/embed.tsx +62 -0
  85. package/src/blocks/embed/helpers.ts +2 -0
  86. package/src/blocks/embed/index.ts +1 -0
  87. package/src/blocks/form/form/component-info.ts +233 -0
  88. package/src/blocks/form/form/form.tsx +324 -0
  89. package/src/blocks/form/form/index.ts +1 -0
  90. package/src/blocks/form/input/component-info.ts +47 -0
  91. package/src/blocks/form/input/index.ts +1 -0
  92. package/src/blocks/form/input/input.tsx +49 -0
  93. package/src/blocks/form/select/component-info.ts +44 -0
  94. package/src/blocks/form/select/index.ts +1 -0
  95. package/src/blocks/form/select/select.tsx +54 -0
  96. package/src/blocks/form/submit-button/component-info.ts +27 -0
  97. package/src/blocks/form/submit-button/index.ts +1 -0
  98. package/src/blocks/form/submit-button/submit-button.tsx +34 -0
  99. package/src/blocks/fragment/component-info.ts +8 -0
  100. package/src/blocks/fragment/fragment.tsx +18 -0
  101. package/src/blocks/fragment/fragment.types.ts +5 -0
  102. package/src/blocks/fragment/index.ts +1 -0
  103. package/src/blocks/helpers.ts +43 -0
  104. package/src/blocks/image/component-info.ts +129 -0
  105. package/src/blocks/image/image.helpers.ts +47 -0
  106. package/src/blocks/image/image.tsx +65 -0
  107. package/src/blocks/image/image.types.ts +20 -0
  108. package/src/blocks/image/index.ts +1 -0
  109. package/src/blocks/img/component-info.ts +16 -0
  110. package/src/blocks/img/img.tsx +55 -0
  111. package/src/blocks/img/index.ts +1 -0
  112. package/src/blocks/raw-text/component-info.ts +11 -0
  113. package/src/blocks/raw-text/index.ts +1 -0
  114. package/src/blocks/raw-text/raw-text.tsx +1 -0
  115. package/src/blocks/section/component-info.ts +41 -0
  116. package/src/blocks/section/index.ts +1 -0
  117. package/src/blocks/section/section.tsx +39 -0
  118. package/src/blocks/section/section.types.ts +6 -0
  119. package/src/blocks/slot/component-info.ts +15 -0
  120. package/src/blocks/slot/index.ts +1 -0
  121. package/src/blocks/slot/slot.tsx +42 -0
  122. package/src/blocks/symbol/component-info.ts +35 -0
  123. package/src/blocks/symbol/index.ts +1 -0
  124. package/src/blocks/symbol/symbol.helpers.ts +47 -0
  125. package/src/blocks/symbol/symbol.tsx +100 -0
  126. package/src/blocks/symbol/symbol.types.ts +17 -0
  127. package/src/blocks/tabs/component-info.ts +139 -0
  128. package/src/blocks/tabs/index.ts +1 -0
  129. package/src/blocks/tabs/tabs.tsx +79 -0
  130. package/src/blocks/tabs/tabs.types.ts +13 -0
  131. package/src/blocks/text/component-info.ts +20 -0
  132. package/src/blocks/text/index.ts +1 -0
  133. package/src/blocks/text/text.tsx +105 -0
  134. package/src/blocks/text/text.types.ts +4 -0
  135. package/src/blocks/textarea/component-info.ts +38 -0
  136. package/src/blocks/textarea/index.ts +1 -0
  137. package/src/blocks/textarea/textarea.tsx +41 -0
  138. package/src/blocks/video/component-info.ts +83 -0
  139. package/src/blocks/video/index.ts +1 -0
  140. package/src/blocks/video/video.tsx +70 -0
  141. package/src/blocks/video/video.types.ts +21 -0
  142. package/src/components/block/animator.ts +220 -0
  143. package/src/components/block/block.helpers.ts +124 -0
  144. package/src/components/block/block.tsx +232 -0
  145. package/src/components/block/components/block-styles.tsx +136 -0
  146. package/src/components/block/components/block-wrapper.tsx +52 -0
  147. package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
  148. package/src/components/block/components/component-ref/component-ref.tsx +66 -0
  149. package/src/components/block/components/interactive-element.tsx +53 -0
  150. package/src/components/block/components/repeated-block.tsx +37 -0
  151. package/src/components/block/types.ts +6 -0
  152. package/src/components/blocks/blocks-wrapper.tsx +93 -0
  153. package/src/components/blocks/blocks.tsx +57 -0
  154. package/src/components/blocks/blocks.types.ts +7 -0
  155. package/src/components/blocks/index.ts +1 -0
  156. package/src/components/content/components/enable-editor.tsx +472 -0
  157. package/src/components/content/components/styles.helpers.ts +101 -0
  158. package/src/components/content/components/styles.tsx +42 -0
  159. package/src/components/content/content.helpers.ts +40 -0
  160. package/src/components/content/content.tsx +150 -0
  161. package/src/components/content/content.types.ts +13 -0
  162. package/src/components/content/contentProps.types.ts +17 -0
  163. package/src/components/content/index.ts +1 -0
  164. package/src/components/content/wrap-component-ref.ts +6 -0
  165. package/src/components/content-variants/content-variants.tsx +146 -0
  166. package/src/components/content-variants/content-variants.types.ts +84 -0
  167. package/src/components/content-variants/helpers.ts +72 -0
  168. package/src/components/content-variants/index.ts +1 -0
  169. package/src/components/content-variants/inlined-fns.ts +22 -0
  170. package/src/components/dynamic-div.tsx +30 -0
  171. package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
  172. package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
  173. package/src/components/error-boundary.tsx +38 -0
  174. package/src/components/inlined-script.tsx +10 -0
  175. package/src/components/inlined-styles.tsx +10 -0
  176. package/src/constants/builder-registered-components.ts +59 -0
  177. package/src/constants/device-sizes.ts +59 -0
  178. package/src/constants/extra-components.ts +1 -0
  179. package/src/constants/sdk-version.ts +1 -0
  180. package/src/constants/target.ts +3 -0
  181. package/src/context/builder.context.ts +15 -0
  182. package/src/context/components.context.ts +3 -0
  183. package/src/context/index.ts +1 -0
  184. package/src/context/types.ts +38 -0
  185. package/src/functions/apply-patch-with-mutation.ts +61 -0
  186. package/src/functions/camel-to-kebab-case.ts +1 -0
  187. package/src/functions/deopt.ts +6 -0
  188. package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
  189. package/src/functions/evaluate/browser-runtime/index.ts +1 -0
  190. package/src/functions/evaluate/choose-eval.ts +23 -0
  191. package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
  192. package/src/functions/evaluate/edge-runtime/edge-runtime.ts +89 -0
  193. package/src/functions/evaluate/edge-runtime/index.ts +1 -0
  194. package/src/functions/evaluate/evaluate.ts +76 -0
  195. package/src/functions/evaluate/helpers.ts +56 -0
  196. package/src/functions/evaluate/index.ts +1 -0
  197. package/src/functions/evaluate/node-runtime/index.ts +1 -0
  198. package/src/functions/evaluate/node-runtime/init.ts +33 -0
  199. package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
  200. package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +14 -0
  201. package/src/functions/evaluate/placeholder-runtime.ts +4 -0
  202. package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
  203. package/src/functions/event-handler-name.ts +4 -0
  204. package/src/functions/extract-text-styles.ts +24 -0
  205. package/src/functions/fast-clone.ts +4 -0
  206. package/src/functions/fetch-builder-props.ts +75 -0
  207. package/src/functions/get-block-actions-handler.ts +17 -0
  208. package/src/functions/get-block-actions.ts +35 -0
  209. package/src/functions/get-block-component-options.ts +7 -0
  210. package/src/functions/get-block-properties.ts +62 -0
  211. package/src/functions/get-builder-search-params/index.ts +33 -0
  212. package/src/functions/get-class-prop-name.ts +15 -0
  213. package/src/functions/get-content/generate-content-url.ts +88 -0
  214. package/src/functions/get-content/index.ts +99 -0
  215. package/src/functions/get-content/types.ts +157 -0
  216. package/src/functions/get-env.ts +5 -0
  217. package/src/functions/get-fetch.ts +11 -0
  218. package/src/functions/get-global-this.ts +16 -0
  219. package/src/functions/get-processed-block.ts +70 -0
  220. package/src/functions/get-style.ts +38 -0
  221. package/src/functions/get.ts +4 -0
  222. package/src/functions/is-browser.ts +3 -0
  223. package/src/functions/is-edge-runtime.ts +9 -0
  224. package/src/functions/is-editing.ts +8 -0
  225. package/src/functions/is-from-trusted-host.ts +11 -0
  226. package/src/functions/is-iframe.ts +4 -0
  227. package/src/functions/is-node-runtime.ts +8 -0
  228. package/src/functions/is-previewing.ts +16 -0
  229. package/src/functions/on-change.ts +29 -0
  230. package/src/functions/register-component.ts +30 -0
  231. package/src/functions/register.ts +44 -0
  232. package/src/functions/set-editor-settings.ts +15 -0
  233. package/src/functions/set.ts +14 -0
  234. package/src/functions/track/helpers.ts +51 -0
  235. package/src/functions/track/index.ts +131 -0
  236. package/src/functions/track/interaction.ts +63 -0
  237. package/src/functions/transform-block-properties.ts +33 -0
  238. package/src/functions/transform-block.ts +30 -0
  239. package/src/functions/transform-style-property.ts +296 -0
  240. package/src/helpers/ab-tests.ts +166 -0
  241. package/src/helpers/canTrack.ts +2 -0
  242. package/src/helpers/cookie.ts +109 -0
  243. package/src/helpers/css.ts +33 -0
  244. package/src/helpers/flatten.ts +41 -0
  245. package/src/helpers/localStorage.ts +36 -0
  246. package/src/helpers/logger.ts +7 -0
  247. package/src/helpers/nullable.ts +2 -0
  248. package/src/helpers/omit.ts +7 -0
  249. package/src/helpers/preview-lru-cache/get.ts +4 -0
  250. package/src/helpers/preview-lru-cache/helpers.ts +1 -0
  251. package/src/helpers/preview-lru-cache/init.ts +7 -0
  252. package/src/helpers/preview-lru-cache/set.ts +12 -0
  253. package/src/helpers/preview-lru-cache/types.ts +1 -0
  254. package/src/helpers/search/search.ts +18 -0
  255. package/src/helpers/sessionId.ts +37 -0
  256. package/src/helpers/subscribe-to-editor.ts +95 -0
  257. package/src/helpers/time.ts +2 -0
  258. package/src/helpers/url.ts +15 -0
  259. package/src/helpers/uuid.ts +17 -0
  260. package/src/helpers/visitorId.ts +37 -0
  261. package/src/index-helpers/blocks-exports.ts +16 -0
  262. package/src/index-helpers/top-of-file.ts +2 -0
  263. package/src/index.ts +15 -0
  264. package/src/scripts/init-editing.ts +119 -0
  265. package/src/server-index.ts +43 -0
  266. package/src/types/api-version.ts +2 -0
  267. package/src/types/builder-block.ts +89 -0
  268. package/src/types/builder-content.ts +47 -0
  269. package/src/types/builder-props.ts +12 -0
  270. package/src/types/can-track.ts +3 -0
  271. package/src/types/components.ts +119 -0
  272. package/src/types/deep-partial.ts +1 -0
  273. package/src/types/element.ts +57 -0
  274. package/src/types/enforced-partials.ts +19 -0
  275. package/src/types/input.ts +123 -0
  276. package/src/types/targets.ts +1 -0
  277. package/src/types/typescript.ts +9 -0
@@ -0,0 +1,59 @@
1
+ import { componentInfo as accordionComponentInfo } from '../blocks/accordion/component-info';
2
+ import { default as Accordion } from '../blocks/accordion/index';
3
+ import { componentInfo as buttonComponentInfo } from '../blocks/button/component-info';
4
+ import { default as Button } from '../blocks/button/index';
5
+ import { componentInfo as columnsComponentInfo } from '../blocks/columns/component-info';
6
+ import { default as Columns } from '../blocks/columns/index';
7
+ import { componentInfo as fragmentComponentInfo } from '../blocks/fragment/component-info';
8
+ import { default as Fragment } from '../blocks/fragment/index';
9
+ import { componentInfo as imageComponentInfo } from '../blocks/image/component-info';
10
+ import { default as Image } from '../blocks/image/index';
11
+ import { componentInfo as sectionComponentInfo } from '../blocks/section/component-info';
12
+ import { default as Section } from '../blocks/section/index';
13
+ import { componentInfo as slotComponentInfo } from '../blocks/slot/component-info';
14
+ import { default as Slot } from '../blocks/slot/index';
15
+ import { componentInfo as symbolComponentInfo } from '../blocks/symbol/component-info';
16
+ import { default as Symbol } from '../blocks/symbol/index';
17
+ import { componentInfo as tabsComponentInfo } from '../blocks/tabs/component-info';
18
+ import { default as Tabs } from '../blocks/tabs/index';
19
+ import { componentInfo as textComponentInfo } from '../blocks/text/component-info';
20
+ import { default as Text } from '../blocks/text/index';
21
+ import type { RegisteredComponent } from '../context/types';
22
+ import { getExtraComponents } from './extra-components';
23
+ import { TARGET } from './target';
24
+
25
+ /**
26
+ * Returns a list of all registered components.
27
+ * NOTE: This needs to be a function to work around ESM circular dependencies.
28
+ */
29
+ export const getDefaultRegisteredComponents: () => RegisteredComponent[] = () => [{
30
+ component: Button,
31
+ ...buttonComponentInfo
32
+ }, {
33
+ component: Columns,
34
+ ...columnsComponentInfo
35
+ }, {
36
+ component: Fragment,
37
+ ...fragmentComponentInfo
38
+ }, {
39
+ component: Image,
40
+ ...imageComponentInfo
41
+ }, {
42
+ component: Section,
43
+ ...sectionComponentInfo
44
+ }, {
45
+ component: Slot,
46
+ ...slotComponentInfo
47
+ }, {
48
+ component: Symbol,
49
+ ...symbolComponentInfo
50
+ }, {
51
+ component: Text,
52
+ ...textComponentInfo
53
+ }, ...(TARGET === 'rsc' ? [] : [{
54
+ component: Tabs,
55
+ ...tabsComponentInfo
56
+ }, {
57
+ component: Accordion,
58
+ ...accordionComponentInfo
59
+ }]), ...getExtraComponents()]
@@ -0,0 +1,59 @@
1
+ import { fastClone } from '../functions/fast-clone';
2
+ export type SizeName = 'large' | 'medium' | 'small';
3
+ interface Size {
4
+ min: number;
5
+ default: number;
6
+ max: number;
7
+ }
8
+ const SIZES: Record<SizeName, Size> = {
9
+ small: {
10
+ min: 320,
11
+ default: 321,
12
+ max: 640
13
+ },
14
+ medium: {
15
+ min: 641,
16
+ default: 642,
17
+ max: 991
18
+ },
19
+ large: {
20
+ min: 990,
21
+ default: 991,
22
+ max: 1200
23
+ }
24
+ };
25
+ export const getMaxWidthQueryForSize = (size: SizeName, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
26
+ interface Breakpoints {
27
+ small?: number;
28
+ medium?: number;
29
+ }
30
+ export const getSizesForBreakpoints = ({
31
+ small,
32
+ medium
33
+ }: Breakpoints) => {
34
+ const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
35
+
36
+ if (!small || !medium) {
37
+ return newSizes;
38
+ }
39
+ const smallMin = Math.floor(small / 2);
40
+ newSizes.small = {
41
+ max: small,
42
+ min: smallMin,
43
+ default: smallMin + 1
44
+ };
45
+ const mediumMin = newSizes.small.max + 1;
46
+ newSizes.medium = {
47
+ max: medium,
48
+ min: mediumMin,
49
+ default: mediumMin + 1
50
+ };
51
+ const largeMin = newSizes.medium.max + 1;
52
+ newSizes.large = {
53
+ max: 2000,
54
+ // TODO: decide upper limit
55
+ min: largeMin,
56
+ default: largeMin + 1
57
+ };
58
+ return newSizes;
59
+ }
@@ -0,0 +1 @@
1
+ export const getExtraComponents = () => [];
@@ -0,0 +1 @@
1
+ export const SDK_VERSION = "1.0.34"
@@ -0,0 +1,3 @@
1
+ type Target = import('../types/targets').Target;
2
+
3
+ export const TARGET = 'reactNative' as Target;
@@ -0,0 +1,15 @@
1
+ import { createContext } from "react";
2
+
3
+ export default createContext<any>({
4
+ content: null,
5
+ context: {},
6
+ localState: undefined,
7
+ rootSetState() {},
8
+ rootState: {},
9
+ apiKey: null,
10
+ apiVersion: undefined,
11
+ componentInfos: {},
12
+ inheritedStyles: {},
13
+ BlocksWrapper: "div",
14
+ BlocksWrapperProps: {},
15
+ });
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+
3
+ export default createContext<any>({ registeredComponents: {} });
@@ -0,0 +1 @@
1
+ export { default as BuilderContext } from './builder.context'
@@ -0,0 +1,38 @@
1
+ import type { BlocksWrapperProps } from '../components/blocks/blocks-wrapper';
2
+ import type { ApiVersion } from '../types/api-version';
3
+ import type { BuilderContent } from '../types/builder-content';
4
+ import type { ComponentInfo } from '../types/components';
5
+ import type { Dictionary, Nullable } from '../types/typescript';
6
+ export type RegisteredComponent = ComponentInfo & {
7
+ component: any;
8
+ };
9
+ export type RegisteredComponents = Dictionary<RegisteredComponent>;
10
+ export type BuilderRenderState = Record<string, unknown>;
11
+ export type BuilderRenderContext = Record<string, unknown>;
12
+ export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'> {
13
+ content: Nullable<BuilderContent>;
14
+ context: BuilderRenderContext;
15
+ /**
16
+ * The state of the application.
17
+ *
18
+ * NOTE: see `localState` below to understand how it is different from `rootState`.
19
+ */
20
+ rootState: BuilderRenderState;
21
+ /**
22
+ * Some frameworks have a `setState` function which needs to be invoked to notify
23
+ * the framework of state change. (other frameworks don't in which case it is `undefined')
24
+ */
25
+ rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
26
+ /**
27
+ * The local state of the current component. This is different from `rootState` in that
28
+ * it can be a child state created by a repeater containing local state.
29
+ * The `rootState` is where all of the state mutations are actually stored.
30
+ */
31
+ localState: BuilderRenderState | undefined;
32
+ apiKey: string | null;
33
+ apiVersion: ApiVersion | undefined;
34
+ componentInfos: Dictionary<ComponentInfo>;
35
+ // Used to recursively store all CSS coming from a parent that would apply to a Text block
36
+ inheritedStyles: Record<string, unknown>;
37
+ canTrack?: boolean;
38
+ }
@@ -0,0 +1,61 @@
1
+ export type Patch = {
2
+ path: string;
3
+ op: 'add' | 'remove' | 'replace';
4
+ value: any;
5
+ };
6
+ export const applyPatchWithMinimalMutationChain = <T extends object,>(obj: T, patch: {
7
+ path: string;
8
+ op: 'add' | 'remove' | 'replace';
9
+ value: any;
10
+ }, preserveRoot = false): T => {
11
+ if (Object(obj) !== obj) {
12
+ return obj;
13
+ }
14
+ const {
15
+ path,
16
+ op,
17
+ value
18
+ } = patch;
19
+ const pathArr: string[] = path.split(/\//);
20
+ if (pathArr[0] === '') {
21
+ pathArr.shift();
22
+ }
23
+ const newObj = preserveRoot ? obj : {
24
+ ...obj
25
+ };
26
+ let objPart = (newObj as any);
27
+ for (let i = 0; i < pathArr.length; i++) {
28
+ const isLast = i === pathArr.length - 1;
29
+ const property = pathArr[i];
30
+ if (isLast) {
31
+ if (op === 'replace') {
32
+ objPart[property] = value;
33
+ } else if (op === 'add') {
34
+ const index = Number(property);
35
+ if (Array.isArray(objPart)) {
36
+ if (property === '-') {
37
+ objPart.push(value);
38
+ } else {
39
+ objPart.splice(index, 0, value);
40
+ }
41
+ } else {
42
+ objPart[property] = value;
43
+ }
44
+ } else if (op === 'remove') {
45
+ const index = Number(property);
46
+ if (Array.isArray(objPart)) {
47
+ objPart.splice(index, 1);
48
+ } else {
49
+ delete objPart[property];
50
+ }
51
+ }
52
+ } else {
53
+ const nextProperty = pathArr[i + 1];
54
+ const newPart = Object(objPart[property]) === objPart[property] ? objPart[property] : String(Number(nextProperty)) === nextProperty ? [] : {};
55
+ objPart = objPart[property] = Array.isArray(newPart) ? [...newPart] : {
56
+ ...newPart
57
+ };
58
+ }
59
+ }
60
+ return newObj;
61
+ }
@@ -0,0 +1 @@
1
+ export const camelToKebabCase = (str?: string) => str ? str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase() : ''
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Workaround until https://github.com/BuilderIO/qwik/issues/5017 is fixed.
3
+ */
4
+ export function deoptSignal<T>(value: T): T {
5
+ return value;
6
+ }
@@ -0,0 +1,61 @@
1
+ import type { BuilderRenderState } from '../../../context/types';
2
+ import type { ExecutorArgs } from '../helpers';
3
+ import { getFunctionArguments } from '../helpers';
4
+ export const runInBrowser = ({
5
+ code,
6
+ builder,
7
+ context,
8
+ event,
9
+ localState,
10
+ rootSetState,
11
+ rootState
12
+ }: ExecutorArgs) => {
13
+ const functionArgs = getFunctionArguments({
14
+ builder,
15
+ context,
16
+ event,
17
+ state: flattenState({
18
+ rootState,
19
+ localState,
20
+ rootSetState
21
+ })
22
+ });
23
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
24
+ };
25
+ export function flattenState({
26
+ rootState,
27
+ localState,
28
+ rootSetState
29
+ }: {
30
+ rootState: Record<string | symbol, any>;
31
+ localState: Record<string | symbol, any> | undefined;
32
+ rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
33
+ }): BuilderRenderState {
34
+ return new Proxy(rootState, {
35
+ get: (target, prop) => {
36
+ if (localState && prop in localState) {
37
+ return localState[prop];
38
+ }
39
+ const val = target[prop];
40
+ if (typeof val === 'object' && val !== null) {
41
+ return flattenState({
42
+ rootState: val,
43
+ localState: undefined,
44
+ rootSetState: rootSetState ? subState => {
45
+ target[prop] = subState;
46
+ rootSetState(target);
47
+ } : undefined
48
+ });
49
+ }
50
+ return val;
51
+ },
52
+ set: (target, prop, value) => {
53
+ if (localState && prop in localState) {
54
+ throw new Error('Writing to local state is not allowed as it is read-only.');
55
+ }
56
+ target[prop] = value;
57
+ rootSetState?.(target);
58
+ return true;
59
+ }
60
+ });
61
+ }
@@ -0,0 +1 @@
1
+ export { runInBrowser as evaluator } from './browser'
@@ -0,0 +1,23 @@
1
+ import { isBrowser } from '../is-browser';
2
+ import { runInBrowser } from './browser-runtime/browser';
3
+ import type { ExecutorArgs } from './helpers';
4
+
5
+ /**
6
+ * THIS IS A MAGICAL IMPORT. It is aliased by the build process of every SDK configuration, so that
7
+ * it points to the correct runtime for that configuration, which are expected to live exactly at:
8
+ * - ./browser-runtime/index.js
9
+ * - ./node-runtime/index.js
10
+ * - ./edge-runtime/index.js
11
+ *
12
+ * We have code in `/output-generation` that does this aliasing, and is re-used by each SDK.
13
+ * Also, each individual `tsconfig.json` aliases this import to the browser runtime so that the
14
+ * types can be resolved correctly.
15
+ */
16
+ import { evaluator } from 'placeholder-runtime';
17
+ import { shouldForceBrowserRuntimeInNode } from './should-force-browser-runtime-in-node';
18
+
19
+ /**
20
+ * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
21
+ * end up sending the server runtime code to the browser (most notably in dev mode).
22
+ */
23
+ export const chooseBrowserOrServerEval = (args: ExecutorArgs) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : evaluator(args)