wapplr 1.0.41 → 1.0.45

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.
@@ -60,18 +60,27 @@ function createClient() {
60
60
  wapplrClient.close();
61
61
  wapplrClient.history.listen(function (_ref) {
62
62
  var action = _ref.action,
63
- location = _ref.location;
63
+ location = _ref.location,
64
+ state = _ref.state;
64
65
  wapplrClient.app({
65
66
  history: {
66
67
  action: action,
67
- location: location
68
+ location: location,
69
+ state: state
68
70
  }
69
71
  });
70
72
  });
71
73
  wapplrClient.app({
72
74
  history: {
73
75
  action: "POP",
74
- location: history.location
76
+ location: {
77
+ pathname: window.location.pathname,
78
+ search: window.location.search,
79
+ hash: window.location.hash
80
+ },
81
+ state: {
82
+ key: 0
83
+ }
75
84
  }
76
85
  }, {}, function out() {
77
86
  var globals = wapp.globals;
@@ -57,7 +57,7 @@ function createHistoryManager() {
57
57
  });
58
58
  }
59
59
 
60
- function defaultHandlePop(e) {
60
+ function defaultHandlePop() {
61
61
  var _window$location = window.location,
62
62
  pathname = _window$location.pathname,
63
63
  search = _window$location.search,
@@ -69,13 +69,12 @@ function createHistoryManager() {
69
69
  hash: hash
70
70
  };
71
71
  state.key = state.key || createKey();
72
- history.location = newLocation;
73
- history.state = state;
74
- defaultRunListeners({
72
+ history.runListeners({
75
73
  action: "POP",
76
- location: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, history.location), {}, {
77
- key: history.state.key
78
- })
74
+ location: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, newLocation), {}, {
75
+ key: state.key
76
+ }),
77
+ state: state
79
78
  });
80
79
  }
81
80
 
@@ -124,8 +123,7 @@ function createHistoryManager() {
124
123
  return partialPath;
125
124
  }
126
125
 
127
- function defaultPush(to) {
128
- var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
126
+ function defaultPush(to, inputState) {
129
127
  var _window$location2 = window.location,
130
128
  pathname = _window$location2.pathname,
131
129
  search = _window$location2.search,
@@ -136,15 +134,15 @@ function createHistoryManager() {
136
134
  hash: hash
137
135
  }, typeof to === "string" ? history.parsePath(to) : to);
138
136
  var url = createHref(newLocation);
137
+ var state = inputState || {};
139
138
  state.key = state.key || createKey();
140
- history.location = newLocation;
141
- history.state = state;
142
139
  globalHistory.pushState(state, "", url);
143
140
  history.runListeners({
144
141
  action: "PUSH",
145
- location: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, history.location), {}, {
146
- key: history.state.key
147
- })
142
+ location: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, newLocation), {}, {
143
+ key: state.key
144
+ }),
145
+ state: state
148
146
  });
149
147
  }
150
148
 
@@ -158,18 +156,20 @@ function createHistoryManager() {
158
156
  return history.addListener(fn);
159
157
  }
160
158
 
159
+ function defaultGetState() {
160
+ return history.globalHistory.state || {};
161
+ }
162
+
161
163
  var history = Object.create(Object.prototype, {
162
164
  globalHistory: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
163
165
  writable: false,
164
166
  enumerable: false,
165
167
  value: globalHistory
166
168
  }),
167
- location: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
168
- value: {
169
- pathname: window.location.pathname,
170
- search: window.location.search,
171
- hash: window.location.hash
172
- }
169
+ getState: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
170
+ writable: false,
171
+ enumerable: false,
172
+ value: defaultGetState
173
173
  }),
174
174
  key: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
175
175
  value: "initial"
@@ -27,12 +27,22 @@ var defaultDescriptor = {
27
27
  exports.defaultDescriptor = defaultDescriptor;
28
28
 
29
29
  function copyObject(obj) {
30
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
+
30
32
  function cloneObj() {
33
+ var _options$skip = options.skip,
34
+ skip = _options$skip === void 0 ? [] : _options$skip,
35
+ _options$keep = options.keep,
36
+ keep = _options$keep === void 0 ? [] : _options$keep;
31
37
  var clone = {};
32
38
 
33
39
  for (var key in obj) {
34
- if (obj.hasOwnProperty(key)) {
35
- clone[key] = copyObject(obj[key]);
40
+ if (keep.indexOf(key) === -1 && skip.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
41
+ clone[key] = copyObject(obj[key], options);
42
+ }
43
+
44
+ if (keep.indexOf(key) > -1) {
45
+ clone[key] = obj[key];
36
46
  }
37
47
  }
38
48
 
@@ -41,7 +51,7 @@ function copyObject(obj) {
41
51
 
42
52
  function cloneArr() {
43
53
  return obj.map(function (item) {
44
- return copyObject(item);
54
+ return copyObject(item, options);
45
55
  });
46
56
  }
47
57
 
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "files": [
23
23
  "dist/*"
24
24
  ],
25
- "version": "1.0.41",
25
+ "version": "1.0.45",
26
26
  "main": "dist/server",
27
27
  "browser": "dist/client",
28
28
  "repository": {