@angular/pwa 17.1.0-next.2 → 17.1.0-next.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/pwa/index.js +7 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/pwa",
3
- "version": "17.1.0-next.2",
3
+ "version": "17.1.0-next.3",
4
4
  "description": "PWA schematics for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -17,8 +17,8 @@
17
17
  "save": false
18
18
  },
19
19
  "dependencies": {
20
- "@angular-devkit/schematics": "17.1.0-next.2",
21
- "@schematics/angular": "17.1.0-next.2",
20
+ "@angular-devkit/schematics": "17.1.0-next.3",
21
+ "@schematics/angular": "17.1.0-next.3",
22
22
  "parse5-html-rewriting-stream": "7.0.0"
23
23
  },
24
24
  "peerDependencies": {
package/pwa/index.js CHANGED
@@ -11,12 +11,10 @@ const schematics_1 = require("@angular-devkit/schematics");
11
11
  const utility_1 = require("@schematics/angular/utility");
12
12
  const path_1 = require("path");
13
13
  const stream_1 = require("stream");
14
+ const promises_1 = require("stream/promises");
14
15
  function updateIndexFile(path) {
15
16
  return async (host) => {
16
- const buffer = host.read(path);
17
- if (buffer === null) {
18
- throw new schematics_1.SchematicsException(`Could not read index file: ${path}`);
19
- }
17
+ const originalContent = host.readText(path);
20
18
  const { RewritingStream } = await loadEsmModule('parse5-html-rewriting-stream');
21
19
  const rewriter = new RewritingStream();
22
20
  let needsNoScript = true;
@@ -36,28 +34,12 @@ function updateIndexFile(path) {
36
34
  }
37
35
  rewriter.emitEndTag(endTag);
38
36
  });
39
- return new Promise((resolve) => {
40
- const input = new stream_1.Readable({
41
- encoding: 'utf8',
42
- read() {
43
- this.push(buffer);
44
- this.push(null);
45
- },
46
- });
37
+ return (0, promises_1.pipeline)(stream_1.Readable.from(originalContent), rewriter, async function (source) {
47
38
  const chunks = [];
48
- const output = new stream_1.Writable({
49
- write(chunk, encoding, callback) {
50
- chunks.push(typeof chunk === 'string' ? Buffer.from(chunk, encoding) : chunk);
51
- callback();
52
- },
53
- final(callback) {
54
- const full = Buffer.concat(chunks);
55
- host.overwrite(path, full.toString());
56
- callback();
57
- resolve();
58
- },
59
- });
60
- input.pipe(rewriter).pipe(output);
39
+ for await (const chunk of source) {
40
+ chunks.push(Buffer.from(chunk));
41
+ }
42
+ host.overwrite(path, Buffer.concat(chunks));
61
43
  });
62
44
  };
63
45
  }