@builder.io/react 3.1.1 → 3.2.0
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.
- package/CHANGELOG.md +50 -33
- package/dist/builder-react-lite.cjs.js +1 -1
- package/dist/builder-react-lite.cjs.js.map +1 -1
- package/dist/builder-react-lite.esm.js +1 -1
- package/dist/builder-react-lite.esm.js.map +1 -1
- package/dist/builder-react.browser.js +1 -1
- package/dist/builder-react.browser.js.map +1 -1
- package/dist/builder-react.cjs.js +1 -1
- package/dist/builder-react.cjs.js.map +1 -1
- package/dist/builder-react.es5.js +1 -1
- package/dist/builder-react.es5.js.map +1 -1
- package/dist/builder-react.unpkg.js +1 -1
- package/dist/builder-react.unpkg.js.map +1 -1
- package/dist/lib/package.json +2 -2
- package/dist/lib/src/blocks/Image.js.map +1 -1
- package/dist/lib/src/blocks/Router.js.map +1 -1
- package/dist/lib/src/blocks/Section.js.map +1 -1
- package/dist/lib/src/blocks/StateProvider.js.map +1 -1
- package/dist/lib/src/blocks/Symbol.js.map +1 -1
- package/dist/lib/src/blocks/Video.js.map +1 -1
- package/dist/lib/src/components/Link.js.map +1 -1
- package/dist/lib/src/components/builder-component.component.js.map +1 -1
- package/dist/lib/src/components/variants-provider.component.js.map +1 -1
- package/dist/types/src/blocks/raw/RawText.d.ts +2 -1
- package/dist/types/src/components/Link.d.ts +1 -1
- package/dist/types/src/components/builder-block.component.d.ts +1 -1
- package/dist/types/src/components/builder-component.component.d.ts +3 -4
- package/dist/types/src/components/builder-content.component.d.ts +16 -4
- package/dist/types/src/components/variants-provider.component.d.ts +1 -1
- package/dist/types/src/functions/no-wrap.d.ts +2 -0
- package/dist/types/src/functions/safe-dynamic-require.d.ts +0 -3
- package/package.json +3 -3
- package/src/blocks/Image.tsx +1 -1
- package/src/blocks/Router.tsx +2 -2
- package/src/blocks/Section.tsx +5 -2
- package/src/blocks/StateProvider.tsx +2 -2
- package/src/blocks/Symbol.tsx +2 -2
- package/src/blocks/Video.tsx +20 -18
- package/src/components/Link.tsx +1 -1
- package/src/components/builder-component.component.tsx +2 -2
- package/src/components/variants-provider.component.tsx +1 -4
- package/tsconfig.json +1 -0
- package/dist/lib/src/scripts/iso-vm.js +0 -74
- package/dist/lib/src/scripts/iso-vm.js.map +0 -1
- package/dist/types/src/scripts/iso-vm.d.ts +0 -1
package/src/blocks/Router.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { PropsWithChildren } from 'react';
|
|
4
4
|
import { BuilderElement, builder, Builder } from '@builder.io/sdk';
|
|
5
5
|
import { BuilderStoreContext } from '../store/builder-store';
|
|
6
6
|
import { BuilderComponent } from '../components/builder-component.component';
|
|
@@ -55,7 +55,7 @@ export interface RouteEvent {
|
|
|
55
55
|
preventDefault(): void;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
class RouterComponent extends React.Component<RouterProps
|
|
58
|
+
class RouterComponent extends React.Component<PropsWithChildren<RouterProps>> {
|
|
59
59
|
builder = builder;
|
|
60
60
|
|
|
61
61
|
routed = false;
|
package/src/blocks/Section.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { PropsWithChildren } from 'react';
|
|
4
4
|
import { BuilderElement } from '@builder.io/sdk';
|
|
5
5
|
import { BuilderBlock as BuilderBlockComponent } from '../components/builder-block.component';
|
|
6
6
|
import { withBuilder } from '../functions/with-builder';
|
|
@@ -14,7 +14,10 @@ interface SectionProps {
|
|
|
14
14
|
lazyStyles?: any;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
class SectionComponent extends React.Component<
|
|
17
|
+
class SectionComponent extends React.Component<
|
|
18
|
+
PropsWithChildren<SectionProps>,
|
|
19
|
+
{ inView?: boolean }
|
|
20
|
+
> {
|
|
18
21
|
ref: HTMLElement | null = null;
|
|
19
22
|
|
|
20
23
|
unmountCallbacks: Function[] = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { PropsWithChildren } from 'react';
|
|
3
3
|
import { BuilderElement } from '@builder.io/sdk';
|
|
4
4
|
import { BuilderBlock as BuilderBlockComponent } from '../components/builder-block.component';
|
|
5
5
|
import { BuilderStoreContext } from '../store/builder-store';
|
|
@@ -11,7 +11,7 @@ interface StateProviderProps {
|
|
|
11
11
|
context?: any;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
class StateProviderComponent extends React.Component<StateProviderProps
|
|
14
|
+
class StateProviderComponent extends React.Component<PropsWithChildren<StateProviderProps>> {
|
|
15
15
|
render() {
|
|
16
16
|
return (
|
|
17
17
|
<BuilderStoreContext.Consumer>
|
package/src/blocks/Symbol.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { PropsWithChildren } from 'react';
|
|
4
4
|
import { BuilderComponent } from '../components/builder-component.component';
|
|
5
5
|
import { Builder, BuilderElement } from '@builder.io/sdk';
|
|
6
6
|
import hash from 'hash-sum';
|
|
@@ -47,7 +47,7 @@ export interface SymbolProps {
|
|
|
47
47
|
inheritState?: boolean;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
class SymbolComponent extends React.Component<SymbolProps
|
|
50
|
+
class SymbolComponent extends React.Component<PropsWithChildren<SymbolProps>> {
|
|
51
51
|
ref: BuilderComponent | null = null;
|
|
52
52
|
staticRef: HTMLDivElement | null = null;
|
|
53
53
|
|
package/src/blocks/Video.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { PropsWithChildren } from 'react';
|
|
4
4
|
|
|
5
5
|
import { throttle } from '../functions/throttle';
|
|
6
6
|
import { withChildren } from '../functions/with-children';
|
|
@@ -8,23 +8,25 @@ import { Builder } from '@builder.io/sdk';
|
|
|
8
8
|
|
|
9
9
|
const DEFAULT_ASPECT_RATIO = 0.7004048582995948;
|
|
10
10
|
|
|
11
|
-
class VideoComponent extends React.Component<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
class VideoComponent extends React.Component<
|
|
12
|
+
PropsWithChildren<{
|
|
13
|
+
video: string;
|
|
14
|
+
autoPlay?: boolean;
|
|
15
|
+
controls?: boolean;
|
|
16
|
+
muted?: boolean;
|
|
17
|
+
loop?: boolean;
|
|
18
|
+
playsInline?: boolean;
|
|
19
|
+
aspectRatio?: number;
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
fit?: 'contain' | 'cover' | 'fill';
|
|
23
|
+
preload?: 'auto' | 'metadata' | 'none';
|
|
24
|
+
position?: string;
|
|
25
|
+
posterImage?: string;
|
|
26
|
+
lazyLoad?: boolean;
|
|
27
|
+
fitContent?: boolean;
|
|
28
|
+
}>
|
|
29
|
+
> {
|
|
28
30
|
video: HTMLVideoElement | null = null;
|
|
29
31
|
containerRef: HTMLElement | null = null;
|
|
30
32
|
|
package/src/components/Link.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { BuilderStoreContext } from '../store/builder-store';
|
|
|
8
8
|
* custom Link component (e.g Next, Gatsby, React Router)
|
|
9
9
|
* <BuilderComponent renderLink=(props) => <myCustomLink {...props} /> />
|
|
10
10
|
*/
|
|
11
|
-
export const Link: React.
|
|
11
|
+
export const Link = (props: React.AnchorHTMLAttributes<HTMLAnchorElement>) => (
|
|
12
12
|
<BuilderStoreContext.Consumer>
|
|
13
13
|
{context => {
|
|
14
14
|
if (context.renderLink) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { PropsWithChildren } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import { jsx, css } from '@emotion/core';
|
|
5
5
|
import { BuilderContent, getContentWithInfo } from './builder-content.component';
|
|
@@ -336,7 +336,7 @@ function searchToObject(location: Location | Url) {
|
|
|
336
336
|
* `props.content`.
|
|
337
337
|
*/
|
|
338
338
|
export class BuilderComponent extends React.Component<
|
|
339
|
-
BuilderComponentProps
|
|
339
|
+
PropsWithChildren<BuilderComponentProps>,
|
|
340
340
|
BuilderComponentState
|
|
341
341
|
> {
|
|
342
342
|
static defaults: Pick<BuilderComponentProps, 'codegen'> = {
|
|
@@ -101,10 +101,7 @@ interface VariantsProviderProps {
|
|
|
101
101
|
children: (variants: BuilderContent[], renderScript?: () => JSX.Element) => JSX.Element;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export const VariantsProvider:
|
|
105
|
-
initialContent,
|
|
106
|
-
children,
|
|
107
|
-
}) => {
|
|
104
|
+
export const VariantsProvider = ({ initialContent, children }: VariantsProviderProps) => {
|
|
108
105
|
if (Builder.isBrowser && !builder.canTrack) {
|
|
109
106
|
return children([initialContent]);
|
|
110
107
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var ivm = require('isolated-vm');
|
|
39
|
-
var isolate = new ivm.Isolate({ memoryLimit: 128 });
|
|
40
|
-
var context = isolate.createContextSync();
|
|
41
|
-
var jail = context.global;
|
|
42
|
-
var state = { articles: { bar: [{ a: 1 }] } };
|
|
43
|
-
var fetch = require('node-fetch');
|
|
44
|
-
var fetching = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var result, json, b;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, fetch("https://cdn.builder.io/api/v3/content/page?apiKey=c3e3257ff5594facbf478a68d37f766d&limit=1&fields=id")];
|
|
49
|
-
case 1:
|
|
50
|
-
result = _a.sent();
|
|
51
|
-
return [4 /*yield*/, result.json()];
|
|
52
|
-
case 2:
|
|
53
|
-
json = _a.sent();
|
|
54
|
-
console.log(json);
|
|
55
|
-
b = undefined;
|
|
56
|
-
jail.setSync('returnValue', function (val) { return (b = val); });
|
|
57
|
-
state.articles = json;
|
|
58
|
-
context.evalClosureSync("\n const refToProxy = (obj) => {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n return new Proxy(obj, {\n get(target, key) {\n if(key === 'toJS') {\n return () => obj.copySync();\n }\n const val = obj.getSync(key);\n if (typeof val?.getSync === 'function') {\n return refToProxy(val);\n }\n return val;\n },\n set(target, key, value) {\n obj.setSync(key, value);\n },\n deleteProperty(target, key) {\n obj.deleteSync(key);\n },\n })\n }\n const state = refToProxy($0);\n \n returnValue(state.toJS());\n return state.articles.results.toJS();\n ", [new ivm.Reference(state)]);
|
|
59
|
-
console.log(b.articles.results);
|
|
60
|
-
return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); };
|
|
64
|
-
jail.setSync('global', jail.derefInto());
|
|
65
|
-
// We will create a basic `log` function for the new isolate to use.
|
|
66
|
-
jail.setSync('log', function () {
|
|
67
|
-
var args = [];
|
|
68
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
69
|
-
args[_i] = arguments[_i];
|
|
70
|
-
}
|
|
71
|
-
console.log.apply(console, args);
|
|
72
|
-
});
|
|
73
|
-
fetching();
|
|
74
|
-
//# sourceMappingURL=iso-vm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iso-vm.js","sourceRoot":"","sources":["../../../../src/scripts/iso-vm.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEnC,IAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;AAEtD,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAC5C,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;AAC5B,IAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;AAChD,IAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACpC,IAAM,QAAQ,GAAG;;;;oBACA,qBAAM,KAAK,CACxB,sGAAsG,CACvG,EAAA;;gBAFK,MAAM,GAAG,SAEd;gBACY,qBAAM,MAAM,CAAC,IAAI,EAAE,EAAA;;gBAA1B,IAAI,GAAG,SAAmB;gBAChC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACd,CAAC,GAAG,SAAS,CAAC;gBAClB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,UAAA,GAAG,IAAI,OAAA,CAAC,CAAC,GAAG,GAAG,CAAC,EAAT,CAAS,CAAC,CAAC;gBAC9C,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACtB,OAAO,CAAC,eAAe,CACrB,qwBA4BF,EACE,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAC3B,CAAC;gBAEF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;;;;KACjC,CAAC;AACF,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;AAEzC,oEAAoE;AACpE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;IAAU,cAAO;SAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;QAAP,yBAAO;;IACnC,OAAO,CAAC,GAAG,OAAX,OAAO,EAAQ,IAAI,EAAE;AACvB,CAAC,CAAC,CAAC;AAEH,QAAQ,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|