@builder.io/react 3.0.5 → 3.0.6-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 (37) hide show
  1. package/.yarnrc.yml +1 -0
  2. package/CHANGELOG.md +4 -1
  3. package/dist/builder-react-lite.cjs.js +1 -1
  4. package/dist/builder-react-lite.cjs.js.map +1 -1
  5. package/dist/builder-react-lite.esm.js +1 -1
  6. package/dist/builder-react-lite.esm.js.map +1 -1
  7. package/dist/builder-react.browser.js +2 -2
  8. package/dist/builder-react.browser.js.map +1 -1
  9. package/dist/builder-react.cjs.js +1 -1
  10. package/dist/builder-react.cjs.js.map +1 -1
  11. package/dist/builder-react.es5.js +1 -1
  12. package/dist/builder-react.es5.js.map +1 -1
  13. package/dist/builder-react.unpkg.js +2 -2
  14. package/dist/builder-react.unpkg.js.map +1 -1
  15. package/dist/lib/package.json +3 -2
  16. package/dist/lib/src/blocks/Symbol.js +2 -2
  17. package/dist/lib/src/blocks/Symbol.js.map +1 -1
  18. package/dist/lib/src/components/builder-component.component.js +11 -7
  19. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  20. package/dist/lib/src/components/builder-content.component.js +2 -2
  21. package/dist/lib/src/components/builder-content.component.js.map +1 -1
  22. package/dist/lib/src/functions/string-to-function.js +4 -4
  23. package/dist/lib/src/functions/string-to-function.js.map +1 -1
  24. package/dist/lib/src/functions/try-eval.js +4 -4
  25. package/dist/lib/src/functions/try-eval.js.map +1 -1
  26. package/dist/lib/src/scripts/init-editing.js +1 -0
  27. package/dist/lib/src/scripts/init-editing.js.map +1 -1
  28. package/dist/types/src/blocks/Symbol.d.ts +1 -0
  29. package/dist/types/src/components/builder-content.component.d.ts +0 -67
  30. package/package.json +5 -4
  31. package/src/blocks/Symbol.tsx +4 -2
  32. package/src/components/builder-component.component.tsx +19 -13
  33. package/src/components/builder-content.component.tsx +2 -2
  34. package/src/functions/string-to-function.ts +10 -9
  35. package/src/functions/try-eval.tsx +4 -3
  36. package/src/scripts/init-editing.ts +1 -0
  37. package/.npmrc +0 -1
@@ -49,6 +49,8 @@ function omit<T, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> {
49
49
  return ret;
50
50
  }
51
51
 
