@angular/compiler 19.0.0-rc.1 → 19.0.0-rc.3

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 v19.0.0-rc.1
2
+ * @license Angular v19.0.0-rc.3
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -8197,13 +8197,15 @@ class ShadowCss {
8197
8197
  _polyfillHostRe.lastIndex = 0;
8198
8198
  if (_polyfillHostRe.test(selector)) {
8199
8199
  const replaceBy = `[${hostSelector}]`;
8200
- return selector
8201
- .replace(_polyfillHostNoCombinatorReGlobal, (_hnc, selector) => {
8202
- return selector.replace(/([^:\)]*)(:*)(.*)/, (_, before, colon, after) => {
8203
- return before + replaceBy + colon + after;
8200
+ let result = selector;
8201
+ while (result.match(_polyfillHostNoCombinatorRe)) {
8202
+ result = result.replace(_polyfillHostNoCombinatorRe, (_hnc, selector) => {
8203
+ return selector.replace(/([^:\)]*)(:*)(.*)/, (_, before, colon, after) => {
8204
+ return before + replaceBy + colon + after;
8205
+ });
8204
8206
  });
8205
- })
8206
- .replace(_polyfillHostRe, replaceBy + ' ');
8207
+ }
8208
+ return result.replace(_polyfillHostRe, replaceBy);
8207
8209
  }
8208
8210
  return scopeSelector + ' ' + selector;
8209
8211
  }
