@builder.io/react 3.0.7-0 → 3.0.7-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 (34) hide show
  1. package/dist/builder-react-lite.cjs.js +1 -1
  2. package/dist/builder-react-lite.cjs.js.map +1 -1
  3. package/dist/builder-react-lite.esm.js +1 -1
  4. package/dist/builder-react-lite.esm.js.map +1 -1
  5. package/dist/builder-react.browser.js +2 -2
  6. package/dist/builder-react.browser.js.map +1 -1
  7. package/dist/builder-react.cjs.js +1 -1
  8. package/dist/builder-react.cjs.js.map +1 -1
  9. package/dist/builder-react.es5.js +1 -1
  10. package/dist/builder-react.es5.js.map +1 -1
  11. package/dist/builder-react.unpkg.js +2 -2
  12. package/dist/builder-react.unpkg.js.map +1 -1
  13. package/dist/lib/package.json +2 -2
  14. package/dist/lib/src/blocks/Symbol.js +2 -2
  15. package/dist/lib/src/blocks/Symbol.js.map +1 -1
  16. package/dist/lib/src/components/builder-component.component.js +8 -11
  17. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  18. package/dist/lib/src/components/builder-content.component.js +2 -2
  19. package/dist/lib/src/components/builder-content.component.js.map +1 -1
  20. package/dist/lib/src/functions/string-to-function.js +5 -4
  21. package/dist/lib/src/functions/string-to-function.js.map +1 -1
  22. package/dist/lib/src/functions/try-eval.js +5 -4
  23. package/dist/lib/src/functions/try-eval.js.map +1 -1
  24. package/dist/lib/src/scripts/init-editing.js +0 -1
  25. package/dist/lib/src/scripts/init-editing.js.map +1 -1
  26. package/dist/types/src/blocks/Symbol.d.ts +0 -1
  27. package/dist/types/src/components/builder-content.component.d.ts +67 -0
  28. package/package.json +3 -3
  29. package/src/blocks/Symbol.tsx +2 -4
  30. package/src/components/builder-component.component.tsx +17 -19
  31. package/src/components/builder-content.component.tsx +2 -2
  32. package/src/functions/string-to-function.ts +13 -10
  33. package/src/functions/try-eval.tsx +7 -4
  34. package/src/scripts/init-editing.ts +0 -1
@@ -49,8 +49,6 @@ 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
-
54
52
  const wrapComponent = (info: any) => {
55
53
  return (props: any) => {
56
54
  // TODO: convention for all of this, like builderTagProps={{ style: {} foo: 'bar' }}
@@ -92,7 +90,7 @@ function debounce(func: Function, wait: number, immediate = false) {
92
90
 
93
91
  const fontsLoaded = new Set();
94
92
 
95
- let fetch: typeof globalThis['fetch'];
93
+ let fetch: (typeof globalThis)['fetch'];
96
94
  if (globalThis.fetch) fetch = globalThis.fetch;
97
95
  fetch ??= require('node-fetch');
98
96
 
@@ -396,7 +394,7 @@ export class BuilderComponent extends React.Component<
396
394
  // TODO: should change if this prop changes
397
395
  context: {
398
396
  ...props.context,
399
- apiKey: this.props.apiKey || builder.apiKey,
397
+ apiKey: builder.apiKey || this.props.apiKey,
400
398
  },
401
399
  state: Object.assign(this.rootState, {
402
400
  ...(this.inlinedContent && this.inlinedContent.data && this.inlinedContent.data.state),
@@ -418,9 +416,7 @@ export class BuilderComponent extends React.Component<
418
416
  if (Builder.isBrowser) {
419
417
  const key = this.props.apiKey;
420
418
  if (key && key !== this.builder.apiKey) {
421
- // hmm this could cause issues with global symbols
422
- const instance = new Builder(key, undefined, undefined, true);
423
- instancesMap.set(key, instance);
419
+ this.builder.apiKey = key;
424
420
  }
425
421
 
426
422
  if (this.inlinedContent) {
@@ -432,8 +428,7 @@ export class BuilderComponent extends React.Component<
432
428
  }
433
429
 
434
430
  get builder() {
435
- const instance = this.props.apiKey && instancesMap.get(this.props.apiKey);
436
- return instance || this.props.builder || builder;
431
+ return this.props.builder || builder;
437
432
  }
438
433
 
439
434
  getHtmlData() {
@@ -1394,16 +1389,19 @@ export class BuilderComponent extends React.Component<
1394
1389
  error.stack
1395
1390
  );
1396
1391
  } else {
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
- // }
1392
+ if (
1393
+ typeof process !== 'undefined' &&
1394
+ typeof process.env !== 'undefined' &&
1395
+ process.env.DEBUG
1396
+ ) {
1397
+ console.debug(
1398
+ 'Builder custom code error:',
1399
+ error.message,
1400
+ 'in',
1401
+ data.jsCode,
1402
+ error.stack
1403
+ );
1404
+ }
1407
1405
  // Add to req.options.errors to return to client
1408
1406
  }
1409
1407
  }
@@ -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
- this.builder.queueGetContent(this.name, this.options).subscribe(
196
+ 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 = (this.builder.editingModel || this.builder.previewingModel) === this.name;
207
+ const isPreviewing = (builder.editingModel || 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,16 +143,19 @@ export function stringToFunction(
143
143
  error.stack || error
144
144
  );
145
145
  } else {
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
- // }
146
+ if (
147
+ typeof process !== 'undefined' &&
148
+ typeof process.env !== 'undefined' &&
149
+ process.env.DEBUG
150
+ ) {
151
+ console.debug(
152
+ 'Builder custom code error:',
153
+ error.message || error,
154
+ 'in',
155
+ str,
156
+ error.stack || error
157
+ );
158
+ }
156
159
  }
157
160
  if (errors) {
158
161
  errors.push(error);
@@ -70,10 +70,13 @@ 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
- // 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
- // }
73
+ if (
74
+ typeof process !== 'undefined' &&
75
+ typeof process.env !== 'undefined' &&
76
+ process.env.DEBUG
77
+ ) {
78
+ console.debug('Builder custom code error:', error.message, 'in', str, error.stack);
79
+ }
77
80
  // Add to req.options.errors to return to client
78
81
  }
79
82
  }
@@ -8,7 +8,6 @@ if (typeof window !== 'undefined') {
8
8
  value: true,
9
9
  supportsPatchUpdates: 'v4',
10
10
  supportsCustomBreakpoints: true,
11
- supportsGlobalSymbols: true,
12
11
  priorVersion: version,
13
12
  },
14
13
  },