@angular/ssr 21.2.7 → 21.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/ssr",
3
- "version": "21.2.7",
3
+ "version": "21.2.9",
4
4
  "description": "Angular server side rendering utilities",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,12 +29,12 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@angular-devkit/schematics": "workspace:*",
32
- "@angular/common": "21.2.7",
33
- "@angular/compiler": "21.2.7",
34
- "@angular/core": "21.2.7",
35
- "@angular/platform-browser": "21.2.7",
36
- "@angular/platform-server": "21.2.7",
37
- "@angular/router": "21.2.7",
32
+ "@angular/common": "21.2.10",
33
+ "@angular/compiler": "21.2.10",
34
+ "@angular/core": "21.2.10",
35
+ "@angular/platform-browser": "21.2.10",
36
+ "@angular/platform-server": "21.2.10",
37
+ "@angular/router": "21.2.10",
38
38
  "@schematics/angular": "workspace:*",
39
39
  "beasties": "0.4.1"
40
40
  },
@@ -449,7 +449,7 @@ License: MIT
449
449
 
450
450
  The MIT License (MIT)
451
451
 
452
- Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
452
+ Copyright 2013 Andrey Sitnik <andrey@sitnik.es>
453
453
 
454
454
  Permission is hereby granted, free of charge, to any person obtaining a copy of
455
455
  this software and associated documentation files (the "Software"), to deal in
