@builder.io/sdk-qwik 0.17.0 → 0.17.2

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 (129) hide show
  1. package/lib/browser/blocks/image/component-info.qwik.cjs +2 -7
  2. package/lib/browser/blocks/image/component-info.qwik.mjs +2 -7
  3. package/lib/browser/blocks/image/image.qwik.cjs +1 -1
  4. package/lib/browser/blocks/image/image.qwik.mjs +1 -1
  5. package/lib/browser/blocks/img/component-info.qwik.cjs +2 -8
  6. package/lib/browser/blocks/img/component-info.qwik.mjs +2 -8
  7. package/lib/browser/blocks/text/text.qwik.cjs +6 -19
  8. package/lib/browser/blocks/text/text.qwik.mjs +7 -20
  9. package/lib/browser/blocks/video/component-info.qwik.cjs +3 -7
  10. package/lib/browser/blocks/video/component-info.qwik.mjs +3 -7
  11. package/lib/browser/components/block/block.helpers.qwik.cjs +16 -5
  12. package/lib/browser/components/block/block.helpers.qwik.mjs +16 -5
  13. package/lib/browser/components/block/block.qwik.cjs +5 -5
  14. package/lib/browser/components/block/block.qwik.mjs +5 -5
  15. package/lib/browser/components/content/components/enable-editor.helpers.qwik.cjs +15 -0
  16. package/lib/browser/components/content/components/enable-editor.helpers.qwik.mjs +15 -0
  17. package/lib/browser/components/content/components/enable-editor.qwik.cjs +19 -7
  18. package/lib/browser/components/content/components/enable-editor.qwik.mjs +19 -7
  19. package/lib/browser/components/content/content.qwik.cjs +7 -18
  20. package/lib/browser/components/content/content.qwik.mjs +7 -18
  21. package/lib/browser/constants/file-types.qwik.cjs +72 -0
  22. package/lib/browser/constants/file-types.qwik.mjs +72 -0
  23. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  24. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  25. package/lib/browser/functions/extract-localized-values.qwik.cjs +37 -0
  26. package/lib/browser/functions/extract-localized-values.qwik.mjs +37 -0
  27. package/lib/browser/functions/get-block-component-options.qwik.cjs +18 -2
  28. package/lib/browser/functions/get-block-component-options.qwik.mjs +18 -2
  29. package/lib/browser/functions/get-content/generate-content-url.qwik.cjs +26 -2
  30. package/lib/browser/functions/get-content/generate-content-url.qwik.mjs +27 -3
  31. package/lib/browser/functions/get-processed-block.qwik.cjs +11 -12
  32. package/lib/browser/functions/get-processed-block.qwik.mjs +11 -12
  33. package/lib/browser/functions/register-component.qwik.cjs +1 -1
  34. package/lib/browser/functions/register-component.qwik.mjs +1 -1
  35. package/lib/browser/functions/traverse.qwik.cjs +31 -0
  36. package/lib/browser/functions/traverse.qwik.mjs +31 -0
  37. package/lib/browser/helpers/flatten.qwik.cjs +18 -0
  38. package/lib/browser/helpers/flatten.qwik.mjs +19 -1
  39. package/lib/edge/blocks/image/component-info.qwik.cjs +2 -7
  40. package/lib/edge/blocks/image/component-info.qwik.mjs +2 -7
  41. package/lib/edge/blocks/image/image.qwik.cjs +1 -1
  42. package/lib/edge/blocks/image/image.qwik.mjs +1 -1
  43. package/lib/edge/blocks/img/component-info.qwik.cjs +2 -8
  44. package/lib/edge/blocks/img/component-info.qwik.mjs +2 -8
  45. package/lib/edge/blocks/text/text.qwik.cjs +6 -19
  46. package/lib/edge/blocks/text/text.qwik.mjs +7 -20
  47. package/lib/edge/blocks/video/component-info.qwik.cjs +3 -7
  48. package/lib/edge/blocks/video/component-info.qwik.mjs +3 -7
  49. package/lib/edge/components/block/block.helpers.qwik.cjs +16 -5
  50. package/lib/edge/components/block/block.helpers.qwik.mjs +16 -5
  51. package/lib/edge/components/block/block.qwik.cjs +5 -5
  52. package/lib/edge/components/block/block.qwik.mjs +5 -5
  53. package/lib/edge/components/content/components/enable-editor.helpers.qwik.cjs +15 -0
  54. package/lib/edge/components/content/components/enable-editor.helpers.qwik.mjs +15 -0
  55. package/lib/edge/components/content/components/enable-editor.qwik.cjs +19 -7
  56. package/lib/edge/components/content/components/enable-editor.qwik.mjs +19 -7
  57. package/lib/edge/components/content/content.qwik.cjs +7 -18
  58. package/lib/edge/components/content/content.qwik.mjs +7 -18
  59. package/lib/edge/constants/file-types.qwik.cjs +72 -0
  60. package/lib/edge/constants/file-types.qwik.mjs +72 -0
  61. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  62. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  63. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.qwik.cjs +1 -4
  64. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.qwik.mjs +1 -4
  65. package/lib/edge/functions/extract-localized-values.qwik.cjs +37 -0
  66. package/lib/edge/functions/extract-localized-values.qwik.mjs +37 -0
  67. package/lib/edge/functions/get-block-component-options.qwik.cjs +18 -2
  68. package/lib/edge/functions/get-block-component-options.qwik.mjs +18 -2
  69. package/lib/edge/functions/get-content/generate-content-url.qwik.cjs +26 -2
  70. package/lib/edge/functions/get-content/generate-content-url.qwik.mjs +27 -3
  71. package/lib/edge/functions/get-processed-block.qwik.cjs +11 -12
  72. package/lib/edge/functions/get-processed-block.qwik.mjs +11 -12
  73. package/lib/edge/functions/register-component.qwik.cjs +1 -1
  74. package/lib/edge/functions/register-component.qwik.mjs +1 -1
  75. package/lib/edge/functions/traverse.qwik.cjs +31 -0
  76. package/lib/edge/functions/traverse.qwik.mjs +31 -0
  77. package/lib/edge/helpers/flatten.qwik.cjs +18 -0
  78. package/lib/edge/helpers/flatten.qwik.mjs +19 -1
  79. package/lib/node/blocks/image/component-info.qwik.cjs +2 -7
  80. package/lib/node/blocks/image/component-info.qwik.mjs +2 -7
  81. package/lib/node/blocks/image/image.qwik.cjs +1 -1
  82. package/lib/node/blocks/image/image.qwik.mjs +1 -1
  83. package/lib/node/blocks/img/component-info.qwik.cjs +2 -8
  84. package/lib/node/blocks/img/component-info.qwik.mjs +2 -8
  85. package/lib/node/blocks/text/text.qwik.cjs +6 -19
  86. package/lib/node/blocks/text/text.qwik.mjs +7 -20
  87. package/lib/node/blocks/video/component-info.qwik.cjs +3 -7
  88. package/lib/node/blocks/video/component-info.qwik.mjs +3 -7
  89. package/lib/node/components/block/block.helpers.qwik.cjs +16 -5
  90. package/lib/node/components/block/block.helpers.qwik.mjs +16 -5
  91. package/lib/node/components/block/block.qwik.cjs +5 -5
  92. package/lib/node/components/block/block.qwik.mjs +5 -5
  93. package/lib/node/components/content/components/enable-editor.helpers.qwik.cjs +15 -0
  94. package/lib/node/components/content/components/enable-editor.helpers.qwik.mjs +15 -0
  95. package/lib/node/components/content/components/enable-editor.qwik.cjs +19 -7
  96. package/lib/node/components/content/components/enable-editor.qwik.mjs +19 -7
  97. package/lib/node/components/content/content.qwik.cjs +7 -18
  98. package/lib/node/components/content/content.qwik.mjs +7 -18
  99. package/lib/node/constants/file-types.qwik.cjs +72 -0
  100. package/lib/node/constants/file-types.qwik.mjs +72 -0
  101. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  102. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  103. package/lib/node/functions/extract-localized-values.qwik.cjs +37 -0
  104. package/lib/node/functions/extract-localized-values.qwik.mjs +37 -0
  105. package/lib/node/functions/get-block-component-options.qwik.cjs +18 -2
  106. package/lib/node/functions/get-block-component-options.qwik.mjs +18 -2
  107. package/lib/node/functions/get-content/generate-content-url.qwik.cjs +26 -2
  108. package/lib/node/functions/get-content/generate-content-url.qwik.mjs +27 -3
  109. package/lib/node/functions/get-processed-block.qwik.cjs +11 -12
  110. package/lib/node/functions/get-processed-block.qwik.mjs +11 -12
  111. package/lib/node/functions/register-component.qwik.cjs +1 -1
  112. package/lib/node/functions/register-component.qwik.mjs +1 -1
  113. package/lib/node/functions/traverse.qwik.cjs +31 -0
  114. package/lib/node/functions/traverse.qwik.mjs +31 -0
  115. package/lib/node/helpers/flatten.qwik.cjs +18 -0
  116. package/lib/node/helpers/flatten.qwik.mjs +19 -1
  117. package/package.json +1 -1
  118. package/types/src/components/block/block.helpers.d.ts +6 -3
  119. package/types/src/components/content/components/enable-editor.helpers.d.ts +11 -0
  120. package/types/src/constants/file-types.d.ts +2 -0
  121. package/types/src/constants/sdk-version.d.ts +1 -1
  122. package/types/src/context/types.d.ts +1 -0
  123. package/types/src/functions/extract-localized-values.d.ts +2 -0
  124. package/types/src/functions/get-block-component-options.d.ts +2 -1
  125. package/types/src/functions/get-processed-block.d.ts +1 -6
  126. package/types/src/functions/traverse.d.ts +34 -0
  127. package/types/src/helpers/flatten.d.ts +6 -0
  128. package/types/src/server-index.d.ts +1 -1
  129. package/types/src/types/components.d.ts +3 -0
