@angular/compiler 16.0.3 → 16.0.5

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.0.3
2
+ * @license Angular v16.0.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -7500,11 +7500,28 @@ class ShadowCss {
7500
7500
  * The hostSelector is the attribute added to the host itself.
7501
7501
  */
7502
7502
  shimCssText(cssText, selector, hostSelector = '') {
7503
- const commentsWithHash = extractCommentsWithHash(cssText);
7504
- cssText = stripComments(cssText);
7503
+ // **NOTE**: Do not strip comments as this will cause component sourcemaps to break
7504
+ // due to shift in lines.
7505
+ // Collect comments and replace them with a placeholder, this is done to avoid complicating
7506
+ // the rule parsing RegExp and keep it safer.
7507
+ const comments = [];
7508
+ cssText = cssText.replace(_commentRe, (m) => {
7509
+ if (m.match(_commentWithHashRe)) {
7510
+ comments.push(m);
7511
+ }
7512
+ else {
7513
+ // Replace non hash comments with empty lines.
7514
+ // This is done so that we do not leak any senstive data in comments.
7515
+ const newLinesMatches = m.match(_newLinesRe);
7516
+ comments.push((newLinesMatches?.join('') ?? '') + '\n');
7517
+ }
7518
+ return COMMENT_PLACEHOLDER;
7519
+ });
7505
7520
  cssText = this._insertDirectives(cssText);
7506
7521
  const scopedCssText = this._scopeCssText(cssText, selector, hostSelector);
7507
- return [scopedCssText, ...commentsWithHash].join('\n');
7522
+ // Add back comments at the original position.
7523
+ let commentIdx = 0;
7524
+ return scopedCssText.replace(_commentWithHashPlaceHolderRe, () => comments[commentIdx++]);
7508
7525
  }
7509
7526
  _insertDirectives(cssText) {
7510
7527
  cssText = this._insertPolyfillDirectivesInCssText(cssText);
@@ -7745,7 +7762,7 @@ class ShadowCss {
7745
7762
  return cssText.replace(_cssColonHostRe, (_, hostSelectors, otherSelectors) => {
7746
7763
  if (hostSelectors) {
7747
7764
  const convertedSelectors = [];
7748
- const hostSelectorArray = hostSelectors.split(',').map(p => p.trim());
7765
+ const hostSelectorArray = hostSelectors.split(',').map((p) => p.trim());
7749
7766
  for (const hostSelector of hostSelectorArray) {
7750
7767
  if (!hostSelector)
7751
7768
  break;
@@ -7775,7 +7792,7 @@ class ShadowCss {
7775
7792
  * .foo<scopeName> .bar { ... }
7776
7793
  */
7777
7794
  _convertColonHostContext(cssText) {
7778
- return cssText.replace(_cssColonHostContextReGlobal, selectorText => {
7795
+ return cssText.replace(_cssColonHostContextReGlobal, (selectorText) => {
7779
7796
  // We have captured a selector that contains a `:host-context` rule.
7780
7797
  // For backward compatibility `:host-context` may contain a comma separated list of selectors.
7781
7798
  // Each context selector group will contain a list of host-context selectors that must match
@@ -7787,10 +7804,10 @@ class ShadowCss {
7787
7804
  // Execute `_cssColonHostContextRe` over and over until we have extracted all the
7788
7805
  // `:host-context` selectors from this selector.
7789
7806
  let match;
7790
- while (match = _cssColonHostContextRe.exec(selectorText)) {
7807
+ while ((match = _cssColonHostContextRe.exec(selectorText))) {
7791
7808
  // `match` = [':host-context(<selectors>)<rest>', <selectors>, <rest>]
7792
7809
  // The `<selectors>` could actually be a comma separated list: `:host-context(.one, .two)`.
7793
- const newContextSelectors = (match[1] ?? '').trim().split(',').map(m => m.trim()).filter(m => m !== '');
7810
+ const newContextSelectors = (match[1] ?? '').trim().split(',').map((m) => m.trim()).filter((m) => m !== '');
7794
7811
  // We must duplicate the current selector group for each of these new selectors.
7795
7812
  // For example if the current groups are:
7796
7813
  // ```
@@ -7813,7 +7830,7 @@ class ShadowCss {
7813
7830
  repeatGroups(contextSelectorGroups, newContextSelectors.length);
7814
7831
  for (let i = 0; i < newContextSelectors.length; i++) {
7815
7832
  for (let j = 0; j < contextSelectorGroupsLength; j++) {
7816
- contextSelectorGroups[j + (i * contextSelectorGroupsLength)].push(newContextSelectors[i]);
7833
+ contextSelectorGroups[j + i * contextSelectorGroupsLength].push(newContextSelectors[i]);
7817
7834
  }
7818
7835
  }
7819
7836
  // Update the `selectorText` and see repeat to see if there are more `:host-context`s.
@@ -7823,7 +7840,7 @@ class ShadowCss {
7823
7840
  // selectors that `:host-context` can match. See `combineHostContextSelectors()` for more
7824
7841
  // info about how this is done.
7825
7842
  return contextSelectorGroups
7826
- .map(contextSelectors => combineHostContextSelectors(contextSelectors, selectorText))
7843
+ .map((contextSelectors) => combineHostContextSelectors(contextSelectors, selectorText))
7827
7844
  .join(', ');
7828
7845
  });
7829
7846
  }
@@ -7875,7 +7892,7 @@ class ShadowCss {
7875
7892
  * ```
7876
7893
  */
7877
7894
  _stripScopingSelectors(cssText) {
7878
- return processRules(cssText, rule => {
7895
+ return processRules(cssText, (rule) => {
7879
7896
  const selector = rule.selector.replace(_shadowDeepSelectors, ' ')
7880
7897
  .replace(_polyfillHostNoCombinatorRe, ' ');
7881
7898
  return new CssRule(selector, rule.content);
@@ -7883,7 +7900,7 @@ class ShadowCss {
7883
7900
  }
7884
7901
  _scopeSelector(selector, scopeSelector, hostSelector) {
7885
7902
  return selector.split(',')
7886
- .map(part => part.trim().split(_shadowDeepSelectors))
7903
+ .map((part) => part.trim().split(_shadowDeepSelectors))
7887
7904
  .map((deepParts) => {
7888
7905
  const [shallowPart, ...otherParts] = deepParts;
7889
7906
  const applyScope = (shallowPart) => {
@@ -8066,17 +8083,14 @@ const _selectorReSuffix = '([>\\s~+[.,{:][\\s\\S]*)?$';
8066
8083
  const _polyfillHostRe = /-shadowcsshost/gim;
8067
8084
  const _colonHostRe = /:host/gim;
8068
8085
  const _colonHostContextRe = /:host-context/gim;
8086
+ const _newLinesRe = /\r?\n/g;
8069
8087
  const _commentRe = /\/\*[\s\S]*?\*\//g;
8088
+ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=/g;
8089
+ const COMMENT_PLACEHOLDER = '%COMMENT%';
8090
+ const _commentWithHashPlaceHolderRe = new RegExp(COMMENT_PLACEHOLDER, 'g');
8070
8091
  const _placeholderRe = /__ph-(\d+)__/g;
8071
- function stripComments(input) {
8072
- return input.replace(_commentRe, '');
8073
- }
8074
- const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
8075
- function extractCommentsWithHash(input) {
8076
- return input.match(_commentWithHashRe) || [];
8077
- }
8078
8092
  const BLOCK_PLACEHOLDER = '%BLOCK%';
8079
- const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
8093
+ const _ruleRe = new RegExp(`(\\s*(?:${COMMENT_PLACEHOLDER}\\s*)*)([^;\\{\\}]+?)(\\s*)((?:{%BLOCK%}?\\s*;?)|(?:\\s*;))`, 'g');
8080
8094
  const CONTENT_PAIRS = new Map([['{', '}']]);
8081
8095
  const COMMA_IN_PLACEHOLDER = '%COMMA_IN_PLACEHOLDER%';
8082
8096
  const SEMI_IN_PLACEHOLDER = '%SEMI_IN_PLACEHOLDER%';
@@ -8285,7 +8299,6 @@ function unescapeQuotes(str, isQuoted) {
8285
8299
  *
8286
8300
  * And so on...
8287
8301
  *
8288
- * @param hostMarker the string that selects the host element.
8289
8302
  * @param contextSelectors an array of context selectors that will be combined.
8290
8303
  * @param otherSelectors the rest of the selectors that are not context selectors.
8291
8304
  */
@@ -22559,7 +22572,7 @@ function publishFacade(global) {
22559
22572
  * @description
22560
22573
  * Entry point for all public APIs of the compiler package.
22561
22574
  */
22562
- const VERSION = new Version('16.0.3');
22575
+ const VERSION = new Version('16.0.5');
22563
22576
 
22564
22577
  class CompilerConfig {
22565
22578
  constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, missingTranslation = null, preserveWhitespaces, strictInjectionParameters } = {}) {
@@ -24487,7 +24500,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
24487
24500
  function compileDeclareClassMetadata(metadata) {
24488
24501
  const definitionMap = new DefinitionMap();
24489
24502
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
24490
- definitionMap.set('version', literal('16.0.3'));
24503
+ definitionMap.set('version', literal('16.0.5'));
24491
24504
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24492
24505
  definitionMap.set('type', metadata.type);
24493
24506
  definitionMap.set('decorators', metadata.decorators);
@@ -24590,7 +24603,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
24590
24603
  function createDirectiveDefinitionMap(meta) {
24591
24604
  const definitionMap = new DefinitionMap();
24592
24605
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
24593
- definitionMap.set('version', literal('16.0.3'));
24606
+ definitionMap.set('version', literal('16.0.5'));
24594
24607
  // e.g. `type: MyDirective`
24595
24608
  definitionMap.set('type', meta.type.value);
24596
24609
  if (meta.isStandalone) {
@@ -24815,7 +24828,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
24815
24828
  function compileDeclareFactoryFunction(meta) {
24816
24829
  const definitionMap = new DefinitionMap();
24817
24830
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
24818
- definitionMap.set('version', literal('16.0.3'));
24831
+ definitionMap.set('version', literal('16.0.5'));
24819
24832
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24820
24833
  definitionMap.set('type', meta.type.value);
24821
24834
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -24850,7 +24863,7 @@ function compileDeclareInjectableFromMetadata(meta) {
24850
24863
  function createInjectableDefinitionMap(meta) {
24851
24864
  const definitionMap = new DefinitionMap();
24852
24865
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
24853
- definitionMap.set('version', literal('16.0.3'));
24866
+ definitionMap.set('version', literal('16.0.5'));
24854
24867
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24855
24868
  definitionMap.set('type', meta.type.value);
24856
24869
  // Only generate providedIn property if it has a non-null value
@@ -24901,7 +24914,7 @@ function compileDeclareInjectorFromMetadata(meta) {
24901
24914
  function createInjectorDefinitionMap(meta) {
24902
24915
  const definitionMap = new DefinitionMap();
24903
24916
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
24904
- definitionMap.set('version', literal('16.0.3'));
24917
+ definitionMap.set('version', literal('16.0.5'));
24905
24918
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24906
24919
  definitionMap.set('type', meta.type.value);
24907
24920
  definitionMap.set('providers', meta.providers);
@@ -24931,7 +24944,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
24931
24944
  function createNgModuleDefinitionMap(meta) {
24932
24945
  const definitionMap = new DefinitionMap();
24933
24946
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
24934
- definitionMap.set('version', literal('16.0.3'));
24947
+ definitionMap.set('version', literal('16.0.5'));
24935
24948
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24936
24949
  definitionMap.set('type', meta.type.value);
24937
24950
  // We only generate the keys in the metadata if the arrays contain values.
@@ -24982,7 +24995,7 @@ function compileDeclarePipeFromMetadata(meta) {
24982
24995
  function createPipeDefinitionMap(meta) {
24983
24996
  const definitionMap = new DefinitionMap();
24984
24997
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
24985
- definitionMap.set('version', literal('16.0.3'));
24998
+ definitionMap.set('version', literal('16.0.5'));
24986
24999
  definitionMap.set('ngImport', importExpr(Identifiers.core));
24987
25000
  // e.g. `type: MyPipe`
24988
25001
  definitionMap.set('type', meta.type.value);