@angular-devkit/core 14.0.0-next.7 → 14.0.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.
@@ -7,201 +7,89 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createVirtualAstObject = exports.unescapeKey = exports.escapeKey = void 0;
11
- const stableStringify = require('fast-json-stable-stringify');
12
- function findNode(parent, p) {
13
- if (parent.kind === 'object') {
14
- const entry = parent.properties.find((entry) => entry.key.value === p);
15
- if (entry) {
16
- return { node: entry.value, parent: entry };
10
+ exports.createVirtualAstObject = void 0;
11
+ const json_1 = require("../../json");
12
+ function createVirtualAstObject(root, options = {}) {
13
+ var _a;
14
+ const reporter = (path, target, oldValue, newValue) => {
15
+ if (!options.listener) {
16
+ return;
17
17
  }
18
- }
19
- else {
20
- const index = Number(p);
21
- if (!isNaN(index)) {
22
- return { node: parent.elements[index], parent };
18
+ if (oldValue === newValue || JSON.stringify(oldValue) === JSON.stringify(newValue)) {
19
+ // same value
20
+ return;
23
21
  }
24
- }
25
- return { parent };
26
- }
27
- function createPropertyDescriptor(value) {
28
- return {
29
- configurable: true,
30
- enumerable: true,
31
- writable: true,
32
- value,
33
- };
34
- }
35
- function escapeKey(key) {
36
- if (typeof key === 'number') {
37
- return key;
38
- }
39
- return key.replace('~', '~0').replace('/', '~1');
40
- }
41
- exports.escapeKey = escapeKey;
42
- function unescapeKey(key) {
43
- if (typeof key === 'number') {
44
- return key;
45
- }
46
- return key.replace('~1', '/').replace('~0', '~');
47
- }
48
- exports.unescapeKey = unescapeKey;
49
- function createVirtualAstObject(root, options = {}) {
50
- const reporter = (path, parent, node, old, current) => {
51
- if (options.listener) {
52
- if (old === current || stableStringify(old) === stableStringify(current)) {
53
- return;
54
- }
55
- const op = old === undefined ? 'add' : current === undefined ? 'remove' : 'replace';
56
- options.listener(op, path, parent, current);
22
+ if (Array.isArray(target)) {
23
+ // For arrays we remove the index and update the entire value as keeping
24
+ // track of changes by indices can be rather complex.
25
+ options.listener(path.slice(0, -1), target);
26
+ }
27
+ else {
28
+ options.listener(path, newValue);
57
29
  }
58
30
  };
59
- return create(root, '', reporter, new Set(options.exclude), options.include && options.include.length > 0 ? new Set(options.include) : undefined, options.base);
31
+ return create(Array.isArray(root) ? [...root] : { ...root }, [], reporter, new Set(options.exclude), ((_a = options.include) === null || _a === void 0 ? void 0 : _a.length) ? new Set(options.include) : undefined);
60
32
  }
61
33
  exports.createVirtualAstObject = createVirtualAstObject;
62
- function create(ast, path, reporter, excluded = new Set(), included, base) {
63
- const cache = new Map();
64
- const alteredNodes = new Set();
65
- if (!base) {
66
- if (ast.kind === 'object') {
67
- base = Object.create(null);
68
- }
69
- else {
70
- base = [];
71
- base.length = ast.elements.length;
72
- }
73
- }
74
- return new Proxy(base, {
34
+ function create(obj, path, reporter, excluded = new Set(), included) {
35
+ return new Proxy(obj, {
75
36
  getOwnPropertyDescriptor(target, p) {
76
- const descriptor = Reflect.getOwnPropertyDescriptor(target, p);
77
- if (descriptor || typeof p === 'symbol') {
78
- return descriptor;
79
- }
80
- else if (excluded.has(p) || (included && !included.has(p))) {
37
+ if (excluded.has(p) || (included && !included.has(p))) {
81
38
  return undefined;
82
39
  }
83
- const propertyPath = path + '/' + escapeKey(p);
84
- const cacheEntry = cache.get(propertyPath);
85
- if (cacheEntry) {
86
- if (cacheEntry.value !== undefined) {
87
- return createPropertyDescriptor(cacheEntry.value);
88
- }
89
- return undefined;
90
- }
91
- const { node } = findNode(ast, p);
92
- if (node) {
93
- return createPropertyDescriptor(node.value);
94
- }
95
- return undefined;
40
+ return Reflect.getOwnPropertyDescriptor(target, p);
96
41
  },
97
42
  has(target, p) {
98
- if (Reflect.has(target, p)) {
99
- return true;
100
- }
101
- else if (typeof p === 'symbol' || excluded.has(p)) {
43
+ if (typeof p === 'symbol' || excluded.has(p)) {
102
44
  return false;
103
45
  }
104
- return cache.has(path + '/' + escapeKey(p)) || findNode(ast, p) !== undefined;
46
+ return Reflect.has(target, p);
105
47
  },
106
48
  get(target, p) {
107
- if (typeof p === 'symbol' || Reflect.has(target, p)) {
108
- return Reflect.get(target, p);
109
- }
110
- else if (excluded.has(p) || (included && !included.has(p))) {
49
+ if (excluded.has(p) || (included && !included.has(p))) {
111
50
  return undefined;
112
51
  }
113
- const propertyPath = path + '/' + escapeKey(p);
114
- const cacheEntry = cache.get(propertyPath);
115
- if (cacheEntry) {
116
- return cacheEntry.value;
52
+ const value = Reflect.get(target, p);
53
+ if (typeof p === 'symbol') {
54
+ return value;
117
55
  }
118
- const { node, parent } = findNode(ast, p);
119
- let value;
120
- if (node) {
121
- if (node.kind === 'object' || node.kind === 'array') {
122
- value = create(node, propertyPath, (path, parent, vnode, old, current) => {
123
- if (!alteredNodes.has(node)) {
124
- reporter(path, parent, vnode, old, current);
125
- }
126
- });
127
- }
128
- else {
129
- value = node.value;
130
- }
131
- cache.set(propertyPath, { node, parent, value });
56
+ if (((0, json_1.isJsonObject)(value) && !(value instanceof Map)) || Array.isArray(value)) {
57
+ return create(value, [...path, p], reporter);
58
+ }
59
+ else {
60
+ return value;
132
61
  }
133
- return value;
134
62
  },
135
63
  set(target, p, value) {
64
+ var _a, _b;
65
+ if (excluded.has(p) || (included && !included.has(p))) {
66
+ return false;
67
+ }
136
68
  if (value === undefined) {
137
- // setting to undefined is equivalent to a delete
138
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
139
- return this.deleteProperty(target, p);
69
+ // setting to undefined is equivalent to a delete.
70
+ return (_b = (_a = this.deleteProperty) === null || _a === void 0 ? void 0 : _a.call(this, target, p)) !== null && _b !== void 0 ? _b : false;
140
71
  }
141
- if (typeof p === 'symbol' || Reflect.has(target, p)) {
72
+ if (typeof p === 'symbol') {
142
73
  return Reflect.set(target, p, value);
143
74
  }
144
- else if (excluded.has(p) || (included && !included.has(p))) {
145
- return false;
146
- }
147
- // TODO: Check if is JSON value
148
- const jsonValue = value;
149
- const propertyPath = path + '/' + escapeKey(p);
150
- const cacheEntry = cache.get(propertyPath);
151
- if (cacheEntry) {
152
- const oldValue = cacheEntry.value;
153
- cacheEntry.value = value;
154
- if (cacheEntry.node && oldValue !== value) {
155
- alteredNodes.add(cacheEntry.node);
156
- }
157
- reporter(propertyPath, cacheEntry.parent, cacheEntry.node, oldValue, jsonValue);
158
- }
159
- else {
160
- const { node, parent } = findNode(ast, p);
161
- cache.set(propertyPath, { node, parent, value: value });
162
- if (node && node.value !== value) {
163
- alteredNodes.add(node);
164
- }
165
- reporter(propertyPath, parent, node, node && node.value, value);
75
+ const existingValue = getCurrentValue(target, p);
76
+ if (Reflect.set(target, p, value)) {
77
+ reporter([...path, p], target, existingValue, value);
78
+ return true;
166
79
  }
167
- return true;
80
+ return false;
168
81
  },
169
82
  deleteProperty(target, p) {
170
- if (typeof p === 'symbol' || Reflect.has(target, p)) {
171
- return Reflect.deleteProperty(target, p);
172
- }
173
- else if (excluded.has(p) || (included && !included.has(p))) {
83
+ if (excluded.has(p)) {
174
84
  return false;
175
85
  }
176
- const propertyPath = path + '/' + escapeKey(p);
177
- const cacheEntry = cache.get(propertyPath);
178
- if (cacheEntry) {
179
- const oldValue = cacheEntry.value;
180
- cacheEntry.value = undefined;
181
- if (cacheEntry.node) {
182
- alteredNodes.add(cacheEntry.node);
183
- }
184
- if (cacheEntry.parent.kind === 'keyvalue') {
185
- // Remove the entire key/value pair from this JSON object
186
- reporter(propertyPath, ast, cacheEntry.node, oldValue, undefined);
187
- }
188
- else {
189
- reporter(propertyPath, cacheEntry.parent, cacheEntry.node, oldValue, undefined);
190
- }
86
+ if (typeof p === 'symbol') {
87
+ return Reflect.deleteProperty(target, p);
191
88
  }
192
- else {
193
- const { node, parent } = findNode(ast, p);
194
- if (node) {
195
- cache.set(propertyPath, { node, parent, value: undefined });
196
- alteredNodes.add(node);
197
- if (parent.kind === 'keyvalue') {
198
- // Remove the entire key/value pair from this JSON object
199
- reporter(propertyPath, ast, node, node && node.value, undefined);
200
- }
201
- else {
202
- reporter(propertyPath, parent, node, node && node.value, undefined);
203
- }
204
- }
89
+ const existingValue = getCurrentValue(target, p);
90
+ if (Reflect.deleteProperty(target, p)) {
91
+ reporter([...path, p], target, existingValue, undefined);
92
+ return true;
205
93
  }
206
94
  return true;
207
95
  },
@@ -212,22 +100,16 @@ function create(ast, path, reporter, excluded = new Set(), included, base) {
212
100
  return false;
213
101
  },
214
102
  ownKeys(target) {
215
- let keys;
216
- if (ast.kind === 'object') {
217
- keys = ast.properties
218
- .map((entry) => entry.key.value)
219
- .filter((p) => !excluded.has(p) && (!included || included.has(p)));
220
- }
221
- else {
222
- keys = [];
223
- }
224
- for (const key of cache.keys()) {
225
- const relativeKey = key.slice(path.length + 1);
226
- if (relativeKey.length > 0 && !relativeKey.includes('/')) {
227
- keys.push(`${unescapeKey(relativeKey)}`);
228
- }
229
- }
230
- return [...new Set([...keys, ...Reflect.ownKeys(target)])];
103
+ return Reflect.ownKeys(target).filter((p) => !excluded.has(p) && (!included || included.has(p)));
231
104
  },
232
105
  });
233
106
  }
107
+ function getCurrentValue(target, property) {
108
+ if (Array.isArray(target) && isFinite(+property)) {
109
+ return target[+property];
110
+ }
111
+ if (target && property in target) {
112
+ return target[property];
113
+ }
114
+ return undefined;
115
+ }
@@ -6,24 +6,19 @@
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
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  exports.writeJsonWorkspace = void 0;
14
- const magic_string_1 = __importDefault(require("magic-string"));
11
+ const jsonc_parser_1 = require("jsonc-parser");
15
12
  const metadata_1 = require("./metadata");
16
- const utilities_1 = require("./utilities");
17
13
  async function writeJsonWorkspace(workspace, host, path, options = {}) {
18
14
  const metadata = workspace[metadata_1.JsonWorkspaceSymbol];
19
15
  if (metadata) {
20
16
  if (!metadata.hasChanges) {
21
- // nothing to do
22
17
  return;
23
18
  }
24
19
  // update existing JSON workspace
25
20
  const data = updateJsonWorkspace(metadata);
26
- return host.writeFile(path || metadata.filePath, data);
21
+ return host.writeFile(path !== null && path !== void 0 ? path : metadata.filePath, data);
27
22
  }
28
23
  else {
29
24
  // serialize directly
@@ -91,206 +86,45 @@ function convertJsonTargetCollection(collection) {
91
86
  }
92
87
  return targets;
93
88
  }
94
- function findFullStart(node, raw) {
95
- let i = node.start.offset;
96
- while (i > 0 && /\s/.test(raw[i - 1])) {
97
- --i;
98
- }
99
- return i;
100
- }
101
- function findFullEnd(node, raw) {
102
- let i = node.end.offset;
103
- if (i >= raw.length) {
104
- return raw.length;
105
- }
106
- else if (raw[i] === ',') {
107
- return i + 1;
108
- }
109
- while (i > node.start.offset && /\s/.test(raw[i - 1])) {
110
- --i;
111
- }
112
- return i;
113
- }
114
- function findPrecedingComma(node, raw) {
115
- let i = node.start.offset;
116
- if (node.comments && node.comments.length > 0) {
117
- i = node.comments[0].start.offset;
118
- }
119
- while (i > 0 && /\s/.test(raw[i - 1])) {
120
- --i;
121
- }
122
- if (raw[i - 1] === ',') {
123
- return i - 1;
124
- }
125
- return -1;
126
- }
127
- function stringify(value, multiline, depth, indent) {
89
+ function normalizeValue(value, type) {
128
90
  if (value === undefined) {
129
- return '';
130
- }
131
- if (multiline) {
132
- const content = JSON.stringify(value, null, indent);
133
- const spacing = '\n' + indent.repeat(depth);
134
- return content.replace(/\n/g, spacing);
91
+ return undefined;
135
92
  }
136
- else {
137
- return JSON.stringify(value);
138
- }
139
- }
140
- function normalizeValue(value, type) {
141
93
  switch (type) {
142
94
  case 'project':
143
95
  return convertJsonProject(value);
144
96
  case 'projectcollection':
145
97
  const projects = convertJsonProjectCollection(value);
146
- return Object.keys(projects).length === 0 ? undefined : projects;
98
+ return isEmpty(projects) ? undefined : projects;
147
99
  case 'target':
148
100
  return convertJsonTarget(value);
149
101
  case 'targetcollection':
150
102
  const targets = convertJsonTargetCollection(value);
151
- return Object.keys(targets).length === 0 ? undefined : targets;
103
+ return isEmpty(targets) ? undefined : targets;
152
104
  default:
153
105
  return value;
154
106
  }
155
107
  }
156
108
  function updateJsonWorkspace(metadata) {
157
- const data = new magic_string_1.default(metadata.raw);
158
- const indent = data.getIndentString();
159
- const removedCommas = new Set();
160
- const nodeChanges = new Map();
161
- for (const { op, path, node, value, type } of metadata.changes) {
162
- // targets/projects are typically large objects so always use multiline
163
- const multiline = node.start.line !== node.end.line || type !== 'json';
164
- const pathSegments = path.split('/');
165
- const depth = pathSegments.length - 1; // TODO: more complete analysis
166
- const propertyOrIndex = (0, utilities_1.unescapeKey)(pathSegments[depth]);
167
- const jsonValue = normalizeValue(value, type);
168
- if (op === 'add' && jsonValue === undefined) {
169
- continue;
170
- }
171
- // Track changes to the order/size of any modified objects/arrays
172
- let elements = nodeChanges.get(node);
173
- if (!elements) {
174
- if (node.kind === 'array') {
175
- elements = node.elements.slice();
176
- nodeChanges.set(node, elements);
177
- }
178
- else if (node.kind === 'object') {
179
- elements = node.properties.slice();
180
- nodeChanges.set(node, elements);
181
- }
182
- else {
183
- // keyvalue
184
- elements = [];
185
- }
186
- }
187
- switch (op) {
188
- case 'add':
189
- let contentPrefix = '';
190
- if (node.kind === 'object') {
191
- contentPrefix = `"${propertyOrIndex}": `;
192
- }
193
- const spacing = multiline ? '\n' + indent.repeat(depth) : ' ';
194
- const content = spacing + contentPrefix + stringify(jsonValue, multiline, depth, indent);
195
- // Additions are handled after analyzing all operations
196
- // This is mainly to support array operations which can occur at arbitrary indices
197
- if (node.kind === 'object') {
198
- // Object property additions are always added at the end for simplicity
199
- elements.push(content);
200
- }
201
- else {
202
- // Add place holders if adding an index past the length
203
- // An empty string is an impossible real value
204
- for (let i = elements.length; i < +propertyOrIndex; ++i) {
205
- elements[i] = '';
206
- }
207
- if (elements[+propertyOrIndex] === '') {
208
- elements[+propertyOrIndex] = content;
209
- }
210
- else {
211
- elements.splice(+propertyOrIndex, 0, content);
212
- }
213
- }
214
- break;
215
- case 'remove':
216
- let removalIndex = -1;
217
- if (node.kind === 'object') {
218
- removalIndex = elements.findIndex((e) => {
219
- return typeof e != 'string' && e.kind === 'keyvalue' && e.key.value === propertyOrIndex;
220
- });
221
- }
222
- else if (node.kind === 'array') {
223
- removalIndex = +propertyOrIndex;
224
- }
225
- if (removalIndex === -1) {
226
- continue;
227
- }
228
- const nodeToRemove = elements[removalIndex];
229
- if (typeof nodeToRemove === 'string') {
230
- // synthetic
231
- elements.splice(removalIndex, 1);
232
- continue;
233
- }
234
- if (elements.length - 1 === removalIndex) {
235
- // If the element is a terminal element remove the otherwise trailing comma
236
- const commaIndex = findPrecedingComma(nodeToRemove, data.original);
237
- if (commaIndex !== -1) {
238
- data.remove(commaIndex, commaIndex + 1);
239
- removedCommas.add(commaIndex);
240
- }
241
- }
242
- data.remove(findFullStart(nodeToRemove, data.original), findFullEnd(nodeToRemove, data.original));
243
- elements.splice(removalIndex, 1);
244
- break;
245
- case 'replace':
246
- let nodeToReplace;
247
- if (node.kind === 'keyvalue') {
248
- nodeToReplace = node.value;
249
- }
250
- else if (node.kind === 'array') {
251
- nodeToReplace = elements[+propertyOrIndex];
252
- if (typeof nodeToReplace === 'string') {
253
- // Was already modified. This is already handled.
254
- continue;
255
- }
256
- }
257
- else {
258
- continue;
259
- }
260
- nodeChanges.delete(nodeToReplace);
261
- data.overwrite(nodeToReplace.start.offset, nodeToReplace.end.offset, stringify(jsonValue, multiline, depth, indent));
262
- break;
109
+ let { raw: content } = metadata;
110
+ const { changes, hasLegacyTargetsName } = metadata;
111
+ for (const { jsonPath, value, type } of changes.values()) {
112
+ // Determine which key to use if (architect or targets)
113
+ if (hasLegacyTargetsName && jsonPath[2] === 'targets') {
114
+ jsonPath[2] = 'architect';
263
115
  }
264
- }
265
- for (const [node, elements] of nodeChanges.entries()) {
266
- let parentPoint = 1 + data.original.indexOf(node.kind === 'array' ? '[' : '{', node.start.offset);
267
- // Short-circuit for simple case
268
- if (elements.length === 1 && typeof elements[0] === 'string') {
269
- data.appendRight(parentPoint, elements[0]);
270
- continue;
271
- }
272
- // Combine adjecent element additions to minimize/simplify insertions
273
- const optimizedElements = [];
274
- for (let i = 0; i < elements.length; ++i) {
275
- const element = elements[i];
276
- if (typeof element === 'string' && i > 0 && typeof elements[i - 1] === 'string') {
277
- optimizedElements[optimizedElements.length - 1] += ',' + element;
278
- }
279
- else {
280
- optimizedElements.push(element);
281
- }
282
- }
283
- let prefixComma = false;
284
- for (const element of optimizedElements) {
285
- if (typeof element === 'string') {
286
- data.appendRight(parentPoint, (prefixComma ? ',' : '') + element);
287
- }
288
- else {
289
- parentPoint = findFullEnd(element, data.original);
290
- prefixComma = data.original[parentPoint - 1] !== ',' || removedCommas.has(parentPoint - 1);
291
- }
292
- }
293
- }
294
- const result = data.toString();
295
- return result;
116
+ // modify
117
+ const newJsonPath = jsonPath.map((v) => (isFinite(+v) ? +v : v));
118
+ // TODO: `modify` re-parses the content every time.
119
+ // See: https://github.com/microsoft/node-jsonc-parser/blob/35d94cd71bd48f9784453b2439262c938e21d49b/src/impl/edit.ts#L18
120
+ // Ideally this should accept a string or an AST to avoid the potentially expensive repeat parsing operation.
121
+ const edits = (0, jsonc_parser_1.modify)(content, newJsonPath, normalizeValue(value, type), {
122
+ formattingOptions: {
123
+ insertSpaces: true,
124
+ tabSize: 2,
125
+ },
126
+ });
127
+ content = (0, jsonc_parser_1.applyEdits)(content, edits);
128
+ }
129
+ return content;
296
130
  }
@@ -1,104 +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 '../exception';
9
- import { JsonAstNode, Position } from './parser_ast';
10
- import { JsonValue } from './utils';
11
- export declare class JsonException extends BaseException {
12
- }
13
- /**
14
- * A character was invalid in this context.
15
- * @deprecated
16
- * @private
17
- */
18
- export declare class InvalidJsonCharacterException extends JsonException {
19
- invalidChar: string;
20
- line: number;
21
- character: number;
22
- offset: number;
23
- constructor(context: JsonParserContext);
24
- }
25
- /**
26
- * More input was expected, but we reached the end of the stream.
27
- * @deprecated
28
- * @private
29
- */
30
- export declare class UnexpectedEndOfInputException extends JsonException {
31
- constructor(_context: JsonParserContext);
32
- }
33
- /**
34
- * An error happened within a file.
35
- * @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
36
- */
37
- export declare class PathSpecificJsonException extends JsonException {
38
- path: string;
39
- exception: JsonException;
40
- constructor(path: string, exception: JsonException);
41
- }
42
- /**
43
- * Context passed around the parser with information about where we currently are in the parse.
44
- * @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
45
- */
46
- export interface JsonParserContext {
47
- position: Position;
48
- previous: Position;
49
- readonly original: string;
50
- readonly mode: JsonParseMode;
51
- }
52
- /**
53
- * The Parse mode used for parsing the JSON string.
54
- */
55
- export declare enum JsonParseMode {
56
- Strict = 0,
57
- CommentsAllowed = 1,
58
- SingleQuotesAllowed = 2,
59
- IdentifierKeyNamesAllowed = 4,
60
- TrailingCommasAllowed = 8,
61
- HexadecimalNumberAllowed = 16,
62
- MultiLineStringAllowed = 32,
63
- LaxNumberParsingAllowed = 64,
64
- NumberConstantsAllowed = 128,
65
- Default = 0,
66
- Loose = 255,
67
- Json = 0,
68
- Json5 = 255
69
- }
70
- /**
71
- * Parse the JSON string and return its AST. The AST may be losing data (end comments are
72
- * discarded for example, and space characters are not represented in the AST), but all values
73
- * will have a single node in the AST (a 1-to-1 mapping).
74
- *
75
- * @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
76
- * @param input The string to use.
77
- * @param mode The mode to parse the input with. {@see JsonParseMode}.
78
- * @returns {JsonAstNode} The root node of the value of the AST.
79
- */
80
- export declare function parseJsonAst(input: string, mode?: JsonParseMode): JsonAstNode;
81
- /**
82
- * Options for the parseJson() function.
83
- * @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
84
- */
85
- export interface ParseJsonOptions {
86
- /**
87
- * If omitted, will only emit errors related to the content of the JSON. If specified, any
88
- * JSON errors will also include the path of the file that caused the error.
89
- */
90
- path?: string;
91
- }
92
- /**
93
- * Parse a JSON string into its value. This discards the AST and only returns the value itself.
94
- *
95
- * If a path option is pass, it also absorbs JSON parsing errors and return a new error with the
96
- * path in it. Useful for showing errors when parsing from a file.
97
- *
98
- * @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
99
- * @param input The string to parse.
100
- * @param mode The mode to parse the input with. {@see JsonParseMode}.
101
- * @param options Additional optinos for parsing.
102
- * @returns {JsonValue} The value represented by the JSON string.
103
- */
104
- export declare function parseJson(input: string, mode?: JsonParseMode, options?: ParseJsonOptions): JsonValue;