@builder.io/sdk-solid 0.5.4 → 0.5.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.5.6
2
+
3
+ - No Changes.
4
+
5
+ ### 0.5.5
6
+
7
+ - Fix: remove `lru-cache` import and usage.
8
+
1
9
  ### 0.5.4
2
10
 
3
11
  - Fix build issues caused by extraneous `acorn` import.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./solid-index.jsx",
@@ -30,6 +30,14 @@
30
30
  "nx": {
31
31
  "implicitDependencies": [
32
32
  "@builder.io/sdks"
33
- ]
33
+ ],
34
+ "targets": {
35
+ "build": {
36
+ "dependsOn": [
37
+ "^build:solid",
38
+ "^build"
39
+ ]
40
+ }
41
+ }
34
42
  }
35
43
  }
@@ -1,6 +1,6 @@
1
1
  import { useContext } from "solid-js";
2
2
 
3
- import BuilderContext from "../context/builder.context";
3
+ import BuilderContext from "../context/builder.context.js";
4
4
 
5
5
  function BaseText(props) {
6
6
  const builderContext = useContext(BuilderContext);
@@ -2,9 +2,9 @@ import { Show, For, createSignal } from "solid-js";
2
2
 
3
3
  import { css } from "solid-styled-components";
4
4
 
5
- import Blocks from "../../components/blocks/blocks.jsx";
5
+ import Blocks from "../../components/blocks/blocks";
6
6
  import { getSizesForBreakpoints } from "../../constants/device-sizes.js";
7
- import InlinedStyles from "../../components/inlined-styles.jsx";
7
+ import InlinedStyles from "../../components/inlined-styles";
8
8
  import { TARGET } from "../../constants/target.js";
9
9
 
10
10
  function Columns(props) {
@@ -35,14 +35,14 @@ var __async = (__this, __arguments, generator) => {
35
35
  step((generator = generator.apply(__this, __arguments)).next());
36
36
  });
37
37
  };
38
- import { getContent } from "../../functions/get-content/index.js";
39
38
  import { logger } from "../../helpers/logger.js";
