@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 { __awaiter } from 'tslib';
9
9
  import { ResourceLoader } from '@angular/compiler';
10
10
  import { Subject, Subscription } from 'rxjs';
@@ -1887,6 +1887,17 @@ function initNgDevMode() {
1887
1887
  return false;
1888
1888
  }
1889
1889
 
1890
+ /**
1891
+ * @license
1892
+ * Copyright Google LLC All Rights Reserved.
1893
+ *
1894
+ * Use of this source code is governed by an MIT-style license that can be
1895
+ * found in the LICENSE file at https://angular.io/license
1896
+ */
1897
+ function isEnvironmentProviders(value) {
1898
+ return value && !!value.ɵproviders;
1899
+ }
1900
+
1890
1901
  /**
1891
1902
  * @license
1892
1903
  * Copyright Google LLC All Rights Reserved.
@@ -1943,8 +1954,13 @@ function throwInvalidProviderError(ngModuleType, providers, provider) {
1943
1954
  const providerDetail = providers.map(v => v == provider ? '?' + provider + '?' : '...');
1944
1955
  throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(', ')}]`);
1945
1956
  }
1946
- else if (provider.ɵproviders) {
1947
- 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.`);
1957
+ else if (isEnvironmentProviders(provider)) {
1958
+ if (provider.ɵfromNgModule) {
1959
+ 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.`);
1960
+ }
1961
+ else {
1962
+ 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.`);
1963
+ }
1948
1964
  }
1949
1965
  else {
1950
1966
  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
@@ -26043,17 +26081,17 @@ class TestBedCompiler {
26043
26081
  getProviderOverrides(providers) {
26044
26082
  if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
26045
26083
  return [];
26046
- // There are two flattening operations here. The inner flatten() operates on the metadata's
26047
- // providers and applies a mapping function which retrieves overrides for each incoming
26048
- // provider. The outer flatten() then flattens the produced overrides array. If this is not
26049
- // done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the
26084
+ // There are two flattening operations here. The inner flattenProviders() operates on the
26085
+ // metadata's providers and applies a mapping function which retrieves overrides for each
26086
+ // incoming provider. The outer flatten() then flattens the produced overrides array. If this is
26087
+ // not done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the
26050
26088
  // providers array and contaminate any error messages that might be generated.
26051
- return flatten(flatten(providers, (provider) => this.getSingleProviderOverrides(provider) || []));
26089
+ return flatten(flattenProviders(providers, (provider) => this.getSingleProviderOverrides(provider) || []));
26052
26090
  }
26053
26091
  getOverriddenProviders(providers) {
26054
26092
  if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
26055
26093
  return [];
26056
- const flattenedProviders = flatten(providers);
26094
+ const flattenedProviders = flattenProviders(providers);
26057
26095
  const overrides = this.getProviderOverrides(flattenedProviders);
26058
26096
  const overriddenProviders = [...flattenedProviders, ...overrides];
26059
26097
  const final = [];
@@ -26118,18 +26156,36 @@ function isNgModule(value) {
26118
26156
  function maybeUnwrapFn(maybeFn) {
26119
26157
  return maybeFn instanceof Function ? maybeFn() : maybeFn;
26120
26158
  }
26121
- function flatten(values, mapFn) {
26159
+ function flatten(values) {
26122
26160
  const out = [];
26123
26161
  values.forEach(value => {
26124
26162
  if (Array.isArray(value)) {
26125
- out.push(...flatten(value, mapFn));
26163
+ out.push(...flatten(value));
26126
26164
  }
26127
26165
  else {
26128
- out.push(mapFn ? mapFn(value) : value);
26166
+ out.push(value);
26129
26167
  }
26130
26168
  });
26131
26169
  return out;
26132
26170
  }
26171
+ function identityFn(value) {
26172
+ return value;
26173
+ }
26174
+ function flattenProviders(providers, mapFn = identityFn) {
26175
+ const out = [];
26176
+ for (let provider of providers) {
26177
+ if (ɵisEnvironmentProviders(provider)) {
26178
+ provider = provider.ɵproviders;
26179
+ }
26180
+ if (Array.isArray(provider)) {
26181
+ out.push(...flattenProviders(provider, mapFn));
26182
+ }
26183
+ else {
26184
+ out.push(mapFn(provider));
26185
+ }
26186
+ }
26187
+ return out;
26188
+ }
26133
26189
  function getProviderField(provider, field) {
26134
26190
  return provider && typeof provider === 'object' && provider[field];
26135
26191
  }