@builder.io/sdk-react-nextjs 0.17.8 → 0.18.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.
Files changed (51) hide show
  1. package/lib/browser/blocks/symbol/symbol.cjs +1 -1
  2. package/lib/browser/blocks/symbol/symbol.mjs +20 -20
  3. package/lib/browser/blocks/video/video.cjs +1 -1
  4. package/lib/browser/blocks/video/video.mjs +54 -17
  5. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  6. package/lib/browser/components/content/components/enable-editor.mjs +68 -62
  7. package/lib/browser/components/content/content.cjs +1 -1
  8. package/lib/browser/components/content/content.mjs +1 -1
  9. package/lib/browser/constants/sdk-version.cjs +1 -1
  10. package/lib/browser/constants/sdk-version.mjs +1 -1
  11. package/lib/browser/helpers/subscribe-to-editor.cjs +1 -1
  12. package/lib/browser/helpers/subscribe-to-editor.mjs +35 -20
  13. package/lib/browser/scripts/init-editing.cjs +1 -1
  14. package/lib/browser/scripts/init-editing.mjs +9 -7
  15. package/lib/edge/blocks/symbol/symbol.cjs +1 -1
  16. package/lib/edge/blocks/symbol/symbol.mjs +20 -20
  17. package/lib/edge/blocks/video/video.cjs +1 -1
  18. package/lib/edge/blocks/video/video.mjs +54 -17
  19. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  20. package/lib/edge/components/content/components/enable-editor.mjs +68 -62
  21. package/lib/edge/components/content/content.cjs +1 -1
  22. package/lib/edge/components/content/content.mjs +1 -1
  23. package/lib/edge/constants/sdk-version.cjs +1 -1
  24. package/lib/edge/constants/sdk-version.mjs +1 -1
  25. package/lib/edge/helpers/subscribe-to-editor.cjs +1 -1
  26. package/lib/edge/helpers/subscribe-to-editor.mjs +35 -20
  27. package/lib/edge/scripts/init-editing.cjs +1 -1
  28. package/lib/edge/scripts/init-editing.mjs +9 -7
  29. package/lib/node/blocks/symbol/symbol.cjs +1 -1
  30. package/lib/node/blocks/symbol/symbol.mjs +20 -20
  31. package/lib/node/blocks/video/video.cjs +1 -1
  32. package/lib/node/blocks/video/video.mjs +54 -17
  33. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  34. package/lib/node/components/content/components/enable-editor.mjs +68 -62
  35. package/lib/node/components/content/content.cjs +1 -1
  36. package/lib/node/components/content/content.mjs +1 -1
  37. package/lib/node/constants/sdk-version.cjs +1 -1
  38. package/lib/node/constants/sdk-version.mjs +1 -1
  39. package/lib/node/helpers/subscribe-to-editor.cjs +1 -1
  40. package/lib/node/helpers/subscribe-to-editor.mjs +35 -20
  41. package/lib/node/scripts/init-editing.cjs +1 -1
  42. package/lib/node/scripts/init-editing.mjs +9 -7
  43. package/package.json +1 -1
  44. package/types/cjs/components/content-variants/content-variants.types.d.ts +2 -2
  45. package/types/cjs/constants/sdk-version.d.ts +1 -1
  46. package/types/cjs/helpers/subscribe-to-editor.d.ts +15 -13
  47. package/types/cjs/scripts/init-editing.d.ts +3 -1
  48. package/types/esm/components/content-variants/content-variants.types.d.ts +2 -2
  49. package/types/esm/constants/sdk-version.d.ts +1 -1
  50. package/types/esm/helpers/subscribe-to-editor.d.ts +15 -13
  51. package/types/esm/scripts/init-editing.d.ts +3 -1
@@ -27,7 +27,7 @@ const S = () => {
27
27
  });
28
28
  };
29
29
  let m = !1;
