Skip to content

Commit d722fdf

Browse files
alan-agius4clydin
authored andcommitted
refactor(@angular-devkit/core): remove deprecated JSON parser
BREAKING CHANGE: The deprecated JSON parser has been removed from public API. [jsonc-parser](https://www.npmjs.com/package/jsonc-parser) should be used instead.
1 parent 9eb599d commit d722fdf

File tree

19 files changed

+61
-288
lines changed

19 files changed

+61
-288
lines changed

goldens/public-api/angular_devkit/core/src/index.md

Lines changed: 6 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
1010
import { Observer } from 'rxjs';
1111
import { Operator } from 'rxjs';
1212
import { PartialObserver } from 'rxjs';
13-
import { Position as Position_2 } from 'source-map';
13+
import { Position } from 'source-map';
1414
import { Subject } from 'rxjs';
1515
import { SubscribableOrPromise } from 'rxjs';
1616
import { Subscription } from 'rxjs';
@@ -530,19 +530,6 @@ class IndentLogger extends Logger {
530530
constructor(name: string, parent?: Logger | null, indentation?: string);
531531
}
532532

533-
// @public @deprecated
534-
export class InvalidJsonCharacterException extends JsonException {
535-
constructor(context: JsonParserContext);
536-
// (undocumented)
537-
character: number;
538-
// (undocumented)
539-
invalidChar: string;
540-
// (undocumented)
541-
line: number;
542-
// (undocumented)
543-
offset: number;
544-
}
545-
546533
// @public (undocumented)
547534
export class InvalidPathException extends BaseException {
548535
constructor(path: string);
@@ -855,201 +842,23 @@ declare namespace json {
855842
schema,
856843
isJsonObject,
857844
isJsonArray,
858-
Position,
859-
JsonAstNode,
860-
JsonAstNodeBase,
861-
JsonAstNumber,
862-
JsonAstString,
863-
JsonAstIdentifier,
864845
JsonArray,
865-
JsonAstArray,
866846
JsonObject,
867-
JsonAstKeyValue,
868-
JsonAstObject,
869-
JsonAstConstantFalse,
870-
JsonAstConstantNull,
871-
JsonAstConstantTrue,
872-
JsonAstMultilineComment,
873-
JsonAstComment,
874-
JsonValue,
875-
parseJsonAst,
876-
parseJson,
877-
JsonException,
878-
InvalidJsonCharacterException,
879-
UnexpectedEndOfInputException,
880-
PathSpecificJsonException,
881-
JsonParserContext,
882-
JsonParseMode,
883-
ParseJsonOptions
847+
JsonValue
884848
}
885849
}
886850
export { json }
887851

888-
// @public (undocumented)
852+
// @public
889853
export interface JsonArray extends Array<JsonValue> {
890854
}
891855

892-
// @public (undocumented)
893-
export interface JsonAstArray extends JsonAstNodeBase {
894-
// (undocumented)
895-
readonly elements: JsonAstNode[];
896-
// (undocumented)
897-
readonly kind: 'array';
898-
// (undocumented)
899-
readonly value: JsonArray;
900-
}
901-
902-
// @public (undocumented)
903-
export interface JsonAstComment extends JsonAstNodeBase {
904-
// (undocumented)
905-
readonly content: string;
906-
// (undocumented)
907-
readonly kind: 'comment';
908-
}
909-
910-
// @public (undocumented)
911-
export interface JsonAstConstantFalse extends JsonAstNodeBase {
912-
// (undocumented)
913-
readonly kind: 'false';
914-
// (undocumented)
915-
readonly value: false;
916-
}
917-
918-
// @public (undocumented)
919-
export interface JsonAstConstantNull extends JsonAstNodeBase {
920-
// (undocumented)
921-
readonly kind: 'null';
922-
// (undocumented)
923-
readonly value: null;
924-
}
925-
926-
// @public (undocumented)
927-
export interface JsonAstConstantTrue extends JsonAstNodeBase {
928-
// (undocumented)
929-
readonly kind: 'true';
930-
// (undocumented)
931-
readonly value: true;
932-
}
933-
934-
// @public (undocumented)
935-
export interface JsonAstIdentifier extends JsonAstNodeBase {
936-
// (undocumented)
937-
readonly kind: 'identifier';
938-
// (undocumented)
939-
readonly value: string;
940-
}
941-
942-
// @public (undocumented)
943-
export interface JsonAstKeyValue extends JsonAstNodeBase {
944-
// (undocumented)
945-
readonly key: JsonAstString | JsonAstIdentifier;
946-
// (undocumented)
947-
readonly kind: 'keyvalue';
948-
// (undocumented)
949-
readonly value: JsonAstNode;
950-
}
951-
952-
// @public (undocumented)
953-
export interface JsonAstMultilineComment extends JsonAstNodeBase {
954-
// (undocumented)
955-
readonly content: string;
956-
// (undocumented)
957-
readonly kind: 'multicomment';
958-
}
959-
960-
// @public (undocumented)
961-
export type JsonAstNode = JsonAstNumber | JsonAstString | JsonAstIdentifier | JsonAstArray | JsonAstObject | JsonAstConstantFalse | JsonAstConstantNull | JsonAstConstantTrue;
962-
963-
// @public (undocumented)
964-
export interface JsonAstNodeBase {
965-
// (undocumented)
966-
readonly comments?: (JsonAstComment | JsonAstMultilineComment)[];
967-
// (undocumented)
968-
readonly end: Position;
969-
// (undocumented)
970-
readonly start: Position;
971-
// (undocumented)
972-
readonly text: string;
973-
}
974-
975-
// @public (undocumented)
976-
export interface JsonAstNumber extends JsonAstNodeBase {
977-
// (undocumented)
978-
readonly kind: 'number';
979-
// (undocumented)
980-
readonly value: number;
981-
}
982-
983-
// @public (undocumented)
984-
export interface JsonAstObject extends JsonAstNodeBase {
985-
// (undocumented)
986-
readonly kind: 'object';
987-
// (undocumented)
988-
readonly properties: JsonAstKeyValue[];
989-
// (undocumented)
990-
readonly value: JsonObject;
991-
}
992-
993-
// @public (undocumented)
994-
export interface JsonAstString extends JsonAstNodeBase {
995-
// (undocumented)
996-
readonly kind: 'string';
997-
// (undocumented)
998-
readonly value: string;
999-
}
1000-
1001-
// @public (undocumented)
1002-
export class JsonException extends BaseException {
1003-
}
1004-
1005856
// @public (undocumented)
1006857
export interface JsonObject {
1007858
// (undocumented)
1008859
[prop: string]: JsonValue;
1009860
}
1010861

1011-
// @public
1012-
export enum JsonParseMode {
1013-
// (undocumented)
1014-
CommentsAllowed = 1,
1015-
// (undocumented)
1016-
Default = 0,
1017-
// (undocumented)
1018-
HexadecimalNumberAllowed = 16,
1019-
// (undocumented)
1020-
IdentifierKeyNamesAllowed = 4,
1021-
// (undocumented)
1022-
Json = 0,
1023-
// (undocumented)
1024-
Json5 = 255,
1025-
// (undocumented)
1026-
LaxNumberParsingAllowed = 64,
1027-
// (undocumented)
1028-
Loose = 255,
1029-
// (undocumented)
1030-
MultiLineStringAllowed = 32,
1031-
// (undocumented)
1032-
NumberConstantsAllowed = 128,
1033-
// (undocumented)
1034-
SingleQuotesAllowed = 2,
1035-
// (undocumented)
1036-
Strict = 0,
1037-
// (undocumented)
1038-
TrailingCommasAllowed = 8
1039-
}
1040-
1041-
// @public @deprecated
1042-
export interface JsonParserContext {
1043-
// (undocumented)
1044-
readonly mode: JsonParseMode;
1045-
// (undocumented)
1046-
readonly original: string;
1047-
// (undocumented)
1048-
position: Position;
1049-
// (undocumented)
1050-
previous: Position;
1051-
}
1052-
1053862
// @public (undocumented)
1054863
type JsonPointer = string & {
1055864
__PRIVATE_DEVKIT_JSON_POINTER: void;
@@ -1065,7 +874,7 @@ interface JsonSchemaVisitor {
1065874
}
1066875

1067876
// @public (undocumented)
1068-
export type JsonValue = JsonAstNode['value'];
877+
export type JsonValue = boolean | string | number | JsonArray | JsonObject | null;
1069878

1070879
// @public (undocumented)
1071880
interface JsonVisitor {
@@ -1368,17 +1177,6 @@ interface PageviewOptions extends CustomDimensionsAndMetricsOptions {
13681177
title?: string;
13691178
}
13701179

1371-
// @public @deprecated
1372-
export function parseJson(input: string, mode?: JsonParseMode, options?: ParseJsonOptions): JsonValue;
1373-
1374-
// @public @deprecated
1375-
export function parseJsonAst(input: string, mode?: JsonParseMode): JsonAstNode;
1376-
1377-
// @public @deprecated
1378-
export interface ParseJsonOptions {
1379-
path?: string;
1380-
}
1381-
13821180
// @public (undocumented)
13831181
function parseJsonPointer(pointer: JsonPointer): string[];
13841182

@@ -1440,15 +1238,6 @@ export class PathMustBeAbsoluteException extends BaseException {
14401238
constructor(path: string);
14411239
}
14421240

1443-
// @public @deprecated
1444-
export class PathSpecificJsonException extends JsonException {
1445-
constructor(path: string, exception: JsonException);
1446-
// (undocumented)
1447-
exception: JsonException;
1448-
// (undocumented)
1449-
path: string;
1450-
}
1451-
14521241
// @public (undocumented)
14531242
class PatternMatchingHost<StatsT extends object = {}> extends ResolverHost<StatsT> {
14541243
// (undocumented)
@@ -1459,16 +1248,6 @@ class PatternMatchingHost<StatsT extends object = {}> extends ResolverHost<Stats
14591248
protected _resolve(path: Path): Path;
14601249
}
14611250

1462-
// @public
1463-
export interface Position {
1464-
// (undocumented)
1465-
readonly character: number;
1466-
// (undocumented)
1467-
readonly line: number;
1468-
// (undocumented)
1469-
readonly offset: number;
1470-
}
1471-
14721251
// @public (undocumented)
14731252
export type PosixPath = string & {
14741253
__PRIVATE_DEVKIT_POSIX_PATH: void;
@@ -2083,9 +1862,9 @@ export interface TemplateAst {
20831862
// @public
20841863
export interface TemplateAstBase {
20851864
// (undocumented)
2086-
end: Position_2;
1865+
end: Position;
20871866
// (undocumented)
2088-
start: Position_2;
1867+
start: Position;
20891868
}
20901869

20911870
// @public
@@ -2244,11 +2023,6 @@ function trimNewlines(strings: TemplateStringsArray, ...values: any[]): string;
22442023
// @public
22452024
function underscore(str: string): string;
22462025

2247-
// @public @deprecated
2248-
export class UnexpectedEndOfInputException extends JsonException {
2249-
constructor(_context: JsonParserContext);
2250-
}
2251-
22522026
// @public (undocumented)
22532027
export class UnimplementedException extends BaseException {
22542028
constructor();

packages/angular_devkit/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"core"
99
],
1010
"dependencies": {
11-
"ajv": "8.6.2",
1211
"ajv-formats": "2.1.0",
12+
"ajv": "8.6.2",
1313
"fast-json-stable-stringify": "2.1.0",
1414
"magic-string": "0.25.7",
1515
"rxjs": "6.6.7",

packages/angular_devkit/core/src/json/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88

99
import * as schema from './schema/index';
1010

11-
export * from './interface';
12-
export * from './parser';
11+
export * from './utils';
1312
export { schema };

packages/angular_devkit/core/src/json/parser.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* eslint-disable no-constant-condition */
1010
import { BaseException } from '../exception';
1111
import {
12-
JsonArray,
1312
JsonAstArray,
1413
JsonAstComment,
1514
JsonAstConstantFalse,
@@ -22,16 +21,16 @@ import {
2221
JsonAstNumber,
2322
JsonAstObject,
2423
JsonAstString,
25-
JsonObject,
26-
JsonValue,
2724
Position,
28-
} from './interface';
25+
} from './parser_ast';
26+
import { JsonArray, JsonObject, JsonValue } from './utils';
2927

3028
export class JsonException extends BaseException {}
3129

3230
/**
3331
* A character was invalid in this context.
34-
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
32+
* @deprecated
33+
* @private
3534
*/
3635
export class InvalidJsonCharacterException extends JsonException {
3736
invalidChar: string;
@@ -53,7 +52,8 @@ export class InvalidJsonCharacterException extends JsonException {
5352

5453
/**
5554
* More input was expected, but we reached the end of the stream.
56-
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
55+
* @deprecated
56+
* @private
5757
*/
5858
export class UnexpectedEndOfInputException extends JsonException {
5959
constructor(_context: JsonParserContext) {

0 commit comments

Comments
 (0)