ember-source 4.3.0-alpha.3 → 4.3.0-beta.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/CHANGELOG.md +10 -2
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +1163 -773
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +74 -43
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3078 -2562
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +15 -10
- package/dist/packages/@ember/-internals/glimmer/index.js +113 -45
- package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
- package/dist/packages/@ember/-internals/metal/index.js +44 -45
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +165 -197
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +96 -375
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +62 -35
- package/dist/packages/@ember/-internals/routing/lib/utils.js +31 -20
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
- package/dist/packages/@ember/-internals/utils/index.js +2 -0
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +420 -352
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# Ember Changelog
|
|
2
2
|
|
|
3
|
-
### v4.
|
|
3
|
+
### v4.3.0-beta.2 (March 1, 2022)
|
|
4
4
|
|
|
5
|
-
- [#
|
|
5
|
+
- [#19971](https://github.com/emberjs/ember.js/pull/19971) [BUGFIX] Don't serialize default Query Params on RouterService
|
|
6
|
+
|
|
7
|
+
### v4.3.0-beta.1 (February 7, 2022)
|
|
8
|
+
|
|
9
|
+
No public API changes or bugfixes.
|
|
10
|
+
|
|
11
|
+
### v4.2.0 (February 7, 2022)
|
|
12
|
+
|
|
13
|
+
- [#19878](https://github.com/emberjs/ember.js/pull/19878) [BUGFIX] Allow class-based helpers to work in strict-mode.
|
|
6
14
|
|
|
7
15
|
### v4.1.0 (December 28, 2021)
|
|
8
16
|
|
package/build-metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.3.0-
|
|
2
|
+
"version": "4.3.0-beta.2",
|
|
3
3
|
"buildType": "tag",
|
|
4
|
-
"SHA": "
|
|
5
|
-
"assetPath": "/tag/shas/
|
|
4
|
+
"SHA": "f4b50b5134f125d32b95e2900631bc24f7ccffd6",
|
|
5
|
+
"assetPath": "/tag/shas/f4b50b5134f125d32b95e2900631bc24f7ccffd6.tgz"
|
|
6
6
|
}
|
|
@@ -48,16 +48,22 @@ function extractQueryParams(array) {
|
|
|
48
48
|
let len = array && array.length, head, queryParams;
|
|
49
49
|
if (len && len > 0) {
|
|
50
50
|
let obj = array[len - 1];
|
|
51
|
-
if (
|
|
51
|
+
if (isQueryParamsContainer(obj)) {
|
|
52
52
|
queryParams = obj.queryParams;
|
|
53
53
|
head = slice.call(array, 0, len - 1);
|
|
54
54
|
return [head, queryParams];
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
// SAFETY: We confirmed that the last item isn't a QP container
|
|
57
58
|
return [array, null];
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
// TODO: Actually check that Dict is QueryParams
|
|
61
|
+
function isQueryParamsContainer(obj) {
|
|
62
|
+
if (obj && typeof obj === 'object') {
|
|
63
|
+
let cast = obj;
|
|
64
|
+
return ('queryParams' in cast && Object.keys(cast.queryParams).every((k) => typeof k === 'string'));
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
61
67
|
}
|
|
62
68
|
/**
|
|
63
69
|
@private
|
|
@@ -498,11 +504,13 @@ let ROUTE_INFOS = new WeakMap();
|
|
|
498
504
|
function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = false) {
|
|
499
505
|
return routeInfos.map((info, i) => {
|
|
500
506
|
let { name, params, paramNames, context, route } = info;
|
|
501
|
-
|
|
502
|
-
|
|
507
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
508
|
+
let key = info;
|
|
509
|
+
if (ROUTE_INFOS.has(key) && includeAttributes) {
|
|
510
|
+
let routeInfo = ROUTE_INFOS.get(key);
|
|
503
511
|
routeInfo = attachMetadata(route, routeInfo);
|
|
504
512
|
let routeInfoWithAttribute = createRouteInfoWithAttributes(routeInfo, context);
|
|
505
|
-
ROUTE_INFOS.set(
|
|
513
|
+
ROUTE_INFOS.set(key, routeInfoWithAttribute);
|
|
506
514
|
return routeInfoWithAttribute;
|
|
507
515
|
}
|
|
508
516
|
let routeInfo = {
|
|
@@ -510,9 +518,12 @@ function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = f
|
|
|
510
518
|
let publicInfo;
|
|
511
519
|
let arr = [];
|
|
512
520
|
if (predicate.length === 3) {
|
|
513
|
-
arr = routeInfos.map(
|
|
521
|
+
arr = routeInfos.map(
|
|
522
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
523
|
+
(info) => ROUTE_INFOS.get(info));
|
|
514
524
|
}
|
|
515
525
|
for (let i = 0; routeInfos.length > i; i++) {
|
|
526
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
516
527
|
publicInfo = ROUTE_INFOS.get(routeInfos[i]);
|
|
517
528
|
if (predicate.call(thisArg, publicInfo, i, arr)) {
|
|
518
529
|
return publicInfo;
|
|
@@ -534,6 +545,7 @@ function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = f
|
|
|
534
545
|
if (parent === undefined) {
|
|
535
546
|
return null;
|
|
536
547
|
}
|
|
548
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
537
549
|
return ROUTE_INFOS.get(parent);
|
|
538
550
|
},
|
|
539
551
|
get child() {
|
|
@@ -541,6 +553,7 @@ function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = f
|
|
|
541
553
|
if (child === undefined) {
|
|
542
554
|
return null;
|
|
543
555
|
}
|
|
556
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
544
557
|
return ROUTE_INFOS.get(child);
|
|
545
558
|
},
|
|
546
559
|
get localName() {
|
|
@@ -557,6 +570,7 @@ function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = f
|
|
|
557
570
|
if (includeAttributes) {
|
|
558
571
|
routeInfo = createRouteInfoWithAttributes(routeInfo, context);
|
|
559
572
|
}
|
|
573
|
+
// SAFETY: This should be safe since it is just for use as a key
|
|
560
574
|
ROUTE_INFOS.set(info, routeInfo);
|
|
561
575
|
return routeInfo;
|
|
562
576
|
});
|
|
@@ -636,10 +650,12 @@ class InternalRouteInfo {
|
|
|
636
650
|
if ('context' in this || !contextsMatch) {
|
|
637
651
|
context = resolvedContext;
|
|
638
652
|
}
|
|
653
|
+
// SAFETY: Since this is just for lookup, it should be safe
|
|
639
654
|
let cached = ROUTE_INFOS.get(this);
|
|
640
655
|
let resolved = new ResolvedRouteInfo(this.router, this.name, this.paramNames, params, this.route, context);
|
|
641
656
|
if (cached !== undefined) {
|
|
642
|
-
|
|
657
|
+
// SAFETY: This is potentially a bit risker, but for what we're doing, it should be ok.
|
|
658
|
+
ROUTE_INFOS.set(this, cached);
|
|
643
659
|
}
|
|
644
660
|
return resolved;
|
|
645
661
|
}
|
|
@@ -720,11 +736,13 @@ class InternalRouteInfo {
|
|
|
720
736
|
// Ignore the fulfilled value returned from afterModel.
|
|
721
737
|
// Return the value stashed in resolvedModels, which
|
|
722
738
|
// might have been swapped out in afterModel.
|
|
739
|
+
// SAFTEY: We expect this to be of type T, though typing it as such is challenging.
|
|
723
740
|
return transition.resolvedModels[name];
|
|
724
741
|
});
|
|
725
742
|
}
|
|
726
743
|
stashResolvedModel(transition, resolvedModel) {
|
|
727
744
|
transition.resolvedModels = transition.resolvedModels || {};
|
|
745
|
+
// SAFETY: It's unfortunate that we have to do this cast. It should be safe though.
|
|
728
746
|
transition.resolvedModels[this.name] = resolvedModel;
|
|
729
747
|
}
|
|
730
748
|
fetchRoute() {
|
|
@@ -768,7 +786,9 @@ class UnresolvedRouteInfoByParam extends InternalRouteInfo {
|
|
|
768
786
|
constructor(router, name, paramNames, params, route) {
|
|
769
787
|
super(router, name, paramNames, route);
|
|
770
788
|
this.params = {};
|
|
771
|
-
|
|
789
|
+
if (params) {
|
|
790
|
+
this.params = params;
|
|
791
|
+
}
|
|
772
792
|
}
|
|
773
793
|
getModel(transition) {
|
|
774
794
|
let fullParams = this.params;
|
|
@@ -779,6 +799,7 @@ class UnresolvedRouteInfoByParam extends InternalRouteInfo {
|
|
|
779
799
|
}
|
|
780
800
|
let route = this.route;
|
|
781
801
|
let result;
|
|
802
|
+
// FIXME: Review these casts
|
|
782
803
|
if (route.deserialize) {
|
|
783
804
|
result = route.deserialize(fullParams, transition);
|
|
784
805
|
}
|
|
@@ -815,6 +836,8 @@ class UnresolvedRouteInfoByObject extends InternalRouteInfo {
|
|
|
815
836
|
serialize(model) {
|
|
816
837
|
let { paramNames, context } = this;
|
|
817
838
|
if (!model) {
|
|
839
|
+
// SAFETY: By the time we serialize, we expect to be resolved.
|
|
840
|
+
// This may not be an entirely safe assumption though no tests fail.
|
|
818
841
|
model = context;
|
|
819
842
|
}
|
|
820
843
|
let object = {};
|
|
@@ -837,6 +860,7 @@ class UnresolvedRouteInfoByObject extends InternalRouteInfo {
|
|
|
837
860
|
}
|
|
838
861
|
let name = paramNames[0];
|
|
839
862
|
if (/_id$/.test(name)) {
|
|
863
|
+
// SAFETY: Model is supposed to extend IModel already
|
|
840
864
|
object[name] = model.id;
|
|
841
865
|
}
|
|
842
866
|
else {
|
|
@@ -846,14 +870,14 @@ class UnresolvedRouteInfoByObject extends InternalRouteInfo {
|
|
|
846
870
|
}
|
|
847
871
|
}
|
|
848
872
|
function paramsMatch(a, b) {
|
|
849
|
-
if (
|
|
850
|
-
//
|
|
851
|
-
return false;
|
|
852
|
-
}
|
|
853
|
-
if (!a) {
|
|
854
|
-
// Both must be null.
|
|
873
|
+
if (a === b) {
|
|
874
|
+
// Both are identical, may both be undefined
|
|
855
875
|
return true;
|
|
856
876
|
}
|
|
877
|
+
if (!a || !b) {
|
|
878
|
+
// Only one is undefined, already checked they aren't identical
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
857
881
|
// Note: this assumes that both params have the same
|
|
858
882
|
// number of keys, but since we're comparing the
|
|
859
883
|
// same routes, they should.
|
|
@@ -887,9 +911,8 @@ function resolveOneRouteInfo(currentState, transition) {
|
|
|
887
911
|
return;
|
|
888
912
|
}
|
|
889
913
|
let routeInfo = currentState.routeInfos[transition.resolveIndex];
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
.then(proceed.bind(null, currentState, transition), null, currentState.promiseLabel('Proceed'));
|
|
914
|
+
let callback = proceed.bind(null, currentState, transition);
|
|
915
|
+
return routeInfo.resolve(transition).then(callback, null, currentState.promiseLabel('Proceed'));
|
|
893
916
|
}
|
|
894
917
|
function proceed(currentState, transition, resolvedRouteInfo) {
|
|
895
918
|
let wasAlreadyResolved = currentState.routeInfos[transition.resolveIndex].isResolved;
|
|
@@ -939,10 +962,12 @@ class TransitionState {
|
|
|
939
962
|
return true;
|
|
940
963
|
});
|
|
941
964
|
transition.resolveIndex = 0;
|
|
965
|
+
let callback = resolveOneRouteInfo.bind(null, this, transition);
|
|
966
|
+
let errorHandler = handleError.bind(null, this, transition);
|
|
942
967
|
// The prelude RSVP.resolve() async moves us into the promise land.
|
|
943
968
|
return Promise.resolve(null, this.promiseLabel('Start transition'))
|
|
944
|
-
.then(
|
|
945
|
-
.catch(
|
|
969
|
+
.then(callback, null, this.promiseLabel('Resolve route'))
|
|
970
|
+
.catch(errorHandler, this.promiseLabel('Handle error'))
|
|
946
971
|
.then(() => this);
|
|
947
972
|
}
|
|
948
973
|
}
|
|
@@ -965,8 +990,7 @@ class NamedTransitionIntent extends TransitionIntent {
|
|
|
965
990
|
this.queryParams = queryParams;
|
|
966
991
|
}
|
|
967
992
|
applyToState(oldState, isIntermediate) {
|
|
968
|
-
|
|
969
|
-
let partitionedArgs = extractQueryParams([this.name].concat(this.contexts)), pureArgs = partitionedArgs[0], handlers = this.router.recognizer.handlersFor(pureArgs[0]);
|
|
993
|
+
let handlers = this.router.recognizer.handlersFor(this.name);
|
|
970
994
|
let targetRouteName = handlers[handlers.length - 1].handler;
|
|
971
995
|
return this.applyToHandlers(oldState, handlers, targetRouteName, isIntermediate, false);
|
|
972
996
|
}
|
|
@@ -1008,7 +1032,9 @@ class NamedTransitionIntent extends TransitionIntent {
|
|
|
1008
1032
|
// If we're performing an isActive check, we want to
|
|
1009
1033
|
// serialize URL params with the provided context, but
|
|
1010
1034
|
// ignore mismatches between old and new context.
|
|
1011
|
-
newHandlerInfo = newHandlerInfo.becomeResolved(null,
|
|
1035
|
+
newHandlerInfo = newHandlerInfo.becomeResolved(null,
|
|
1036
|
+
// SAFETY: This seems to imply that it would be resolved, but it's unclear if that's actually the case.
|
|
1037
|
+
newHandlerInfo.context);
|
|
1012
1038
|
let oldContext = oldHandlerInfo && oldHandlerInfo.context;
|
|
1013
1039
|
if (result.names.length > 0 &&
|
|
1014
1040
|
oldHandlerInfo.context !== undefined &&
|
|
@@ -1026,7 +1052,9 @@ class NamedTransitionIntent extends TransitionIntent {
|
|
|
1026
1052
|
handlerToUse = newHandlerInfo;
|
|
1027
1053
|
}
|
|
1028
1054
|
if (isIntermediate && !checkingIfActive) {
|
|
1029
|
-
handlerToUse = handlerToUse.becomeResolved(null,
|
|
1055
|
+
handlerToUse = handlerToUse.becomeResolved(null,
|
|
1056
|
+
// SAFETY: This seems to imply that it would be resolved, but it's unclear if that's actually the case.
|
|
1057
|
+
handlerToUse.context);
|
|
1030
1058
|
}
|
|
1031
1059
|
newState.routeInfos.unshift(handlerToUse);
|
|
1032
1060
|
}
|
|
@@ -1071,7 +1099,7 @@ class NamedTransitionIntent extends TransitionIntent {
|
|
|
1071
1099
|
else {
|
|
1072
1100
|
if (this.preTransitionState) {
|
|
1073
1101
|
let preTransitionHandlerInfo = this.preTransitionState.routeInfos[i];
|
|
1074
|
-
objectToUse = preTransitionHandlerInfo
|
|
1102
|
+
objectToUse = preTransitionHandlerInfo === null || preTransitionHandlerInfo === void 0 ? void 0 : preTransitionHandlerInfo.context;
|
|
1075
1103
|
}
|
|
1076
1104
|
else {
|
|
1077
1105
|
// Ideally we should throw this error to provide maximal
|
|
@@ -1305,6 +1333,7 @@ class Router {
|
|
|
1305
1333
|
if (queryParamChangelist) {
|
|
1306
1334
|
let newTransition = this.queryParamsTransition(queryParamChangelist, wasTransitioning, oldState, newState);
|
|
1307
1335
|
newTransition.queryParamsOnly = true;
|
|
1336
|
+
// SAFETY: The returned OpaqueTransition should actually be this.
|
|
1308
1337
|
return newTransition;
|
|
1309
1338
|
}
|
|
1310
1339
|
// No-op. No need to create a new transition.
|
|
@@ -1358,6 +1387,8 @@ class Router {
|
|
|
1358
1387
|
let lastArg = modelsArray[modelsArray.length - 1];
|
|
1359
1388
|
let queryParams = {};
|
|
1360
1389
|
if (lastArg !== undefined && lastArg.hasOwnProperty('queryParams')) {
|
|
1390
|
+
// We just checked this.
|
|
1391
|
+
// TODO: Use an assertion?
|
|
1361
1392
|
queryParams = modelsArray.pop().queryParams;
|
|
1362
1393
|
}
|
|
1363
1394
|
let intent;
|
|
@@ -1374,7 +1405,9 @@ class Router {
|
|
|
1374
1405
|
}
|
|
1375
1406
|
else {
|
|
1376
1407
|
log(this, 'Attempting transition to ' + name);
|
|
1377
|
-
intent = new NamedTransitionIntent(this, name, undefined,
|
|
1408
|
+
intent = new NamedTransitionIntent(this, name, undefined,
|
|
1409
|
+
// SAFETY: We know this to be the case since we removed the last item if it was QPs
|
|
1410
|
+
modelsArray, queryParams);
|
|
1378
1411
|
}
|
|
1379
1412
|
return this.transitionByIntent(intent, isIntermediate);
|
|
1380
1413
|
}
|
|
@@ -1905,8 +1938,8 @@ class Router {
|
|
|
1905
1938
|
return routesEqual && !getChangelist(activeQPsOnNewHandler, queryParams);
|
|
1906
1939
|
}
|
|
1907
1940
|
isActive(routeName, ...args) {
|
|
1908
|
-
let
|
|
1909
|
-
return this.isActiveIntent(routeName,
|
|
1941
|
+
let [contexts, queryParams] = extractQueryParams(args);
|
|
1942
|
+
return this.isActiveIntent(routeName, contexts, queryParams);
|
|
1910
1943
|
}
|
|
1911
1944
|
trigger(name, ...args) {
|
|
1912
1945
|
this.triggerEvent(this.currentRouteInfos, false, name, args);
|
|
@@ -1917,6 +1950,7 @@ function routeInfosEqual(routeInfos, otherRouteInfos) {
|
|
|
1917
1950
|
return false;
|
|
1918
1951
|
}
|
|
1919
1952
|
for (let i = 0, len = routeInfos.length; i < len; ++i) {
|
|
1953
|
+
// SAFETY: Just casting for comparison
|
|
1920
1954
|
if (routeInfos[i] !== otherRouteInfos[i]) {
|
|
1921
1955
|
return false;
|
|
1922
1956
|
}
|
|
@@ -1938,11 +1972,12 @@ function routeInfosSameExceptQueryParams(routeInfos, otherRouteInfos) {
|
|
|
1938
1972
|
return true;
|
|
1939
1973
|
}
|
|
1940
1974
|
function paramsEqual(params, otherParams) {
|
|
1941
|
-
if (
|
|
1975
|
+
if (params === otherParams) {
|
|
1976
|
+
// Both identical or both undefined
|
|
1942
1977
|
return true;
|
|
1943
1978
|
}
|
|
1944
|
-
|
|
1945
|
-
//
|
|
1979
|
+
if (!params || !otherParams) {
|
|
1980
|
+
// One is falsy but other is not
|
|
1946
1981
|
return false;
|
|
1947
1982
|
}
|
|
1948
1983
|
let keys = Object.keys(params);
|