40
- const fetchContent = _0 => __async(void 0, [_0], function* ({
39
+ import { fetchOneEntry } from "../../index.js";
40
+ const fetchSymbolContent = _0 => __async(void 0, [_0], function* ({
41
41
  builderContextValue,
42
42
  symbol
43
43
  }) {
44
44
  if ((symbol == null ? void 0 : symbol.model) && (builderContextValue == null ? void 0 : builderContextValue.apiKey)) {
45
- return getContent(__spreadValues({
45
+ return fetchOneEntry(__spreadValues({
46
46
  model: symbol.model,
47
47
  apiKey: builderContextValue.apiKey,
48
48
  apiVersion: builderContextValue.apiVersion
@@ -57,4 +57,4 @@ const fetchContent = _0 => __async(void 0, [_0], function* ({
57
57
  }
58
58
  return void 0;
59
59
  });
60
- export { fetchContent }
60
+ export { fetchSymbolContent }
@@ -1,8 +1,8 @@
1
1
  import { onMount, on, createEffect, createSignal } from "solid-js";
2
2
 
3
- import ContentVariants from "../../components/content-variants/content-variants.jsx";
3
+ import ContentVariants from "../../components/content-variants/content-variants";
4
4
  import { filterAttrs } from "../helpers.js";
5
- import { fetchContent } from "./symbol.helpers.js";
5
+ import { fetchSymbolContent } from "./symbol.helpers.js";
6
6
 
7
7
  function Symbol(props) {
8
8
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
@@ -22,7 +22,7 @@ function Symbol(props) {
22
22
 
23
23
  function setContent() {
24
24
  if (contentToUse()) return;
25
- fetchContent({
25
+ fetchSymbolContent({
26
26
  symbol: props.symbol,
27
27
  builderContextValue: props.builderContext,
28
28
  }).then((newContent) => {
@@ -26,7 +26,7 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
- import { evaluate } from "../../functions/evaluate";
29
+ import { evaluate } from "../../functions/evaluate/index.js";
30
30
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
31
31
  const EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
32
32
  const isEmptyHtmlElement = tagName => {
@@ -3,16 +3,16 @@ import { Show, For, createSignal } from "solid-js";
3
3
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
4
4
  import { getBlockProperties } from "../../functions/get-block-properties.js";
5
5
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
6
- import BlockStyles from "./components/block-styles.jsx";
6
+ import BlockStyles from "./components/block-styles";
7
7
  import {
8
8
  getComponent,
9
9
  getRepeatItemData,
10
10
  isEmptyHtmlElement,
11
11
  } from "./block.helpers.js";
12
- import RepeatedBlock from "./components/repeated-block.jsx";
12
+ import RepeatedBlock from "./components/repeated-block";
13
13
  import { extractTextStyles } from "../../functions/extract-text-styles.js";
14
- import ComponentRef from "./components/component-ref/component-ref.jsx";
15
- import BlockWrapper from "./components/block-wrapper.jsx";
14
+ import ComponentRef from "./components/component-ref/component-ref";
15
+ import BlockWrapper from "./components/block-wrapper";
16
16
 
17
17
  function Block(props) {
18
18
  const [childrenContext, setChildrenContext] = createSignal(props.context);
@@ -8,7 +8,7 @@ import { TARGET } from "../../../constants/target.js";
8
8
  import { getProcessedBlock } from "../../../functions/get-processed-block.js";
9
9
  import { createCssClass } from "../../../helpers/css.js";
10
10
  import { checkIsDefined } from "../../../helpers/nullable.js";
11
- import InlinedStyles from "../../inlined-styles.jsx";
11
+ import InlinedStyles from "../../inlined-styles";
12
12
 
13
13
  function BlockStyles(props) {
14
14
  const [processedBlock, setProcessedBlock] = createSignal(
@@ -1,9 +1,9 @@
1
1
  import { Show, For, createSignal } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
3
 
4
- import BlockStyles from "../block-styles.jsx";
5
- import Block from "../../block.jsx";
6
- import InteractiveElement from "../interactive-element.jsx";
4
+ import BlockStyles from "../block-styles";
5
+ import Block from "../../block";
6
+ import InteractiveElement from "../interactive-element";
7
7
  import { getWrapperProps } from "./component-ref.helpers.js";
8
8
 
9
9
  function ComponentRef(props) {
@@ -1,7 +1,7 @@
1
1
  import { createSignal } from "solid-js";
2
2
 
3
- import BuilderContext from "../../../context/builder.context";
4
- import Block from "../block.jsx";
3
+ import BuilderContext from "../../../context/builder.context.js";
4
+ import Block from "../block";
5
5
 
6
6
  function RepeatedBlock(props) {
7
7
  const [store, setStore] = createSignal(props.repeatContext);
@@ -1,10 +1,10 @@
1
1
  import { useContext, Show, For } from "solid-js";
2
2
 
3
- import BlockStyles from "../block/components/block-styles.jsx";
4
- import Block from "../block/block.jsx";
5
- import BlocksWrapper from "./blocks-wrapper.jsx";
6
- import BuilderContext from "../../context/builder.context";
7
- import ComponentsContext from "../../context/components.context";
3
+ import BlockStyles from "../block/components/block-styles";
4
+ import Block from "../block/block";
5
+ import BlocksWrapper from "./blocks-wrapper";
6
+ import BuilderContext from "../../context/builder.context.js";
7
+ import ComponentsContext from "../../context/components.context.js";
8
8
 
9
9
  function Blocks(props) {
10
10
  const builderContext = useContext(BuilderContext);
@@ -1,12 +1,12 @@
1
1
  import { Show, onMount, on, createEffect, createSignal } from "solid-js";
2
2
 
3
- import { evaluate } from "../../../functions/evaluate";
3
+ import { evaluate } from "../../../functions/evaluate/index.js";
4
4
  import { fetch } from "../../../functions/get-fetch.js";
5
5
  import { isBrowser } from "../../../functions/is-browser.js";
6
6
  import { isEditing } from "../../../functions/is-editing.js";
7
7
  import { createRegisterComponentMessage } from "../../../functions/register-component.js";
8
8
  import { _track } from "../../../functions/track/index.js";
9
- import builderContext from "../../../context/builder.context";
9
+ import builderContext from "../../../context/builder.context.js";
10
10
  import {
11
11
  registerInsertMenu,
12
12
  setupBrowserForEditing,
@@ -14,7 +14,7 @@ import {
14
14
  import { checkIsDefined } from "../../../helpers/nullable.js";
15
15
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
16
16
  import { logger } from "../../../helpers/logger.js";
17
- import { getContent } from "../../../functions/get-content/index.js";
17
+ import { fetchOneEntry } from "../../../functions/get-content/index.js";
18
18
  import { isPreviewing } from "../../../functions/is-previewing.js";
19
19
  import { postPreviewContent } from "../../../helpers/preview-lru-cache/set.js";
20
20
 
@@ -263,7 +263,7 @@ function EnableEditor(props) {
263
263
  previewApiKey === props.apiKey &&
264
264
  (!props.content || searchParamPreviewId === props.content.id)
265
265
  ) {
266
- getContent({
266
+ fetchOneEntry({
267
267
  model: props.model,
268
268
  apiKey: props.apiKey,
269
269
  apiVersion: props.builderContextSignal.apiVersion,
@@ -1,6 +1,6 @@
1
1
  import { createSignal } from "solid-js";
2
2
 
3
- import InlinedStyles from "../../inlined-styles.jsx";
3
+ import InlinedStyles from "../../inlined-styles";
4
4
  import { getCss } from "./styles.helpers.js";
5
5
  import { getFontCss } from "./styles.helpers.js";
6
6
 
@@ -5,18 +5,18 @@ import {
5
5
  components,
6
6
  serializeComponentInfo,
7
7
  } from "../../functions/register-component.js";
8
- import Blocks from "../blocks/blocks.jsx";
9
- import ContentStyles from "./components/styles.jsx";
8
+ import Blocks from "../blocks/blocks";
9
+ import ContentStyles from "./components/styles";
10
10
  import {
11
11
  getContentInitialValue,
12
12
  getContextStateInitialValue,
13
13
  } from "./content.helpers.js";
14
14
  import { TARGET } from "../../constants/target.js";
15
15
  import { getRenderContentScriptString } from "../content-variants/helpers.js";
16
- import EnableEditor from "./components/enable-editor.jsx";
17
- import InlinedScript from "../inlined-script.jsx";
16
+ import EnableEditor from "./components/enable-editor";
17
+ import InlinedScript from "../inlined-script";
18
18
  import { wrapComponentRef } from "./wrap-component-ref.js";
19
- import ComponentsContext from "../../context/components.context";
19
+ import ComponentsContext from "../../context/components.context.js";
20
20
 
21
21
  function ContentComponent(props) {
22
22
  const [scriptStr, setScriptStr] = createSignal(
@@ -6,11 +6,11 @@ import {
6
6
  getVariants,
7
7
  getVariantsScriptString,
8
8
  } from "./helpers.js";
9
- import ContentComponent from "../content/content.jsx";
9
+ import ContentComponent from "../content/content";
10
10
  import { getDefaultCanTrack } from "../../helpers/canTrack.js";
11
- import InlinedStyles from "../inlined-styles.jsx";
11
+ import InlinedStyles from "../inlined-styles";
12
12
  import { handleABTestingSync } from "../../helpers/ab-tests.js";
13
- import InlinedScript from "../inlined-script.jsx";
13
+ import InlinedScript from "../inlined-script";
14
14
  import { TARGET } from "../../constants/target.js";
15
15
 
16
16
  function ContentVariants(props) {
@@ -1,2 +1 @@
1
- const SDK_VERSION = "UNKNOWN_VERSION";
2
- export { SDK_VERSION }
1
+ export const SDK_VERSION = "0.5.6"
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value
12
+ }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = value => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = value => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+ import { getBuilderSearchParams } from "./get-builder-search-params/index.js";
42
+ import { fetchOneEntry } from "./get-content/index.js";
43
+ const fetchBuilderProps = _args => __async(void 0, null, function* () {
44
+ var _a, _b, _c;
45
+ const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
46
+ const getContentArgs = __spreadProps(__spreadValues({}, _args), {
47
+ apiKey: _args.apiKey,
48
+ model: _args.model || "page",
49
+ userAttributes: __spreadValues(__spreadValues({}, _args.userAttributes), urlPath ? {
50
+ urlPath
51
+ } : {}),
52
+ options: getBuilderSearchParams(_args.searchParams || ((_c = _args.url) == null ? void 0 : _c.searchParams) || _args.options)
53
+ });
54
+ return {
55
+ apiKey: getContentArgs.apiKey,
56
+ model: getContentArgs.model,
57
+ content: yield fetchOneEntry(getContentArgs)
58
+ };
59
+ });
60
+ export { fetchBuilderProps }
@@ -47,9 +47,9 @@ import { fetch } from "../get-fetch.js";
47
47
  import { isBrowser } from "../is-browser.js";
48
48
  import { generateContentUrl } from "./generate-content-url.js";
49
49
  const checkContentHasResults = content => "results" in content;
50
- function getContent(options) {
50
+ function fetchOneEntry(options) {
51
51
  return __async(this, null, function* () {
52
- const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), {
52
+ const allContent = yield fetchEntries(__spreadProps(__spreadValues({}, options), {
53
53
  limit: 1
54
54
  }));
55
55
  if (allContent) {
@@ -58,13 +58,14 @@ function getContent(options) {
58
58
  return null;
59
59
  });
60
60
  }
61
- const fetchContent = options => __async(void 0, null, function* () {
61
+ const getContent = fetchOneEntry;
62
+ const _fetchContent = options => __async(void 0, null, function* () {
62
63
  const url = generateContentUrl(options);
63
64
  const res = yield fetch(url.href);
64
65
  const content = yield res.json();
65
66
  return content;
66
67
  });
67
- const processContentResult = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (options, content, url = generateContentUrl(options)) {
68
+ const _processContentResult = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (options, content, url = generateContentUrl(options)) {
68
69
  const canTrack = getDefaultCanTrack(options.canTrack);
69
70
  const isPreviewing = url.search.includes(`preview=`);
70
71
  if (TARGET === "rsc" && isPreviewing) {
@@ -91,11 +92,11 @@ const processContentResult = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2],
91
92
  }
92
93
  return content;
93
94
  });
94
- function getAllContent(options) {
95
+ function fetchEntries(options) {
95
96
  return __async(this, null, function* () {
96
97
  try {
97
98
  const url = generateContentUrl(options);
98
- const content = yield fetchContent(options);
99
+ const content = yield _fetchContent(options);
99
100
  if (!checkContentHasResults(content)) {
100
101
  logger.error("Error fetching data. ", {
101
102
  url,
@@ -104,11 +105,12 @@ function getAllContent(options) {
104
105
  });
105
106
  return null;
106
107
  }
107
- return processContentResult(options, content);
108
+ return _processContentResult(options, content);
108
109
  } catch (error) {
109
110
  logger.error("Error fetching data. ", error);
110
111
  return null;
111
112
  }
112
113
  });
113
114
  }
114
- export { getAllContent, getContent, processContentResult }
115
+ const getAllContent = fetchEntries;
116
+ export { _processContentResult, fetchEntries, fetchOneEntry, getAllContent, getContent }
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- import { evaluate } from "./evaluate";
21
+ import { evaluate } from "./evaluate/index.js";
22
22
  import { fastClone } from "./fast-clone.js";
23
23
  import { set } from "./set.js";
24
24
  import { transformBlock } from "./transform-block.js";
@@ -1,4 +1,4 @@
1
- import { isBrowser } from "./is-browser";
1
+ import { isBrowser } from "./is-browser.js";
2
2
  function isNonNodeServer() {
3
3
  const hasNode = () => {
4
4
  var _a;
@@ -1,8 +1,4 @@
1
- import { getIdFromSearchParams } from "./helpers";
2
- import { init } from "./init";
3
- function getPreviewContent(searchParams) {
4
- init();
5
- const id = getIdFromSearchParams(searchParams);
6
- return typeof id === "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id) : void 0;
1
+ function getPreviewContent(_searchParams) {
2
+ return void 0;
7
3
  }
8
4
  export { getPreviewContent }
@@ -1,10 +0,0 @@
1
- import { logger } from "../logger";
2
- const getIdFromSearchParams = searchParams => {
3
- const previewedModel = searchParams.get("preview");
4
- const previewedId = searchParams.get("overrides." + previewedModel);
5
- if (!previewedId) {
6
- logger.warn("No previewed ID found in search params.");
7
- }
8
- return previewedId;
9
- };
10
- export { getIdFromSearchParams }
@@ -1,10 +1,2 @@
1
- import { LRUCache } from "lru-cache";
2
- function init() {
3
- if (!globalThis._BUILDER_PREVIEW_LRU_CACHE) {
4
- globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
5
- max: 500,
6
- ttl: 1e3 * 60 * 5
7
- });
8
- }
9
- }
1
+ function init() {}
10
2
  export { init }
@@ -18,15 +18,11 @@ var __async = (__this, __arguments, generator) => {
18
18
  step((generator = generator.apply(__this, __arguments)).next());
19
19
  });
20
20
  };
21
- "use server";
22
- import { init } from "./init";
23
21
  function postPreviewContent(_0) {
24
22
  return __async(this, arguments, function* ({
25
23
  key,
26
24
  value
27
25
  }) {
28
- init();
29
- globalThis._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
30
26
  return {
31
27
  [key]: value
32
28
  };
@@ -2,10 +2,12 @@ import { default as default2 } from "../blocks/button/button";
2
2
  import { default as default3 } from "../blocks/columns/columns";
3
3
  import { default as default4 } from "../blocks/fragment/fragment";
4
4
  import { default as default5 } from "../blocks/image/image";
5
- import { default as default6 } from "../components/blocks/blocks";
6
- import { default as default7 } from "../blocks/section/section";
7
- import { default as default8 } from "../blocks/symbol/symbol";
8
- import { default as default9 } from "../blocks/text/text";
9
- import { default as default10 } from "../blocks/video/video";
10
- import { default as default11 } from "../components/content-variants/content-variants";
11
- export { default2 as Button, default3 as Columns, default4 as Fragment, default5 as Image, default6 as RenderBlocks, default11 as RenderContent, default7 as Section, default8 as Symbol, default9 as Text, default10 as Video }
5
+ import { default as default6 } from "../blocks/section/section";
6
+ import { default as default7 } from "../blocks/symbol/symbol";
7
+ import { default as default8 } from "../blocks/text/text";
8
+ import { default as default9 } from "../blocks/video/video";
9
+ import { default as Blocks } from "../components/blocks/blocks";
10
+ import { default as Content } from "../components/content-variants/content-variants";
11
+ const RenderBlocks = Blocks;
12
+ const RenderContent = Content;
13
+ export { Blocks, default2 as Button, default3 as Columns, Content, default4 as Fragment, default5 as Image, RenderBlocks, RenderContent, default6 as Section, default7 as Symbol, default8 as Text, default9 as Video }
package/src/index.js CHANGED
@@ -5,7 +5,8 @@ import { isPreviewing } from "./functions/is-previewing.js";
5
5
  import { createRegisterComponentMessage } from "./functions/register-component.js";
6
6
  import { register } from "./functions/register.js";
7
7
  import { setEditorSettings } from "./functions/set-editor-settings.js";
8
- import { getAllContent, getContent, processContentResult } from "./functions/get-content/index.js";
8
+ import { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from "./functions/get-content/index.js";
9
9
  import { getBuilderSearchParams } from "./functions/get-builder-search-params/index.js";
10
10
  import { track } from "./functions/track/index.js";
11
- export { createRegisterComponentMessage, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, processContentResult, register, setEditorSettings, track }
11
+ import { fetchBuilderProps } from "./functions/fetch-builder-props.js";
12
+ export { _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track }
@@ -1,13 +0,0 @@
1
- import { TARGET } from "../constants/target.js";
2
- function ifTarget({
3
- targets,
4
- doThing,
5
- elseThing
6
- }) {
7
- if (TARGET && targets.includes(TARGET)) {
8
- return doThing();
9
- } else {
10
- return elseThing == null ? void 0 : elseThing();
11
- }
12
- }
13
- export { ifTarget }