@builder.io/sdk-react 0.0.2 → 0.0.4
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.
- package/package.json +6 -1
- package/packages/_rsc/src/blocks/BaseText.js +27 -0
- package/packages/_rsc/src/blocks/button/button.js +35 -0
- package/packages/_rsc/src/blocks/button/component-info.js +41 -0
- package/packages/_rsc/src/blocks/columns/columns.js +96 -0
- package/packages/_rsc/src/blocks/columns/component-info.js +242 -0
- package/packages/_rsc/src/blocks/custom-code/component-info.js +31 -0
- package/packages/_rsc/src/blocks/custom-code/custom-code.js +63 -0
- package/packages/_rsc/src/blocks/embed/component-info.js +44 -0
- package/packages/_rsc/src/blocks/embed/embed.js +55 -0
- package/packages/_rsc/src/blocks/embed/helpers.js +9 -0
- package/packages/_rsc/src/blocks/form/component-info.js +262 -0
- package/packages/_rsc/src/blocks/form/form.js +222 -0
- package/packages/_rsc/src/blocks/fragment/component-info.js +11 -0
- package/packages/_rsc/src/blocks/fragment/fragment.js +24 -0
- package/packages/_rsc/src/blocks/image/component-info.js +151 -0
- package/packages/_rsc/src/blocks/image/image.helpers.js +48 -0
- package/packages/_rsc/src/blocks/image/image.js +101 -0
- package/packages/_rsc/src/blocks/img/component-info.js +20 -0
- package/packages/_rsc/src/blocks/img/img.js +33 -0
- package/packages/_rsc/src/blocks/input/component-info.js +74 -0
- package/packages/_rsc/src/blocks/input/input.js +36 -0
- package/packages/_rsc/src/blocks/raw-text/component-info.js +16 -0
- package/packages/_rsc/src/blocks/raw-text/raw-text.js +28 -0
- package/packages/_rsc/src/blocks/section/component-info.js +49 -0
- package/packages/_rsc/src/blocks/section/section.js +31 -0
- package/packages/_rsc/src/blocks/select/component-info.js +59 -0
- package/packages/_rsc/src/blocks/select/select.js +36 -0
- package/packages/_rsc/src/blocks/submit-button/component-info.js +28 -0
- package/packages/_rsc/src/blocks/submit-button/submit-button.js +26 -0
- package/packages/_rsc/src/blocks/symbol/component-info.js +43 -0
- package/packages/_rsc/src/blocks/symbol/symbol.js +51 -0
- package/packages/_rsc/src/blocks/text/component-info.js +24 -0
- package/packages/_rsc/src/blocks/text/text.js +27 -0
- package/packages/_rsc/src/blocks/textarea/component-info.js +47 -0
- package/packages/_rsc/src/blocks/textarea/textarea.js +32 -0
- package/packages/_rsc/src/blocks/util.js +8 -0
- package/packages/_rsc/src/blocks/video/component-info.js +106 -0
- package/packages/_rsc/src/blocks/video/video.js +57 -0
- package/packages/_rsc/src/components/render-block/block-styles.js +70 -0
- package/packages/_rsc/src/components/render-block/render-block.helpers.js +23 -0
- package/packages/_rsc/src/components/render-block/render-block.js +206 -0
- package/packages/_rsc/src/components/render-block/render-component-with-context.js +51 -0
- package/packages/_rsc/src/components/render-block/render-component.js +43 -0
- package/packages/_rsc/src/components/render-block/render-repeated-block.js +49 -0
- package/packages/_rsc/src/components/render-block/types.js +0 -0
- package/packages/_rsc/src/components/render-blocks.js +80 -0
- package/packages/_rsc/src/components/render-content/builder-editing.js +35 -0
- package/packages/_rsc/src/components/render-content/components/render-styles.js +78 -0
- package/packages/_rsc/src/components/render-content/index.js +4 -0
- package/packages/_rsc/src/components/render-content/render-content.js +200 -0
- package/packages/_rsc/src/components/render-inlined-styles.js +36 -0
- package/packages/_rsc/src/constants/builder-registered-components.js +54 -0
- package/packages/_rsc/src/constants/device-sizes.js +48 -0
- package/packages/_rsc/src/constants/target.js +4 -0
- package/packages/_rsc/src/context/builder.context.js +11 -0
- package/packages/_rsc/src/context/types.js +0 -0
- package/packages/_rsc/src/functions/camel-to-kebab-case.js +4 -0
- package/packages/_rsc/src/functions/evaluate.js +6 -0
- package/packages/_rsc/src/functions/event-handler-name.js +7 -0
- package/packages/_rsc/src/functions/extract-text-styles.js +22 -0
- package/packages/_rsc/src/functions/fast-clone.js +4 -0
- package/packages/_rsc/src/functions/get-block-actions-handler.js +11 -0
- package/packages/_rsc/src/functions/get-block-actions.js +18 -0
- package/packages/_rsc/src/functions/get-block-component-options.js +28 -0
- package/packages/_rsc/src/functions/get-block-properties.js +29 -0
- package/packages/_rsc/src/functions/get-block-tag.js +6 -0
- package/packages/_rsc/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/packages/_rsc/src/functions/get-builder-search-params/index.js +38 -0
- package/packages/_rsc/src/functions/get-content/ab-testing.js +99 -0
- package/packages/_rsc/src/functions/get-content/fn.test.js +31 -0
- package/packages/_rsc/src/functions/get-content/index.js +101 -0
- package/packages/_rsc/src/functions/get-content/types.js +0 -0
- package/packages/_rsc/src/functions/get-fetch.js +34 -0
- package/packages/_rsc/src/functions/get-global-this.js +18 -0
- package/packages/_rsc/src/functions/get-processed-block.js +59 -0
- package/packages/_rsc/src/functions/get-processed-block.test.js +32 -0
- package/packages/_rsc/src/functions/get-react-native-block-styles.js +32 -0
- package/packages/_rsc/src/functions/if-target.js +15 -0
- package/packages/_rsc/src/functions/is-browser.js +6 -0
- package/packages/_rsc/src/functions/is-editing.js +7 -0
- package/packages/_rsc/src/functions/is-iframe.js +7 -0
- package/packages/_rsc/src/functions/is-previewing.js +14 -0
- package/packages/_rsc/src/functions/on-change.js +27 -0
- package/packages/_rsc/src/functions/on-change.test.js +19 -0
- package/packages/_rsc/src/functions/register-component.js +68 -0
- package/packages/_rsc/src/functions/register.js +29 -0
- package/packages/_rsc/src/functions/sanitize-react-native-block-styles.js +66 -0
- package/packages/_rsc/src/functions/set-editor-settings.js +15 -0
- package/packages/_rsc/src/functions/set.js +11 -0
- package/packages/_rsc/src/functions/set.test.js +16 -0
- package/packages/_rsc/src/functions/track.js +124 -0
- package/packages/_rsc/src/functions/transform-block.js +6 -0
- package/packages/_rsc/src/helpers/ab-tests.js +16 -0
- package/packages/_rsc/src/helpers/cookie.js +79 -0
- package/packages/_rsc/src/helpers/css.js +28 -0
- package/packages/_rsc/src/helpers/flatten.js +34 -0
- package/packages/_rsc/src/helpers/localStorage.js +34 -0
- package/packages/_rsc/src/helpers/nullable.js +4 -0
- package/packages/_rsc/src/helpers/sessionId.js +49 -0
- package/packages/_rsc/src/helpers/time.js +5 -0
- package/packages/_rsc/src/helpers/url.js +10 -0
- package/packages/_rsc/src/helpers/url.test.js +15 -0
- package/packages/_rsc/src/helpers/uuid.js +13 -0
- package/packages/_rsc/src/helpers/visitorId.js +33 -0
- package/packages/_rsc/src/index-helpers/blocks-exports.js +22 -0
- package/packages/_rsc/src/index-helpers/top-of-file.js +2 -0
- package/packages/_rsc/src/index.js +14 -0
- package/packages/_rsc/src/scripts/init-editing.js +93 -0
- package/packages/_rsc/src/types/builder-block.js +0 -0
- package/packages/_rsc/src/types/builder-content.js +0 -0
- package/packages/_rsc/src/types/can-track.js +0 -0
- package/packages/_rsc/src/types/components.js +0 -0
- package/packages/_rsc/src/types/deep-partial.js +0 -0
- package/packages/_rsc/src/types/element.js +0 -0
- package/packages/_rsc/src/types/targets.js +0 -0
- package/packages/_rsc/src/types/typescript.js +0 -0
- package/src/blocks/button/button.jsx +6 -5
- package/src/blocks/columns/columns.jsx +9 -10
- package/src/blocks/columns/component-info.js +2 -2
- package/src/blocks/embed/component-info.js +2 -2
- package/src/blocks/form/form.jsx +4 -7
- package/src/blocks/image/component-info.js +2 -2
- package/src/blocks/image/image.jsx +36 -14
- package/src/blocks/img/img.jsx +2 -5
- package/src/blocks/submit-button/submit-button.jsx +2 -5
- package/src/blocks/symbol/symbol.jsx +3 -4
- package/src/blocks/util.js +6 -5
- package/src/components/render-block/block-styles.jsx +9 -3
- package/src/components/render-block/render-block.jsx +14 -11
- package/src/components/render-block/render-component.jsx +1 -2
- package/src/components/render-content/builder-editing.jsx +7 -0
- package/src/components/render-content/render-content.jsx +14 -6
- package/src/components/render-inlined-styles.jsx +4 -4
- package/src/constants/device-sizes.js +29 -2
- package/src/constants/target.js +1 -1
- package/src/functions/evaluate.js +4 -3
- package/src/functions/get-block-actions-handler.js +8 -9
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-builder-search-params/index.js +2 -1
- package/src/functions/get-content/index.js +8 -3
- package/src/functions/register-component.js +1 -5
- package/src/functions/track.js +4 -0
- package/src/index.js +1 -1
- package/src/scripts/init-editing.js +17 -5
- package/src/functions/mark-mutable.js +0 -10
|
@@ -68,7 +68,7 @@ function RenderBlock(props) {
|
|
|
68
68
|
return ref;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function tag() {
|
|
72
72
|
return getBlockTag(useBlock());
|
|
73
73
|
}
|
|
74
74
|
function useBlock() {
|
|
@@ -79,12 +79,15 @@ function RenderBlock(props) {
|
|
|
79
79
|
shouldEvaluateBindings: true
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return
|
|
82
|
+
function actions() {
|
|
83
|
+
return getBlockActions({
|
|
84
84
|
block: useBlock(),
|
|
85
85
|
state: props.context.state,
|
|
86
86
|
context: props.context.context
|
|
87
|
-
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function attributes() {
|
|
90
|
+
return __spreadValues(__spreadValues({}, getBlockProperties(useBlock())), TARGET === "reactNative" ? {
|
|
88
91
|
style: getReactNativeBlockStyles({
|
|
89
92
|
block: useBlock(),
|
|
90
93
|
context: props.context
|
|
@@ -98,22 +101,22 @@ function RenderBlock(props) {
|
|
|
98
101
|
function renderComponentProps() {
|
|
99
102
|
var _a2;
|
|
100
103
|
return {
|
|
101
|
-
blockChildren:
|
|
104
|
+
blockChildren: useChildren(),
|
|
102
105
|
componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
|
|
103
106
|
componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
|
|
104
|
-
attributes: attributes()
|
|
107
|
+
attributes: __spreadValues(__spreadValues({}, attributes()), actions())
|
|
105
108
|
}),
|
|
106
109
|
context: childrenContext()
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
function
|
|
112
|
+
function useChildren() {
|
|
110
113
|
var _a2;
|
|
111
114
|
return (_a2 = useBlock().children) != null ? _a2 : [];
|
|
112
115
|
}
|
|
113
116
|
function childrenWithoutParentComponent() {
|
|
114
117
|
var _a2;
|
|
115
118
|
const shouldRenderChildrenOutsideRef = !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component) && !repeatItemData();
|
|
116
|
-
return shouldRenderChildrenOutsideRef ?
|
|
119
|
+
return shouldRenderChildrenOutsideRef ? useChildren() : [];
|
|
117
120
|
}
|
|
118
121
|
function repeatItemData() {
|
|
119
122
|
const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
|
|
@@ -174,12 +177,12 @@ function RenderBlock(props) {
|
|
|
174
177
|
}
|
|
175
178
|
const [componentInfo, setComponentInfo] = useState(() => null);
|
|
176
179
|
const RenderComponentTagRef = renderComponentTag();
|
|
177
|
-
const
|
|
178
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(
|
|
180
|
+
const TagRef = tag();
|
|
181
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(tag()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagRef, __spreadValues(__spreadValues({}, attributes()), actions()))) : null, !isEmptyHtmlElement(tag()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
|
|
179
182
|
key: index,
|
|
180
183
|
repeatContext: data.context,
|
|
181
184
|
block: data.block
|
|
182
|
-
}))) : null, !isEmptyHtmlElement(
|
|
185
|
+
}))) : null, !isEmptyHtmlElement(tag()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagRef, __spreadValues(__spreadValues({}, attributes()), actions()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
183
186
|
key: "render-block-" + child.id,
|
|
184
187
|
block: child,
|
|
185
188
|
context: childrenContext()
|
|
@@ -17,11 +17,10 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import BlockStyles from "./block-styles.jsx";
|
|
19
19
|
import RenderBlock from "./render-block.jsx";
|
|
20
|
-
import { markPropsMutable } from "../../functions/mark-mutable.js";
|
|
21
20
|
function RenderComponent(props) {
|
|
22
21
|
var _a, _b;
|
|
23
22
|
const ComponentRefRef = props.componentRef;
|
|
24
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({},
|
|
23
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, props.componentOptions), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
25
24
|
key: "render-block-" + child.id,
|
|
26
25
|
block: child,
|
|
27
26
|
context: props.context
|
|
@@ -21,7 +21,6 @@ import * as React from "react";
|
|
|
21
21
|
import { useState, useRef, useEffect } from "react";
|
|
22
22
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
23
23
|
import { TARGET } from "../../constants/target.js";
|
|
24
|
-
import BuilderContext from "../../context/builder.context.js";
|
|
25
24
|
import { evaluate } from "../../functions/evaluate.js";
|
|
26
25
|
import { getContent } from "../../functions/get-content/index.js";
|
|
27
26
|
import { getFetch } from "../../functions/get-fetch.js";
|
|
@@ -35,11 +34,11 @@ import {
|
|
|
35
34
|
import { _track } from "../../functions/track.js";
|
|
36
35
|
import RenderBlocks from "../render-blocks.jsx";
|
|
37
36
|
import RenderContentStyles from "./components/render-styles.jsx";
|
|
37
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
38
38
|
import {
|
|
39
39
|
registerInsertMenu,
|
|
40
40
|
setupBrowserForEditing
|
|
41
41
|
} from "../../scripts/init-editing.js";
|
|
42
|
-
import { markMutable } from "../../functions/mark-mutable.js";
|
|
43
42
|
function RenderContent(props) {
|
|
44
43
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
45
44
|
const elementRef = useRef(null);
|
|
@@ -62,7 +61,9 @@ function RenderContent(props) {
|
|
|
62
61
|
const [overrideState, setOverrideState] = useState(() => ({}));
|
|
63
62
|
function contentState() {
|
|
64
63
|
var _a2, _b2;
|
|
65
|
-
return __spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data),
|
|
64
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data), props.locale ? {
|
|
65
|
+
locale: props.locale
|
|
66
|
+
} : {}), overrideState);
|
|
66
67
|
}
|
|
67
68
|
function contextContext() {
|
|
68
69
|
return props.context || {};
|
|
@@ -174,11 +175,18 @@ function RenderContent(props) {
|
|
|
174
175
|
}
|
|
175
176
|
useEffect(() => {
|
|
176
177
|
var _a2, _b2;
|
|
178
|
+
if (!props.apiKey) {
|
|
179
|
+
console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
180
|
+
}
|
|
177
181
|
if (isBrowser()) {
|
|
178
182
|
if (isEditing()) {
|
|
179
183
|
setForceReRenderCount(forceReRenderCount + 1);
|
|
180
184
|
registerInsertMenu();
|
|
181
|
-
setupBrowserForEditing(
|
|
185
|
+
setupBrowserForEditing(__spreadValues(__spreadValues({}, props.locale ? {
|
|
186
|
+
locale: props.locale
|
|
187
|
+
} : {}), props.includeRefs ? {
|
|
188
|
+
includeRefs: props.includeRefs
|
|
189
|
+
} : {}));
|
|
182
190
|
Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
|
|
183
191
|
var _a3;
|
|
184
192
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -221,7 +229,7 @@ function RenderContent(props) {
|
|
|
221
229
|
}, []);
|
|
222
230
|
useEffect(() => {
|
|
223
231
|
evaluateJsCode();
|
|
224
|
-
}, [(_b = (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode]);
|
|
232
|
+
}, [(_b = (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode, contentState()]);
|
|
225
233
|
useEffect(() => {
|
|
226
234
|
runHttpRequests();
|
|
227
235
|
}, [(_d = (_c = useContent == null ? void 0 : useContent()) == null ? void 0 : _c.data) == null ? void 0 : _d.httpRequests]);
|
|
@@ -263,7 +271,7 @@ function RenderContent(props) {
|
|
|
263
271
|
cssCode: (_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.cssCode,
|
|
264
272
|
customFonts: (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.customFonts
|
|
265
273
|
}) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
266
|
-
blocks:
|
|
274
|
+
blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks,
|
|
267
275
|
key: forceReRenderCount
|
|
268
276
|
}))) : null);
|
|
269
277
|
}
|
|
@@ -2,15 +2,15 @@ import * as React from "react";
|
|
|
2
2
|
import { TARGET } from "../constants/target.js";
|
|
3
3
|
function RenderInlinedStyles(props) {
|
|
4
4
|
function injectedStyleScript() {
|
|
5
|
-
return `<${
|
|
5
|
+
return `<${tag()}>${props.styles}</${tag()}>`;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function tag() {
|
|
8
8
|
return "style";
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const TagRef = tag();
|
|
11
11
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
12
12
|
dangerouslySetInnerHTML: { __html: injectedStyleScript() }
|
|
13
|
-
})) : /* @__PURE__ */ React.createElement(
|
|
13
|
+
})) : /* @__PURE__ */ React.createElement(TagRef, null, props.styles));
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
16
16
|
RenderInlinedStyles as default
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fastClone } from "../functions/fast-clone";
|
|
1
2
|
const SIZES = {
|
|
2
3
|
small: {
|
|
3
4
|
min: 320,
|
|
@@ -15,7 +16,33 @@ const SIZES = {
|
|
|
15
16
|
max: 1200
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
|
-
const getMaxWidthQueryForSize = (size) => `@media (max-width: ${
|
|
19
|
+
const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
|
+
const getSizesForBreakpoints = ({ small, medium }) => {
|
|
21
|
+
const newSizes = fastClone(SIZES);
|
|
22
|
+
if (!small || !medium) {
|
|
23
|
+
return newSizes;
|
|
24
|
+
}
|
|
25
|
+
const smallMin = Math.floor(small / 2);
|
|
26
|
+
newSizes.small = {
|
|
27
|
+
max: small,
|
|
28
|
+
min: smallMin,
|
|
29
|
+
default: smallMin + 1
|
|
30
|
+
};
|
|
31
|
+
const mediumMin = newSizes.small.max + 1;
|
|
32
|
+
newSizes.medium = {
|
|
33
|
+
max: medium,
|
|
34
|
+
min: mediumMin,
|
|
35
|
+
default: mediumMin + 1
|
|
36
|
+
};
|
|
37
|
+
const largeMin = newSizes.medium.max + 1;
|
|
38
|
+
newSizes.large = {
|
|
39
|
+
max: 2e3,
|
|
40
|
+
min: largeMin,
|
|
41
|
+
default: largeMin + 1
|
|
42
|
+
};
|
|
43
|
+
return newSizes;
|
|
44
|
+
};
|
|
19
45
|
export {
|
|
20
|
-
getMaxWidthQueryForSize
|
|
46
|
+
getMaxWidthQueryForSize,
|
|
47
|
+
getSizesForBreakpoints
|
|
21
48
|
};
|
package/src/constants/target.js
CHANGED
|
@@ -4,7 +4,8 @@ function evaluate({
|
|
|
4
4
|
code,
|
|
5
5
|
context,
|
|
6
6
|
state,
|
|
7
|
-
event
|
|
7
|
+
event,
|
|
8
|
+
isExpression = true
|
|
8
9
|
}) {
|
|
9
10
|
if (code === "") {
|
|
10
11
|
console.warn("Skipping evaluation of empty code block.");
|
|
@@ -15,12 +16,12 @@ function evaluate({
|
|
|
15
16
|
isBrowser: isBrowser(),
|
|
16
17
|
isServer: !isBrowser()
|
|
17
18
|
};
|
|
18
|
-
const useReturn = !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
19
|
+
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
19
20
|
const useCode = useReturn ? `return (${code});` : code;
|
|
20
21
|
try {
|
|
21
22
|
return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
|
|
22
23
|
} catch (e) {
|
|
23
|
-
console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e
|
|
24
|
+
console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
export {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { evaluate } from "./evaluate.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
const createEventHandler = (value, options) => (event) => evaluate({
|
|
3
|
+
code: value,
|
|
4
|
+
context: options.context,
|
|
5
|
+
state: options.state,
|
|
6
|
+
event,
|
|
7
|
+
isExpression: false
|
|
8
|
+
});
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
createEventHandler
|
|
12
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getEventHandlerName } from "./event-handler-name.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createEventHandler } from "./get-block-actions-handler.js";
|
|
3
3
|
function getBlockActions(options) {
|
|
4
4
|
var _a;
|
|
5
5
|
const obj = {};
|
|
@@ -9,7 +9,7 @@ function getBlockActions(options) {
|
|
|
9
9
|
continue;
|
|
10
10
|
}
|
|
11
11
|
const value = optionActions[key];
|
|
12
|
-
obj[getEventHandlerName(key)] =
|
|
12
|
+
obj[getEventHandlerName(key)] = createEventHandler(value, options);
|
|
13
13
|
}
|
|
14
14
|
return obj;
|
|
15
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isBrowser } from "../is-browser.js";
|
|
2
2
|
const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3
|
+
const BUILDER_OPTIONS_PREFIX = "options.";
|
|
3
4
|
const convertSearchParamsToQueryObject = (searchParams) => {
|
|
4
5
|
const options = {};
|
|
5
6
|
searchParams.forEach((value, key) => {
|
|
@@ -15,7 +16,7 @@ const getBuilderSearchParams = (_options) => {
|
|
|
15
16
|
const newOptions = {};
|
|
16
17
|
Object.keys(options).forEach((key) => {
|
|
17
18
|
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
18
|
-
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "");
|
|
19
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
19
20
|
newOptions[trimmedKey] = options[key];
|
|
20
21
|
}
|
|
21
22
|
});
|
|
@@ -56,9 +56,14 @@ const generateContentUrl = (options) => {
|
|
|
56
56
|
query,
|
|
57
57
|
noTraverse = false,
|
|
58
58
|
model,
|
|
59
|
-
apiKey
|
|
59
|
+
apiKey,
|
|
60
|
+
includeRefs = true,
|
|
61
|
+
locale
|
|
60
62
|
} = options;
|
|
61
|
-
|
|
63
|
+
if (!apiKey) {
|
|
64
|
+
throw new Error("Missing API key");
|
|
65
|
+
}
|
|
66
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
|
|
62
67
|
const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
|
|
63
68
|
const flattened = flatten(queryOptions);
|
|
64
69
|
for (const key in flattened) {
|
|
@@ -81,7 +86,7 @@ function getAllContent(options) {
|
|
|
81
86
|
const fetch = yield getFetch();
|
|
82
87
|
const content = yield fetch(url.href).then((res) => res.json());
|
|
83
88
|
const canTrack = options.canTrack !== false;
|
|
84
|
-
if (canTrack) {
|
|
89
|
+
if (canTrack && Array.isArray(content.results)) {
|
|
85
90
|
for (const item of content.results) {
|
|
86
91
|
yield handleABTesting({ item, canTrack });
|
|
87
92
|
}
|
|
@@ -29,6 +29,7 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
+
import { serializeFn } from "../blocks/util.js";
|
|
32
33
|
import { fastClone } from "./fast-clone.js";
|
|
33
34
|
const components = [];
|
|
34
35
|
function registerComponent(component, info) {
|
|
@@ -48,11 +49,6 @@ const createRegisterComponentMessage = (_a) => {
|
|
|
48
49
|
};
|
|
49
50
|
};
|
|
50
51
|
const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
51
|
-
const serializeFn = (fnValue) => {
|
|
52
|
-
const fnStr = fnValue.toString().trim();
|
|
53
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
54
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
55
|
-
};
|
|
56
52
|
const prepareComponentInfoToSend = (_c) => {
|
|
57
53
|
var _d = _c, {
|
|
58
54
|
inputs
|
package/src/functions/track.js
CHANGED
|
@@ -90,6 +90,10 @@ const createEvent = (_a) => __async(void 0, null, function* () {
|
|
|
90
90
|
});
|
|
91
91
|
function _track(eventProps) {
|
|
92
92
|
return __async(this, null, function* () {
|
|
93
|
+
if (!eventProps.apiKey) {
|
|
94
|
+
console.error("[Builder.io]: Missing API key for track call. Please provide your API key.");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
93
97
|
if (!eventProps.canTrack) {
|
|
94
98
|
return;
|
|
95
99
|
}
|
package/src/index.js
CHANGED
|
@@ -19,19 +19,31 @@ const registerInsertMenu = () => {
|
|
|
19
19
|
]
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let isSetupForEditing = false;
|
|
23
|
+
const setupBrowserForEditing = (options = {}) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if (isSetupForEditing) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
isSetupForEditing = true;
|
|
24
29
|
if (isBrowser()) {
|
|
25
30
|
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
26
31
|
type: "builder.sdkInfo",
|
|
27
32
|
data: {
|
|
28
33
|
target: TARGET,
|
|
29
34
|
supportsPatchUpdates: false,
|
|
30
|
-
supportsAddBlockScoping: true
|
|
35
|
+
supportsAddBlockScoping: true,
|
|
36
|
+
supportsCustomBreakpoints: true
|
|
37
|
+
}
|
|
38
|
+
}, "*");
|
|
39
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
40
|
+
type: "builder.updateContent",
|
|
41
|
+
data: {
|
|
42
|
+
options
|
|
31
43
|
}
|
|
32
44
|
}, "*");
|
|
33
45
|
window.addEventListener("message", ({ data }) => {
|
|
34
|
-
var _a2,
|
|
46
|
+
var _a2, _b2;
|
|
35
47
|
if (!(data == null ? void 0 : data.type)) {
|
|
36
48
|
return;
|
|
37
49
|
}
|
|
@@ -63,7 +75,7 @@ const setupBrowserForEditing = () => {
|
|
|
63
75
|
}, "*");
|
|
64
76
|
}).catch(console.error);
|
|
65
77
|
} else {
|
|
66
|
-
(
|
|
78
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
67
79
|
type: "builder.evaluateResult",
|
|
68
80
|
data: { result, id }
|
|
69
81
|
}, "*");
|