@angular/compiler 19.0.0-next.7 → 19.0.0-next.9
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/LICENSE +21 -0
- package/fesm2022/compiler.mjs +119 -65
- package/fesm2022/compiler.mjs.map +1 -1
- package/index.d.ts +7 -1
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010-2024 Google LLC. https://angular.dev/license
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/fesm2022/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-next.
|
|
2
|
+
* @license Angular v19.0.0-next.9
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2829,6 +2829,7 @@ class Identifiers {
|
|
|
2829
2829
|
}; }
|
|
2830
2830
|
static { this.forwardRef = { name: 'forwardRef', moduleName: CORE }; }
|
|
2831
2831
|
static { this.resolveForwardRef = { name: 'resolveForwardRef', moduleName: CORE }; }
|
|
2832
|
+
static { this.replaceMetadata = { name: 'ɵɵreplaceMetadata', moduleName: CORE }; }
|
|
2832
2833
|
static { this.ɵɵdefineInjectable = { name: 'ɵɵdefineInjectable', moduleName: CORE }; }
|
|
2833
2834
|
static { this.declareInjectable = { name: 'ɵɵngDeclareInjectable', moduleName: CORE }; }
|
|
2834
2835
|
static { this.InjectableDeclaration = {
|
|
@@ -2942,6 +2943,10 @@ class Identifiers {
|
|
|
2942
2943
|
name: 'ɵɵInputTransformsFeature',
|
|
2943
2944
|
moduleName: CORE,
|
|
2944
2945
|
}; }
|
|
2946
|
+
static { this.ExternalStylesFeature = {
|
|
2947
|
+
name: 'ɵɵExternalStylesFeature',
|
|
2948
|
+
moduleName: CORE,
|
|
2949
|
+
}; }
|
|
2945
2950
|
static { this.listener = { name: 'ɵɵlistener', moduleName: CORE }; }
|
|
2946
2951
|
static { this.getInheritedFactory = {
|
|
2947
2952
|
name: 'ɵɵgetInheritedFactory',
|
|
@@ -7304,7 +7309,7 @@ class ShadowCss {
|
|
|
7304
7309
|
* captures how many (if any) leading whitespaces are present or a comma
|
|
7305
7310
|
* - (?:(?:(['"])((?:\\\\|\\\2|(?!\2).)+)\2)|(-?[A-Za-z][\w\-]*))
|
|
7306
7311
|
* captures two different possible keyframes, ones which are quoted or ones which are valid css
|
|
7307
|
-
*
|
|
7312
|
+
* indents (custom properties excluded)
|
|
7308
7313
|
* - (?=[,\s;]|$)
|
|
7309
7314
|
* simply matches the end of the possible keyframe, valid endings are: a comma, a space, a
|
|
7310
7315
|
* semicolon or the end of the string
|
|
@@ -7533,7 +7538,7 @@ class ShadowCss {
|
|
|
7533
7538
|
*/
|
|
7534
7539
|
_scopeCssText(cssText, scopeSelector, hostSelector) {
|
|
7535
7540
|
const unscopedRules = this._extractUnscopedRulesFromCssText(cssText);
|
|
7536
|
-
// replace :host and :host-context -shadowcsshost and -
|
|
7541
|
+
// replace :host and :host-context with -shadowcsshost and -shadowcsshostcontext respectively
|
|
7537
7542
|
cssText = this._insertPolyfillHostInCssText(cssText);
|
|
7538
7543
|
cssText = this._convertColonHost(cssText);
|
|
7539
7544
|
cssText = this._convertColonHostContext(cssText);
|
|
@@ -7611,7 +7616,7 @@ class ShadowCss {
|
|
|
7611
7616
|
* .foo<scopeName> .bar { ... }
|
|
7612
7617
|
*/
|
|
7613
7618
|
_convertColonHostContext(cssText) {
|
|
7614
|
-
return cssText.replace(_cssColonHostContextReGlobal, (selectorText) => {
|
|
7619
|
+
return cssText.replace(_cssColonHostContextReGlobal, (selectorText, pseudoPrefix) => {
|
|
7615
7620
|
// We have captured a selector that contains a `:host-context` rule.
|
|
7616
7621
|
// For backward compatibility `:host-context` may contain a comma separated list of selectors.
|
|
7617
7622
|
// Each context selector group will contain a list of host-context selectors that must match
|
|
@@ -7660,10 +7665,10 @@ class ShadowCss {
|
|
|
7660
7665
|
selectorText = match[2];
|
|
7661
7666
|
}
|
|
7662
7667
|
// The context selectors now must be combined with each other to capture all the possible
|
|
7663
|
-
// selectors that `:host-context` can match. See `
|
|
7668
|
+
// selectors that `:host-context` can match. See `_combineHostContextSelectors()` for more
|
|
7664
7669
|
// info about how this is done.
|
|
7665
7670
|
return contextSelectorGroups
|
|
7666
|
-
.map((contextSelectors) =>
|
|
7671
|
+
.map((contextSelectors) => _combineHostContextSelectors(contextSelectors, selectorText, pseudoPrefix))
|
|
7667
7672
|
.join(', ');
|
|
7668
7673
|
});
|
|
7669
7674
|
}
|
|
@@ -7680,7 +7685,12 @@ class ShadowCss {
|
|
|
7680
7685
|
let selector = rule.selector;
|
|
7681
7686
|
let content = rule.content;
|
|
7682
7687
|
if (rule.selector[0] !== '@') {
|
|
7683
|
-
selector = this._scopeSelector(
|
|
7688
|
+
selector = this._scopeSelector({
|
|
7689
|
+
selector,
|
|
7690
|
+
scopeSelector,
|
|
7691
|
+
hostSelector,
|
|
7692
|
+
isParentSelector: true,
|
|
7693
|
+
});
|
|
7684
7694
|
}
|
|
7685
7695
|
else if (scopedAtRuleIdentifiers.some((atRule) => rule.selector.startsWith(atRule))) {
|
|
7686
7696
|
content = this._scopeSelectors(rule.content, scopeSelector, hostSelector);
|
|
@@ -7720,15 +7730,29 @@ class ShadowCss {
|
|
|
7720
7730
|
return new CssRule(selector, rule.content);
|
|
7721
7731
|
});
|
|
7722
7732
|
}
|
|
7723
|
-
|
|
7733
|
+
// `isParentSelector` is used to distinguish the selectors which are coming from
|
|
7734
|
+
// the initial selector string and any nested selectors, parsed recursively,
|
|
7735
|
+
// for example `selector = 'a:where(.one)'` could be the parent, while recursive call
|
|
7736
|
+
// would have `selector = '.one'`.
|
|
7737
|
+
_scopeSelector({ selector, scopeSelector, hostSelector, isParentSelector = false, }) {
|
|
7738
|
+
// Split the selector into independent parts by `,` (comma) unless
|
|
7739
|
+
// comma is within parenthesis, for example `:is(.one, two)`.
|
|
7740
|
+
// Negative lookup after comma allows not splitting inside nested parenthesis,
|
|
7741
|
+
// up to three levels (((,))).
|
|
7742
|
+
const selectorSplitRe = / ?,(?!(?:[^)(]*(?:\([^)(]*(?:\([^)(]*(?:\([^)(]*\)[^)(]*)*\)[^)(]*)*\)[^)(]*)*\))) ?/;
|
|
7724
7743
|
return selector
|
|
7725
|
-
.split(
|
|
7744
|
+
.split(selectorSplitRe)
|
|
7726
7745
|
.map((part) => part.split(_shadowDeepSelectors))
|
|
7727
7746
|
.map((deepParts) => {
|
|
7728
7747
|
const [shallowPart, ...otherParts] = deepParts;
|
|
7729
7748
|
const applyScope = (shallowPart) => {
|
|
7730
7749
|
if (this._selectorNeedsScoping(shallowPart, scopeSelector)) {
|
|
7731
|
-
return this._applySelectorScope(
|
|
7750
|
+
return this._applySelectorScope({
|
|
7751
|
+
selector: shallowPart,
|
|
7752
|
+
scopeSelector,
|
|
7753
|
+
hostSelector,
|
|
7754
|
+
isParentSelector,
|
|
7755
|
+
});
|
|
7732
7756
|
}
|
|
7733
7757
|
else {
|
|
7734
7758
|
return shallowPart;
|
|
@@ -7755,8 +7779,8 @@ class ShadowCss {
|
|
|
7755
7779
|
if (_polyfillHostRe.test(selector)) {
|
|
7756
7780
|
const replaceBy = `[${hostSelector}]`;
|
|
7757
7781
|
return selector
|
|
7758
|
-
.replace(
|
|
7759
|
-
return selector.replace(/([
|
|
7782
|
+
.replace(_polyfillHostNoCombinatorReGlobal, (_hnc, selector) => {
|
|
7783
|
+
return selector.replace(/([^:\)]*)(:*)(.*)/, (_, before, colon, after) => {
|
|
7760
7784
|
return before + replaceBy + colon + after;
|
|
7761
7785
|
});
|
|
7762
7786
|
})
|
|
@@ -7766,7 +7790,7 @@ class ShadowCss {
|
|
|
7766
7790
|
}
|
|
7767
7791
|
// return a selector with [name] suffix on each simple selector
|
|
7768
7792
|
// e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] /** @internal */
|
|
7769
|
-
_applySelectorScope(selector, scopeSelector, hostSelector) {
|
|
7793
|
+
_applySelectorScope({ selector, scopeSelector, hostSelector, isParentSelector, }) {
|
|
7770
7794
|
const isRe = /\[is=([^\]]*)\]/g;
|
|
7771
7795
|
scopeSelector = scopeSelector.replace(isRe, (_, ...parts) => parts[0]);
|
|
7772
7796
|
const attrName = '[' + scopeSelector + ']';
|
|
@@ -7777,6 +7801,10 @@ class ShadowCss {
|
|
|
7777
7801
|
}
|
|
7778
7802
|
if (p.includes(_polyfillHostNoCombinator)) {
|
|
7779
7803
|
scopedP = this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
|
|
7804
|
+
if (_polyfillHostNoCombinatorWithinPseudoFunction.test(p)) {
|
|
7805
|
+
const [_, before, colon, after] = scopedP.match(/([^:]*)(:*)(.*)/);
|
|
7806
|
+
scopedP = before + attrName + colon + after;
|
|
7807
|
+
}
|
|
7780
7808
|
}
|
|
7781
7809
|
else {
|
|
7782
7810
|
// remove :host since it should be unnecessary
|
|
@@ -7790,12 +7818,50 @@ class ShadowCss {
|
|
|
7790
7818
|
}
|
|
7791
7819
|
return scopedP;
|
|
7792
7820
|
};
|
|
7793
|
-
|
|
7794
|
-
selector
|
|
7821
|
+
// Wraps `_scopeSelectorPart()` to not use it directly on selectors with
|
|
7822
|
+
// pseudo selector functions like `:where()`. Selectors within pseudo selector
|
|
7823
|
+
// functions are recursively sent to `_scopeSelector()`.
|
|
7824
|
+
const _pseudoFunctionAwareScopeSelectorPart = (selectorPart) => {
|
|
7825
|
+
let scopedPart = '';
|
|
7826
|
+
const cssPrefixWithPseudoSelectorFunctionMatch = selectorPart.match(_cssPrefixWithPseudoSelectorFunction);
|
|
7827
|
+
if (cssPrefixWithPseudoSelectorFunctionMatch) {
|
|
7828
|
+
const [cssPseudoSelectorFunction] = cssPrefixWithPseudoSelectorFunctionMatch;
|
|
7829
|
+
// Unwrap the pseudo selector to scope its contents.
|
|
7830
|
+
// For example,
|
|
7831
|
+
// - `:where(selectorToScope)` -> `selectorToScope`;
|
|
7832
|
+
// - `:is(.foo, .bar)` -> `.foo, .bar`.
|
|
7833
|
+
const selectorToScope = selectorPart.slice(cssPseudoSelectorFunction.length, -1);
|
|
7834
|
+
if (selectorToScope.includes(_polyfillHostNoCombinator)) {
|
|
7835
|
+
this._shouldScopeIndicator = true;
|
|
7836
|
+
}
|
|
7837
|
+
const scopedInnerPart = this._scopeSelector({
|
|
7838
|
+
selector: selectorToScope,
|
|
7839
|
+
scopeSelector,
|
|
7840
|
+
hostSelector,
|
|
7841
|
+
});
|
|
7842
|
+
// Put the result back into the pseudo selector function.
|
|
7843
|
+
scopedPart = `${cssPseudoSelectorFunction}${scopedInnerPart})`;
|
|
7844
|
+
}
|
|
7845
|
+
else {
|
|
7846
|
+
this._shouldScopeIndicator =
|
|
7847
|
+
this._shouldScopeIndicator || selectorPart.includes(_polyfillHostNoCombinator);
|
|
7848
|
+
scopedPart = this._shouldScopeIndicator ? _scopeSelectorPart(selectorPart) : selectorPart;
|
|
7849
|
+
}
|
|
7850
|
+
return scopedPart;
|
|
7851
|
+
};
|
|
7852
|
+
if (isParentSelector) {
|
|
7853
|
+
this._safeSelector = new SafeSelector(selector);
|
|
7854
|
+
selector = this._safeSelector.content();
|
|
7855
|
+
}
|
|
7795
7856
|
let scopedSelector = '';
|
|
7796
7857
|
let startIndex = 0;
|
|
7797
7858
|
let res;
|
|
7798
|
-
|
|
7859
|
+
// Combinators aren't used as a delimiter if they are within parenthesis,
|
|
7860
|
+
// for example `:where(.one .two)` stays intact.
|
|
7861
|
+
// Similarly to selector separation by comma initially, negative lookahead
|
|
7862
|
+
// is used here to not break selectors within nested parenthesis up to three
|
|
7863
|
+
// nested layers.
|
|
7864
|
+
const sep = /( |>|\+|~(?!=))(?!([^)(]*(?:\([^)(]*(?:\([^)(]*(?:\([^)(]*\)[^)(]*)*\)[^)(]*)*\)[^)(]*)*\)))\s*/g;
|
|
7799
7865
|
// If a selector appears before :host it should not be shimmed as it
|
|
7800
7866
|
// matches on ancestor elements and not on elements in the host's shadow
|
|
7801
7867
|
// `:host-context(div)` is transformed to
|
|
@@ -7808,8 +7874,13 @@ class ShadowCss {
|
|
|
7808
7874
|
// - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
|
|
7809
7875
|
// `:host-context(tag)`)
|
|
7810
7876
|
const hasHost = selector.includes(_polyfillHostNoCombinator);
|
|
7811
|
-
// Only scope parts after the first `-shadowcsshost-no-combinator`
|
|
7812
|
-
|
|
7877
|
+
// Only scope parts after or on the same level as the first `-shadowcsshost-no-combinator`
|
|
7878
|
+
// when it is present. The selector has the same level when it is a part of a pseudo
|
|
7879
|
+
// selector, like `:where()`, for example `:where(:host, .foo)` would result in `.foo`
|
|
7880
|
+
// being scoped.
|
|
7881
|
+
if (isParentSelector || this._shouldScopeIndicator) {
|
|
7882
|
+
this._shouldScopeIndicator = !hasHost;
|
|
7883
|
+
}
|
|
7813
7884
|
while ((res = sep.exec(selector)) !== null) {
|
|
7814
7885
|
const separator = res[1];
|
|
7815
7886
|
// Do not trim the selector, as otherwise this will break sourcemaps
|
|
@@ -7825,16 +7896,15 @@ class ShadowCss {
|
|
|
7825
7896
|
if (part.match(/__esc-ph-(\d+)__/) && selector[res.index + 1]?.match(/[a-fA-F\d]/)) {
|
|
7826
7897
|
continue;
|
|
7827
7898
|
}
|
|
7828
|
-
|
|
7829
|
-
const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;
|
|
7899
|
+
const scopedPart = _pseudoFunctionAwareScopeSelectorPart(part);
|
|
7830
7900
|
scopedSelector += `${scopedPart} ${separator} `;
|
|
7831
7901
|
startIndex = sep.lastIndex;
|
|
7832
7902
|
}
|
|
7833
7903
|
const part = selector.substring(startIndex);
|
|
7834
|
-
|
|
7835
|
-
scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
|
|
7904
|
+
scopedSelector += _pseudoFunctionAwareScopeSelectorPart(part);
|
|
7836
7905
|
// replace the placeholders with their original values
|
|
7837
|
-
|
|
7906
|
+
// using values stored inside the `safeSelector` instance.
|
|
7907
|
+
return this._safeSelector.restore(scopedSelector);
|
|
7838
7908
|
}
|
|
7839
7909
|
_insertPolyfillHostInCssText(selector) {
|
|
7840
7910
|
return selector
|
|
@@ -7889,6 +7959,8 @@ class SafeSelector {
|
|
|
7889
7959
|
});
|
|
7890
7960
|
}
|
|
7891
7961
|
}
|
|
7962
|
+
const _cssScopedPseudoFunctionPrefix = '(:(where|is)\\()?';
|
|
7963
|
+
const _cssPrefixWithPseudoSelectorFunction = /^:(where|is)\(/i;
|
|
7892
7964
|
const _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim;
|
|
7893
7965
|
const _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
|
|
7894
7966
|
const _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
|
|
@@ -7897,10 +7969,12 @@ const _polyfillHost = '-shadowcsshost';
|
|
|
7897
7969
|
const _polyfillHostContext = '-shadowcsscontext';
|
|
7898
7970
|
const _parenSuffix = '(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)';
|
|
7899
7971
|
const _cssColonHostRe = new RegExp(_polyfillHost + _parenSuffix, 'gim');
|
|
7900
|
-
const _cssColonHostContextReGlobal = new RegExp(_polyfillHostContext + _parenSuffix, 'gim');
|
|
7972
|
+
const _cssColonHostContextReGlobal = new RegExp(_cssScopedPseudoFunctionPrefix + '(' + _polyfillHostContext + _parenSuffix + ')', 'gim');
|
|
7901
7973
|
const _cssColonHostContextRe = new RegExp(_polyfillHostContext + _parenSuffix, 'im');
|
|
7902
7974
|
const _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
|
|
7975
|
+
const _polyfillHostNoCombinatorWithinPseudoFunction = new RegExp(`:.*\\(.*${_polyfillHostNoCombinator}.*\\)`);
|
|
7903
7976
|
const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
|
|
7977
|
+
const _polyfillHostNoCombinatorReGlobal = new RegExp(_polyfillHostNoCombinatorRe, 'g');
|
|
7904
7978
|
const _shadowDOMSelectorsRe = [
|
|
7905
7979
|
/::shadow/g,
|
|
7906
7980
|
/::content/g,
|
|
@@ -8134,7 +8208,7 @@ function unescapeQuotes(str, isQuoted) {
|
|
|
8134
8208
|
* @param contextSelectors an array of context selectors that will be combined.
|
|
8135
8209
|
* @param otherSelectors the rest of the selectors that are not context selectors.
|
|
8136
8210
|
*/
|
|
8137
|
-
function
|
|
8211
|
+
function _combineHostContextSelectors(contextSelectors, otherSelectors, pseudoPrefix = '') {
|
|
8138
8212
|
const hostMarker = _polyfillHostNoCombinator;
|
|
8139
8213
|
_polyfillHostRe.lastIndex = 0; // reset the regex to ensure we get an accurate test
|
|
8140
8214
|
const otherSelectorsHasHost = _polyfillHostRe.test(otherSelectors);
|
|
@@ -8160,8 +8234,8 @@ function combineHostContextSelectors(contextSelectors, otherSelectors) {
|
|
|
8160
8234
|
// (A<hostMarker>) or as an ancestor (A <hostMarker>).
|
|
8161
8235
|
return combined
|
|
8162
8236
|
.map((s) => otherSelectorsHasHost
|
|
8163
|
-
? `${s}${otherSelectors}`
|
|
8164
|
-
: `${s}${hostMarker}${otherSelectors}, ${s} ${hostMarker}${otherSelectors}`)
|
|
8237
|
+
? `${pseudoPrefix}${s}${otherSelectors}`
|
|
8238
|
+
: `${pseudoPrefix}${s}${hostMarker}${otherSelectors}, ${pseudoPrefix}${s} ${hostMarker}${otherSelectors}`)
|
|
8165
8239
|
.join(',');
|
|
8166
8240
|
}
|
|
8167
8241
|
/**
|
|
@@ -25104,29 +25178,9 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
25104
25178
|
return convertAst(ast.ast, job, baseSourceSpan);
|
|
25105
25179
|
}
|
|
25106
25180
|
else if (ast instanceof PropertyRead) {
|
|
25107
|
-
const isThisReceiver = ast.receiver instanceof ThisReceiver;
|
|
25108
25181
|
// Whether this is an implicit receiver, *excluding* explicit reads of `this`.
|
|
25109
25182
|
const isImplicitReceiver = ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver);
|
|
25110
|
-
|
|
25111
|
-
// receiver.
|
|
25112
|
-
const isSpecialNode = ast.name === '$any' || ast.name === '$event';
|
|
25113
|
-
// TODO: The most sensible condition here would be simply `isImplicitReceiver`, to convert only
|
|
25114
|
-
// actual implicit `this` reads, and not explicit ones. However, TemplateDefinitionBuilder (and
|
|
25115
|
-
// the Typecheck block!) both have the same bug, in which they also consider explicit `this`
|
|
25116
|
-
// reads to be implicit. This causes problems when the explicit `this` read is inside a
|
|
25117
|
-
// template with a context that also provides the variable name being read:
|
|
25118
|
-
// ```
|
|
25119
|
-
// <ng-template let-a>{{this.a}}</ng-template>
|
|
25120
|
-
// ```
|
|
25121
|
-
// The whole point of the explicit `this` was to access the class property, but TDB and the
|
|
25122
|
-
// current TCB treat the read as implicit, and give you the context property instead!
|
|
25123
|
-
//
|
|
25124
|
-
// For now, we emulate this old behavior by aggressively converting explicit reads to to
|
|
25125
|
-
// implicit reads, except for the special cases that TDB and the current TCB protect. However,
|
|
25126
|
-
// it would be an improvement to fix this.
|
|
25127
|
-
//
|
|
25128
|
-
// See also the corresponding comment for the TCB, in `type_check_block.ts`.
|
|
25129
|
-
if (isImplicitReceiver || (isThisReceiver && !isSpecialNode)) {
|
|
25183
|
+
if (isImplicitReceiver) {
|
|
25130
25184
|
return new LexicalReadExpr(ast.name);
|
|
25131
25185
|
}
|
|
25132
25186
|
else {
|
|
@@ -27987,6 +28041,10 @@ function addFeatures(definitionMap, meta) {
|
|
|
27987
28041
|
if (meta.hasOwnProperty('template') && meta.isStandalone) {
|
|
27988
28042
|
features.push(importExpr(Identifiers.StandaloneFeature));
|
|
27989
28043
|
}
|
|
28044
|
+
if ('externalStyles' in meta && meta.externalStyles?.length) {
|
|
28045
|
+
const externalStyleNodes = meta.externalStyles.map((externalStyle) => literal(externalStyle));
|
|
28046
|
+
features.push(importExpr(Identifiers.ExternalStylesFeature).callFn([literalArr(externalStyleNodes)]));
|
|
28047
|
+
}
|
|
27990
28048
|
if (features.length) {
|
|
27991
28049
|
definitionMap.set('features', literalArr(features));
|
|
27992
28050
|
}
|
|
@@ -28062,6 +28120,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
28062
28120
|
if (meta.encapsulation === null) {
|
|
28063
28121
|
meta.encapsulation = ViewEncapsulation.Emulated;
|
|
28064
28122
|
}
|
|
28123
|
+
let hasStyles = !!meta.externalStyles?.length;
|
|
28065
28124
|
// e.g. `styles: [str1, str2]`
|
|
28066
28125
|
if (meta.styles && meta.styles.length) {
|
|
28067
28126
|
const styleValues = meta.encapsulation == ViewEncapsulation.Emulated
|
|
@@ -28074,10 +28133,11 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
28074
28133
|
return result;
|
|
28075
28134
|
}, []);
|
|
28076
28135
|
if (styleNodes.length > 0) {
|
|
28136
|
+
hasStyles = true;
|
|
28077
28137
|
definitionMap.set('styles', literalArr(styleNodes));
|
|
28078
28138
|
}
|
|
28079
28139
|
}
|
|
28080
|
-
|
|
28140
|
+
if (!hasStyles && meta.encapsulation === ViewEncapsulation.Emulated) {
|
|
28081
28141
|
// If there is no style, don't generate css selectors on elements
|
|
28082
28142
|
meta.encapsulation = ViewEncapsulation.None;
|
|
28083
28143
|
}
|
|
@@ -29119,18 +29179,12 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
29119
29179
|
maybeMap(ast, name) {
|
|
29120
29180
|
// If the receiver of the expression isn't the `ImplicitReceiver`, this isn't the root of an
|
|
29121
29181
|
// `AST` expression that maps to a `Variable` or `Reference`.
|
|
29122
|
-
if (!(ast.receiver instanceof ImplicitReceiver)) {
|
|
29182
|
+
if (!(ast.receiver instanceof ImplicitReceiver) || ast.receiver instanceof ThisReceiver) {
|
|
29123
29183
|
return;
|
|
29124
29184
|
}
|
|
29125
29185
|
// Check whether the name exists in the current scope. If so, map it. Otherwise, the name is
|
|
29126
29186
|
// probably a property on the top-level component context.
|
|
29127
29187
|
const target = this.scope.lookup(name);
|
|
29128
|
-
// It's not allowed to read template entities via `this`, however it previously worked by
|
|
29129
|
-
// accident (see #55115). Since `@let` declarations are new, we can fix it from the beginning,
|
|
29130
|
-
// whereas pre-existing template entities will be fixed in #55115.
|
|
29131
|
-
if (target instanceof LetDeclaration$1 && ast.receiver instanceof ThisReceiver) {
|
|
29132
|
-
return;
|
|
29133
|
-
}
|
|
29134
29188
|
if (target !== null) {
|
|
29135
29189
|
this.bindings.set(ast, target);
|
|
29136
29190
|
}
|
|
@@ -29987,7 +30041,7 @@ function publishFacade(global) {
|
|
|
29987
30041
|
* @description
|
|
29988
30042
|
* Entry point for all public APIs of the compiler package.
|
|
29989
30043
|
*/
|
|
29990
|
-
const VERSION = new Version('19.0.0-next.
|
|
30044
|
+
const VERSION = new Version('19.0.0-next.9');
|
|
29991
30045
|
|
|
29992
30046
|
class CompilerConfig {
|
|
29993
30047
|
constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, preserveWhitespaces, strictInjectionParameters, } = {}) {
|
|
@@ -31638,7 +31692,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
|
31638
31692
|
function compileDeclareClassMetadata(metadata) {
|
|
31639
31693
|
const definitionMap = new DefinitionMap();
|
|
31640
31694
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
31641
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
31695
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
31642
31696
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31643
31697
|
definitionMap.set('type', metadata.type);
|
|
31644
31698
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -31656,7 +31710,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
|
31656
31710
|
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
|
|
31657
31711
|
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
|
|
31658
31712
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
31659
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
31713
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
31660
31714
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31661
31715
|
definitionMap.set('type', metadata.type);
|
|
31662
31716
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
@@ -31751,7 +31805,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
31751
31805
|
const definitionMap = new DefinitionMap();
|
|
31752
31806
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
31753
31807
|
definitionMap.set('minVersion', literal(minVersion));
|
|
31754
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
31808
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
31755
31809
|
// e.g. `type: MyDirective`
|
|
31756
31810
|
definitionMap.set('type', meta.type.value);
|
|
31757
31811
|
if (meta.isStandalone) {
|
|
@@ -32173,7 +32227,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
32173
32227
|
function compileDeclareFactoryFunction(meta) {
|
|
32174
32228
|
const definitionMap = new DefinitionMap();
|
|
32175
32229
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
32176
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
32230
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
32177
32231
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32178
32232
|
definitionMap.set('type', meta.type.value);
|
|
32179
32233
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -32208,7 +32262,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
32208
32262
|
function createInjectableDefinitionMap(meta) {
|
|
32209
32263
|
const definitionMap = new DefinitionMap();
|
|
32210
32264
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
32211
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
32265
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
32212
32266
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32213
32267
|
definitionMap.set('type', meta.type.value);
|
|
32214
32268
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -32259,7 +32313,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
32259
32313
|
function createInjectorDefinitionMap(meta) {
|
|
32260
32314
|
const definitionMap = new DefinitionMap();
|
|
32261
32315
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
32262
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
32316
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
32263
32317
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32264
32318
|
definitionMap.set('type', meta.type.value);
|
|
32265
32319
|
definitionMap.set('providers', meta.providers);
|
|
@@ -32292,7 +32346,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
32292
32346
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
32293
32347
|
}
|
|
32294
32348
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
32295
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
32349
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
32296
32350
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32297
32351
|
definitionMap.set('type', meta.type.value);
|
|
32298
32352
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -32343,7 +32397,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
32343
32397
|
function createPipeDefinitionMap(meta) {
|
|
32344
32398
|
const definitionMap = new DefinitionMap();
|
|
32345
32399
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
32346
|
-
definitionMap.set('version', literal('19.0.0-next.
|
|
32400
|
+
definitionMap.set('version', literal('19.0.0-next.9'));
|
|
32347
32401
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32348
32402
|
// e.g. `type: MyPipe`
|
|
32349
32403
|
definitionMap.set('type', meta.type.value);
|