targetj 1.0.260 → 1.1.1
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/Export.js +3 -0
- package/build/AnimationManager.js +221 -153
- package/build/AnimationUtil.js +0 -1
- package/build/App.js +82 -34
- package/build/BaseModel.js +51 -15
- package/build/Bracket.js +7 -1
- package/build/Easing.js +5 -0
- package/build/EventListener.js +37 -8
- package/build/HtmlToCanvas.js +411 -0
- package/build/LocationManager.js +167 -46
- package/build/PageManager.js +67 -115
- package/build/ParticleChild.js +576 -0
- package/build/ParticleExplode.js +360 -0
- package/build/ParticleRenderer.js +821 -159
- package/build/ParticleRuntime.js +1529 -381
- package/build/ParticleTModel.js +864 -293
- package/build/ParticleUtil.js +120 -172
- package/build/RunScheduler.js +23 -11
- package/build/StateManager.js +206 -57
- package/build/StateUtil.js +141 -82
- package/build/TModel.js +172 -73
- package/build/TModelManager.js +155 -132
- package/build/TModelUtil.js +232 -142
- package/build/TUtil.js +55 -50
- package/build/TargetData.js +26 -12
- package/build/TargetExecutor.js +48 -17
- package/build/TargetManager.js +47 -39
- package/build/TargetParser.js +57 -4
- package/build/TargetUtil.js +211 -129
- package/build/VisibilityUtil.js +4 -2
- package/build/index.js +1 -0
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/build/PageManager.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
2
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
4
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -18,10 +17,8 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
18
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
19
|
import { TUtil } from "./TUtil.js";
|
|
21
|
-
import { tApp, App,
|
|
20
|
+
import { tApp, App, getLocationManager, getEvents, getRunScheduler } from "./App.js";
|
|
22
21
|
import { DomInit } from "./DomInit.js";
|
|
23
|
-
import { $Dom } from "./$Dom.js";
|
|
24
|
-
import { TargetUtil } from "./TargetUtil.js";
|
|
25
22
|
import { TModelUtil } from "./TModelUtil.js";
|
|
26
23
|
|
|
27
24
|
/**
|
|
@@ -32,8 +29,7 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
32
29
|
function PageManager() {
|
|
33
30
|
_classCallCheck(this, PageManager);
|
|
34
31
|
this.currentLink = TUtil.getFullLink(document.URL);
|
|
35
|
-
this.
|
|
36
|
-
this.pageCache = {};
|
|
32
|
+
this.pageCache = new Map();
|
|
37
33
|
this.initHistory();
|
|
38
34
|
}
|
|
39
35
|
return _createClass(PageManager, [{
|
|
@@ -112,39 +108,42 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
112
108
|
case 0:
|
|
113
109
|
updateHistory = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
114
110
|
link = TUtil.getFullLink(link);
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
if (!(link === this.currentLink)) {
|
|
112
|
+
_context2.next = 4;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context2.abrupt("return");
|
|
117
116
|
case 4:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
case 7:
|
|
117
|
+
_context2.next = 6;
|
|
118
|
+
return this.storePage(this.currentLink);
|
|
119
|
+
case 6:
|
|
122
120
|
if (updateHistory) {
|
|
123
121
|
history.pushState({
|
|
124
122
|
link: link
|
|
125
123
|
}, "", link);
|
|
126
124
|
}
|
|
127
125
|
this.currentLink = link;
|
|
128
|
-
if (this.pageCache
|
|
129
|
-
_context2.next =
|
|
126
|
+
if (!this.pageCache.has(link)) {
|
|
127
|
+
_context2.next = 12;
|
|
130
128
|
break;
|
|
131
129
|
}
|
|
130
|
+
_context2.next = 11;
|
|
131
|
+
return this.restorePage(link);
|
|
132
|
+
case 11:
|
|
133
|
+
return _context2.abrupt("return");
|
|
134
|
+
case 12:
|
|
135
|
+
// Application was already stopped and reset by storePage().
|
|
132
136
|
tApp.tRoot.$dom.innerHTML("");
|
|
133
137
|
App.oids = {};
|
|
134
138
|
App.tmodelIdMap = {};
|
|
135
139
|
tApp.tRoot = tApp.tRootFactory();
|
|
136
|
-
_context2.next =
|
|
137
|
-
return tApp.start(
|
|
138
|
-
|
|
139
|
-
return _context2.abrupt("return");
|
|
140
|
-
case 17:
|
|
141
|
-
_context2.next = 19;
|
|
142
|
-
return this.restorePage(link, {
|
|
143
|
-
shouldReset: false
|
|
140
|
+
_context2.next = 18;
|
|
141
|
+
return tApp.start({
|
|
142
|
+
skipSchedulerReset: true
|
|
144
143
|
});
|
|
145
|
-
case
|
|
144
|
+
case 18:
|
|
146
145
|
getRunScheduler().schedule(0, "pagemanager-processOpenLink");
|
|
147
|
-
case
|
|
146
|
+
case 19:
|
|
148
147
|
case "end":
|
|
149
148
|
return _context2.stop();
|
|
150
149
|
}
|
|
@@ -160,37 +159,42 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
160
159
|
value: function back() {
|
|
161
160
|
return history.back();
|
|
162
161
|
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "getStateKey",
|
|
164
|
+
value: function getStateKey(link) {
|
|
165
|
+
return "page:".concat(TUtil.getFullLink(link));
|
|
166
|
+
}
|
|
163
167
|
}, {
|
|
164
168
|
key: "storePage",
|
|
165
169
|
value: function () {
|
|
166
170
|
var _storePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(link) {
|
|
167
|
-
var runSnapshot
|
|
171
|
+
var runSnapshot;
|
|
168
172
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
169
173
|
while (1) switch (_context3.prev = _context3.next) {
|
|
170
174
|
case 0:
|
|
171
|
-
runSnapshot = getRunScheduler().getSnapshot();
|
|
172
175
|
link = TUtil.getFullLink(link);
|
|
176
|
+
runSnapshot = getRunScheduler().getSnapshot();
|
|
173
177
|
_context3.next = 4;
|
|
174
178
|
return tApp.stop();
|
|
175
179
|
case 4:
|
|
176
180
|
getLocationManager().cancelCurrentCalculation();
|
|
177
181
|
this.onPageClose();
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
link: link,
|
|
182
|
-
html: html,
|
|
183
|
-
domState: TModelUtil.captureDomState($pageDom),
|
|
182
|
+
this.pageCache.set(link, {
|
|
183
|
+
html: TModelUtil.getPageDom().innerHTML(),
|
|
184
|
+
tRoot: tApp.tRoot,
|
|
184
185
|
oids: _objectSpread({}, App.oids),
|
|
185
186
|
tmodelIdMap: _objectSpread({}, App.tmodelIdMap),
|
|
186
187
|
visibleOidMap: _objectSpread({}, tApp.manager.visibleOidMap),
|
|
187
|
-
scrollLeft:
|
|
188
|
-
scrollTop:
|
|
189
|
-
tRoot: tApp.tRoot,
|
|
188
|
+
scrollLeft: window.scrollX,
|
|
189
|
+
scrollTop: window.scrollY,
|
|
190
190
|
runSnapshot: runSnapshot
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
});
|
|
192
|
+
_context3.next = 9;
|
|
193
|
+
return tApp.reset({
|
|
194
|
+
preserveCachedModels: true,
|
|
195
|
+
skipSchedulerReset: true
|
|
196
|
+
});
|
|
197
|
+
case 9:
|
|
194
198
|
case "end":
|
|
195
199
|
return _context3.stop();
|
|
196
200
|
}
|
|
@@ -205,77 +209,43 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
205
209
|
key: "restorePage",
|
|
206
210
|
value: function () {
|
|
207
211
|
var _restorePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(link) {
|
|
208
|
-
var
|
|
212
|
+
var cached, visibles, newVisibles, restored;
|
|
209
213
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
210
214
|
while (1) switch (_context4.prev = _context4.next) {
|
|
211
215
|
case 0:
|
|
212
|
-
|
|
213
|
-
if (
|
|
216
|
+
cached = this.pageCache.get(TUtil.getFullLink(link));
|
|
217
|
+
if (cached) {
|
|
214
218
|
_context4.next = 3;
|
|
215
219
|
break;
|
|
216
220
|
}
|
|
217
221
|
return _context4.abrupt("return", false);
|
|
218
222
|
case 3:
|
|
219
|
-
tApp.tRoot =
|
|
220
|
-
App.oids = _objectSpread({},
|
|
221
|
-
App.tmodelIdMap = _objectSpread({},
|
|
222
|
-
|
|
223
|
-
$pageDom.innerHTML(cache.html);
|
|
224
|
-
TModelUtil.restoreDomState($pageDom, cache.domState);
|
|
223
|
+
tApp.tRoot = cached.tRoot;
|
|
224
|
+
App.oids = _objectSpread({}, cached.oids);
|
|
225
|
+
App.tmodelIdMap = _objectSpread({}, cached.tmodelIdMap);
|
|
226
|
+
TModelUtil.getPageDom().innerHTML(cached.html);
|
|
225
227
|
tApp.tRoot.$dom = TModelUtil.getRootDom();
|
|
226
|
-
visibles = Object.values(
|
|
228
|
+
visibles = Object.values(cached.visibleOidMap);
|
|
227
229
|
newVisibles = DomInit.initCacheDoms(visibles);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (!tmodel.hasDom()) {
|
|
235
|
-
tmodel.markLayoutDirty('pageRestoreNoDom');
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
} catch (err) {
|
|
239
|
-
_iterator.e(err);
|
|
240
|
-
} finally {
|
|
241
|
-
_iterator.f();
|
|
242
|
-
}
|
|
243
|
-
TargetUtil.convertAnimatingTargetsToUpdating(restored);
|
|
244
|
-
tApp.manager.visibleOidMap = {};
|
|
245
|
-
_iterator2 = _createForOfIteratorHelper(restored);
|
|
246
|
-
try {
|
|
247
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
248
|
-
_tmodel = _step2.value;
|
|
249
|
-
if (_tmodel.isIncluded()) {
|
|
250
|
-
tApp.manager.visibleOidMap[_tmodel.oid] = _tmodel;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
} catch (err) {
|
|
254
|
-
_iterator2.e(err);
|
|
255
|
-
} finally {
|
|
256
|
-
_iterator2.f();
|
|
257
|
-
}
|
|
258
|
-
tApp.manager.activatePendingTargetsAfterDom(restored, {
|
|
259
|
-
restoredDoneTargets: true
|
|
230
|
+
visibles.forEach(function (tmodel) {
|
|
231
|
+
tmodel.visibilityStatus = undefined;
|
|
232
|
+
});
|
|
233
|
+
tApp.manager.visibleOidMap = _objectSpread({}, cached.visibleOidMap);
|
|
234
|
+
newVisibles.forEach(function (tmodel) {
|
|
235
|
+
tApp.manager.visibleOidMap[tmodel.oid] = tmodel;
|
|
260
236
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
_context4.next =
|
|
266
|
-
return tApp.start(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
_context4.next = 30;
|
|
272
|
-
return TModelUtil.restoreScroll(cache);
|
|
273
|
-
case 30:
|
|
274
|
-
_context4.next = 32;
|
|
275
|
-
return TModelUtil.restoreDomInteractionState($restoredPageDom, cache.domState);
|
|
276
|
-
case 32:
|
|
237
|
+
restored = _toConsumableArray(new Set([].concat(visibles, _toConsumableArray(newVisibles))));
|
|
238
|
+
tApp.manager.activatePendingTargetsAfterDom(restored);
|
|
239
|
+
window.scrollTo(cached.scrollLeft, cached.scrollTop);
|
|
240
|
+
tApp.tRoot.markLayoutDirty("pageCacheRestore");
|
|
241
|
+
_context4.next = 19;
|
|
242
|
+
return tApp.start({
|
|
243
|
+
skipSchedulerReset: true
|
|
244
|
+
});
|
|
245
|
+
case 19:
|
|
246
|
+
getRunScheduler().restoreSnapshot(cached.runSnapshot);
|
|
277
247
|
return _context4.abrupt("return", true);
|
|
278
|
-
case
|
|
248
|
+
case 21:
|
|
279
249
|
case "end":
|
|
280
250
|
return _context4.stop();
|
|
281
251
|
}
|
|
@@ -286,24 +256,6 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
286
256
|
}
|
|
287
257
|
return restorePage;
|
|
288
258
|
}()
|
|
289
|
-
}, {
|
|
290
|
-
key: "getCachedPage",
|
|
291
|
-
value: function getCachedPage() {
|
|
292
|
-
var link = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastCachedLink;
|
|
293
|
-
if (!link) {
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
link = TUtil.getFullLink(link);
|
|
297
|
-
return this.pageCache[link];
|
|
298
|
-
}
|
|
299
|
-
}, {
|
|
300
|
-
key: "getCachedTModel",
|
|
301
|
-
value: function getCachedTModel(id) {
|
|
302
|
-
var _page$tmodelIdMap;
|
|
303
|
-
var link = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.lastCachedLink;
|
|
304
|
-
var page = this.getCachedPage(link);
|
|
305
|
-
return page === null || page === void 0 || (_page$tmodelIdMap = page.tmodelIdMap) === null || _page$tmodelIdMap === void 0 ? void 0 : _page$tmodelIdMap[id];
|
|
306
|
-
}
|
|
307
259
|
}]);
|
|
308
260
|
}();
|
|
309
261
|
export { PageManager };
|