@angular/ssr 22.1.0-next.3 → 22.1.0-next.4

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": "22.1.0-next.3",
3
+ "version": "22.1.0-next.4",
4
4
  "description": "Angular server side rendering utilities",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -37,12 +37,12 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@angular-devkit/schematics": "workspace:*",
40
- "@angular/common": "22.1.0-next.3",
41
- "@angular/compiler": "22.1.0-next.3",
42
- "@angular/core": "22.1.0-next.3",
43
- "@angular/platform-browser": "22.1.0-next.3",
44
- "@angular/platform-server": "22.1.0-next.3",
45
- "@angular/router": "22.1.0-next.3",
40
+ "@angular/common": "22.1.0-next.5",
41
+ "@angular/compiler": "22.1.0-next.5",
42
+ "@angular/core": "22.1.0-next.5",
43
+ "@angular/platform-browser": "22.1.0-next.5",
44
+ "@angular/platform-server": "22.1.0-next.5",
45
+ "@angular/router": "22.1.0-next.5",
46
46
  "@schematics/angular": "workspace:*",
47
47
  "beasties": "0.4.2"
48
48
  },
@@ -1087,7 +1087,10 @@ function requireNode$1 () {
1087
1087
  if (name === 'nodes') {
1088
1088
  this.nodes = [];
1089
1089
  for (let node of defaults[name]) {
1090
- if (typeof node.clone === 'function') {
1090
+ // Clone only nodes that already belong to another tree, so passing a
1091
+ // freshly created (parent-less) node adopts that instance instead of
1092
+ // a copy and keeps the caller's reference usable. See #1987.
1093
+ if (typeof node.clone === 'function' && node.parent) {
1091
1094
  this.append(node.clone());
1092
1095
  } else {
1093
1096
  this.append(node);
@@ -1220,14 +1223,18 @@ function requireNode$1 () {
1220
1223
  }
1221
1224
 
1222
1225
  positionBy(opts = {}) {
1223
- let pos = this.source.start;
1226
+ let inputString =
1227
+ 'document' in this.source.input
1228
+ ? this.source.input.document
1229
+ : this.source.input.css;
1230
+ let pos = {
1231
+ column: this.source.start.column,
1232
+ line: this.source.start.line,
1233
+ offset: sourceOffset(inputString, this.source.start)
1234
+ };
1224
1235
  if (opts.index) {
1225
1236
  pos = this.positionInside(opts.index);
1226
1237
  } else if (opts.word) {
1227
- let inputString =
1228
- 'document' in this.source.input
1229
- ? this.source.input.document
1230
- : this.source.input.css;
1231
1238
  let stringRepresentation = inputString.slice(
1232
1239
  sourceOffset(inputString, this.source.start),
1233
1240
  sourceOffset(inputString, this.source.end)
@@ -1312,7 +1319,7 @@ function requireNode$1 () {
1312
1319
  line: opts.start.line,
1313
1320
  offset: sourceOffset(inputString, opts.start)
1314
1321
  };
1315
- } else if (opts.index) {
1322
+ } else if (typeof opts.index === 'number') {
1316
1323
  start = this.positionInside(opts.index);
1317
1324
  }
1318
1325
 
@@ -1324,7 +1331,7 @@ function requireNode$1 () {
1324
1331
  };
1325
1332
  } else if (typeof opts.endIndex === 'number') {
1326
1333
  end = this.positionInside(opts.endIndex);
1327
- } else if (opts.index) {
1334
+ } else if (typeof opts.index === 'number') {
1328
1335
  end = this.positionInside(opts.index + 1);
1329
1336
  }
1330
1337
  }
@@ -2059,7 +2066,7 @@ function requireNonSecure () {
2059
2066
  return (size = defaultSize) => {
2060
2067
  let id = '';
2061
2068
  let i = size | 0;
2062
- while (i--) {
2069
+ while (i-- > 0) {
2063
2070
  id += alphabet[(Math.random() * alphabet.length) | 0];
2064
2071
  }
2065
2072
  return id
@@ -2069,7 +2076,7 @@ function requireNonSecure () {
2069
2076
  let nanoid = (size = 21) => {
2070
2077
  let id = '';
2071
2078
  let i = size | 0;
2072
- while (i--) {
2079
+ while (i-- > 0) {
2073
2080
  id += urlAlphabet[(Math.random() * 64) | 0];
2074
2081
  }
2075
2082
  return id
@@ -2461,12 +2468,15 @@ function requireInput () {
2461
2468
  if (!this.map) return false
2462
2469
  let consumer = this.map.consumer();
2463
2470
 
2464
- let from = consumer.originalPositionFor({ column, line });
2471
+ let from = consumer.originalPositionFor({ column: column - 1, line });
2465
2472
  if (!from.source) return false
2466
2473
 
2467
2474
  let to;
2468
2475
  if (typeof endLine === 'number') {
2469
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
2476
+ to = consumer.originalPositionFor({
2477
+ column: endColumn - 1,
2478
+ line: endLine
2479
+ });
2470
2480
  }
2471
2481
 
2472
2482
  let fromUrl;
@@ -2481,8 +2491,8 @@ function requireInput () {
2481
2491
  }
2482
2492
 
2483
2493
  let result = {
2484
- column: from.column,
2485
- endColumn: to && to.column,
2494
+ column: from.column + 1,
2495
+ endColumn: to && to.column + 1,
2486
2496
  endLine: to && to.line,
2487
2497
  line: from.line,
2488
2498
  url: fromUrl.toString()
@@ -2731,8 +2741,13 @@ function requireFromJSON () {
2731
2741
  inputs.push(inputHydrated);
2732
2742
  }
2733
2743
  }
2744
+ // Rehydrate children separately and attach them after construction.
2745
+ // Passing them through the container constructor would re-run insertion
2746
+ // spacing normalization and overwrite each child's own `raws.before`.
2747
+ let nodes;
2734
2748
  if (defaults.nodes) {
2735
- defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
2749
+ nodes = json.nodes.map(n => fromJSON(n, inputs));
2750
+ delete defaults.nodes;
2736
2751
  }
2737
2752
  if (defaults.source) {
2738
2753
  let { inputId, ...source } = defaults.source;
@@ -2741,19 +2756,28 @@ function requireFromJSON () {
2741
2756
  defaults.source.input = inputs[inputId];
2742
2757
  }
2743
2758
  }
2759
+
2760
+ let node;
2744
2761
  if (defaults.type === 'root') {
2745
- return new Root(defaults)
2762
+ node = new Root(defaults);
2746
2763
  } else if (defaults.type === 'decl') {
2747
- return new Declaration(defaults)
2764
+ node = new Declaration(defaults);
2748
2765
  } else if (defaults.type === 'rule') {
2749
- return new Rule(defaults)
2766
+ node = new Rule(defaults);
2750
2767
  } else if (defaults.type === 'comment') {
2751
- return new Comment(defaults)
2768
+ node = new Comment(defaults);
2752
2769
  } else if (defaults.type === 'atrule') {
2753
- return new AtRule(defaults)
2770
+ node = new AtRule(defaults);
2754
2771
  } else {
2755
2772
  throw new Error('Unknown node type: ' + json.type)
2756
2773
  }
2774
+
2775
+ if (nodes) {
2776
+ node.nodes = nodes;
2777
+ for (let child of nodes) child.parent = node;
2778
+ }
2779
+
2780
+ return node
2757
2781
  }
2758
2782
 
2759
2783
  fromJSON_1 = fromJSON;
@@ -4946,7 +4970,7 @@ function requireProcessor () {
4946
4970
 
4947
4971
  class Processor {
4948
4972
  constructor(plugins = []) {
4949
- this.version = '8.5.15';
4973
+ this.version = '8.5.16';
4950
4974
  this.plugins = this.normalize(plugins);
4951
4975
  }
4952
4976