@builder.io/sdk 2.0.6 → 2.0.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/CHANGELOG.md +22 -0
- package/dist/index.browser.js +2721 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +31 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.esm.js +24 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +33 -37
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +13 -9
- package/dist/src/builder.class.d.ts +861 -862
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/classes/animator.class.d.ts +26 -26
- package/dist/src/classes/cookies.class.d.ts +15 -15
- package/dist/src/classes/observable.class.d.ts +27 -27
- package/dist/src/classes/promise.class.d.ts +17 -17
- package/dist/src/classes/query-string.class.d.ts +9 -9
- package/dist/src/classes/query-string.class.test.d.ts +1 -1
- package/dist/src/constants/builder.d.ts +2 -2
- package/dist/src/functions/assign.function.d.ts +1 -1
- package/dist/src/functions/fetch.function.d.ts +28 -28
- package/dist/src/functions/finder.function.d.ts +10 -10
- package/dist/src/functions/get-top-level-domain.d.ts +6 -6
- package/dist/src/functions/next-tick.function.d.ts +1 -1
- package/dist/src/functions/next-tick.function.js +1 -7
- package/dist/src/functions/next-tick.function.js.map +1 -1
- package/dist/src/functions/omit.function.d.ts +1 -1
- package/dist/src/functions/server-only-require.function.d.ts +3 -3
- package/dist/src/functions/throttle.function.d.ts +1 -1
- package/dist/src/functions/to-error.d.ts +13 -13
- package/dist/src/functions/uuid.d.ts +8 -8
- package/dist/src/types/api-version.d.ts +2 -2
- package/dist/src/types/content.d.ts +31 -31
- package/dist/src/types/element.d.ts +60 -60
- package/dist/src/url.d.ts +9 -9
- package/dist/src/url.test.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -9
- package/project.json +4 -0
package/dist/index.cjs.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var tslib = require('tslib');
|
|
8
|
-
var hash =
|
|
6
|
+
var hash = require('hash-sum');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
|
|
9
11
|
|
|
10
12
|
(function () {
|
|
11
13
|
if (typeof window === 'undefined' || typeof window.CustomEvent === 'function') return false;
|
|
@@ -22,21 +24,16 @@ var hash = _interopDefault(require('hash-sum'));
|
|
|
22
24
|
|
|
23
25
|
var isSafari = typeof window !== 'undefined' &&
|
|
24
26
|
/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);
|
|
27
|
+
var isClient = typeof window !== 'undefined';
|
|
25
28
|
// TODO: queue all of these in a debounceNextTick
|
|
26
29
|
function nextTick(fn) {
|
|
27
|
-
// React native
|
|
28
|
-
if (typeof setImmediate === 'function' && typeof window === 'undefined') {
|
|
29
|
-
return setImmediate(fn);
|
|
30
|
-
}
|
|
31
|
-
// TODO: should this be setImmediate instead? Forgot if that is micro or macro task
|
|
32
|
-
// TODO: detect specifically if is server
|
|
33
30
|
// if (typeof process !== 'undefined' && process.nextTick) {
|
|
34
31
|
// console.log('process.nextTick?');
|
|
35
32
|
// process.nextTick(fn);
|
|
36
33
|
// return;
|
|
37
34
|
// }
|
|
38
35
|
// FIXME: fix the real safari issue of this randomly not working
|
|
39
|
-
if (isSafari || typeof MutationObserver === 'undefined') {
|
|
36
|
+
if (!isClient || isSafari || typeof MutationObserver === 'undefined') {
|
|
40
37
|
setTimeout(fn);
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
@@ -129,7 +126,7 @@ function assertAllowedPropertyName(name) {
|
|
|
129
126
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
var version = "2.0.
|
|
129
|
+
var version = "2.0.7";
|
|
133
130
|
|
|
134
131
|
var Subscription = /** @class */ (function () {
|
|
135
132
|
function Subscription(listeners, listener) {
|
|
@@ -488,10 +485,6 @@ function getFetch() {
|
|
|
488
485
|
}
|
|
489
486
|
|
|
490
487
|
function assign(target) {
|
|
491
|
-
var args = [];
|
|
492
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
493
|
-
args[_i - 1] = arguments[_i];
|
|
494
|
-
}
|
|
495
488
|
var to = Object(target);
|
|
496
489
|
for (var index = 1; index < arguments.length; index++) {
|
|
497
490
|
var nextSource = arguments[index];
|
|
@@ -932,7 +925,7 @@ function emptyUrl() {
|
|
|
932
925
|
}
|
|
933
926
|
// Replacement for `url.parse` using `URL` global object that works with relative paths.
|
|
934
927
|
// Assumptions: this function operates in a NodeJS environment.
|
|
935
|
-
function parse(url) {
|
|
928
|
+
function parse$1(url) {
|
|
936
929
|
var out = emptyUrl();
|
|
937
930
|
var u;
|
|
938
931
|
var pathOnly = url === '' || url[0] === '/';
|
|
@@ -1042,12 +1035,12 @@ var urlParser = {
|
|
|
1042
1035
|
return out;
|
|
1043
1036
|
},
|
|
1044
1037
|
};
|
|
1045
|
-
var parse
|
|
1038
|
+
var parse = isReactNative
|
|
1046
1039
|
? function () { return emptyUrl(); }
|
|
1047
1040
|
: typeof window === 'object'
|
|
1048
1041
|
? urlParser.parse
|
|
1049
|
-
: parse;
|
|
1050
|
-
function setCookie(name
|
|
1042
|
+
: parse$1;
|
|
1043
|
+
function setCookie(name, value, expires) {
|
|
1051
1044
|
try {
|
|
1052
1045
|
var expiresString = '';
|
|
1053
1046
|
// TODO: need to know if secure server side
|
|
@@ -1056,7 +1049,7 @@ function setCookie(name$$1, value, expires) {
|
|
|
1056
1049
|
}
|
|
1057
1050
|
var secure = isBrowser ? location.protocol === 'https:' : true;
|
|
1058
1051
|
document.cookie =
|
|
1059
|
-
name
|
|
1052
|
+
name +
|
|
1060
1053
|
'=' +
|
|
1061
1054
|
(value || '') +
|
|
1062
1055
|
expiresString +
|
|
@@ -1068,10 +1061,10 @@ function setCookie(name$$1, value, expires) {
|
|
|
1068
1061
|
console.warn('Could not set cookie', err);
|
|
1069
1062
|
}
|
|
1070
1063
|
}
|
|
1071
|
-
function getCookie(name
|
|
1064
|
+
function getCookie(name) {
|
|
1072
1065
|
try {
|
|
1073
1066
|
return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
|
|
1074
|
-
encodeURIComponent(name
|
|
1067
|
+
encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
|
|
1075
1068
|
'\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
|
|
1076
1069
|
}
|
|
1077
1070
|
catch (err) {
|
|
@@ -1301,11 +1294,11 @@ var Builder = /** @class */ (function () {
|
|
|
1301
1294
|
throw new Error("Action not found: ".concat(action));
|
|
1302
1295
|
}
|
|
1303
1296
|
};
|
|
1304
|
-
Builder.fields = function (name
|
|
1297
|
+
Builder.fields = function (name, fields) {
|
|
1305
1298
|
var _a;
|
|
1306
1299
|
(_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
1307
1300
|
type: 'builder.fields',
|
|
1308
|
-
data: { name: name
|
|
1301
|
+
data: { name: name, fields: fields },
|
|
1309
1302
|
}, '*');
|
|
1310
1303
|
};
|
|
1311
1304
|
/**
|
|
@@ -1798,7 +1791,7 @@ var Builder = /** @class */ (function () {
|
|
|
1798
1791
|
var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
|
|
1799
1792
|
var builder = params.builder;
|
|
1800
1793
|
if (builder) {
|
|
1801
|
-
var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env
|
|
1794
|
+
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;
|
|
1802
1795
|
if (userAttributes) {
|
|
1803
1796
|
this.setUserAttributes(userAttributes);
|
|
1804
1797
|
}
|
|
@@ -1846,7 +1839,7 @@ var Builder = /** @class */ (function () {
|
|
|
1846
1839
|
if (isBrowser) {
|
|
1847
1840
|
addEventListener('message', function (event) {
|
|
1848
1841
|
var _a, _b, _c, _d, _e;
|
|
1849
|
-
var url = parse
|
|
1842
|
+
var url = parse(event.origin);
|
|
1850
1843
|
var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
|
|
1851
1844
|
var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
|
|
1852
1845
|
if (isRestricted && !isTrusted) {
|
|
@@ -2065,11 +2058,11 @@ var Builder = /** @class */ (function () {
|
|
|
2065
2058
|
var parsedLocation = {};
|
|
2066
2059
|
// in ssr mode
|
|
2067
2060
|
if (this.request) {
|
|
2068
|
-
parsedLocation = parse
|
|
2061
|
+
parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
|
|
2069
2062
|
}
|
|
2070
2063
|
else if (typeof location === 'object') {
|
|
2071
2064
|
// in the browser
|
|
2072
|
-
parsedLocation = parse
|
|
2065
|
+
parsedLocation = parse(location.href);
|
|
2073
2066
|
}
|
|
2074
2067
|
// IE11 bug with parsed path being empty string
|
|
2075
2068
|
// causes issues with our user targeting
|
|
@@ -2313,7 +2306,7 @@ var Builder = /** @class */ (function () {
|
|
|
2313
2306
|
}
|
|
2314
2307
|
var pageQueryParams = typeof location !== 'undefined'
|
|
2315
2308
|
? QueryString.parseDeep(location.search.substr(1))
|
|
2316
|
-
:
|
|
2309
|
+
: {};
|
|
2317
2310
|
var userAttributes =
|
|
2318
2311
|
// FIXME: HACK: only checks first in queue for user attributes overrides, should check all
|
|
2319
2312
|
// TODO: merge user attributes provided here with defaults and current user attiributes (?)
|
|
@@ -2526,20 +2519,20 @@ var Builder = /** @class */ (function () {
|
|
|
2526
2519
|
future.setDate(future.getDate() + 30);
|
|
2527
2520
|
return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
|
|
2528
2521
|
};
|
|
2529
|
-
Builder.prototype.getCookie = function (name
|
|
2522
|
+
Builder.prototype.getCookie = function (name) {
|
|
2530
2523
|
if (this.cookies) {
|
|
2531
|
-
return this.cookies.get(name
|
|
2524
|
+
return this.cookies.get(name);
|
|
2532
2525
|
}
|
|
2533
|
-
return Builder.isBrowser && getCookie(name
|
|
2526
|
+
return Builder.isBrowser && getCookie(name);
|
|
2534
2527
|
};
|
|
2535
|
-
Builder.prototype.setCookie = function (name
|
|
2528
|
+
Builder.prototype.setCookie = function (name, value, expires) {
|
|
2536
2529
|
if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
|
|
2537
|
-
return this.cookies.set(name
|
|
2530
|
+
return this.cookies.set(name, value, {
|
|
2538
2531
|
expires: expires,
|
|
2539
2532
|
secure: this.getLocation().protocol === 'https:',
|
|
2540
2533
|
});
|
|
2541
2534
|
}
|
|
2542
|
-
return Builder.isBrowser && setCookie(name
|
|
2535
|
+
return Builder.isBrowser && setCookie(name, value, expires);
|
|
2543
2536
|
};
|
|
2544
2537
|
Builder.prototype.getContent = function (modelName, options) {
|
|
2545
2538
|
if (options === void 0) { options = {}; }
|
|
@@ -2570,7 +2563,7 @@ var Builder = /** @class */ (function () {
|
|
|
2570
2563
|
// Make the key include all options, so we don't reuse cache for the same content fetched
|
|
2571
2564
|
// with different options
|
|
2572
2565
|
Builder.isBrowser
|
|
2573
|
-
? "".concat(modelName, ":").concat(
|
|
2566
|
+
? "".concat(modelName, ":").concat(hash__default["default"](omit(options, 'initialContent', 'req', 'res')))
|
|
2574
2567
|
: undefined }))
|
|
2575
2568
|
.promise();
|
|
2576
2569
|
};
|
|
@@ -2622,10 +2615,10 @@ var Builder = /** @class */ (function () {
|
|
|
2622
2615
|
var builder = new Builder(null, undefined, undefined, true);
|
|
2623
2616
|
Builder.singletonInstance = builder;
|
|
2624
2617
|
|
|
2618
|
+
exports.BehaviorSubject = BehaviorSubject;
|
|
2625
2619
|
exports.Builder = Builder;
|
|
2626
2620
|
exports.BuilderComponent = BuilderComponent;
|
|
2627
|
-
exports.isBrowser = isBrowser;
|
|
2628
|
-
exports.BehaviorSubject = BehaviorSubject;
|
|
2629
2621
|
exports.Subscription = Subscription;
|
|
2630
2622
|
exports.builder = builder;
|
|
2623
|
+
exports.isBrowser = isBrowser;
|
|
2631
2624
|
//# sourceMappingURL=index.cjs.js.map
|