@angular/core 15.0.0-next.5 → 15.0.0-next.6

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.
Files changed (38) hide show
  1. package/esm2020/src/application_ref.mjs +1 -1
  2. package/esm2020/src/core_private_export.mjs +2 -1
  3. package/esm2020/src/di/index.mjs +2 -2
  4. package/esm2020/src/di/interface/defs.mjs +1 -1
  5. package/esm2020/src/di/interface/provider.mjs +4 -2
  6. package/esm2020/src/di/provider_collection.mjs +30 -4
  7. package/esm2020/src/di/r3_injector.mjs +4 -6
  8. package/esm2020/src/metadata/directives.mjs +1 -1
  9. package/esm2020/src/metadata/ng_module.mjs +1 -1
  10. package/esm2020/src/render3/errors_di.mjs +9 -3
  11. package/esm2020/src/render3/jit/directive.mjs +2 -6
  12. package/esm2020/src/render3/ng_module_ref.mjs +1 -1
  13. package/esm2020/src/version.mjs +1 -1
  14. package/esm2020/testing/src/logger.mjs +3 -3
  15. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  16. package/esm2020/testing/src/test_bed_compiler.mjs +29 -11
  17. package/fesm2015/core.mjs +52 -18
  18. package/fesm2015/core.mjs.map +1 -1
  19. package/fesm2015/testing.mjs +78 -22
  20. package/fesm2015/testing.mjs.map +1 -1
  21. package/fesm2020/core.mjs +52 -18
  22. package/fesm2020/core.mjs.map +1 -1
  23. package/fesm2020/testing.mjs +78 -22
  24. package/fesm2020/testing.mjs.map +1 -1
  25. package/index.d.ts +58 -13
  26. package/package.json +2 -2
  27. package/schematics/migrations/relative-link-resolution/index.d.ts +10 -0
  28. package/schematics/migrations/relative-link-resolution/index.js +68 -0
  29. package/schematics/migrations/relative-link-resolution/util.d.ts +20 -0
  30. package/schematics/migrations/relative-link-resolution/util.js +82 -0
  31. package/schematics/migrations/router-link-with-href/index.d.ts +10 -0
  32. package/schematics/migrations/router-link-with-href/index.js +70 -0
  33. package/schematics/migrations/router-link-with-href/util.d.ts +19 -0
  34. package/schematics/migrations/router-link-with-href/util.js +111 -0
  35. package/schematics/migrations.json +10 -0
  36. package/schematics/utils/typescript/imports.d.ts +10 -0
  37. package/schematics/utils/typescript/imports.js +17 -2
  38. package/testing/index.d.ts +1 -1
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @license Angular v15.0.0-next.5
2
+ * @license Angular v15.0.0-next.6
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, InjectionToken as InjectionToken$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, Injector as Injector$1, InjectFlags as InjectFlags$1, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode as ɵsetUnknownElementStrictMode$1, ɵsetUnknownPropertyStrictMode as ɵsetUnknownPropertyStrictMode$1, ɵgetUnknownElementStrictMode as ɵgetUnknownElementStrictMode$1, ɵgetUnknownPropertyStrictMode as ɵgetUnknownPropertyStrictMode$1, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
7
+ import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, InjectionToken as InjectionToken$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ɵisEnvironmentProviders, ModuleWithComponentFactories, ɵconvertToBitFlags, Injector as Injector$1, InjectFlags as InjectFlags$1, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode as ɵsetUnknownElementStrictMode$1, ɵsetUnknownPropertyStrictMode as ɵsetUnknownPropertyStrictMode$1, ɵgetUnknownElementStrictMode as ɵgetUnknownElementStrictMode$1, ɵgetUnknownPropertyStrictMode as ɵgetUnknownPropertyStrictMode$1, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
8
8
  import { ResourceLoader } from '@angular/compiler';
9
9
  import { Subject, Subscription } from 'rxjs';
10
10
 
@@ -1886,6 +1886,17 @@ function initNgDevMode() {
1886
1886
  return false;
1887
1887
  }
1888
1888
 