30
- const x = (a = {}) => {
30
+ const x = (r) => {
31
31
  var n, i;
32
32
  m || (m = !0, b() && ((n = window.parent) == null || n.postMessage({
33
33
  type: "builder.sdkInfo",
@@ -39,17 +39,19 @@ const x = (a = {}) => {
39
39
  // scope our '+ add block' button styling
40
40
  supportsAddBlockScoping: !0,
41
41
  supportsCustomBreakpoints: !0,
42
+ modelName: r.modelName,
43
+ apiKey: r.apiKey,
42
44
  supportsXSmallBreakpoint: !0,
43
45
  blockLevelPersonalization: !0
44
46
  }
45
47
  }, "*"), (i = window.parent) == null || i.postMessage({
46
48
  type: "builder.updateContent",
47
49
  data: {
48
- options: a
50
+ options: r
49
51
  }
50
52
  }, "*"), window.addEventListener("message", (u) => {
51
53
  var p, d;
52
- if (!B(a.trustedHosts, u))
54
+ if (!B(r.trustedHosts, u))
53
55
  return;
54
56
  const {
55
57
  data: e
@@ -57,7 +59,7 @@ const x = (a = {}) => {
57
59
  if (e != null && e.type)
58
60
  switch (e.type) {
59
61
  case "builder.evaluate": {
60
- const c = e.data.text, f = e.data.arguments || [], r = e.data.id, g = new Function(c);
62
+ const c = e.data.text, f = e.data.arguments || [], a = e.data.id, g = new Function(c);
61
63
  let t, s = null;
62
64
  try {
63
65
  t = g.apply(null, f);
@@ -67,7 +69,7 @@ const x = (a = {}) => {
67
69
  s ? (p = window.parent) == null || p.postMessage({
68
70
  type: "builder.evaluateError",
69
71
  data: {
70
- id: r,
72
+ id: a,
71
73
  error: s.message
72
74
  }
73
75
  }, "*") : t && typeof t.then == "function" ? t.then((o) => {
@@ -75,7 +77,7 @@ const x = (a = {}) => {
75
77
  (l = window.parent) == null || l.postMessage({
76
78
  type: "builder.evaluateResult",
77
79
  data: {
78
- id: r,
80
+ id: a,
79
81
  result: o
80
82
  }
81
83
  }, "*");
@@ -83,7 +85,7 @@ const x = (a = {}) => {
83
85
  type: "builder.evaluateResult",
84
86
  data: {
85
87
  result: t,
86
- id: r
88
+ id: a
87
89
  }
88
90
  }, "*");
89
91
  break;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-nextjs",
3
3
  "description": "Builder.io RSC SDK for NextJS App Directory",
4
- "version": "0.17.8",
4
+ "version": "0.18.1",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -7,11 +7,11 @@ export interface ContentVariantsPrps extends ExtraFrameworkProps {
7
7
  /**
8
8
  * The Builder content JSON to render (required).
9
9
  */
10
- content?: Nullable<BuilderContent>;
10
+ content: Nullable<BuilderContent>;
11
11
  /**
12
12
  * The Builder content `model` to render (required).
13
13
  */
14
- model?: string;
14
+ model: string;
15
15
  /**
16
16
  * Additional data to inject into your Builder content (optional).
17
17
  */
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.17.8";
1
+ export declare const SDK_VERSION = "0.18.1";
@@ -1,27 +1,29 @@
1
1
  import type { ContentProps } from '../components/content/content.types.js';
2
2
  import type { BuilderAnimation } from '../types/builder-block.js';
3
3
  import type { BuilderContent } from '../types/builder-content.js';
4
+ import type { Dictionary } from '../types/typescript.js';
4
5
  type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
5
6
  callbacks: {
6
7
  contentUpdate: (updatedContent: BuilderContent) => void;
8
+ stateUpdate: (newState: Dictionary<string>) => void;
7
9
  animation: (updatedContent: BuilderAnimation) => void;
8
10
  configureSdk: (updatedContent: any) => void;
9
11
  };
10
12
  };
11
13
  export declare const createEditorListener: ({ model, trustedHosts, callbacks }: ContentListener) => (event: MessageEvent<any>) => void;
12
- type SubscribeToEditor = (
13
- /**
14
- * The Builder `model` to subscribe to
15
- */
16
- model: string,
17
- /**
18
- * The callback function to call when the content is updated.
19
- */
20
- callback: (updatedContent: BuilderContent) => void,
21
- /**
22
- * Extra options for the listener.
23
- */
24
- options?: {
14
+ type SubscribeToEditor = ({ model, apiKey, callback, trustedHosts }: {
15
+ /**
16
+ * The Builder `model` to subscribe to
17
+ */
18
+ model: string;
19
+ /**
20
+ * Builder API Key to use for the editor.
21
+ */
22
+ apiKey: string;
23
+ /**
24
+ * The callback function to call when the content is updated.
25
+ */
26
+ callback: (updatedContent: BuilderContent) => void;
25
27
  /**
26
28
  * List of hosts to allow editing content from.
27
29
  */
@@ -1,5 +1,7 @@
1
1
  export declare const registerInsertMenu: () => void;
2
- export declare const setupBrowserForEditing: (options?: {
2
+ export declare const setupBrowserForEditing: (options: {
3
+ modelName: string;
4
+ apiKey: string;
3
5
  enrich?: boolean;
4
6
  includeRefs?: boolean;
5
7
  locale?: string;
@@ -7,11 +7,11 @@ export interface ContentVariantsPrps extends ExtraFrameworkProps {
7
7
  /**
8
8
  * The Builder content JSON to render (required).
9
9
  */
10
- content?: Nullable<BuilderContent>;
10
+ content: Nullable<BuilderContent>;
11
11
  /**
12
12
  * The Builder content `model` to render (required).
13
13
  */
14
- model?: string;
14
+ model: string;
15
15
  /**
16
16
  * Additional data to inject into your Builder content (optional).
17
17
  */
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.17.8";
1
+ export declare const SDK_VERSION = "0.18.1";
@@ -1,27 +1,29 @@
1
1
  import type { ContentProps } from '../components/content/content.types.js';
2
2
  import type { BuilderAnimation } from '../types/builder-block.js';
3
3
  import type { BuilderContent } from '../types/builder-content.js';
4
+ import type { Dictionary } from '../types/typescript.js';
4
5
  type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
5
6
  callbacks: {
6
7
  contentUpdate: (updatedContent: BuilderContent) => void;
8
+ stateUpdate: (newState: Dictionary<string>) => void;
7
9
  animation: (updatedContent: BuilderAnimation) => void;
8
10
  configureSdk: (updatedContent: any) => void;
9
11
  };
10
12
  };
11
13
  export declare const createEditorListener: ({ model, trustedHosts, callbacks }: ContentListener) => (event: MessageEvent<any>) => void;
12
- type SubscribeToEditor = (
13
- /**
14
- * The Builder `model` to subscribe to
15
- */
16
- model: string,
17
- /**
18
- * The callback function to call when the content is updated.
19
- */
20
- callback: (updatedContent: BuilderContent) => void,
21
- /**
22
- * Extra options for the listener.
23
- */
24
- options?: {
14
+ type SubscribeToEditor = ({ model, apiKey, callback, trustedHosts }: {
15
+ /**
16
+ * The Builder `model` to subscribe to
17
+ */
18
+ model: string;
19
+ /**
20
+ * Builder API Key to use for the editor.
21
+ */
22
+ apiKey: string;
23
+ /**
24
+ * The callback function to call when the content is updated.
25
+ */
26
+ callback: (updatedContent: BuilderContent) => void;
25
27
  /**
26
28
  * List of hosts to allow editing content from.
27
29
  */
@@ -1,5 +1,7 @@
1
1
  export declare const registerInsertMenu: () => void;
2
- export declare const setupBrowserForEditing: (options?: {
2
+ export declare const setupBrowserForEditing: (options: {
3
+ modelName: string;
4
+ apiKey: string;
3
5
  enrich?: boolean;
4
6
  includeRefs?: boolean;
5
7
  locale?: string;