UNPKG

5.39 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("lodash/lang"), require("./actions.js"), require("./pageUtils.js"), require("./merge.js"));
4 else if(typeof define === 'function' && define.amd)
5 define(["lodash/lang", "./actions.js", "./pageUtils.js", "./merge.js"], factory);
6 else if(typeof exports === 'object')
7 exports["reducer.js"] = factory(require("lodash/lang"), require("./actions.js"), require("./pageUtils.js"), require("./merge.js"));
8 else
9 root["reducer.js"] = factory(root["lodash/lang"], root["./actions.js"], root["./pageUtils.js"], root["./merge.js"]);
10})(this, function(__WEBPACK_EXTERNAL_MODULE_13__, __WEBPACK_EXTERNAL_MODULE_14__, __WEBPACK_EXTERNAL_MODULE_15__, __WEBPACK_EXTERNAL_MODULE_317__) {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId])
20/******/ return installedModules[moduleId].exports;
21
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ exports: {},
25/******/ id: moduleId,
26/******/ loaded: false
27/******/ };
28
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
32/******/ // Flag the module as loaded
33/******/ module.loaded = true;
34
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38
39
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45
46/******/ // __webpack_public_path__
47/******/ __webpack_require__.p = "";
48
49/******/ // Load entry module and return exports
50/******/ return __webpack_require__(0);
51/******/ })
52/************************************************************************/
53/******/ ({
54
55/***/ 0:
56/***/ function(module, exports, __webpack_require__) {
57
58 'use strict';
59
60 Object.defineProperty(exports, "__esModule", {
61 value: true
62 });
63
64 var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
65
66 var _lang = __webpack_require__(13);
67
68 var _merge = __webpack_require__(317);
69
70 var _merge2 = _interopRequireDefault(_merge);
71
72 var _pageUtils = __webpack_require__(15);
73
74 var _actions = __webpack_require__(14);
75
76 var actions = _interopRequireWildcard(_actions);
77
78 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
79
80 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
81
82 var DEFAULT = {
83 currentPageIndex: -1,
84 history: [],
85 currentPage: {},
86 shell: false
87 };
88
89 exports.default = function () {
90 var state = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT : arguments[0];
91 var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
92
93 switch (action.type) {
94 case actions.SET_PAGE:
95 {
96 var _action$payload = action.payload;
97 var url = _action$payload.url;
98 var urlParams = _action$payload.urlParams;
99 var queryParams = _action$payload.queryParams;
100 var hashParams = _action$payload.hashParams;
101 var referrer = _action$payload.referrer;
102
103 var relevantHistory = state.history.slice(0, state.currentPageIndex + 1);
104 var referrerFromHistory = !(0, _lang.isEmpty)(state.currentPage) ? (0, _pageUtils.urlFromPage)(state.currentPage) : '';
105
106 var pageData = {
107 url: url,
108 urlParams: urlParams,
109 queryParams: queryParams,
110 hashParams: hashParams,
111 referrer: referrer || referrerFromHistory
112 };
113
114 return _extends({}, state, {
115 currentPageIndex: state.currentPageIndex + 1,
116 history: relevantHistory.concat([pageData]),
117 currentPage: pageData
118 });
119 }
120 case actions.GOTO_PAGE_INDEX:
121 {
122 var pageIndex = action.payload.pageIndex;
123
124
125 return _extends({}, state, {
126 currentPageIndex: pageIndex,
127 currentPage: state.history[pageIndex]
128 });
129 }
130 case actions.SET_SHELL:
131 {
132 return (0, _merge2.default)(state, {
133 shell: action.shell
134 });
135 }
136 default:
137 return state;
138 }
139 };
140
141/***/ },
142
143/***/ 13:
144/***/ function(module, exports) {
145
146 module.exports = require("lodash/lang");
147
148/***/ },
149
150/***/ 14:
151/***/ function(module, exports) {
152
153 module.exports = __WEBPACK_EXTERNAL_MODULE_14__;
154
155/***/ },
156
157/***/ 15:
158/***/ function(module, exports) {
159
160 module.exports = __WEBPACK_EXTERNAL_MODULE_15__;
161
162/***/ },
163
164/***/ 317:
165/***/ function(module, exports) {
166
167 module.exports = __WEBPACK_EXTERNAL_MODULE_317__;
168
169/***/ }
170
171/******/ })
172});
173;
\No newline at end of file