52
+ const instancesMap = new Map<string, Builder>();
53
+
52
54
  const wrapComponent = (info: any) => {
53
55
  return (props: any) => {
54
56
  // TODO: convention for all of this, like builderTagProps={{ style: {} foo: 'bar' }}
@@ -90,7 +92,7 @@ function debounce(func: Function, wait: number, immediate = false) {
90
92
 
91
93
  const fontsLoaded = new Set();
92
94
 
93
- let fetch: (typeof globalThis)['fetch'];
95
+ let fetch: typeof globalThis['fetch'];
94
96
  if (globalThis.fetch) fetch = globalThis.fetch;
95
97
  fetch ??= require('node-fetch');
96
98
 
@@ -394,7 +396,7 @@ export class BuilderComponent extends React.Component<
394
396
  // TODO: should change if this prop changes
395
397
  context: {
396
398
  ...props.context,
397
- apiKey: builder.apiKey || this.props.apiKey,
399
+ apiKey: this.props.apiKey || builder.apiKey,
398
400
  },
399
401
  state: Object.assign(this.rootState, {
400
402
  ...(this.inlinedContent && this.inlinedContent.data && this.inlinedContent.data.state),
@@ -416,7 +418,9 @@ export class BuilderComponent extends React.Component<
416
418
  if (Builder.isBrowser) {
417
419
  const key = this.props.apiKey;
418
420
  if (key && key !== this.builder.apiKey) {
419
- this.builder.apiKey = key;
421
+ // hmm this could cause issues with global symbols
422
+ const instance = new Builder(key, undefined, undefined, true);
423
+ instancesMap.set(key, instance);
420
424
  }
421
425
 
422
426
  if (this.inlinedContent) {
@@ -428,7 +432,8 @@ export class BuilderComponent extends React.Component<
428
432
  }
429
433
 
430
434
  get builder() {
431
- return this.props.builder || builder;
435
+ const instance = this.props.apiKey && instancesMap.get(this.props.apiKey);
436
+ return instance || this.props.builder || builder;
432
437
  }
433
438
 
434
439
  getHtmlData() {
@@ -1389,15 +1394,16 @@ export class BuilderComponent extends React.Component<
1389
1394
  error.stack
1390
1395
  );
1391
1396
  } else {
1392
- if (process?.env?.DEBUG) {
1393
- console.debug(
1394
- 'Builder custom code error:',
1395
- error.message,
1396
- 'in',
1397
- data.jsCode,
1398
- error.stack
1399
- );
1400
- }
1397
+ // TODO(SK): test with replacing the below with typeof process !== undefined
1398
+ // if (global?.process?.env?.DEBUG) {
1399
+ console.debug(
1400
+ 'Builder custom code error:',
1401
+ error.message,
1402
+ 'in',
1403
+ data.jsCode,
1404
+ error.stack
1405
+ );
1406
+ // }
1401
1407
  // Add to req.options.errors to return to client
1402
1408
  }
1403
1409
  }
@@ -193,7 +193,7 @@ export class BuilderContent<ContentType extends object = any> extends React.Comp
193
193
  if (this.name !== '_inline') {
194
194
  // TODO:... using targeting...? express.request hmmm
195
195
  this.subscriptions.add(
196
- builder.queueGetContent(this.name, this.options).subscribe(
196
+ this.builder.queueGetContent(this.name, this.options).subscribe(
197
197
  matches => {
198
198
  const match = matches && matches[0];
199
199
  this.setState({
@@ -204,7 +204,7 @@ export class BuilderContent<ContentType extends object = any> extends React.Comp
204
204
  // causing the sdk to resolve this call to the initialContent instead of the previewed/edited content
205
205
  // so we test here if the BuilderContent is being used directly ( not inlined ) and it has initial content ( content prop ), we let the first render go through to show the initial content
206
206
  // and we subscribe again to get the draft/editing content
207
- const isPreviewing = (builder.editingModel || builder.previewingModel) === this.name;
207
+ const isPreviewing = (this.builder.editingModel || this.builder.previewingModel) === this.name;
208
208
  if (!this.props.inline && this.props.content && this.firstLoad && isPreviewing) {
209
209
  this.firstLoad = false;
210
210
  this.subscriptions.unsubscribe();
@@ -143,15 +143,16 @@ export function stringToFunction(
143
143
  error.stack || error
144
144
  );
145
145
  } else {
146
- if (process?.env?.DEBUG) {
147
- console.debug(
148
- 'Builder custom code error:',
149
- error.message || error,
150
- 'in',
151
- str,
152
- error.stack || error
153
- );
154
- }
146
+ // TODO(SK): test with replacing the below with typeof process !== undefined
147
+ // if (process?.env?.DEBUG) {
148
+ console.debug(
149
+ 'Builder custom code error:',
150
+ error.message || error,
151
+ 'in',
152
+ str,
153
+ error.stack || error
154
+ );
155
+ // }
155
156
  }
156
157
  if (errors) {
157
158
  errors.push(error);
@@ -70,9 +70,10 @@ export const tryEval = (str?: string, data: any = {}, errors?: Error[]): any =>
70
70
  if (Builder.isBrowser) {
71
71
  console.warn('Builder custom code error:', error.message, 'in', str, error.stack);
72
72
  } else {
73
- if (process?.env?.DEBUG) {
74
- console.debug('Builder custom code error:', error.message, 'in', str, error.stack);
75
- }
73
+ // TODO(SK): test with replacing the below with typeof process !== undefined
74
+ // if (process?.env?.DEBUG) {
75
+ console.debug('Builder custom code error:', error.message, 'in', str, error.stack);
76
+ // }
76
77
  // Add to req.options.errors to return to client
77
78
  }
78
79
  }
@@ -8,6 +8,7 @@ if (typeof window !== 'undefined') {
8
8
  value: true,
9
9
  supportsPatchUpdates: 'v4',
10
10
  supportsCustomBreakpoints: true,
11
+ supportsGlobalSymbols: true,
11
12
  priorVersion: version,
12
13
  },
13
14
  },
package/.npmrc DELETED
@@ -1 +0,0 @@
1
- git-tag-version=false