@angular-devkit/schematics 17.2.3 → 17.3.0-rc.0
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 +3 -3
- package/src/tree/recorder.d.ts +10 -11
- package/src/tree/recorder.js +49 -34
- package/src/utility/update-buffer.d.ts +0 -50
- package/src/utility/update-buffer.js +0 -90
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/schematics",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.3.0-rc.0",
|
|
4
4
|
"description": "Angular Schematics - Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"tooling"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@angular-devkit/core": "17.
|
|
21
|
+
"@angular-devkit/core": "17.3.0-rc.0",
|
|
22
22
|
"jsonc-parser": "3.2.1",
|
|
23
|
-
"magic-string": "0.30.
|
|
23
|
+
"magic-string": "0.30.8",
|
|
24
24
|
"ora": "5.4.1",
|
|
25
25
|
"rxjs": "7.8.1"
|
|
26
26
|
},
|
package/src/tree/recorder.d.ts
CHANGED
|
@@ -5,24 +5,23 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { BaseException } from '@angular-devkit/core';
|
|
9
|
+
import MagicString from 'magic-string';
|
|
9
10
|
import { FileEntry, UpdateRecorder } from './interface';
|
|
11
|
+
export declare class IndexOutOfBoundException extends BaseException {
|
|
12
|
+
constructor(index: number, min: number, max?: number);
|
|
13
|
+
}
|
|
10
14
|
export declare class UpdateRecorderBase implements UpdateRecorder {
|
|
15
|
+
private readonly data;
|
|
16
|
+
private readonly bom;
|
|
11
17
|
protected _path: string;
|
|
12
|
-
protected
|
|
13
|
-
|
|
14
|
-
constructor(entry: FileEntry);
|
|
18
|
+
protected content: MagicString;
|
|
19
|
+
constructor(data: Uint8Array, path: string, encoding?: string, bom?: boolean);
|
|
15
20
|
static createFromFileEntry(entry: FileEntry): UpdateRecorderBase;
|
|
16
21
|
get path(): string;
|
|
22
|
+
protected _assertIndex(index: number): void;
|
|
17
23
|
insertLeft(index: number, content: Buffer | string): UpdateRecorder;
|
|
18
24
|
insertRight(index: number, content: Buffer | string): UpdateRecorder;
|
|
19
25
|
remove(index: number, length: number): UpdateRecorder;
|
|
20
26
|
apply(content: Buffer): Buffer;
|
|
21
27
|
}
|
|
22
|
-
export declare class UpdateRecorderBom extends UpdateRecorderBase {
|
|
23
|
-
private _delta;
|
|
24
|
-
constructor(entry: FileEntry, _delta?: number);
|
|
25
|
-
insertLeft(index: number, content: Buffer | string): UpdateRecorder;
|
|
26
|
-
insertRight(index: number, content: Buffer | string): UpdateRecorder;
|
|
27
|
-
remove(index: number, length: number): UpdateRecorder;
|
|
28
|
-
}
|
package/src/tree/recorder.js
CHANGED
|
@@ -6,18 +6,40 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
13
|
+
exports.UpdateRecorderBase = exports.IndexOutOfBoundException = void 0;
|
|
14
|
+
const core_1 = require("@angular-devkit/core");
|
|
15
|
+
const magic_string_1 = __importDefault(require("magic-string"));
|
|
11
16
|
const exception_1 = require("../exception/exception");
|
|
12
|
-
|
|
17
|
+
class IndexOutOfBoundException extends core_1.BaseException {
|
|
18
|
+
constructor(index, min, max = Infinity) {
|
|
19
|
+
super(`Index ${index} outside of range [${min}, ${max}].`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.IndexOutOfBoundException = IndexOutOfBoundException;
|
|
13
23
|
class UpdateRecorderBase {
|
|
24
|
+
data;
|
|
25
|
+
bom;
|
|
14
26
|
_path;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
content;
|
|
28
|
+
constructor(data, path, encoding = 'utf-8', bom = false) {
|
|
29
|
+
this.data = data;
|
|
30
|
+
this.bom = bom;
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = new TextDecoder(encoding, { fatal: true, ignoreBOM: false }).decode(data);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if (e instanceof TypeError) {
|
|
37
|
+
throw new Error(`Failed to decode "${path}" as ${encoding} text.`);
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
this._path = path;
|
|
42
|
+
this.content = new magic_string_1.default(text);
|
|
21
43
|
}
|
|
22
44
|
static createFromFileEntry(entry) {
|
|
23
45
|
const c0 = entry.content.byteLength > 0 && entry.content.readUInt8(0);
|
|
@@ -25,54 +47,47 @@ class UpdateRecorderBase {
|
|
|
25
47
|
const c2 = entry.content.byteLength > 2 && entry.content.readUInt8(2);
|
|
26
48
|
// Check if we're BOM.
|
|
27
49
|
if (c0 == 0xef && c1 == 0xbb && c2 == 0xbf) {
|
|
28
|
-
return new
|
|
50
|
+
return new UpdateRecorderBase(entry.content, entry.path, 'utf-8', true);
|
|
29
51
|
}
|
|
30
52
|
else if (c0 === 0xff && c1 == 0xfe) {
|
|
31
|
-
return new
|
|
53
|
+
return new UpdateRecorderBase(entry.content, entry.path, 'utf-16le', true);
|
|
32
54
|
}
|
|
33
55
|
else if (c0 === 0xfe && c1 == 0xff) {
|
|
34
|
-
return new
|
|
56
|
+
return new UpdateRecorderBase(entry.content, entry.path, 'utf-16be', true);
|
|
35
57
|
}
|
|
36
|
-
return new UpdateRecorderBase(entry);
|
|
58
|
+
return new UpdateRecorderBase(entry.content, entry.path);
|
|
37
59
|
}
|
|
38
60
|
get path() {
|
|
39
61
|
return this._path;
|
|
40
62
|
}
|
|
63
|
+
_assertIndex(index) {
|
|
64
|
+
if (index < 0 || index > this.content.original.length) {
|
|
65
|
+
throw new IndexOutOfBoundException(index, 0, this.content.original.length);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
41
68
|
// These just record changes.
|
|
42
69
|
insertLeft(index, content) {
|
|
43
|
-
this.
|
|
70
|
+
this._assertIndex(index);
|
|
71
|
+
this.content.appendLeft(index, content.toString());
|
|
44
72
|
return this;
|
|
45
73
|
}
|
|
46
74
|
insertRight(index, content) {
|
|
47
|
-
this.
|
|
75
|
+
this._assertIndex(index);
|
|
76
|
+
this.content.appendRight(index, content.toString());
|
|
48
77
|
return this;
|
|
49
78
|
}
|
|
50
79
|
remove(index, length) {
|
|
51
|
-
this.
|
|
80
|
+
this._assertIndex(index);
|
|
81
|
+
this.content.remove(index, index + length);
|
|
52
82
|
return this;
|
|
53
83
|
}
|
|
54
84
|
apply(content) {
|
|
55
|
-
if (!content.equals(this.
|
|
85
|
+
if (!content.equals(this.data)) {
|
|
56
86
|
throw new exception_1.ContentHasMutatedException(this.path);
|
|
57
87
|
}
|
|
58
|
-
|
|
88
|
+
// Schematics only support writing UTF-8 text
|
|
89
|
+
const result = Buffer.from((this.bom ? '\uFEFF' : '') + this.content.toString(), 'utf-8');
|
|
90
|
+
return result;
|
|
59
91
|
}
|
|
60
92
|
}
|
|
61
93
|
exports.UpdateRecorderBase = UpdateRecorderBase;
|
|
62
|
-
class UpdateRecorderBom extends UpdateRecorderBase {
|
|
63
|
-
_delta;
|
|
64
|
-
constructor(entry, _delta = 1) {
|
|
65
|
-
super(entry);
|
|
66
|
-
this._delta = _delta;
|
|
67
|
-
}
|
|
68
|
-
insertLeft(index, content) {
|
|
69
|
-
return super.insertLeft(index + this._delta, content);
|
|
70
|
-
}
|
|
71
|
-
insertRight(index, content) {
|
|
72
|
-
return super.insertRight(index + this._delta, content);
|
|
73
|
-
}
|
|
74
|
-
remove(index, length) {
|
|
75
|
-
return super.remove(index + this._delta, length);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.UpdateRecorderBom = UpdateRecorderBom;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BaseException } from '@angular-devkit/core';
|
|
9
|
-
import MagicString from 'magic-string';
|
|
10
|
-
export declare class IndexOutOfBoundException extends BaseException {
|
|
11
|
-
constructor(index: number, min: number, max?: number);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Base class for an update buffer implementation that allows buffers to be inserted to the _right
|
|
15
|
-
* or _left, or deleted, while keeping indices to the original buffer.
|
|
16
|
-
*/
|
|
17
|
-
export declare abstract class UpdateBufferBase {
|
|
18
|
-
protected _originalContent: Buffer;
|
|
19
|
-
constructor(_originalContent: Buffer);
|
|
20
|
-
abstract get length(): number;
|
|
21
|
-
abstract get original(): Buffer;
|
|
22
|
-
abstract toString(encoding?: string): string;
|
|
23
|
-
abstract generate(): Buffer;
|
|
24
|
-
abstract insertLeft(index: number, content: Buffer, assert?: boolean): void;
|
|
25
|
-
abstract insertRight(index: number, content: Buffer, assert?: boolean): void;
|
|
26
|
-
abstract remove(index: number, length: number): void;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an UpdateBufferBase instance.
|
|
29
|
-
*
|
|
30
|
-
* @param contentPath The path of the update buffer instance.
|
|
31
|
-
* @param originalContent The original content of the update buffer instance.
|
|
32
|
-
* @returns An UpdateBufferBase instance.
|
|
33
|
-
*/
|
|
34
|
-
static create(contentPath: string, originalContent: Buffer): UpdateBufferBase;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* An utility class that allows buffers to be inserted to the _right or _left, or deleted, while
|
|
38
|
-
* keeping indices to the original buffer.
|
|
39
|
-
*/
|
|
40
|
-
export declare class UpdateBuffer extends UpdateBufferBase {
|
|
41
|
-
protected _mutatableContent: MagicString;
|
|
42
|
-
protected _assertIndex(index: number): void;
|
|
43
|
-
get length(): number;
|
|
44
|
-
get original(): Buffer;
|
|
45
|
-
toString(): string;
|
|
46
|
-
generate(): Buffer;
|
|
47
|
-
insertLeft(index: number, content: Buffer): void;
|
|
48
|
-
insertRight(index: number, content: Buffer): void;
|
|
49
|
-
remove(index: number, length: number): void;
|
|
50
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UpdateBuffer = exports.UpdateBufferBase = exports.IndexOutOfBoundException = void 0;
|
|
14
|
-
const core_1 = require("@angular-devkit/core");
|
|
15
|
-
const magic_string_1 = __importDefault(require("magic-string"));
|
|
16
|
-
const node_util_1 = require("node:util");
|
|
17
|
-
class IndexOutOfBoundException extends core_1.BaseException {
|
|
18
|
-
constructor(index, min, max = Infinity) {
|
|
19
|
-
super(`Index ${index} outside of range [${min}, ${max}].`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.IndexOutOfBoundException = IndexOutOfBoundException;
|
|
23
|
-
/**
|
|
24
|
-
* Base class for an update buffer implementation that allows buffers to be inserted to the _right
|
|
25
|
-
* or _left, or deleted, while keeping indices to the original buffer.
|
|
26
|
-
*/
|
|
27
|
-
class UpdateBufferBase {
|
|
28
|
-
_originalContent;
|
|
29
|
-
constructor(_originalContent) {
|
|
30
|
-
this._originalContent = _originalContent;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates an UpdateBufferBase instance.
|
|
34
|
-
*
|
|
35
|
-
* @param contentPath The path of the update buffer instance.
|
|
36
|
-
* @param originalContent The original content of the update buffer instance.
|
|
37
|
-
* @returns An UpdateBufferBase instance.
|
|
38
|
-
*/
|
|
39
|
-
static create(contentPath, originalContent) {
|
|
40
|
-
try {
|
|
41
|
-
// We only support utf8 encoding.
|
|
42
|
-
new node_util_1.TextDecoder('utf8', { fatal: true }).decode(originalContent);
|
|
43
|
-
return new UpdateBuffer(originalContent);
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
if (e instanceof TypeError) {
|
|
47
|
-
throw new Error(`Failed to decode "${contentPath}" as UTF-8 text.`);
|
|
48
|
-
}
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.UpdateBufferBase = UpdateBufferBase;
|
|
54
|
-
/**
|
|
55
|
-
* An utility class that allows buffers to be inserted to the _right or _left, or deleted, while
|
|
56
|
-
* keeping indices to the original buffer.
|
|
57
|
-
*/
|
|
58
|
-
class UpdateBuffer extends UpdateBufferBase {
|
|
59
|
-
_mutatableContent = new magic_string_1.default(this._originalContent.toString());
|
|
60
|
-
_assertIndex(index) {
|
|
61
|
-
if (index < 0 || index > this._originalContent.length) {
|
|
62
|
-
throw new IndexOutOfBoundException(index, 0, this._originalContent.length);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
get length() {
|
|
66
|
-
return this._mutatableContent.length();
|
|
67
|
-
}
|
|
68
|
-
get original() {
|
|
69
|
-
return this._originalContent;
|
|
70
|
-
}
|
|
71
|
-
toString() {
|
|
72
|
-
return this._mutatableContent.toString();
|
|
73
|
-
}
|
|
74
|
-
generate() {
|
|
75
|
-
return Buffer.from(this.toString());
|
|
76
|
-
}
|
|
77
|
-
insertLeft(index, content) {
|
|
78
|
-
this._assertIndex(index);
|
|
79
|
-
this._mutatableContent.appendLeft(index, content.toString());
|
|
80
|
-
}
|
|
81
|
-
insertRight(index, content) {
|
|
82
|
-
this._assertIndex(index);
|
|
83
|
-
this._mutatableContent.appendRight(index, content.toString());
|
|
84
|
-
}
|
|
85
|
-
remove(index, length) {
|
|
86
|
-
this._assertIndex(index);
|
|
87
|
-
this._mutatableContent.remove(index, index + length);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.UpdateBuffer = UpdateBuffer;
|