@angular/core 14.1.0-next.1 → 14.1.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/esm2020/src/application_ref.mjs +10 -24
- package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +3 -5
- package/esm2020/src/change_detection/differs/default_keyvalue_differ.mjs +3 -5
- package/esm2020/src/change_detection/differs/iterable_differs.mjs +3 -5
- package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +2 -5
- package/esm2020/src/di/injector_compatibility.mjs +4 -9
- package/esm2020/src/render3/features/inherit_definition_feature.mjs +3 -5
- package/esm2020/src/render3/jit/directive.mjs +20 -3
- package/esm2020/src/render3/ng_module_ref.mjs +10 -2
- package/esm2020/src/render3/view_ref.mjs +3 -5
- package/esm2020/src/sanitization/sanitization.mjs +4 -9
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/esm2020/testing/src/r3_test_bed_compiler.mjs +30 -25
- package/fesm2015/core.mjs +56 -68
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +53 -54
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +56 -68
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +53 -54
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +10 -2
- package/package.json +1 -1
- package/testing/index.d.ts +1 -1
package/fesm2020/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.1.0-next.
|
|
2
|
+
* @license Angular v14.1.0-next.2
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2045,10 +2045,8 @@ function setCurrentInjector(injector) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
function injectInjectorOnly(token, flags = InjectFlags.Default) {
|
|
2047
2047
|
if (_currentInjector === undefined) {
|
|
2048
|
-
|
|
2049
|
-
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`
|
|
2050
|
-
'';
|
|
2051
|
-
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, errorMessage);
|
|
2048
|
+
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, ngDevMode &&
|
|
2049
|
+
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`);
|
|
2052
2050
|
}
|
|
2053
2051
|
else if (_currentInjector === null) {
|
|
2054
2052
|
return injectRootLimpMode(token, undefined, flags);
|
|
@@ -2154,10 +2152,7 @@ function injectArgs(types) {
|
|
|
2154
2152
|
const arg = resolveForwardRef(types[i]);
|
|
2155
2153
|
if (Array.isArray(arg)) {
|
|
2156
2154
|
if (arg.length === 0) {
|
|
2157
|
-
|
|
2158
|
-
'Arguments array must have arguments.' :
|
|
2159
|
-
'';
|
|
2160
|
-
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, errorMessage);
|
|
2155
|
+
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
|
|
2161
2156
|
}
|
|
2162
2157
|
let type = undefined;
|
|
2163
2158
|
let flags = InjectFlags.Default;
|
|
@@ -6489,10 +6484,8 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
|
|
|
6489
6484
|
if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* BypassType.ResourceUrl */)) {
|
|
6490
6485
|
return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
|
|
6491
6486
|
}
|
|
6492
|
-
|
|
6493
|
-
'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)'
|
|
6494
|
-
'';
|
|
6495
|
-
throw new RuntimeError(904 /* RuntimeErrorCode.UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
|
|
6487
|
+
throw new RuntimeError(904 /* RuntimeErrorCode.UNSAFE_VALUE_IN_RESOURCE_URL */, ngDevMode &&
|
|
6488
|
+
'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
|
|
6496
6489
|
}
|
|
6497
6490
|
/**
|
|
6498
6491
|
* A `script` sanitizer which only lets trusted javascript through.
|
|
@@ -6514,10 +6507,7 @@ function ɵɵsanitizeScript(unsafeScript) {
|
|
|
6514
6507
|
if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* BypassType.Script */)) {
|
|
6515
6508
|
return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
|
|
6516
6509
|
}
|
|
6517
|
-
|
|
6518
|
-
'unsafe value used in a script context' :
|
|
6519
|
-
'';
|
|
6520
|
-
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
|
|
6510
|
+
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, ngDevMode && 'unsafe value used in a script context');
|
|
6521
6511
|
}
|
|
6522
6512
|
/**
|
|
6523
6513
|
* A template tag function for promoting the associated constant literal to a
|
|
@@ -14385,10 +14375,8 @@ function ɵɵInheritDefinitionFeature(definition) {
|
|
|
14385
14375
|
}
|
|
14386
14376
|
else {
|
|
14387
14377
|
if (superType.ɵcmp) {
|
|
14388
|
-
|
|
14389
|
-
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`
|
|
14390
|
-
'';
|
|
14391
|
-
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, errorMessage);
|
|
14378
|
+
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
|
|
14379
|
+
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
|
|
14392
14380
|
}
|
|
14393
14381
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
14394
14382
|
superDef = superType.ɵdir;
|
|
@@ -22085,7 +22073,7 @@ class Version {
|
|
|
22085
22073
|
/**
|
|
22086
22074
|
* @publicApi
|
|
22087
22075
|
*/
|
|
22088
|
-
const VERSION = new Version('14.1.0-next.
|
|
22076
|
+
const VERSION = new Version('14.1.0-next.2');
|
|
22089
22077
|
|
|
22090
22078
|
/**
|
|
22091
22079
|
* @license
|
|
@@ -22423,8 +22411,7 @@ class ViewRef {
|
|
|
22423
22411
|
}
|
|
22424
22412
|
attachToViewContainerRef() {
|
|
22425
22413
|
if (this._appRef) {
|
|
22426
|
-
|
|
22427
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
22414
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached directly to the ApplicationRef!');
|
|
22428
22415
|
}
|
|
22429
22416
|
this._attachedToViewContainer = true;
|
|
22430
22417
|
}
|
|
@@ -22434,8 +22421,7 @@ class ViewRef {
|
|
|
22434
22421
|
}
|
|
22435
22422
|
attachToAppRef(appRef) {
|
|
22436
22423
|
if (this._attachedToViewContainer) {
|
|
22437
|
-
|
|
22438
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
22424
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
|
|
22439
22425
|
}
|
|
22440
22426
|
this._appRef = appRef;
|
|
22441
22427
|
}
|
|
@@ -22756,10 +22742,18 @@ class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
|
|
|
22756
22742
|
/**
|
|
22757
22743
|
* Create a new environment injector.
|
|
22758
22744
|
*
|
|
22745
|
+
* Learn more about environment injectors in
|
|
22746
|
+
* [this guide](guide/standalone-components#environment-injectors).
|
|
22747
|
+
*
|
|
22748
|
+
* @param providers An array of providers.
|
|
22749
|
+
* @param parent A parent environment injector.
|
|
22750
|
+
* @param debugName An optional name for this injector instance, which will be used in error
|
|
22751
|
+
* messages.
|
|
22752
|
+
*
|
|
22759
22753
|
* @publicApi
|
|
22760
22754
|
* @developerPreview
|
|
22761
22755
|
*/
|
|
22762
|
-
function createEnvironmentInjector(providers, parent
|
|
22756
|
+
function createEnvironmentInjector(providers, parent, debugName = null) {
|
|
22763
22757
|
const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
|
|
22764
22758
|
return adapter.injector;
|
|
22765
22759
|
}
|
|
@@ -24713,7 +24707,7 @@ function patchModuleCompilation() {
|
|
|
24713
24707
|
function isModuleWithProviders$1(value) {
|
|
24714
24708
|
return value.ngModule !== undefined;
|
|
24715
24709
|
}
|
|
24716
|
-
function isNgModule(value) {
|
|
24710
|
+
function isNgModule$1(value) {
|
|
24717
24711
|
return !!getNgModuleDef(value);
|
|
24718
24712
|
}
|
|
24719
24713
|
|
|
@@ -25136,7 +25130,7 @@ function patchComponentDefWithScope(componentDef, transitiveScopes) {
|
|
|
25136
25130
|
* (either a NgModule or a standalone component / directive / pipe).
|
|
25137
25131
|
*/
|
|
25138
25132
|
function transitiveScopesFor(type) {
|
|
25139
|
-
if (isNgModule(type)) {
|
|
25133
|
+
if (isNgModule$1(type)) {
|
|
25140
25134
|
return transitiveScopesForNgModule(type);
|
|
25141
25135
|
}
|
|
25142
25136
|
else if (isStandalone(type)) {
|
|
@@ -25220,7 +25214,7 @@ function transitiveScopesForNgModule(moduleType) {
|
|
|
25220
25214
|
const exportedType = exported;
|
|
25221
25215
|
// Either the type is a module, a pipe, or a component/directive (which may not have a
|
|
25222
25216
|
// ɵcmp as it might be compiled asynchronously).
|
|
25223
|
-
if (isNgModule(exportedType)) {
|
|
25217
|
+
if (isNgModule$1(exportedType)) {
|
|
25224
25218
|
// When this module exports another, the exported module's exported directives and pipes are
|
|
25225
25219
|
// added to both the compilation and exported scopes of this module.
|
|
25226
25220
|
const exportedScope = transitiveScopesFor(exportedType);
|
|
@@ -25527,7 +25521,7 @@ class R3TestBedCompiler {
|
|
|
25527
25521
|
// module's provider list.
|
|
25528
25522
|
this.providerOverridesByModule = new Map();
|
|
25529
25523
|
this.providerOverridesByToken = new Map();
|
|
25530
|
-
this.
|
|
25524
|
+
this.scopesWithOverriddenProviders = new Set();
|
|
25531
25525
|
this.testModuleRef = null;
|
|
25532
25526
|
class DynamicTestModule {
|
|
25533
25527
|
}
|
|
@@ -25695,7 +25689,7 @@ class R3TestBedCompiler {
|
|
|
25695
25689
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25696
25690
|
this.compileTypesSync();
|
|
25697
25691
|
this.applyProviderOverrides();
|
|
25698
|
-
this.
|
|
25692
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25699
25693
|
this.applyTransitiveScopes();
|
|
25700
25694
|
}
|
|
25701
25695
|
/**
|
|
@@ -25705,7 +25699,7 @@ class R3TestBedCompiler {
|
|
|
25705
25699
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25706
25700
|
await this.compileComponents();
|
|
25707
25701
|
this.applyProviderOverrides();
|
|
25708
|
-
this.
|
|
25702
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25709
25703
|
this.applyTransitiveScopes();
|
|
25710
25704
|
}
|
|
25711
25705
|
/**
|
|
@@ -25806,50 +25800,52 @@ class R3TestBedCompiler {
|
|
|
25806
25800
|
this.seenComponents.clear();
|
|
25807
25801
|
this.seenDirectives.clear();
|
|
25808
25802
|
}
|
|
25809
|
-
|
|
25810
|
-
|
|
25803
|
+
/**
|
|
25804
|
+
* Applies provider overrides to a given type (either an NgModule or a standalone component)
|
|
25805
|
+
* and all imported NgModules and standalone components recursively.
|
|
25806
|
+
*/
|
|
25807
|
+
applyProviderOverridesInScope(type) {
|
|
25808
|
+
const hasScope = isStandaloneComponent(type) || isNgModule(type);
|
|
25809
|
+
// The function can be re-entered recursively while inspecting dependencies
|
|
25810
|
+
// of an NgModule or a standalone component. Exit early if we come across a
|
|
25811
|
+
// type that can not have a scope (directive or pipe) or the type is already
|
|
25812
|
+
// processed earlier.
|
|
25813
|
+
if (!hasScope || this.scopesWithOverriddenProviders.has(type)) {
|
|
25811
25814
|
return;
|
|
25812
25815
|
}
|
|
25813
|
-
this.
|
|
25816
|
+
this.scopesWithOverriddenProviders.add(type);
|
|
25814
25817
|
// NOTE: the line below triggers JIT compilation of the module injector,
|
|
25815
25818
|
// which also invokes verification of the NgModule semantics, which produces
|
|
25816
25819
|
// detailed error messages. The fact that the code relies on this line being
|
|
25817
25820
|
// present here is suspicious and should be refactored in a way that the line
|
|
25818
25821
|
// below can be moved (for ex. after an early exit check below).
|
|
25819
|
-
const injectorDef =
|
|
25822
|
+
const injectorDef = type[ɵNG_INJ_DEF];
|
|
25820
25823
|
// No provider overrides, exit early.
|
|
25821
25824
|
if (this.providerOverridesByToken.size === 0)
|
|
25822
25825
|
return;
|
|
25823
|
-
if (isStandaloneComponent(
|
|
25826
|
+
if (isStandaloneComponent(type)) {
|
|
25824
25827
|
// Visit all component dependencies and override providers there.
|
|
25825
|
-
const def = getComponentDef(
|
|
25828
|
+
const def = getComponentDef(type);
|
|
25826
25829
|
const dependencies = maybeUnwrapFn(def.dependencies ?? []);
|
|
25827
25830
|
for (const dependency of dependencies) {
|
|
25828
|
-
|
|
25829
|
-
// when a dependency is a standalone component or an NgModule.
|
|
25830
|
-
// In AOT, the `dependencies` might also contain regular (NgModule-based)
|
|
25831
|
-
// Component, Directive and Pipes. Skip them here, they are handled in a
|
|
25832
|
-
// different location (in the `configureTestingModule` function).
|
|
25833
|
-
if (isStandaloneComponent(dependency) || hasNgModuleDef(dependency)) {
|
|
25834
|
-
this.applyProviderOverridesToModule(dependency);
|
|
25835
|
-
}
|
|
25831
|
+
this.applyProviderOverridesInScope(dependency);
|
|
25836
25832
|
}
|
|
25837
25833
|
}
|
|
25838
25834
|
else {
|
|
25839
25835
|
const providers = [
|
|
25840
25836
|
...injectorDef.providers,
|
|
25841
|
-
...(this.providerOverridesByModule.get(
|
|
25837
|
+
...(this.providerOverridesByModule.get(type) || [])
|
|
25842
25838
|
];
|
|
25843
25839
|
if (this.hasProviderOverrides(providers)) {
|
|
25844
|
-
this.maybeStoreNgDef(ɵNG_INJ_DEF,
|
|
25845
|
-
this.storeFieldOfDefOnType(
|
|
25840
|
+
this.maybeStoreNgDef(ɵNG_INJ_DEF, type);
|
|
25841
|
+
this.storeFieldOfDefOnType(type, ɵNG_INJ_DEF, 'providers');
|
|
25846
25842
|
injectorDef.providers = this.getOverriddenProviders(providers);
|
|
25847
25843
|
}
|
|
25848
25844
|
// Apply provider overrides to imported modules recursively
|
|
25849
|
-
const moduleDef =
|
|
25845
|
+
const moduleDef = type[ɵNG_MOD_DEF];
|
|
25850
25846
|
const imports = maybeUnwrapFn(moduleDef.imports);
|
|
25851
25847
|
for (const importedModule of imports) {
|
|
25852
|
-
this.
|
|
25848
|
+
this.applyProviderOverridesInScope(importedModule);
|
|
25853
25849
|
}
|
|
25854
25850
|
// Also override the providers on any ModuleWithProviders imports since those don't appear in
|
|
25855
25851
|
// the moduleDef.
|
|
@@ -26086,7 +26082,7 @@ class R3TestBedCompiler {
|
|
|
26086
26082
|
});
|
|
26087
26083
|
});
|
|
26088
26084
|
this.initialNgDefs.clear();
|
|
26089
|
-
this.
|
|
26085
|
+
this.scopesWithOverriddenProviders.clear();
|
|
26090
26086
|
this.restoreComponentResolutionQueue();
|
|
26091
26087
|
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
|
26092
26088
|
ɵsetLocaleId(ɵDEFAULT_LOCALE_ID);
|
|
@@ -26113,7 +26109,7 @@ class R3TestBedCompiler {
|
|
|
26113
26109
|
providers,
|
|
26114
26110
|
}, /* allowDuplicateDeclarationsInRoot */ true);
|
|
26115
26111
|
// clang-format on
|
|
26116
|
-
this.
|
|
26112
|
+
this.applyProviderOverridesInScope(this.testModuleType);
|
|
26117
26113
|
}
|
|
26118
26114
|
get injector() {
|
|
26119
26115
|
if (this._injector !== null) {
|
|
@@ -26213,6 +26209,9 @@ function getComponentDef(value) {
|
|
|
26213
26209
|
function hasNgModuleDef(value) {
|
|
26214
26210
|
return value.hasOwnProperty('ɵmod');
|
|
26215
26211
|
}
|
|
26212
|
+
function isNgModule(value) {
|
|
26213
|
+
return hasNgModuleDef(value);
|
|
26214
|
+
}
|
|
26216
26215
|
function maybeUnwrapFn(maybeFn) {
|
|
26217
26216
|
return maybeFn instanceof Function ? maybeFn() : maybeFn;
|
|
26218
26217
|
}
|