1889
+ /**
1890
+ * @license
1891
+ * Copyright Google LLC All Rights Reserved.
1892
+ *
1893
+ * Use of this source code is governed by an MIT-style license that can be
1894
+ * found in the LICENSE file at https://angular.io/license
1895
+ */
1896
+ function isEnvironmentProviders(value) {
1897
+ return value && !!value.ɵproviders;
1898
+ }
1899
+
1889
1900
  /**
1890
1901
  * @license
1891
1902
  * Copyright Google LLC All Rights Reserved.
@@ -1942,8 +1953,13 @@ function throwInvalidProviderError(ngModuleType, providers, provider) {
1942
1953
  const providerDetail = providers.map(v => v == provider ? '?' + provider + '?' : '...');
1943
1954
  throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(', ')}]`);
1944
1955
  }
1945
- else if (provider.ɵproviders) {
1946
- throw new RuntimeError(207 /* RuntimeErrorCode.PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`);
1956
+ else if (isEnvironmentProviders(provider)) {
1957
+ if (provider.ɵfromNgModule) {
1958
+ throw new RuntimeError(207 /* RuntimeErrorCode.PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`);
1959
+ }
1960
+ else {
1961
+ throw new RuntimeError(207 /* RuntimeErrorCode.PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
1962
+ }
1947
1963
  }
1948
1964
  else {
1949
1965
  throw new Error('Invalid provider');
@@ -6775,6 +6791,15 @@ class NullInjector {
6775
6791
  * Use of this source code is governed by an MIT-style license that can be
6776
6792
  * found in the LICENSE file at https://angular.io/license
6777
6793
  */
6794
+ /**
6795
+ * Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
6796
+ * referenced in `@Component in a component injector.
6797
+ */
6798
+ function makeEnvironmentProviders(providers) {
6799
+ return {
6800
+ ɵproviders: providers,
6801
+ };
6802
+ }
6778
6803
  /**
6779
6804
  * Collects providers from all NgModules and standalone components, including transitively imported
6780
6805
  * ones.
@@ -6817,7 +6842,10 @@ class NullInjector {
6817
6842
  * @developerPreview
6818
6843
  */
6819
6844
  function importProvidersFrom(...sources) {
6820
- return { ɵproviders: internalImportProvidersFrom(true, sources) };
6845
+ return {
6846
+ ɵproviders: internalImportProvidersFrom(true, sources),
6847
+ ɵfromNgModule: true,
6848
+ };
6821
6849
  }
6822
6850
  function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
6823
6851
  const providersOut = [];
