@builder.io/react 3.0.6-0 → 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 (40) hide show
  1. package/.yarnrc.yml +1 -0
  2. package/CHANGELOG.md +3 -0
  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-block.component.js +1 -7
  19. package/dist/lib/src/components/builder-block.component.js.map +1 -1
  20. package/dist/lib/src/components/builder-component.component.js +11 -7
  21. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  22. package/dist/lib/src/components/builder-content.component.js +2 -2
  23. package/dist/lib/src/components/builder-content.component.js.map +1 -1
  24. package/dist/lib/src/functions/string-to-function.js +4 -4
  25. package/dist/lib/src/functions/string-to-function.js.map +1 -1
  26. package/dist/lib/src/functions/try-eval.js +4 -4
  27. package/dist/lib/src/functions/try-eval.js.map +1 -1
  28. package/dist/lib/src/scripts/init-editing.js +1 -0
  29. package/dist/lib/src/scripts/init-editing.js.map +1 -1
  30. package/dist/types/src/blocks/Symbol.d.ts +1 -0
  31. package/dist/types/src/components/builder-content.component.d.ts +0 -67
  32. package/package.json +4 -4
  33. package/src/blocks/Symbol.tsx +4 -2
  34. package/src/components/builder-block.component.tsx +1 -12
  35. package/src/components/builder-component.component.tsx +19 -13
  36. package/src/components/builder-content.component.tsx +2 -2
  37. package/src/functions/string-to-function.ts +10 -9
  38. package/src/functions/try-eval.tsx +4 -3
  39. package/src/scripts/init-editing.ts +1 -0
  40. package/.npmrc +0 -1
@@ -56,73 +56,6 @@ export declare class BuilderContent<ContentType extends object = any> extends Re
56
56
  get name(): string;
57
57
  get renderedVariantId(): any;
58
58
  get options(): {
59
- apiVersion?: "v1" | undefined;
60
- userAttributes?: import("@builder.io/sdk/dist/src/builder.class").UserAttributes | undefined;
61
- url?: string | undefined;
62
- includeUrl?: boolean | undefined;
63
- includeRefs?: boolean | undefined;
64
- cacheSeconds?: number | undefined;
65
- staleCacheSeconds?: number | undefined;
66
- limit?: number | undefined;
67
- query?: any;
68
- cachebust?: boolean | undefined;
69
- prerender?: boolean | undefined;
70
- extractCss?: boolean | undefined;
71
- offset?: number | undefined;
72
- initialContent?: any;
73
- model?: string | undefined;
74
- cache?: boolean | undefined;
75
- locale?: string | undefined;
76
- preview?: boolean | undefined;
77
- entry?: string | undefined;
78
- alias?: string | undefined;
79
- fields?: string | undefined;
80
- omit?: string | undefined;
81
- key?: string | undefined;
82
- format?: "react" | "html" | "email" | "solid" | "amp" | undefined;
83
- noWrap?: true | undefined;
84
- rev?: string | undefined;
85
- static?: boolean | undefined;
86
- options?: {
87
- [key: string]: any;
88
- } | undefined;
89
- noEditorUpdates?: boolean | undefined;
90
- } | {
91
- apiVersion?: "v3" | undefined;
92
- enrich?: boolean | undefined;
93
- userAttributes?: import("@builder.io/sdk/dist/src/builder.class").UserAttributes | undefined;
94
- url?: string | undefined;
95
- includeUrl?: boolean | undefined;
96
- includeRefs?: boolean | undefined;
97
- cacheSeconds?: number | undefined;
98
- staleCacheSeconds?: number | undefined;
99
- limit?: number | undefined;
100
- query?: any;
101
- cachebust?: boolean | undefined;
102
- prerender?: boolean | undefined;
103
- extractCss?: boolean | undefined;
104
- offset?: number | undefined;
105
- initialContent?: any;
106
- model?: string | undefined;
107
- cache?: boolean | undefined;
108
- locale?: string | undefined;
109
- preview?: boolean | undefined;
110
- entry?: string | undefined;
111
- alias?: string | undefined;
112
- fields?: string | undefined;
113
- omit?: string | undefined;
114
- key?: string | undefined;
115
- format?: "react" | "html" | "email" | "solid" | "amp" | undefined;
116
- noWrap?: true | undefined;
117
- rev?: string | undefined;
118
- static?: boolean | undefined;
119
- options?: {
120
- [key: string]: any;
121
- } | undefined;
122
- noEditorUpdates?: boolean | undefined;
123
- } | {
124
- apiVersion?: undefined;
125
- enrich?: boolean | undefined;
126
59
  userAttributes?: import("@builder.io/sdk/dist/src/builder.class").UserAttributes | undefined;
127
60
  url?: string | undefined;
128
61
  includeUrl?: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/react",
3
- "version": "3.0.6-0",
3
+ "version": "3.0.6-2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/builder-react.cjs.js",
@@ -122,7 +122,7 @@
122
122
  "react-dom": ">=16.8.0"
123
123
  },
