@builder.io/react
Advanced tools
Comparing version 0.1.96-14 to 0.1.96-15
@@ -20,2 +20,11 @@ "use strict"; | ||
}; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -66,2 +75,28 @@ return new (P || (P = Promise))(function (resolve, reject) { | ||
var pick_1 = require("lodash-es/pick"); | ||
var throttle_1 = require("lodash-es/throttle"); | ||
function decorator(fn) { | ||
return function argReceiver() { | ||
var fnArgs = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fnArgs[_i] = arguments[_i]; | ||
} | ||
// Check if the decorator is being called without arguments (ex `@foo methodName() {}`) | ||
if (fnArgs.length === 3) { | ||
var target = fnArgs[0], key = fnArgs[1], descriptor = fnArgs[2]; | ||
if (descriptor && (descriptor.value || descriptor.get)) { | ||
fnArgs = []; | ||
return descriptorChecker(target, key, descriptor); | ||
} | ||
} | ||
return descriptorChecker; | ||
// descriptorChecker determines whether a method or getter is being decorated | ||
// and replaces the appropriate key with the decorated function. | ||
function descriptorChecker(target, key, descriptor) { | ||
var _a; | ||
var descriptorKey = descriptor.value ? 'value' : 'get'; | ||
return __assign({}, descriptor, (_a = {}, _a[descriptorKey] = fn.apply(void 0, [descriptor[descriptorKey]].concat(fnArgs)), _a)); | ||
} | ||
}; | ||
} | ||
var Throttle = decorator(throttle_1.default); | ||
var tryEval = function (str, data) { | ||
@@ -107,2 +142,3 @@ if (data === void 0) { data = {}; } | ||
var _this = _super.call(this, props) || this; | ||
_this.subscriptions = new sdk_1.Subscription(); | ||
_this.updateState = function (fn) { | ||
@@ -189,2 +225,5 @@ var nextState = immer_1.default(_this.state.state, function (draftState) { | ||
}; | ||
BuilderPage.prototype.componentWillUnmount = function () { | ||
this.unsubscribe(); | ||
}; | ||
BuilderPage.prototype.getFontCss = function (data) { | ||
@@ -221,2 +260,3 @@ var _this = this; | ||
}; | ||
// TODO | ||
BuilderPage.prototype.handleHttpRequest = function (propertyName, url) { | ||
@@ -243,8 +283,17 @@ return __awaiter(this, void 0, void 0, function () { | ||
}; | ||
BuilderPage.prototype.unsubscribe = function () { | ||
if (this.subscriptions) { | ||
this.subscriptions.unsubscribe(); | ||
this.subscriptions = new sdk_1.Subscription(); | ||
} | ||
}; | ||
BuilderPage.prototype.handleBuilderRequest = function (propertyName, optionsString) { | ||
var _this = this; | ||
var options = tryEval(optionsString, this.data); | ||
if (this.subscriptions) { | ||
this; | ||
} | ||
if (options) { | ||
// TODO: unsubscribe on destroy | ||
sdk_1.builder.queueGetContent(options.model, options).subscribe(function (matches) { | ||
this.subscriptions.add(sdk_1.builder.queueGetContent(options.model, options).subscribe(function (matches) { | ||
if (matches) { | ||
@@ -255,5 +304,11 @@ _this.updateState(function (ctx) { | ||
} | ||
}); | ||
})); | ||
} | ||
}; | ||
__decorate([ | ||
Throttle(100, { leading: true, trailing: true }), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String]), | ||
__metadata("design:returntype", Promise) | ||
], BuilderPage.prototype, "handleHttpRequest", null); | ||
return BuilderPage; | ||
@@ -260,0 +315,0 @@ }(react_1.default.Component)); |
import React from 'react'; | ||
import { GetContentOptions } from '@builder.io/sdk'; | ||
import { GetContentOptions, Subscription } from '@builder.io/sdk'; | ||
export interface BuilderPageProps { | ||
@@ -14,2 +14,3 @@ modelName?: string; | ||
export declare class BuilderPage extends React.Component<BuilderPageProps, BuilderPageState> { | ||
subscriptions: Subscription; | ||
constructor(props: BuilderPageProps); | ||
@@ -34,2 +35,3 @@ readonly locationState: { | ||
getCssFromFont(font: any): string; | ||
componentWillUnmount(): void; | ||
getFontCss(data: any): any; | ||
@@ -41,2 +43,3 @@ getCss(data: any): any; | ||
handleHttpRequest(propertyName: string, url: string): Promise<void>; | ||
unsubscribe(): void; | ||
handleBuilderRequest(propertyName: string, optionsString: string): void; | ||
@@ -43,0 +46,0 @@ onContentLoaded: (data: any) => void; |
{ | ||
"name": "@builder.io/react", | ||
"version": "0.1.96-14", | ||
"version": "0.1.96-15", | ||
"description": "", | ||
@@ -121,3 +121,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@builder.io/sdk": "^0.1.49-2", | ||
"@builder.io/sdk": "^0.1.49-4", | ||
"core-js": "^2.5.7", | ||
@@ -124,0 +124,0 @@ "immer": "^1.7.2", |
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
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
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
3587362
25927
Updated@builder.io/sdk@^0.1.49-4