@@ -8212,7 +8214,7 @@ class ShadowCss {
8212
8214
  _applySelectorScope({ selector, scopeSelector, hostSelector, isParentSelector, }) {
8213
8215
  const isRe = /\[is=([^\]]*)\]/g;
8214
8216
  scopeSelector = scopeSelector.replace(isRe, (_, ...parts) => parts[0]);
8215
- const attrName = '[' + scopeSelector + ']';
8217
+ const attrName = `[${scopeSelector}]`;
8216
8218
  const _scopeSelectorPart = (p) => {
8217
8219
  let scopedP = p.trim();
8218
8220
  if (!scopedP) {
@@ -8220,8 +8222,8 @@ class ShadowCss {
8220
8222
  }
8221
8223
  if (p.includes(_polyfillHostNoCombinator)) {
8222
8224
  scopedP = this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
8223
- if (_polyfillHostNoCombinatorWithinPseudoFunction.test(p)) {
8224
- const [_, before, colon, after] = scopedP.match(/([^:]*)(:*)(.*)/);
8225
+ if (!p.match(_polyfillHostNoCombinatorOutsidePseudoFunction)) {
8226
+ const [_, before, colon, after] = scopedP.match(/([^:]*)(:*)([\s\S]*)/);
8225
8227
  scopedP = before + attrName + colon + after;
8226
8228
  }
8227
8229
  }
@@ -8229,7 +8231,7 @@ class ShadowCss {
8229
8231
  // remove :host since it should be unnecessary
8230
8232
  const t = p.replace(_polyfillHostRe, '');
8231
8233
  if (t.length > 0) {
8232
- const matches = t.match(/([^:]*)(:*)(.*)/);
8234
+ const matches = t.match(/([^:]*)(:*)([\s\S]*)/);
8233
8235
  if (matches) {
8234
8236
  scopedP = matches[1] + attrName + matches[2] + matches[3];
8235
8237
  }
@@ -8242,24 +8244,55 @@ class ShadowCss {
8242
8244
  // functions are recursively sent to `_scopeSelector()`.
8243
8245
  const _pseudoFunctionAwareScopeSelectorPart = (selectorPart) => {
8244
8246
  let scopedPart = '';
8245
- const cssPrefixWithPseudoSelectorFunctionMatch = selectorPart.match(_cssPrefixWithPseudoSelectorFunction);
8246
- if (cssPrefixWithPseudoSelectorFunctionMatch) {
8247
- const [cssPseudoSelectorFunction] = cssPrefixWithPseudoSelectorFunctionMatch;
8248
- // Unwrap the pseudo selector to scope its contents.
8249
- // For example,
8250
- // - `:where(selectorToScope)` -> `selectorToScope`;
8251
- // - `:is(.foo, .bar)` -> `.foo, .bar`.
8252
- const selectorToScope = selectorPart.slice(cssPseudoSelectorFunction.length, -1);
8253
- if (selectorToScope.includes(_polyfillHostNoCombinator)) {
8254
- this._shouldScopeIndicator = true;
8255
- }
8256
- const scopedInnerPart = this._scopeSelector({
8257
- selector: selectorToScope,
8258
- scopeSelector,
8259
- hostSelector,
8260
- });
8261
- // Put the result back into the pseudo selector function.
8262
- scopedPart = `${cssPseudoSelectorFunction}${scopedInnerPart})`;
8247
+ // Collect all outer `:where()` and `:is()` selectors,
8248
+ // counting parenthesis to keep nested selectors intact.
8249
+ const pseudoSelectorParts = [];
8250
+ let pseudoSelectorMatch;
8251
+ while ((pseudoSelectorMatch = _cssPrefixWithPseudoSelectorFunction.exec(selectorPart)) !== null) {
8252
+ let openedBrackets = 1;
8253
+ let index = _cssPrefixWithPseudoSelectorFunction.lastIndex;
8254
+ while (index < selectorPart.length) {
8255
+ const currentSymbol = selectorPart[index];
8256
+ index++;
8257
+ if (currentSymbol === '(') {
8258
+ openedBrackets++;
8259
+ continue;
8260
+ }
8261
+ if (currentSymbol === ')') {
8262
+ openedBrackets--;
8263
+ if (openedBrackets === 0) {
8264
+ break;
8265
+ }
8266
+ continue;
8267
+ }
8268
+ }
8269
+ pseudoSelectorParts.push(`${pseudoSelectorMatch[0]}${selectorPart.slice(_cssPrefixWithPseudoSelectorFunction.lastIndex, index)}`);
8270
+ _cssPrefixWithPseudoSelectorFunction.lastIndex = index;
8271
+ }
8272
+ // If selector consists of only `:where()` and `:is()` on the outer level
8273
+ // scope those pseudo-selectors individually, otherwise scope the whole
8274
+ // selector.
8275
+ if (pseudoSelectorParts.join('') === selectorPart) {
8276
+ scopedPart = pseudoSelectorParts
8277
+ .map((selectorPart) => {
8278
+ const [cssPseudoSelectorFunction] = selectorPart.match(_cssPrefixWithPseudoSelectorFunction) ?? [];
8279
+ // Unwrap the pseudo selector to scope its contents.
8280
+ // For example,
8281
+ // - `:where(selectorToScope)` -> `selectorToScope`;
8282
+ // - `:is(.foo, .bar)` -> `.foo, .bar`.
8283
+ const selectorToScope = selectorPart.slice(cssPseudoSelectorFunction?.length, -1);
8284
+ if (selectorToScope.includes(_polyfillHostNoCombinator)) {
8285
+ this._shouldScopeIndicator = true;
8286
+ }
8287
+ const scopedInnerPart = this._scopeSelector({
8288
+ selector: selectorToScope,
8289
+ scopeSelector,
8290
+ hostSelector,
8291
+ });
8292
+ // Put the result back into the pseudo selector function.
8293
+ return `${cssPseudoSelectorFunction}${scopedInnerPart})`;
8294
+ })
8295
+ .join('');
8263
8296
  }
8264
8297
  else {
8265
8298
  this._shouldScopeIndicator =
@@ -8380,7 +8413,7 @@ class SafeSelector {
8380
8413
  }
8381
8414
  }
8382
8415
  const _cssScopedPseudoFunctionPrefix = '(:(where|is)\\()?';
8383
- const _cssPrefixWithPseudoSelectorFunction = /^:(where|is)\(/i;
8416
+ const _cssPrefixWithPseudoSelectorFunction = /:(where|is)\(/gi;
8384
8417
  const _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim;
8385
8418
  const _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
8386
8419
  const _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
@@ -8392,9 +8425,8 @@ const _cssColonHostRe = new RegExp(_polyfillHost + _parenSuffix, 'gim');
8392
8425
  const _cssColonHostContextReGlobal = new RegExp(_cssScopedPseudoFunctionPrefix + '(' + _polyfillHostContext + _parenSuffix + ')', 'gim');
8393
8426
  const _cssColonHostContextRe = new RegExp(_polyfillHostContext + _parenSuffix, 'im');
8394
8427
  const _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
8395
- const _polyfillHostNoCombinatorWithinPseudoFunction = new RegExp(`:.*\\(.*${_polyfillHostNoCombinator}.*\\)`);
8396
- const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
8397
- const _polyfillHostNoCombinatorReGlobal = new RegExp(_polyfillHostNoCombinatorRe, 'g');
8428
+ const _polyfillHostNoCombinatorOutsidePseudoFunction = new RegExp(`${_polyfillHostNoCombinator}(?![^(]*\\))`, 'g');
8429
+ const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s,]*)/;
8398
8430
  const _shadowDOMSelectorsRe = [
8399
8431
  /::shadow/g,
8400
8432
  /::content/g,
@@ -26348,15 +26380,16 @@ function convertSourceSpan(span, baseSourceSpan) {
26348
26380
  * workaround, because it'll include an additional text node as the first child. We can work
26349
26381
  * around it here, but in a discussion it was decided not to, because the user explicitly opted
26350
26382
  * into preserving the whitespace and we would have to drop it from the generated code.
26351
- * The diagnostic mentioned point #1 will flag such cases to users.
26383
+ * The diagnostic mentioned point in #1 will flag such cases to users.
26352
26384
  *
26353
26385
  * @returns Tag name to be used for the control flow template.
26354
26386
  */
26355
26387
  function ingestControlFlowInsertionPoint(unit, xref, node) {
26356
26388
  let root = null;
26357
26389
  for (const child of node.children) {
26358
- // Skip over comment nodes.
26359
- if (child instanceof Comment$1) {
26390
+ // Skip over comment nodes and @let declarations since
26391
+ // it doesn't matter where they end up in the DOM.
26392
+ if (child instanceof Comment$1 || child instanceof LetDeclaration$1) {
26360
26393
  continue;
26361
26394
  }
26362
26395
  // We can only infer the tag name/attributes if there's a single root node.
@@ -26367,6 +26400,9 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
26367
26400
  if (child instanceof Element$1 || (child instanceof Template && child.tagName !== null)) {
26368
26401
  root = child;
26369
26402
  }
26403
+ else {
26404
+ return null;
26405
+ }
26370
26406
  }
26371
26407
  // If we've found a single root node, its tag name and attributes can be
26372
26408
  // copied to the surrounding template to be used for content projection.
@@ -30836,7 +30872,7 @@ function publishFacade(global) {
30836
30872
  * @description
30837
30873
  * Entry point for all public APIs of the compiler package.
30838
30874
  */
30839
- const VERSION = new Version('19.0.0-rc.1');
30875
+ const VERSION = new Version('19.0.0-rc.3');
30840
30876
 
30841
30877
  class CompilerConfig {
30842
30878
  defaultEncapsulation;
@@ -32680,7 +32716,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
32680
32716
  function compileDeclareClassMetadata(metadata) {
32681
32717
  const definitionMap = new DefinitionMap();
32682
32718
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
32683
- definitionMap.set('version', literal('19.0.0-rc.1'));
32719
+ definitionMap.set('version', literal('19.0.0-rc.3'));
32684
32720
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32685
32721
  definitionMap.set('type', metadata.type);
32686
32722
  definitionMap.set('decorators', metadata.decorators);
@@ -32698,7 +32734,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
32698
32734
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
32699
32735
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
32700
32736
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
32701
- definitionMap.set('version', literal('19.0.0-rc.1'));
32737
+ definitionMap.set('version', literal('19.0.0-rc.3'));
32702
32738
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32703
32739
  definitionMap.set('type', metadata.type);
32704
32740
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -32793,7 +32829,7 @@ function createDirectiveDefinitionMap(meta) {
32793
32829
  const definitionMap = new DefinitionMap();
32794
32830
  const minVersion = getMinimumVersionForPartialOutput(meta);
32795
32831
  definitionMap.set('minVersion', literal(minVersion));
32796
- definitionMap.set('version', literal('19.0.0-rc.1'));
32832
+ definitionMap.set('version', literal('19.0.0-rc.3'));
32797
32833
  // e.g. `type: MyDirective`
32798
32834
  definitionMap.set('type', meta.type.value);
32799
32835
  if (meta.isStandalone !== undefined) {
@@ -33212,7 +33248,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
33212
33248
  function compileDeclareFactoryFunction(meta) {
33213
33249
  const definitionMap = new DefinitionMap();
33214
33250
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
33215
- definitionMap.set('version', literal('19.0.0-rc.1'));
33251
+ definitionMap.set('version', literal('19.0.0-rc.3'));
33216
33252
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33217
33253
  definitionMap.set('type', meta.type.value);
33218
33254
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -33247,7 +33283,7 @@ function compileDeclareInjectableFromMetadata(meta) {
33247
33283
  function createInjectableDefinitionMap(meta) {
33248
33284
  const definitionMap = new DefinitionMap();
33249
33285
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
33250
- definitionMap.set('version', literal('19.0.0-rc.1'));
33286
+ definitionMap.set('version', literal('19.0.0-rc.3'));
33251
33287
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33252
33288
  definitionMap.set('type', meta.type.value);
33253
33289
  // Only generate providedIn property if it has a non-null value
@@ -33298,7 +33334,7 @@ function compileDeclareInjectorFromMetadata(meta) {
33298
33334
  function createInjectorDefinitionMap(meta) {
33299
33335
  const definitionMap = new DefinitionMap();
33300
33336
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
33301
- definitionMap.set('version', literal('19.0.0-rc.1'));
33337
+ definitionMap.set('version', literal('19.0.0-rc.3'));
33302
33338
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33303
33339
  definitionMap.set('type', meta.type.value);
33304
33340
  definitionMap.set('providers', meta.providers);
@@ -33331,7 +33367,7 @@ function createNgModuleDefinitionMap(meta) {
33331
33367
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
33332
33368
  }
33333
33369
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
33334
- definitionMap.set('version', literal('19.0.0-rc.1'));
33370
+ definitionMap.set('version', literal('19.0.0-rc.3'));
33335
33371
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33336
33372
  definitionMap.set('type', meta.type.value);
33337
33373
  // We only generate the keys in the metadata if the arrays contain values.
@@ -33382,7 +33418,7 @@ function compileDeclarePipeFromMetadata(meta) {
33382
33418
  function createPipeDefinitionMap(meta) {
33383
33419
  const definitionMap = new DefinitionMap();
33384
33420
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
33385
- definitionMap.set('version', literal('19.0.0-rc.1'));
33421
+ definitionMap.set('version', literal('19.0.0-rc.3'));
33386
33422
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33387
33423
  // e.g. `type: MyPipe`
33388
33424
  definitionMap.set('type', meta.type.value);