@@ -6850,7 +6878,7 @@ function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
6850
6878
  function processInjectorTypesWithProviders(typesWithProviders, providersOut) {
6851
6879
  for (let i = 0; i < typesWithProviders.length; i++) {
6852
6880
  const { ngModule, providers } = typesWithProviders[i];
6853
- deepForEach(providers, provider => {
6881
+ deepForEachProvider(providers, provider => {
6854
6882
  ngDevMode && validateProvider(provider, providers || EMPTY_ARRAY, ngModule);
6855
6883
  providersOut.push(provider);
6856
6884
  });
@@ -6967,7 +6995,7 @@ function walkProviderTree(container, providersOut, parents, dedup) {
6967
6995
  const defProviders = injDef.providers;
6968
6996
  if (defProviders != null && !isDuplicate) {
6969
6997
  const injectorType = container;
6970
- deepForEach(defProviders, provider => {
6998
+ deepForEachProvider(defProviders, provider => {
6971
6999
  ngDevMode && validateProvider(provider, defProviders, injectorType);
6972
7000
  providersOut.push(provider);
6973
7001
  });
@@ -6991,6 +7019,19 @@ function validateProvider(provider, providers, containerType) {
6991
7019
  throwInvalidProviderError(containerType, providers, provider);
6992
7020
  }
6993
7021
  }
7022
+ function deepForEachProvider(providers, fn) {
7023
+ for (let provider of providers) {
7024
+ if (isEnvironmentProviders(provider)) {
7025
+ provider = provider.ɵproviders;
7026
+ }
7027
+ if (Array.isArray(provider)) {
7028
+ deepForEachProvider(provider, fn);
7029
+ }
7030
+ else {
7031
+ fn(provider);
7032
+ }
7033
+ }
7034
+ }
6994
7035
  const USE_VALUE$1 = getClosureSafeProperty({ provide: String, useValue: getClosureSafeProperty });
6995
7036
  function isValueProvider(value) {
6996
7037
  return value !== null && typeof value == 'object' && USE_VALUE$1 in value;
@@ -7356,7 +7397,7 @@ function providerToRecord(provider) {
7356
7397
  */
7357
7398
  function providerToFactory(provider, ngModuleType, providers) {
7358
7399
  let factory = undefined;
7359
- if (ngDevMode && isImportedNgModuleProviders(provider)) {
7400
+ if (ngDevMode && isEnvironmentProviders(provider)) {
7360
7401
  throwInvalidProviderError(undefined, providers, provider);
7361
7402
  }
7362
7403
  if (isTypeProvider(provider)) {
@@ -7407,15 +7448,12 @@ function couldBeInjectableType(value) {
7407
7448
  return (typeof value === 'function') ||
7408
7449
  (typeof value === 'object' && value instanceof InjectionToken);
7409
7450
  }
7410
- function isImportedNgModuleProviders(provider) {
7411
- return !!provider.ɵproviders;
7412
- }
7413
7451
  function forEachSingleProvider(providers, fn) {
7414
7452
  for (const provider of providers) {
7415
7453
  if (Array.isArray(provider)) {
7416
7454
  forEachSingleProvider(provider, fn);
7417
7455
  }
7418
- else if (isImportedNgModuleProviders(provider)) {
7456
+ else if (provider && isEnvironmentProviders(provider)) {
7419
7457
  forEachSingleProvider(provider.ɵproviders, fn);
7420
7458
  }
7421
7459
  else {
@@ -7646,7 +7684,7 @@ class Version {
7646
7684
  /**
7647
7685
  * @publicApi
7648
7686
  */
7649
- const VERSION = new Version('15.0.0-next.5');
7687
+ const VERSION = new Version('15.0.0-next.6');
7650
7688
 
7651
7689
  /**
7652
7690
  * @license
@@ -26039,17 +26077,17 @@ class TestBedCompiler {
26039
26077
  getProviderOverrides(providers) {
26040
26078
  if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
26041
26079
  return [];
26042
- // There are two flattening operations here. The inner flatten() operates on the metadata's
26043
- // providers and applies a mapping function which retrieves overrides for each incoming
26044
- // provider. The outer flatten() then flattens the produced overrides array. If this is not
26045
- // done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the
26080
+ // There are two flattening operations here. The inner flattenProviders() operates on the
26081
+ // metadata's providers and applies a mapping function which retrieves overrides for each
26082
+ // incoming provider. The outer flatten() then flattens the produced overrides array. If this is
26083
+ // not done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the
26046
26084
  // providers array and contaminate any error messages that might be generated.
26047
- return flatten(flatten(providers, (provider) => this.getSingleProviderOverrides(provider) || []));
26085
+ return flatten(flattenProviders(providers, (provider) => this.getSingleProviderOverrides(provider) || []));
26048
26086
  }
26049
26087
  getOverriddenProviders(providers) {
26050
26088
  if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
26051
26089
  return [];
26052
- const flattenedProviders = flatten(providers);
26090
+ const flattenedProviders = flattenProviders(providers);
26053
26091
  const overrides = this.getProviderOverrides(flattenedProviders);
26054
26092
  const overriddenProviders = [...flattenedProviders, ...overrides];
26055
26093
  const final = [];
@@ -26113,18 +26151,36 @@ function isNgModule(value) {
26113
26151
  function maybeUnwrapFn(maybeFn) {
26114
26152
  return maybeFn instanceof Function ? maybeFn() : maybeFn;
26115
26153
  }
26116
- function flatten(values, mapFn) {
26154
+ function flatten(values) {
26117
26155
  const out = [];
26118
26156
  values.forEach(value => {
26119
26157
  if (Array.isArray(value)) {
26120
- out.push(...flatten(value, mapFn));
26158
+ out.push(...flatten(value));
26121
26159
  }
26122
26160
  else {
26123
- out.push(mapFn ? mapFn(value) : value);
26161
+ out.push(value);
26124
26162
  }
26125
26163
  });
26126
26164
  return out;
26127
26165
  }
26166
+ function identityFn(value) {
26167
+ return value;
26168
+ }
26169
+ function flattenProviders(providers, mapFn = identityFn) {
26170
+ const out = [];
26171
+ for (let provider of providers) {
26172
+ if (ɵisEnvironmentProviders(provider)) {
26173
+ provider = provider.ɵproviders;
26174
+ }
26175
+ if (Array.isArray(provider)) {
26176
+ out.push(...flattenProviders(provider, mapFn));
26177
+ }
26178
+ else {
26179
+ out.push(mapFn(provider));
26180
+ }
26181
+ }
26182
+ return out;
26183
+ }
26128
26184
  function getProviderField(provider, field) {
26129
26185
  return provider && typeof provider === 'object' && provider[field];
26130
26186
  }