@builder.io/sdk 2.2.7-0 → 2.2.8
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/.yarnrc.yml +1 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.browser.js +58 -79
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +58 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +58 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +58 -79
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +1 -0
- package/dist/src/builder.class.js +57 -78
- 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/src/classes/promise.class.js +154 -150
- package/dist/src/classes/query-string.class.js +74 -73
- package/dist/src/classes/query-string.class.test.js +20 -20
- package/dist/src/functions/assign.function.js +19 -19
- package/dist/src/functions/fetch.function.js +75 -97
- package/dist/src/functions/finder.function.js +274 -389
- package/dist/src/functions/get-top-level-domain.js +8 -8
- package/dist/src/functions/next-tick.function.js +23 -26
- package/dist/src/functions/omit.function.js +13 -13
- package/dist/src/functions/server-only-require.function.js +9 -10
- package/dist/src/functions/throttle.function.js +37 -35
- package/dist/src/functions/to-error.js +6 -5
- package/dist/src/functions/uuid.js +8 -9
- package/dist/src/types/api-version.js +3 -3
- package/dist/src/types/element.js +3 -3
- package/dist/src/url.test.js +118 -222
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
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.8";
|
|
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,20 +1748,15 @@ 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
|
-
|
|
1768
|
-
this.setTestCookie(key, tests[key]);
|
|
1769
|
-
}
|
|
1751
|
+
var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
|
|
1752
|
+
var tests = params.builder && params.builder.tests;
|
|
1753
|
+
if (tests && typeof tests === 'object') {
|
|
1754
|
+
for (var key in tests) {
|
|
1755
|
+
if (tests.hasOwnProperty(key)) {
|
|
1756
|
+
this.setTestCookie(key, tests[key]);
|
|
1770
1757
|
}
|
|
1771
1758
|
}
|
|
1772
1759
|
}
|
|
1773
|
-
catch (e) {
|
|
1774
|
-
console.debug('Error parsing tests from URL', e);
|
|
1775
|
-
}
|
|
1776
1760
|
};
|
|
1777
1761
|
Builder.prototype.resetOverrides = function () {
|
|
1778
1762
|
// Ugly - pass down instances per request instead using react context
|
|
@@ -1790,46 +1774,41 @@ var Builder = /** @class */ (function () {
|
|
|
1790
1774
|
};
|
|
1791
1775
|
Builder.prototype.getOverridesFromQueryString = function () {
|
|
1792
1776
|
var location = this.getLocation();
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
this.editingModel = editingModel;
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
if (cachebust) {
|
|
1818
|
-
this.cachebust = true;
|
|
1819
|
-
}
|
|
1820
|
-
if (noCache) {
|
|
1821
|
-
this.noCache = true;
|
|
1822
|
-
}
|
|
1823
|
-
if (preview) {
|
|
1824
|
-
this.preview = true;
|
|
1825
|
-
}
|
|
1826
|
-
if (params) {
|
|
1827
|
-
this.overrideParams = overrideParams;
|
|
1777
|
+
var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
|
|
1778
|
+
var builder = params.builder;
|
|
1779
|
+
if (builder) {
|
|
1780
|
+
var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env; builder.host; var api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
|
|
1781
|
+
if (userAttributes) {
|
|
1782
|
+
this.setUserAttributes(userAttributes);
|
|
1783
|
+
}
|
|
1784
|
+
if (options) {
|
|
1785
|
+
// picking only locale, includeRefs, and enrich for now
|
|
1786
|
+
this.queryOptions = __assign(__assign(__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
|
|
1787
|
+
}
|
|
1788
|
+
if (overrides) {
|
|
1789
|
+
this.overrides = overrides;
|
|
1790
|
+
}
|
|
1791
|
+
if (validEnvList.indexOf(env || api) > -1) {
|
|
1792
|
+
this.env = env || api;
|
|
1793
|
+
}
|
|
1794
|
+
if (Builder.isEditing) {
|
|
1795
|
+
var editingModel = frameEditing || editing || preview;
|
|
1796
|
+
if (editingModel && editingModel !== 'true') {
|
|
1797
|
+
this.editingModel = editingModel;
|
|
1828
1798
|
}
|
|
1829
1799
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1800
|
+
if (cachebust) {
|
|
1801
|
+
this.cachebust = true;
|
|
1802
|
+
}
|
|
1803
|
+
if (noCache) {
|
|
1804
|
+
this.noCache = true;
|
|
1805
|
+
}
|
|
1806
|
+
if (preview) {
|
|
1807
|
+
this.preview = true;
|
|
1808
|
+
}
|
|
1809
|
+
if (params) {
|
|
1810
|
+
this.overrideParams = overrideParams;
|
|
1811
|
+
}
|
|
1833
1812
|
}
|
|
1834
1813
|
};
|
|
1835
1814
|
Builder.prototype.messageFrameLoaded = function () {
|