@builder.io/sdk 1.1.34 → 1.1.36-0
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 +4 -1
- package/coverage/clover.xml +3848 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/builder.class.ts.html +8107 -0
- package/coverage/lcov-report/src/classes/animator.class.ts.html +847 -0
- package/coverage/lcov-report/src/classes/cookies.class.ts.html +559 -0
- package/coverage/lcov-report/src/classes/index.html +176 -0
- package/coverage/lcov-report/src/classes/observable.class.ts.html +388 -0
- package/coverage/lcov-report/src/classes/promise.class.ts.html +607 -0
- package/coverage/lcov-report/src/classes/query-string.class.ts.html +328 -0
- package/coverage/lcov-report/src/functions/assign.function.ts.html +139 -0
- package/coverage/lcov-report/src/functions/fetch.function.ts.html +427 -0
- package/coverage/lcov-report/src/functions/get-top-level-domain.ts.html +121 -0
- package/coverage/lcov-report/src/functions/index.html +236 -0
- package/coverage/lcov-report/src/functions/next-tick.function.ts.html +184 -0
- package/coverage/lcov-report/src/functions/omit.function.ts.html +106 -0
- package/coverage/lcov-report/src/functions/server-only-require.function.ts.html +121 -0
- package/coverage/lcov-report/src/functions/throttle.function.ts.html +181 -0
- package/coverage/lcov-report/src/functions/to-error.ts.html +133 -0
- package/coverage/lcov-report/src/functions/uuid.ts.html +136 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/polyfills/custom-event-polyfill.js.html +121 -0
- package/coverage/lcov-report/src/polyfills/index.html +116 -0
- package/coverage/lcov-report/src/types/api-version.ts.html +91 -0
- package/coverage/lcov-report/src/types/index.html +116 -0
- package/coverage/lcov-report/src/url.ts.html +253 -0
- package/coverage/lcov.info +4317 -0
- package/dist/index.browser.js +2718 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +88 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +81 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +101 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +17 -15
- package/dist/src/builder.class.d.ts +16 -10
- package/dist/src/builder.class.js +58 -8
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.d.ts +1 -0
- package/dist/src/builder.class.test.js +23 -0
- package/dist/src/builder.class.test.js.map +1 -0
- package/dist/src/classes/cookies.class.d.ts +1 -1
- package/dist/src/classes/observable.class.d.ts +1 -1
- package/dist/src/classes/query-string.class.d.ts +1 -1
- package/dist/src/functions/finder.function.d.ts +1 -1
- package/dist/src/functions/finder.function.js +1 -1
- package/dist/src/functions/next-tick.function.d.ts +2 -1
- package/dist/src/functions/server-only-require.function.d.ts +1 -1
- package/dist/src/types/api-version.d.ts +2 -0
- package/dist/src/types/api-version.js +5 -0
- package/dist/src/types/api-version.js.map +1 -0
- package/dist/src/types/element.d.ts +2 -2
- package/dist/src/url.d.ts +3 -3
- package/dist/src/url.test.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.config.ts +1 -3
- package/package.json +17 -15
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAQ6B;AACpB,wFARP,uBAAO,OAQO;AAAE,iGAPhB,gCAAgB,OAOgB;AAAE,0FANlC,yBAAS,OAMkC;AAE7C,mEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,gHAAA,YAAY,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAQ6B;AACpB,wFARP,uBAAO,OAQO;AAAE,iGAPhB,gCAAgB,OAOgB;AAAE,0FANlC,yBAAS,OAMkC;AAE7C,mEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,gHAAA,YAAY,OAAA;AAMtC,mDAAkD;AAAzC,kGAAA,OAAO,OAAA"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@builder.io/sdk', ['exports'], factory) :
|
|
4
|
-
(factory(
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderIO = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
21
|
|
|
22
22
|
var __assign = function() {
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
return t;
|
|
29
29
|
};
|
|
30
30
|
return __assign.apply(this, arguments);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
+
var e = new Error(message);
|
|
35
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
(function () {
|
|
@@ -152,7 +157,7 @@
|
|
|
152
157
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
var version = "1.1.
|
|
160
|
+
var version = "1.1.36-0";
|
|
156
161
|
|
|
157
162
|
var Subscription = /** @class */ (function () {
|
|
158
163
|
function Subscription(listeners, listener) {
|
|
@@ -502,10 +507,6 @@
|
|
|
502
507
|
}
|
|
503
508
|
|
|
504
509
|
function assign(target) {
|
|
505
|
-
var args = [];
|
|
506
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
507
|
-
args[_i - 1] = arguments[_i];
|
|
508
|
-
}
|
|
509
510
|
var to = Object(target);
|
|
510
511
|
for (var index = 1; index < arguments.length; index++) {
|
|
511
512
|
var nextSource = arguments[index];
|
|
@@ -946,7 +947,7 @@
|
|
|
946
947
|
}
|
|
947
948
|
// Replacement for `url.parse` using `URL` global object that works with relative paths.
|
|
948
949
|
// Assumptions: this function operates in a NodeJS environment.
|
|
949
|
-
function parse(url) {
|
|
950
|
+
function parse$1(url) {
|
|
950
951
|
var out = emptyUrl();
|
|
951
952
|
var u;
|
|
952
953
|
var pathOnly = url === '' || url[0] === '/';
|
|
@@ -1060,6 +1061,8 @@
|
|
|
1060
1061
|
return new Error(String(err));
|
|
1061
1062
|
}
|
|
1062
1063
|
|
|
1064
|
+
var DEFAULT_API_VERSION = 'v1';
|
|
1065
|
+
|
|
1063
1066
|
function datePlusMinutes(minutes) {
|
|
1064
1067
|
if (minutes === void 0) { minutes = 30; }
|
|
1065
1068
|
return new Date(Date.now() + minutes * 60000);
|
|
@@ -1122,12 +1125,12 @@
|
|
|
1122
1125
|
return out;
|
|
1123
1126
|
},
|
|
1124
1127
|
};
|
|
1125
|
-
var parse
|
|
1128
|
+
var parse = isReactNative
|
|
1126
1129
|
? function () { return emptyUrl(); }
|
|
1127
1130
|
: typeof window === 'object'
|
|
1128
1131
|
? urlParser.parse
|
|
1129
|
-
: parse;
|
|
1130
|
-
function setCookie(name
|
|
1132
|
+
: parse$1;
|
|
1133
|
+
function setCookie(name, value, expires) {
|
|
1131
1134
|
try {
|
|
1132
1135
|
var expiresString = '';
|
|
1133
1136
|
// TODO: need to know if secure server side
|
|
@@ -1136,7 +1139,7 @@
|
|
|
1136
1139
|
}
|
|
1137
1140
|
var secure = isBrowser ? location.protocol === 'https:' : true;
|
|
1138
1141
|
document.cookie =
|
|
1139
|
-
name
|
|
1142
|
+
name +
|
|
1140
1143
|
'=' +
|
|
1141
1144
|
(value || '') +
|
|
1142
1145
|
expiresString +
|
|
@@ -1148,10 +1151,10 @@
|
|
|
1148
1151
|
console.warn('Could not set cookie', err);
|
|
1149
1152
|
}
|
|
1150
1153
|
}
|
|
1151
|
-
function getCookie(name
|
|
1154
|
+
function getCookie(name) {
|
|
1152
1155
|
try {
|
|
1153
1156
|
return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
|
|
1154
|
-
encodeURIComponent(name
|
|
1157
|
+
encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
|
|
1155
1158
|
'\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
|
|
1156
1159
|
}
|
|
1157
1160
|
catch (err) {
|
|
@@ -1182,7 +1185,7 @@
|
|
|
1182
1185
|
return Builder.Component(info);
|
|
1183
1186
|
}
|
|
1184
1187
|
var Builder = /** @class */ (function () {
|
|
1185
|
-
function Builder(apiKey, request, response, forceNewInstance, authToken) {
|
|
1188
|
+
function Builder(apiKey, request, response, forceNewInstance, authToken, apiVersion) {
|
|
1186
1189
|
if (apiKey === void 0) { apiKey = null; }
|
|
1187
1190
|
if (forceNewInstance === void 0) { forceNewInstance = false; }
|
|
1188
1191
|
if (authToken === void 0) { authToken = null; }
|
|
@@ -1207,6 +1210,7 @@
|
|
|
1207
1210
|
this.overrideParams = '';
|
|
1208
1211
|
this.noCache = false;
|
|
1209
1212
|
this.preview = false;
|
|
1213
|
+
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1210
1214
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1211
1215
|
this.apiKey$ = new BehaviorSubject(null);
|
|
1212
1216
|
this.authToken$ = new BehaviorSubject(null);
|
|
@@ -1246,6 +1250,9 @@
|
|
|
1246
1250
|
if (apiKey) {
|
|
1247
1251
|
this.apiKey = apiKey;
|
|
1248
1252
|
}
|
|
1253
|
+
if (apiVersion) {
|
|
1254
|
+
this.apiVersion = apiVersion;
|
|
1255
|
+
}
|
|
1249
1256
|
if (authToken) {
|
|
1250
1257
|
this.authToken = authToken;
|
|
1251
1258
|
}
|
|
@@ -1357,7 +1364,11 @@
|
|
|
1357
1364
|
this.trustedHosts.push(host);
|
|
1358
1365
|
};
|
|
1359
1366
|
Builder.isTrustedHost = function (hostname) {
|
|
1360
|
-
return (this.trustedHosts.findIndex(function (trustedHost) {
|
|
1367
|
+
return (this.trustedHosts.findIndex(function (trustedHost) {
|
|
1368
|
+
return trustedHost.startsWith('*.')
|
|
1369
|
+
? hostname.endsWith(trustedHost.slice(1))
|
|
1370
|
+
: trustedHost === hostname;
|
|
1371
|
+
}) > -1);
|
|
1361
1372
|
};
|
|
1362
1373
|
Builder.runAction = function (action) {
|
|
1363
1374
|
// TODO
|
|
@@ -1366,11 +1377,11 @@
|
|
|
1366
1377
|
throw new Error("Action not found: ".concat(action));
|
|
1367
1378
|
}
|
|
1368
1379
|
};
|
|
1369
|
-
Builder.fields = function (name
|
|
1380
|
+
Builder.fields = function (name, fields) {
|
|
1370
1381
|
var _a;
|
|
1371
1382
|
(_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
1372
1383
|
type: 'builder.fields',
|
|
1373
|
-
data: { name: name
|
|
1384
|
+
data: { name: name, fields: fields },
|
|
1374
1385
|
}, '*');
|
|
1375
1386
|
};
|
|
1376
1387
|
/**
|
|
@@ -1554,6 +1565,18 @@
|
|
|
1554
1565
|
enumerable: false,
|
|
1555
1566
|
configurable: true
|
|
1556
1567
|
});
|
|
1568
|
+
Object.defineProperty(Builder.prototype, "apiVersion", {
|
|
1569
|
+
get: function () {
|
|
1570
|
+
return this.apiVersion$.value;
|
|
1571
|
+
},
|
|
1572
|
+
set: function (apiVersion) {
|
|
1573
|
+
if (this.apiVersion !== apiVersion) {
|
|
1574
|
+
this.apiVersion$.next(apiVersion);
|
|
1575
|
+
}
|
|
1576
|
+
},
|
|
1577
|
+
enumerable: false,
|
|
1578
|
+
configurable: true
|
|
1579
|
+
});
|
|
1557
1580
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1558
1581
|
get: function () {
|
|
1559
1582
|
return this.editingMode$.value;
|
|
@@ -1851,7 +1874,7 @@
|
|
|
1851
1874
|
var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
|
|
1852
1875
|
var builder = params.builder;
|
|
1853
1876
|
if (builder) {
|
|
1854
|
-
var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env
|
|
1877
|
+
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;
|
|
1855
1878
|
if (userAttributes) {
|
|
1856
1879
|
this.setUserAttributes(userAttributes);
|
|
1857
1880
|
}
|
|
@@ -1899,7 +1922,7 @@
|
|
|
1899
1922
|
if (isBrowser) {
|
|
1900
1923
|
addEventListener('message', function (event) {
|
|
1901
1924
|
var _a, _b, _c, _d, _e;
|
|
1902
|
-
var url = parse
|
|
1925
|
+
var url = parse(event.origin);
|
|
1903
1926
|
var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
|
|
1904
1927
|
var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
|
|
1905
1928
|
if (isRestricted && !isTrusted) {
|
|
@@ -2085,7 +2108,7 @@
|
|
|
2085
2108
|
enumerable: false,
|
|
2086
2109
|
configurable: true
|
|
2087
2110
|
});
|
|
2088
|
-
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken) {
|
|
2111
|
+
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken, apiVersion) {
|
|
2089
2112
|
if (canTrack === void 0) { canTrack = this.defaultCanTrack; }
|
|
2090
2113
|
if (req) {
|
|
2091
2114
|
this.request = req;
|
|
@@ -2098,6 +2121,9 @@
|
|
|
2098
2121
|
if (authToken) {
|
|
2099
2122
|
this.authToken = authToken;
|
|
2100
2123
|
}
|
|
2124
|
+
if (apiVersion) {
|
|
2125
|
+
this.apiVersion = apiVersion;
|
|
2126
|
+
}
|
|
2101
2127
|
return this;
|
|
2102
2128
|
};
|
|
2103
2129
|
Object.defineProperty(Builder.prototype, "previewingModel", {
|
|
@@ -2115,11 +2141,11 @@
|
|
|
2115
2141
|
var parsedLocation = {};
|
|
2116
2142
|
// in ssr mode
|
|
2117
2143
|
if (this.request) {
|
|
2118
|
-
parsedLocation = parse
|
|
2144
|
+
parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
|
|
2119
2145
|
}
|
|
2120
2146
|
else if (typeof location === 'object') {
|
|
2121
2147
|
// in the browser
|
|
2122
|
-
parsedLocation = parse
|
|
2148
|
+
parsedLocation = parse(location.href);
|
|
2123
2149
|
}
|
|
2124
2150
|
// IE11 bug with parsed path being empty string
|
|
2125
2151
|
// causes issues with our user targeting
|
|
@@ -2180,16 +2206,21 @@
|
|
|
2180
2206
|
if (options === void 0) { options = {}; }
|
|
2181
2207
|
var instance = this;
|
|
2182
2208
|
if (!Builder.isBrowser) {
|
|
2183
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken);
|
|
2209
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2184
2210
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2185
2211
|
}
|
|
2186
2212
|
else {
|
|
2213
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2214
|
+
// directly calls .get on the singleton instance of Builder
|
|
2187
2215
|
if (options.apiKey && !this.apiKey) {
|
|
2188
2216
|
this.apiKey = options.apiKey;
|
|
2189
2217
|
}
|
|
2190
2218
|
if (options.authToken && !this.authToken) {
|
|
2191
2219
|
this.authToken = options.authToken;
|
|
2192
2220
|
}
|
|
2221
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2222
|
+
this.apiVersion = options.apiVersion;
|
|
2223
|
+
}
|
|
2193
2224
|
}
|
|
2194
2225
|
return instance.queueGetContent(modelName, options).map(
|
|
2195
2226
|
/* map( */ function (matches) {
|
|
@@ -2330,6 +2361,14 @@
|
|
|
2330
2361
|
if (!this.apiKey) {
|
|
2331
2362
|
throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
|
|
2332
2363
|
}
|
|
2364
|
+
if (this.apiVersion) {
|
|
2365
|
+
if (!['v1', 'v3'].includes(this.apiVersion)) {
|
|
2366
|
+
throw new Error("Invalid apiVersion: expected 'v1' or 'v3', received '".concat(this.apiVersion, "'"));
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
else {
|
|
2370
|
+
this.apiVersion = DEFAULT_API_VERSION;
|
|
2371
|
+
}
|
|
2333
2372
|
if (!usePastQueue && !this.getContentQueue) {
|
|
2334
2373
|
return;
|
|
2335
2374
|
}
|
|
@@ -2347,7 +2386,7 @@
|
|
|
2347
2386
|
}
|
|
2348
2387
|
var pageQueryParams = typeof location !== 'undefined'
|
|
2349
2388
|
? QueryString.parseDeep(location.search.substr(1))
|
|
2350
|
-
:
|
|
2389
|
+
: {};
|
|
2351
2390
|
var userAttributes =
|
|
2352
2391
|
// FIXME: HACK: only checks first in queue for user attributes overrides, should check all
|
|
2353
2392
|
// TODO: merge user attributes provided here with defaults and current user attiributes (?)
|
|
@@ -2459,7 +2498,9 @@
|
|
|
2459
2498
|
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
|
|
2460
2499
|
}
|
|
2461
2500
|
var fn = format === 'solid' || format === 'react' ? 'codegen' : 'query';
|
|
2462
|
-
|
|
2501
|
+
// NOTE: this is a hack to get around the fact that the codegen endpoint is not yet available in v3
|
|
2502
|
+
var apiVersionBasedOnFn = fn === 'query' ? this.apiVersion : 'v1';
|
|
2503
|
+
var url = "".concat(host, "/api/").concat(apiVersionBasedOnFn, "/").concat(fn, "/").concat(this.apiKey, "/").concat(keyNames) +
|
|
2463
2504
|
(queryParams && hasParams ? "?".concat(queryStr) : '');
|
|
2464
2505
|
var promise = getFetch()(url, requestOptions)
|
|
2465
2506
|
.then(function (res) { return res.json(); })
|
|
@@ -2563,20 +2604,20 @@
|
|
|
2563
2604
|
future.setDate(future.getDate() + 30);
|
|
2564
2605
|
return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
|
|
2565
2606
|
};
|
|
2566
|
-
Builder.prototype.getCookie = function (name
|
|
2607
|
+
Builder.prototype.getCookie = function (name) {
|
|
2567
2608
|
if (this.cookies) {
|
|
2568
|
-
return this.cookies.get(name
|
|
2609
|
+
return this.cookies.get(name);
|
|
2569
2610
|
}
|
|
2570
|
-
return Builder.isBrowser && getCookie(name
|
|
2611
|
+
return Builder.isBrowser && getCookie(name);
|
|
2571
2612
|
};
|
|
2572
|
-
Builder.prototype.setCookie = function (name
|
|
2613
|
+
Builder.prototype.setCookie = function (name, value, expires) {
|
|
2573
2614
|
if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
|
|
2574
|
-
return this.cookies.set(name
|
|
2615
|
+
return this.cookies.set(name, value, {
|
|
2575
2616
|
expires: expires,
|
|
2576
2617
|
secure: this.getLocation().protocol === 'https:',
|
|
2577
2618
|
});
|
|
2578
2619
|
}
|
|
2579
|
-
return Builder.isBrowser && setCookie(name
|
|
2620
|
+
return Builder.isBrowser && setCookie(name, value, expires);
|
|
2580
2621
|
};
|
|
2581
2622
|
Builder.prototype.getContent = function (modelName, options) {
|
|
2582
2623
|
if (options === void 0) { options = {}; }
|
|
@@ -2589,17 +2630,22 @@
|
|
|
2589
2630
|
if (options === void 0) { options = {}; }
|
|
2590
2631
|
var instance = this;
|
|
2591
2632
|
if (!Builder.isBrowser) {
|
|
2592
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res);
|
|
2633
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, false, null, options.apiVersion);
|
|
2593
2634
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2594
2635
|
}
|
|
2595
2636
|
else {
|
|
2637
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2638
|
+
// directly calls .get on the singleton instance of Builder
|
|
2596
2639
|
if (options.apiKey && !this.apiKey) {
|
|
2597
2640
|
this.apiKey = options.apiKey;
|
|
2598
2641
|
}
|
|
2642
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2643
|
+
this.apiVersion = options.apiVersion;
|
|
2644
|
+
}
|
|
2599
2645
|
}
|
|
2600
2646
|
return instance
|
|
2601
2647
|
.getContent(modelName, __assign(__assign({ limit: 30 }, options), { key: options.key ||
|
|
2602
|
-
// Make the key include all options so we don't reuse cache for the same
|
|
2648
|
+
// Make the key include all options, so we don't reuse cache for the same content fetched
|
|
2603
2649
|
// with different options
|
|
2604
2650
|
Builder.isBrowser
|
|
2605
2651
|
? "".concat(modelName, ":").concat(hashSum(omit(options, 'initialContent', 'req', 'res')))
|
|
@@ -2624,7 +2670,13 @@
|
|
|
2624
2670
|
Builder.nextTick = nextTick;
|
|
2625
2671
|
Builder.throttle = throttle;
|
|
2626
2672
|
Builder.editors = [];
|
|
2627
|
-
Builder.trustedHosts = [
|
|
2673
|
+
Builder.trustedHosts = [
|
|
2674
|
+
'*.beta.builder.io',
|
|
2675
|
+
'beta.builder.io',
|
|
2676
|
+
'builder.io',
|
|
2677
|
+
'localhost',
|
|
2678
|
+
'qa.builder.io',
|
|
2679
|
+
];
|
|
2628
2680
|
Builder.plugins = [];
|
|
2629
2681
|
Builder.actions = [];
|
|
2630
2682
|
Builder.registry = {};
|
|
@@ -2654,14 +2706,14 @@
|
|
|
2654
2706
|
var builder = new Builder(null, undefined, undefined, true);
|
|
2655
2707
|
Builder.singletonInstance = builder;
|
|
2656
2708
|
|
|
2709
|
+
exports.BehaviorSubject = BehaviorSubject;
|
|
2657
2710
|
exports.Builder = Builder;
|
|
2658
2711
|
exports.BuilderComponent = BuilderComponent;
|
|
2659
|
-
exports.isBrowser = isBrowser;
|
|
2660
|
-
exports.BehaviorSubject = BehaviorSubject;
|
|
2661
2712
|
exports.Subscription = Subscription;
|
|
2662
2713
|
exports.builder = builder;
|
|
2714
|
+
exports.isBrowser = isBrowser;
|
|
2663
2715
|
|
|
2664
2716
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2665
2717
|
|
|
2666
|
-
}))
|
|
2718
|
+
}));
|
|
2667
2719
|
//# sourceMappingURL=index.umd.js.map
|