bernie-core 982.772.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bernie-core might be problematic. Click here for more details.
- package/dist/code-split.js +172 -0
- package/dist/components/get-providers.js +17 -0
- package/dist/components/index.js +14 -0
- package/dist/controller/get-controllers.js +25 -0
- package/dist/controller/index.js +18 -0
- package/dist/controller/match-route.js +34 -0
- package/dist/controller/result.js +21 -0
- package/dist/index.js +22 -0
- package/dist/logger/bernie-core-events.js +14 -0
- package/dist/logger/index.js +18 -0
- package/dist/logger/logger-provider.js +45 -0
- package/dist/logger/logger.js +44 -0
- package/dist/routing/close-dialog.js +19 -0
- package/dist/routing/dialog-route.js +69 -0
- package/dist/routing/index.js +24 -0
- package/dist/routing/matches-query.js +47 -0
- package/dist/routing/merge-query-string.js +29 -0
- package/dist/routing/query-route.js +90 -0
- package/dist/routing/query-switch.js +75 -0
- package/dist/routing/update-search.js +19 -0
- package/dist/source/bff-source.js +33 -0
- package/dist/source/index.js +16 -0
- package/dist/source/options/index.js +3 -0
- package/dist/source/spi/index.js +3 -0
- package/dist/store/common/analytics-store.js +250 -0
- package/dist/store/common/context-store.js +140 -0
- package/dist/store/common/experiment-store.js +64 -0
- package/dist/store/common/get-experiment-logger.js +80 -0
- package/dist/store/common/index.js +13 -0
- package/dist/store/common/page-store.js +102 -0
- package/dist/store/index.js +15 -0
- package/dist/store/spi/index.js +7 -0
- package/dist/store/spi/store-container.js +27 -0
- package/dist/store/spi/store.js +37 -0
- package/dist/util/autobind.js +44 -0
- package/dist/util/batch-queue.js +33 -0
- package/dist/util/brand-config.js +32 -0
- package/dist/util/debounce.js +19 -0
- package/dist/util/index.js +44 -0
- package/dist/util/merge.js +120 -0
- package/dist/util/not-serialize.js +43 -0
- package/dist/util/retry.js +21 -0
- package/dist/util/timeout-promise.js +17 -0
- package/dist/util/unique-batch-queue.js +40 -0
- package/index.js +28 -0
- package/package.json +22 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
16
|
+
__assign = Object.assign || function(t) {
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
18
|
+
s = arguments[i];
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
20
|
+
t[p] = s[p];
|
21
|
+
}
|
22
|
+
return t;
|
23
|
+
};
|
24
|
+
return __assign.apply(this, arguments);
|
25
|
+
};
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
33
|
+
});
|
34
|
+
};
|
35
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
36
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
37
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
38
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
39
|
+
function step(op) {
|
40
|
+
if (f) throw new TypeError("Generator is already executing.");
|
41
|
+
while (_) try {
|
42
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
43
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
44
|
+
switch (op[0]) {
|
45
|
+
case 0: case 1: t = op; break;
|
46
|
+
case 4: _.label++; return { value: op[1], done: false };
|
47
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
48
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
49
|
+
default:
|
50
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
51
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
52
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
53
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
54
|
+
if (t[2]) _.ops.pop();
|
55
|
+
_.trys.pop(); continue;
|
56
|
+
}
|
57
|
+
op = body.call(thisArg, _);
|
58
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
59
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
60
|
+
}
|
61
|
+
};
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
63
|
+
exports.codeSplit = exports.CodeSplit = void 0;
|
64
|
+
var React = require("react");
|
65
|
+
var CodeSplit = /** @class */ (function (_super) {
|
66
|
+
__extends(CodeSplit, _super);
|
67
|
+
function CodeSplit(props) {
|
68
|
+
return _super.call(this, props) || this;
|
69
|
+
}
|
70
|
+
CodeSplit.loadRoute = function () {
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
72
|
+
return __generator(this, function (_a) {
|
73
|
+
throw new Error('loadRoute not implemented');
|
74
|
+
});
|
75
|
+
});
|
76
|
+
};
|
77
|
+
CodeSplit.componentLoaded = false;
|
78
|
+
return CodeSplit;
|
79
|
+
}(React.Component));
|
80
|
+
exports.CodeSplit = CodeSplit;
|
81
|
+
/**
|
82
|
+
* Gets the appropriate name of a code split component.
|
83
|
+
* @param WrappedComponent The internally loaded React component.
|
84
|
+
*/
|
85
|
+
var getDisplayName = function (WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; };
|
86
|
+
/**
|
87
|
+
* Produces a new React component class that asynchronously loads the internal component.
|
88
|
+
*
|
89
|
+
* For use with dynamic imports. See more:
|
90
|
+
* - Mozilla: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
|
91
|
+
* - Webpack: https://github.com/webpack/webpack.js.org/blob/master/src/content/guides/code-splitting.md#dynamic-imports
|
92
|
+
* - or use commit hash b77b222c1c52873f7d8b2fb66573598ef4ad5232 instead of master
|
93
|
+
*
|
94
|
+
* @param {CodeSplitLoader} loaderFunction A function that returns a `Promise` containing an object with a default
|
95
|
+
* export of a React component. Bernie is unable to know any specifics of the imported component, therefore it requires
|
96
|
+
* a default export so it has something to run. It will throw an error if a default export is not found.
|
97
|
+
*/
|
98
|
+
exports.codeSplit = function (loaderFunction) {
|
99
|
+
// tslint:disable-next-line:max-classes-per-file
|
100
|
+
return /** @class */ (function (_super) {
|
101
|
+
__extends(WebpackRoute, _super);
|
102
|
+
function WebpackRoute(props) {
|
103
|
+
var _this = _super.call(this, props) || this;
|
104
|
+
_this.logger = {};
|
105
|
+
_this.state = { component: WebpackRoute.wrappedComponent };
|
106
|
+
if (!_this.state.component) {
|
107
|
+
_this.doLoadRoute(false);
|
108
|
+
}
|
109
|
+
return _this;
|
110
|
+
}
|
111
|
+
WebpackRoute.prototype.componentDidMount = function () {
|
112
|
+
if (!this.state.component) {
|
113
|
+
this.doLoadRoute();
|
114
|
+
}
|
115
|
+
};
|
116
|
+
WebpackRoute.prototype.render = function () {
|
117
|
+
var Component = this.state.component;
|
118
|
+
var loadingComponent = this.props.loadingState || null;
|
119
|
+
return Component ? React.createElement(Component, __assign({}, this.props)) : loadingComponent;
|
120
|
+
};
|
121
|
+
WebpackRoute.prototype.doLoadRoute = function (setState) {
|
122
|
+
if (setState === void 0) { setState = true; }
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
124
|
+
var component, error_1;
|
125
|
+
return __generator(this, function (_a) {
|
126
|
+
switch (_a.label) {
|
127
|
+
case 0:
|
128
|
+
_a.trys.push([0, 2, , 3]);
|
129
|
+
return [4 /*yield*/, WebpackRoute.loadRoute()];
|
130
|
+
case 1:
|
131
|
+
component = _a.sent();
|
132
|
+
if (setState) {
|
133
|
+
this.setState({ component: component });
|
134
|
+
}
|
135
|
+
return [3 /*break*/, 3];
|
136
|
+
case 2:
|
137
|
+
error_1 = _a.sent();
|
138
|
+
if (this.logger && this.logger.error) {
|
139
|
+
this.logger.error(error_1);
|
140
|
+
}
|
141
|
+
return [3 /*break*/, 3];
|
142
|
+
case 3: return [2 /*return*/];
|
143
|
+
}
|
144
|
+
});
|
145
|
+
});
|
146
|
+
};
|
147
|
+
WebpackRoute.loadRoute = function () {
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
149
|
+
var component;
|
150
|
+
return __generator(this, function (_a) {
|
151
|
+
switch (_a.label) {
|
152
|
+
case 0:
|
153
|
+
if (!!WebpackRoute.componentLoaded) return [3 /*break*/, 2];
|
154
|
+
return [4 /*yield*/, loaderFunction()];
|
155
|
+
case 1:
|
156
|
+
component = _a.sent();
|
157
|
+
if (!component || !component.default) {
|
158
|
+
throw new Error('Code split components must have a default export');
|
159
|
+
}
|
160
|
+
WebpackRoute.wrappedComponent = component.default;
|
161
|
+
WebpackRoute.displayName = "WebpackRoute(" + getDisplayName(component.default) + ")";
|
162
|
+
WebpackRoute.componentLoaded = true;
|
163
|
+
_a.label = 2;
|
164
|
+
case 2: return [2 /*return*/, WebpackRoute.wrappedComponent];
|
165
|
+
}
|
166
|
+
});
|
167
|
+
});
|
168
|
+
};
|
169
|
+
return WebpackRoute;
|
170
|
+
}(CodeSplit));
|
171
|
+
};
|
172
|
+
//# sourceMappingURL=code-split.js.map
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getProviders = void 0;
|
4
|
+
var React = require("react");
|
5
|
+
var l10n_provider_1 = require("bernie-l10n/dist/components/l10n-provider");
|
6
|
+
var viewport_context_1 = require("@shared-ui/viewport-context");
|
7
|
+
var brand_context_1 = require("@shared-ui/brand-context");
|
8
|
+
var logger_1 = require("../logger");
|
9
|
+
exports.getProviders = function (options) {
|
10
|
+
var deviceInformation = options.deviceInformation, localization = options.localization, loggerFactory = options.loggerFactory, brandData = options.brandData;
|
11
|
+
var Providers = function (props) { return (React.createElement(l10n_provider_1.LocalizationContext.Provider, { value: localization },
|
12
|
+
React.createElement(logger_1.LoggerProvider, { factory: loggerFactory },
|
13
|
+
React.createElement(viewport_context_1.ViewportProvider, { deviceInformation: deviceInformation },
|
14
|
+
React.createElement(brand_context_1.BrandProvider, { config: brandData }, props.children || null))))); };
|
15
|
+
return Providers;
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=get-providers.js.map
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./get-providers"), exports);
|
14
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getControllers = void 0;
|
4
|
+
/**
|
5
|
+
* Collects all exported controllers from the client
|
6
|
+
* application as an array.
|
7
|
+
*/
|
8
|
+
exports.getControllers = function () {
|
9
|
+
var controllers;
|
10
|
+
if (!controllers) {
|
11
|
+
var root = global || window;
|
12
|
+
controllers = root['Bernie'] ? root['Bernie']['controllers'] : null;
|
13
|
+
if (!controllers) {
|
14
|
+
throw new Error('Could not find "Bernie.controllers" on global object.');
|
15
|
+
}
|
16
|
+
}
|
17
|
+
if (controllers instanceof Function) {
|
18
|
+
controllers = controllers();
|
19
|
+
}
|
20
|
+
if (!Array.isArray(controllers)) {
|
21
|
+
throw new TypeError('Controllers should be exported as an array of Controller class definitions.');
|
22
|
+
}
|
23
|
+
return controllers.map(function (controller) { return new controller(); });
|
24
|
+
};
|
25
|
+
//# sourceMappingURL=get-controllers.js.map
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
var get_controllers_1 = require("./get-controllers");
|
14
|
+
Object.defineProperty(exports, "getControllers", { enumerable: true, get: function () { return get_controllers_1.getControllers; } });
|
15
|
+
var match_route_1 = require("./match-route");
|
16
|
+
Object.defineProperty(exports, "matchRoute", { enumerable: true, get: function () { return match_route_1.matchRoute; } });
|
17
|
+
__exportStar(require("./result"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.matchRoute = void 0;
|
4
|
+
var react_router_dom_1 = require("react-router-dom");
|
5
|
+
/**
|
6
|
+
* Using React Router's `matchPath` function, chooses the
|
7
|
+
* controller that matches the inbound request path.
|
8
|
+
* @param controllers An array of application controllers.
|
9
|
+
* @param path The incoming request path, e.g. `/Hotels`.
|
10
|
+
*/
|
11
|
+
exports.matchRoute = function (controllers, path, options) {
|
12
|
+
if (options === void 0) { options = {}; }
|
13
|
+
var match;
|
14
|
+
var result = {};
|
15
|
+
var hasPrefix = options.baseUrl && path.indexOf(options.baseUrl) === 0;
|
16
|
+
var strippedPath = hasPrefix ? path.replace(new RegExp('^' + options.baseUrl), '') : path;
|
17
|
+
controllers.some(function (controller) {
|
18
|
+
match = react_router_dom_1.matchPath(strippedPath, controller);
|
19
|
+
if (match) {
|
20
|
+
result = {
|
21
|
+
route: controller,
|
22
|
+
params: match.params,
|
23
|
+
location: {
|
24
|
+
path: path,
|
25
|
+
pathname: controller.routeName || 'unknown'
|
26
|
+
}
|
27
|
+
};
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
return false;
|
31
|
+
});
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=match-route.js.map
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Result = void 0;
|
4
|
+
var bernie_http_1 = require("bernie-http");
|
5
|
+
// tslint:disable-next-line:no-namespace
|
6
|
+
var Result;
|
7
|
+
(function (Result) {
|
8
|
+
Result.ok = function () { return ({
|
9
|
+
status: bernie_http_1.HttpStatus.OK
|
10
|
+
}); };
|
11
|
+
Result.internalServerError = function () { return ({
|
12
|
+
status: bernie_http_1.HttpStatus.INTERNAL_SERVER_ERROR
|
13
|
+
}); };
|
14
|
+
Result.partialContent = function () { return ({
|
15
|
+
status: bernie_http_1.HttpStatus.PARTIAL_CONTENT
|
16
|
+
}); };
|
17
|
+
Result.notFound = function () { return ({
|
18
|
+
status: bernie_http_1.HttpStatus.NOT_FOUND
|
19
|
+
}); };
|
20
|
+
})(Result = exports.Result || (exports.Result = {}));
|
21
|
+
//# sourceMappingURL=result.js.map
|
package/dist/index.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./controller"), exports);
|
14
|
+
__exportStar(require("./util"), exports);
|
15
|
+
var source_1 = require("./source");
|
16
|
+
Object.defineProperty(exports, "BffSource", { enumerable: true, get: function () { return source_1.BffSource; } });
|
17
|
+
__exportStar(require("./store"), exports);
|
18
|
+
__exportStar(require("./routing"), exports);
|
19
|
+
__exportStar(require("./code-split"), exports);
|
20
|
+
__exportStar(require("./logger"), exports);
|
21
|
+
__exportStar(require("./components"), exports);
|
22
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BERNIE_CORE_EVENTS = void 0;
|
4
|
+
var bernie_logger_1 = require("bernie-logger");
|
5
|
+
exports.BERNIE_CORE_EVENTS = {
|
6
|
+
LOG_EXPERIMENT_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'LOG_EXPERIMENT_ERROR'),
|
7
|
+
MERGE_OMNITURE_DATA_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'MERGE_OMNITURE_DATA_ERROR'),
|
8
|
+
PAGE_NAMESPACE_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'PAGE_NAMESPACE_ERROR'),
|
9
|
+
PAGE_OMNITURE_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'PAGE_OMNITURE_ERROR'),
|
10
|
+
PUBLISH_ANALYTICS_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'PUBLISH_ANALYTICS_ERROR'),
|
11
|
+
TRACK_EVENT_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.ERROR, 'TRACK_EVENT_ERROR'),
|
12
|
+
REACT_ROUTE_ERROR: new bernie_logger_1.SystemEvent(bernie_logger_1.SystemEventLevel.CRITICAL, 'REACT_ROUTE_ERROR')
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=bernie-core-events.js.map
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
var logger_1 = require("./logger");
|
14
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
15
|
+
var logger_provider_1 = require("./logger-provider");
|
16
|
+
Object.defineProperty(exports, "LoggerProvider", { enumerable: true, get: function () { return logger_provider_1.LoggerProvider; } });
|
17
|
+
__exportStar(require("./bernie-core-events"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
16
|
+
exports.LoggerProvider = void 0;
|
17
|
+
var React = require("react");
|
18
|
+
var PropTypes = require("prop-types");
|
19
|
+
/**
|
20
|
+
* Provider component that injects a runtime `LoggerFactory`
|
21
|
+
* function into the child context of the component tree.
|
22
|
+
*/
|
23
|
+
var LoggerProvider = /** @class */ (function (_super) {
|
24
|
+
__extends(LoggerProvider, _super);
|
25
|
+
function LoggerProvider() {
|
26
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
27
|
+
}
|
28
|
+
LoggerProvider.prototype.render = function () {
|
29
|
+
return React.Children.only(this.props.children);
|
30
|
+
};
|
31
|
+
LoggerProvider.prototype.getChildContext = function () {
|
32
|
+
return {
|
33
|
+
factory: this.props.factory
|
34
|
+
};
|
35
|
+
};
|
36
|
+
LoggerProvider.contextTypes = {
|
37
|
+
factory: PropTypes.func
|
38
|
+
};
|
39
|
+
LoggerProvider.childContextTypes = {
|
40
|
+
factory: PropTypes.func
|
41
|
+
};
|
42
|
+
return LoggerProvider;
|
43
|
+
}(React.Component));
|
44
|
+
exports.LoggerProvider = LoggerProvider;
|
45
|
+
//# sourceMappingURL=logger-provider.js.map
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
+
exports.logger = void 0;
|
15
|
+
var React = require("react");
|
16
|
+
var PropTypes = require("prop-types");
|
17
|
+
var bernie_logger_1 = require("bernie-logger");
|
18
|
+
/**
|
19
|
+
* Decorator that injects `logger` as a prop to the decorated
|
20
|
+
* component.
|
21
|
+
* @param name The name or identifier to associate with the
|
22
|
+
* injected logger.
|
23
|
+
*/
|
24
|
+
exports.logger = function (name) {
|
25
|
+
return function (componentClass) {
|
26
|
+
var Wrapper = function (props, context) {
|
27
|
+
var factory = context.factory || (function (_) { return bernie_logger_1.NOOP_LOGGER; });
|
28
|
+
var log = bernie_logger_1.NOOP_LOGGER;
|
29
|
+
try {
|
30
|
+
log = factory(name);
|
31
|
+
}
|
32
|
+
catch (e) {
|
33
|
+
//
|
34
|
+
}
|
35
|
+
return React.createElement(componentClass, __assign(__assign({}, props), { logger: log }));
|
36
|
+
};
|
37
|
+
Wrapper.contextTypes = {
|
38
|
+
factory: PropTypes.func
|
39
|
+
};
|
40
|
+
Wrapper['wrappedComponent'] = componentClass;
|
41
|
+
return Wrapper;
|
42
|
+
};
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=logger.js.map
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.closeDialog = void 0;
|
4
|
+
var update_search_1 = require("./update-search");
|
5
|
+
exports.closeDialog = function (_a) {
|
6
|
+
var _b;
|
7
|
+
var history = _a.history, location = _a.location, _c = _a.key, key = _c === void 0 ? 'pwaOverlay' : _c;
|
8
|
+
// `MemoryHistory` instances: `history.index` is used to indicate the initial entry
|
9
|
+
// `BrowserHistory` instances: `location.key` is used: https://github.com/ReactTraining/history/blob/master/docs/api-reference.md#locationkey
|
10
|
+
// - in v4, it defaults to `undefined` (https://github.com/ReactTraining/history/blob/3f69f9e07b0a739419704cffc3b3563133281548/modules/createBrowserHistory.js#L54)
|
11
|
+
// - in v5, it defaults to `'default'` (https://github.com/ReactTraining/history/blob/v5.0.0/docs/api-reference.md#locationkey)
|
12
|
+
if (history['index'] === 0 || typeof location.key === 'undefined' || location.key === 'default') {
|
13
|
+
update_search_1.updateSearch({ history: history, location: location, newParams: (_b = {}, _b[key] = undefined, _b), replace: true });
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
history.goBack();
|
17
|
+
}
|
18
|
+
};
|
19
|
+
//# sourceMappingURL=close-dialog.js.map
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
16
|
+
__assign = Object.assign || function(t) {
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
18
|
+
s = arguments[i];
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
20
|
+
t[p] = s[p];
|
21
|
+
}
|
22
|
+
return t;
|
23
|
+
};
|
24
|
+
return __assign.apply(this, arguments);
|
25
|
+
};
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
27
|
+
exports.DialogRoute = exports.buildDialogQueryFn = void 0;
|
28
|
+
var React = require("react");
|
29
|
+
var queryString = require("query-string");
|
30
|
+
var query_route_1 = require("./query-route");
|
31
|
+
//This function allows us to find dialogs in a comma-separate series
|
32
|
+
// eg, foo.com/bar?pwaDialog=dialogA,dialogB,dialogC
|
33
|
+
function buildDialogQueryFn(dialogId) {
|
34
|
+
return function (query) { return query.split(',').includes(dialogId); };
|
35
|
+
}
|
36
|
+
exports.buildDialogQueryFn = buildDialogQueryFn;
|
37
|
+
var DialogRoute = /** @class */ (function (_super) {
|
38
|
+
__extends(DialogRoute, _super);
|
39
|
+
function DialogRoute() {
|
40
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
41
|
+
}
|
42
|
+
DialogRoute.buildDialogChain = function (query, dialogId, key) {
|
43
|
+
if (key === void 0) { key = 'pwaDialog'; }
|
44
|
+
var queryObj = queryString.parse(query);
|
45
|
+
return queryObj[key] ? queryObj[key] + "," + dialogId : dialogId;
|
46
|
+
};
|
47
|
+
DialogRoute.appendDialogToQuery = function (query, dialogId, key) {
|
48
|
+
var _a;
|
49
|
+
if (key === void 0) { key = 'pwaDialog'; }
|
50
|
+
var queryObj = queryString.parse(query);
|
51
|
+
var dialogChain = queryObj[key] ? queryObj[key] + "," + dialogId : dialogId;
|
52
|
+
var enhancedQuery = __assign(__assign({}, queryObj), (_a = {}, _a[key] = dialogChain, _a));
|
53
|
+
return queryString.stringify(enhancedQuery);
|
54
|
+
};
|
55
|
+
DialogRoute.prototype.render = function () {
|
56
|
+
var _a;
|
57
|
+
var _b = this.props, children = _b.children, id = _b.id, type = _b.type, useQueryBuilder = _b.useQueryBuilder;
|
58
|
+
var query = useQueryBuilder ? buildDialogQueryFn(id) : id;
|
59
|
+
var queryVal = (_a = {}, _a[type] = query, _a);
|
60
|
+
return React.createElement(query_route_1.QueryRoute, { query: queryVal }, children);
|
61
|
+
};
|
62
|
+
DialogRoute.defaultProps = {
|
63
|
+
type: 'pwaDialog',
|
64
|
+
useQueryBuilder: true
|
65
|
+
};
|
66
|
+
return DialogRoute;
|
67
|
+
}(React.Component));
|
68
|
+
exports.DialogRoute = DialogRoute;
|
69
|
+
//# sourceMappingURL=dialog-route.js.map
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
var matches_query_1 = require("./matches-query");
|
14
|
+
Object.defineProperty(exports, "matchesQuery", { enumerable: true, get: function () { return matches_query_1.matchesQuery; } });
|
15
|
+
var dialog_route_1 = require("./dialog-route");
|
16
|
+
Object.defineProperty(exports, "DialogRoute", { enumerable: true, get: function () { return dialog_route_1.DialogRoute; } });
|
17
|
+
var query_route_1 = require("./query-route");
|
18
|
+
Object.defineProperty(exports, "QueryRoute", { enumerable: true, get: function () { return query_route_1.QueryRoute; } });
|
19
|
+
var query_switch_1 = require("./query-switch");
|
20
|
+
Object.defineProperty(exports, "QuerySwitch", { enumerable: true, get: function () { return query_switch_1.QuerySwitch; } });
|
21
|
+
__exportStar(require("./merge-query-string"), exports);
|
22
|
+
__exportStar(require("./update-search"), exports);
|
23
|
+
__exportStar(require("./close-dialog"), exports);
|
24
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.matchesQuery = void 0;
|
4
|
+
var queryString = require('query-string');
|
5
|
+
/**
|
6
|
+
* Example Calls:
|
7
|
+
* matchesQuery(location.search, "destination") => Does the query contain the key "destination"?
|
8
|
+
* matchesQuery(location.search, {adults: 2}) => Does the query contain the key "adults" with the value "2"?
|
9
|
+
* matchesQuery(location.search, ["startDate", "endDate"] ) => Does the query contain both startDate and endDate keys?
|
10
|
+
* matchesQuery(location.search, [{regionid: 179993}, "foobar"]) => Does the query contain a key of "regionid"
|
11
|
+
* with a value of 179993, AND a key of foobar (with any value)?
|
12
|
+
*/
|
13
|
+
exports.matchesQuery = function (locationSearch, specification) {
|
14
|
+
// Accept locationSearch as either a string, or a parsed query object.
|
15
|
+
var queryObj = typeof locationSearch === 'string' ? queryString.parse(locationSearch) : locationSearch;
|
16
|
+
var queryObjKeys = Object.keys(queryObj);
|
17
|
+
// If passed a string, find that query key's existance
|
18
|
+
if (typeof specification === 'string') {
|
19
|
+
return queryObjKeys.includes(specification);
|
20
|
+
}
|
21
|
+
// If passed an array, test each entry
|
22
|
+
if (typeof specification === 'object' && Array.isArray(specification)) {
|
23
|
+
return specification.reduce(function (matchesAll, item) { return matchesAll && exports.matchesQuery(queryObj, item); }, true);
|
24
|
+
}
|
25
|
+
// If passed an object, test against both keys and values
|
26
|
+
if (typeof specification === 'object') {
|
27
|
+
return Object.keys(specification).reduce(function (matchesAll, key) {
|
28
|
+
var queryValue = specification[key];
|
29
|
+
// Does the key exist in the location search
|
30
|
+
var matchesKey = queryObjKeys.includes(key);
|
31
|
+
if (!matchesKey) {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
// Does the value of that key match the desired value
|
35
|
+
var matchesValue = false;
|
36
|
+
if (typeof queryValue === 'function') {
|
37
|
+
matchesValue = queryValue(queryObj[key]);
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
matchesValue = queryObj[key] === queryValue.toString();
|
41
|
+
}
|
42
|
+
return matchesAll && matchesValue;
|
43
|
+
}, true);
|
44
|
+
}
|
45
|
+
return false;
|
46
|
+
};
|
47
|
+
//# sourceMappingURL=matches-query.js.map
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
+
exports.mergeQueryString = void 0;
|
15
|
+
var queryString = require("query-string");
|
16
|
+
function mergeQueryString(query, params, filterQueryParams) {
|
17
|
+
var queryObj = queryString.parse(query);
|
18
|
+
var paramObj = typeof params === 'string' ? queryString.parse(params) : params;
|
19
|
+
if (filterQueryParams) {
|
20
|
+
Object.keys(queryObj).forEach(function (key) {
|
21
|
+
if (!filterQueryParams(key)) {
|
22
|
+
delete queryObj[key];
|
23
|
+
}
|
24
|
+
});
|
25
|
+
}
|
26
|
+
return queryString.stringify(__assign(__assign({}, queryObj), paramObj));
|
27
|
+
}
|
28
|
+
exports.mergeQueryString = mergeQueryString;
|
29
|
+
//# sourceMappingURL=merge-query-string.js.map
|