@builder.io/sdk 2.2.7 → 2.2.9
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 +12 -0
- package/dist/index.browser.js +68 -69
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +68 -69
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +68 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +68 -69
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +2 -3
- package/dist/src/builder.class.d.ts +1 -0
- package/dist/src/builder.class.js +67 -68
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +136 -0
- package/dist/src/builder.class.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
package/dist/index.esm.js
CHANGED
|
@@ -118,7 +118,7 @@ function assertAllowedPropertyName(name) {
|
|
|
118
118
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
var version = "2.2.
|
|
121
|
+
var version = "2.2.9";
|
|
122
122
|
|
|
123
123
|
var Subscription = /** @class */ (function () {
|
|
124
124
|
function Subscription(listeners, listener) {
|
|
@@ -1339,36 +1339,25 @@ var Builder = /** @class */ (function () {
|
|
|
1339
1339
|
enumerable: false,
|
|
1340
1340
|
configurable: true
|
|
1341
1341
|
});
|
|
1342
|
+
Builder.serializeComponentInfo = function (info) {
|
|
1343
|
+
var serializeFn = function (fnValue) {
|
|
1344
|
+
var fnStr = fnValue.toString().trim();
|
|
1345
|
+
// we need to account for a few different fn syntaxes:
|
|
1346
|
+
// 1. `function name(args) => {code}`
|
|
1347
|
+
// 2. `name(args) => {code}`
|
|
1348
|
+
// 3. `(args) => {}`
|
|
1349
|
+
var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
1350
|
+
return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
|
|
1351
|
+
};
|
|
1352
|
+
return JSON.parse(JSON.stringify(info, function (key, value) {
|
|
1353
|
+
if (typeof value === 'function') {
|
|
1354
|
+
return serializeFn(value);
|
|
1355
|
+
}
|
|
1356
|
+
return value;
|
|
1357
|
+
}));
|
|
1358
|
+
};
|
|
1342
1359
|
Builder.prepareComponentSpecToSend = function (spec) {
|
|
1343
|
-
return __assign(__assign(
|
|
1344
|
-
inputs: spec.inputs.map(function (input) {
|
|
1345
|
-
var _a;
|
|
1346
|
-
// TODO: do for nexted fields too
|
|
1347
|
-
// TODO: probably just convert all functions, not just
|
|
1348
|
-
// TODO: put this in input hooks: { onChange: ..., showIf: ... }
|
|
1349
|
-
var keysToConvertFnToString = ['onChange', 'showIf'];
|
|
1350
|
-
for (var _i = 0, keysToConvertFnToString_1 = keysToConvertFnToString; _i < keysToConvertFnToString_1.length; _i++) {
|
|
1351
|
-
var key = keysToConvertFnToString_1[_i];
|
|
1352
|
-
if (input[key] && typeof input[key] === 'function') {
|
|
1353
|
-
var fn = input[key];
|
|
1354
|
-
input = __assign(__assign({}, input), (_a = {}, _a[key] = "return (".concat(fn.toString(), ").apply(this, arguments)"), _a));
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
return input;
|
|
1358
|
-
}),
|
|
1359
|
-
})), { hooks: Object.keys(spec.hooks || {}).reduce(function (memo, key) {
|
|
1360
|
-
var value = spec.hooks && spec.hooks[key];
|
|
1361
|
-
if (!value) {
|
|
1362
|
-
return memo;
|
|
1363
|
-
}
|
|
1364
|
-
if (typeof value === 'string') {
|
|
1365
|
-
memo[key] = value;
|
|
1366
|
-
}
|
|
1367
|
-
else {
|
|
1368
|
-
memo[key] = "return (".concat(value.toString(), ").apply(this, arguments)");
|
|
1369
|
-
}
|
|
1370
|
-
return memo;
|
|
1371
|
-
}, {}), class: undefined });
|
|
1360
|
+
return __assign(__assign({}, this.serializeComponentInfo(spec)), { class: undefined });
|
|
1372
1361
|
};
|
|
1373
1362
|
Builder.registerBlock = function (component, options) {
|
|
1374
1363
|
this.registerComponent(component, options);
|
|
@@ -1759,15 +1748,20 @@ var Builder = /** @class */ (function () {
|
|
|
1759
1748
|
};
|
|
1760
1749
|
Builder.prototype.setTestsFromUrl = function () {
|
|
1761
1750
|
var search = this.getLocation().search;
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1751
|
+
try {
|
|
1752
|
+
var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
|
|
1753
|
+
var tests = params.builder && params.builder.tests;
|
|
1754
|
+
if (tests && typeof tests === 'object') {
|
|
1755
|
+
for (var key in tests) {
|
|
1756
|
+
if (tests.hasOwnProperty(key)) {
|
|
1757
|
+
this.setTestCookie(key, tests[key]);
|
|
1758
|
+
}
|
|
1768
1759
|
}
|
|
1769
1760
|
}
|
|
1770
1761
|
}
|
|
1762
|
+
catch (e) {
|
|
1763
|
+
console.debug('Error parsing tests from URL', e);
|
|
1764
|
+
}
|
|
1771
1765
|
};
|
|
1772
1766
|
Builder.prototype.resetOverrides = function () {
|
|
1773
1767
|
// Ugly - pass down instances per request instead using react context
|
|
@@ -1785,41 +1779,46 @@ var Builder = /** @class */ (function () {
|
|
|
1785
1779
|
};
|
|
1786
1780
|
Builder.prototype.getOverridesFromQueryString = function () {
|
|
1787
1781
|
var location = this.getLocation();
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1782
|
+
try {
|
|
1783
|
+
var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
|
|
1784
|
+
var builder = params.builder;
|
|
1785
|
+
if (builder) {
|
|
1786
|
+
var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env, host = builder.host, api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
|
|
1787
|
+
if (userAttributes) {
|
|
1788
|
+
this.setUserAttributes(userAttributes);
|
|
1789
|
+
}
|
|
1790
|
+
if (options) {
|
|
1791
|
+
// picking only locale, includeRefs, and enrich for now
|
|
1792
|
+
this.queryOptions = __assign(__assign(__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
|
|
1793
|
+
}
|
|
1794
|
+
if (overrides) {
|
|
1795
|
+
this.overrides = overrides;
|
|
1796
|
+
}
|
|
1797
|
+
if (validEnvList.indexOf(env || api) > -1) {
|
|
1798
|
+
this.env = env || api;
|
|
1799
|
+
}
|
|
1800
|
+
if (Builder.isEditing) {
|
|
1801
|
+
var editingModel = frameEditing || editing || preview;
|
|
1802
|
+
if (editingModel && editingModel !== 'true') {
|
|
1803
|
+
this.editingModel = editingModel;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
if (cachebust) {
|
|
1807
|
+
this.cachebust = true;
|
|
1808
|
+
}
|
|
1809
|
+
if (noCache) {
|
|
1810
|
+
this.noCache = true;
|
|
1811
|
+
}
|
|
1812
|
+
if (preview) {
|
|
1813
|
+
this.preview = true;
|
|
1814
|
+
}
|
|
1815
|
+
if (params) {
|
|
1816
|
+
this.overrideParams = overrideParams;
|
|
1809
1817
|
}
|
|
1810
1818
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
if (noCache) {
|
|
1815
|
-
this.noCache = true;
|
|
1816
|
-
}
|
|
1817
|
-
if (preview) {
|
|
1818
|
-
this.preview = true;
|
|
1819
|
-
}
|
|
1820
|
-
if (params) {
|
|
1821
|
-
this.overrideParams = overrideParams;
|
|
1822
|
-
}
|
|
1819
|
+
}
|
|
1820
|
+
catch (e) {
|
|
1821
|
+
console.debug('Error parsing overrides from URL', e);
|
|
1823
1822
|
}
|
|
1824
1823
|
};
|
|
1825
1824
|
Builder.prototype.messageFrameLoaded = function () {
|