124
124
  "dependencies": {
125
- "@builder.io/sdk": "2.0.4",
125
+ "@builder.io/sdk": "workspace:*",
126
126
  "@emotion/core": "^10.0.17",
127
127
  "hash-sum": "^2.0.0",
128
128
  "preact": "^10.1.0",
@@ -132,5 +132,5 @@
132
132
  "hoistingLimits": "workspaces"
133
133
  },
134
134
  "gitHead": "4d96fbc32864698afbb355ab991c6d90be991951",
135
- "stableVersion": "3.0.5"
136
- }
135
+ "stableVersion": "3.0.4"
136
+ }
@@ -34,6 +34,7 @@ export interface SymbolInfo {
34
34
  content?: any;
35
35
  inline?: boolean;
36
36
  dynamic?: boolean;
37
+ ownerId?: string;
37
38
  }
38
39
 
39
40
  export interface SymbolProps {
@@ -89,7 +90,7 @@ class SymbolComponent extends React.Component<SymbolProps> {
89
90
  ? NoWrap
90
91
  : (this.props.builderBlock && this.props.builderBlock.tagName) || 'div';
91
92
 
92
- const { model, entry, data, content, inline } = symbol || {};
93
+ const { model, entry, data, content, inline, ownerId } = symbol || {};
93
94
  const dynamic = symbol?.dynamic || this.props.dynamic;
94
95
  if (!(model && (entry || dynamic)) && !content?.data?.blocksJs && !inline) {
95
96
  showPlaceholder = true;
@@ -122,11 +123,12 @@ class SymbolComponent extends React.Component<SymbolProps> {
122
123
  this.placeholder
123
124
  ) : (
124
125
  <BuilderComponent
126
+ {...(ownerId && { apiKey: ownerId })}
125
127
  {...(state.state?.locale && { locale: state.state.locale })}
126
128
  isChild
127
129
  ref={(ref: any) => (this.ref = ref)}
128
130
  context={{ ...state.context, symbolId: this.props.builderBlock?.id }}
129
- modelName={model}
131
+ model={model}
130
132
  entry={entry}
131
133
  data={{
132
134
  ...data,
@@ -593,18 +593,7 @@ export class BuilderBlock extends React.Component<
593
593
  <InnerComponent
594
594
  builderState={this.privateState}
595
595
  builderBlock={block}
596
- {...(Builder.isEditing
597
- ? innerComponentProperties
598
- : innerComponentProperties?.text &&
599
- innerComponentProperties?.text?.['@type'] ===
600
- '@builder.io/core:LocalizedValue'
601
- ? {
602
- ...innerComponentProperties,
603
- text: innerComponentProperties?.text['Default'],
604
- }
605
- : {
606
- ...innerComponentProperties,
607
- })}
596
+ {...innerComponentProperties}
608
597
  />
609
598
  )}
610
599
  {(block as any).text || options.text
@@ -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