@angular/upgrade 17.0.0-next.0 → 17.0.0-next.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/esm2022/src/common/src/version.mjs +1 -1
- package/esm2022/src/dynamic/src/upgrade_adapter.mjs +3 -3
- package/esm2022/src/dynamic/src/upgrade_ng1_adapter.mjs +3 -3
- package/esm2022/static/common.mjs +22 -0
- package/esm2022/static/public_api.mjs +2 -1
- package/esm2022/static/src/downgrade_module.mjs +16 -18
- package/esm2022/static/src/upgrade_component.mjs +12 -14
- package/esm2022/static/src/upgrade_module.mjs +25 -26
- package/esm2022/static/testing/src/create_angular_testing_module.mjs +9 -10
- package/esm2022/static/testing/src/create_angularjs_testing_module.mjs +6 -7
- package/fesm2022/static/testing.mjs +16 -107
- package/fesm2022/static/testing.mjs.map +1 -1
- package/fesm2022/static.mjs +311 -239
- package/fesm2022/static.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +7 -7
- package/fesm2022/upgrade.mjs.map +1 -1
- package/index.d.ts +3 -3
- package/package.json +5 -5
- package/static/index.d.ts +553 -1
- package/static/testing/index.d.ts +1 -1
package/fesm2022/static.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.0.0-next.
|
|
2
|
+
* @license Angular v17.0.0-next.2
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -74,6 +74,20 @@ const injector = (modules, strictDi) => angular.injector(modules, strictDi);
|
|
|
74
74
|
const resumeBootstrap = () => angular.resumeBootstrap();
|
|
75
75
|
const getTestability = e => angular.getTestability(e);
|
|
76
76
|
|
|
77
|
+
var angular1 = /*#__PURE__*/Object.freeze({
|
|
78
|
+
__proto__: null,
|
|
79
|
+
setAngularLib: setAngularLib,
|
|
80
|
+
getAngularLib: getAngularLib,
|
|
81
|
+
setAngularJSGlobal: setAngularJSGlobal,
|
|
82
|
+
getAngularJSGlobal: getAngularJSGlobal,
|
|
83
|
+
bootstrap: bootstrap,
|
|
84
|
+
module_: module_,
|
|
85
|
+
element: element,
|
|
86
|
+
injector: injector,
|
|
87
|
+
resumeBootstrap: resumeBootstrap,
|
|
88
|
+
getTestability: getTestability
|
|
89
|
+
});
|
|
90
|
+
|
|
77
91
|
const $COMPILE = '$compile';
|
|
78
92
|
const $CONTROLLER = '$controller';
|
|
79
93
|
const $DELEGATE = '$delegate';
|
|
@@ -100,6 +114,35 @@ const REQUIRE_INJECTOR = '?^^' + INJECTOR_KEY;
|
|
|
100
114
|
const REQUIRE_NG_MODEL = '?ngModel';
|
|
101
115
|
const UPGRADE_MODULE_NAME = '$$UpgradeModule';
|
|
102
116
|
|
|
117
|
+
var constants = /*#__PURE__*/Object.freeze({
|
|
118
|
+
__proto__: null,
|
|
119
|
+
$COMPILE: $COMPILE,
|
|
120
|
+
$CONTROLLER: $CONTROLLER,
|
|
121
|
+
$DELEGATE: $DELEGATE,
|
|
122
|
+
$EXCEPTION_HANDLER: $EXCEPTION_HANDLER,
|
|
123
|
+
$HTTP_BACKEND: $HTTP_BACKEND,
|
|
124
|
+
$INJECTOR: $INJECTOR,
|
|
125
|
+
$INTERVAL: $INTERVAL,
|
|
126
|
+
$PARSE: $PARSE,
|
|
127
|
+
$PROVIDE: $PROVIDE,
|
|
128
|
+
$ROOT_ELEMENT: $ROOT_ELEMENT,
|
|
129
|
+
$ROOT_SCOPE: $ROOT_SCOPE,
|
|
130
|
+
$SCOPE: $SCOPE,
|
|
131
|
+
$TEMPLATE_CACHE: $TEMPLATE_CACHE,
|
|
132
|
+
$TEMPLATE_REQUEST: $TEMPLATE_REQUEST,
|
|
133
|
+
$$TESTABILITY: $$TESTABILITY,
|
|
134
|
+
COMPILER_KEY: COMPILER_KEY,
|
|
135
|
+
DOWNGRADED_MODULE_COUNT_KEY: DOWNGRADED_MODULE_COUNT_KEY,
|
|
136
|
+
GROUP_PROJECTABLE_NODES_KEY: GROUP_PROJECTABLE_NODES_KEY,
|
|
137
|
+
INJECTOR_KEY: INJECTOR_KEY,
|
|
138
|
+
LAZY_MODULE_REF: LAZY_MODULE_REF,
|
|
139
|
+
NG_ZONE_KEY: NG_ZONE_KEY,
|
|
140
|
+
UPGRADE_APP_TYPE_KEY: UPGRADE_APP_TYPE_KEY,
|
|
141
|
+
REQUIRE_INJECTOR: REQUIRE_INJECTOR,
|
|
142
|
+
REQUIRE_NG_MODEL: REQUIRE_NG_MODEL,
|
|
143
|
+
UPGRADE_MODULE_NAME: UPGRADE_MODULE_NAME
|
|
144
|
+
});
|
|
145
|
+
|
|
103
146
|
/**
|
|
104
147
|
* A `PropertyBinding` represents a mapping between a property name
|
|
105
148
|
* and an attribute name. It is parsed from a string of the form
|
|
@@ -259,6 +302,24 @@ function strictEquals(val1, val2) {
|
|
|
259
302
|
return val1 === val2 || (val1 !== val1 && val2 !== val2);
|
|
260
303
|
}
|
|
261
304
|
|
|
305
|
+
var util = /*#__PURE__*/Object.freeze({
|
|
306
|
+
__proto__: null,
|
|
307
|
+
onError: onError,
|
|
308
|
+
cleanData: cleanData,
|
|
309
|
+
controllerKey: controllerKey,
|
|
310
|
+
destroyApp: destroyApp,
|
|
311
|
+
directiveNormalize: directiveNormalize,
|
|
312
|
+
getTypeName: getTypeName,
|
|
313
|
+
getDowngradedModuleCount: getDowngradedModuleCount,
|
|
314
|
+
getUpgradeAppType: getUpgradeAppType,
|
|
315
|
+
isFunction: isFunction,
|
|
316
|
+
isNgModuleType: isNgModuleType,
|
|
317
|
+
validateInjectionKey: validateInjectionKey,
|
|
318
|
+
Deferred: Deferred,
|
|
319
|
+
hookupNgModel: hookupNgModel,
|
|
320
|
+
strictEquals: strictEquals
|
|
321
|
+
});
|
|
322
|
+
|
|
262
323
|
const INITIAL_VALUE$1 = {
|
|
263
324
|
__UNINITIALIZED__: true
|
|
264
325
|
};
|
|
@@ -851,235 +912,7 @@ function downgradeInjectable(token, downgradedModule = '') {
|
|
|
851
912
|
/**
|
|
852
913
|
* @publicApi
|
|
853
914
|
*/
|
|
854
|
-
const VERSION = new Version('17.0.0-next.
|
|
855
|
-
|
|
856
|
-
// We have to do a little dance to get the ng1 injector into the module injector.
|
|
857
|
-
// We store the ng1 injector so that the provider in the module injector can access it
|
|
858
|
-
// Then we "get" the ng1 injector from the module injector, which triggers the provider to read
|
|
859
|
-
// the stored injector and release the reference to it.
|
|
860
|
-
let tempInjectorRef = null;
|
|
861
|
-
function setTempInjectorRef(injector) {
|
|
862
|
-
tempInjectorRef = injector;
|
|
863
|
-
}
|
|
864
|
-
function injectorFactory() {
|
|
865
|
-
if (!tempInjectorRef) {
|
|
866
|
-
throw new Error('Trying to get the AngularJS injector before it being set.');
|
|
867
|
-
}
|
|
868
|
-
const injector = tempInjectorRef;
|
|
869
|
-
tempInjectorRef = null; // clear the value to prevent memory leaks
|
|
870
|
-
return injector;
|
|
871
|
-
}
|
|
872
|
-
function rootScopeFactory(i) {
|
|
873
|
-
return i.get('$rootScope');
|
|
874
|
-
}
|
|
875
|
-
function compileFactory(i) {
|
|
876
|
-
return i.get('$compile');
|
|
877
|
-
}
|
|
878
|
-
function parseFactory(i) {
|
|
879
|
-
return i.get('$parse');
|
|
880
|
-
}
|
|
881
|
-
const angular1Providers = [
|
|
882
|
-
// We must use exported named functions for the ng2 factories to keep the compiler happy:
|
|
883
|
-
// > Metadata collected contains an error that will be reported at runtime:
|
|
884
|
-
// > Function calls are not supported.
|
|
885
|
-
// > Consider replacing the function or lambda with a reference to an exported function
|
|
886
|
-
{ provide: '$injector', useFactory: injectorFactory, deps: [] },
|
|
887
|
-
{ provide: '$rootScope', useFactory: rootScopeFactory, deps: ['$injector'] },
|
|
888
|
-
{ provide: '$compile', useFactory: compileFactory, deps: ['$injector'] },
|
|
889
|
-
{ provide: '$parse', useFactory: parseFactory, deps: ['$injector'] }
|
|
890
|
-
];
|
|
891
|
-
|
|
892
|
-
class NgAdapterInjector {
|
|
893
|
-
constructor(modInjector) {
|
|
894
|
-
this.modInjector = modInjector;
|
|
895
|
-
}
|
|
896
|
-
// When Angular locate a service in the component injector tree, the not found value is set to
|
|
897
|
-
// `NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR`. In such a case we should not walk up to the module
|
|
898
|
-
// injector.
|
|
899
|
-
// AngularJS only supports a single tree and should always check the module injector.
|
|
900
|
-
get(token, notFoundValue) {
|
|
901
|
-
if (notFoundValue === ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
|
902
|
-
return notFoundValue;
|
|
903
|
-
}
|
|
904
|
-
return this.modInjector.get(token, notFoundValue);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
let moduleUid = 0;
|
|
909
|
-
/**
|
|
910
|
-
* @description
|
|
911
|
-
*
|
|
912
|
-
* A helper function for creating an AngularJS module that can bootstrap an Angular module
|
|
913
|
-
* "on-demand" (possibly lazily) when a {@link downgradeComponent downgraded component} needs to be
|
|
914
|
-
* instantiated.
|
|
915
|
-
*
|
|
916
|
-
* *Part of the [upgrade/static](api?query=upgrade/static) library for hybrid upgrade apps that
|
|
917
|
-
* support AOT compilation.*
|
|
918
|
-
*
|
|
919
|
-
* It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to
|
|
920
|
-
* pay the cost up-front. For example, you can have an AngularJS application that uses Angular for
|
|
921
|
-
* specific routes and only instantiate the Angular modules if/when the user visits one of these
|
|
922
|
-
* routes.
|
|
923
|
-
*
|
|
924
|
-
* The Angular module will be bootstrapped once (when requested for the first time) and the same
|
|
925
|
-
* reference will be used from that point onwards.
|
|
926
|
-
*
|
|
927
|
-
* `downgradeModule()` requires either an `NgModuleFactory`, `NgModule` class or a function:
|
|
928
|
-
* - `NgModuleFactory`: If you pass an `NgModuleFactory`, it will be used to instantiate a module
|
|
929
|
-
* using `platformBrowser`'s {@link PlatformRef#bootstrapModuleFactory bootstrapModuleFactory()}.
|
|
930
|
-
* NOTE: this type of the argument is deprecated. Please either provide an `NgModule` class or a
|
|
931
|
-
* bootstrap function instead.
|
|
932
|
-
* - `NgModule` class: If you pass an NgModule class, it will be used to instantiate a module
|
|
933
|
-
* using `platformBrowser`'s {@link PlatformRef#bootstrapModule bootstrapModule()}.
|
|
934
|
-
* - `Function`: If you pass a function, it is expected to return a promise resolving to an
|
|
935
|
-
* `NgModuleRef`. The function is called with an array of extra {@link StaticProvider Providers}
|
|
936
|
-
* that are expected to be available from the returned `NgModuleRef`'s `Injector`.
|
|
937
|
-
*
|
|
938
|
-
* `downgradeModule()` returns the name of the created AngularJS wrapper module. You can use it to
|
|
939
|
-
* declare a dependency in your main AngularJS module.
|
|
940
|
-
*
|
|
941
|
-
* {@example upgrade/static/ts/lite/module.ts region="basic-how-to"}
|
|
942
|
-
*
|
|
943
|
-
* For more details on how to use `downgradeModule()` see
|
|
944
|
-
* [Upgrading for Performance](guide/upgrade-performance).
|
|
945
|
-
*
|
|
946
|
-
* @usageNotes
|
|
947
|
-
*
|
|
948
|
-
* Apart from `UpgradeModule`, you can use the rest of the `upgrade/static` helpers as usual to
|
|
949
|
-
* build a hybrid application. Note that the Angular pieces (e.g. downgraded services) will not be
|
|
950
|
-
* available until the downgraded module has been bootstrapped, i.e. by instantiating a downgraded
|
|
951
|
-
* component.
|
|
952
|
-
*
|
|
953
|
-
* <div class="alert is-important">
|
|
954
|
-
*
|
|
955
|
-
* You cannot use `downgradeModule()` and `UpgradeModule` in the same hybrid application.<br />
|
|
956
|
-
* Use one or the other.
|
|
957
|
-
*
|
|
958
|
-
* </div>
|
|
959
|
-
*
|
|
960
|
-
* ### Differences with `UpgradeModule`
|
|
961
|
-
*
|
|
962
|
-
* Besides their different API, there are two important internal differences between
|
|
963
|
-
* `downgradeModule()` and `UpgradeModule` that affect the behavior of hybrid applications:
|
|
964
|
-
*
|
|
965
|
-
* 1. Unlike `UpgradeModule`, `downgradeModule()` does not bootstrap the main AngularJS module
|
|
966
|
-
* inside the {@link NgZone Angular zone}.
|
|
967
|
-
* 2. Unlike `UpgradeModule`, `downgradeModule()` does not automatically run a
|
|
968
|
-
* [$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) when changes are
|
|
969
|
-
* detected in the Angular part of the application.
|
|
970
|
-
*
|
|
971
|
-
* What this means is that applications using `UpgradeModule` will run change detection more
|
|
972
|
-
* frequently in order to ensure that both frameworks are properly notified about possible changes.
|
|
973
|
-
* This will inevitably result in more change detection runs than necessary.
|
|
974
|
-
*
|
|
975
|
-
* `downgradeModule()`, on the other side, does not try to tie the two change detection systems as
|
|
976
|
-
* tightly, restricting the explicit change detection runs only to cases where it knows it is
|
|
977
|
-
* necessary (e.g. when the inputs of a downgraded component change). This improves performance,
|
|
978
|
-
* especially in change-detection-heavy applications, but leaves it up to the developer to manually
|
|
979
|
-
* notify each framework as needed.
|
|
980
|
-
*
|
|
981
|
-
* For a more detailed discussion of the differences and their implications, see
|
|
982
|
-
* [Upgrading for Performance](guide/upgrade-performance).
|
|
983
|
-
*
|
|
984
|
-
* <div class="alert is-helpful">
|
|
985
|
-
*
|
|
986
|
-
* You can manually trigger a change detection run in AngularJS using
|
|
987
|
-
* [scope.$apply(...)](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$apply) or
|
|
988
|
-
* [$rootScope.$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest).
|
|
989
|
-
*
|
|
990
|
-
* You can manually trigger a change detection run in Angular using {@link NgZone#run
|
|
991
|
-
* ngZone.run(...)}.
|
|
992
|
-
*
|
|
993
|
-
* </div>
|
|
994
|
-
*
|
|
995
|
-
* ### Downgrading multiple modules
|
|
996
|
-
*
|
|
997
|
-
* It is possible to downgrade multiple modules and include them in an AngularJS application. In
|
|
998
|
-
* that case, each downgraded module will be bootstrapped when an associated downgraded component or
|
|
999
|
-
* injectable needs to be instantiated.
|
|
1000
|
-
*
|
|
1001
|
-
* Things to keep in mind, when downgrading multiple modules:
|
|
1002
|
-
*
|
|
1003
|
-
* - Each downgraded component/injectable needs to be explicitly associated with a downgraded
|
|
1004
|
-
* module. See `downgradeComponent()` and `downgradeInjectable()` for more details.
|
|
1005
|
-
*
|
|
1006
|
-
* - If you want some injectables to be shared among all downgraded modules, you can provide them as
|
|
1007
|
-
* `StaticProvider`s, when creating the `PlatformRef` (e.g. via `platformBrowser` or
|
|
1008
|
-
* `platformBrowserDynamic`).
|
|
1009
|
-
*
|
|
1010
|
-
* - When using {@link PlatformRef#bootstrapmodule `bootstrapModule()`} or
|
|
1011
|
-
* {@link PlatformRef#bootstrapmodulefactory `bootstrapModuleFactory()`} to bootstrap the
|
|
1012
|
-
* downgraded modules, each one is considered a "root" module. As a consequence, a new instance
|
|
1013
|
-
* will be created for every injectable provided in `"root"` (via
|
|
1014
|
-
* {@link Injectable#providedIn `providedIn`}).
|
|
1015
|
-
* If this is not your intention, you can have a shared module (that will act as act as the "root"
|
|
1016
|
-
* module) and create all downgraded modules using that module's injector:
|
|
1017
|
-
*
|
|
1018
|
-
* {@example upgrade/static/ts/lite-multi-shared/module.ts region="shared-root-module"}
|
|
1019
|
-
*
|
|
1020
|
-
* @publicApi
|
|
1021
|
-
*/
|
|
1022
|
-
function downgradeModule(moduleOrBootstrapFn) {
|
|
1023
|
-
const lazyModuleName = `${UPGRADE_MODULE_NAME}.lazy${++moduleUid}`;
|
|
1024
|
-
const lazyModuleRefKey = `${LAZY_MODULE_REF}${lazyModuleName}`;
|
|
1025
|
-
const lazyInjectorKey = `${INJECTOR_KEY}${lazyModuleName}`;
|
|
1026
|
-
let bootstrapFn;
|
|
1027
|
-
if (isNgModuleType(moduleOrBootstrapFn)) {
|
|
1028
|
-
// NgModule class
|
|
1029
|
-
bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModule(moduleOrBootstrapFn);
|
|
1030
|
-
}
|
|
1031
|
-
else if (!isFunction(moduleOrBootstrapFn)) {
|
|
1032
|
-
// NgModule factory
|
|
1033
|
-
bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModuleFactory(moduleOrBootstrapFn);
|
|
1034
|
-
}
|
|
1035
|
-
else {
|
|
1036
|
-
// bootstrap function
|
|
1037
|
-
bootstrapFn = moduleOrBootstrapFn;
|
|
1038
|
-
}
|
|
1039
|
-
let injector;
|
|
1040
|
-
// Create an ng1 module to bootstrap.
|
|
1041
|
-
module_(lazyModuleName, [])
|
|
1042
|
-
.constant(UPGRADE_APP_TYPE_KEY, 3 /* UpgradeAppType.Lite */)
|
|
1043
|
-
.factory(INJECTOR_KEY, [lazyInjectorKey, identity])
|
|
1044
|
-
.factory(lazyInjectorKey, () => {
|
|
1045
|
-
if (!injector) {
|
|
1046
|
-
throw new Error('Trying to get the Angular injector before bootstrapping the corresponding ' +
|
|
1047
|
-
'Angular module.');
|
|
1048
|
-
}
|
|
1049
|
-
return injector;
|
|
1050
|
-
})
|
|
1051
|
-
.factory(LAZY_MODULE_REF, [lazyModuleRefKey, identity])
|
|
1052
|
-
.factory(lazyModuleRefKey, [
|
|
1053
|
-
$INJECTOR,
|
|
1054
|
-
($injector) => {
|
|
1055
|
-
setTempInjectorRef($injector);
|
|
1056
|
-
const result = {
|
|
1057
|
-
promise: bootstrapFn(angular1Providers).then(ref => {
|
|
1058
|
-
injector = result.injector = new NgAdapterInjector(ref.injector);
|
|
1059
|
-
injector.get($INJECTOR);
|
|
1060
|
-
// Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.
|
|
1061
|
-
// This does not happen in a typical SPA scenario, but it might be useful for
|
|
1062
|
-
// other use-cases where disposing of an Angular/AngularJS app is necessary
|
|
1063
|
-
// (such as Hot Module Replacement (HMR)).
|
|
1064
|
-
// See https://github.com/angular/angular/issues/39935.
|
|
1065
|
-
injector.get(PlatformRef).onDestroy(() => destroyApp($injector));
|
|
1066
|
-
return injector;
|
|
1067
|
-
})
|
|
1068
|
-
};
|
|
1069
|
-
return result;
|
|
1070
|
-
}
|
|
1071
|
-
])
|
|
1072
|
-
.config([
|
|
1073
|
-
$INJECTOR, $PROVIDE,
|
|
1074
|
-
($injector, $provide) => {
|
|
1075
|
-
$provide.constant(DOWNGRADED_MODULE_COUNT_KEY, getDowngradedModuleCount($injector) + 1);
|
|
1076
|
-
}
|
|
1077
|
-
]);
|
|
1078
|
-
return lazyModuleName;
|
|
1079
|
-
}
|
|
1080
|
-
function identity(x) {
|
|
1081
|
-
return x;
|
|
1082
|
-
}
|
|
915
|
+
const VERSION = new Version('17.0.0-next.2');
|
|
1083
916
|
|
|
1084
917
|
// Constants
|
|
1085
918
|
const REQUIRE_PREFIX_RE = /^(\^\^?)?(\?)?(\^\^?)?/;
|
|
@@ -1314,6 +1147,245 @@ function notSupported(name, feature) {
|
|
|
1314
1147
|
throw new Error(`Upgraded directive '${name}' contains unsupported feature: '${feature}'.`);
|
|
1315
1148
|
}
|
|
1316
1149
|
|
|
1150
|
+
var upgrade_helper = /*#__PURE__*/Object.freeze({
|
|
1151
|
+
__proto__: null,
|
|
1152
|
+
UpgradeHelper: UpgradeHelper
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Note: We intentionally use cross entry-point relative paths here. This
|
|
1157
|
+
* is because the primary entry-point is deprecated and we also don't have
|
|
1158
|
+
* it available in G3.
|
|
1159
|
+
*/
|
|
1160
|
+
|
|
1161
|
+
// We have to do a little dance to get the ng1 injector into the module injector.
|
|
1162
|
+
// We store the ng1 injector so that the provider in the module injector can access it
|
|
1163
|
+
// Then we "get" the ng1 injector from the module injector, which triggers the provider to read
|
|
1164
|
+
// the stored injector and release the reference to it.
|
|
1165
|
+
let tempInjectorRef = null;
|
|
1166
|
+
function setTempInjectorRef(injector) {
|
|
1167
|
+
tempInjectorRef = injector;
|
|
1168
|
+
}
|
|
1169
|
+
function injectorFactory() {
|
|
1170
|
+
if (!tempInjectorRef) {
|
|
1171
|
+
throw new Error('Trying to get the AngularJS injector before it being set.');
|
|
1172
|
+
}
|
|
1173
|
+
const injector = tempInjectorRef;
|
|
1174
|
+
tempInjectorRef = null; // clear the value to prevent memory leaks
|
|
1175
|
+
return injector;
|
|
1176
|
+
}
|
|
1177
|
+
function rootScopeFactory(i) {
|
|
1178
|
+
return i.get('$rootScope');
|
|
1179
|
+
}
|
|
1180
|
+
function compileFactory(i) {
|
|
1181
|
+
return i.get('$compile');
|
|
1182
|
+
}
|
|
1183
|
+
function parseFactory(i) {
|
|
1184
|
+
return i.get('$parse');
|
|
1185
|
+
}
|
|
1186
|
+
const angular1Providers = [
|
|
1187
|
+
// We must use exported named functions for the ng2 factories to keep the compiler happy:
|
|
1188
|
+
// > Metadata collected contains an error that will be reported at runtime:
|
|
1189
|
+
// > Function calls are not supported.
|
|
1190
|
+
// > Consider replacing the function or lambda with a reference to an exported function
|
|
1191
|
+
{ provide: '$injector', useFactory: injectorFactory, deps: [] },
|
|
1192
|
+
{ provide: '$rootScope', useFactory: rootScopeFactory, deps: ['$injector'] },
|
|
1193
|
+
{ provide: '$compile', useFactory: compileFactory, deps: ['$injector'] },
|
|
1194
|
+
{ provide: '$parse', useFactory: parseFactory, deps: ['$injector'] }
|
|
1195
|
+
];
|
|
1196
|
+
|
|
1197
|
+
class NgAdapterInjector {
|
|
1198
|
+
constructor(modInjector) {
|
|
1199
|
+
this.modInjector = modInjector;
|
|
1200
|
+
}
|
|
1201
|
+
// When Angular locate a service in the component injector tree, the not found value is set to
|
|
1202
|
+
// `NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR`. In such a case we should not walk up to the module
|
|
1203
|
+
// injector.
|
|
1204
|
+
// AngularJS only supports a single tree and should always check the module injector.
|
|
1205
|
+
get(token, notFoundValue) {
|
|
1206
|
+
if (notFoundValue === ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
|
1207
|
+
return notFoundValue;
|
|
1208
|
+
}
|
|
1209
|
+
return this.modInjector.get(token, notFoundValue);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
let moduleUid = 0;
|
|
1214
|
+
/**
|
|
1215
|
+
* @description
|
|
1216
|
+
*
|
|
1217
|
+
* A helper function for creating an AngularJS module that can bootstrap an Angular module
|
|
1218
|
+
* "on-demand" (possibly lazily) when a {@link downgradeComponent downgraded component} needs to be
|
|
1219
|
+
* instantiated.
|
|
1220
|
+
*
|
|
1221
|
+
* *Part of the [upgrade/static](api?query=upgrade/static) library for hybrid upgrade apps that
|
|
1222
|
+
* support AOT compilation.*
|
|
1223
|
+
*
|
|
1224
|
+
* It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to
|
|
1225
|
+
* pay the cost up-front. For example, you can have an AngularJS application that uses Angular for
|
|
1226
|
+
* specific routes and only instantiate the Angular modules if/when the user visits one of these
|
|
1227
|
+
* routes.
|
|
1228
|
+
*
|
|
1229
|
+
* The Angular module will be bootstrapped once (when requested for the first time) and the same
|
|
1230
|
+
* reference will be used from that point onwards.
|
|
1231
|
+
*
|
|
1232
|
+
* `downgradeModule()` requires either an `NgModuleFactory`, `NgModule` class or a function:
|
|
1233
|
+
* - `NgModuleFactory`: If you pass an `NgModuleFactory`, it will be used to instantiate a module
|
|
1234
|
+
* using `platformBrowser`'s {@link PlatformRef#bootstrapModuleFactory bootstrapModuleFactory()}.
|
|
1235
|
+
* NOTE: this type of the argument is deprecated. Please either provide an `NgModule` class or a
|
|
1236
|
+
* bootstrap function instead.
|
|
1237
|
+
* - `NgModule` class: If you pass an NgModule class, it will be used to instantiate a module
|
|
1238
|
+
* using `platformBrowser`'s {@link PlatformRef#bootstrapModule bootstrapModule()}.
|
|
1239
|
+
* - `Function`: If you pass a function, it is expected to return a promise resolving to an
|
|
1240
|
+
* `NgModuleRef`. The function is called with an array of extra {@link StaticProvider Providers}
|
|
1241
|
+
* that are expected to be available from the returned `NgModuleRef`'s `Injector`.
|
|
1242
|
+
*
|
|
1243
|
+
* `downgradeModule()` returns the name of the created AngularJS wrapper module. You can use it to
|
|
1244
|
+
* declare a dependency in your main AngularJS module.
|
|
1245
|
+
*
|
|
1246
|
+
* {@example upgrade/static/ts/lite/module.ts region="basic-how-to"}
|
|
1247
|
+
*
|
|
1248
|
+
* For more details on how to use `downgradeModule()` see
|
|
1249
|
+
* [Upgrading for Performance](guide/upgrade-performance).
|
|
1250
|
+
*
|
|
1251
|
+
* @usageNotes
|
|
1252
|
+
*
|
|
1253
|
+
* Apart from `UpgradeModule`, you can use the rest of the `upgrade/static` helpers as usual to
|
|
1254
|
+
* build a hybrid application. Note that the Angular pieces (e.g. downgraded services) will not be
|
|
1255
|
+
* available until the downgraded module has been bootstrapped, i.e. by instantiating a downgraded
|
|
1256
|
+
* component.
|
|
1257
|
+
*
|
|
1258
|
+
* <div class="alert is-important">
|
|
1259
|
+
*
|
|
1260
|
+
* You cannot use `downgradeModule()` and `UpgradeModule` in the same hybrid application.<br />
|
|
1261
|
+
* Use one or the other.
|
|
1262
|
+
*
|
|
1263
|
+
* </div>
|
|
1264
|
+
*
|
|
1265
|
+
* ### Differences with `UpgradeModule`
|
|
1266
|
+
*
|
|
1267
|
+
* Besides their different API, there are two important internal differences between
|
|
1268
|
+
* `downgradeModule()` and `UpgradeModule` that affect the behavior of hybrid applications:
|
|
1269
|
+
*
|
|
1270
|
+
* 1. Unlike `UpgradeModule`, `downgradeModule()` does not bootstrap the main AngularJS module
|
|
1271
|
+
* inside the {@link NgZone Angular zone}.
|
|
1272
|
+
* 2. Unlike `UpgradeModule`, `downgradeModule()` does not automatically run a
|
|
1273
|
+
* [$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) when changes are
|
|
1274
|
+
* detected in the Angular part of the application.
|
|
1275
|
+
*
|
|
1276
|
+
* What this means is that applications using `UpgradeModule` will run change detection more
|
|
1277
|
+
* frequently in order to ensure that both frameworks are properly notified about possible changes.
|
|
1278
|
+
* This will inevitably result in more change detection runs than necessary.
|
|
1279
|
+
*
|
|
1280
|
+
* `downgradeModule()`, on the other side, does not try to tie the two change detection systems as
|
|
1281
|
+
* tightly, restricting the explicit change detection runs only to cases where it knows it is
|
|
1282
|
+
* necessary (e.g. when the inputs of a downgraded component change). This improves performance,
|
|
1283
|
+
* especially in change-detection-heavy applications, but leaves it up to the developer to manually
|
|
1284
|
+
* notify each framework as needed.
|
|
1285
|
+
*
|
|
1286
|
+
* For a more detailed discussion of the differences and their implications, see
|
|
1287
|
+
* [Upgrading for Performance](guide/upgrade-performance).
|
|
1288
|
+
*
|
|
1289
|
+
* <div class="alert is-helpful">
|
|
1290
|
+
*
|
|
1291
|
+
* You can manually trigger a change detection run in AngularJS using
|
|
1292
|
+
* [scope.$apply(...)](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$apply) or
|
|
1293
|
+
* [$rootScope.$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest).
|
|
1294
|
+
*
|
|
1295
|
+
* You can manually trigger a change detection run in Angular using {@link NgZone#run
|
|
1296
|
+
* ngZone.run(...)}.
|
|
1297
|
+
*
|
|
1298
|
+
* </div>
|
|
1299
|
+
*
|
|
1300
|
+
* ### Downgrading multiple modules
|
|
1301
|
+
*
|
|
1302
|
+
* It is possible to downgrade multiple modules and include them in an AngularJS application. In
|
|
1303
|
+
* that case, each downgraded module will be bootstrapped when an associated downgraded component or
|
|
1304
|
+
* injectable needs to be instantiated.
|
|
1305
|
+
*
|
|
1306
|
+
* Things to keep in mind, when downgrading multiple modules:
|
|
1307
|
+
*
|
|
1308
|
+
* - Each downgraded component/injectable needs to be explicitly associated with a downgraded
|
|
1309
|
+
* module. See `downgradeComponent()` and `downgradeInjectable()` for more details.
|
|
1310
|
+
*
|
|
1311
|
+
* - If you want some injectables to be shared among all downgraded modules, you can provide them as
|
|
1312
|
+
* `StaticProvider`s, when creating the `PlatformRef` (e.g. via `platformBrowser` or
|
|
1313
|
+
* `platformBrowserDynamic`).
|
|
1314
|
+
*
|
|
1315
|
+
* - When using {@link PlatformRef#bootstrapmodule `bootstrapModule()`} or
|
|
1316
|
+
* {@link PlatformRef#bootstrapmodulefactory `bootstrapModuleFactory()`} to bootstrap the
|
|
1317
|
+
* downgraded modules, each one is considered a "root" module. As a consequence, a new instance
|
|
1318
|
+
* will be created for every injectable provided in `"root"` (via
|
|
1319
|
+
* {@link Injectable#providedIn `providedIn`}).
|
|
1320
|
+
* If this is not your intention, you can have a shared module (that will act as act as the "root"
|
|
1321
|
+
* module) and create all downgraded modules using that module's injector:
|
|
1322
|
+
*
|
|
1323
|
+
* {@example upgrade/static/ts/lite-multi-shared/module.ts region="shared-root-module"}
|
|
1324
|
+
*
|
|
1325
|
+
* @publicApi
|
|
1326
|
+
*/
|
|
1327
|
+
function downgradeModule(moduleOrBootstrapFn) {
|
|
1328
|
+
const lazyModuleName = `${UPGRADE_MODULE_NAME}.lazy${++moduleUid}`;
|
|
1329
|
+
const lazyModuleRefKey = `${LAZY_MODULE_REF}${lazyModuleName}`;
|
|
1330
|
+
const lazyInjectorKey = `${INJECTOR_KEY}${lazyModuleName}`;
|
|
1331
|
+
let bootstrapFn;
|
|
1332
|
+
if (isNgModuleType(moduleOrBootstrapFn)) {
|
|
1333
|
+
// NgModule class
|
|
1334
|
+
bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModule(moduleOrBootstrapFn);
|
|
1335
|
+
}
|
|
1336
|
+
else if (!isFunction(moduleOrBootstrapFn)) {
|
|
1337
|
+
// NgModule factory
|
|
1338
|
+
bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModuleFactory(moduleOrBootstrapFn);
|
|
1339
|
+
}
|
|
1340
|
+
else {
|
|
1341
|
+
// bootstrap function
|
|
1342
|
+
bootstrapFn = moduleOrBootstrapFn;
|
|
1343
|
+
}
|
|
1344
|
+
let injector;
|
|
1345
|
+
// Create an ng1 module to bootstrap.
|
|
1346
|
+
module_(lazyModuleName, [])
|
|
1347
|
+
.constant(UPGRADE_APP_TYPE_KEY, 3 /* ɵutil.UpgradeAppType.Lite */)
|
|
1348
|
+
.factory(INJECTOR_KEY, [lazyInjectorKey, identity])
|
|
1349
|
+
.factory(lazyInjectorKey, () => {
|
|
1350
|
+
if (!injector) {
|
|
1351
|
+
throw new Error('Trying to get the Angular injector before bootstrapping the corresponding ' +
|
|
1352
|
+
'Angular module.');
|
|
1353
|
+
}
|
|
1354
|
+
return injector;
|
|
1355
|
+
})
|
|
1356
|
+
.factory(LAZY_MODULE_REF, [lazyModuleRefKey, identity])
|
|
1357
|
+
.factory(lazyModuleRefKey, [
|
|
1358
|
+
$INJECTOR,
|
|
1359
|
+
($injector) => {
|
|
1360
|
+
setTempInjectorRef($injector);
|
|
1361
|
+
const result = {
|
|
1362
|
+
promise: bootstrapFn(angular1Providers).then(ref => {
|
|
1363
|
+
injector = result.injector = new NgAdapterInjector(ref.injector);
|
|
1364
|
+
injector.get($INJECTOR);
|
|
1365
|
+
// Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.
|
|
1366
|
+
// This does not happen in a typical SPA scenario, but it might be useful for
|
|
1367
|
+
// other use-cases where disposing of an Angular/AngularJS app is necessary
|
|
1368
|
+
// (such as Hot Module Replacement (HMR)).
|
|
1369
|
+
// See https://github.com/angular/angular/issues/39935.
|
|
1370
|
+
injector.get(PlatformRef).onDestroy(() => destroyApp($injector));
|
|
1371
|
+
return injector;
|
|
1372
|
+
})
|
|
1373
|
+
};
|
|
1374
|
+
return result;
|
|
1375
|
+
}
|
|
1376
|
+
])
|
|
1377
|
+
.config([
|
|
1378
|
+
$INJECTOR, $PROVIDE,
|
|
1379
|
+
($injector, $provide) => {
|
|
1380
|
+
$provide.constant(DOWNGRADED_MODULE_COUNT_KEY, getDowngradedModuleCount($injector) + 1);
|
|
1381
|
+
}
|
|
1382
|
+
]);
|
|
1383
|
+
return lazyModuleName;
|
|
1384
|
+
}
|
|
1385
|
+
function identity(x) {
|
|
1386
|
+
return x;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1317
1389
|
const NOT_SUPPORTED = 'NOT_SUPPORTED';
|
|
1318
1390
|
const INITIAL_VALUE = {
|
|
1319
1391
|
__UNINITIALIZED__: true
|
|
@@ -1546,10 +1618,10 @@ class UpgradeComponent {
|
|
|
1546
1618
|
bindingDestination.$onChanges(changes);
|
|
1547
1619
|
}
|
|
1548
1620
|
}
|
|
1549
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1550
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.0-next.
|
|
1621
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1622
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.0-next.2", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 }); }
|
|
1551
1623
|
}
|
|
1552
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1624
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeComponent, decorators: [{
|
|
1553
1625
|
type: Directive
|
|
1554
1626
|
}], ctorParameters: function () { return [{ type: undefined }, { type: i0.ElementRef }, { type: i0.Injector }]; } });
|
|
1555
1627
|
|
|
@@ -1706,7 +1778,7 @@ class UpgradeModule {
|
|
|
1706
1778
|
const INIT_MODULE_NAME = UPGRADE_MODULE_NAME + '.init';
|
|
1707
1779
|
// Create an ng1 module to bootstrap
|
|
1708
1780
|
module_(INIT_MODULE_NAME, [])
|
|
1709
|
-
.constant(UPGRADE_APP_TYPE_KEY, 2 /* UpgradeAppType.Static */)
|
|
1781
|
+
.constant(UPGRADE_APP_TYPE_KEY, 2 /* ɵutil.UpgradeAppType.Static */)
|
|
1710
1782
|
.value(INJECTOR_KEY, this.injector)
|
|
1711
1783
|
.factory(LAZY_MODULE_REF, [INJECTOR_KEY, (injector) => ({ injector })])
|
|
1712
1784
|
.config([
|
|
@@ -1822,11 +1894,11 @@ class UpgradeModule {
|
|
|
1822
1894
|
}
|
|
1823
1895
|
return returnValue;
|
|
1824
1896
|
}
|
|
1825
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1826
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-next.
|
|
1827
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1897
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1898
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeModule }); }
|
|
1899
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); }
|
|
1828
1900
|
}
|
|
1829
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1901
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.2", ngImport: i0, type: UpgradeModule, decorators: [{
|
|
1830
1902
|
type: NgModule,
|
|
1831
1903
|
args: [{ providers: [angular1Providers] }]
|
|
1832
1904
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgZone }, { type: i0.PlatformRef }]; } });
|
|
@@ -1839,5 +1911,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.0",
|
|
|
1839
1911
|
* Generated bundle index. Do not edit.
|
|
1840
1912
|
*/
|
|
1841
1913
|
|
|
1842
|
-
export { UpgradeComponent, UpgradeModule, VERSION, downgradeComponent, downgradeInjectable, downgradeModule, getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib };
|
|
1914
|
+
export { UpgradeComponent, UpgradeModule, VERSION, downgradeComponent, downgradeInjectable, downgradeModule, getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib, angular1 as ɵangular1, constants as ɵconstants, upgrade_helper as ɵupgradeHelper, util as ɵutil };
|
|
1843
1915
|
//# sourceMappingURL=static.mjs.map
|