@next-core/brick-kit 2.118.7 → 2.120.0
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/CHANGELOG.md +32 -0
- package/dist/index.bundle.js +70 -10
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +70 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/LocationContext.d.ts +5 -0
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/MockRegistry.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -5792,11 +5792,14 @@ function registerMock(useMocks) {
|
|
|
5792
5792
|
var _useMocks$mockList;
|
|
5793
5793
|
|
|
5794
5794
|
if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
|
|
5795
|
-
mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item =>
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5795
|
+
mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => {
|
|
5796
|
+
var isFlowAPi = isCustomApiProvider(item.provider);
|
|
5797
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
5798
|
+
uri: "".concat(isFlowAPi ? item.uri.replace(/(.+?)\/(.+)/, (_match, p1, p2) => {
|
|
5799
|
+
return "/".concat(p1, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p2, "$");
|
|
5800
|
+
}) : "/".concat(item.uri.split(".").slice(2).join("."), "$")).replace(/:\w+/g, "([^/]+)")
|
|
5801
|
+
});
|
|
5802
|
+
})
|
|
5800
5803
|
});
|
|
5801
5804
|
}
|
|
5802
5805
|
function getMockList() {
|
|
@@ -5816,6 +5819,7 @@ var getMockInfo = (requestUrl, method) => {
|
|
|
5816
5819
|
if (item) {
|
|
5817
5820
|
return {
|
|
5818
5821
|
url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
|
|
5822
|
+
// 忽略版本
|
|
5819
5823
|
return "".concat(p1, "/").concat(p3);
|
|
5820
5824
|
}).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
|
|
5821
5825
|
mockId: mocks.mockId
|
|
@@ -9073,12 +9077,16 @@ class LocationContext {
|
|
|
9073
9077
|
|
|
9074
9078
|
_defineProperty$1(this, "messageHandlers", []);
|
|
9075
9079
|
|
|
9080
|
+
_defineProperty$1(this, "scrollIntoViewHandlersMap", new Map());
|
|
9081
|
+
|
|
9076
9082
|
_defineProperty$1(this, "segues", {});
|
|
9077
9083
|
|
|
9078
9084
|
_defineProperty$1(this, "currentMatch", void 0);
|
|
9079
9085
|
|
|
9080
9086
|
_defineProperty$1(this, "storyboardContextWrapper", new StoryboardContextWrapper());
|
|
9081
9087
|
|
|
9088
|
+
_defineProperty$1(this, "observersList", []);
|
|
9089
|
+
|
|
9082
9090
|
this.kernel = kernel;
|
|
9083
9091
|
this.location = location;
|
|
9084
9092
|
this.resolver = new Resolver(kernel);
|
|
@@ -9445,7 +9453,7 @@ class LocationContext {
|
|
|
9445
9453
|
_this6 = this;
|
|
9446
9454
|
|
|
9447
9455
|
return _asyncToGenerator$4(function* () {
|
|
9448
|
-
var _this6$kernel$nextApp;
|
|
9456
|
+
var _this6$kernel$nextApp, _brickConf$lifeCycle, _brick$lifeCycle;
|
|
9449
9457
|
|
|
9450
9458
|
var tplStack = _arguments.length > 4 && _arguments[4] !== undefined ? _arguments[4] : [];
|
|
9451
9459
|
var tplContextId = brickConf[symbolForTplContextId];
|
|
@@ -9486,7 +9494,7 @@ class LocationContext {
|
|
|
9486
9494
|
yield _this6.storyboardContextWrapper.define(brickConf.context, context, brick);
|
|
9487
9495
|
yield _this6.preCheckPermissions(brickConf, context);
|
|
9488
9496
|
var trackingContextList = [];
|
|
9489
|
-
Object.assign(brick, {
|
|
9497
|
+
Object.assign(brick, _objectSpread({
|
|
9490
9498
|
type: tplTagName || brickConf.brick,
|
|
9491
9499
|
properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
|
|
9492
9500
|
events: isObject(brickConf.events) ? brickConf.events : {},
|
|
@@ -9496,7 +9504,11 @@ class LocationContext {
|
|
|
9496
9504
|
refForProxy: brickConf[symbolForRefForProxy],
|
|
9497
9505
|
tplContextId,
|
|
9498
9506
|
iid: brickConf.iid
|
|
9499
|
-
})
|
|
9507
|
+
}, (_brickConf$lifeCycle = brickConf.lifeCycle) !== null && _brickConf$lifeCycle !== void 0 && _brickConf$lifeCycle.onScrollIntoView ? {
|
|
9508
|
+
lifeCycle: {
|
|
9509
|
+
onScrollIntoView: brickConf.lifeCycle.onScrollIntoView
|
|
9510
|
+
}
|
|
9511
|
+
} : {}));
|
|
9500
9512
|
|
|
9501
9513
|
if (brickConf[symbolForComputedPropsFromProxy]) {
|
|
9502
9514
|
Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref2 => {
|
|
@@ -9511,7 +9523,11 @@ class LocationContext {
|
|
|
9511
9523
|
brick.refForProxy.brick = brick;
|
|
9512
9524
|
}
|
|
9513
9525
|
|
|
9514
|
-
_this6.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
|
|
9526
|
+
_this6.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
|
|
9527
|
+
|
|
9528
|
+
if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
|
|
9529
|
+
_this6.brickBindObserver(brick);
|
|
9530
|
+
} // Then, resolve the brick.
|
|
9515
9531
|
|
|
9516
9532
|
|
|
9517
9533
|
yield _this6.resolver.resolve(brickConf, brick, context);
|
|
@@ -9586,7 +9602,8 @@ class LocationContext {
|
|
|
9586
9602
|
onAnchorUnload,
|
|
9587
9603
|
onMediaChange,
|
|
9588
9604
|
onMessage,
|
|
9589
|
-
onMessageClose
|
|
9605
|
+
onMessageClose,
|
|
9606
|
+
onScrollIntoView
|
|
9590
9607
|
} = lifeCycle !== null && lifeCycle !== void 0 ? lifeCycle : {};
|
|
9591
9608
|
|
|
9592
9609
|
if (onBeforePageLoad) {
|
|
@@ -9669,6 +9686,15 @@ class LocationContext {
|
|
|
9669
9686
|
handler: onMessageClose
|
|
9670
9687
|
});
|
|
9671
9688
|
}
|
|
9689
|
+
|
|
9690
|
+
if (onScrollIntoView) {
|
|
9691
|
+
this.scrollIntoViewHandlersMap.set(brick.iid, {
|
|
9692
|
+
brick,
|
|
9693
|
+
match,
|
|
9694
|
+
tplContextId,
|
|
9695
|
+
handler: onScrollIntoView.handlers
|
|
9696
|
+
});
|
|
9697
|
+
}
|
|
9672
9698
|
}
|
|
9673
9699
|
|
|
9674
9700
|
handleBeforePageLoad() {
|
|
@@ -9723,6 +9749,17 @@ class LocationContext {
|
|
|
9723
9749
|
}), this.messageCloseHandlers);
|
|
9724
9750
|
}
|
|
9725
9751
|
|
|
9752
|
+
handleScrollIntoView(id) {
|
|
9753
|
+
var currentHandlers = this.scrollIntoViewHandlersMap.get(id);
|
|
9754
|
+
this.dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), [currentHandlers]);
|
|
9755
|
+
}
|
|
9756
|
+
|
|
9757
|
+
handleBrickBindObserver() {
|
|
9758
|
+
this.observersList.forEach(value => {
|
|
9759
|
+
value.$$observe();
|
|
9760
|
+
});
|
|
9761
|
+
}
|
|
9762
|
+
|
|
9726
9763
|
getCurrentMatch() {
|
|
9727
9764
|
return this.currentMatch;
|
|
9728
9765
|
}
|
|
@@ -9755,6 +9792,27 @@ class LocationContext {
|
|
|
9755
9792
|
})();
|
|
9756
9793
|
}
|
|
9757
9794
|
|
|
9795
|
+
brickBindObserver(brick) {
|
|
9796
|
+
var _brick$lifeCycle$onSc;
|
|
9797
|
+
|
|
9798
|
+
var threshold = (_brick$lifeCycle$onSc = brick.lifeCycle.onScrollIntoView.threshold) !== null && _brick$lifeCycle$onSc !== void 0 ? _brick$lifeCycle$onSc : 0.1;
|
|
9799
|
+
var observer = new IntersectionObserver((entries, observer) => {
|
|
9800
|
+
entries.forEach(entry => {
|
|
9801
|
+
if (entry.isIntersecting) {
|
|
9802
|
+
if (entry.intersectionRatio >= threshold) {
|
|
9803
|
+
this.handleScrollIntoView(brick.iid);
|
|
9804
|
+
observer.disconnect();
|
|
9805
|
+
}
|
|
9806
|
+
}
|
|
9807
|
+
});
|
|
9808
|
+
}, {
|
|
9809
|
+
threshold
|
|
9810
|
+
});
|
|
9811
|
+
this.observersList.push({
|
|
9812
|
+
$$observe: () => observer.observe(brick.element)
|
|
9813
|
+
});
|
|
9814
|
+
}
|
|
9815
|
+
|
|
9758
9816
|
}
|
|
9759
9817
|
|
|
9760
9818
|
function unmountTree(mountPoint) {
|
|
@@ -10634,6 +10692,8 @@ class Router {
|
|
|
10634
10692
|
window.scrollTo(0, 0);
|
|
10635
10693
|
|
|
10636
10694
|
if (!failed) {
|
|
10695
|
+
_this3.locationContext.handleBrickBindObserver();
|
|
10696
|
+
|
|
10637
10697
|
_this3.locationContext.handlePageLoad();
|
|
10638
10698
|
|
|
10639
10699
|
_this3.locationContext.handleAnchorLoad();
|