@builder.io/sdk-solid 0.0.1
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/README.md +3 -0
- package/package.json +9 -0
- package/src/blocks/button.js +41 -0
- package/src/blocks/button.lite.tsx +18 -0
- package/src/blocks/columns.js +133 -0
- package/src/blocks/columns.lite.tsx +96 -0
- package/src/blocks/custom-code.js +72 -0
- package/src/blocks/custom-code.lite.tsx +65 -0
- package/src/blocks/embed.js +62 -0
- package/src/blocks/embed.lite.tsx +57 -0
- package/src/blocks/form.js +355 -0
- package/src/blocks/form.lite.tsx +291 -0
- package/src/blocks/fragment.js +15 -0
- package/src/blocks/fragment.lite.tsx +3 -0
- package/src/blocks/image.js +136 -0
- package/src/blocks/image.lite.tsx +81 -0
- package/src/blocks/img.js +39 -0
- package/src/blocks/img.lite.tsx +16 -0
- package/src/blocks/input.js +45 -0
- package/src/blocks/input.lite.tsx +18 -0
- package/src/blocks/raw-text.js +25 -0
- package/src/blocks/raw-text.lite.tsx +8 -0
- package/src/blocks/section.js +24 -0
- package/src/blocks/section.lite.tsx +16 -0
- package/src/blocks/select.js +57 -0
- package/src/blocks/select.lite.tsx +23 -0
- package/src/blocks/submit-button.js +18 -0
- package/src/blocks/submit-button.lite.tsx +7 -0
- package/src/blocks/symbol.js +69 -0
- package/src/blocks/symbol.lite.tsx +37 -0
- package/src/blocks/text.js +15 -0
- package/src/blocks/text.lite.tsx +3 -0
- package/src/blocks/textarea.js +34 -0
- package/src/blocks/textarea.lite.tsx +11 -0
- package/src/blocks/video.js +54 -0
- package/src/blocks/video.lite.tsx +24 -0
- package/src/components/block-styles.js +3 -0
- package/src/components/block-styles.lite.tsx +3 -0
- package/src/components/error-boundary.js +3 -0
- package/src/components/error-boundary.lite.tsx +3 -0
- package/src/components/render-block.js +154 -0
- package/src/components/render-block.lite.tsx +108 -0
- package/src/components/render-blocks.js +104 -0
- package/src/components/render-blocks.lite.tsx +72 -0
- package/src/components/render-content.js +314 -0
- package/src/components/render-content.lite.tsx +289 -0
- package/src/constants/device-sizes.js +39 -0
- package/src/context/builder.context.js +10 -0
- package/src/functions/evaluate.js +28 -0
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +23 -0
- package/src/functions/get-block-component-options.js +23 -0
- package/src/functions/get-block-properties.js +29 -0
- package/src/functions/get-block-styles.js +42 -0
- package/src/functions/get-block-tag.js +6 -0
- package/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/src/functions/get-builder-search-params/index.js +22 -0
- package/src/functions/get-content/fn.test.js +31 -0
- package/src/functions/get-content/index.js +137 -0
- package/src/functions/get-fetch.js +12 -0
- package/src/functions/get-global-this.js +18 -0
- package/src/functions/get-processed-block.js +46 -0
- package/src/functions/get-processed-block.test.js +31 -0
- package/src/functions/get-target.js +6 -0
- package/src/functions/if-target.js +6 -0
- package/src/functions/is-browser.js +6 -0
- package/src/functions/is-editing.js +7 -0
- package/src/functions/is-iframe.js +7 -0
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/is-react-native.js +6 -0
- package/src/functions/macro-eval.js +5 -0
- package/src/functions/on-change.js +27 -0
- package/src/functions/on-change.test.js +19 -0
- package/src/functions/previewing-model-name.js +11 -0
- package/src/functions/register-component.js +53 -0
- package/src/functions/register.js +29 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +11 -0
- package/src/functions/set.test.js +16 -0
- package/src/functions/track.js +22 -0
- package/src/functions/transform-block.js +6 -0
- package/src/index-helpers/blocks-exports.js +20 -0
- package/src/index-helpers/top-of-file.js +4 -0
- package/src/index.js +13 -0
- package/src/scripts/init-editing.js +70 -0
- package/src/types/builder-block.js +0 -0
- package/src/types/builder-content.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/typescript.js +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { set } from "./set";
|
|
2
|
+
test("can shallow set a property", () => {
|
|
3
|
+
const obj = { foo: "bar" };
|
|
4
|
+
set(obj, "foo", "baz");
|
|
5
|
+
expect(obj.foo).toBe("baz");
|
|
6
|
+
});
|
|
7
|
+
test("can deeply set a property", () => {
|
|
8
|
+
const obj = { foo: "bar" };
|
|
9
|
+
set(obj, "foo.bar", "baz");
|
|
10
|
+
expect(obj.foo.bar).toBe("baz");
|
|
11
|
+
});
|
|
12
|
+
test("can deeply create arrays", () => {
|
|
13
|
+
const obj = { foo: "bar" };
|
|
14
|
+
set(obj, "foo.bar.0", "hi");
|
|
15
|
+
expect(obj.foo.bar).toEqual(["hi"]);
|
|
16
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBrowser } from "./is-browser";
|
|
2
|
+
import { isEditing } from "./is-editing";
|
|
3
|
+
import { isReactNative } from "./is-react-native";
|
|
4
|
+
function track(event, properties) {
|
|
5
|
+
if (isEditing()) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (!(isBrowser() || isReactNative())) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return fetch(`https://builder.io/api/v1/track`, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
body: JSON.stringify({ events: [{ type: event, data: properties }] }),
|
|
14
|
+
headers: {
|
|
15
|
+
"content-type": "application/json"
|
|
16
|
+
},
|
|
17
|
+
mode: "cors"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
track
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as default2 } from "../blocks/columns";
|
|
2
|
+
import { default as default3 } from "../blocks/image";
|
|
3
|
+
import { default as default4 } from "../blocks/text";
|
|
4
|
+
import { default as default5 } from "../blocks/video";
|
|
5
|
+
import { default as default6 } from "../blocks/symbol";
|
|
6
|
+
import { default as default7 } from "../blocks/button";
|
|
7
|
+
import { default as default8 } from "../blocks/section";
|
|
8
|
+
import { default as default9 } from "../blocks/fragment";
|
|
9
|
+
import { default as default10 } from "../components/render-content";
|
|
10
|
+
export {
|
|
11
|
+
default7 as Button,
|
|
12
|
+
default2 as Columns,
|
|
13
|
+
default9 as Fragment,
|
|
14
|
+
default3 as Image,
|
|
15
|
+
default10 as RenderContent,
|
|
16
|
+
default8 as Section,
|
|
17
|
+
default6 as Symbol,
|
|
18
|
+
default4 as Text,
|
|
19
|
+
default5 as Video
|
|
20
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import("./index-helpers/top-of-file");
|
|
2
|
+
import { isEditing } from "./functions/is-editing";
|
|
3
|
+
if (isEditing()) {
|
|
4
|
+
import("./scripts/init-editing");
|
|
5
|
+
}
|
|
6
|
+
export * from "./index-helpers/blocks-exports";
|
|
7
|
+
export * from "./functions/is-editing";
|
|
8
|
+
export * from "./functions/is-previewing";
|
|
9
|
+
export * from "./functions/register-component";
|
|
10
|
+
export * from "./functions/register";
|
|
11
|
+
export * from "./functions/set-editor-settings";
|
|
12
|
+
export * from "./functions/get-content";
|
|
13
|
+
export * from "./functions/get-builder-search-params";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { isBrowser } from "../functions/is-browser";
|
|
3
|
+
import { register } from "../functions/register";
|
|
4
|
+
register("insertMenu", {
|
|
5
|
+
name: "_default",
|
|
6
|
+
default: true,
|
|
7
|
+
items: [
|
|
8
|
+
{ name: "Box" },
|
|
9
|
+
{ name: "Text" },
|
|
10
|
+
{ name: "Image" },
|
|
11
|
+
{ name: "Columns" },
|
|
12
|
+
...false ? [] : [
|
|
13
|
+
{ name: "Core:Section" },
|
|
14
|
+
{ name: "Core:Button" },
|
|
15
|
+
{ name: "Embed" },
|
|
16
|
+
{ name: "Custom Code" }
|
|
17
|
+
]
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
if (isBrowser()) {
|
|
21
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
22
|
+
type: "builder.sdkInfo",
|
|
23
|
+
data: {
|
|
24
|
+
target: "solid",
|
|
25
|
+
supportsPatchUpdates: false
|
|
26
|
+
}
|
|
27
|
+
}, "*");
|
|
28
|
+
window.addEventListener("message", ({ data }) => {
|
|
29
|
+
var _a2, _b;
|
|
30
|
+
if (data) {
|
|
31
|
+
switch (data.type) {
|
|
32
|
+
case "builder.evaluate": {
|
|
33
|
+
const text = data.data.text;
|
|
34
|
+
const args = data.data.arguments || [];
|
|
35
|
+
const id = data.data.id;
|
|
36
|
+
const fn = new Function(text);
|
|
37
|
+
let result;
|
|
38
|
+
let error = null;
|
|
39
|
+
try {
|
|
40
|
+
result = fn.apply(null, args);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
error = err;
|
|
43
|
+
}
|
|
44
|
+
if (error) {
|
|
45
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
46
|
+
type: "builder.evaluateError",
|
|
47
|
+
data: { id, error: error.message }
|
|
48
|
+
}, "*");
|
|
49
|
+
} else {
|
|
50
|
+
if (result && typeof result.then === "function") {
|
|
51
|
+
result.then((finalResult) => {
|
|
52
|
+
var _a3;
|
|
53
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
54
|
+
type: "builder.evaluateResult",
|
|
55
|
+
data: { id, result: finalResult }
|
|
56
|
+
}, "*");
|
|
57
|
+
}).catch(console.error);
|
|
58
|
+
} else {
|
|
59
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
60
|
+
type: "builder.evaluateResult",
|
|
61
|
+
data: { result, id }
|
|
62
|
+
}, "*");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|