@@ -13,7 +13,7 @@ const enableEditor = require("./components/enable-editor.qwik.cjs");
13
13
  const styles = require("./components/styles.qwik.cjs");
14
14
  const content_helpers = require("./content.helpers.qwik.cjs");
15
15
  const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
16
- var _a, _b, _c, _d;
16
+ var _a, _b;
17
17
  qwik._jsxBranch();
18
18
  const state = qwik.useStore({
19
19
  builderContextSignal: {
@@ -34,13 +34,7 @@ const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
34
34
  apiVersion: props.apiVersion,
35
35
  componentInfos: [
36
36
  ...builderRegisteredComponents.getDefaultRegisteredComponents(),
37
- ...((_a = props.customComponents) == null ? void 0 : _a.filter(({ models }) => {
38
- if (!(models == null ? void 0 : models.length))
39
- return true;
40
- if (!props.model)
41
- return true;
42
- return models.includes(props.model);
43
- })) || []
37
+ ...props.customComponents || []
44
38
  ].reduce((acc, { component: _, ...info }) => ({
45
39
  ...acc,
46
40
  [info.name]: registerComponent.serializeIncludingFunctions(info)
@@ -48,17 +42,12 @@ const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
48
42
  inheritedStyles: {},
49
43
  BlocksWrapper: props.blocksWrapper || "div",
50
44
  BlocksWrapperProps: props.blocksWrapperProps || {},
51
- nonce: props.nonce || ""
45
+ nonce: props.nonce || "",
46
+ model: props.model || ""
52
47
  },
53
48
  registeredComponents: [
54
49
  ...builderRegisteredComponents.getDefaultRegisteredComponents(),
55
- ...((_b = props.customComponents) == null ? void 0 : _b.filter(({ models }) => {
56
- if (!(models == null ? void 0 : models.length))
57
- return true;
58
- if (!props.model)
59
- return true;
60
- return models.includes(props.model);
61
- })) || []
50
+ ...props.customComponents || []
62
51
  ].reduce((acc, { component, ...info }) => ({
63
52
  ...acc,
64
53
  [info.name]: {
@@ -68,9 +57,9 @@ const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
68
57
  }), {}),
69
58
  scriptStr: helpers.getUpdateVariantVisibilityScript({
70
59
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
71
- variationId: (_c = props.content) == null ? void 0 : _c.testVariationId,
60
+ variationId: (_a = props.content) == null ? void 0 : _a.testVariationId,
72
61
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
73
- contentId: (_d = props.content) == null ? void 0 : _d.id
62
+ contentId: (_b = props.content) == null ? void 0 : _b.id
74
63
  })
75
64
  }, {
76
65
  deep: true
@@ -11,7 +11,7 @@ import { EnableEditor } from "./components/enable-editor.qwik.mjs";
11
11
  import { ContentStyles } from "./components/styles.qwik.mjs";
12
12
  import { getContentInitialValue, getRootStateInitialValue } from "./content.helpers.qwik.mjs";
13
13
  const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
14
- var _a, _b, _c, _d;
14
+ var _a, _b;
15
15
  _jsxBranch();
16
16
  const state = useStore({
17
17
  builderContextSignal: {
@@ -32,13 +32,7 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
32
32
  apiVersion: props.apiVersion,
33
33
  componentInfos: [
34
34
  ...getDefaultRegisteredComponents(),
35
- ...((_a = props.customComponents) == null ? void 0 : _a.filter(({ models }) => {
36
- if (!(models == null ? void 0 : models.length))
37
- return true;
38
- if (!props.model)
39
- return true;
40
- return models.includes(props.model);
41
- })) || []
35
+ ...props.customComponents || []
42
36
  ].reduce((acc, { component: _, ...info }) => ({
43
37
  ...acc,
44
38
  [info.name]: serializeIncludingFunctions(info)
@@ -46,17 +40,12 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
46
40
  inheritedStyles: {},
47
41
  BlocksWrapper: props.blocksWrapper || "div",
48
42
  BlocksWrapperProps: props.blocksWrapperProps || {},
49
- nonce: props.nonce || ""
43
+ nonce: props.nonce || "",
44
+ model: props.model || ""
50
45
  },
51
46
  registeredComponents: [
52
47
  ...getDefaultRegisteredComponents(),
53
- ...((_b = props.customComponents) == null ? void 0 : _b.filter(({ models }) => {
54
- if (!(models == null ? void 0 : models.length))
55
- return true;
56
- if (!props.model)
57
- return true;
58
- return models.includes(props.model);
59
- })) || []
48
+ ...props.customComponents || []
60
49
  ].reduce((acc, { component, ...info }) => ({
61
50
  ...acc,
62
51
  [info.name]: {
@@ -66,9 +55,9 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
66
55
  }), {}),
67
56
  scriptStr: getUpdateVariantVisibilityScript({
68
57
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
69
- variationId: (_c = props.content) == null ? void 0 : _c.testVariationId,
58
+ variationId: (_a = props.content) == null ? void 0 : _a.testVariationId,
70
59
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
71
- contentId: (_d = props.content) == null ? void 0 : _d.id
60
+ contentId: (_b = props.content) == null ? void 0 : _b.id
72
61
  })
73
62
  }, {
74
63
  deep: true
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const IMAGE_FILE_TYPES = [
4
+ "jpeg",
5
+ "jpg",
6
+ "png",
7
+ "svg",
8
+ "webp",
9
+ "gif",
10
+ "jfif",
11
+ "pjpeg",
12
+ "pjp",
13
+ "apng",
14
+ "avif",
15
+ "tif",
16
+ "tiff",
17
+ "heif",
18
+ "bmp",
19
+ "eps",
20
+ "raw",
21
+ "cr2",
22
+ "nef",
23
+ "orf",
24
+ "sr2",
25
+ "psd",
26
+ "heic",
27
+ "dib",
28
+ "ai"
29
+ ];
30
+ const VIDEO_FILE_TYPES = [
31
+ "mp4",
32
+ "webm",
33
+ "mkv",
34
+ "flv",
35
+ "vob",
36
+ "ogv",
37
+ "ogg",
38
+ "drc",
39
+ "gif",
40
+ "gifv",
41
+ "mng",
42
+ "avi",
43
+ "mov",
44
+ "qt",
45
+ "mts",
46
+ "m2ts",
47
+ "ts",
48
+ "wmv",
49
+ "yuv",
50
+ "rm",
51
+ "rmvb",
52
+ "viv",
53
+ "asf",
54
+ "amv",
55
+ "m4p",
56
+ "mpeg",
57
+ "mpe",
58
+ "m2v",
59
+ "m4v",
60
+ "svi",
61
+ "3gp",
62
+ "3g2",
63
+ "mxf",
64
+ "roq",
65
+ "nsv",
66
+ "f4v",
67
+ "f4p",
68
+ "f4a",
69
+ "f4b"
70
+ ];
71
+ exports.IMAGE_FILE_TYPES = IMAGE_FILE_TYPES;
72
+ exports.VIDEO_FILE_TYPES = VIDEO_FILE_TYPES;
@@ -0,0 +1,72 @@
1
+ const IMAGE_FILE_TYPES = [
2
+ "jpeg",
3
+ "jpg",
4
+ "png",
5
+ "svg",
6
+ "webp",
7
+ "gif",
8
+ "jfif",
9
+ "pjpeg",
10
+ "pjp",
11
+ "apng",
12
+ "avif",
13
+ "tif",
14
+ "tiff",
15
+ "heif",
16
+ "bmp",
17
+ "eps",
18
+ "raw",
19
+ "cr2",
20
+ "nef",
21
+ "orf",
22
+ "sr2",
23
+ "psd",
24
+ "heic",
25
+ "dib",
26
+ "ai"
27
+ ];
28
+ const VIDEO_FILE_TYPES = [
29
+ "mp4",
30
+ "webm",
31
+ "mkv",
32
+ "flv",
33
+ "vob",
34
+ "ogv",
35
+ "ogg",
36
+ "drc",
37
+ "gif",
38
+ "gifv",
39
+ "mng",
40
+ "avi",
41
+ "mov",
42
+ "qt",
43
+ "mts",
44
+ "m2ts",
45
+ "ts",
46
+ "wmv",
47
+ "yuv",
48
+ "rm",
49
+ "rmvb",
50
+ "viv",
51
+ "asf",
52
+ "amv",
53
+ "m4p",
54
+ "mpeg",
55
+ "mpe",
56
+ "m2v",
57
+ "m4v",
58
+ "svi",
59
+ "3gp",
60
+ "3g2",
61
+ "mxf",
62
+ "roq",
63
+ "nsv",
64
+ "f4v",
65
+ "f4p",
66
+ "f4a",
67
+ "f4b"
68
+ ];
69
+ export {
70
+ IMAGE_FILE_TYPES,
71
+ VIDEO_FILE_TYPES
72
+ };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.17.0";
3
+ const SDK_VERSION = "0.17.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.17.0";
1
+ const SDK_VERSION = "0.17.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const traverse = require("./traverse.qwik.cjs");
4
+ function isLocalizedField(value) {
5
+ return value && typeof value === "object" && value["@type"] === "@builder.io/core:LocalizedValue";
6
+ }
7
+ function containsLocalizedValues(data) {
8
+ if (!data || !Object.getOwnPropertyNames(data).length)
9
+ return false;
10
+ let hasLocalizedValues = false;
11
+ traverse.traverse(data, (value) => {
12
+ if (isLocalizedField(value)) {
13
+ hasLocalizedValues = true;
14
+ return;
15
+ }
16
+ });
17
+ return hasLocalizedValues;
18
+ }
19
+ function extractLocalizedValues(data, locale) {
20
+ if (!data || !Object.getOwnPropertyNames(data).length)
21
+ return {};
22
+ traverse.traverse(data, (value, update) => {
23
+ if (isLocalizedField(value))
24
+ update(value[locale] ?? void 0);
25
+ });
26
+ return data;
27
+ }
28
+ function resolveLocalizedValues(block, locale) {
29
+ var _a, _b;
30
+ if (((_a = block.component) == null ? void 0 : _a.options) && containsLocalizedValues((_b = block.component) == null ? void 0 : _b.options)) {
31
+ if (!locale)
32
+ console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization");
33
+ block.component.options = extractLocalizedValues(block.component.options, locale ?? "Default");
34
+ }
35
+ return block;
36
+ }
37
+ exports.resolveLocalizedValues = resolveLocalizedValues;
@@ -0,0 +1,37 @@
1
+ import { traverse } from "./traverse.qwik.mjs";
2
+ function isLocalizedField(value) {
3
+ return value && typeof value === "object" && value["@type"] === "@builder.io/core:LocalizedValue";
4
+ }
5
+ function containsLocalizedValues(data) {
6
+ if (!data || !Object.getOwnPropertyNames(data).length)
7
+ return false;
8
+ let hasLocalizedValues = false;
9
+ traverse(data, (value) => {
10
+ if (isLocalizedField(value)) {
11
+ hasLocalizedValues = true;
12
+ return;
13
+ }
14
+ });
15
+ return hasLocalizedValues;
16
+ }
17
+ function extractLocalizedValues(data, locale) {
18
+ if (!data || !Object.getOwnPropertyNames(data).length)
19
+ return {};
20
+ traverse(data, (value, update) => {
21
+ if (isLocalizedField(value))
22
+ update(value[locale] ?? void 0);
23
+ });
24
+ return data;
25
+ }
26
+ function resolveLocalizedValues(block, locale) {
27
+ var _a, _b;
28
+ if (((_a = block.component) == null ? void 0 : _a.options) && containsLocalizedValues((_b = block.component) == null ? void 0 : _b.options)) {
29
+ if (!locale)
30
+ console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization");
31
+ block.component.options = extractLocalizedValues(block.component.options, locale ?? "Default");
32
+ }
33
+ return block;
34
+ }
35
+ export {
36
+ resolveLocalizedValues
37
+ };
@@ -1,10 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function getBlockComponentOptions(block) {
3
+ const evaluate = require("./evaluate/evaluate.qwik.cjs");
4
+ function getBlockComponentOptions(block, context) {
4
5
  var _a;
5
6
  return {
6
7
  ...(_a = block.component) == null ? void 0 : _a.options,
7
- ...block.options
8
+ ...block.options,
9
+ ...evaluateTextComponentTextOption(block, context)
8
10
  };
9
11
  }
12
+ const evaluateTextComponentTextOption = (block, context) => {
13
+ var _a, _b;
14
+ if (((_a = block.component) == null ? void 0 : _a.name) === "Text" && ((_b = block.component.options) == null ? void 0 : _b.text) && typeof block.component.options.text === "string")
15
+ return {
16
+ ...block.component.options,
17
+ text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate.evaluate({
18
+ code: group,
19
+ context,
20
+ localState: context.localState,
21
+ rootState: context.rootState,
22
+ rootSetState: context.rootSetState
23
+ }))
24
+ };
25
+ };
10
26
  exports.getBlockComponentOptions = getBlockComponentOptions;
@@ -1,10 +1,26 @@
1
- function getBlockComponentOptions(block) {
1
+ import { evaluate } from "./evaluate/evaluate.qwik.mjs";
2
+ function getBlockComponentOptions(block, context) {
2
3
  var _a;
3
4
  return {
4
5
  ...(_a = block.component) == null ? void 0 : _a.options,
5
- ...block.options
6
+ ...block.options,
7
+ ...evaluateTextComponentTextOption(block, context)
6
8
  };
7
9
  }
10
+ const evaluateTextComponentTextOption = (block, context) => {
11
+ var _a, _b;
12
+ if (((_a = block.component) == null ? void 0 : _a.name) === "Text" && ((_b = block.component.options) == null ? void 0 : _b.text) && typeof block.component.options.text === "string")
13
+ return {
14
+ ...block.component.options,
15
+ text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
16
+ code: group,
17
+ context,
18
+ localState: context.localState,
19
+ rootState: context.rootState,
20
+ rootSetState: context.rootSetState
21
+ }))
22
+ };
23
+ };
8
24
  export {
9
25
  getBlockComponentOptions
10
26
  };
@@ -4,6 +4,7 @@ const flatten = require("../../helpers/flatten.qwik.cjs");
4
4
  const search = require("../../helpers/search/search.qwik.cjs");
5
5
  const apiVersion = require("../../types/api-version.qwik.cjs");
6
6
  const index = require("../get-builder-search-params/index.qwik.cjs");
7
+ const isBrowser = require("../is-browser.qwik.cjs");
7
8
  const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
8
9
  const generateContentUrl = (options) => {
9
10
  const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
@@ -21,7 +22,7 @@ const generateContentUrl = (options) => {
21
22
  url.searchParams.set("noTraverse", String(noTraverse));
22
23
  url.searchParams.set("includeRefs", String(true));
23
24
  const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
24
- let finalUserAttributes = userAttributes;
25
+ let finalUserAttributes = userAttributes || {};
25
26
  if (finalLocale) {
26
27
  url.searchParams.set("locale", finalLocale);
27
28
  finalUserAttributes = {
@@ -53,10 +54,14 @@ const generateContentUrl = (options) => {
53
54
  ...index.getBuilderSearchParamsFromWindow(),
54
55
  ...search.normalizeSearchParams(options.options || {})
55
56
  };
57
+ finalUserAttributes = {
58
+ ...finalUserAttributes,
59
+ ...getUserAttributesAsJSON(queryOptions)
60
+ };
56
61
  const flattened = flatten.flatten(queryOptions);
57
62
  for (const key in flattened)
58
63
  url.searchParams.set(key, String(flattened[key]));
59
- if (finalUserAttributes)
64
+ if (Object.keys(finalUserAttributes).length > 0)
60
65
  url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
61
66
  if (query) {
62
67
  const flattened2 = flatten.flattenMongoQuery({
@@ -67,4 +72,23 @@ const generateContentUrl = (options) => {
67
72
  }
68
73
  return url;
69
74
  };
75
+ const getUserAttributesFromQueryOptions = (queryOptions) => {
76
+ const newUserAttributes = {};
77
+ for (const key in queryOptions)
78
+ if (key.startsWith("userAttributes.")) {
79
+ newUserAttributes[key] = queryOptions[key];
80
+ delete queryOptions[key];
81
+ }
82
+ return newUserAttributes;
83
+ };
84
+ const getUserAttributesAsJSON = (queryOptions) => {
85
+ if (isBrowser.isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
86
+ queryOptions["userAttributes.urlPath"] = window.location.pathname;
87
+ queryOptions["userAttributes.host"] = window.location.host;
88
+ const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
89
+ const { userAttributes } = flatten.unflatten(queryOptionsForUserAttributes);
90
+ return userAttributes;
91
+ }
92
+ return {};
93
+ };
70
94
  exports.generateContentUrl = generateContentUrl;
@@ -1,7 +1,8 @@
1
- import { flatten, flattenMongoQuery } from "../../helpers/flatten.qwik.mjs";
1
+ import { flatten, flattenMongoQuery, unflatten } from "../../helpers/flatten.qwik.mjs";
2
2
  import { normalizeSearchParams } from "../../helpers/search/search.qwik.mjs";
3
3
  import { DEFAULT_API_VERSION } from "../../types/api-version.qwik.mjs";
4
4
  import { getBuilderSearchParamsFromWindow } from "../get-builder-search-params/index.qwik.mjs";
5
+ import { isBrowser } from "../is-browser.qwik.mjs";
5
6
  const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
6
7
  const generateContentUrl = (options) => {
7
8
  const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
@@ -19,7 +20,7 @@ const generateContentUrl = (options) => {
19
20
  url.searchParams.set("noTraverse", String(noTraverse));
20
21
  url.searchParams.set("includeRefs", String(true));
21
22
  const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
22
- let finalUserAttributes = userAttributes;
23
+ let finalUserAttributes = userAttributes || {};
23
24
  if (finalLocale) {
24
25
  url.searchParams.set("locale", finalLocale);
25
26
  finalUserAttributes = {
@@ -51,10 +52,14 @@ const generateContentUrl = (options) => {
51
52
  ...getBuilderSearchParamsFromWindow(),
52
53
  ...normalizeSearchParams(options.options || {})
53
54
  };
55
+ finalUserAttributes = {
56
+ ...finalUserAttributes,
57
+ ...getUserAttributesAsJSON(queryOptions)
58
+ };
54
59
  const flattened = flatten(queryOptions);
55
60
  for (const key in flattened)
56
61
  url.searchParams.set(key, String(flattened[key]));
57
- if (finalUserAttributes)
62
+ if (Object.keys(finalUserAttributes).length > 0)
58
63
  url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
59
64
  if (query) {
60
65
  const flattened2 = flattenMongoQuery({
@@ -65,6 +70,25 @@ const generateContentUrl = (options) => {
65
70
  }
66
71
  return url;
67
72
  };
73
+ const getUserAttributesFromQueryOptions = (queryOptions) => {
74
+ const newUserAttributes = {};
75
+ for (const key in queryOptions)
76
+ if (key.startsWith("userAttributes.")) {
77
+ newUserAttributes[key] = queryOptions[key];
78
+ delete queryOptions[key];
79
+ }
80
+ return newUserAttributes;
81
+ };
82
+ const getUserAttributesAsJSON = (queryOptions) => {
83
+ if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
84
+ queryOptions["userAttributes.urlPath"] = window.location.pathname;
85
+ queryOptions["userAttributes.host"] = window.location.host;
86
+ const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
87
+ const { userAttributes } = unflatten(queryOptionsForUserAttributes);
88
+ return userAttributes;
89
+ }
90
+ return {};
91
+ };
68
92
  export {
69
93
  generateContentUrl
70
94
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const target = require("../constants/target.qwik.cjs");
4
4
  const omit = require("../helpers/omit.qwik.cjs");
5
5
  const evaluate = require("./evaluate/evaluate.qwik.cjs");
6
+ const extractLocalizedValues = require("./extract-localized-values.qwik.cjs");
6
7
  const fastClone = require("./fast-clone.qwik.cjs");
7
8
  const set = require("./set.qwik.cjs");
8
9
  const transformBlock = require("./transform-block.qwik.cjs");
@@ -71,18 +72,16 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
71
72
  }
72
73
  return copied;
73
74
  };
74
- function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
75
- const transformedBlock = transformBlock.transformBlock(block);
76
- if (shouldEvaluateBindings)
77
- return evaluateBindings({
78
- block: transformedBlock,
79
- localState,
80
- rootState,
81
- rootSetState,
82
- context
83
- });
84
- else
85
- return transformedBlock;
75
+ function getProcessedBlock({ block, context, localState, rootState, rootSetState }) {
76
+ let transformedBlock = extractLocalizedValues.resolveLocalizedValues(block, rootState.locale);
77
+ transformedBlock = transformBlock.transformBlock(transformedBlock);
78
+ return evaluateBindings({
79
+ block: transformedBlock,
80
+ localState,
81
+ rootState,
82
+ rootSetState,
83
+ context
84
+ });
86
85
  }
87
86
  exports.deepCloneWithConditions = deepCloneWithConditions;
88
87
  exports.getProcessedBlock = getProcessedBlock;
@@ -1,6 +1,7 @@
1
1
  import { TARGET } from "../constants/target.qwik.mjs";
2
2
  import { omit } from "../helpers/omit.qwik.mjs";
3
3
  import { evaluate } from "./evaluate/evaluate.qwik.mjs";
4
+ import { resolveLocalizedValues } from "./extract-localized-values.qwik.mjs";
4
5
  import { fastClone } from "./fast-clone.qwik.mjs";
5
6
  import { set } from "./set.qwik.mjs";
6
7
  import { transformBlock } from "./transform-block.qwik.mjs";
@@ -69,18 +70,16 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
69
70
  }
70
71
  return copied;
71
72
  };
72
- function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
73
- const transformedBlock = transformBlock(block);
74
- if (shouldEvaluateBindings)
75
- return evaluateBindings({
76
- block: transformedBlock,
77
- localState,
78
- rootState,
79
- rootSetState,
80
- context
81
- });
82
- else
83
- return transformedBlock;
73
+ function getProcessedBlock({ block, context, localState, rootState, rootSetState }) {
74
+ let transformedBlock = resolveLocalizedValues(block, rootState.locale);
75
+ transformedBlock = transformBlock(transformedBlock);
76
+ return evaluateBindings({
77
+ block: transformedBlock,
78
+ localState,
79
+ rootState,
80
+ rootSetState,
81
+ context
82
+ });
84
83
  }
85
84
  export {
86
85
  deepCloneWithConditions,
@@ -7,7 +7,7 @@ const createRegisterComponentMessage = (info) => ({
7
7
  const serializeFn = (fnValue) => {
8
8
  const fnStr = fnValue.toString().trim();
9
9
  const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
10
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
10
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
11
11
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
12
12
  };
13
13
  function serializeIncludingFunctions(info) {
@@ -5,7 +5,7 @@ const createRegisterComponentMessage = (info) => ({
5
5
  const serializeFn = (fnValue) => {
6
6
  const fnStr = fnValue.toString().trim();
7
7
  const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
8
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
8
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
9
9
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
10
10
  };
11
11
  function serializeIncludingFunctions(info) {
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function traverse(obj, callback, parent = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
4
+ if (obj == null || typeof obj !== "object") {
5
+ callback(obj, (newValue) => {
6
+ if (parent !== null && key !== null)
7
+ parent[key] = newValue;
8
+ });
9
+ return;
10
+ }
11
+ if (visited.has(obj))
12
+ return;
13
+ visited.add(obj);
14
+ if (Array.isArray(obj))
15
+ obj.forEach((item, index) => {
16
+ const update = (newValue) => {
17
+ obj[index] = newValue;
18
+ };
19
+ callback(item, update);
20
+ traverse(item, callback, obj, index, visited);
21
+ });
22
+ else
23
+ Object.entries(obj).forEach(([key2, value]) => {
24
+ const update = (newValue) => {
25
+ obj[key2] = newValue;
26
+ };
27
+ callback(value, update);
28
+ traverse(value, callback, obj, key2, visited);
29
+ });
30
+ }
31
+ exports.traverse = traverse;