@builder.io/react
Advanced tools
Comparing version 0.1.62 to 0.1.63-0
@@ -35,3 +35,3 @@ "use strict"; | ||
Image.prototype.render = function () { | ||
var aspectRatio = this.props.aspectRatio; | ||
var _a = this.props, aspectRatio = _a.aspectRatio, builderBlock = _a.builderBlock; | ||
// TODO: add height and width params to image | ||
@@ -80,3 +80,38 @@ return (react_1.default.createElement("div", { style: { position: 'relative', fontSize: 0 } }, | ||
// TODO: something better | ||
defaultValue: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d' | ||
defaultValue: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d', | ||
onChange: function (options) { | ||
function loadImage(url, timeout) { | ||
if (timeout === void 0) { timeout = 60000; } | ||
return new Promise(function (resolve, reject) { | ||
var img = document.createElement('img'); | ||
var loaded = false; | ||
img.onload = function () { | ||
loaded = true; | ||
resolve(img); | ||
}; | ||
img.addEventListener('error', function (event) { | ||
console.warn('Image load failed', event.error); | ||
reject(event.error); | ||
}); | ||
img.src = url; | ||
setTimeout(function () { | ||
if (!loaded) { | ||
reject(new Error('Image load timed out')); | ||
} | ||
}, timeout); | ||
}); | ||
} | ||
// // TODO | ||
var value = options.get('image'); | ||
var aspectRatio = options.get('aspectRatio'); | ||
if (value && !aspectRatio) { | ||
return loadImage(value).then(function (img) { | ||
if (options.get('image') === value && !options.get('aspectRatio')) { | ||
if (img.width && img.height) { | ||
options.set('aspectRatio', img.width / img.height); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}, | ||
@@ -83,0 +118,0 @@ { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var sdk_1 = require("@builder.io/sdk"); | ||
// import omit from 'lodash-es/omit'; | ||
var omit_1 = require("lodash-es/omit"); | ||
function BuilderBlock(options) { | ||
options.type = 'react'; | ||
return function (target) { | ||
if (!options.name) { | ||
options.name = target.name; | ||
} | ||
options.class = target; | ||
if (!sdk_1.Builder.components.find(function (item) { return item.name === options.name; })) { | ||
sdk_1.Builder.components.push(options); | ||
} | ||
if (sdk_1.Builder.isIframe) { | ||
window.parent.postMessage({ | ||
type: 'builder.registerComponent', | ||
data: omit_1.default(options, 'class') | ||
}, '*'); | ||
} | ||
return target; | ||
}; | ||
return sdk_1.Builder.Component(options); | ||
} | ||
exports.BuilderBlock = BuilderBlock; | ||
//# sourceMappingURL=builder-block.decorator.js.map |
import { Component } from '@builder.io/sdk'; | ||
interface ReactComponent extends Component { | ||
} | ||
export declare function BuilderBlock(options: ReactComponent): (target: any) => any; | ||
export declare function BuilderBlock(options: ReactComponent): (component: import("../../node_modules/@builder.io/sdk/dist/clients/js/src/builder.class").Class) => void; | ||
export {}; |
{ | ||
"name": "@builder.io/react", | ||
"version": "0.1.62", | ||
"version": "0.1.63-0", | ||
"description": "", | ||
@@ -120,3 +120,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@builder.io/sdk": "^0.1.16", | ||
"@builder.io/sdk": "^0.1.22", | ||
"@types/react": "^16.4.1", | ||
@@ -123,0 +123,0 @@ "core-js": "^2.5.7", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5541147
40557
19
Updated@builder.io/sdk@^0.1.22