@@ -599,6 +599,18 @@ function requireStringifier () {
599
599
  if (hasRequiredStringifier) return stringifier;
600
600
  hasRequiredStringifier = 1;
601
601
 
602
+ // Escapes sequences that could break out of an HTML <style> context.
603
+ // Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
604
+ // correctly by all compliant CSS consumers.
605
+ const STYLE_TAG = /(<)(\/?style\b)/gi;
606
+ const COMMENT_OPEN = /(<)(!--)/g;
607
+
608
+ function escapeHTMLInCSS(str) {
609
+ if (typeof str !== 'string') return str
610
+ if (!str.includes('<')) return str
611
+ return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
612
+ }
613
+
602
614
  const DEFAULT_RAW = {
603
615
  after: '\n',
604
616
  beforeClose: '\n',
@@ -624,11 +636,12 @@ function requireStringifier () {
624
636
  }
625
637
 
626
638
  atrule(node, semicolon) {
639
+ let raws = node.raws;
627
640
  let name = '@' + node.name;
628
641
  let params = node.params ? this.rawValue(node, 'params') : '';
629
642
 
630
- if (typeof node.raws.afterName !== 'undefined') {
631
- name += node.raws.afterName;
643
+ if (typeof raws.afterName !== 'undefined') {
644
+ name += raws.afterName;
632
645
  } else if (params) {
633
646
  name += ' ';
634
647
  }
@@ -636,8 +649,8 @@ function requireStringifier () {
636
649
  if (node.nodes) {
637
650
  this.block(node, name + params);
638
651
  } else {
639
- let end = (node.raws.between || '') + (semicolon ? ';' : '');
640
- this.builder(name + params + end, node);
652
+ let end = (raws.between || '') + (semicolon ? ';' : '');
653
+ this.builder(escapeHTMLInCSS(name + params + end), node);
641
654
  }
642
655
  }
643
656
 
@@ -671,53 +684,77 @@ function requireStringifier () {
671
684
  }
672
685
 
673
686
  block(node, start) {
674
- let between = this.raw(node, 'between', 'beforeOpen');
675
- this.builder(start + between + '{', node, 'start');
687
+ let raws = node.raws;
688
+ let between = typeof raws.between !== 'undefined'
689
+ ? raws.between
690
+ : this.raw(node, 'between', 'beforeOpen');
691
+ this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start');
676
692
 
677
693
  let after;
678
694
  if (node.nodes && node.nodes.length) {
679
695
  this.body(node);
680
- after = this.raw(node, 'after');
696
+ after = typeof raws.after !== 'undefined'
697
+ ? raws.after
698
+ : this.raw(node, 'after');
681
699
  } else {
682
- after = this.raw(node, 'after', 'emptyBody');
700
+ after = typeof raws.after !== 'undefined'
701
+ ? raws.after
702
+ : this.raw(node, 'after', 'emptyBody');
683
703
  }
684
704
 
685
- if (after) this.builder(after);
705
+ if (after) this.builder(escapeHTMLInCSS(after));
686
706
  this.builder('}', node, 'end');
687
707
  }
688
708
 
689
709
  body(node) {
690
- let last = node.nodes.length - 1;
710
+ let nodes = node.nodes;
711
+ let last = nodes.length - 1;
691
712
  while (last > 0) {
692
- if (node.nodes[last].type !== 'comment') break
713
+ if (nodes[last].type !== 'comment') break
693
714
  last -= 1;
694
715
  }
695
716
 
696
717
  let semicolon = this.raw(node, 'semicolon');
697
- for (let i = 0; i < node.nodes.length; i++) {
698
- let child = node.nodes[i];
699
- let before = this.raw(child, 'before');
700
- if (before) this.builder(before);
718
+ let isDocument = node.type === 'document';
719
+ for (let i = 0; i < nodes.length; i++) {
720
+ let child = nodes[i];
721
+ let before = child.raws.before;
722
+ if (typeof before === 'undefined') {
723
+ before = this.raw(child, 'before');
724
+ }
725
+ if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before));
701
726
  this.stringify(child, last !== i || semicolon);
702
727
  }
703
728
  }
704
729
 
705
730
  comment(node) {
706
- let left = this.raw(node, 'left', 'commentLeft');
707
- let right = this.raw(node, 'right', 'commentRight');
708
- this.builder('/*' + left + node.text + right + '*/', node);
731
+ let raws = node.raws;
732
+ let left = typeof raws.left !== 'undefined'
733
+ ? raws.left
734
+ : this.raw(node, 'left', 'commentLeft');
735
+ let right = typeof raws.right !== 'undefined'
736
+ ? raws.right
737
+ : this.raw(node, 'right', 'commentRight');
738
+ this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node);
709
739
  }
710
740
 
711
741
  decl(node, semicolon) {
712
- let between = this.raw(node, 'between', 'colon');
713
- let string = node.prop + between + this.rawValue(node, 'value');
742
+ let raws = node.raws;
743
+ let between = typeof raws.between !== 'undefined'
744
+ ? raws.between
745
+ : this.raw(node, 'between', 'colon');
746
+
747
+ let rawVal = raws.value;
748
+ let value = rawVal && rawVal.value === node.value ? rawVal.raw : node.value;
749
+
750
+ let string = node.prop + between + value;
714
751
 
715
752
  if (node.important) {
716
- string += node.raws.important || ' !important';
753
+ string += raws.important || ' !important';
717
754
  }
718
755
 
719
756
  if (semicolon) string += ';';
720
- this.builder(string, node);
757
+ this.builder(escapeHTMLInCSS(string), node);
721
758
  }
722
759
 
723
760
  document(node) {
@@ -753,9 +790,9 @@ function requireStringifier () {
753
790
 
754
791
  // Detect style by other nodes
755
792
  let root = node.root();
756
- if (!root.rawCache) root.rawCache = {};
757
- if (typeof root.rawCache[detect] !== 'undefined') {
758
- return root.rawCache[detect]
793
+ let cache = root.rawCache || (root.rawCache = {});
794
+ if (typeof cache[detect] !== 'undefined') {
795
+ return cache[detect]
759
796
  }
760
797
 
761
798
  if (detect === 'before' || detect === 'after') {
@@ -774,7 +811,7 @@ function requireStringifier () {
774
811
 
775
812
  if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
776
813
 
777
- root.rawCache[detect] = value;
814
+ cache[detect] = value;
778
815
  return value
779
816
  }
780
817
 
@@ -923,13 +960,17 @@ function requireStringifier () {
923
960
 
924
961
  root(node) {
925
962
  this.body(node);
926
- if (node.raws.after) this.builder(node.raws.after);
963
+ if (node.raws.after) {
964
+ let after = node.raws.after;
965
+ let isDocument = node.parent && node.parent.type === 'document';
966
+ this.builder(isDocument ? after : escapeHTMLInCSS(after));
967
+ }
927
968
  }
928
969
 
929
970
  rule(node) {
930
971
  this.block(node, this.rawValue(node, 'selector'));
931
972
  if (node.raws.ownSemicolon) {
932
- this.builder(node.raws.ownSemicolon, node, 'end');
973
+ this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end');
933
974
  }
934
975
  }
935
976
 
@@ -2091,6 +2132,7 @@ function requirePreviousMap () {
2091
2132
  class PreviousMap {
2092
2133
  constructor(css, opts) {
2093
2134
  if (opts.map === false) return
2135
+ if (opts.unsafeMap) this.unsafeMap = true;
2094
2136
  this.loadAnnotation(css);
2095
2137
  this.inline = this.startWith(this.annotation, 'data:');
2096
2138
 
@@ -2105,7 +2147,7 @@ function requirePreviousMap () {
2105
2147
 
2106
2148
  consumer() {
2107
2149
  if (!this.consumerCache) {
2108
- this.consumerCache = new SourceMapConsumer(this.text);
2150
+ this.consumerCache = new SourceMapConsumer(this.json || this.text);
2109
2151
  }
2110
2152
  return this.consumerCache
2111
2153
  }
@@ -2126,7 +2168,8 @@ function requirePreviousMap () {
2126
2168
  return fromBase64(text.substr(baseUriMatch[0].length))
2127
2169
  }
2128
2170
 
2129
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
2171
+ let encoding = text.slice('data:application/json;'.length);
2172
+ encoding = encoding.slice(0, encoding.indexOf(','));
2130
2173
  throw new Error('Unsupported source map encoding ' + encoding)
2131
2174
  }
2132
2175
 
@@ -2157,7 +2200,13 @@ function requirePreviousMap () {
2157
2200
  }
2158
2201
  }
2159
2202
 
2160
- loadFile(path) {
2203
+ loadFile(path, cssFile, trusted) {
2204
+ /* c8 ignore next 5 */
2205
+ if (!trusted && !this.unsafeMap) {
2206
+ if (!/\.map$/i.test(path)) {
2207
+ return undefined
2208
+ }
2209
+ }
2161
2210
  this.root = dirname(path);
2162
2211
  if (existsSync(path)) {
2163
2212
  this.mapFile = path;
@@ -2174,7 +2223,7 @@ function requirePreviousMap () {
2174
2223
  } else if (typeof prev === 'function') {
2175
2224
  let prevPath = prev(file);
2176
2225
  if (prevPath) {
2177
- let map = this.loadFile(prevPath);
2226
+ let map = this.loadFile(prevPath, file, true);
2178
2227
  if (!map) {
2179
2228
  throw new Error(
2180
2229
  'Unable to load previous source map: ' + prevPath.toString()
@@ -2198,7 +2247,16 @@ function requirePreviousMap () {
2198
2247
  } else if (this.annotation) {
2199
2248
  let map = this.annotation;
2200
2249
  if (file) map = join(dirname(file), map);
2201
- return this.loadFile(map)
2250
+ let unknown = this.loadFile(map, file, false);
2251
+ if (unknown) {
2252
+ try {
2253
+ /* c8 ignore next 4 */
2254
+ this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ''));
2255
+ } catch {
2256
+ return undefined
2257
+ }
2258
+ }
2259
+ return unknown
2202
2260
  }
2203
2261
  }
2204
2262
 
@@ -2369,7 +2427,15 @@ function requireInput () {
2369
2427
  );
2370
2428
  }
2371
2429
 
2372
- result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
2430
+ result.input = {
2431
+ column,
2432
+ endColumn,
2433
+ endLine,
2434
+ endOffset,
2435
+ line,
2436
+ offset,
2437
+ source: this.css
2438
+ };
2373
2439
  if (this.file) {
2374
2440
  if (pathToFileURL) {
2375
2441
  result.input.url = pathToFileURL(this.file).toString();
@@ -2807,7 +2873,15 @@ function requireMapGenerator () {
2807
2873
  }
2808
2874
  }
2809
2875
  } else if (this.css) {
2810
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
2876
+ let startIndex;
2877
+ while ((startIndex = this.css.lastIndexOf('/*#')) !== -1) {
2878
+ let endIndex = this.css.indexOf('*/', startIndex + 3);
2879
+ if (endIndex === -1) break
2880
+ while (startIndex > 0 && this.css[startIndex - 1] === '\n') {
2881
+ startIndex--;
2882
+ }
2883
+ this.css = this.css.slice(0, startIndex) + this.css.slice(endIndex + 2);
2884
+ }
2811
2885
  }
2812
2886
  }
2813
2887
 
@@ -3144,6 +3218,7 @@ function requireTokenize () {
3144
3218
  let pos = 0;
3145
3219
  let buffer = [];
3146
3220
  let returned = [];
3221
+ let lastBadParen = -1;
3147
3222
 
3148
3223
  function position() {
3149
3224
  return pos
@@ -3235,11 +3310,14 @@ function requireTokenize () {
3235
3310
  currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
3236
3311
 
3237
3312
  pos = next;
3313
+ } else if (pos <= lastBadParen) {
3314
+ currentToken = ['(', '(', pos];
3238
3315
  } else {
3239
3316
  next = css.indexOf(')', pos + 1);
3240
3317
  content = css.slice(pos, next + 1);
3241
3318
 
3242
3319
  if (next === -1 || RE_BAD_BRACKET.test(content)) {
3320
+ lastBadParen = next === -1 ? length : next;
3243
3321
  currentToken = ['(', '(', pos];
3244
3322
  } else {
3245
3323
  currentToken = ['brackets', content, pos, next];
@@ -3558,7 +3636,7 @@ function requireParser () {
3558
3636
  node.source.end.offset++;
3559
3637
 
3560
3638
  let text = token[1].slice(2, -2);
3561
- if (/^\s*$/.test(text)) {
3639
+ if (!text.trim()) {
3562
3640
  node.text = '';
3563
3641
  node.raws.left = text;
3564
3642
  node.raws.right = '';
@@ -4546,6 +4624,16 @@ function requireLazyResult () {
4546
4624
  if (opts.stringifier) str = opts.stringifier;
4547
4625
  if (str.stringify) str = str.stringify;
4548
4626
 
4627
+ let rootSource = this.result.root.source;
4628
+ if (opts.map === undefined && !(rootSource && rootSource.input && rootSource.input.map)) {
4629
+ let result = '';
4630
+ str(this.result.root, i => {
4631
+ result += i;
4632
+ });
4633
+ this.result.css = result;
4634
+ return this.result
4635
+ }
4636
+
4549
4637
  let map = new MapGenerator(str, this.result.root, this.result.opts);
4550
4638
  let data = map.generate();
4551
4639
  this.result.css = data[0];
@@ -4728,7 +4816,7 @@ function requireNoWorkResult () {
4728
4816
 
4729
4817
  let MapGenerator = requireMapGenerator();
4730
4818
  let parse = requireParse();
4731
- const Result = requireResult();
4819
+ let Result = requireResult();
4732
4820
  let stringify = requireStringify();
4733
4821
  let warnOnce = requireWarnOnce();
4734
4822
 
@@ -4791,10 +4879,9 @@ function requireNoWorkResult () {
4791
4879
  this._css = css;
4792
4880
  this._opts = opts;
4793
4881
  this._map = undefined;
4794
- let root;
4795
4882
 
4796
4883
  let str = stringify;
4797
- this.result = new Result(this._processor, root, this._opts);
4884
+ this.result = new Result(this._processor, undefined, this._opts);
4798
4885
  this.result.css = css;
4799
4886
 
4800
4887
  let self = this;
@@ -4804,7 +4891,7 @@ function requireNoWorkResult () {
4804
4891
  }
4805
4892
  });
4806
4893
 
4807
- let map = new MapGenerator(str, root, this._opts, css);
4894
+ let map = new MapGenerator(str, undefined, this._opts, css);
4808
4895
  if (map.isMap()) {
4809
4896
  let [generatedCSS, generatedMap] = map.generate();
4810
4897
  if (generatedCSS) {
@@ -4879,7 +4966,7 @@ function requireProcessor () {
4879
4966
 
4880
4967
  class Processor {
4881
4968
  constructor(plugins = []) {
4882
- this.version = '8.5.6';
4969
+ this.version = '8.5.12';
4883
4970
  this.plugins = this.normalize(plugins);
4884
4971
  }
4885
4972