@motifx/core 1.2.0-rc.1 → 1.2.0-rc.2
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/dist/chunks/{core-vVL0WG0n.esm.js → core-C5z0P3iY.esm.js} +55 -20
- package/dist/chunks/core-C5z0P3iY.esm.js.map +1 -0
- package/dist/chunks/{core-SS-LXi1V.cjs → core-CX1Sz73P.cjs} +55 -20
- package/dist/chunks/core-CX1Sz73P.cjs.map +1 -0
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.esm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +54 -19
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-SS-LXi1V.cjs.map +0 -1
- package/dist/chunks/core-vVL0WG0n.esm.js.map +0 -1
|
@@ -9163,6 +9163,7 @@ class ScrollMemory {
|
|
|
9163
9163
|
viewport;
|
|
9164
9164
|
positions = new Map();
|
|
9165
9165
|
currentKey = '';
|
|
9166
|
+
currentPath = null;
|
|
9166
9167
|
visited = false;
|
|
9167
9168
|
restoring = false;
|
|
9168
9169
|
cancelFrame = null;
|
|
@@ -9194,11 +9195,13 @@ class ScrollMemory {
|
|
|
9194
9195
|
this.remember(this.currentKey, this.viewport.scrollTop());
|
|
9195
9196
|
this.persist();
|
|
9196
9197
|
}
|
|
9197
|
-
arrived(uri) {
|
|
9198
|
+
arrived(uri, direction) {
|
|
9198
9199
|
this.visited = true;
|
|
9199
9200
|
const { path, hash } = splitUri(uri);
|
|
9201
|
+
const inPage = !!hash && path === this.currentPath && (direction === 'push' || direction === 'replace' || direction === 'traverse');
|
|
9202
|
+
this.currentPath = path;
|
|
9200
9203
|
this.currentKey = this.keyOf(path);
|
|
9201
|
-
this.restore(this.currentKey, this.options.anchor === false ? '' : hash || (this.locationAnchor ? locationHash() : ''));
|
|
9204
|
+
this.restore(this.currentKey, this.options.anchor === false ? '' : hash || (this.locationAnchor ? locationHash() : ''), inPage);
|
|
9202
9205
|
}
|
|
9203
9206
|
saved(key) {
|
|
9204
9207
|
return this.positions.get(this.keyOf(splitUri(key).path)) ?? 0;
|
|
@@ -9225,7 +9228,7 @@ class ScrollMemory {
|
|
|
9225
9228
|
this.positions.delete(oldest.value);
|
|
9226
9229
|
}
|
|
9227
9230
|
}
|
|
9228
|
-
restore(key, anchor) {
|
|
9231
|
+
restore(key, anchor, follow) {
|
|
9229
9232
|
this.cancelRestore();
|
|
9230
9233
|
const target = this.positions.get(key) ?? 0;
|
|
9231
9234
|
if (!anchor && target <= 0) {
|
|
@@ -9238,7 +9241,7 @@ class ScrollMemory {
|
|
|
9238
9241
|
const startedAt = Date.now();
|
|
9239
9242
|
const attempt = () => {
|
|
9240
9243
|
this.cancelFrame = null;
|
|
9241
|
-
const done = anchor ? this.viewport.scrollToAnchor(anchor) : this.reached(target);
|
|
9244
|
+
const done = anchor ? this.viewport.scrollToAnchor(anchor, follow) : this.reached(target);
|
|
9242
9245
|
if (done || Date.now() - startedAt >= settleMs) {
|
|
9243
9246
|
this.cancelRestore();
|
|
9244
9247
|
this.remember(key, this.viewport.scrollTop());
|
|
@@ -9330,16 +9333,30 @@ function windowViewport() {
|
|
|
9330
9333
|
},
|
|
9331
9334
|
scrollTo: (top) => {
|
|
9332
9335
|
try {
|
|
9333
|
-
window.scrollTo(
|
|
9336
|
+
window.scrollTo({ top, behavior: 'instant' });
|
|
9337
|
+
}
|
|
9338
|
+
catch {
|
|
9339
|
+
try {
|
|
9340
|
+
window.scrollTo(0, top);
|
|
9341
|
+
}
|
|
9342
|
+
catch { }
|
|
9334
9343
|
}
|
|
9335
|
-
catch { }
|
|
9336
9344
|
},
|
|
9337
|
-
scrollToAnchor: (id) => {
|
|
9345
|
+
scrollToAnchor: (id, follow) => {
|
|
9338
9346
|
try {
|
|
9339
9347
|
const node = document.getElementById(id);
|
|
9340
9348
|
if (!node)
|
|
9341
9349
|
return false;
|
|
9342
|
-
|
|
9350
|
+
if (follow)
|
|
9351
|
+
node.scrollIntoView();
|
|
9352
|
+
else {
|
|
9353
|
+
try {
|
|
9354
|
+
node.scrollIntoView({ behavior: 'instant' });
|
|
9355
|
+
}
|
|
9356
|
+
catch {
|
|
9357
|
+
node.scrollIntoView();
|
|
9358
|
+
}
|
|
9359
|
+
}
|
|
9343
9360
|
return true;
|
|
9344
9361
|
}
|
|
9345
9362
|
catch {
|
|
@@ -9376,11 +9393,16 @@ function containerViewport(container) {
|
|
|
9376
9393
|
return;
|
|
9377
9394
|
}
|
|
9378
9395
|
try {
|
|
9379
|
-
el.
|
|
9396
|
+
el.scrollTo({ top, behavior: 'instant' });
|
|
9397
|
+
}
|
|
9398
|
+
catch {
|
|
9399
|
+
try {
|
|
9400
|
+
el.scrollTop = top;
|
|
9401
|
+
}
|
|
9402
|
+
catch { }
|
|
9380
9403
|
}
|
|
9381
|
-
catch { }
|
|
9382
9404
|
},
|
|
9383
|
-
scrollToAnchor: (id) => fallback.scrollToAnchor(id),
|
|
9405
|
+
scrollToAnchor: (id, follow) => fallback.scrollToAnchor(id, follow),
|
|
9384
9406
|
};
|
|
9385
9407
|
}
|
|
9386
9408
|
/** `/docs/x#bolum` → `{ path: '/docs/x', hash: 'bolum' }`. */
|
|
@@ -11234,7 +11256,7 @@ class UrlRoutingModule {
|
|
|
11234
11256
|
const h = w?.location?.hash || '';
|
|
11235
11257
|
return h && h.startsWith('#') ? h.slice(1) || '/' : '/';
|
|
11236
11258
|
}
|
|
11237
|
-
return (w?.location?.pathname || '/') + (w?.location?.search || '');
|
|
11259
|
+
return (w?.location?.pathname || '/') + (w?.location?.search || '') + (w?.location?.hash || '');
|
|
11238
11260
|
}
|
|
11239
11261
|
catch {
|
|
11240
11262
|
return '/';
|
|
@@ -11509,7 +11531,7 @@ class UrlRoutingModule {
|
|
|
11509
11531
|
}
|
|
11510
11532
|
const snapshotOf = (result) => ({
|
|
11511
11533
|
target: result,
|
|
11512
|
-
chain:
|
|
11534
|
+
chain: this.chainOf(result),
|
|
11513
11535
|
direction,
|
|
11514
11536
|
state: entryState,
|
|
11515
11537
|
});
|
|
@@ -11553,7 +11575,7 @@ class UrlRoutingModule {
|
|
|
11553
11575
|
this._handleScrollBehavior(navOptions.scroll);
|
|
11554
11576
|
}
|
|
11555
11577
|
else {
|
|
11556
|
-
this._scroll?.arrived(this._uriWithHash(appliedPath, uri));
|
|
11578
|
+
this._scroll?.arrived(this._uriWithHash(appliedPath, uri), direction);
|
|
11557
11579
|
}
|
|
11558
11580
|
this.application.fire?.('motifjs-router-navigated', {
|
|
11559
11581
|
uri: appliedPath,
|
|
@@ -11735,6 +11757,9 @@ class UrlRoutingModule {
|
|
|
11735
11757
|
}
|
|
11736
11758
|
return { proceed, uri: urix };
|
|
11737
11759
|
}
|
|
11760
|
+
chainOf(result) {
|
|
11761
|
+
return result.chain.map(r => this.routingEngine.generatePathString(r.path, result.params) || '');
|
|
11762
|
+
}
|
|
11738
11763
|
resolve(uri) {
|
|
11739
11764
|
const candidates = [];
|
|
11740
11765
|
const pageSearch = this._pageSearch();
|
|
@@ -11932,8 +11957,14 @@ class UrlRoutingModule {
|
|
|
11932
11957
|
return;
|
|
11933
11958
|
}
|
|
11934
11959
|
if (w?.history && typeof w.history.pushState === 'function') {
|
|
11935
|
-
const current = (w.location.pathname || '/') + (w.location.search || '');
|
|
11936
|
-
|
|
11960
|
+
const current = (w.location.pathname || '/') + (w.location.search || '') + (w.location.hash || '');
|
|
11961
|
+
let wanted = uri;
|
|
11962
|
+
try {
|
|
11963
|
+
const url = new URL(uri, w.location.href);
|
|
11964
|
+
wanted = url.pathname + url.search + url.hash;
|
|
11965
|
+
}
|
|
11966
|
+
catch { }
|
|
11967
|
+
if (current !== wanted) {
|
|
11937
11968
|
if (options.replace) {
|
|
11938
11969
|
const stamp = this._nextHistoryStamp(false);
|
|
11939
11970
|
w.history.replaceState(this._routerState(options.state, stamp), '', uri);
|
|
@@ -12118,15 +12149,19 @@ function createRouter(state, module) {
|
|
|
12118
12149
|
return module()?.routeInfos() ?? [];
|
|
12119
12150
|
},
|
|
12120
12151
|
navigate: async (uri, options) => {
|
|
12121
|
-
await required().navigate(uri, options);
|
|
12152
|
+
return await required().navigate(uri, options);
|
|
12122
12153
|
},
|
|
12123
12154
|
navigateByName: async (name, params, options) => {
|
|
12124
|
-
await required().navigateByName(name, params, options);
|
|
12155
|
+
return await required().navigateByName(name, params, options);
|
|
12125
12156
|
},
|
|
12126
12157
|
evict: async (route) => {
|
|
12127
12158
|
await required().evict(route);
|
|
12128
12159
|
},
|
|
12129
|
-
resolve: (uri) =>
|
|
12160
|
+
resolve: (uri) => {
|
|
12161
|
+
const current = required();
|
|
12162
|
+
const result = current.resolve(uri);
|
|
12163
|
+
return { chain: current.chainOf(result), result };
|
|
12164
|
+
},
|
|
12130
12165
|
href: (name, params) => required().href(name, params),
|
|
12131
12166
|
};
|
|
12132
12167
|
}
|
|
@@ -12594,4 +12629,4 @@ exports.untracked = untracked;
|
|
|
12594
12629
|
exports.useApplication = useApplication;
|
|
12595
12630
|
exports.useModel = useModel;
|
|
12596
12631
|
exports.useNavigation = useNavigation;
|
|
12597
|
-
//# sourceMappingURL=core-
|
|
12632
|
+
//# sourceMappingURL=core-CX1Sz73P.cjs.map
|